create-dubhe 0.1.6 → 0.1.8
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/index.js +1 -1
- package/package.json +11 -3
- package/template/101/aptos-template/.prettierignore +1 -0
- package/template/101/aptos-template/.prettierrc +7 -7
- package/template/101/aptos-template/.prettierrc.json +8 -0
- package/template/101/aptos-template/README.md +3 -2
- package/template/101/aptos-template/jest.config.ts +3 -3
- package/template/101/aptos-template/next-i18next.config.js +4 -4
- package/template/101/aptos-template/next.config.js +11 -12
- package/template/101/aptos-template/package.json +10 -5
- package/template/101/aptos-template/postcss.config.js +1 -1
- package/template/101/aptos-template/public/locales/de/common.json +1 -1
- package/template/101/aptos-template/public/locales/de/footer.json +1 -1
- package/template/101/aptos-template/public/locales/de/second-page.json +1 -1
- package/template/101/aptos-template/public/locales/en/footer.json +1 -1
- package/template/101/aptos-template/public/locales/en/second-page.json +1 -1
- package/template/101/aptos-template/public/locales/zn/common.json +1 -1
- package/template/101/aptos-template/public/locales/zn/footer.json +1 -1
- package/template/101/aptos-template/public/locales/zn/second-page.json +1 -1
- package/template/101/aptos-template/scripts/checkBalance.ts +1 -1
- package/template/101/aptos-template/src/css/font-awesome.css +692 -687
- package/template/101/aptos-template/src/css/font-awesome.min.css +2333 -1
- package/template/101/aptos-template/tailwind.config.js +40 -52
- package/template/101/initia-template/.prettierignore +1 -0
- package/template/101/initia-template/.prettierrc +7 -7
- package/template/101/initia-template/.prettierrc.json +8 -0
- package/template/101/initia-template/README.md +3 -2
- package/template/101/initia-template/jest.config.ts +3 -3
- package/template/101/initia-template/next-i18next.config.js +4 -4
- package/template/101/initia-template/next.config.js +11 -12
- package/template/101/initia-template/package.json +8 -3
- package/template/101/initia-template/postcss.config.js +1 -1
- package/template/101/initia-template/public/locales/de/common.json +1 -1
- package/template/101/initia-template/public/locales/de/footer.json +1 -1
- package/template/101/initia-template/public/locales/de/second-page.json +1 -1
- package/template/101/initia-template/public/locales/en/footer.json +1 -1
- package/template/101/initia-template/public/locales/en/second-page.json +1 -1
- package/template/101/initia-template/public/locales/zn/common.json +1 -1
- package/template/101/initia-template/public/locales/zn/footer.json +1 -1
- package/template/101/initia-template/public/locales/zn/second-page.json +1 -1
- package/template/101/initia-template/src/chain/config.ts +1 -1
- package/template/101/initia-template/src/css/font-awesome.css +692 -687
- package/template/101/initia-template/src/css/font-awesome.min.css +2333 -1
- package/template/101/initia-template/src/pages/index.tsx +7 -9
- package/template/101/initia-template/tailwind.config.js +40 -52
- package/template/101/movement-template/.prettierignore +1 -0
- package/template/101/movement-template/.prettierrc +7 -7
- package/template/101/movement-template/.prettierrc.json +8 -0
- package/template/101/movement-template/README.md +3 -2
- package/template/101/movement-template/jest.config.ts +3 -3
- package/template/101/movement-template/next-i18next.config.js +4 -4
- package/template/101/movement-template/next.config.js +11 -12
- package/template/101/movement-template/package.json +10 -5
- package/template/101/movement-template/postcss.config.js +1 -1
- package/template/101/movement-template/public/locales/de/common.json +1 -1
- package/template/101/movement-template/public/locales/de/footer.json +1 -1
- package/template/101/movement-template/public/locales/de/second-page.json +1 -1
- package/template/101/movement-template/public/locales/en/footer.json +1 -1
- package/template/101/movement-template/public/locales/en/second-page.json +1 -1
- package/template/101/movement-template/public/locales/zn/common.json +1 -1
- package/template/101/movement-template/public/locales/zn/footer.json +1 -1
- package/template/101/movement-template/public/locales/zn/second-page.json +1 -1
- package/template/101/movement-template/src/css/font-awesome.css +692 -687
- package/template/101/movement-template/src/css/font-awesome.min.css +2333 -1
- package/template/101/movement-template/tailwind.config.js +40 -52
- package/template/101/rooch-template/.prettierignore +1 -0
- package/template/101/rooch-template/.prettierrc +7 -7
- package/template/101/rooch-template/.prettierrc.json +8 -0
- package/template/101/rooch-template/README.md +3 -2
- package/template/101/rooch-template/jest.config.ts +3 -3
- package/template/101/rooch-template/next-i18next.config.js +4 -4
- package/template/101/rooch-template/next.config.js +11 -12
- package/template/101/rooch-template/package.json +8 -3
- package/template/101/rooch-template/postcss.config.js +1 -1
- package/template/101/rooch-template/public/locales/de/common.json +1 -1
- package/template/101/rooch-template/public/locales/de/footer.json +1 -1
- package/template/101/rooch-template/public/locales/de/second-page.json +1 -1
- package/template/101/rooch-template/public/locales/en/footer.json +1 -1
- package/template/101/rooch-template/public/locales/en/second-page.json +1 -1
- package/template/101/rooch-template/public/locales/zn/common.json +1 -1
- package/template/101/rooch-template/public/locales/zn/footer.json +1 -1
- package/template/101/rooch-template/public/locales/zn/second-page.json +1 -1
- package/template/101/rooch-template/src/chain/config.ts +1 -1
- package/template/101/rooch-template/src/css/font-awesome.css +692 -687
- package/template/101/rooch-template/src/css/font-awesome.min.css +2333 -1
- package/template/101/rooch-template/src/pages/index.tsx +7 -9
- package/template/101/rooch-template/tailwind.config.js +40 -52
- package/template/101/sui-template/.prettierignore +1 -0
- package/template/101/sui-template/.prettierrc.json +8 -0
- package/template/101/sui-template/README.md +4 -2
- package/template/101/sui-template/contracts/counter/sources/codegen/dapp/metadata.move +1 -1
- package/template/101/sui-template/contracts/counter/sources/codegen/dapp/schema.move +2 -2
- package/template/101/sui-template/contracts/counter/sources/codegen/dapp/system.move +7 -7
- package/template/101/sui-template/contracts/counter/sources/codegen/data/increment_event.move +1 -1
- package/template/101/sui-template/contracts/counter/sources/codegen/errors.move +3 -3
- package/template/101/sui-template/contracts/counter/sources/codegen/events.move +4 -4
- package/template/101/sui-template/contracts/counter/sources/codegen/genesis.move +5 -5
- package/template/101/sui-template/contracts/counter/sources/codegen/schema.move +9 -1
- package/template/101/sui-template/contracts/counter/sources/scripts/deploy_hook.move +2 -2
- package/template/101/sui-template/contracts/counter/sources/scripts/migrate.move +1 -1
- package/template/101/sui-template/contracts/counter/sources/systems/counter.move +3 -3
- package/template/101/sui-template/contracts/counter/sources/tests/counter.move +3 -3
- package/template/101/sui-template/contracts/counter/sources/tests/init.move +3 -3
- package/template/101/sui-template/dubhe.config.ts +4 -4
- package/template/101/sui-template/package.json +8 -7
- package/template/cocos/aptos-template/README.md +2 -1
- package/template/cocos/aptos-template/assets/Scripts/aptos.ts +15 -15
- package/template/cocos/aptos-template/assets/Scripts/chain/config.ts +5 -5
- package/template/cocos/aptos-template/assets/Scripts/dubhe.config.ts +8 -8
- package/template/cocos/aptos-template/assets/lib/obelisk.js +23107 -19762
- package/template/cocos/aptos-template/package.json +37 -37
- package/template/cocos/aptos-template/scripts/formatAccount.ts +18 -18
- package/template/cocos/aptos-template/scripts/generateAccount.ts +2 -2
- package/template/cocos/aptos-template/scripts/storeConfig.ts +37 -37
- package/template/cocos/aptos-template/tsconfig.json +2 -2
- package/template/cocos/sui-template/README.md +2 -1
- package/template/cocos/sui-template/assets/Scripts/chain/config.ts +3 -7
- package/template/cocos/sui-template/assets/Scripts/dubhe.config.ts +9 -9
- package/template/cocos/sui-template/assets/Scripts/sui.ts +87 -103
- package/template/cocos/sui-template/docker-compose.yaml +10 -4
- package/template/cocos/sui-template/package.json +25 -25
- package/template/cocos/sui-template/scripts/generateAccount.ts +38 -38
- package/template/cocos/sui-template/scripts/storeConfig.ts +36 -41
- package/template/cocos/sui-template/tsconfig.json +3 -10
- package/template/contract/sui-template/dubhe.config.ts +3 -3
- package/template/contract/sui-template/package.json +28 -28
- package/template/contract/sui-template/tsconfig.json +3 -13
- package/template/nextjs/aptos-template/.prettierignore +1 -0
- package/template/nextjs/aptos-template/.prettierrc +7 -7
- package/template/nextjs/aptos-template/.prettierrc.json +8 -0
- package/template/nextjs/aptos-template/README.md +2 -1
- package/template/nextjs/aptos-template/jest.config.ts +3 -3
- package/template/nextjs/aptos-template/next-i18next.config.js +4 -4
- package/template/nextjs/aptos-template/next.config.js +11 -12
- package/template/nextjs/aptos-template/package.json +11 -8
- package/template/nextjs/aptos-template/postcss.config.js +1 -1
- package/template/nextjs/aptos-template/public/locales/de/common.json +1 -1
- package/template/nextjs/aptos-template/public/locales/de/footer.json +1 -1
- package/template/nextjs/aptos-template/public/locales/de/second-page.json +1 -1
- package/template/nextjs/aptos-template/public/locales/en/footer.json +1 -1
- package/template/nextjs/aptos-template/public/locales/en/second-page.json +1 -1
- package/template/nextjs/aptos-template/public/locales/zn/common.json +1 -1
- package/template/nextjs/aptos-template/public/locales/zn/footer.json +1 -1
- package/template/nextjs/aptos-template/public/locales/zn/second-page.json +1 -1
- package/template/nextjs/aptos-template/src/components/Animation.tsx +60 -70
- package/template/nextjs/aptos-template/src/components/Container.tsx +2 -8
- package/template/nextjs/aptos-template/src/components/footer/index.tsx +124 -135
- package/template/nextjs/aptos-template/src/components/head/index.tsx +14 -14
- package/template/nextjs/aptos-template/src/components/header/index.tsx +143 -157
- package/template/nextjs/aptos-template/src/components/pop_up_box/index.tsx +150 -138
- package/template/nextjs/aptos-template/src/css/font-awesome.css +692 -687
- package/template/nextjs/aptos-template/src/css/font-awesome.min.css +2333 -1
- package/template/nextjs/aptos-template/src/jotai/index.tsx +9 -10
- package/template/nextjs/aptos-template/src/pages/_app.tsx +16 -16
- package/template/nextjs/aptos-template/src/pages/index.tsx +7 -10
- package/template/nextjs/aptos-template/tailwind.config.js +44 -55
- package/template/nextjs/aptos-template/tsconfig.json +3 -13
- package/template/nextjs/sui-template/.prettierignore +1 -0
- package/template/nextjs/sui-template/.prettierrc.json +8 -0
- package/template/nextjs/sui-template/README.md +4 -2
- package/template/nextjs/sui-template/contracts/counter/sources/codegen/dapp/metadata.move +1 -1
- package/template/nextjs/sui-template/contracts/counter/sources/codegen/dapp/schema.move +2 -2
- package/template/nextjs/sui-template/contracts/counter/sources/codegen/dapp/system.move +7 -7
- package/template/nextjs/sui-template/contracts/counter/sources/codegen/data/increment_event.move +1 -1
- package/template/nextjs/sui-template/contracts/counter/sources/codegen/errors.move +3 -3
- package/template/nextjs/sui-template/contracts/counter/sources/codegen/events.move +4 -4
- package/template/nextjs/sui-template/contracts/counter/sources/codegen/genesis.move +5 -5
- package/template/nextjs/sui-template/contracts/counter/sources/codegen/schema.move +9 -1
- package/template/nextjs/sui-template/contracts/counter/sources/scripts/deploy_hook.move +2 -2
- package/template/nextjs/sui-template/contracts/counter/sources/scripts/migrate.move +1 -1
- package/template/nextjs/sui-template/contracts/counter/sources/systems/counter.move +3 -3
- package/template/nextjs/sui-template/contracts/counter/sources/tests/counter.move +3 -3
- package/template/nextjs/sui-template/contracts/counter/sources/tests/init.move +3 -3
- package/template/nextjs/sui-template/dubhe.config.ts +4 -4
- package/template/nextjs/sui-template/next.config.mjs +1 -2
- package/template/nextjs/sui-template/package.json +9 -8
- package/template/nextjs/sui-template/src/chain/config.ts +2 -2
|
@@ -1,39 +1,39 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
2
|
+
"name": "dubhe-cocos-template",
|
|
3
|
+
"uuid": "ba0d698f-d890-4886-831d-0920a44b3236",
|
|
4
|
+
"creator": {
|
|
5
|
+
"version": "3.8.0"
|
|
6
|
+
},
|
|
7
|
+
"scripts": {
|
|
8
|
+
"dev": "pnpm dubhe hello && pnpm run localnode && sleep 15 && ts-node scripts/generateAccount.ts && pnpm dubhe faucet --network local && pnpm dubhe publish --network local --configPath ./assets/Scripts/dubhe.config.ts && ts-node scripts/storeConfig.ts local && tail -f localnode.nohup.out",
|
|
9
|
+
"dev:movement": "pnpm dubhe hello && pnpm run start-movement-template",
|
|
10
|
+
"start-movement-template": "ts-node scripts/formatAccount.ts && pnpm dubhe publish --network movementdevnet --configPath ./assets/Scripts/dubhe.config.ts && ts-node scripts/storeConfig.ts movementdevnet",
|
|
11
|
+
"faucet-localnet": "pnpm dubhe faucet --network local",
|
|
12
|
+
"faucet-devnet": "pnpm dubhe faucet --network devnet",
|
|
13
|
+
"faucet-testnet": "pnpm dubhe faucet --network testnet",
|
|
14
|
+
"world-publsih-localnet": "pnpm dubhe publish --network local --configPath ./assets/Scripts/dubhe.config.ts && ts-node scripts/storeConfig.ts local",
|
|
15
|
+
"world-publsih-devnet": "pnpm dubhe publish --network devnet --configPath ./assets/Scripts/dubhe.config.ts && ts-node scripts/storeConfig.ts devnet",
|
|
16
|
+
"world-publsih-testnet": "pnpm dubhe publish --network testnet --configPath ./assets/Scripts/dubhe.config.ts && ts-node scripts/storeConfig.ts testnet",
|
|
17
|
+
"world-publsih-mainnet": "pnpm dubhe publish --network mainnet --configPath ./assets/Scripts/dubhe.config.ts && ts-node scripts/storeConfig.ts mainnet",
|
|
18
|
+
"world-upgrade-localnet": "pnpm dubhe upgrade --network local --configPath ./assets/Scripts/dubhe.config.ts && ts-node scripts/storeConfig.ts local",
|
|
19
|
+
"world-upgrade-devnet": "pnpm dubhe upgrade --network devnet --configPath ./assets/Scripts/dubhe.config.ts && ts-node scripts/storeConfig.ts devnet",
|
|
20
|
+
"world-upgrade-testnet": "pnpm dubhe upgrade --network testnet --configPath ./assets/Scripts/dubhe.config.ts && ts-node scripts/storeConfig.ts testnet",
|
|
21
|
+
"world-upgrade-mainnet": "pnpm dubhe upgrade --network mainnet --configPath ./assets/Scripts/dubhe.config.ts && ts-node scripts/storeConfig.ts mainnet",
|
|
22
|
+
"localnode": "nohup pnpm dubhe localnode > localnode.nohup.out &",
|
|
23
|
+
"worldgen": "pnpm dubhe schemagen ./assets/Scripts/dubhe.config.ts",
|
|
24
|
+
"storeConfig": "ts-node scripts/storeConfig.ts",
|
|
25
|
+
"generateAccount": "ts-node scripts/generateAccount.ts"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@0xobelisk/aptos-common": "^0.0.8",
|
|
29
|
+
"@0xobelisk/aptos-client": "^0.0.19",
|
|
30
|
+
"@0xobelisk/aptos-cli": "^0.0.16",
|
|
31
|
+
"aptos": "^1.20.0",
|
|
32
|
+
"dotenv": "^16.0.3"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@types/node": "18.16.16",
|
|
36
|
+
"ts-node": "^10.9.1",
|
|
37
|
+
"typescript": "^5.1.6"
|
|
38
|
+
}
|
|
39
39
|
}
|
|
@@ -4,32 +4,32 @@ import * as dotenv from 'dotenv';
|
|
|
4
4
|
dotenv.config();
|
|
5
5
|
|
|
6
6
|
function generateAccount() {
|
|
7
|
-
|
|
7
|
+
const PRIVATE_KEY = process.env.PRIVATE_KEY;
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
if (PRIVATE_KEY === undefined) {
|
|
10
|
+
console.log('Missing PRIVATE_KEY in .env');
|
|
11
|
+
process.exit(0);
|
|
12
|
+
}
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
const keypair = AptosAccount.fromAptosAccountObject({
|
|
15
|
+
privateKeyHex: PRIVATE_KEY
|
|
16
|
+
});
|
|
17
|
+
const privateKey = keypair.toPrivateKeyObject().privateKeyHex;
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
const path = process.cwd();
|
|
20
|
+
const chainFolderPath = `${path}/src/chain`;
|
|
21
|
+
fs.mkdirSync(chainFolderPath, { recursive: true });
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
// fs.writeFileSync(`${path}/.env`, `PRIVATE_KEY=${privateKey}`);
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
fs.writeFileSync(
|
|
26
|
+
`${path}/src/chain/key.ts`,
|
|
27
|
+
`export const PRIVATEKEY = '${privateKey}';
|
|
28
28
|
export const ACCOUNT = '${keypair.address().toString()}';
|
|
29
29
|
`
|
|
30
|
-
|
|
30
|
+
);
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
console.log(`Format env Account: ${keypair.address().toString()}`);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
generateAccount();
|
|
@@ -5,34 +5,34 @@ import { dubheConfig } from '../assets/Scripts/dubhe.config';
|
|
|
5
5
|
import { dirname } from 'path';
|
|
6
6
|
|
|
7
7
|
type DeploymentJsonType = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
8
|
+
projectName: string;
|
|
9
|
+
network:
|
|
10
|
+
| 'mainnet'
|
|
11
|
+
| 'testnet'
|
|
12
|
+
| 'devnet'
|
|
13
|
+
| 'local'
|
|
14
|
+
| 'movementtestnet'
|
|
15
|
+
| 'movementdevnet'
|
|
16
|
+
| 'movementlocal';
|
|
17
|
+
packageId: string;
|
|
18
|
+
version: number;
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
async function getDeploymentJson(projectPath: string, network: string) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
22
|
+
try {
|
|
23
|
+
const data = await fsAsync.readFile(
|
|
24
|
+
`${projectPath}/.history/aptos_${network}/latest.json`,
|
|
25
|
+
'utf8'
|
|
26
|
+
);
|
|
27
|
+
return JSON.parse(data) as DeploymentJsonType;
|
|
28
|
+
} catch {
|
|
29
|
+
console.log('store config failed.');
|
|
30
|
+
exit;
|
|
31
|
+
}
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
function storeConfig(network: string, packageId: string) {
|
|
35
|
-
|
|
35
|
+
let code = `import { NetworkType } from '@0xobelisk/aptos-client';
|
|
36
36
|
|
|
37
37
|
const NETWORK = '${network}' as NetworkType;
|
|
38
38
|
|
|
@@ -40,29 +40,29 @@ const PACKAGE_ID = '${packageId}';
|
|
|
40
40
|
|
|
41
41
|
export { NETWORK, PACKAGE_ID };
|
|
42
42
|
`;
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
const path = process.cwd();
|
|
44
|
+
writeOutput(code, `${path}/assets/Scripts/chain/config.ts`, 'storeConfig');
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
async function writeOutput(
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
output: string,
|
|
49
|
+
fullOutputPath: string,
|
|
50
|
+
logPrefix?: string
|
|
51
51
|
): Promise<void> {
|
|
52
|
-
|
|
52
|
+
mkdirSync(dirname(fullOutputPath), { recursive: true });
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
writeFileSync(fullOutputPath, output);
|
|
55
|
+
if (logPrefix !== undefined) {
|
|
56
|
+
console.log(`${logPrefix}: ${fullOutputPath}`);
|
|
57
|
+
}
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
async function main() {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
61
|
+
const path = process.cwd();
|
|
62
|
+
const network = process.argv[2];
|
|
63
|
+
const contractPath = `${path}/contracts/${dubheConfig.name}`;
|
|
64
|
+
const deployment = await getDeploymentJson(contractPath, network);
|
|
65
|
+
storeConfig(deployment.network, deployment.packageId);
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
main();
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"allowJs": true,
|
|
7
7
|
"experimentalDecorators": true,
|
|
8
8
|
"skipLibCheck": true,
|
|
9
|
-
"resolveJsonModule": true
|
|
9
|
+
"resolveJsonModule": true
|
|
10
10
|
},
|
|
11
|
-
"exclude": ["node_modules", "library", "local", "temp", "build", "settings"
|
|
11
|
+
"exclude": ["node_modules", "library", "local", "temp", "build", "settings"]
|
|
12
12
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
## How to use
|
|
2
|
+
|
|
2
3
|
```bash
|
|
3
4
|
|
|
4
5
|
1 install sui <https://docs.sui.io/build/install>
|
|
5
6
|
2 import project by cocos create IDE
|
|
6
7
|
3 pnpm i
|
|
7
8
|
4 pnpm run dev
|
|
8
|
-
5 start your cocos project
|
|
9
|
+
5 start your cocos project
|
|
9
10
|
```
|
|
10
11
|
|
|
11
12
|
Deploy it to the cloud with [Vercel](https://vercel.com/new?utm_source=github&utm_medium=readme&utm_campaign=next-example) ([Documentation](https://nextjs.org/docs/deployment)).
|
|
@@ -2,11 +2,7 @@ type NetworkType = 'testnet' | 'mainnet' | 'devnet' | 'localnet';
|
|
|
2
2
|
|
|
3
3
|
const NETWORK: NetworkType = 'localnet';
|
|
4
4
|
|
|
5
|
-
const PACKAGE_ID = '0x8eb4a5f43d92d8b95cfab98d421897744881f7bde2c8b1a26417e5f23b6d0f6d'
|
|
6
|
-
const WORLD_ID = '0x6c6abaf48f31bdff8de2c8c23f0ce86d8a8c400274094dcd17c25fd29b36dbe0'
|
|
5
|
+
const PACKAGE_ID = '0x8eb4a5f43d92d8b95cfab98d421897744881f7bde2c8b1a26417e5f23b6d0f6d';
|
|
6
|
+
const WORLD_ID = '0x6c6abaf48f31bdff8de2c8c23f0ce86d8a8c400274094dcd17c25fd29b36dbe0';
|
|
7
7
|
|
|
8
|
-
export {
|
|
9
|
-
NETWORK,
|
|
10
|
-
PACKAGE_ID,
|
|
11
|
-
WORLD_ID,
|
|
12
|
-
}
|
|
8
|
+
export { NETWORK, PACKAGE_ID, WORLD_ID };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { DubheConfig } from '@0xobelisk/sui-common';
|
|
2
2
|
|
|
3
3
|
export const dubheConfig = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
name: 'counter',
|
|
5
|
+
description: 'counter',
|
|
6
|
+
systems: ['counter_system'],
|
|
7
|
+
schemas: {
|
|
8
|
+
counter: {
|
|
9
|
+
valueType: 'u64',
|
|
10
|
+
defaultValue: 0
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
13
|
} as DubheConfig;
|
|
@@ -6,115 +6,99 @@ const { ccclass, property } = _decorator;
|
|
|
6
6
|
|
|
7
7
|
@ccclass('sui')
|
|
8
8
|
export class sui extends Component {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
async start() {
|
|
10
|
+
this.sui_account_create();
|
|
11
|
+
}
|
|
12
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
);
|
|
48
|
-
const counter_node = find('Canvas/Camera/counter');
|
|
49
|
-
const label = counter_node.getComponent(
|
|
50
|
-
'cc.Label'
|
|
51
|
-
) as LabelComponent;
|
|
52
|
-
label.string = `Counter: ${component_value}`;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
13
|
+
async sui_account_create() {
|
|
14
|
+
// @ts-ignore
|
|
15
|
+
const dubhe_sdk = window.dubhe;
|
|
16
|
+
const decode = JSON.parse(sys.localStorage.getItem('userWalletData'));
|
|
17
|
+
if (decode == null) {
|
|
18
|
+
const keypair = new dubhe_sdk.Ed25519Keypair();
|
|
19
|
+
const wallet = keypair.export();
|
|
20
|
+
const code = JSON.stringify(wallet);
|
|
21
|
+
sys.localStorage.setItem('userWalletData', code);
|
|
22
|
+
const metadata = await dubhe_sdk.loadMetadata(NETWORK, PACKAGE_ID);
|
|
23
|
+
const dubhe = new dubhe_sdk.Dubhe({
|
|
24
|
+
networkType: NETWORK,
|
|
25
|
+
packageId: PACKAGE_ID,
|
|
26
|
+
metadata: metadata
|
|
27
|
+
});
|
|
28
|
+
const address = keypair.getPublicKey().toSuiAddress();
|
|
29
|
+
await dubhe.requestFaucet(address, NETWORK);
|
|
30
|
+
const component_name = Object.keys(dubheConfig.schemas)[0];
|
|
31
|
+
const component_value = await dubhe.getEntity(WORLD_ID, component_name);
|
|
32
|
+
console.log(component_value);
|
|
33
|
+
} else {
|
|
34
|
+
const metadata = await dubhe_sdk.loadMetadata(NETWORK, PACKAGE_ID);
|
|
35
|
+
const dubhe = new dubhe_sdk.Dubhe({
|
|
36
|
+
networkType: NETWORK,
|
|
37
|
+
packageId: PACKAGE_ID,
|
|
38
|
+
metadata: metadata
|
|
39
|
+
});
|
|
40
|
+
const component_name = Object.keys(dubheConfig.schemas)[0];
|
|
41
|
+
const component_value = await dubhe.getEntity(WORLD_ID, component_name);
|
|
42
|
+
const counter_node = find('Canvas/Camera/counter');
|
|
43
|
+
const label = counter_node.getComponent('cc.Label') as LabelComponent;
|
|
44
|
+
label.string = `Counter: ${component_value}`;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
55
47
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
.join('');
|
|
74
|
-
return hex_privkey;
|
|
75
|
-
}
|
|
48
|
+
async export_wallet() {
|
|
49
|
+
// @ts-ignore
|
|
50
|
+
const dubhe_sdk = window.dubhe;
|
|
51
|
+
const fromB64 = dubhe_sdk.fromB64;
|
|
52
|
+
const decode = JSON.parse(sys.localStorage.getItem('userWalletData'));
|
|
53
|
+
const decode_private_key = decode.privateKey;
|
|
54
|
+
const base_64_privkey = fromB64(decode_private_key);
|
|
55
|
+
const keypair = dubhe_sdk.Ed25519Keypair.fromSecretKey(base_64_privkey, {
|
|
56
|
+
skipValidation: false
|
|
57
|
+
});
|
|
58
|
+
const address = keypair.getPublicKey().toSuiAddress();
|
|
59
|
+
console.log(address);
|
|
60
|
+
const hex_privkey = Array.prototype.map
|
|
61
|
+
.call(base_64_privkey, (x) => ('00' + x.toString(16)).slice(-2))
|
|
62
|
+
.join('');
|
|
63
|
+
return hex_privkey;
|
|
64
|
+
}
|
|
76
65
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
66
|
+
async gameStart() {
|
|
67
|
+
// @ts-ignore
|
|
68
|
+
const dubhe_sdk = window.dubhe;
|
|
69
|
+
const metadata = await dubhe_sdk.loadMetadata(NETWORK, PACKAGE_ID);
|
|
70
|
+
console.log(metadata);
|
|
82
71
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
72
|
+
const privateKey = await this.export_wallet();
|
|
73
|
+
// new dubhe class
|
|
74
|
+
const dubhe = new dubhe_sdk.Dubhe({
|
|
75
|
+
networkType: NETWORK,
|
|
76
|
+
packageId: PACKAGE_ID,
|
|
77
|
+
metadata: metadata,
|
|
78
|
+
secretKey: privateKey
|
|
79
|
+
});
|
|
91
80
|
|
|
92
|
-
|
|
93
|
-
|
|
81
|
+
const tx = new dubhe_sdk.TransactionBlock();
|
|
82
|
+
const world = tx.pure(WORLD_ID);
|
|
94
83
|
|
|
95
|
-
|
|
84
|
+
const params = [world];
|
|
96
85
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
'cc.Label'
|
|
114
|
-
) as LabelComponent;
|
|
115
|
-
label.string = `Counter: ${component_value}`;
|
|
116
|
-
}, 100);
|
|
117
|
-
}
|
|
86
|
+
const result = await dubhe.tx.counter_system.inc(tx, params);
|
|
87
|
+
console.log(result);
|
|
88
|
+
setTimeout(async () => {
|
|
89
|
+
const metadata = await dubhe_sdk.loadMetadata(NETWORK, PACKAGE_ID);
|
|
90
|
+
const dubhe = new dubhe_sdk.Dubhe({
|
|
91
|
+
networkType: NETWORK,
|
|
92
|
+
packageId: PACKAGE_ID,
|
|
93
|
+
metadata: metadata
|
|
94
|
+
});
|
|
95
|
+
const component_name = Object.keys(dubheConfig.schemas)[0];
|
|
96
|
+
const component_value = await dubhe.getEntity(WORLD_ID, component_name);
|
|
97
|
+
const counter_node = find('Canvas/Camera/counter');
|
|
98
|
+
const label = counter_node.getComponent('cc.Label') as LabelComponent;
|
|
99
|
+
label.string = `Counter: ${component_value}`;
|
|
100
|
+
}, 100);
|
|
101
|
+
}
|
|
118
102
|
|
|
119
|
-
|
|
103
|
+
update(deltaTime: number) {}
|
|
120
104
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
version: "3"
|
|
1
|
+
version: '3'
|
|
3
2
|
|
|
4
3
|
services:
|
|
5
4
|
sui-test-validator-node:
|
|
@@ -10,9 +9,16 @@ services:
|
|
|
10
9
|
ports:
|
|
11
10
|
- 9000:9000
|
|
12
11
|
- 9123:9123
|
|
13
|
-
command:
|
|
12
|
+
command:
|
|
13
|
+
[
|
|
14
|
+
'/opt/sui/bin/sui-test-validator',
|
|
15
|
+
'--fullnode-rpc-addr',
|
|
16
|
+
'0.0.0.0:9000',
|
|
17
|
+
'--faucet-addr',
|
|
18
|
+
'0.0.0.0:9123'
|
|
19
|
+
]
|
|
14
20
|
healthcheck:
|
|
15
|
-
test: [
|
|
21
|
+
test: ['CMD', 'curl', '-f', 'http://sui-test-validator-node:9123']
|
|
16
22
|
interval: 3s
|
|
17
23
|
timeout: 5s
|
|
18
24
|
retries: 10
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
2
|
+
"name": "dubhe-cocos-template",
|
|
3
|
+
"uuid": "ba0d698f-d890-4886-831d-0920a44b3236",
|
|
4
|
+
"creator": {
|
|
5
|
+
"version": "3.8.0"
|
|
6
|
+
},
|
|
7
|
+
"scripts": {
|
|
8
|
+
"dev": "pnpm dubhe hello && pnpm start-template",
|
|
9
|
+
"start-template": "pnpm generateAccount && pnpm faucet && pnpm dapp-publish && pnpm storeConfig",
|
|
10
|
+
"faucet": "pnpm dubhe faucet --network testnet",
|
|
11
|
+
"schemagen": "pnpm dubhe schemagen --config-path ./dubhe.config.ts",
|
|
12
|
+
"dapp-publish": "pnpm dubhe publish --network testnet --config-path ./assets/Scripts/dubhe.config.ts && ts-node scripts/storeConfig.ts testnet",
|
|
13
|
+
"upgrade": "pnpm dubhe upgrade --network testnet && ts-node scripts/storeConfig.ts testnet",
|
|
14
|
+
"storeConfig": "ts-node scripts/storeConfig.ts testnet",
|
|
15
|
+
"generateAccount": "ts-node scripts/generateAccount.ts"
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@0xobelisk/sui-cli": "^0.5.34",
|
|
19
|
+
"@0xobelisk/sui-client": "^0.5.30",
|
|
20
|
+
"@0xobelisk/sui-common": "^0.5.23"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@types/node": "18.16.16",
|
|
24
|
+
"ts-node": "^10.9.1",
|
|
25
|
+
"typescript": "^5.1.6"
|
|
26
|
+
}
|
|
27
27
|
}
|