@mysten/create-dapp 0.0.0-experimental-20231012175001
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/LICENSE +201 -0
- package/README.md +33 -0
- package/bin/index.js +4 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +95 -0
- package/dist/index.js.map +1 -0
- package/package.json +49 -0
- package/src/index.ts +120 -0
- package/templates/react-client-dapp/CHANGELOG.md +14 -0
- package/templates/react-client-dapp/README.md +35 -0
- package/templates/react-client-dapp/index.html +59 -0
- package/templates/react-client-dapp/node_modules/.bin/eslint +17 -0
- package/templates/react-client-dapp/node_modules/.bin/prettier +17 -0
- package/templates/react-client-dapp/node_modules/.bin/tsc +17 -0
- package/templates/react-client-dapp/node_modules/.bin/tsserver +17 -0
- package/templates/react-client-dapp/node_modules/.bin/vite +17 -0
- package/templates/react-client-dapp/package.json +35 -0
- package/templates/react-client-dapp/prettier.config.cjs +4 -0
- package/templates/react-client-dapp/src/App.tsx +39 -0
- package/templates/react-client-dapp/src/OwnedObjects.tsx +42 -0
- package/templates/react-client-dapp/src/WalletStatus.tsx +23 -0
- package/templates/react-client-dapp/src/main.tsx +32 -0
- package/templates/react-client-dapp/src/vite-env.d.ts +1 -0
- package/templates/react-client-dapp/tsconfig.json +25 -0
- package/templates/react-client-dapp/tsconfig.node.json +10 -0
- package/templates/react-client-dapp/vite.config.ts +7 -0
- package/templates/react-e2e-counter/CHANGELOG.md +14 -0
- package/templates/react-e2e-counter/README.md +99 -0
- package/templates/react-e2e-counter/index.html +59 -0
- package/templates/react-e2e-counter/move/counter/Move.toml +9 -0
- package/templates/react-e2e-counter/move/counter/sources/counter.move +53 -0
- package/templates/react-e2e-counter/node_modules/.bin/eslint +17 -0
- package/templates/react-e2e-counter/node_modules/.bin/prettier +17 -0
- package/templates/react-e2e-counter/node_modules/.bin/tsc +17 -0
- package/templates/react-e2e-counter/node_modules/.bin/tsserver +17 -0
- package/templates/react-e2e-counter/node_modules/.bin/vite +17 -0
- package/templates/react-e2e-counter/package.json +35 -0
- package/templates/react-e2e-counter/prettier.config.cjs +4 -0
- package/templates/react-e2e-counter/src/App.tsx +61 -0
- package/templates/react-e2e-counter/src/Counter.tsx +90 -0
- package/templates/react-e2e-counter/src/CreateCounter.tsx +63 -0
- package/templates/react-e2e-counter/src/constants.ts +2 -0
- package/templates/react-e2e-counter/src/main.tsx +32 -0
- package/templates/react-e2e-counter/src/vite-env.d.ts +1 -0
- package/templates/react-e2e-counter/tsconfig.json +25 -0
- package/templates/react-e2e-counter/tsconfig.node.json +10 -0
- package/templates/react-e2e-counter/vite.config.ts +7 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
+
|
|
4
|
+
case `uname` in
|
|
5
|
+
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
|
6
|
+
esac
|
|
7
|
+
|
|
8
|
+
if [ -z "$NODE_PATH" ]; then
|
|
9
|
+
export NODE_PATH="/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/prettier@3.0.3/node_modules/prettier/bin/node_modules:/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/prettier@3.0.3/node_modules/prettier/node_modules:/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/prettier@3.0.3/node_modules:/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/node_modules"
|
|
10
|
+
else
|
|
11
|
+
export NODE_PATH="/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/prettier@3.0.3/node_modules/prettier/bin/node_modules:/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/prettier@3.0.3/node_modules/prettier/node_modules:/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/prettier@3.0.3/node_modules:/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
12
|
+
fi
|
|
13
|
+
if [ -x "$basedir/node" ]; then
|
|
14
|
+
exec "$basedir/node" "$basedir/../prettier/bin/prettier.cjs" "$@"
|
|
15
|
+
else
|
|
16
|
+
exec node "$basedir/../prettier/bin/prettier.cjs" "$@"
|
|
17
|
+
fi
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
+
|
|
4
|
+
case `uname` in
|
|
5
|
+
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
|
6
|
+
esac
|
|
7
|
+
|
|
8
|
+
if [ -z "$NODE_PATH" ]; then
|
|
9
|
+
export NODE_PATH="/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/typescript@5.1.6/node_modules/typescript/bin/node_modules:/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/typescript@5.1.6/node_modules/typescript/node_modules:/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/typescript@5.1.6/node_modules:/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/node_modules"
|
|
10
|
+
else
|
|
11
|
+
export NODE_PATH="/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/typescript@5.1.6/node_modules/typescript/bin/node_modules:/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/typescript@5.1.6/node_modules/typescript/node_modules:/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/typescript@5.1.6/node_modules:/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
12
|
+
fi
|
|
13
|
+
if [ -x "$basedir/node" ]; then
|
|
14
|
+
exec "$basedir/node" "$basedir/../typescript/bin/tsc" "$@"
|
|
15
|
+
else
|
|
16
|
+
exec node "$basedir/../typescript/bin/tsc" "$@"
|
|
17
|
+
fi
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
+
|
|
4
|
+
case `uname` in
|
|
5
|
+
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
|
6
|
+
esac
|
|
7
|
+
|
|
8
|
+
if [ -z "$NODE_PATH" ]; then
|
|
9
|
+
export NODE_PATH="/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/typescript@5.1.6/node_modules/typescript/bin/node_modules:/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/typescript@5.1.6/node_modules/typescript/node_modules:/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/typescript@5.1.6/node_modules:/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/node_modules"
|
|
10
|
+
else
|
|
11
|
+
export NODE_PATH="/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/typescript@5.1.6/node_modules/typescript/bin/node_modules:/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/typescript@5.1.6/node_modules/typescript/node_modules:/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/typescript@5.1.6/node_modules:/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
12
|
+
fi
|
|
13
|
+
if [ -x "$basedir/node" ]; then
|
|
14
|
+
exec "$basedir/node" "$basedir/../typescript/bin/tsserver" "$@"
|
|
15
|
+
else
|
|
16
|
+
exec node "$basedir/../typescript/bin/tsserver" "$@"
|
|
17
|
+
fi
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
+
|
|
4
|
+
case `uname` in
|
|
5
|
+
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
|
6
|
+
esac
|
|
7
|
+
|
|
8
|
+
if [ -z "$NODE_PATH" ]; then
|
|
9
|
+
export NODE_PATH="/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/vite@4.4.11_@types+node@20.4.2_sass@1.63.6/node_modules/vite/bin/node_modules:/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/vite@4.4.11_@types+node@20.4.2_sass@1.63.6/node_modules/vite/node_modules:/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/vite@4.4.11_@types+node@20.4.2_sass@1.63.6/node_modules:/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/node_modules"
|
|
10
|
+
else
|
|
11
|
+
export NODE_PATH="/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/vite@4.4.11_@types+node@20.4.2_sass@1.63.6/node_modules/vite/bin/node_modules:/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/vite@4.4.11_@types+node@20.4.2_sass@1.63.6/node_modules/vite/node_modules:/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/vite@4.4.11_@types+node@20.4.2_sass@1.63.6/node_modules:/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
12
|
+
fi
|
|
13
|
+
if [ -x "$basedir/node" ]; then
|
|
14
|
+
exec "$basedir/node" "$basedir/../vite/bin/vite.js" "$@"
|
|
15
|
+
else
|
|
16
|
+
exec node "$basedir/../vite/bin/vite.js" "$@"
|
|
17
|
+
fi
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mysten/template-react-client-app",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "0.0.0-experimental-20231012175001",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "vite",
|
|
8
|
+
"build": "tsc && vite build",
|
|
9
|
+
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
|
10
|
+
"preview": "vite preview"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@mysten/dapp-kit": "workspace:*",
|
|
14
|
+
"@mysten/sui.js": "workspace:*",
|
|
15
|
+
"@radix-ui/colors": "^3.0.0",
|
|
16
|
+
"@radix-ui/react-icons": "^1.3.0",
|
|
17
|
+
"@radix-ui/themes": "^2.0.0",
|
|
18
|
+
"@tanstack/react-query": "^4.29.25",
|
|
19
|
+
"react": "^18.2.0",
|
|
20
|
+
"react-dom": "^18.2.0"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@types/react": "^18.2.15",
|
|
24
|
+
"@types/react-dom": "^18.2.7",
|
|
25
|
+
"@typescript-eslint/eslint-plugin": "^6.1.0",
|
|
26
|
+
"@typescript-eslint/parser": "^6.1.0",
|
|
27
|
+
"@vitejs/plugin-react-swc": "^3.3.2",
|
|
28
|
+
"eslint": "^8.45.0",
|
|
29
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
|
30
|
+
"eslint-plugin-react-refresh": "^0.4.3",
|
|
31
|
+
"prettier": "^3.0.0",
|
|
32
|
+
"typescript": "^5.1.6",
|
|
33
|
+
"vite": "^4.4.4"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ConnectButton } from "@mysten/dapp-kit";
|
|
2
|
+
import { Box, Container, Flex, Heading } from "@radix-ui/themes";
|
|
3
|
+
import { WalletStatus } from "./WalletStatus";
|
|
4
|
+
|
|
5
|
+
function App() {
|
|
6
|
+
return (
|
|
7
|
+
<>
|
|
8
|
+
<Flex
|
|
9
|
+
position="sticky"
|
|
10
|
+
px="4"
|
|
11
|
+
py="2"
|
|
12
|
+
justify="between"
|
|
13
|
+
style={{
|
|
14
|
+
borderBottom: "1px solid var(--gray-a2)",
|
|
15
|
+
}}
|
|
16
|
+
>
|
|
17
|
+
<Box>
|
|
18
|
+
<Heading>dApp Starter Template</Heading>
|
|
19
|
+
</Box>
|
|
20
|
+
|
|
21
|
+
<Box>
|
|
22
|
+
<ConnectButton />
|
|
23
|
+
</Box>
|
|
24
|
+
</Flex>
|
|
25
|
+
<Container>
|
|
26
|
+
<Container
|
|
27
|
+
mt="5"
|
|
28
|
+
pt="2"
|
|
29
|
+
px="4"
|
|
30
|
+
style={{ background: "var(--gray-a2)", minHeight: 500 }}
|
|
31
|
+
>
|
|
32
|
+
<WalletStatus />
|
|
33
|
+
</Container>
|
|
34
|
+
</Container>
|
|
35
|
+
</>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export default App;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { useCurrentAccount, useSuiClientQuery } from "@mysten/dapp-kit";
|
|
2
|
+
import { Flex, Heading, Text } from "@radix-ui/themes";
|
|
3
|
+
|
|
4
|
+
export function OwnedObjects() {
|
|
5
|
+
const account = useCurrentAccount();
|
|
6
|
+
const { data, isLoading, error } = useSuiClientQuery(
|
|
7
|
+
"getOwnedObjects",
|
|
8
|
+
{
|
|
9
|
+
owner: account?.address as string,
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
enabled: !!account,
|
|
13
|
+
},
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
if (!account) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (error) {
|
|
21
|
+
return <Flex>Error: {error.message}</Flex>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (isLoading || !data) {
|
|
25
|
+
return <Flex>Loading...</Flex>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<Flex direction="column" my="2">
|
|
30
|
+
{data.data.length === 0 ? (
|
|
31
|
+
<Text>No objects owned by the connected wallet</Text>
|
|
32
|
+
) : (
|
|
33
|
+
<Heading size="4">Objects owned by the connected wallet</Heading>
|
|
34
|
+
)}
|
|
35
|
+
{data.data.map((object) => (
|
|
36
|
+
<Flex key={object.data?.objectId}>
|
|
37
|
+
<Text>Object ID: {object.data?.objectId}</Text>
|
|
38
|
+
</Flex>
|
|
39
|
+
))}
|
|
40
|
+
</Flex>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useCurrentAccount } from "@mysten/dapp-kit";
|
|
2
|
+
import { Container, Flex, Heading, Text } from "@radix-ui/themes";
|
|
3
|
+
import { OwnedObjects } from "./OwnedObjects";
|
|
4
|
+
|
|
5
|
+
export function WalletStatus() {
|
|
6
|
+
const account = useCurrentAccount();
|
|
7
|
+
|
|
8
|
+
return (
|
|
9
|
+
<Container my="2">
|
|
10
|
+
<Heading mb="2">Wallet Status</Heading>
|
|
11
|
+
|
|
12
|
+
{account ? (
|
|
13
|
+
<Flex direction="column">
|
|
14
|
+
<Text>Wallet connected</Text>
|
|
15
|
+
<Text>Address: {account.address}</Text>
|
|
16
|
+
</Flex>
|
|
17
|
+
) : (
|
|
18
|
+
<Text>Wallet not connected</Text>
|
|
19
|
+
)}
|
|
20
|
+
<OwnedObjects />
|
|
21
|
+
</Container>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import ReactDOM from "react-dom/client";
|
|
3
|
+
import "@mysten/dapp-kit/dist/index.css";
|
|
4
|
+
import "@radix-ui/themes/styles.css";
|
|
5
|
+
|
|
6
|
+
import { getFullnodeUrl } from "@mysten/sui.js/client";
|
|
7
|
+
import { SuiClientProvider, WalletProvider } from "@mysten/dapp-kit";
|
|
8
|
+
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
9
|
+
import { Theme } from "@radix-ui/themes";
|
|
10
|
+
import App from "./App.tsx";
|
|
11
|
+
|
|
12
|
+
const queryClient = new QueryClient();
|
|
13
|
+
const networks = {
|
|
14
|
+
localnet: { url: getFullnodeUrl("localnet") },
|
|
15
|
+
devnet: { url: getFullnodeUrl("devnet") },
|
|
16
|
+
testnet: { url: getFullnodeUrl("testnet") },
|
|
17
|
+
mainnet: { url: getFullnodeUrl("mainnet") },
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
ReactDOM.createRoot(document.getElementById("root")!).render(
|
|
21
|
+
<React.StrictMode>
|
|
22
|
+
<Theme appearance="dark">
|
|
23
|
+
<QueryClientProvider client={queryClient}>
|
|
24
|
+
<SuiClientProvider networks={networks} defaultNetwork="devnet">
|
|
25
|
+
<WalletProvider autoConnect>
|
|
26
|
+
<App />
|
|
27
|
+
</WalletProvider>
|
|
28
|
+
</SuiClientProvider>
|
|
29
|
+
</QueryClientProvider>
|
|
30
|
+
</Theme>
|
|
31
|
+
</React.StrictMode>,
|
|
32
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"useDefineForClassFields": true,
|
|
5
|
+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
|
6
|
+
"module": "ESNext",
|
|
7
|
+
"skipLibCheck": true,
|
|
8
|
+
|
|
9
|
+
/* Bundler mode */
|
|
10
|
+
"moduleResolution": "bundler",
|
|
11
|
+
"allowImportingTsExtensions": true,
|
|
12
|
+
"resolveJsonModule": true,
|
|
13
|
+
"isolatedModules": true,
|
|
14
|
+
"noEmit": true,
|
|
15
|
+
"jsx": "react-jsx",
|
|
16
|
+
|
|
17
|
+
/* Linting */
|
|
18
|
+
"strict": true,
|
|
19
|
+
"noUnusedLocals": true,
|
|
20
|
+
"noUnusedParameters": true,
|
|
21
|
+
"noFallthroughCasesInSwitch": true
|
|
22
|
+
},
|
|
23
|
+
"include": ["src"],
|
|
24
|
+
"references": [{ "path": "./tsconfig.node.json" }]
|
|
25
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# @mysten/template-react-e2e-coinflip
|
|
2
|
+
|
|
3
|
+
## 0.0.0-experimental-20231012175001
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [361818abc]
|
|
8
|
+
- Updated dependencies [2b532bc37]
|
|
9
|
+
- Updated dependencies [b48289346]
|
|
10
|
+
- Updated dependencies [11cf4e68b]
|
|
11
|
+
- Updated dependencies [0c5cdc049]
|
|
12
|
+
- Updated dependencies [c7e12c928]
|
|
13
|
+
- @mysten/dapp-kit@0.0.0-experimental-20231012175001
|
|
14
|
+
- @mysten/sui.js@0.0.0-experimental-20231012175001
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# Sui dApp Starter Template
|
|
2
|
+
|
|
3
|
+
This dApp was created using `@mysten/create-dapp` that sets up a simple React
|
|
4
|
+
Client dApp using the following tools:
|
|
5
|
+
|
|
6
|
+
- [React](https://react.dev/) as the UI framework
|
|
7
|
+
- [TypeScript](https://www.typescriptlang.org/) for type checking
|
|
8
|
+
- [Vite](https://vitejs.dev/) for build tooling
|
|
9
|
+
- [Radix UI](https://www.radix-ui.com/) for pre-built UI components
|
|
10
|
+
- [ESLint](https://eslint.org/) for linting
|
|
11
|
+
- [`@mysten/dapp-kit`](https://sui-typescript-docs.vercel.app/dapp-kit) for
|
|
12
|
+
connecting to wallets and loading data
|
|
13
|
+
- [pnpm](https://pnpm.io/) for package management
|
|
14
|
+
|
|
15
|
+
## Deploying your Move code
|
|
16
|
+
|
|
17
|
+
### Install Sui cli
|
|
18
|
+
|
|
19
|
+
Before deploying your move code, ensure that you have installed the Sui CLI. You
|
|
20
|
+
can follow the [Sui installation instruction](https://docs.sui.io/build/install)
|
|
21
|
+
to get everything set up.
|
|
22
|
+
|
|
23
|
+
This template uses `devnet` by default, so we'll need to set up a devnet
|
|
24
|
+
environment in the CLI:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
sui client new-env --alias devnet --rpc https://fullnode.devnet.sui.io:443
|
|
28
|
+
sui client switch --env devnet
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
If you haven't set up an address in the sui client yet, you can use the
|
|
32
|
+
following command to get a new address:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
sui client new-address secp256k1
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
This well generate a new address and recover phrase for you. You can mark a
|
|
39
|
+
newly created address as you active address by running the following command
|
|
40
|
+
with your new address:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
sui client switch --address 0xYOUR_ADDRESS...
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
We can ensure we have some Sui in our new wallet by requesting Sui from the
|
|
47
|
+
faucet (make sure to replace the address with your address):
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
curl --location --request POST 'https://faucet.devnet.sui.io/gas' \
|
|
51
|
+
--header 'Content-Type: application/json' \
|
|
52
|
+
--data-raw '{
|
|
53
|
+
"FixedAmountRequest": {
|
|
54
|
+
"recipient": "<YOUR_ADDRESS>"
|
|
55
|
+
}
|
|
56
|
+
}'
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Publishing the move package
|
|
60
|
+
|
|
61
|
+
The move code for this template is located in the `move` directory. To publish
|
|
62
|
+
it, you can enter the `move` directory, and publish it with the Sui CLI:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
cd move
|
|
66
|
+
sui client publish --gas-budget 100000000 counter
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
In the output there will be an object with a `"packageId"` property. You'll want
|
|
70
|
+
to save that package ID to the `src/constants.ts` file as `PACKAGE_ID`:
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
export const PACKAGE_ID = "<YOUR_PACKAGE_ID>";
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Now that we have published the move code, and update the package ID, we can
|
|
77
|
+
start the app.
|
|
78
|
+
|
|
79
|
+
## Starting your dApp
|
|
80
|
+
|
|
81
|
+
To install dependencies you can run
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
pnpm install
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
To start your dApp in development mode run
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
pnpm dev
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Building
|
|
94
|
+
|
|
95
|
+
To build your app for deployment you can run
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
pnpm build
|
|
99
|
+
```
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en" class="dark-theme" style="color-scheme: dark">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<title>Sui dApp Starter</title>
|
|
8
|
+
|
|
9
|
+
<style>
|
|
10
|
+
/*
|
|
11
|
+
Josh's Custom CSS Reset
|
|
12
|
+
https://www.joshwcomeau.com/css/custom-css-reset/
|
|
13
|
+
*/
|
|
14
|
+
*,
|
|
15
|
+
*::before,
|
|
16
|
+
*::after {
|
|
17
|
+
box-sizing: border-box;
|
|
18
|
+
}
|
|
19
|
+
* {
|
|
20
|
+
margin: 0;
|
|
21
|
+
}
|
|
22
|
+
body {
|
|
23
|
+
line-height: 1.5;
|
|
24
|
+
-webkit-font-smoothing: antialiased;
|
|
25
|
+
}
|
|
26
|
+
img,
|
|
27
|
+
picture,
|
|
28
|
+
video,
|
|
29
|
+
canvas,
|
|
30
|
+
svg {
|
|
31
|
+
display: block;
|
|
32
|
+
max-width: 100%;
|
|
33
|
+
}
|
|
34
|
+
input,
|
|
35
|
+
button,
|
|
36
|
+
textarea,
|
|
37
|
+
select {
|
|
38
|
+
font: inherit;
|
|
39
|
+
}
|
|
40
|
+
p,
|
|
41
|
+
h1,
|
|
42
|
+
h2,
|
|
43
|
+
h3,
|
|
44
|
+
h4,
|
|
45
|
+
h5,
|
|
46
|
+
h6 {
|
|
47
|
+
overflow-wrap: break-word;
|
|
48
|
+
}
|
|
49
|
+
#root,
|
|
50
|
+
#__next {
|
|
51
|
+
isolation: isolate;
|
|
52
|
+
}
|
|
53
|
+
</style>
|
|
54
|
+
</head>
|
|
55
|
+
<body>
|
|
56
|
+
<div id="root"></div>
|
|
57
|
+
<script type="module" src="/src/main.tsx"></script>
|
|
58
|
+
</body>
|
|
59
|
+
</html>
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// Copyright (c) Mysten Labs, Inc.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
/// This example demonstrates a basic use of a shared object.
|
|
5
|
+
/// Rules:
|
|
6
|
+
/// - anyone can create and share a counter
|
|
7
|
+
/// - everyone can increment a counter by 1
|
|
8
|
+
/// - the owner of the counter can reset it to any value
|
|
9
|
+
module counter::counter {
|
|
10
|
+
use sui::transfer;
|
|
11
|
+
use sui::object::{Self, UID};
|
|
12
|
+
use sui::tx_context::{Self, TxContext};
|
|
13
|
+
|
|
14
|
+
/// A shared counter.
|
|
15
|
+
struct Counter has key {
|
|
16
|
+
id: UID,
|
|
17
|
+
owner: address,
|
|
18
|
+
value: u64
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public fun owner(counter: &Counter): address {
|
|
22
|
+
counter.owner
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
public fun value(counter: &Counter): u64 {
|
|
26
|
+
counter.value
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/// Create and share a Counter object.
|
|
30
|
+
public entry fun create(ctx: &mut TxContext) {
|
|
31
|
+
transfer::share_object(Counter {
|
|
32
|
+
id: object::new(ctx),
|
|
33
|
+
owner: tx_context::sender(ctx),
|
|
34
|
+
value: 0
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/// Increment a counter by 1.
|
|
39
|
+
public entry fun increment(counter: &mut Counter) {
|
|
40
|
+
counter.value = counter.value + 1;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/// Set value (only runnable by the Counter owner)
|
|
44
|
+
public entry fun set_value(counter: &mut Counter, value: u64, ctx: &TxContext) {
|
|
45
|
+
assert!(counter.owner == tx_context::sender(ctx), 0);
|
|
46
|
+
counter.value = value;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/// Assert a value for the counter.
|
|
50
|
+
public entry fun assert_value(counter: &Counter, value: u64) {
|
|
51
|
+
assert!(counter.value == value, 0)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
+
|
|
4
|
+
case `uname` in
|
|
5
|
+
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
|
6
|
+
esac
|
|
7
|
+
|
|
8
|
+
if [ -z "$NODE_PATH" ]; then
|
|
9
|
+
export NODE_PATH="/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/eslint@8.45.0/node_modules/eslint/bin/node_modules:/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/eslint@8.45.0/node_modules/eslint/node_modules:/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/eslint@8.45.0/node_modules:/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/node_modules"
|
|
10
|
+
else
|
|
11
|
+
export NODE_PATH="/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/eslint@8.45.0/node_modules/eslint/bin/node_modules:/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/eslint@8.45.0/node_modules/eslint/node_modules:/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/eslint@8.45.0/node_modules:/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
12
|
+
fi
|
|
13
|
+
if [ -x "$basedir/node" ]; then
|
|
14
|
+
exec "$basedir/node" "$basedir/../eslint/bin/eslint.js" "$@"
|
|
15
|
+
else
|
|
16
|
+
exec node "$basedir/../eslint/bin/eslint.js" "$@"
|
|
17
|
+
fi
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
+
|
|
4
|
+
case `uname` in
|
|
5
|
+
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
|
6
|
+
esac
|
|
7
|
+
|
|
8
|
+
if [ -z "$NODE_PATH" ]; then
|
|
9
|
+
export NODE_PATH="/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/prettier@3.0.3/node_modules/prettier/bin/node_modules:/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/prettier@3.0.3/node_modules/prettier/node_modules:/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/prettier@3.0.3/node_modules:/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/node_modules"
|
|
10
|
+
else
|
|
11
|
+
export NODE_PATH="/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/prettier@3.0.3/node_modules/prettier/bin/node_modules:/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/prettier@3.0.3/node_modules/prettier/node_modules:/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/prettier@3.0.3/node_modules:/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
12
|
+
fi
|
|
13
|
+
if [ -x "$basedir/node" ]; then
|
|
14
|
+
exec "$basedir/node" "$basedir/../prettier/bin/prettier.cjs" "$@"
|
|
15
|
+
else
|
|
16
|
+
exec node "$basedir/../prettier/bin/prettier.cjs" "$@"
|
|
17
|
+
fi
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
+
|
|
4
|
+
case `uname` in
|
|
5
|
+
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
|
6
|
+
esac
|
|
7
|
+
|
|
8
|
+
if [ -z "$NODE_PATH" ]; then
|
|
9
|
+
export NODE_PATH="/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/typescript@5.1.6/node_modules/typescript/bin/node_modules:/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/typescript@5.1.6/node_modules/typescript/node_modules:/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/typescript@5.1.6/node_modules:/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/node_modules"
|
|
10
|
+
else
|
|
11
|
+
export NODE_PATH="/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/typescript@5.1.6/node_modules/typescript/bin/node_modules:/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/typescript@5.1.6/node_modules/typescript/node_modules:/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/typescript@5.1.6/node_modules:/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
12
|
+
fi
|
|
13
|
+
if [ -x "$basedir/node" ]; then
|
|
14
|
+
exec "$basedir/node" "$basedir/../typescript/bin/tsc" "$@"
|
|
15
|
+
else
|
|
16
|
+
exec node "$basedir/../typescript/bin/tsc" "$@"
|
|
17
|
+
fi
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
+
|
|
4
|
+
case `uname` in
|
|
5
|
+
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
|
6
|
+
esac
|
|
7
|
+
|
|
8
|
+
if [ -z "$NODE_PATH" ]; then
|
|
9
|
+
export NODE_PATH="/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/typescript@5.1.6/node_modules/typescript/bin/node_modules:/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/typescript@5.1.6/node_modules/typescript/node_modules:/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/typescript@5.1.6/node_modules:/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/node_modules"
|
|
10
|
+
else
|
|
11
|
+
export NODE_PATH="/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/typescript@5.1.6/node_modules/typescript/bin/node_modules:/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/typescript@5.1.6/node_modules/typescript/node_modules:/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/typescript@5.1.6/node_modules:/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
12
|
+
fi
|
|
13
|
+
if [ -x "$basedir/node" ]; then
|
|
14
|
+
exec "$basedir/node" "$basedir/../typescript/bin/tsserver" "$@"
|
|
15
|
+
else
|
|
16
|
+
exec node "$basedir/../typescript/bin/tsserver" "$@"
|
|
17
|
+
fi
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
+
|
|
4
|
+
case `uname` in
|
|
5
|
+
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
|
6
|
+
esac
|
|
7
|
+
|
|
8
|
+
if [ -z "$NODE_PATH" ]; then
|
|
9
|
+
export NODE_PATH="/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/vite@4.4.11_@types+node@20.4.2_sass@1.63.6/node_modules/vite/bin/node_modules:/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/vite@4.4.11_@types+node@20.4.2_sass@1.63.6/node_modules/vite/node_modules:/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/vite@4.4.11_@types+node@20.4.2_sass@1.63.6/node_modules:/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/node_modules"
|
|
10
|
+
else
|
|
11
|
+
export NODE_PATH="/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/vite@4.4.11_@types+node@20.4.2_sass@1.63.6/node_modules/vite/bin/node_modules:/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/vite@4.4.11_@types+node@20.4.2_sass@1.63.6/node_modules/vite/node_modules:/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/vite@4.4.11_@types+node@20.4.2_sass@1.63.6/node_modules:/home/runner/work/sui-operations/sui-operations/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
12
|
+
fi
|
|
13
|
+
if [ -x "$basedir/node" ]; then
|
|
14
|
+
exec "$basedir/node" "$basedir/../vite/bin/vite.js" "$@"
|
|
15
|
+
else
|
|
16
|
+
exec node "$basedir/../vite/bin/vite.js" "$@"
|
|
17
|
+
fi
|