@mysten/create-dapp 0.5.13 → 0.6.0
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 +39 -2
- package/README.md +0 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +32 -8
- package/dist/index.js.map +1 -1
- package/package.json +10 -10
- package/src/index.ts +58 -36
- package/templates/.oxlintrc.json +5 -0
- package/templates/react-client-dapp/README.md +31 -4
- package/templates/react-client-dapp/index.html +2 -48
- package/templates/react-client-dapp/package.json +14 -17
- package/templates/react-client-dapp/prettier.config.cjs +0 -1
- package/templates/react-client-dapp/src/App.tsx +12 -30
- package/templates/react-client-dapp/src/OwnedObjects.tsx +58 -31
- package/templates/react-client-dapp/src/WalletStatus.tsx +38 -13
- package/templates/react-client-dapp/src/components/ui/card.tsx +75 -0
- package/templates/react-client-dapp/src/dApp-kit.ts +24 -0
- package/templates/react-client-dapp/src/index.css +39 -0
- package/templates/react-client-dapp/src/lib/utils.ts +6 -0
- package/templates/react-client-dapp/src/main.tsx +8 -14
- package/templates/react-client-dapp/vite.config.mts +2 -1
- package/templates/react-e2e-counter/.gitattributes +2 -0
- package/templates/react-e2e-counter/README.md +53 -7
- package/templates/react-e2e-counter/index.html +2 -48
- package/templates/react-e2e-counter/package.json +18 -20
- package/templates/react-e2e-counter/prettier.config.cjs +0 -1
- package/templates/react-e2e-counter/src/App.tsx +29 -30
- package/templates/react-e2e-counter/src/Counter.tsx +147 -74
- package/templates/react-e2e-counter/src/CreateCounter.tsx +84 -43
- package/templates/react-e2e-counter/src/components/ui/button.tsx +52 -0
- package/templates/react-e2e-counter/src/components/ui/card.tsx +75 -0
- package/templates/react-e2e-counter/src/constants.ts +4 -3
- package/templates/react-e2e-counter/src/contracts/counter/counter.ts +96 -0
- package/templates/react-e2e-counter/src/contracts/utils/index.ts +243 -0
- package/templates/react-e2e-counter/src/dApp-kit.ts +48 -0
- package/templates/react-e2e-counter/src/index.css +39 -0
- package/templates/react-e2e-counter/src/lib/utils.ts +6 -0
- package/templates/react-e2e-counter/src/main.tsx +8 -14
- package/templates/react-e2e-counter/sui-codegen.config.ts +13 -0
- package/templates/react-e2e-counter/vite.config.mts +2 -1
- package/templates/react-client-dapp/src/networkConfig.ts +0 -17
- package/templates/react-e2e-counter/src/networkConfig.ts +0 -31
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,42 @@
|
|
|
1
1
|
# @mysten/create-dapp
|
|
2
2
|
|
|
3
|
+
## 0.6.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- e00788c: Update create-dapp templates:
|
|
8
|
+
- Migrate from `@mysten/dapp-kit` to `@mysten/dapp-kit-react`
|
|
9
|
+
- Upgrade React to version 19.2.1
|
|
10
|
+
- Remove forwardRef usage in favor of React 19 ref prop pattern
|
|
11
|
+
- Add TypeScript code generation support using `@mysten/codegen`
|
|
12
|
+
- Update UI components to use shadcn/ui-style card and button components
|
|
13
|
+
- Update to Tailwind CSS v4
|
|
14
|
+
- Update example code to use gRPC client and new SDK patterns
|
|
15
|
+
- Fix transaction result handling to properly unwrap TransactionResult types
|
|
16
|
+
- Add documentation and setup guides
|
|
17
|
+
- Fix dependency injection for devDependencies
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Updated dependencies [e00788c]
|
|
22
|
+
- Updated dependencies [e00788c]
|
|
23
|
+
- Updated dependencies [e00788c]
|
|
24
|
+
- Updated dependencies [e00788c]
|
|
25
|
+
- Updated dependencies [e00788c]
|
|
26
|
+
- Updated dependencies [e00788c]
|
|
27
|
+
- Updated dependencies [e00788c]
|
|
28
|
+
- Updated dependencies [e00788c]
|
|
29
|
+
- Updated dependencies [e00788c]
|
|
30
|
+
- Updated dependencies [e00788c]
|
|
31
|
+
- Updated dependencies [e00788c]
|
|
32
|
+
- Updated dependencies [e00788c]
|
|
33
|
+
- Updated dependencies [e00788c]
|
|
34
|
+
- Updated dependencies [e00788c]
|
|
35
|
+
- Updated dependencies [e00788c]
|
|
36
|
+
- @mysten/sui@2.0.0
|
|
37
|
+
- @mysten/dapp-kit-react@1.0.0
|
|
38
|
+
- @mysten/codegen@0.6.0
|
|
39
|
+
|
|
3
40
|
## 0.5.13
|
|
4
41
|
|
|
5
42
|
### Patch Changes
|
|
@@ -848,8 +885,8 @@
|
|
|
848
885
|
|
|
849
886
|
- a92b03de42: The Typescript SDK has been renamed to `@mysten/sui` and includes many new features
|
|
850
887
|
and breaking changes. See the
|
|
851
|
-
[full migration guide](https://sdk.mystenlabs.com/
|
|
852
|
-
|
|
888
|
+
[full migration guide](https://sdk.mystenlabs.com/sui/migrations/sui-1.0) for details on how to
|
|
889
|
+
upgrade.
|
|
853
890
|
|
|
854
891
|
### Patch Changes
|
|
855
892
|
|
package/README.md
CHANGED
|
@@ -26,7 +26,6 @@ you including:
|
|
|
26
26
|
- [TypeScript](https://www.typescriptlang.org/)
|
|
27
27
|
- [Vite](https://vitejs.dev/)
|
|
28
28
|
- [Radix UI](https://www.radix-ui.com/)
|
|
29
|
-
- [ESLint](https://eslint.org/)
|
|
30
29
|
- [`@mysten/dapp-kit`](https://sdk.mystenlabs.com/dapp-kit)
|
|
31
30
|
|
|
32
31
|
These templates are still new, and would love to get feedback and suggestions for improvements or
|
package/dist/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Copyright (c) Mysten Labs, Inc.
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
/* eslint-disable @typescript-eslint/ban-types */
|
|
5
|
-
/* eslint-disable no-restricted-globals */
|
|
6
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
5
|
const fs_1 = require("fs");
|
|
8
6
|
const promises_1 = require("fs/promises");
|
|
@@ -16,10 +14,15 @@ const { values: args } = (0, util_1.parseArgs)({
|
|
|
16
14
|
default: '',
|
|
17
15
|
short: 't',
|
|
18
16
|
},
|
|
17
|
+
name: {
|
|
18
|
+
type: 'string',
|
|
19
|
+
default: '',
|
|
20
|
+
short: 'n',
|
|
21
|
+
},
|
|
19
22
|
},
|
|
20
23
|
});
|
|
21
24
|
async function main() {
|
|
22
|
-
const
|
|
25
|
+
const questions = [
|
|
23
26
|
{
|
|
24
27
|
type: 'select',
|
|
25
28
|
name: 'template',
|
|
@@ -41,12 +44,26 @@ async function main() {
|
|
|
41
44
|
message: 'What is the name of your dApp? (this will be used as the directory name)',
|
|
42
45
|
initial: 'my-first-sui-dapp',
|
|
43
46
|
},
|
|
44
|
-
].filter((question) =>
|
|
45
|
-
|
|
47
|
+
].filter((question) => {
|
|
48
|
+
if (question.name === 'template' && args.template)
|
|
49
|
+
return false;
|
|
50
|
+
if (question.name === 'dAppName' && args.name)
|
|
51
|
+
return false;
|
|
52
|
+
return true;
|
|
53
|
+
});
|
|
54
|
+
const results = questions.length > 0
|
|
55
|
+
? await (0, enquirer_1.prompt)(questions)
|
|
56
|
+
: { template: undefined, dAppName: undefined };
|
|
57
|
+
const template = results.template ?? args.template;
|
|
58
|
+
const dAppName = results.dAppName ?? args.name;
|
|
59
|
+
if (!template || !dAppName) {
|
|
60
|
+
throw new Error('Template and name are required');
|
|
61
|
+
}
|
|
62
|
+
const outDir = (0, path_1.resolve)(process.cwd(), dAppName);
|
|
46
63
|
if ((0, fs_1.existsSync)(outDir)) {
|
|
47
64
|
throw new Error(`Directory ${outDir} already exists`);
|
|
48
65
|
}
|
|
49
|
-
const files = await collectFiles(
|
|
66
|
+
const files = await collectFiles(template, dAppName);
|
|
50
67
|
await writeFiles(files, outDir);
|
|
51
68
|
}
|
|
52
69
|
main();
|
|
@@ -75,8 +92,15 @@ async function collectFiles(template, dAppName) {
|
|
|
75
92
|
if (entry === 'package.json') {
|
|
76
93
|
const json = JSON.parse(content.toString());
|
|
77
94
|
json.name = dAppName;
|
|
78
|
-
json.dependencies['@mysten/sui']
|
|
79
|
-
|
|
95
|
+
if (json.dependencies?.['@mysten/sui']) {
|
|
96
|
+
json.dependencies['@mysten/sui'] = dependencies['@mysten/sui'];
|
|
97
|
+
}
|
|
98
|
+
if (json.dependencies?.['@mysten/dapp-kit-react']) {
|
|
99
|
+
json.dependencies['@mysten/dapp-kit-react'] = dependencies['@mysten/dapp-kit-react'];
|
|
100
|
+
}
|
|
101
|
+
if (json.devDependencies?.['@mysten/codegen']) {
|
|
102
|
+
json.devDependencies['@mysten/codegen'] = dependencies['@mysten/codegen'];
|
|
103
|
+
}
|
|
80
104
|
content = Buffer.from(JSON.stringify(json, null, 2));
|
|
81
105
|
}
|
|
82
106
|
files.push({ path: (0, path_1.relative)(templateDir, entryPath), content });
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,kCAAkC;AAClC,sCAAsC
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,kCAAkC;AAClC,sCAAsC;;AAEtC,2BAA0C;AAC1C,0CAAkE;AAClE,+BAAyC;AACzC,+BAAiC;AACjC,uCAAkC;AAElC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,IAAA,gBAAS,EAAC;IAClC,OAAO,EAAE;QACR,QAAQ,EAAE;YACT,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,EAAE;YACX,KAAK,EAAE,GAAG;SACV;QACD,IAAI,EAAE;YACL,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,EAAE;YACX,KAAK,EAAE,GAAG;SACV;KACD;CACD,CAAC,CAAC;AAEH,KAAK,UAAU,IAAI;IAClB,MAAM,SAAS,GAAG;QACjB;YACC,IAAI,EA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AAC,IAAA,eAAU,EAAC,OAAO,CAAC,EAAE,CAAC;YAC1B,MAAM,IAAA,gBAAK,EAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC3C,CAAC;QAED,MAAM,IAAA,oBAAS,EAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;AACF,CAAC;AAED,KAAK,UAAU,qBAAqB;IACnC,MAAM,WAAW,GAAG,IAAA,cAAO,EAAC,SAAS,EAAE,iBAAiB,CAAC,CAAC;IAC1D,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,IAAA,mBAAQ,EAAC,WAAW,EAAE,OAAO,CAAC,CAE9D,CAAC;IAEF,OAAO,OAAO,CAAC,YAAY,CAAC;AAC7B,CAAC"}
|
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.
|
|
6
|
+
"version": "0.6.0",
|
|
7
7
|
"license": "Apache-2.0",
|
|
8
8
|
"files": [
|
|
9
9
|
"CHANGELOG.md",
|
|
@@ -28,14 +28,14 @@
|
|
|
28
28
|
"access": "public"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"typescript": "^5.9.3"
|
|
32
|
-
"@mysten/build-scripts": "0.0.0"
|
|
31
|
+
"typescript": "^5.9.3"
|
|
33
32
|
},
|
|
34
33
|
"dependencies": {
|
|
35
|
-
"@types/node": "^
|
|
34
|
+
"@types/node": "^25.0.8",
|
|
36
35
|
"enquirer": "^2.4.1",
|
|
37
|
-
"@mysten/
|
|
38
|
-
"@mysten/dapp-kit": "0.
|
|
36
|
+
"@mysten/codegen": "^0.6.0",
|
|
37
|
+
"@mysten/dapp-kit-react": "^1.0.0",
|
|
38
|
+
"@mysten/sui": "^2.0.0"
|
|
39
39
|
},
|
|
40
40
|
"sideEffects": false,
|
|
41
41
|
"bin": "./bin/index.js",
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
"build": "tsc --build",
|
|
45
45
|
"prettier:check": "prettier -c --ignore-unknown .",
|
|
46
46
|
"prettier:fix": "prettier -w --ignore-unknown .",
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"lint": "pnpm run
|
|
50
|
-
"lint:fix": "pnpm run
|
|
47
|
+
"oxlint:check": "oxlint .",
|
|
48
|
+
"oxlint:fix": "oxlint --fix",
|
|
49
|
+
"lint": "pnpm run oxlint:check && pnpm run prettier:check",
|
|
50
|
+
"lint:fix": "pnpm run oxlint:fix && pnpm run prettier:fix"
|
|
51
51
|
}
|
|
52
52
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
// Copyright (c) Mysten Labs, Inc.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
/* eslint-disable @typescript-eslint/ban-types */
|
|
4
|
-
/* eslint-disable no-restricted-globals */
|
|
5
3
|
|
|
6
4
|
import { existsSync, statSync } from 'fs';
|
|
7
5
|
import { mkdir, readdir, readFile, writeFile } from 'fs/promises';
|
|
@@ -16,47 +14,62 @@ const { values: args } = parseArgs({
|
|
|
16
14
|
default: '',
|
|
17
15
|
short: 't',
|
|
18
16
|
},
|
|
17
|
+
name: {
|
|
18
|
+
type: 'string',
|
|
19
|
+
default: '',
|
|
20
|
+
short: 'n',
|
|
21
|
+
},
|
|
19
22
|
},
|
|
20
23
|
});
|
|
21
24
|
|
|
22
25
|
async function main() {
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
26
|
+
const questions = [
|
|
27
|
+
{
|
|
28
|
+
type: 'select',
|
|
29
|
+
name: 'template',
|
|
30
|
+
message: 'Which starter template would you like to use?',
|
|
31
|
+
choices: [
|
|
32
|
+
{
|
|
33
|
+
name: 'react-client-dapp',
|
|
34
|
+
hint: 'React Client dApp that reads data from wallet and the blockchain',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: 'react-e2e-counter',
|
|
38
|
+
hint: 'React dApp with a move smart contract that implements a distributed counter',
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
type: 'input',
|
|
44
|
+
name: 'dAppName',
|
|
45
|
+
message: 'What is the name of your dApp? (this will be used as the directory name)',
|
|
46
|
+
initial: 'my-first-sui-dapp',
|
|
47
|
+
},
|
|
48
|
+
].filter((question) => {
|
|
49
|
+
if (question.name === 'template' && args.template) return false;
|
|
50
|
+
if (question.name === 'dAppName' && args.name) return false;
|
|
51
|
+
return true;
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const results =
|
|
55
|
+
questions.length > 0
|
|
56
|
+
? await prompt<{ template?: string; dAppName?: string }>(questions)
|
|
57
|
+
: { template: undefined, dAppName: undefined };
|
|
58
|
+
|
|
59
|
+
const template = results.template ?? args.template;
|
|
60
|
+
const dAppName = results.dAppName ?? args.name;
|
|
61
|
+
|
|
62
|
+
if (!template || !dAppName) {
|
|
63
|
+
throw new Error('Template and name are required');
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const outDir = resolve(process.cwd(), dAppName);
|
|
54
67
|
|
|
55
68
|
if (existsSync(outDir)) {
|
|
56
69
|
throw new Error(`Directory ${outDir} already exists`);
|
|
57
70
|
}
|
|
58
71
|
|
|
59
|
-
const files = await collectFiles(
|
|
72
|
+
const files = await collectFiles(template, dAppName);
|
|
60
73
|
await writeFiles(files, outDir);
|
|
61
74
|
}
|
|
62
75
|
|
|
@@ -96,8 +109,17 @@ async function collectFiles(template: string, dAppName: string) {
|
|
|
96
109
|
if (entry === 'package.json') {
|
|
97
110
|
const json = JSON.parse(content.toString());
|
|
98
111
|
json.name = dAppName;
|
|
99
|
-
|
|
100
|
-
json.dependencies['@mysten/
|
|
112
|
+
|
|
113
|
+
if (json.dependencies?.['@mysten/sui']) {
|
|
114
|
+
json.dependencies['@mysten/sui'] = dependencies['@mysten/sui'];
|
|
115
|
+
}
|
|
116
|
+
if (json.dependencies?.['@mysten/dapp-kit-react']) {
|
|
117
|
+
json.dependencies['@mysten/dapp-kit-react'] = dependencies['@mysten/dapp-kit-react'];
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (json.devDependencies?.['@mysten/codegen']) {
|
|
121
|
+
json.devDependencies['@mysten/codegen'] = dependencies['@mysten/codegen'];
|
|
122
|
+
}
|
|
101
123
|
|
|
102
124
|
content = Buffer.from(JSON.stringify(json, null, 2));
|
|
103
125
|
}
|
|
@@ -6,12 +6,25 @@ Client dApp using the following tools:
|
|
|
6
6
|
- [React](https://react.dev/) as the UI framework
|
|
7
7
|
- [TypeScript](https://www.typescriptlang.org/) for type checking
|
|
8
8
|
- [Vite](https://vitejs.dev/) for build tooling
|
|
9
|
-
- [
|
|
10
|
-
- [
|
|
11
|
-
- [`@mysten/dapp-kit`](https://sdk.mystenlabs.com/dapp-kit) for connecting
|
|
12
|
-
wallets and loading data
|
|
9
|
+
- [Tailwind CSS v4](https://tailwindcss.com/) for styling
|
|
10
|
+
- [Lucide React](https://lucide.dev/) for icons
|
|
11
|
+
- [`@mysten/dapp-kit-react`](https://sdk.mystenlabs.com/dapp-kit) for connecting
|
|
12
|
+
to wallets and loading data
|
|
13
13
|
- [pnpm](https://pnpm.io/) for package management
|
|
14
14
|
|
|
15
|
+
## Project Structure
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
src/
|
|
19
|
+
├── components/ui/ # Reusable UI components (Card)
|
|
20
|
+
├── lib/utils.ts # Utility functions (cn for classnames)
|
|
21
|
+
├── App.tsx # Main application component
|
|
22
|
+
├── WalletStatus.tsx # Wallet connection status display
|
|
23
|
+
├── OwnedObjects.tsx # Display objects owned by connected wallet
|
|
24
|
+
├── dApp-kit.ts # dApp Kit configuration
|
|
25
|
+
└── index.css # Tailwind CSS with theme variables
|
|
26
|
+
```
|
|
27
|
+
|
|
15
28
|
## Starting your dApp
|
|
16
29
|
|
|
17
30
|
To install dependencies you can run
|
|
@@ -33,3 +46,17 @@ To build your app for deployment you can run
|
|
|
33
46
|
```bash
|
|
34
47
|
pnpm build
|
|
35
48
|
```
|
|
49
|
+
|
|
50
|
+
## Customizing the UI
|
|
51
|
+
|
|
52
|
+
This template uses [Tailwind CSS v4](https://tailwindcss.com/docs) for styling
|
|
53
|
+
with [shadcn/ui](https://ui.shadcn.com/)-style components. The UI components in
|
|
54
|
+
`src/components/ui/` are based on shadcn/ui patterns and can be customized or
|
|
55
|
+
extended.
|
|
56
|
+
|
|
57
|
+
To add more shadcn/ui components, you can copy them from the
|
|
58
|
+
[shadcn/ui components](https://ui.shadcn.com/docs/components) documentation and
|
|
59
|
+
adapt them to work with your project.
|
|
60
|
+
|
|
61
|
+
Theme variables are defined in `src/index.css` using Tailwind's `@theme`
|
|
62
|
+
directive.
|
|
@@ -1,58 +1,12 @@
|
|
|
1
1
|
<!doctype html>
|
|
2
|
-
<html lang="en"
|
|
2
|
+
<html lang="en">
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
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
8
|
</head>
|
|
55
|
-
<body>
|
|
9
|
+
<body class="min-h-screen antialiased">
|
|
56
10
|
<div id="root"></div>
|
|
57
11
|
<script type="module" src="/src/main.tsx"></script>
|
|
58
12
|
</body>
|
|
@@ -6,30 +6,27 @@
|
|
|
6
6
|
"scripts": {
|
|
7
7
|
"dev": "vite",
|
|
8
8
|
"build": "tsc && vite build",
|
|
9
|
-
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
|
10
9
|
"preview": "vite preview"
|
|
11
10
|
},
|
|
12
11
|
"dependencies": {
|
|
13
|
-
"@mysten/dapp-kit": "workspace
|
|
14
|
-
"@mysten/sui": "workspace
|
|
15
|
-
"@
|
|
16
|
-
"@
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"react": "^19.2.
|
|
20
|
-
"react-dom": "^19.2.
|
|
12
|
+
"@mysten/dapp-kit-react": "workspace:^",
|
|
13
|
+
"@mysten/sui": "workspace:^",
|
|
14
|
+
"@nanostores/react": "^1.0.0",
|
|
15
|
+
"@tanstack/react-query": "^5.90.16",
|
|
16
|
+
"clsx": "^2.1.1",
|
|
17
|
+
"lucide-react": "^0.562.0",
|
|
18
|
+
"react": "^19.2.3",
|
|
19
|
+
"react-dom": "^19.2.3",
|
|
20
|
+
"tailwind-merge": "^3.4.0"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@
|
|
23
|
+
"@tailwindcss/vite": "^4.0.0",
|
|
24
|
+
"@types/react": "^19.2.8",
|
|
24
25
|
"@types/react-dom": "^19.2.3",
|
|
25
|
-
"@typescript-eslint/eslint-plugin": "^8.48.1",
|
|
26
|
-
"@typescript-eslint/parser": "^8.48.1",
|
|
27
26
|
"@vitejs/plugin-react-swc": "^4.2.2",
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"eslint-plugin-react-refresh": "^0.4.20",
|
|
31
|
-
"prettier": "^3.7.3",
|
|
27
|
+
"prettier": "^3.7.4",
|
|
28
|
+
"tailwindcss": "^4.1.18",
|
|
32
29
|
"typescript": "^5.9.3",
|
|
33
|
-
"vite": "^7.
|
|
30
|
+
"vite": "^7.3.1"
|
|
34
31
|
}
|
|
35
32
|
}
|
|
@@ -1,38 +1,20 @@
|
|
|
1
|
-
import { ConnectButton } from "@mysten/dapp-kit";
|
|
2
|
-
import { Box, Container, Flex, Heading } from "@radix-ui/themes";
|
|
1
|
+
import { ConnectButton } from "@mysten/dapp-kit-react";
|
|
3
2
|
import { WalletStatus } from "./WalletStatus";
|
|
4
3
|
|
|
5
4
|
function App() {
|
|
6
5
|
return (
|
|
7
|
-
|
|
8
|
-
<
|
|
9
|
-
|
|
10
|
-
|
|
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>
|
|
6
|
+
<div className="min-h-screen">
|
|
7
|
+
<header className="sticky top-0 z-50 border-b bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60">
|
|
8
|
+
<div className="container mx-auto flex h-14 items-center justify-between px-4">
|
|
9
|
+
<h1 className="text-lg font-semibold">Sui dApp Starter</h1>
|
|
22
10
|
<ConnectButton />
|
|
23
|
-
</
|
|
24
|
-
</
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
style={{ background: "var(--gray-a2)", minHeight: 500 }}
|
|
31
|
-
>
|
|
32
|
-
<WalletStatus />
|
|
33
|
-
</Container>
|
|
34
|
-
</Container>
|
|
35
|
-
</>
|
|
11
|
+
</div>
|
|
12
|
+
</header>
|
|
13
|
+
|
|
14
|
+
<main className="container mx-auto px-4 py-8">
|
|
15
|
+
<WalletStatus />
|
|
16
|
+
</main>
|
|
17
|
+
</div>
|
|
36
18
|
);
|
|
37
19
|
}
|
|
38
20
|
|
|
@@ -1,42 +1,69 @@
|
|
|
1
|
-
import { useCurrentAccount,
|
|
2
|
-
import {
|
|
1
|
+
import { useCurrentAccount, useCurrentClient } from "@mysten/dapp-kit-react";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import {
|
|
4
|
+
Card,
|
|
5
|
+
CardContent,
|
|
6
|
+
CardDescription,
|
|
7
|
+
CardHeader,
|
|
8
|
+
CardTitle,
|
|
9
|
+
} from "./components/ui/card";
|
|
10
|
+
import { Package, Loader2 } from "lucide-react";
|
|
3
11
|
|
|
4
12
|
export function OwnedObjects() {
|
|
5
13
|
const account = useCurrentAccount();
|
|
6
|
-
const
|
|
7
|
-
"getOwnedObjects",
|
|
8
|
-
{
|
|
9
|
-
owner: account?.address as string,
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
enabled: !!account,
|
|
13
|
-
},
|
|
14
|
-
);
|
|
14
|
+
const client = useCurrentClient();
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
const { data, isPending, error } = useQuery({
|
|
17
|
+
queryKey: ["ownedObjects", account?.address],
|
|
18
|
+
queryFn: async () => {
|
|
19
|
+
if (!account) return null;
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
const { response } = await client.stateService.listOwnedObjects({
|
|
22
|
+
owner: account.address,
|
|
23
|
+
});
|
|
24
|
+
return response.objects ?? [];
|
|
25
|
+
},
|
|
26
|
+
enabled: !!account,
|
|
27
|
+
});
|
|
23
28
|
|
|
24
|
-
if (
|
|
25
|
-
return
|
|
29
|
+
if (!account) {
|
|
30
|
+
return null;
|
|
26
31
|
}
|
|
27
32
|
|
|
28
33
|
return (
|
|
29
|
-
<
|
|
30
|
-
|
|
31
|
-
<
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
34
|
+
<Card>
|
|
35
|
+
<CardHeader>
|
|
36
|
+
<CardTitle className="flex items-center gap-2">
|
|
37
|
+
<Package className="h-5 w-5" />
|
|
38
|
+
Owned Objects
|
|
39
|
+
</CardTitle>
|
|
40
|
+
<CardDescription>Objects owned by the connected wallet</CardDescription>
|
|
41
|
+
</CardHeader>
|
|
42
|
+
<CardContent>
|
|
43
|
+
{error ? (
|
|
44
|
+
<p className="text-destructive-foreground">
|
|
45
|
+
Error: {(error as Error)?.message || "Unknown error"}
|
|
46
|
+
</p>
|
|
47
|
+
) : isPending || !data ? (
|
|
48
|
+
<div className="flex items-center gap-2 text-muted-foreground">
|
|
49
|
+
<Loader2 className="h-4 w-4 animate-spin" />
|
|
50
|
+
Loading objects...
|
|
51
|
+
</div>
|
|
52
|
+
) : data.length === 0 ? (
|
|
53
|
+
<p className="text-muted-foreground">No objects found</p>
|
|
54
|
+
) : (
|
|
55
|
+
<div className="space-y-2">
|
|
56
|
+
{data.map((object) => (
|
|
57
|
+
<div
|
|
58
|
+
key={object.objectId}
|
|
59
|
+
className="rounded-md border bg-muted/50 p-3"
|
|
60
|
+
>
|
|
61
|
+
<p className="font-mono text-xs break-all">{object.objectId}</p>
|
|
62
|
+
</div>
|
|
63
|
+
))}
|
|
64
|
+
</div>
|
|
65
|
+
)}
|
|
66
|
+
</CardContent>
|
|
67
|
+
</Card>
|
|
41
68
|
);
|
|
42
69
|
}
|