From 1dbd0dff3929a5ed938740072a4add0175d5f4e1 Mon Sep 17 00:00:00 2001
From: Alex Ni <12097569+nialexsan@users.noreply.github.com>
Date: Tue, 10 Sep 2024 17:04:05 -0400
Subject: [PATCH 1/7] update default cadence code
---
src/providers/Project/projectDefault.ts | 6 +++---
test/util/generator.test.js | 20 ++++++++++----------
2 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/src/providers/Project/projectDefault.ts b/src/providers/Project/projectDefault.ts
index 7c6b6584..9cef1402 100644
--- a/src/providers/Project/projectDefault.ts
+++ b/src/providers/Project/projectDefault.ts
@@ -16,11 +16,11 @@ const HelloWorldContract = `// HelloWorld.cdc
// The HelloWorld contract contains a single string field and a public getter function.
//
// Follow the "Hello, World!" tutorial to learn more: https://docs.onflow.org/cadence/tutorial/02-hello-world/
-pub contract HelloWorld {
+access(all) contract HelloWorld {
// Declare a public field of type String.
//
// All fields must be initialized in the init() function.
- pub var greeting: String
+ access(self) var greeting: String
// Public function that sets our friendly greeting!
// In your own applications you may want to tighten up this access control.
@@ -58,7 +58,7 @@ transaction(greeting: String) {
const DEFAULT_SCRIPT = `import HelloWorld from 0x05
-pub fun main() {
+access(all) fun main() {
log(HelloWorld.hello())
}
`;
diff --git a/test/util/generator.test.js b/test/util/generator.test.js
index 3345a564..558c1898 100644
--- a/test/util/generator.test.js
+++ b/test/util/generator.test.js
@@ -36,7 +36,7 @@ describe('Generator Related Unit Tests', () => {
test('should find no imports in a script template', () => {
const template = `
- pub fun main(){
+ access(all) fun main(){
console.log("Hello")
}
`;
@@ -48,7 +48,7 @@ describe('Generator Related Unit Tests', () => {
const template = `
import First from 0x01
- pub fun main(){
+ access(all) fun main(){
console.log("Hello")
}
`;
@@ -90,7 +90,7 @@ describe('Generator Related Unit Tests', () => {
test('should return list of arguments from script template', () => {
const template = `
- pub fun main(a: Int, b: Int, recipient: Address) {
+ access(all) fun main(a: Int, b: Int, recipient: Address) {
log("hello, Jest")
}
`;
@@ -130,7 +130,7 @@ describe('Generator Related Unit Tests', () => {
test('should return empty list of arguments from script with no arguments', () => {
const template = `
- pub fun main() {
+ access(all) fun main() {
log("no args here")
}
`;
@@ -232,7 +232,7 @@ describe('Generator Related Unit Tests', () => {
describe('Generator - Contracts', () => {
test('should deploy contract', () => {
const template = `
- pub contract HelloWorld {
+ access(all) contract HelloWorld {
init(){
log("Hello, World")
}
@@ -248,7 +248,7 @@ describe('Generator - Contracts', () => {
import First from 0x01
import Second from 0x02
- pub contract HelloWorld {
+ access(all) contract HelloWorld {
init(){
log("Hello, World")
}
@@ -263,7 +263,7 @@ describe('Generator - Contracts', () => {
describe('Generator - Scripts', () => {
test('should create proper code - basic', () => {
const template = `
- pub fun main() {
+ access(all) fun main() {
return "Hello, Jest"
}
`;
@@ -274,7 +274,7 @@ describe('Generator - Scripts', () => {
});
test('should create proper code - return type and getAccount call', () => {
const template = `
- pub fun main(): String {
+ access(all) fun main(): String {
let Dave = getAccount(0x04)
return "Hello, Jest"
}
@@ -290,7 +290,7 @@ describe('Generator - Scripts', () => {
import Second from 0x02
import Third from 0x03
- pub fun main(): String {
+ access(all) fun main(): String {
let Dave = getAccount(0x04)
return "Hello, Jest"
}
@@ -306,7 +306,7 @@ describe('Generator - Scripts', () => {
import Second from 0x02
import Third from 0x03
- pub fun main(a: Int, b: Int, c: String, d:Address): String {
+ access(all) fun main(a: Int, b: Int, c: String, d:Address): String {
let Dave = getAccount(0x04)
return "Hello, Jest"
}
From 1e3ffabe0f7238410536e93ccbe1c26987753e60 Mon Sep 17 00:00:00 2001
From: Alex Ni <12097569+nialexsan@users.noreply.github.com>
Date: Wed, 11 Sep 2024 10:12:50 -0400
Subject: [PATCH 2/7] remove announcement
---
src/components/TopNav/Announcement.tsx | 90 --------------------------
src/components/TopNav/Header.tsx | 7 +-
src/containers/Playground/index.tsx | 15 +----
src/providers/Announcement/index.tsx | 42 ------------
4 files changed, 3 insertions(+), 151 deletions(-)
delete mode 100644 src/components/TopNav/Announcement.tsx
delete mode 100644 src/providers/Announcement/index.tsx
diff --git a/src/components/TopNav/Announcement.tsx b/src/components/TopNav/Announcement.tsx
deleted file mode 100644
index 76085843..00000000
--- a/src/components/TopNav/Announcement.tsx
+++ /dev/null
@@ -1,90 +0,0 @@
-import TimesIcon from 'components/Icons/TimesIcon';
-import { AnnouncementContext } from 'providers/Announcement';
-import React, { useContext } from 'react';
-import { SXStyles } from 'src/types';
-import { Box, Flex, IconButton, Link, useThemeUI } from 'theme-ui';
-
-const Announcement = () => {
- const context = useThemeUI();
- const { theme } = context;
-
- const { toggleAnnouncement } = useContext(AnnouncementContext);
-
- const styles: SXStyles = {
- root: {
- width: '100%',
- backgroundColor: 'white',
- flex: '1 1 auto',
- flexDirection: 'row',
- background: '#007BFF',
- padding: '0.25rem 0 0.5rem',
- height: '60px',
- color: `${theme.colors.secondary}`,
- justifyContent: 'space-around',
- alignContent: 'center',
- },
- content: {
- flex: '1 1 auto',
- justifyContent: 'space-between',
- flexDirection: 'column',
- alignItems: 'center',
- },
- message: {
- display: 'flex',
- justifyContent: 'center',
- alignItems: 'center',
- textAlign: 'center',
- color: `${theme.colors.secondary}`,
- fontSize: '14px',
- padding: '0.15rem',
- gap: '4px',
- },
- devLink: {
- textDecoration: 'underline',
- color: `${theme.colors.secondary}`,
- },
- };
-
- return (
-
-
- 🔧 Upgrade to Cadence 1.0 🔧
-
- The highly anticipated
-
- Crescendo
-
- network upgrade is coming soon with 20+ new
-
- Cadence 1.0
-
- features and
-
- EVM
-
- equivalence.
-
-
-
-
-
-
- );
-};
-
-export default Announcement;
diff --git a/src/components/TopNav/Header.tsx b/src/components/TopNav/Header.tsx
index 897a543c..28ce50a6 100644
--- a/src/components/TopNav/Header.tsx
+++ b/src/components/TopNav/Header.tsx
@@ -1,8 +1,5 @@
-import React, { useContext } from 'react';
-import AnnouncementBar from './Announcement';
+import React from 'react';
import TopNav from '.';
-import { isMobile } from '../Editor/CadenceEditor/ControlPanel/utils';
-import { AnnouncementContext } from 'providers/Announcement';
const headerStyle: React.CSSProperties = {
display: 'flex',
@@ -13,10 +10,8 @@ const headerStyle: React.CSSProperties = {
};
const Header = () => {
- const { isVisible: isAnnouncementVisible } = useContext(AnnouncementContext);
return (
- {!isMobile() && isAnnouncementVisible && }
);
diff --git a/src/containers/Playground/index.tsx b/src/containers/Playground/index.tsx
index 07ebac91..7586fb6e 100644
--- a/src/containers/Playground/index.tsx
+++ b/src/containers/Playground/index.tsx
@@ -14,10 +14,6 @@ import { LOCAL_PROJECT_ID } from 'util/url';
import useToggleExplorer from '../../hooks/useToggleExplorer';
import EditorLayout from './EditorLayout';
import { isMobile } from 'components/Editor/CadenceEditor/ControlPanel/utils';
-import {
- AnnouncementContext,
- AnnouncementProvider,
-} from 'providers/Announcement';
export const LEFT_SIDEBAR_WIDTH = 350;
@@ -44,7 +40,6 @@ const closeLeftSidebarButtonStyle: CSSProperties = {
const getBaseStyles = (
showProjectsSidebar: boolean,
isExplorerCollapsed: boolean,
- isAnnouncementVisible: boolean,
): ThemeUICSSObject => {
const fileExplorerWidth = isExplorerCollapsed
? isMobile()
@@ -62,9 +57,7 @@ const getBaseStyles = (
display: 'grid',
gridTemplateAreas: "'header header' 'sidebar main'",
gridTemplateColumns: `[sidebar] ${fileExplorerWidth} [main] auto`,
- gridTemplateRows: isAnnouncementVisible
- ? ['40px auto', '105px auto']
- : ['40px auto', '50px auto'],
+ gridTemplateRows: ['40px auto', '50px auto'],
overflow: 'hidden',
filter: showProjectsSidebar ? 'blur(1px)' : 'none',
};
@@ -77,12 +70,10 @@ const leftSidebarTransition = { type: 'spring', bounce: 0.2, duration: 0.25 };
const Content = () => {
const { showProjectsSidebar, toggleProjectsSidebar } = useProject();
const { isExplorerCollapsed, toggleExplorer } = useToggleExplorer();
- const { isVisible: isAnnouncementVisible } = useContext(AnnouncementContext);
const baseStyles = getBaseStyles(
showProjectsSidebar,
isExplorerCollapsed,
- isAnnouncementVisible,
);
return (
<>
@@ -213,9 +204,7 @@ const Playground = ({ projectId }: PlaygroundProps) => {
return (
-
-
-
+
);
diff --git a/src/providers/Announcement/index.tsx b/src/providers/Announcement/index.tsx
deleted file mode 100644
index afb93da7..00000000
--- a/src/providers/Announcement/index.tsx
+++ /dev/null
@@ -1,42 +0,0 @@
-import React, { createContext } from 'react';
-import { CookiesProvider, useCookies } from 'react-cookie';
-
-interface AnnouncementContextValue {
- isVisible: boolean;
- toggleAnnouncement: () => void;
-}
-
-// Create a context
-const AnnouncementContext: React.Context =
- createContext(null);
-
-const COOKIE_NAME = 'stable-cadence-announcement-dismissed';
-
-// Create a context provider component
-const _AnnounecementProvider: React.FC = ({ children }) => {
- const [cookies, setIsVisible] = useCookies([COOKIE_NAME]);
- const isVisible = !cookies[COOKIE_NAME];
-
- // in 7 days
- const futureDate = new Date(Date.now() + 7 * 24 * 60 * 60 * 1000);
-
- const toggleAnnouncement = () => {
- setIsVisible(COOKIE_NAME, !isVisible, { expires: futureDate });
- };
-
- return (
-
- {children}
-
- );
-};
-
-const AnnouncementProvider: React.FC = ({ children }) => {
- return (
-
- <_AnnounecementProvider>{children}
-
- );
-};
-
-export { AnnouncementProvider, AnnouncementContext };
From aed08266fec60a3f5bdb7679aae9f4f648df3df3 Mon Sep 17 00:00:00 2001
From: Alex Ni <12097569+nialexsan@users.noreply.github.com>
Date: Wed, 11 Sep 2024 10:42:37 -0400
Subject: [PATCH 3/7] bump
From f91b98fc1c9c5e9f1b3a7df48665b3f67e4f20f4 Mon Sep 17 00:00:00 2001
From: Alex Ni <12097569+nialexsan@users.noreply.github.com>
Date: Thu, 12 Sep 2024 17:28:04 -0400
Subject: [PATCH 4/7] linter
---
src/containers/Playground/index.tsx | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/src/containers/Playground/index.tsx b/src/containers/Playground/index.tsx
index 7586fb6e..51deb049 100644
--- a/src/containers/Playground/index.tsx
+++ b/src/containers/Playground/index.tsx
@@ -71,10 +71,7 @@ const Content = () => {
const { showProjectsSidebar, toggleProjectsSidebar } = useProject();
const { isExplorerCollapsed, toggleExplorer } = useToggleExplorer();
- const baseStyles = getBaseStyles(
- showProjectsSidebar,
- isExplorerCollapsed,
- );
+ const baseStyles = getBaseStyles(showProjectsSidebar, isExplorerCollapsed);
return (
<>
From b13535c787bc9f7533ca5b80ec65bcabff2f1c44 Mon Sep 17 00:00:00 2001
From: Alex Ni <12097569+nialexsan@users.noreply.github.com>
Date: Thu, 12 Sep 2024 18:26:18 -0400
Subject: [PATCH 5/7] types
---
src/containers/Playground/index.tsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/containers/Playground/index.tsx b/src/containers/Playground/index.tsx
index 51deb049..a3275005 100644
--- a/src/containers/Playground/index.tsx
+++ b/src/containers/Playground/index.tsx
@@ -7,7 +7,7 @@ import { AnimatePresence, motion, MotionStyle } from 'framer-motion';
import CadenceChecker from 'providers/CadenceChecker';
import { ProjectProvider } from 'providers/Project';
import useGetProject, { useProject } from 'providers/Project/projectHooks';
-import React, { CSSProperties, useContext } from 'react';
+import React, { CSSProperties } from 'react';
import { Box, Button, Spinner, ThemeUICSSObject } from 'theme-ui';
import { userDataKeys, UserLocalStorage } from 'util/localstorage';
import { LOCAL_PROJECT_ID } from 'util/url';
From e4c5d4796e574373e8542a1b20906afccc04ce23 Mon Sep 17 00:00:00 2001
From: Alex Ni <12097569+nialexsan@users.noreply.github.com>
Date: Mon, 16 Sep 2024 17:14:06 -0400
Subject: [PATCH 6/7] fix local project account address
---
src/providers/Project/projectDefault.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/providers/Project/projectDefault.ts b/src/providers/Project/projectDefault.ts
index ed6f6407..39fd7217 100644
--- a/src/providers/Project/projectDefault.ts
+++ b/src/providers/Project/projectDefault.ts
@@ -111,7 +111,7 @@ export function createLocalProject(
const accountEntities: Account[] = accounts.map((_account) => {
return {
__typename: 'Account',
- address: `000000000000000${_account}`,
+ address: _account,
deployedContracts: [],
state: DEFAULT_ACCOUNT_STATE,
};
From ca3f5c2c28fd1d19b20892a0ef7d55f913937c94 Mon Sep 17 00:00:00 2001
From: Alex Ni <12097569+nialexsan@users.noreply.github.com>
Date: Mon, 16 Sep 2024 17:29:50 -0400
Subject: [PATCH 7/7] left pad
---
src/providers/Project/projectDefault.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/providers/Project/projectDefault.ts b/src/providers/Project/projectDefault.ts
index 39fd7217..0272c069 100644
--- a/src/providers/Project/projectDefault.ts
+++ b/src/providers/Project/projectDefault.ts
@@ -111,7 +111,7 @@ export function createLocalProject(
const accountEntities: Account[] = accounts.map((_account) => {
return {
__typename: 'Account',
- address: _account,
+ address: _account.padStart(16, "0"),
deployedContracts: [],
state: DEFAULT_ACCOUNT_STATE,
};