@mysten/create-dapp 0.3.11 → 0.3.12
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 +18 -2
- package/package.json +5 -5
- package/templates/react-client-dapp/package.json +15 -15
- package/templates/react-client-dapp/src/main.tsx +2 -13
- package/templates/react-client-dapp/src/networkConfig.ts +17 -0
- package/templates/react-e2e-counter/README.md +8 -5
- package/templates/react-e2e-counter/move/counter/sources/counter.move +26 -43
- package/templates/react-e2e-counter/package.json +12 -12
- package/templates/react-e2e-counter/src/Counter.tsx +16 -7
- package/templates/react-e2e-counter/src/CreateCounter.tsx +18 -17
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @mysten/create-dapp
|
|
2
2
|
|
|
3
|
+
## 0.3.12
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 0f27a97: Update dependencies
|
|
8
|
+
- Updated dependencies [7fc464a]
|
|
9
|
+
- Updated dependencies [086b2bc]
|
|
10
|
+
- Updated dependencies [0fb0628]
|
|
11
|
+
- Updated dependencies [cdedf69]
|
|
12
|
+
- Updated dependencies [0f27a97]
|
|
13
|
+
- Updated dependencies [beed646]
|
|
14
|
+
- @mysten/sui@1.3.0
|
|
15
|
+
- @mysten/dapp-kit@0.14.12
|
|
16
|
+
|
|
3
17
|
## 0.3.11
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -92,8 +106,10 @@
|
|
|
92
106
|
|
|
93
107
|
### Minor Changes
|
|
94
108
|
|
|
95
|
-
- a92b03de42: The Typescript SDK has been renamed to `@mysten/sui` and includes many new features
|
|
96
|
-
|
|
109
|
+
- a92b03de42: The Typescript SDK has been renamed to `@mysten/sui` and includes many new features
|
|
110
|
+
and breaking changes. See the
|
|
111
|
+
[full migration guide](https://sdk.mystenlabs.com/typescript/migrations/sui-1.0) for details on
|
|
112
|
+
how to upgrade.
|
|
97
113
|
|
|
98
114
|
### Patch Changes
|
|
99
115
|
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"author": "Mysten Labs <build@mystenlabs.com>",
|
|
4
4
|
"description": "A CLI for creating new Sui dApps",
|
|
5
5
|
"homepage": "https://sdk.mystenlabs.com",
|
|
6
|
-
"version": "0.3.
|
|
6
|
+
"version": "0.3.12",
|
|
7
7
|
"license": "Apache-2.0",
|
|
8
8
|
"files": [
|
|
9
9
|
"CHANGELOG.md",
|
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
"access": "public"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"typescript": "^5.
|
|
27
|
+
"typescript": "^5.5.3",
|
|
28
28
|
"@mysten/build-scripts": "0.0.0"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@types/node": "^20.
|
|
31
|
+
"@types/node": "^20.14.10",
|
|
32
32
|
"enquirer": "^2.4.1",
|
|
33
|
-
"@mysten/dapp-kit": "0.14.
|
|
34
|
-
"@mysten/sui": "1.
|
|
33
|
+
"@mysten/dapp-kit": "0.14.12",
|
|
34
|
+
"@mysten/sui": "1.3.0"
|
|
35
35
|
},
|
|
36
36
|
"sideEffects": false,
|
|
37
37
|
"bin": "./bin/index.js",
|
|
@@ -14,22 +14,22 @@
|
|
|
14
14
|
"@mysten/sui": "workspace:*",
|
|
15
15
|
"@radix-ui/colors": "^3.0.0",
|
|
16
16
|
"@radix-ui/react-icons": "^1.3.0",
|
|
17
|
-
"@radix-ui/themes": "^
|
|
18
|
-
"@tanstack/react-query": "^5.
|
|
19
|
-
"react": "^18.
|
|
20
|
-
"react-dom": "^18.
|
|
17
|
+
"@radix-ui/themes": "^3.1.1",
|
|
18
|
+
"@tanstack/react-query": "^5.50.1",
|
|
19
|
+
"react": "^18.3.1",
|
|
20
|
+
"react-dom": "^18.3.1"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@types/react": "^18.
|
|
24
|
-
"@types/react-dom": "^18.
|
|
25
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
26
|
-
"@typescript-eslint/parser": "^
|
|
27
|
-
"@vitejs/plugin-react-swc": "^3.
|
|
28
|
-
"eslint": "^
|
|
29
|
-
"eslint-plugin-react-hooks": "^4.6.
|
|
30
|
-
"eslint-plugin-react-refresh": "^0.4.
|
|
31
|
-
"prettier": "^3.
|
|
32
|
-
"typescript": "^5.
|
|
33
|
-
"vite": "^
|
|
23
|
+
"@types/react": "^18.3.3",
|
|
24
|
+
"@types/react-dom": "^18.3.0",
|
|
25
|
+
"@typescript-eslint/eslint-plugin": "^7.16.0",
|
|
26
|
+
"@typescript-eslint/parser": "^7.16.0",
|
|
27
|
+
"@vitejs/plugin-react-swc": "^3.7.0",
|
|
28
|
+
"eslint": "^9.6.0",
|
|
29
|
+
"eslint-plugin-react-hooks": "^4.6.2",
|
|
30
|
+
"eslint-plugin-react-refresh": "^0.4.7",
|
|
31
|
+
"prettier": "^3.3.2",
|
|
32
|
+
"typescript": "^5.5.3",
|
|
33
|
+
"vite": "^5.3.3"
|
|
34
34
|
}
|
|
35
35
|
}
|
|
@@ -3,25 +3,14 @@ import ReactDOM from "react-dom/client";
|
|
|
3
3
|
import "@mysten/dapp-kit/dist/index.css";
|
|
4
4
|
import "@radix-ui/themes/styles.css";
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
SuiClientProvider,
|
|
9
|
-
WalletProvider,
|
|
10
|
-
createNetworkConfig,
|
|
11
|
-
} from "@mysten/dapp-kit";
|
|
6
|
+
import { SuiClientProvider, WalletProvider } from "@mysten/dapp-kit";
|
|
12
7
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
13
8
|
import { Theme } from "@radix-ui/themes";
|
|
14
9
|
import App from "./App.tsx";
|
|
10
|
+
import { networkConfig } from "./networkConfig.ts";
|
|
15
11
|
|
|
16
12
|
const queryClient = new QueryClient();
|
|
17
13
|
|
|
18
|
-
const { networkConfig } = createNetworkConfig({
|
|
19
|
-
localnet: { url: getFullnodeUrl("localnet") },
|
|
20
|
-
devnet: { url: getFullnodeUrl("devnet") },
|
|
21
|
-
testnet: { url: getFullnodeUrl("testnet") },
|
|
22
|
-
mainnet: { url: getFullnodeUrl("mainnet") },
|
|
23
|
-
});
|
|
24
|
-
|
|
25
14
|
ReactDOM.createRoot(document.getElementById("root")!).render(
|
|
26
15
|
<React.StrictMode>
|
|
27
16
|
<Theme appearance="dark">
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { getFullnodeUrl } from "@mysten/sui/client";
|
|
2
|
+
import { createNetworkConfig } from "@mysten/dapp-kit";
|
|
3
|
+
|
|
4
|
+
const { networkConfig, useNetworkVariable, useNetworkVariables } =
|
|
5
|
+
createNetworkConfig({
|
|
6
|
+
devnet: {
|
|
7
|
+
url: getFullnodeUrl("devnet"),
|
|
8
|
+
},
|
|
9
|
+
testnet: {
|
|
10
|
+
url: getFullnodeUrl("testnet"),
|
|
11
|
+
},
|
|
12
|
+
mainnet: {
|
|
13
|
+
url: getFullnodeUrl("mainnet"),
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export { useNetworkVariable, useNetworkVariables, networkConfig };
|
|
@@ -12,6 +12,9 @@ Client dApp using the following tools:
|
|
|
12
12
|
wallets and loading data
|
|
13
13
|
- [pnpm](https://pnpm.io/) for package management
|
|
14
14
|
|
|
15
|
+
For a full guide on how to build this dApp from scratch, visit this
|
|
16
|
+
[guide](http://docs.sui.io/guides/developer/app-examples/e2e-counter#frontend).
|
|
17
|
+
|
|
15
18
|
## Deploying your Move code
|
|
16
19
|
|
|
17
20
|
### Install Sui cli
|
|
@@ -20,12 +23,12 @@ Before deploying your move code, ensure that you have installed the Sui CLI. You
|
|
|
20
23
|
can follow the [Sui installation instruction](https://docs.sui.io/build/install)
|
|
21
24
|
to get everything set up.
|
|
22
25
|
|
|
23
|
-
This template uses `
|
|
26
|
+
This template uses `testnet` by default, so we'll need to set up a testnet
|
|
24
27
|
environment in the CLI:
|
|
25
28
|
|
|
26
29
|
```bash
|
|
27
|
-
sui client new-env --alias
|
|
28
|
-
sui client switch --env
|
|
30
|
+
sui client new-env --alias testnet --rpc https://fullnode.testnet.sui.io:443
|
|
31
|
+
sui client switch --env testnet
|
|
29
32
|
```
|
|
30
33
|
|
|
31
34
|
If you haven't set up an address in the sui client yet, you can use the
|
|
@@ -47,7 +50,7 @@ We can ensure we have some Sui in our new wallet by requesting Sui from the
|
|
|
47
50
|
faucet (make sure to replace the address with your address):
|
|
48
51
|
|
|
49
52
|
```bash
|
|
50
|
-
curl --location --request POST 'https://faucet.
|
|
53
|
+
curl --location --request POST 'https://faucet.testnet.sui.io/gas' \
|
|
51
54
|
--header 'Content-Type: application/json' \
|
|
52
55
|
--data-raw '{
|
|
53
56
|
"FixedAmountRequest": {
|
|
@@ -70,7 +73,7 @@ In the output there will be an object with a `"packageId"` property. You'll want
|
|
|
70
73
|
to save that package ID to the `src/constants.ts` file as `PACKAGE_ID`:
|
|
71
74
|
|
|
72
75
|
```ts
|
|
73
|
-
export const
|
|
76
|
+
export const TESTNET_COUNTER_PACKAGE_ID = "<YOUR_PACKAGE_ID>";
|
|
74
77
|
```
|
|
75
78
|
|
|
76
79
|
Now that we have published the move code, and update the package ID, we can
|
|
@@ -7,47 +7,30 @@
|
|
|
7
7
|
/// - everyone can increment a counter by 1
|
|
8
8
|
/// - the owner of the counter can reset it to any value
|
|
9
9
|
module counter::counter {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/// Increment a counter by 1.
|
|
39
|
-
public fun increment(counter: &mut Counter) {
|
|
40
|
-
counter.value = counter.value + 1;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/// Set value (only runnable by the Counter owner)
|
|
44
|
-
public 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 fun assert_value(counter: &Counter, value: u64) {
|
|
51
|
-
assert!(counter.value == value, 0)
|
|
52
|
-
}
|
|
10
|
+
/// A shared counter.
|
|
11
|
+
public struct Counter has key {
|
|
12
|
+
id: UID,
|
|
13
|
+
owner: address,
|
|
14
|
+
value: u64
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/// Create and share a Counter object.
|
|
18
|
+
public fun create(ctx: &mut TxContext) {
|
|
19
|
+
transfer::share_object(Counter {
|
|
20
|
+
id: object::new(ctx),
|
|
21
|
+
owner: ctx.sender(),
|
|
22
|
+
value: 0
|
|
23
|
+
})
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/// Increment a counter by 1.
|
|
27
|
+
public fun increment(counter: &mut Counter) {
|
|
28
|
+
counter.value = counter.value + 1;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/// Set value (only runnable by the Counter owner)
|
|
32
|
+
public fun set_value(counter: &mut Counter, value: u64, ctx: &TxContext) {
|
|
33
|
+
assert!(counter.owner == ctx.sender(), 0);
|
|
34
|
+
counter.value = value;
|
|
35
|
+
}
|
|
53
36
|
}
|
|
@@ -14,22 +14,22 @@
|
|
|
14
14
|
"@mysten/sui": "workspace:*",
|
|
15
15
|
"@radix-ui/colors": "^3.0.0",
|
|
16
16
|
"@radix-ui/react-icons": "^1.3.0",
|
|
17
|
-
"@radix-ui/themes": "^
|
|
18
|
-
"@tanstack/react-query": "^5.
|
|
19
|
-
"react": "^18.
|
|
20
|
-
"react-dom": "^18.
|
|
17
|
+
"@radix-ui/themes": "^3.1.1",
|
|
18
|
+
"@tanstack/react-query": "^5.50.1",
|
|
19
|
+
"react": "^18.3.1",
|
|
20
|
+
"react-dom": "^18.3.1"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@types/react": "^18.
|
|
24
|
-
"@types/react-dom": "^18.
|
|
23
|
+
"@types/react": "^18.3.3",
|
|
24
|
+
"@types/react-dom": "^18.3.0",
|
|
25
25
|
"@typescript-eslint/eslint-plugin": "^6.1.0",
|
|
26
26
|
"@typescript-eslint/parser": "^6.1.0",
|
|
27
|
-
"@vitejs/plugin-react-swc": "^3.
|
|
27
|
+
"@vitejs/plugin-react-swc": "^3.7.0",
|
|
28
28
|
"eslint": "^8.45.0",
|
|
29
|
-
"eslint-plugin-react-hooks": "^4.6.
|
|
30
|
-
"eslint-plugin-react-refresh": "^0.4.
|
|
31
|
-
"prettier": "^3.
|
|
32
|
-
"typescript": "^5.
|
|
33
|
-
"vite": "^
|
|
29
|
+
"eslint-plugin-react-hooks": "^4.6.2",
|
|
30
|
+
"eslint-plugin-react-refresh": "^0.4.7",
|
|
31
|
+
"prettier": "^3.3.2",
|
|
32
|
+
"typescript": "^5.5.3",
|
|
33
|
+
"vite": "^5.3.3"
|
|
34
34
|
}
|
|
35
35
|
}
|
|
@@ -10,10 +10,21 @@ import { Button, Flex, Heading, Text } from "@radix-ui/themes";
|
|
|
10
10
|
import { useNetworkVariable } from "./networkConfig";
|
|
11
11
|
|
|
12
12
|
export function Counter({ id }: { id: string }) {
|
|
13
|
-
const client = useSuiClient();
|
|
14
|
-
const currentAccount = useCurrentAccount();
|
|
15
13
|
const counterPackageId = useNetworkVariable("counterPackageId");
|
|
16
|
-
const
|
|
14
|
+
const suiClient = useSuiClient();
|
|
15
|
+
const currentAccount = useCurrentAccount();
|
|
16
|
+
const { mutate: signAndExecute } = useSignAndExecuteTransaction({
|
|
17
|
+
execute: async ({ bytes, signature }) =>
|
|
18
|
+
await suiClient.executeTransactionBlock({
|
|
19
|
+
transactionBlock: bytes,
|
|
20
|
+
signature,
|
|
21
|
+
options: {
|
|
22
|
+
// Raw effects are required so the effects can be reported back to the wallet
|
|
23
|
+
showRawEffects: true,
|
|
24
|
+
showEffects: true,
|
|
25
|
+
},
|
|
26
|
+
}),
|
|
27
|
+
});
|
|
17
28
|
const { data, isPending, error, refetch } = useSuiClientQuery("getObject", {
|
|
18
29
|
id,
|
|
19
30
|
options: {
|
|
@@ -42,10 +53,8 @@ export function Counter({ id }: { id: string }) {
|
|
|
42
53
|
transaction: tx,
|
|
43
54
|
},
|
|
44
55
|
{
|
|
45
|
-
onSuccess: (
|
|
46
|
-
|
|
47
|
-
refetch();
|
|
48
|
-
});
|
|
56
|
+
onSuccess: async () => {
|
|
57
|
+
await refetch();
|
|
49
58
|
},
|
|
50
59
|
},
|
|
51
60
|
);
|
|
@@ -8,9 +8,20 @@ export function CreateCounter({
|
|
|
8
8
|
}: {
|
|
9
9
|
onCreated: (id: string) => void;
|
|
10
10
|
}) {
|
|
11
|
-
const client = useSuiClient();
|
|
12
11
|
const counterPackageId = useNetworkVariable("counterPackageId");
|
|
13
|
-
const
|
|
12
|
+
const suiClient = useSuiClient();
|
|
13
|
+
const { mutate: signAndExecute } = useSignAndExecuteTransaction({
|
|
14
|
+
execute: async ({ bytes, signature }) =>
|
|
15
|
+
await suiClient.executeTransactionBlock({
|
|
16
|
+
transactionBlock: bytes,
|
|
17
|
+
signature,
|
|
18
|
+
options: {
|
|
19
|
+
// Raw effects are required so the effects can be reported back to the wallet
|
|
20
|
+
showRawEffects: true,
|
|
21
|
+
showEffects: true,
|
|
22
|
+
},
|
|
23
|
+
}),
|
|
24
|
+
});
|
|
14
25
|
|
|
15
26
|
return (
|
|
16
27
|
<Container>
|
|
@@ -38,21 +49,11 @@ export function CreateCounter({
|
|
|
38
49
|
transaction: tx,
|
|
39
50
|
},
|
|
40
51
|
{
|
|
41
|
-
onSuccess: (
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
showEffects: true,
|
|
47
|
-
},
|
|
48
|
-
})
|
|
49
|
-
.then((tx) => {
|
|
50
|
-
const objectId = tx.effects?.created?.[0]?.reference?.objectId;
|
|
51
|
-
|
|
52
|
-
if (objectId) {
|
|
53
|
-
onCreated(objectId);
|
|
54
|
-
}
|
|
55
|
-
});
|
|
52
|
+
onSuccess: (result) => {
|
|
53
|
+
const objectId = result.effects?.created?.[0]?.reference?.objectId;
|
|
54
|
+
if (objectId) {
|
|
55
|
+
onCreated(objectId);
|
|
56
|
+
}
|
|
56
57
|
},
|
|
57
58
|
},
|
|
58
59
|
);
|