@mysten/create-dapp 0.3.29 → 0.3.31
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/package.json +3 -3
- package/templates/react-e2e-counter/move/counter/Move.toml +1 -1
- package/templates/react-e2e-counter/package.json +2 -1
- package/templates/react-e2e-counter/src/Counter.tsx +27 -17
- package/templates/react-e2e-counter/src/CreateCounter.tsx +29 -30
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @mysten/create-dapp
|
|
2
2
|
|
|
3
|
+
## 0.3.31
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [e7bc63e]
|
|
8
|
+
- @mysten/sui@1.14.2
|
|
9
|
+
- @mysten/dapp-kit@0.14.30
|
|
10
|
+
|
|
11
|
+
## 0.3.30
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- 325955b: Fixes issue regarding refetching object data too soon after executing transactions
|
|
16
|
+
|
|
3
17
|
## 0.3.29
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
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.31",
|
|
7
7
|
"license": "Apache-2.0",
|
|
8
8
|
"files": [
|
|
9
9
|
"CHANGELOG.md",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@types/node": "^20.14.10",
|
|
32
32
|
"enquirer": "^2.4.1",
|
|
33
|
-
"@mysten/dapp-kit": "0.14.
|
|
34
|
-
"@mysten/sui": "1.14.
|
|
33
|
+
"@mysten/dapp-kit": "0.14.30",
|
|
34
|
+
"@mysten/sui": "1.14.2"
|
|
35
35
|
},
|
|
36
36
|
"sideEffects": false,
|
|
37
37
|
"bin": "./bin/index.js",
|
|
@@ -4,7 +4,7 @@ version = "0.0.1"
|
|
|
4
4
|
edition = "2024.beta"
|
|
5
5
|
|
|
6
6
|
[dependencies]
|
|
7
|
-
Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "framework/
|
|
7
|
+
Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "framework/testnet" }
|
|
8
8
|
|
|
9
9
|
[addresses]
|
|
10
10
|
counter = "0x0"
|
|
@@ -8,23 +8,14 @@ import type { SuiObjectData } from "@mysten/sui/client";
|
|
|
8
8
|
import { Transaction } from "@mysten/sui/transactions";
|
|
9
9
|
import { Button, Flex, Heading, Text } from "@radix-ui/themes";
|
|
10
10
|
import { useNetworkVariable } from "./networkConfig";
|
|
11
|
+
import { useState } from "react";
|
|
12
|
+
import ClipLoader from "react-spinners/ClipLoader";
|
|
11
13
|
|
|
12
14
|
export function Counter({ id }: { id: string }) {
|
|
13
15
|
const counterPackageId = useNetworkVariable("counterPackageId");
|
|
14
16
|
const suiClient = useSuiClient();
|
|
15
17
|
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
|
-
});
|
|
18
|
+
const { mutate: signAndExecute } = useSignAndExecuteTransaction();
|
|
28
19
|
const { data, isPending, error, refetch } = useSuiClientQuery("getObject", {
|
|
29
20
|
id,
|
|
30
21
|
options: {
|
|
@@ -33,7 +24,11 @@ export function Counter({ id }: { id: string }) {
|
|
|
33
24
|
},
|
|
34
25
|
});
|
|
35
26
|
|
|
27
|
+
const [waitingForTxn, setWaitingForTxn] = useState("");
|
|
28
|
+
|
|
36
29
|
const executeMoveCall = (method: "increment" | "reset") => {
|
|
30
|
+
setWaitingForTxn(method);
|
|
31
|
+
|
|
37
32
|
const tx = new Transaction();
|
|
38
33
|
|
|
39
34
|
if (method === "reset") {
|
|
@@ -53,8 +48,11 @@ export function Counter({ id }: { id: string }) {
|
|
|
53
48
|
transaction: tx,
|
|
54
49
|
},
|
|
55
50
|
{
|
|
56
|
-
onSuccess:
|
|
57
|
-
|
|
51
|
+
onSuccess: (tx) => {
|
|
52
|
+
suiClient.waitForTransaction({ digest: tx.digest }).then(async () => {
|
|
53
|
+
await refetch();
|
|
54
|
+
setWaitingForTxn("");
|
|
55
|
+
});
|
|
58
56
|
},
|
|
59
57
|
},
|
|
60
58
|
);
|
|
@@ -76,11 +74,23 @@ export function Counter({ id }: { id: string }) {
|
|
|
76
74
|
<Flex direction="column" gap="2">
|
|
77
75
|
<Text>Count: {getCounterFields(data.data)?.value}</Text>
|
|
78
76
|
<Flex direction="row" gap="2">
|
|
79
|
-
<Button
|
|
80
|
-
|
|
77
|
+
<Button
|
|
78
|
+
onClick={() => executeMoveCall("increment")}
|
|
79
|
+
disabled={waitingForTxn !== ""}
|
|
80
|
+
>
|
|
81
|
+
{waitingForTxn === "increment" ? (
|
|
82
|
+
<ClipLoader size={20} />
|
|
83
|
+
) : (
|
|
84
|
+
"Increment"
|
|
85
|
+
)}
|
|
81
86
|
</Button>
|
|
82
87
|
{ownedByCurrentAccount ? (
|
|
83
|
-
<Button
|
|
88
|
+
<Button
|
|
89
|
+
onClick={() => executeMoveCall("reset")}
|
|
90
|
+
disabled={waitingForTxn !== ""}
|
|
91
|
+
>
|
|
92
|
+
{waitingForTxn === "reset" ? <ClipLoader size={20} /> : "Reset"}
|
|
93
|
+
</Button>
|
|
84
94
|
) : null}
|
|
85
95
|
</Flex>
|
|
86
96
|
</Flex>
|
|
@@ -2,6 +2,7 @@ import { Transaction } from "@mysten/sui/transactions";
|
|
|
2
2
|
import { Button, Container } from "@radix-ui/themes";
|
|
3
3
|
import { useSignAndExecuteTransaction, useSuiClient } from "@mysten/dapp-kit";
|
|
4
4
|
import { useNetworkVariable } from "./networkConfig";
|
|
5
|
+
import ClipLoader from "react-spinners/ClipLoader";
|
|
5
6
|
|
|
6
7
|
export function CreateCounter({
|
|
7
8
|
onCreated,
|
|
@@ -10,31 +11,11 @@ export function CreateCounter({
|
|
|
10
11
|
}) {
|
|
11
12
|
const counterPackageId = useNetworkVariable("counterPackageId");
|
|
12
13
|
const suiClient = useSuiClient();
|
|
13
|
-
const {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
});
|
|
25
|
-
|
|
26
|
-
return (
|
|
27
|
-
<Container>
|
|
28
|
-
<Button
|
|
29
|
-
size="3"
|
|
30
|
-
onClick={() => {
|
|
31
|
-
create();
|
|
32
|
-
}}
|
|
33
|
-
>
|
|
34
|
-
Create Counter
|
|
35
|
-
</Button>
|
|
36
|
-
</Container>
|
|
37
|
-
);
|
|
14
|
+
const {
|
|
15
|
+
mutate: signAndExecute,
|
|
16
|
+
isSuccess,
|
|
17
|
+
isPending,
|
|
18
|
+
} = useSignAndExecuteTransaction();
|
|
38
19
|
|
|
39
20
|
function create() {
|
|
40
21
|
const tx = new Transaction();
|
|
@@ -49,13 +30,31 @@ export function CreateCounter({
|
|
|
49
30
|
transaction: tx,
|
|
50
31
|
},
|
|
51
32
|
{
|
|
52
|
-
onSuccess: (
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
33
|
+
onSuccess: async ({ digest }) => {
|
|
34
|
+
const { effects } = await suiClient.waitForTransaction({
|
|
35
|
+
digest: digest,
|
|
36
|
+
options: {
|
|
37
|
+
showEffects: true,
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
onCreated(effects?.created?.[0]?.reference?.objectId!);
|
|
57
42
|
},
|
|
58
43
|
},
|
|
59
44
|
);
|
|
60
45
|
}
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<Container>
|
|
49
|
+
<Button
|
|
50
|
+
size="3"
|
|
51
|
+
onClick={() => {
|
|
52
|
+
create();
|
|
53
|
+
}}
|
|
54
|
+
disabled={isSuccess || isPending}
|
|
55
|
+
>
|
|
56
|
+
{isSuccess || isPending ? <ClipLoader size={20} /> : "Create Counter"}
|
|
57
|
+
</Button>
|
|
58
|
+
</Container>
|
|
59
|
+
);
|
|
61
60
|
}
|