create-dubhe 0.0.1
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/LICENSE +21 -0
- package/README.md +9 -0
- package/dist/index.mjs +100 -0
- package/index.js +3 -0
- package/package.json +46 -0
- package/template/101/aptos-template/.dockerignore +7 -0
- package/template/101/aptos-template/.eslintrc.json +3 -0
- package/template/101/aptos-template/.prettierrc +8 -0
- package/template/101/aptos-template/Dockerfile +56 -0
- package/template/101/aptos-template/LICENSE +674 -0
- package/template/101/aptos-template/README.md +14 -0
- package/template/101/aptos-template/contracts/counter/Move.toml +16 -0
- package/template/101/aptos-template/contracts/counter/sources/codegen/eps/events.move +34 -0
- package/template/101/aptos-template/contracts/counter/sources/codegen/eps/world.move +65 -0
- package/template/101/aptos-template/contracts/counter/sources/codegen/init.move +17 -0
- package/template/101/aptos-template/contracts/counter/sources/codegen/schemas/counter.move +59 -0
- package/template/101/aptos-template/contracts/counter/sources/entity_key.move +31 -0
- package/template/101/aptos-template/contracts/counter/sources/script/deploy_hook.move +19 -0
- package/template/101/aptos-template/contracts/counter/sources/system/counter_system.move +11 -0
- package/template/101/aptos-template/dubhe.config.ts +13 -0
- package/template/101/aptos-template/jest.config.ts +17 -0
- package/template/101/aptos-template/next-env.d.ts +5 -0
- package/template/101/aptos-template/next-i18next.config.js +6 -0
- package/template/101/aptos-template/next.config.js +15 -0
- package/template/101/aptos-template/package.json +83 -0
- package/template/101/aptos-template/postcss.config.js +6 -0
- package/template/101/aptos-template/public/discord.svg +9 -0
- package/template/101/aptos-template/public/fail.svg +12 -0
- package/template/101/aptos-template/public/favicon.ico +0 -0
- package/template/101/aptos-template/public/locales/de/common.json +8 -0
- package/template/101/aptos-template/public/locales/de/footer.json +3 -0
- package/template/101/aptos-template/public/locales/de/second-page.json +5 -0
- package/template/101/aptos-template/public/locales/en/common.json +8 -0
- package/template/101/aptos-template/public/locales/en/footer.json +3 -0
- package/template/101/aptos-template/public/locales/en/second-page.json +5 -0
- package/template/101/aptos-template/public/locales/zn/common.json +8 -0
- package/template/101/aptos-template/public/locales/zn/footer.json +3 -0
- package/template/101/aptos-template/public/locales/zn/second-page.json +5 -0
- package/template/101/aptos-template/public/logo.svg +1 -0
- package/template/101/aptos-template/public/medium.svg +9 -0
- package/template/101/aptos-template/public/successful.svg +11 -0
- package/template/101/aptos-template/public/telegram.svg +9 -0
- package/template/101/aptos-template/public/twitter.svg +9 -0
- package/template/101/aptos-template/scripts/formatAccount.ts +35 -0
- package/template/101/aptos-template/scripts/generateAccount.ts +25 -0
- package/template/101/aptos-template/scripts/storeConfig.ts +54 -0
- package/template/101/aptos-template/src/chain/config.ts +7 -0
- package/template/101/aptos-template/src/css/font-awesome.css +2337 -0
- package/template/101/aptos-template/src/css/font-awesome.min.css +4 -0
- package/template/101/aptos-template/src/fonts/FontAwesome.otf +0 -0
- package/template/101/aptos-template/src/fonts/fontawesome-webfont.eot +0 -0
- package/template/101/aptos-template/src/fonts/fontawesome-webfont.svg +2671 -0
- package/template/101/aptos-template/src/fonts/fontawesome-webfont.ttf +0 -0
- package/template/101/aptos-template/src/fonts/fontawesome-webfont.woff +0 -0
- package/template/101/aptos-template/src/fonts/fontawesome-webfont.woff2 +0 -0
- package/template/101/aptos-template/src/jotai/index.tsx +12 -0
- package/template/101/aptos-template/src/pages/_app.tsx +9 -0
- package/template/101/aptos-template/src/pages/home/index.tsx +78 -0
- package/template/101/aptos-template/src/pages/index.tsx +12 -0
- package/template/101/aptos-template/tailwind.config.js +56 -0
- package/template/101/aptos-template/tsconfig.json +25 -0
- package/template/101/sui-template/.dockerignore +7 -0
- package/template/101/sui-template/.eslintrc.json +3 -0
- package/template/101/sui-template/.prettierrc +8 -0
- package/template/101/sui-template/Dockerfile +52 -0
- package/template/101/sui-template/LICENSE +674 -0
- package/template/101/sui-template/README.md +14 -0
- package/template/101/sui-template/contracts/counter/Move.toml +13 -0
- package/template/101/sui-template/contracts/counter/sources/codegen/dapp_key.move +16 -0
- package/template/101/sui-template/contracts/counter/sources/codegen/schemas/counter.move +50 -0
- package/template/101/sui-template/contracts/counter/sources/script/deploy_hook.move +67 -0
- package/template/101/sui-template/contracts/counter/sources/system/counter.move +11 -0
- package/template/101/sui-template/docker-compose.yaml +29 -0
- package/template/101/sui-template/dubhe.config.ts +14 -0
- package/template/101/sui-template/jest.config.ts +17 -0
- package/template/101/sui-template/localnet/dubhe-framework/Move.toml +39 -0
- package/template/101/sui-template/localnet/dubhe-framework/README.md +18 -0
- package/template/101/sui-template/localnet/dubhe-framework/sources/access_control.move +35 -0
- package/template/101/sui-template/localnet/dubhe-framework/sources/events.move +23 -0
- package/template/101/sui-template/localnet/dubhe-framework/sources/resource_id.move +22 -0
- package/template/101/sui-template/localnet/dubhe-framework/sources/resource_types.move +18 -0
- package/template/101/sui-template/localnet/dubhe-framework/sources/schema.move +36 -0
- package/template/101/sui-template/localnet/dubhe-framework/sources/schemas/dapps/dapps.move +73 -0
- package/template/101/sui-template/localnet/dubhe-framework/sources/schemas/dapps/metadata.move +96 -0
- package/template/101/sui-template/localnet/dubhe-framework/sources/storages/double_map.move +156 -0
- package/template/101/sui-template/localnet/dubhe-framework/sources/storages/map.move +159 -0
- package/template/101/sui-template/localnet/dubhe-framework/sources/storages/value.move +100 -0
- package/template/101/sui-template/localnet/dubhe-framework/sources/systems/dapps.move +90 -0
- package/template/101/sui-template/localnet/dubhe-framework/sources/world.move +81 -0
- package/template/101/sui-template/localnet/dubhe-framework/tests/dapp.move +16 -0
- package/template/101/sui-template/localnet/dubhe-framework/tests/init.move +6 -0
- package/template/101/sui-template/localnet/dubhe-framework/tests/obelisk_framework_tests.move +19 -0
- package/template/101/sui-template/localnet/dubhe-framework/tests/storage.move +398 -0
- package/template/101/sui-template/next-env.d.ts +5 -0
- package/template/101/sui-template/next-i18next.config.js +6 -0
- package/template/101/sui-template/next.config.js +15 -0
- package/template/101/sui-template/package.json +82 -0
- package/template/101/sui-template/postcss.config.js +6 -0
- package/template/101/sui-template/public/discord.svg +9 -0
- package/template/101/sui-template/public/fail.svg +12 -0
- package/template/101/sui-template/public/favicon.ico +0 -0
- package/template/101/sui-template/public/locales/de/common.json +8 -0
- package/template/101/sui-template/public/locales/de/footer.json +3 -0
- package/template/101/sui-template/public/locales/de/second-page.json +5 -0
- package/template/101/sui-template/public/locales/en/common.json +8 -0
- package/template/101/sui-template/public/locales/en/footer.json +3 -0
- package/template/101/sui-template/public/locales/en/second-page.json +5 -0
- package/template/101/sui-template/public/locales/zn/common.json +8 -0
- package/template/101/sui-template/public/locales/zn/footer.json +3 -0
- package/template/101/sui-template/public/locales/zn/second-page.json +5 -0
- package/template/101/sui-template/public/logo.svg +1 -0
- package/template/101/sui-template/public/medium.svg +9 -0
- package/template/101/sui-template/public/successful.svg +11 -0
- package/template/101/sui-template/public/telegram.svg +9 -0
- package/template/101/sui-template/public/twitter.svg +9 -0
- package/template/101/sui-template/scripts/checkBalance.ts +40 -0
- package/template/101/sui-template/scripts/deployment/common.ts +60 -0
- package/template/101/sui-template/scripts/deployment/localnet/deploy.ts +42 -0
- package/template/101/sui-template/scripts/deployment/testnet/deploy.ts +48 -0
- package/template/101/sui-template/scripts/deployment/types.ts +13 -0
- package/template/101/sui-template/scripts/framework/common.ts +17 -0
- package/template/101/sui-template/scripts/framework/deploy.ts +199 -0
- package/template/101/sui-template/scripts/framework/parse-history.ts +76 -0
- package/template/101/sui-template/scripts/framework/types.ts +8 -0
- package/template/101/sui-template/scripts/generateAccount.ts +55 -0
- package/template/101/sui-template/scripts/storeConfig.ts +61 -0
- package/template/101/sui-template/scripts/waitNode.ts +9 -0
- package/template/101/sui-template/src/chain/config.ts +7 -0
- package/template/101/sui-template/src/css/font-awesome.css +2337 -0
- package/template/101/sui-template/src/css/font-awesome.min.css +4 -0
- package/template/101/sui-template/src/fonts/FontAwesome.otf +0 -0
- package/template/101/sui-template/src/fonts/fontawesome-webfont.eot +0 -0
- package/template/101/sui-template/src/fonts/fontawesome-webfont.svg +2671 -0
- package/template/101/sui-template/src/fonts/fontawesome-webfont.ttf +0 -0
- package/template/101/sui-template/src/fonts/fontawesome-webfont.woff +0 -0
- package/template/101/sui-template/src/fonts/fontawesome-webfont.woff2 +0 -0
- package/template/101/sui-template/src/jotai/index.tsx +12 -0
- package/template/101/sui-template/src/pages/_app.tsx +9 -0
- package/template/101/sui-template/src/pages/home/index.tsx +82 -0
- package/template/101/sui-template/src/pages/index.tsx +14 -0
- package/template/101/sui-template/tailwind.config.js +56 -0
- package/template/101/sui-template/tsconfig.json +25 -0
- package/template/cocos/aptos-template/.creator/asset-template/typescript/Custom Script Template Help Documentation.url +2 -0
- package/template/cocos/aptos-template/README.md +11 -0
- package/template/cocos/aptos-template/assets/Scripts/aptos.ts +87 -0
- package/template/cocos/aptos-template/assets/Scripts/aptos.ts.meta +9 -0
- package/template/cocos/aptos-template/assets/Scripts/chain/config.ts +12 -0
- package/template/cocos/aptos-template/assets/Scripts/chain/config.ts.meta +9 -0
- package/template/cocos/aptos-template/assets/Scripts/chain/key.ts.meta +9 -0
- package/template/cocos/aptos-template/assets/Scripts/chain.meta +9 -0
- package/template/cocos/aptos-template/assets/Scripts/dubhe.config.ts +13 -0
- package/template/cocos/aptos-template/assets/Scripts/dubhe.config.ts.meta +9 -0
- package/template/cocos/aptos-template/assets/Scripts.meta +9 -0
- package/template/cocos/aptos-template/assets/lib/dubhe.js +22281 -0
- package/template/cocos/aptos-template/assets/lib/obelisk.js +22281 -0
- package/template/cocos/aptos-template/assets/lib/obelisk.js.meta +15 -0
- package/template/cocos/aptos-template/assets/lib.meta +12 -0
- package/template/cocos/aptos-template/assets/main.scene +875 -0
- package/template/cocos/aptos-template/assets/main.scene.meta +11 -0
- package/template/cocos/aptos-template/contracts/counter/Move.toml +16 -0
- package/template/cocos/aptos-template/contracts/counter/sources/codegen/eps/events.move +34 -0
- package/template/cocos/aptos-template/contracts/counter/sources/codegen/eps/world.move +65 -0
- package/template/cocos/aptos-template/contracts/counter/sources/codegen/init.move +17 -0
- package/template/cocos/aptos-template/contracts/counter/sources/codegen/schemas/counter.move +59 -0
- package/template/cocos/aptos-template/contracts/counter/sources/entity_key.move +31 -0
- package/template/cocos/aptos-template/contracts/counter/sources/script/deploy_hook.move +19 -0
- package/template/cocos/aptos-template/contracts/counter/sources/system/counter_system.move +11 -0
- package/template/cocos/aptos-template/package.json +39 -0
- package/template/cocos/aptos-template/scripts/formatAccount.ts +35 -0
- package/template/cocos/aptos-template/scripts/generateAccount.ts +25 -0
- package/template/cocos/aptos-template/scripts/storeConfig.ts +68 -0
- package/template/cocos/aptos-template/settings/v2/packages/builder.json +3 -0
- package/template/cocos/aptos-template/settings/v2/packages/cocos-service.json +23 -0
- package/template/cocos/aptos-template/settings/v2/packages/device.json +3 -0
- package/template/cocos/aptos-template/settings/v2/packages/engine.json +150 -0
- package/template/cocos/aptos-template/settings/v2/packages/information.json +23 -0
- package/template/cocos/aptos-template/settings/v2/packages/program.json +3 -0
- package/template/cocos/aptos-template/settings/v2/packages/project.json +3 -0
- package/template/cocos/aptos-template/tsconfig.json +12 -0
- package/template/cocos/sui-template/.creator/asset-template/typescript/Custom Script Template Help Documentation.url +2 -0
- package/template/cocos/sui-template/README.md +11 -0
- package/template/cocos/sui-template/assets/Scripts/chain/config.ts +12 -0
- package/template/cocos/sui-template/assets/Scripts/chain/config.ts.meta +9 -0
- package/template/cocos/sui-template/assets/Scripts/chain/key.ts.meta +9 -0
- package/template/cocos/sui-template/assets/Scripts/chain.meta +9 -0
- package/template/cocos/sui-template/assets/Scripts/dubhe.config.ts +13 -0
- package/template/cocos/sui-template/assets/Scripts/dubhe.config.ts.meta +9 -0
- package/template/cocos/sui-template/assets/Scripts/sui.ts +120 -0
- package/template/cocos/sui-template/assets/Scripts/sui.ts.meta +9 -0
- package/template/cocos/sui-template/assets/Scripts.meta +12 -0
- package/template/cocos/sui-template/assets/lib/dubhe.js +55694 -0
- package/template/cocos/sui-template/assets/lib/dubhe.js.meta +15 -0
- package/template/cocos/sui-template/assets/lib.meta +12 -0
- package/template/cocos/sui-template/assets/main.scene +875 -0
- package/template/cocos/sui-template/assets/main.scene.meta +11 -0
- package/template/cocos/sui-template/contracts/counter/Move.toml +13 -0
- package/template/cocos/sui-template/contracts/counter/sources/codegen/dapp_key.move +16 -0
- package/template/cocos/sui-template/contracts/counter/sources/codegen/schemas/counter.move +50 -0
- package/template/cocos/sui-template/contracts/counter/sources/script/deploy_hook.move +67 -0
- package/template/cocos/sui-template/contracts/counter/sources/system/counter.move +11 -0
- package/template/cocos/sui-template/docker-compose.yaml +18 -0
- package/template/cocos/sui-template/package.json +27 -0
- package/template/cocos/sui-template/scripts/generateAccount.ts +55 -0
- package/template/cocos/sui-template/scripts/storeConfig.ts +75 -0
- package/template/cocos/sui-template/settings/v2/packages/builder.json +3 -0
- package/template/cocos/sui-template/settings/v2/packages/cocos-service.json +23 -0
- package/template/cocos/sui-template/settings/v2/packages/device.json +3 -0
- package/template/cocos/sui-template/settings/v2/packages/engine.json +150 -0
- package/template/cocos/sui-template/settings/v2/packages/information.json +23 -0
- package/template/cocos/sui-template/settings/v2/packages/program.json +3 -0
- package/template/cocos/sui-template/settings/v2/packages/project.json +3 -0
- package/template/cocos/sui-template/tsconfig.json +19 -0
- package/template/nextjs/aptos-template/.dockerignore +7 -0
- package/template/nextjs/aptos-template/.eslintrc.json +3 -0
- package/template/nextjs/aptos-template/.prettierrc +8 -0
- package/template/nextjs/aptos-template/Dockerfile +56 -0
- package/template/nextjs/aptos-template/LICENSE +674 -0
- package/template/nextjs/aptos-template/README.md +13 -0
- package/template/nextjs/aptos-template/contracts/counter/Move.toml +16 -0
- package/template/nextjs/aptos-template/contracts/counter/sources/codegen/eps/events.move +34 -0
- package/template/nextjs/aptos-template/contracts/counter/sources/codegen/eps/world.move +65 -0
- package/template/nextjs/aptos-template/contracts/counter/sources/codegen/init.move +17 -0
- package/template/nextjs/aptos-template/contracts/counter/sources/codegen/schemas/counter.move +59 -0
- package/template/nextjs/aptos-template/contracts/counter/sources/entity_key.move +31 -0
- package/template/nextjs/aptos-template/contracts/counter/sources/script/deploy_hook.move +19 -0
- package/template/nextjs/aptos-template/contracts/counter/sources/system/counter_system.move +11 -0
- package/template/nextjs/aptos-template/dubhe.config.ts +13 -0
- package/template/nextjs/aptos-template/jest.config.ts +17 -0
- package/template/nextjs/aptos-template/next-env.d.ts +5 -0
- package/template/nextjs/aptos-template/next-i18next.config.js +6 -0
- package/template/nextjs/aptos-template/next.config.js +15 -0
- package/template/nextjs/aptos-template/package.json +82 -0
- package/template/nextjs/aptos-template/postcss.config.js +6 -0
- package/template/nextjs/aptos-template/public/discord.svg +9 -0
- package/template/nextjs/aptos-template/public/fail.svg +12 -0
- package/template/nextjs/aptos-template/public/favicon.ico +0 -0
- package/template/nextjs/aptos-template/public/locales/de/common.json +8 -0
- package/template/nextjs/aptos-template/public/locales/de/footer.json +3 -0
- package/template/nextjs/aptos-template/public/locales/de/second-page.json +5 -0
- package/template/nextjs/aptos-template/public/locales/en/common.json +8 -0
- package/template/nextjs/aptos-template/public/locales/en/footer.json +3 -0
- package/template/nextjs/aptos-template/public/locales/en/second-page.json +5 -0
- package/template/nextjs/aptos-template/public/locales/zn/common.json +8 -0
- package/template/nextjs/aptos-template/public/locales/zn/footer.json +3 -0
- package/template/nextjs/aptos-template/public/locales/zn/second-page.json +5 -0
- package/template/nextjs/aptos-template/public/logo.svg +1 -0
- package/template/nextjs/aptos-template/public/medium.svg +9 -0
- package/template/nextjs/aptos-template/public/successful.svg +11 -0
- package/template/nextjs/aptos-template/public/telegram.svg +9 -0
- package/template/nextjs/aptos-template/public/twitter.svg +9 -0
- package/template/nextjs/aptos-template/scripts/formatAccount.ts +35 -0
- package/template/nextjs/aptos-template/scripts/generateAccount.ts +25 -0
- package/template/nextjs/aptos-template/scripts/storeConfig.ts +54 -0
- package/template/nextjs/aptos-template/src/chain/config.ts +7 -0
- package/template/nextjs/aptos-template/src/components/Animation.tsx +80 -0
- package/template/nextjs/aptos-template/src/components/Container.tsx +11 -0
- package/template/nextjs/aptos-template/src/components/footer/index.tsx +138 -0
- package/template/nextjs/aptos-template/src/components/head/index.tsx +14 -0
- package/template/nextjs/aptos-template/src/components/header/index.tsx +173 -0
- package/template/nextjs/aptos-template/src/components/pop_up_box/index.tsx +149 -0
- package/template/nextjs/aptos-template/src/css/font-awesome.css +2337 -0
- package/template/nextjs/aptos-template/src/css/font-awesome.min.css +4 -0
- package/template/nextjs/aptos-template/src/fonts/FontAwesome.otf +0 -0
- package/template/nextjs/aptos-template/src/fonts/fontawesome-webfont.eot +0 -0
- package/template/nextjs/aptos-template/src/fonts/fontawesome-webfont.svg +2671 -0
- package/template/nextjs/aptos-template/src/fonts/fontawesome-webfont.ttf +0 -0
- package/template/nextjs/aptos-template/src/fonts/fontawesome-webfont.woff +0 -0
- package/template/nextjs/aptos-template/src/fonts/fontawesome-webfont.woff2 +0 -0
- package/template/nextjs/aptos-template/src/jotai/index.tsx +13 -0
- package/template/nextjs/aptos-template/src/pages/_app.tsx +32 -0
- package/template/nextjs/aptos-template/src/pages/home/index.tsx +112 -0
- package/template/nextjs/aptos-template/src/pages/index.tsx +15 -0
- package/template/nextjs/aptos-template/tailwind.config.js +59 -0
- package/template/nextjs/aptos-template/tsconfig.json +35 -0
- package/template/nextjs/sui-template/.dockerignore +7 -0
- package/template/nextjs/sui-template/.eslintrc.json +3 -0
- package/template/nextjs/sui-template/.prettierrc +8 -0
- package/template/nextjs/sui-template/Dockerfile +52 -0
- package/template/nextjs/sui-template/LICENSE +674 -0
- package/template/nextjs/sui-template/README.md +13 -0
- package/template/nextjs/sui-template/contracts/counter/Move.toml +13 -0
- package/template/nextjs/sui-template/contracts/counter/sources/codegen/dapp_key.move +16 -0
- package/template/nextjs/sui-template/contracts/counter/sources/codegen/schemas/counter.move +50 -0
- package/template/nextjs/sui-template/contracts/counter/sources/script/deploy_hook.move +67 -0
- package/template/nextjs/sui-template/contracts/counter/sources/system/counter.move +11 -0
- package/template/nextjs/sui-template/docker-compose.yaml +29 -0
- package/template/nextjs/sui-template/dubhe.config.ts +14 -0
- package/template/nextjs/sui-template/jest.config.ts +17 -0
- package/template/nextjs/sui-template/localnet/dubhe-framework/Move.toml +39 -0
- package/template/nextjs/sui-template/localnet/dubhe-framework/README.md +18 -0
- package/template/nextjs/sui-template/localnet/dubhe-framework/sources/access_control.move +35 -0
- package/template/nextjs/sui-template/localnet/dubhe-framework/sources/events.move +23 -0
- package/template/nextjs/sui-template/localnet/dubhe-framework/sources/resource_id.move +22 -0
- package/template/nextjs/sui-template/localnet/dubhe-framework/sources/resource_types.move +18 -0
- package/template/nextjs/sui-template/localnet/dubhe-framework/sources/schema.move +36 -0
- package/template/nextjs/sui-template/localnet/dubhe-framework/sources/schemas/dapps/dapps.move +73 -0
- package/template/nextjs/sui-template/localnet/dubhe-framework/sources/schemas/dapps/metadata.move +96 -0
- package/template/nextjs/sui-template/localnet/dubhe-framework/sources/storages/double_map.move +156 -0
- package/template/nextjs/sui-template/localnet/dubhe-framework/sources/storages/map.move +159 -0
- package/template/nextjs/sui-template/localnet/dubhe-framework/sources/storages/value.move +100 -0
- package/template/nextjs/sui-template/localnet/dubhe-framework/sources/systems/dapps.move +90 -0
- package/template/nextjs/sui-template/localnet/dubhe-framework/sources/world.move +81 -0
- package/template/nextjs/sui-template/localnet/dubhe-framework/tests/dapp.move +16 -0
- package/template/nextjs/sui-template/localnet/dubhe-framework/tests/init.move +6 -0
- package/template/nextjs/sui-template/localnet/dubhe-framework/tests/obelisk_framework_tests.move +19 -0
- package/template/nextjs/sui-template/localnet/dubhe-framework/tests/storage.move +398 -0
- package/template/nextjs/sui-template/next-env.d.ts +5 -0
- package/template/nextjs/sui-template/next-i18next.config.js +6 -0
- package/template/nextjs/sui-template/next.config.js +15 -0
- package/template/nextjs/sui-template/package.json +84 -0
- package/template/nextjs/sui-template/postcss.config.js +6 -0
- package/template/nextjs/sui-template/public/discord.svg +9 -0
- package/template/nextjs/sui-template/public/fail.svg +12 -0
- package/template/nextjs/sui-template/public/favicon.ico +0 -0
- package/template/nextjs/sui-template/public/locales/de/common.json +8 -0
- package/template/nextjs/sui-template/public/locales/de/footer.json +3 -0
- package/template/nextjs/sui-template/public/locales/de/second-page.json +5 -0
- package/template/nextjs/sui-template/public/locales/en/common.json +8 -0
- package/template/nextjs/sui-template/public/locales/en/footer.json +3 -0
- package/template/nextjs/sui-template/public/locales/en/second-page.json +5 -0
- package/template/nextjs/sui-template/public/locales/zn/common.json +8 -0
- package/template/nextjs/sui-template/public/locales/zn/footer.json +3 -0
- package/template/nextjs/sui-template/public/locales/zn/second-page.json +5 -0
- package/template/nextjs/sui-template/public/logo.svg +1 -0
- package/template/nextjs/sui-template/public/medium.svg +9 -0
- package/template/nextjs/sui-template/public/successful.svg +11 -0
- package/template/nextjs/sui-template/public/telegram.svg +9 -0
- package/template/nextjs/sui-template/public/twitter.svg +9 -0
- package/template/nextjs/sui-template/scripts/checkBalance.ts +40 -0
- package/template/nextjs/sui-template/scripts/deployment/common.ts +60 -0
- package/template/nextjs/sui-template/scripts/deployment/localnet/deploy.ts +42 -0
- package/template/nextjs/sui-template/scripts/deployment/testnet/deploy.ts +48 -0
- package/template/nextjs/sui-template/scripts/deployment/types.ts +13 -0
- package/template/nextjs/sui-template/scripts/framework/common.ts +17 -0
- package/template/nextjs/sui-template/scripts/framework/deploy.ts +199 -0
- package/template/nextjs/sui-template/scripts/framework/parse-history.ts +76 -0
- package/template/nextjs/sui-template/scripts/framework/types.ts +8 -0
- package/template/nextjs/sui-template/scripts/generateAccount.ts +55 -0
- package/template/nextjs/sui-template/scripts/storeConfig.ts +61 -0
- package/template/nextjs/sui-template/scripts/waitNode.ts +9 -0
- package/template/nextjs/sui-template/src/chain/config.ts +7 -0
- package/template/nextjs/sui-template/src/components/Animation.tsx +80 -0
- package/template/nextjs/sui-template/src/components/Container.tsx +11 -0
- package/template/nextjs/sui-template/src/components/footer/index.tsx +138 -0
- package/template/nextjs/sui-template/src/components/head/index.tsx +14 -0
- package/template/nextjs/sui-template/src/components/header/index.tsx +173 -0
- package/template/nextjs/sui-template/src/components/pop_up_box/index.tsx +149 -0
- package/template/nextjs/sui-template/src/css/font-awesome.css +2337 -0
- package/template/nextjs/sui-template/src/css/font-awesome.min.css +4 -0
- package/template/nextjs/sui-template/src/fonts/FontAwesome.otf +0 -0
- package/template/nextjs/sui-template/src/fonts/fontawesome-webfont.eot +0 -0
- package/template/nextjs/sui-template/src/fonts/fontawesome-webfont.svg +2671 -0
- package/template/nextjs/sui-template/src/fonts/fontawesome-webfont.ttf +0 -0
- package/template/nextjs/sui-template/src/fonts/fontawesome-webfont.woff +0 -0
- package/template/nextjs/sui-template/src/fonts/fontawesome-webfont.woff2 +0 -0
- package/template/nextjs/sui-template/src/jotai/index.tsx +13 -0
- package/template/nextjs/sui-template/src/pages/_app.tsx +32 -0
- package/template/nextjs/sui-template/src/pages/home/index.tsx +147 -0
- package/template/nextjs/sui-template/src/pages/index.tsx +15 -0
- package/template/nextjs/sui-template/tailwind.config.js +56 -0
- package/template/nextjs/sui-template/tsconfig.json +35 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
// Copyright (c) Mysten Labs, Inc.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
#[allow(unused_variable)]
|
|
5
|
+
module dubhe::storage_double_map {
|
|
6
|
+
|
|
7
|
+
// This key does not exist in the map
|
|
8
|
+
const EKeyDoesNotExist: u64 = 0;
|
|
9
|
+
|
|
10
|
+
/// This key already exists in the map
|
|
11
|
+
const EKeyAlreadyExists: u64 = 1;
|
|
12
|
+
|
|
13
|
+
// An entry in the map
|
|
14
|
+
public struct Entry<K1: copy + drop + store, K2: copy + drop + store, V: store> has copy, drop, store {
|
|
15
|
+
key1: K1,
|
|
16
|
+
key2: K2,
|
|
17
|
+
value: V,
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// A map data structure backed by a vector. The map is guaranteed not to contain duplicate keys, but entries
|
|
21
|
+
public struct StorageDoubleMap<K1: copy + drop + store, K2: copy + drop + store, V: store> has store {
|
|
22
|
+
contents: vector<Entry<K1, K2, V>>,
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Create an empty `StorageDoubleMap`
|
|
26
|
+
public fun new<K1: copy + drop + store, K2: copy + drop + store, V: store>(): StorageDoubleMap<K1, K2,V> {
|
|
27
|
+
StorageDoubleMap { contents: vector[] }
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Return true if `self` contains_key an entry for `key`, false otherwise
|
|
31
|
+
public fun contains_key<K1: copy + drop + store, K2: copy + drop + store, V: store>(self: &StorageDoubleMap<K1, K2, V>, key1: K1, key2: K2): bool {
|
|
32
|
+
get_idx_opt(self, key1, key2).is_some()
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Return the number of entries in `self`
|
|
36
|
+
public fun length<K1: copy + drop + store, K2: copy + drop + store, V: store>(self: &StorageDoubleMap<K1, K2, V>): u64 {
|
|
37
|
+
self.contents.length()
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Get a reference to the value bound to `key` in `self`.
|
|
41
|
+
// Aborts if `key` is not bound in `self`.
|
|
42
|
+
public fun borrow<K1: copy + drop + store, K2: copy + drop + store, V: store>(self: &StorageDoubleMap<K1, K2, V>, key1: K1, key2: K2): &V {
|
|
43
|
+
let idx = self.get_idx(key1, key2);
|
|
44
|
+
let entry = &self.contents[idx];
|
|
45
|
+
&entry.value
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Get a mutable reference to the value bound to `key` in `self`.
|
|
49
|
+
// Aborts if `key` is not bound in `self`.
|
|
50
|
+
public fun borrow_mut<K1: copy + drop + store, K2: copy + drop + store, V: store>(self: &mut StorageDoubleMap<K1, K2, V>, key1: K1, key2: K2): &mut V {
|
|
51
|
+
let idx = self.get_idx(key1, key2);
|
|
52
|
+
let entry = &mut self.contents[idx];
|
|
53
|
+
&mut entry.value
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Remove the entry `key` |-> `value` from self. Aborts if `key` is not bound in `self`.
|
|
57
|
+
public fun take<K1: copy + drop + store, K2: copy + drop + store, V: store>(self: &mut StorageDoubleMap<K1, K2,V>, key1: K1, key2: K2): V {
|
|
58
|
+
let idx = self.get_idx(key1, key2);
|
|
59
|
+
let Entry { key1, key2, value } = self.contents.remove(idx);
|
|
60
|
+
value
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public macro fun mutate<$K1: copy + drop, $K2: copy + drop, $V: copy + drop>(
|
|
64
|
+
$self: &mut StorageDoubleMap<$K1, $K2, $V>,
|
|
65
|
+
$key1: $K1,
|
|
66
|
+
$key2: $K2,
|
|
67
|
+
$f: |&mut $V|
|
|
68
|
+
) {
|
|
69
|
+
let self = $self;
|
|
70
|
+
let key1 = $key1;
|
|
71
|
+
let key2 = $key2;
|
|
72
|
+
$f(borrow_mut(self, key1, key2));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Returns a list of keys in the map.
|
|
76
|
+
// Do not assume any particular ordering.
|
|
77
|
+
public fun keys<K1: copy + drop + store, K2: copy + drop + store, V: store>(self: &StorageDoubleMap<K1, K2, V>): (vector<K1>, vector<K2>) {
|
|
78
|
+
let mut i = 0;
|
|
79
|
+
let n = self.contents.length();
|
|
80
|
+
let mut keys1 = vector[];
|
|
81
|
+
let mut keys2 = vector[];
|
|
82
|
+
while (i < n) {
|
|
83
|
+
let entry = self.contents.borrow(i);
|
|
84
|
+
keys1.push_back(entry.key1);
|
|
85
|
+
keys2.push_back(entry.key2);
|
|
86
|
+
i = i + 1;
|
|
87
|
+
};
|
|
88
|
+
(keys1, keys2)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Find the index of `key` in `self`. Return `None` if `key` is not in `self`.
|
|
92
|
+
// Note that map entries are stored in insertion order, *not* sorted by key.
|
|
93
|
+
public fun get_idx_opt<K1: copy + drop + store, K2: copy + drop + store, V: store>(self: &StorageDoubleMap<K1, K2, V>, key1: K1, key2: K2): Option<u64> {
|
|
94
|
+
self.contents.find_index!(|entry| { entry.key1 == key1 && entry.key2 == key2 })
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Find the index of `key` in `self`. Aborts if `key` is not in `self`.
|
|
98
|
+
// Note that map entries are stored in insertion order, *not* sorted by key.
|
|
99
|
+
public fun get_idx<K1: copy + drop + store, K2: copy + drop + store, V: store>(self: &StorageDoubleMap<K1, K2, V>, key1: K1, key2: K2): u64 {
|
|
100
|
+
let idx_opt = self.get_idx_opt(key1, key2);
|
|
101
|
+
assert!(idx_opt.is_some(), EKeyDoesNotExist);
|
|
102
|
+
idx_opt.destroy_some()
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/// Insert the entry `key` |-> `value` into `self`.
|
|
106
|
+
/// Aborts if `key` is already bound in `self`.
|
|
107
|
+
public fun insert<K1: copy + drop + store, K2: copy + drop + store, V: store>(self: &mut StorageDoubleMap<K1, K2, V>, key1: K1, key2: K2, value: V) {
|
|
108
|
+
assert!(!self.contains_key(key1, key2), EKeyAlreadyExists);
|
|
109
|
+
self.contents.push_back(Entry { key1, key2, value })
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// =======================================Value: drop + copy + store=======================================
|
|
113
|
+
|
|
114
|
+
// Insert the entry `key` |-> `value` into `self`.
|
|
115
|
+
public fun set<K1: copy + drop + store, K2: copy + drop + store, V: copy + drop + store>(self: &mut StorageDoubleMap<K1, K2,V>, key1: K1, key2: K2, value: V) {
|
|
116
|
+
let idx = self.get_idx_opt(key1, key2);
|
|
117
|
+
if (idx.is_some()) {
|
|
118
|
+
self.contents[idx.destroy_some()].value = value;
|
|
119
|
+
} else {
|
|
120
|
+
self.contents.push_back(Entry { key1, key2, value })
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Get a reference to the value bound to `key` in `self`.
|
|
125
|
+
// Aborts if `key` is not bound in `self`.
|
|
126
|
+
public fun get<K1: copy + drop + store, K2: copy + drop + store, V: copy + drop + store>(self: &StorageDoubleMap<K1, K2, V>, key1: K1, key2: K2): V {
|
|
127
|
+
let idx = self.get_idx(key1, key2);
|
|
128
|
+
let entry = &self.contents[idx];
|
|
129
|
+
entry.value
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Safely try borrow a value bound to `key` in `self`.
|
|
133
|
+
// Return Some(V) if the value exists, None otherwise.
|
|
134
|
+
// Only works for a "copyable" value as references cannot be stored in `vector`.
|
|
135
|
+
public fun try_get<K1: copy + drop + store, K2: copy + drop + store, V: copy + drop + store>(self: &StorageDoubleMap<K1, K2, V>, key1: K1, key2: K2): Option<V> {
|
|
136
|
+
if (self.contains_key(key1, key2)) {
|
|
137
|
+
option::some(get(self, key1, key2))
|
|
138
|
+
} else {
|
|
139
|
+
option::none()
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Remove the entry `key` |-> `value` from self.
|
|
144
|
+
public fun remove<K1: copy + drop + store, K2: copy + drop + store, V: copy + drop + store>(self: &mut StorageDoubleMap<K1, K2,V>, key1: K1, key2: K2) {
|
|
145
|
+
let idx = self.get_idx_opt(key1, key2);
|
|
146
|
+
if (idx.is_some()) {
|
|
147
|
+
self.contents.remove(idx.destroy_some());
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Returns a list of values in the map.
|
|
152
|
+
// Do not assume any particular ordering.
|
|
153
|
+
public fun values<K1: copy + drop + store, K2: copy + drop + store, V: copy + drop + store>(self: &StorageDoubleMap<K1, K2, V>): vector<V> {
|
|
154
|
+
self.contents.map!(|entry| entry.value)
|
|
155
|
+
}
|
|
156
|
+
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
// Copyright (c) Mysten Labs, Inc.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
#[allow(unused_variable)]
|
|
5
|
+
module dubhe::storage_map {
|
|
6
|
+
|
|
7
|
+
/// This key already exists in the map
|
|
8
|
+
const EKeyAlreadyExists: u64 = 0;
|
|
9
|
+
|
|
10
|
+
/// This key does not exist in the map
|
|
11
|
+
const EKeyDoesNotExist: u64 = 1;
|
|
12
|
+
|
|
13
|
+
/// An entry in the map
|
|
14
|
+
public struct Entry<K: copy + drop + store, V: store> has copy, drop, store {
|
|
15
|
+
key: K,
|
|
16
|
+
value: V,
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/// A map data structure backed by a vector. The map is guaranteed not to contain duplicate keys, but entries
|
|
20
|
+
/// are *not* sorted by key--entries are included in insertion order.
|
|
21
|
+
/// All operations are O(N) in the size of the map--the intention of this data structure is only to provide
|
|
22
|
+
/// the convenience of programming against a map API.
|
|
23
|
+
/// Large maps should use handwritten parent/child relationships instead.
|
|
24
|
+
/// Maps that need sorted iteration rather than insertion order iteration should also be handwritten.
|
|
25
|
+
public struct StorageMap<K: copy + drop + store, V: store> has store {
|
|
26
|
+
contents: vector<Entry<K, V>>,
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/// Create an empty `StorageMap`
|
|
30
|
+
public fun new<K: copy + drop + store, V: store>(): StorageMap<K, V> {
|
|
31
|
+
StorageMap { contents: vector[] }
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/// Return true if `self` contains_key an entry for `key`, false otherwise
|
|
35
|
+
public fun contains_key<K: copy + drop + store, V: store>(self: &StorageMap<K, V>, key: K): bool {
|
|
36
|
+
get_idx_opt(self, key).is_some()
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/// Return the number of entries in `self`
|
|
40
|
+
public fun length<K: copy + drop + store, V: store>(self: &StorageMap<K,V>): u64 {
|
|
41
|
+
self.contents.length()
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/// Get a reference to the value bound to `key` in `self`.
|
|
45
|
+
/// Aborts if `key` is not bound in `self`.
|
|
46
|
+
public fun borrow<K: copy + drop + store, V: store>(self: &StorageMap<K,V>, key: K): &V {
|
|
47
|
+
let idx = self.get_idx(key);
|
|
48
|
+
let entry = &self.contents[idx];
|
|
49
|
+
&entry.value
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
/// Get a mutable reference to the value bound to `key` in `self`.
|
|
54
|
+
/// Aborts if `key` is not bound in `self`.
|
|
55
|
+
public fun borrow_mut<K: copy + drop + store, V: store>(self: &mut StorageMap<K,V>, key: K): &mut V {
|
|
56
|
+
let idx = self.get_idx(key);
|
|
57
|
+
let entry = &mut self.contents[idx];
|
|
58
|
+
&mut entry.value
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/// Remove the entry `key` |-> `value` from self. Aborts if `key` is not bound in `self`.
|
|
62
|
+
public fun take<K: copy + drop + store, V: store>(self: &mut StorageMap<K,V>, key: K): V {
|
|
63
|
+
let idx = self.get_idx(key);
|
|
64
|
+
let Entry { key, value } = self.contents.remove(idx);
|
|
65
|
+
value
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public macro fun mutate<$K: copy + drop + store, $V: store>(
|
|
69
|
+
$self: &mut StorageMap<$K, $V>,
|
|
70
|
+
$key: $K,
|
|
71
|
+
$f: |&mut $V|
|
|
72
|
+
) {
|
|
73
|
+
let self = $self;
|
|
74
|
+
let key = $key;
|
|
75
|
+
$f(borrow_mut(self, key));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/// Returns a list of keys in the map.
|
|
79
|
+
/// Do not assume any particular ordering.
|
|
80
|
+
public fun keys<K: copy + drop + store, V: store>(self: &StorageMap<K, V>): vector<K> {
|
|
81
|
+
let mut i = 0;
|
|
82
|
+
let n = self.contents.length();
|
|
83
|
+
let mut keys = vector[];
|
|
84
|
+
while (i < n) {
|
|
85
|
+
let entry = self.contents.borrow(i);
|
|
86
|
+
keys.push_back(entry.key);
|
|
87
|
+
i = i + 1;
|
|
88
|
+
};
|
|
89
|
+
keys
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/// Find the index of `key` in `self`. Return `None` if `key` is not in `self`.
|
|
93
|
+
/// Note that map entries are stored in insertion order, *not* sorted by key.
|
|
94
|
+
public fun get_idx_opt<K: copy + drop + store, V: store>(self: &StorageMap<K,V>, key: K): Option<u64> {
|
|
95
|
+
self.contents.find_index!(|entry| { entry.key == key})
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/// Find the index of `key` in `self`. Aborts if `key` is not in `self`.
|
|
99
|
+
/// Note that map entries are stored in insertion order, *not* sorted by key.
|
|
100
|
+
public fun get_idx<K: copy + drop + store, V: store>(self: &StorageMap<K,V>, key: K): u64 {
|
|
101
|
+
let idx_opt = self.get_idx_opt(key);
|
|
102
|
+
assert!(idx_opt.is_some(), EKeyDoesNotExist);
|
|
103
|
+
idx_opt.destroy_some()
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/// Insert the entry `key` |-> `value` into `self`.
|
|
107
|
+
/// Aborts if `key` is already bound in `self`.
|
|
108
|
+
public fun insert<K: copy + drop + store, V: store>(self: &mut StorageMap<K,V>, key: K, value: V) {
|
|
109
|
+
assert!(!self.contains_key(key), EKeyAlreadyExists);
|
|
110
|
+
self.contents.push_back(Entry { key, value })
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// =======================================Value: drop + copy + store=======================================
|
|
114
|
+
|
|
115
|
+
/// Adds a key-value pair to the self `self: &mut StorageMap<K, V>`
|
|
116
|
+
/// Aborts with `sui::dynamic_field::EFieldAlreadyExists` if the self already has an entry with
|
|
117
|
+
/// that key `k: K`.
|
|
118
|
+
public fun set<K: copy + drop + store, V: copy + drop + store>(self: &mut StorageMap<K, V>, key: K, value: V) {
|
|
119
|
+
let idx = self.get_idx_opt(key);
|
|
120
|
+
if (idx.is_some()) {
|
|
121
|
+
self.contents[idx.destroy_some()].value = value;
|
|
122
|
+
} else {
|
|
123
|
+
self.contents.push_back(Entry { key, value })
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/// Get a reference to the value bound to `key` in `self`.
|
|
128
|
+
/// Aborts if `key` is not bound in `self`.
|
|
129
|
+
public fun get<K: copy + drop + store, V: copy + drop + store>(self: &StorageMap<K,V>, key: K): V {
|
|
130
|
+
let idx = self.get_idx(key);
|
|
131
|
+
let entry = &self.contents[idx];
|
|
132
|
+
entry.value
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/// Safely try borrow a value bound to `key` in `self`.
|
|
136
|
+
/// Return Some(V) if the value exists, None otherwise.
|
|
137
|
+
/// Only works for a "copyable" value as references cannot be stored in `vector`.
|
|
138
|
+
public fun try_get<K: copy + drop + store, V: copy + drop + store>(self: &StorageMap<K,V>, key: K): Option<V> {
|
|
139
|
+
if (self.contains_key(key)) {
|
|
140
|
+
option::some(get(self, key))
|
|
141
|
+
} else {
|
|
142
|
+
option::none()
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/// Remove the entry `key` |-> `value` from self. Aborts if `key` is not bound in `self`.
|
|
147
|
+
public fun remove<K: copy + drop + store, V: copy + drop + store>(self: &mut StorageMap<K,V>, key: K) {
|
|
148
|
+
let idx = self.get_idx_opt(key);
|
|
149
|
+
if (idx.is_some()) {
|
|
150
|
+
self.contents.remove(idx.destroy_some());
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Returns a list of values in the map.
|
|
155
|
+
// Do not assume any particular ordering.
|
|
156
|
+
public fun values<K: copy + drop + store, V: copy + drop + store>(self: &StorageMap<K, V>): vector<V> {
|
|
157
|
+
self.contents.map!(|entry| entry.value)
|
|
158
|
+
}
|
|
159
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// Copyright (c) Mysten Labs, Inc.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
module dubhe::storage_value {
|
|
5
|
+
|
|
6
|
+
/// This key does not exist in the map
|
|
7
|
+
const EValueDoesNotExist: u64 = 0;
|
|
8
|
+
|
|
9
|
+
/// This key does not exist in the map
|
|
10
|
+
const EValueAlreadyExist: u64 = 1;
|
|
11
|
+
|
|
12
|
+
/// An entry in the value
|
|
13
|
+
public struct Entry<Value: store> has copy, drop, store {
|
|
14
|
+
value: Value,
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/// A storable handler for values in general. Is used in the `StorageValue`
|
|
18
|
+
public struct StorageValue<Value: store> has store {
|
|
19
|
+
contents: vector<Entry<Value>>,
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/// Creates a new, empty StorageValue
|
|
23
|
+
public fun new<Value: store>(): StorageValue<Value> {
|
|
24
|
+
StorageValue { contents: vector[] }
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/// Gets the value of the StorageValue `self: &StorageValue<Value>`.
|
|
28
|
+
public fun borrow<Value: store>(self: &StorageValue<Value>): &Value {
|
|
29
|
+
assert!(self.contains(), EValueDoesNotExist);
|
|
30
|
+
&self.contents[0].value
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/// Gets the value of the StorageValue `self: &mut StorageValue<Value>`.
|
|
34
|
+
public fun borrow_mut<Value: store>(self: &mut StorageValue<Value>): &mut Value {
|
|
35
|
+
assert!(self.contains(), EValueDoesNotExist);
|
|
36
|
+
&mut self.contents[0].value
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/// Update the `value` of the `StorageValue`.
|
|
40
|
+
public macro fun mutate<$Value: store>($self: &mut StorageValue<$Value>, $f: |&mut $Value|) {
|
|
41
|
+
let self = $self;
|
|
42
|
+
$f(borrow_mut(self));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/// Return true if `self` contains_key an entry for `key`, false otherwise
|
|
46
|
+
public fun contains<V: store>(self: &StorageValue<V>): bool {
|
|
47
|
+
self.contents.length() == 1
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/// Remove the entry `key` |-> `value` from self. Aborts if `key` is not bound in `self`.
|
|
51
|
+
public fun take<V: store>(self: &mut StorageValue<V>): V {
|
|
52
|
+
assert!(self.contains(), EValueDoesNotExist);
|
|
53
|
+
let Entry { value } = self.contents.remove(0);
|
|
54
|
+
value
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/// Set the `value` of the `StorageValue`.
|
|
58
|
+
public fun put<V: store>(self: &mut StorageValue<V>, value: V) {
|
|
59
|
+
assert!(!self.contains(), EValueAlreadyExist);
|
|
60
|
+
self.contents.push_back(Entry { value });
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
// ======================================= Value: drop + copy + store =======================================
|
|
65
|
+
|
|
66
|
+
/// Set the `value` of the `StorageValue`.
|
|
67
|
+
public fun set<V: copy + drop + store>(self: &mut StorageValue<V>, value: V) {
|
|
68
|
+
if (self.contains()) {
|
|
69
|
+
*self.borrow_mut() = value;
|
|
70
|
+
} else {
|
|
71
|
+
self.contents.push_back(Entry { value });
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/// Get the `value` of the `StorageValue`.
|
|
76
|
+
public fun get<V: copy + drop + store>(self: &StorageValue<V>): V {
|
|
77
|
+
assert!(self.contains(), EValueDoesNotExist);
|
|
78
|
+
self.contents[0].value
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/// Safely try borrow a value bound to `key` in `self`.
|
|
82
|
+
/// Return Some(V) if the value exists, None otherwise.
|
|
83
|
+
/// Only works for a "copyable" value as references cannot be stored in `vector`.
|
|
84
|
+
public fun try_get<V: copy + drop + store>(self: &StorageValue<V>): Option<V> {
|
|
85
|
+
if (self.contains()) {
|
|
86
|
+
option::some(self.contents[0].value)
|
|
87
|
+
} else {
|
|
88
|
+
option::none()
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/// Remove the entry `key` |-> `value` from self. Aborts if `key` is not bound in `self`.
|
|
93
|
+
public fun remove<V: copy + drop + store>(self: &mut StorageValue<V>) {
|
|
94
|
+
if (self.contains()) {
|
|
95
|
+
self.contents.remove(0);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// ============================================================================================
|
|
100
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
module dubhe::dapps_system {
|
|
2
|
+
use std::ascii::String;
|
|
3
|
+
use std::ascii;
|
|
4
|
+
use std::type_name;
|
|
5
|
+
use sui::address;
|
|
6
|
+
use dubhe::dapp_metadata;
|
|
7
|
+
use sui::clock::Clock;
|
|
8
|
+
use dubhe::dapps_schema::Dapps;
|
|
9
|
+
|
|
10
|
+
public fun current_package_id<T>(): address {
|
|
11
|
+
let dapp_package_id_string = type_name::get<T>().get_address().into_bytes();
|
|
12
|
+
address::from_ascii_bytes(&dapp_package_id_string)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
public entry fun register<T>(
|
|
16
|
+
dapps: &mut Dapps,
|
|
17
|
+
name: String,
|
|
18
|
+
description: String,
|
|
19
|
+
clock: &Clock,
|
|
20
|
+
ctx: &mut TxContext
|
|
21
|
+
) {
|
|
22
|
+
let dapp_package_id = current_package_id<T>();
|
|
23
|
+
assert!(!dapps.borrow_metadata().contains_key(dapp_package_id), 0);
|
|
24
|
+
|
|
25
|
+
dapps.borrow_mut_metadata().set(
|
|
26
|
+
dapp_package_id,
|
|
27
|
+
dapp_metadata::new(
|
|
28
|
+
name,
|
|
29
|
+
description,
|
|
30
|
+
ascii::string(b""),
|
|
31
|
+
ascii::string(b""),
|
|
32
|
+
clock.timestamp_ms(),
|
|
33
|
+
vector[]
|
|
34
|
+
)
|
|
35
|
+
);
|
|
36
|
+
dapps.borrow_mut_admin().set(dapp_package_id, ctx.sender());
|
|
37
|
+
dapps.borrow_mut_version().set(dapp_package_id, 0);
|
|
38
|
+
dapps.borrow_mut_schemas().set(dapp_package_id, vector[]);
|
|
39
|
+
dapps.borrow_mut_safe_mode().set(dapp_package_id, false);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public entry fun set_metadata(
|
|
43
|
+
dapps: &mut Dapps,
|
|
44
|
+
package_id: address,
|
|
45
|
+
clock: &Clock,
|
|
46
|
+
name: String,
|
|
47
|
+
description: String,
|
|
48
|
+
icon_url: String,
|
|
49
|
+
website_url: String,
|
|
50
|
+
partners: vector<String>,
|
|
51
|
+
ctx: &mut TxContext
|
|
52
|
+
) {
|
|
53
|
+
assert!(dapps.borrow_admin().get(package_id) == ctx.sender(), 0);
|
|
54
|
+
let created_at = clock.timestamp_ms();
|
|
55
|
+
assert!(dapps.borrow_metadata().contains_key(package_id), 0);
|
|
56
|
+
dapps.borrow_mut_metadata().mutate!(package_id, |metadata| {
|
|
57
|
+
metadata.set(name, description, icon_url, website_url, created_at, partners);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
public entry fun add_schema<T>(dapps: &mut Dapps, package_id: address, ctx: &mut TxContext) {
|
|
62
|
+
assert!(dapps.borrow_admin().get(package_id) == ctx.sender(), 0);
|
|
63
|
+
let schema = type_name::get<T>().into_string();
|
|
64
|
+
assert!(!dapps.borrow_schemas().get(package_id).contains(&schema), 0);
|
|
65
|
+
dapps.borrow_mut_schemas().mutate!(package_id, |schemas| {
|
|
66
|
+
schemas.push_back(schema);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
public entry fun transfer_ownership(
|
|
71
|
+
dapps: &mut Dapps,
|
|
72
|
+
package_id: address,
|
|
73
|
+
new_admin: address,
|
|
74
|
+
ctx: &mut TxContext
|
|
75
|
+
) {
|
|
76
|
+
assert!(dapps.borrow_admin().get(package_id) == ctx.sender(), 0);
|
|
77
|
+
dapps.borrow_mut_admin().set(package_id, new_admin);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
public fun assert_admin<T: drop>(dapps: &Dapps, ctx: &TxContext) {
|
|
81
|
+
let package_id = current_package_id<T>();
|
|
82
|
+
assert!(dapps.borrow_admin().get(package_id) == ctx.sender(), 0);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
public fun assert_is_safe_mode<T: drop>(dapps: &Dapps) {
|
|
86
|
+
let package_id = current_package_id<T>();
|
|
87
|
+
assert!(!dapps.borrow_safe_mode().get(package_id), 0);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
module dubhe::world {
|
|
2
|
+
use std::ascii::{String};
|
|
3
|
+
use sui::bag::{Self, Bag};
|
|
4
|
+
|
|
5
|
+
public struct AdminCap has key, store {
|
|
6
|
+
id: UID,
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
public struct World has key, store {
|
|
10
|
+
id: UID,
|
|
11
|
+
/// Name of the world
|
|
12
|
+
name: String,
|
|
13
|
+
/// Description of the world
|
|
14
|
+
description: String,
|
|
15
|
+
/// Schemas of the world
|
|
16
|
+
schemas: Bag,
|
|
17
|
+
/// Schema names of the world
|
|
18
|
+
schema_names: vector<String>,
|
|
19
|
+
/// admin of the world
|
|
20
|
+
admin: ID,
|
|
21
|
+
/// version of the world
|
|
22
|
+
version: u64
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
public fun create(name: String, description: String, ctx: &mut TxContext): (World, AdminCap) {
|
|
26
|
+
let admin_cap = AdminCap {
|
|
27
|
+
id: object::new(ctx),
|
|
28
|
+
};
|
|
29
|
+
let world = World {
|
|
30
|
+
id: object::new(ctx),
|
|
31
|
+
name,
|
|
32
|
+
description,
|
|
33
|
+
schemas: bag::new(ctx),
|
|
34
|
+
schema_names: vector::empty(),
|
|
35
|
+
admin: object::id(&admin_cap),
|
|
36
|
+
version: 1,
|
|
37
|
+
};
|
|
38
|
+
(world, admin_cap)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public fun admin(world: &World): ID {
|
|
42
|
+
world.admin
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public fun version(world: &World): u64 {
|
|
46
|
+
world.version
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
public fun mut_version(world: &mut World, admin_cap: &AdminCap): &mut u64 {
|
|
50
|
+
assert!(world.admin() == object::id(admin_cap), 0);
|
|
51
|
+
&mut world.version
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
public fun info(world: &World): (String, String) {
|
|
55
|
+
(world.name, world.description)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
public fun schema_names(world: &World): vector<String> {
|
|
59
|
+
world.schema_names
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
public(package) fun mut_schema_names(world: &mut World): &mut vector<String> {
|
|
63
|
+
&mut world.schema_names
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
public(package) fun mut_uid(world: &mut World): &mut UID {
|
|
67
|
+
&mut world.id
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
public(package) fun uid(world: &World): &UID {
|
|
71
|
+
&world.id
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
public(package) fun schemas(world: &World): &Bag {
|
|
75
|
+
&world.schemas
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
public(package) fun mut_schemas(world: &mut World): &mut Bag {
|
|
79
|
+
&mut world.schemas
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#[test_only]
|
|
2
|
+
module dubhe::dapps_tests {
|
|
3
|
+
use std::debug;
|
|
4
|
+
use std::type_name;
|
|
5
|
+
use sui::address;
|
|
6
|
+
|
|
7
|
+
public struct USDT has drop {}
|
|
8
|
+
|
|
9
|
+
#[test]
|
|
10
|
+
public fun dapps_register() {
|
|
11
|
+
let name = type_name::get<USDT>().get_address().into_bytes();
|
|
12
|
+
let package_id = address::from_ascii_bytes(&name);
|
|
13
|
+
debug::print(&package_id);
|
|
14
|
+
debug::print(&type_name::get<USDT>().get_module());
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
#[test_only]
|
|
3
|
+
module dubhe_framework::dubhe_framework_tests {
|
|
4
|
+
// uncomment this line to import the module
|
|
5
|
+
// use dubhe_framework::dubhe_framework;
|
|
6
|
+
|
|
7
|
+
const ENotImplemented: u64 = 0;
|
|
8
|
+
|
|
9
|
+
#[test]
|
|
10
|
+
fun test_dubhe_framework() {
|
|
11
|
+
// pass
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
#[test, expected_failure(abort_code = ::dubhe_framework::dubhe_framework_tests::ENotImplemented)]
|
|
15
|
+
fun test_dubhe_framework_fail() {
|
|
16
|
+
abort ENotImplemented
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
*/
|