create-dubhe 0.0.4 → 0.0.5

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.
Files changed (157) hide show
  1. package/dist/index.mjs +44 -42
  2. package/package.json +1 -1
  3. package/template/101/rooch-template/.dockerignore +7 -0
  4. package/template/101/rooch-template/.eslintrc.json +3 -0
  5. package/template/101/rooch-template/.prettierrc +8 -0
  6. package/template/101/rooch-template/Dockerfile +52 -0
  7. package/template/101/rooch-template/LICENSE +674 -0
  8. package/template/101/rooch-template/README.md +14 -0
  9. package/template/101/rooch-template/contracts/counter/Move.toml +14 -0
  10. package/template/101/rooch-template/contracts/counter/sources/counter.move +48 -0
  11. package/template/101/rooch-template/dubhe.config.ts +14 -0
  12. package/template/101/rooch-template/jest.config.ts +17 -0
  13. package/template/101/rooch-template/next-env.d.ts +5 -0
  14. package/template/101/rooch-template/next-i18next.config.js +6 -0
  15. package/template/101/rooch-template/next.config.js +15 -0
  16. package/template/101/rooch-template/package.json +72 -0
  17. package/template/101/rooch-template/postcss.config.js +6 -0
  18. package/template/101/rooch-template/public/discord.svg +9 -0
  19. package/template/101/rooch-template/public/fail.svg +12 -0
  20. package/template/101/rooch-template/public/favicon.ico +0 -0
  21. package/template/101/rooch-template/public/locales/de/common.json +8 -0
  22. package/template/101/rooch-template/public/locales/de/footer.json +3 -0
  23. package/template/101/rooch-template/public/locales/de/second-page.json +5 -0
  24. package/template/101/rooch-template/public/locales/en/common.json +8 -0
  25. package/template/101/rooch-template/public/locales/en/footer.json +3 -0
  26. package/template/101/rooch-template/public/locales/en/second-page.json +5 -0
  27. package/template/101/rooch-template/public/locales/zn/common.json +8 -0
  28. package/template/101/rooch-template/public/locales/zn/footer.json +3 -0
  29. package/template/101/rooch-template/public/locales/zn/second-page.json +5 -0
  30. package/template/101/rooch-template/public/logo.svg +1 -0
  31. package/template/101/rooch-template/public/medium.svg +9 -0
  32. package/template/101/rooch-template/public/successful.svg +11 -0
  33. package/template/101/rooch-template/public/telegram.svg +9 -0
  34. package/template/101/rooch-template/public/twitter.svg +9 -0
  35. package/template/101/rooch-template/scripts/checkBalance.ts +37 -0
  36. package/template/101/rooch-template/scripts/generateAccount.ts +55 -0
  37. package/template/101/rooch-template/scripts/storeConfig.ts +52 -0
  38. package/template/101/rooch-template/scripts/waitNode.ts +9 -0
  39. package/template/101/rooch-template/src/chain/config.ts +5 -0
  40. package/template/101/rooch-template/src/css/font-awesome.css +2337 -0
  41. package/template/101/rooch-template/src/css/font-awesome.min.css +4 -0
  42. package/template/101/rooch-template/src/fonts/FontAwesome.otf +0 -0
  43. package/template/101/rooch-template/src/fonts/fontawesome-webfont.eot +0 -0
  44. package/template/101/rooch-template/src/fonts/fontawesome-webfont.svg +2671 -0
  45. package/template/101/rooch-template/src/fonts/fontawesome-webfont.ttf +0 -0
  46. package/template/101/rooch-template/src/fonts/fontawesome-webfont.woff +0 -0
  47. package/template/101/rooch-template/src/fonts/fontawesome-webfont.woff2 +0 -0
  48. package/template/101/rooch-template/src/jotai/index.tsx +12 -0
  49. package/template/101/rooch-template/src/pages/_app.tsx +9 -0
  50. package/template/101/rooch-template/src/pages/home/index.tsx +82 -0
  51. package/template/101/rooch-template/src/pages/index.tsx +14 -0
  52. package/template/101/rooch-template/tailwind.config.js +56 -0
  53. package/template/101/rooch-template/tsconfig.json +25 -0
  54. package/template/101/sui-template/contracts/counter/Move.toml +3 -3
  55. package/template/101/sui-template/contracts/counter/sources/codegen/schema_hub.move +60 -0
  56. package/template/101/sui-template/contracts/counter/sources/codegen/schemas/counter.move +17 -15
  57. package/template/101/sui-template/contracts/counter/sources/script/deploy_hook.move +37 -19
  58. package/template/101/sui-template/contracts/counter/sources/script/migrate.move +8 -0
  59. package/template/101/sui-template/localnet/dubhe-framework/Move.toml +6 -16
  60. package/template/{nextjs/sui-template/localnet/dubhe-framework/sources/schemas/dapps/dapps.move → 101/sui-template/localnet/dubhe-framework/sources/core/dapps/schema.move} +12 -2
  61. package/template/101/sui-template/localnet/dubhe-framework/sources/core/dapps/system.move +75 -0
  62. package/template/101/sui-template/localnet/dubhe-framework/sources/core/dapps/tests.move +52 -0
  63. package/template/101/sui-template/localnet/dubhe-framework/sources/core/root/schema.move +33 -0
  64. package/template/101/sui-template/localnet/dubhe-framework/sources/core/root/system.move +24 -0
  65. package/template/101/sui-template/localnet/dubhe-framework/sources/core/root/tests.move +39 -0
  66. package/template/101/sui-template/localnet/dubhe-framework/sources/frames/utils/type_info.move +29 -0
  67. package/template/101/sui-template/localnet/dubhe-framework/sources/storages/double_map.move +0 -3
  68. package/template/101/sui-template/localnet/dubhe-framework/sources/storages/map.move +0 -3
  69. package/template/101/sui-template/localnet/dubhe-framework/sources/storages/migrate.move +19 -0
  70. package/template/101/sui-template/localnet/dubhe-framework/sources/storages/value.move +0 -3
  71. package/template/101/sui-template/package.json +19 -27
  72. package/template/101/sui-template/scripts/deployment/testnet/deploy.ts +2 -2
  73. package/template/101/sui-template/src/chain/config.ts +3 -3
  74. package/template/cocos/sui-template/assets/lib/dubhe.js +21 -1
  75. package/template/cocos/sui-template/contracts/counter/Move.toml +1 -1
  76. package/template/cocos/sui-template/package.json +3 -3
  77. package/template/contract/sui-template/contracts/counter/Move.toml +13 -0
  78. package/template/contract/sui-template/contracts/counter/sources/codegen/dapp_key.move +16 -0
  79. package/template/contract/sui-template/contracts/counter/sources/codegen/schema_hub.move +60 -0
  80. package/template/contract/sui-template/contracts/counter/sources/codegen/schemas/counter.move +60 -0
  81. package/template/contract/sui-template/contracts/counter/sources/script/deploy_hook.move +85 -0
  82. package/template/contract/sui-template/contracts/counter/sources/script/migrate.move +8 -0
  83. package/template/contract/sui-template/dubhe.config.ts +14 -0
  84. package/template/contract/sui-template/localnet/dubhe-framework/Move.toml +29 -0
  85. package/template/{101/sui-template/localnet/dubhe-framework/sources/schemas/dapps/dapps.move → contract/sui-template/localnet/dubhe-framework/sources/core/dapps/schema.move} +12 -2
  86. package/template/contract/sui-template/localnet/dubhe-framework/sources/core/dapps/system.move +75 -0
  87. package/template/contract/sui-template/localnet/dubhe-framework/sources/core/dapps/tests.move +52 -0
  88. package/template/contract/sui-template/localnet/dubhe-framework/sources/core/root/schema.move +33 -0
  89. package/template/contract/sui-template/localnet/dubhe-framework/sources/core/root/system.move +24 -0
  90. package/template/contract/sui-template/localnet/dubhe-framework/sources/core/root/tests.move +39 -0
  91. package/template/contract/sui-template/localnet/dubhe-framework/sources/frames/utils/type_info.move +29 -0
  92. package/template/contract/sui-template/localnet/dubhe-framework/sources/storages/double_map.move +153 -0
  93. package/template/contract/sui-template/localnet/dubhe-framework/sources/storages/map.move +156 -0
  94. package/template/contract/sui-template/localnet/dubhe-framework/sources/storages/migrate.move +19 -0
  95. package/template/contract/sui-template/localnet/dubhe-framework/sources/storages/value.move +97 -0
  96. package/template/contract/sui-template/localnet/dubhe-framework/tests/init.move +6 -0
  97. package/template/contract/sui-template/localnet/dubhe-framework/tests/obelisk_framework_tests.move +19 -0
  98. package/template/contract/sui-template/package.json +28 -0
  99. package/template/contract/sui-template/scripts/checkBalance.ts +40 -0
  100. package/template/contract/sui-template/scripts/deployment/common.ts +45 -0
  101. package/template/contract/sui-template/scripts/deployment/localnet/deploy.ts +42 -0
  102. package/template/contract/sui-template/scripts/deployment/testnet/deploy.ts +48 -0
  103. package/template/contract/sui-template/scripts/deployment/types.ts +13 -0
  104. package/template/contract/sui-template/scripts/framework/common.ts +17 -0
  105. package/template/contract/sui-template/scripts/framework/deploy.ts +199 -0
  106. package/template/contract/sui-template/scripts/framework/parse-history.ts +76 -0
  107. package/template/contract/sui-template/scripts/framework/types.ts +8 -0
  108. package/template/contract/sui-template/scripts/generateAccount.ts +37 -0
  109. package/template/contract/sui-template/tsconfig.json +35 -0
  110. package/template/nextjs/sui-template/contracts/counter/Move.toml +3 -3
  111. package/template/nextjs/sui-template/contracts/counter/sources/codegen/schema_hub.move +60 -0
  112. package/template/nextjs/sui-template/contracts/counter/sources/codegen/schemas/counter.move +17 -15
  113. package/template/nextjs/sui-template/contracts/counter/sources/script/deploy_hook.move +37 -19
  114. package/template/nextjs/sui-template/contracts/counter/sources/script/migrate.move +8 -0
  115. package/template/nextjs/sui-template/contracts/counter/sources/systems/counter.move +11 -0
  116. package/template/nextjs/sui-template/dubhe.config.ts +2 -2
  117. package/template/nextjs/sui-template/localnet/dubhe-framework/Move.toml +6 -16
  118. package/template/nextjs/sui-template/localnet/dubhe-framework/sources/core/dapps/metadata.move +96 -0
  119. package/template/nextjs/sui-template/localnet/dubhe-framework/sources/core/dapps/schema.move +83 -0
  120. package/template/nextjs/sui-template/localnet/dubhe-framework/sources/core/dapps/system.move +75 -0
  121. package/template/nextjs/sui-template/localnet/dubhe-framework/sources/core/dapps/tests.move +52 -0
  122. package/template/nextjs/sui-template/localnet/dubhe-framework/sources/core/root/schema.move +33 -0
  123. package/template/nextjs/sui-template/localnet/dubhe-framework/sources/core/root/system.move +24 -0
  124. package/template/nextjs/sui-template/localnet/dubhe-framework/sources/core/root/tests.move +39 -0
  125. package/template/nextjs/sui-template/localnet/dubhe-framework/sources/frames/utils/type_info.move +29 -0
  126. package/template/nextjs/sui-template/localnet/dubhe-framework/sources/storages/double_map.move +0 -3
  127. package/template/nextjs/sui-template/localnet/dubhe-framework/sources/storages/map.move +0 -3
  128. package/template/nextjs/sui-template/localnet/dubhe-framework/sources/storages/migrate.move +19 -0
  129. package/template/nextjs/sui-template/localnet/dubhe-framework/sources/storages/tests.move +398 -0
  130. package/template/nextjs/sui-template/localnet/dubhe-framework/sources/storages/value.move +0 -3
  131. package/template/nextjs/sui-template/package.json +19 -27
  132. package/template/nextjs/sui-template/scripts/deployment/testnet/deploy.ts +2 -2
  133. package/template/nextjs/sui-template/src/chain/config.ts +2 -2
  134. package/template/101/sui-template/localnet/dubhe-framework/README.md +0 -18
  135. package/template/101/sui-template/localnet/dubhe-framework/sources/access_control.move +0 -35
  136. package/template/101/sui-template/localnet/dubhe-framework/sources/events.move +0 -23
  137. package/template/101/sui-template/localnet/dubhe-framework/sources/resource_id.move +0 -22
  138. package/template/101/sui-template/localnet/dubhe-framework/sources/resource_types.move +0 -18
  139. package/template/101/sui-template/localnet/dubhe-framework/sources/schema.move +0 -36
  140. package/template/101/sui-template/localnet/dubhe-framework/sources/systems/dapps.move +0 -90
  141. package/template/101/sui-template/localnet/dubhe-framework/sources/world.move +0 -81
  142. package/template/101/sui-template/localnet/dubhe-framework/tests/dapp.move +0 -16
  143. package/template/nextjs/sui-template/localnet/dubhe-framework/README.md +0 -18
  144. package/template/nextjs/sui-template/localnet/dubhe-framework/sources/access_control.move +0 -35
  145. package/template/nextjs/sui-template/localnet/dubhe-framework/sources/events.move +0 -23
  146. package/template/nextjs/sui-template/localnet/dubhe-framework/sources/resource_id.move +0 -22
  147. package/template/nextjs/sui-template/localnet/dubhe-framework/sources/resource_types.move +0 -18
  148. package/template/nextjs/sui-template/localnet/dubhe-framework/sources/schema.move +0 -36
  149. package/template/nextjs/sui-template/localnet/dubhe-framework/sources/systems/dapps.move +0 -90
  150. package/template/nextjs/sui-template/localnet/dubhe-framework/sources/world.move +0 -81
  151. package/template/nextjs/sui-template/localnet/dubhe-framework/tests/dapp.move +0 -16
  152. /package/template/101/sui-template/contracts/counter/sources/{system → systems}/counter.move +0 -0
  153. /package/template/101/sui-template/localnet/dubhe-framework/sources/{schemas → core}/dapps/metadata.move +0 -0
  154. /package/template/101/sui-template/localnet/dubhe-framework/{tests/storage.move → sources/storages/tests.move} +0 -0
  155. /package/template/{nextjs/sui-template/contracts/counter/sources/system → contract/sui-template/contracts/counter/sources/systems}/counter.move +0 -0
  156. /package/template/{nextjs/sui-template/localnet/dubhe-framework/sources/schemas → contract/sui-template/localnet/dubhe-framework/sources/core}/dapps/metadata.move +0 -0
  157. /package/template/{nextjs/sui-template/localnet/dubhe-framework/tests/storage.move → contract/sui-template/localnet/dubhe-framework/sources/storages/tests.move} +0 -0
@@ -0,0 +1,33 @@
1
+ module dubhe::root_schema {
2
+ use dubhe::storage_value;
3
+ use dubhe::storage_value::StorageValue;
4
+ use sui::transfer::public_share_object;
5
+
6
+ public struct Root has key, store {
7
+ id: UID,
8
+ key: StorageValue<address>,
9
+ }
10
+
11
+
12
+ public(package) fun borrow_mut_key(self: &mut Root): &mut StorageValue<address> {
13
+ &mut self.key
14
+ }
15
+
16
+ public fun borrow_key(self: &Root): &StorageValue<address> {
17
+ &self.key
18
+ }
19
+
20
+ fun init(ctx: &mut TxContext) {
21
+ let mut key = storage_value::new();
22
+ key.set(ctx.sender());
23
+ public_share_object(Root {
24
+ id: object::new(ctx),
25
+ key,
26
+ });
27
+ }
28
+
29
+ #[test_only]
30
+ public fun init_root_for_testing(ctx: &mut TxContext){
31
+ init(ctx)
32
+ }
33
+ }
@@ -0,0 +1,24 @@
1
+ module dubhe::root_system {
2
+ use dubhe::root_schema::Root;
3
+
4
+ public entry fun set_key(
5
+ root: &mut Root,
6
+ key: address,
7
+ ctx: &mut TxContext
8
+ ) {
9
+ ensure_root(root, ctx);
10
+ root.borrow_mut_key().set(key);
11
+ }
12
+
13
+ public entry fun remove_key(
14
+ root: &mut Root,
15
+ ctx: &mut TxContext
16
+ ) {
17
+ ensure_root(root, ctx);
18
+ root.borrow_mut_key().remove();
19
+ }
20
+
21
+ public fun ensure_root(root: &Root, ctx: &TxContext) {
22
+ assert!(root.borrow_key().get() == ctx.sender(), 0);
23
+ }
24
+ }
@@ -0,0 +1,39 @@
1
+ #[test_only]
2
+ module dubhe::root_tests {
3
+ use dubhe::root_schema::Root;
4
+ use dubhe::root_schema;
5
+ use dubhe::root_system;
6
+ use sui::test_scenario;
7
+
8
+ public struct USDT has drop {}
9
+
10
+ #[test]
11
+ public fun root_key() {
12
+ let mut scenario = test_scenario::begin(@0xA);
13
+ {
14
+ let ctx = test_scenario::ctx(&mut scenario);
15
+ root_schema::init_root_for_testing(ctx);
16
+ test_scenario::next_tx(&mut scenario,@0xA);
17
+ };
18
+
19
+ let mut root = test_scenario::take_shared<Root>(&scenario);
20
+ assert!(root.borrow_key().get() == @0xA, 0);
21
+
22
+ {
23
+ let ctx = test_scenario::ctx(&mut scenario);
24
+ root_system::set_key(&mut root, @0xB, ctx);
25
+ test_scenario::next_tx(&mut scenario,@0xB);
26
+ };
27
+ assert!(root.borrow_key().get() == @0xB, 0);
28
+
29
+ {
30
+ let ctx = test_scenario::ctx(&mut scenario);
31
+ root_system::remove_key(&mut root, ctx);
32
+ test_scenario::next_tx(&mut scenario,@0xC);
33
+ };
34
+ assert!(root.borrow_key().try_get() == option::none<address>(), 0);
35
+
36
+ test_scenario::return_shared<Root>(root);
37
+ scenario.end();
38
+ }
39
+ }
@@ -0,0 +1,29 @@
1
+ module dubhe::type_info {
2
+ use std::ascii::String;
3
+ use std::ascii::string;
4
+ use sui::address;
5
+ use std::type_name::TypeName;
6
+
7
+ public fun parse_type_name(type_name: TypeName): (address, String, String, String) {
8
+ let pending_parse_str = type_name.into_string();
9
+ let delimiter = string(b"::");
10
+
11
+ // TBD: this can probably be hard-coded as all hex addrs are 64 bytes
12
+ let package_delimiter_index = pending_parse_str.index_of(&delimiter);
13
+ let package_addr = pending_parse_str.substring(0, package_delimiter_index);
14
+ let package_id = address::from_ascii_bytes(package_addr.as_bytes());
15
+
16
+ let tail = pending_parse_str.substring(package_delimiter_index + 2, pending_parse_str.length());
17
+
18
+ let module_delimiter_index = tail.index_of(&delimiter);
19
+ let module_name = tail.substring(0, module_delimiter_index);
20
+
21
+ let struct_name_with_type = tail.substring(module_delimiter_index + 2, tail.length());
22
+
23
+ let delimiter = string(b"<");
24
+ let struct_name_delimiter_index = struct_name_with_type.index_of(&delimiter);
25
+ let struct_name = struct_name_with_type.substring(0, struct_name_delimiter_index);
26
+
27
+ (package_id, module_name, struct_name, struct_name_with_type)
28
+ }
29
+ }
@@ -1,6 +1,3 @@
1
- // Copyright (c) Mysten Labs, Inc.
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
1
  #[allow(unused_variable)]
5
2
  module dubhe::storage_double_map {
6
3
 
@@ -1,6 +1,3 @@
1
- // Copyright (c) Mysten Labs, Inc.
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
1
  #[allow(unused_variable)]
5
2
  module dubhe::storage_map {
6
3
 
@@ -0,0 +1,19 @@
1
+ module dubhe::storage_migrate {
2
+ use sui::dynamic_field as df;
3
+
4
+ public fun add_field<StorageType: store>(uid: &mut UID, field_name: vector<u8>, storagr_type: StorageType) {
5
+ df::add(uid, field_name, storagr_type);
6
+ }
7
+
8
+ public fun borrow_field<StorageType: store>(uid: &UID, field_name: vector<u8>): &StorageType {
9
+ df::borrow(uid, field_name)
10
+ }
11
+
12
+ public fun borrow_mut_field<StorageType: store>(uid: &mut UID, field_name: vector<u8>): &mut StorageType {
13
+ df::borrow_mut(uid, field_name)
14
+ }
15
+
16
+ public fun field_exists(uid: &UID, field_name: vector<u8>): bool {
17
+ df::exists_(uid, field_name)
18
+ }
19
+ }
@@ -1,6 +1,3 @@
1
- // Copyright (c) Mysten Labs, Inc.
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
1
  module dubhe::storage_value {
5
2
 
6
3
  /// This key does not exist in the map
@@ -5,39 +5,31 @@
5
5
  "author": "team@0xobelisk.com",
6
6
  "license": "MIT",
7
7
  "scripts": {
8
- "// Development Environment": "----------------",
9
- "dev": "pnpm dev:localnet",
10
- "dev:localnet": "pnpm localnet:setup && pnpm next",
11
- "dev:testnet": "pnpm testnet:setup && pnpm next",
12
- "// Production Environment": "----------------",
13
- "prod:localnet": "pnpm config:store localnet && pnpm next",
14
- "prod:testnet": "pnpm config:store testnet && pnpm next",
15
- "// Local Network": "----------------",
16
- "localnet:setup": "pnpm localnet:start && pnpm localnet:wait && pnpm localnet:account && pnpm localnet:faucet && pnpm localnet:deploy",
17
- "localnet:start": "pnpm dubhe localnode start -b",
18
- "localnet:restart": "pnpm dubhe localnode restart -b",
19
- "localnet:stop": "pnpm dubhe localnode stop",
20
- "localnet:status": "pnpm dubhe localnode status",
21
- "localnet:wait": "NODE_NO_WARNINGS=1 ts-node scripts/waitNode.ts",
22
- "localnet:account": "NODE_NO_WARNINGS=1 ts-node scripts/generateAccount.ts",
23
- "localnet:faucet": "pnpm dubhe faucet --network localnet",
24
- "localnet:deploy": "NODE_NO_WARNINGS=1 ts-node scripts/deployment/localnet/deploy.ts",
25
- "// Test Network": "----------------",
26
- "testnet:setup": "pnpm testnet:account && pnpm testnet:check-balance && pnpm testnet:deploy",
27
- "testnet:account": "NODE_NO_WARNINGS=1 ts-node scripts/generateAccount.ts",
28
- "testnet:check-balance": "NODE_NO_WARNINGS=1 ts-node scripts/checkBalance.ts testnet",
29
- "testnet:faucet": "pnpm dubhe faucet --network testnet",
30
- "testnet:deploy": "NODE_NO_WARNINGS=1 ts-node scripts/deployment/testnet/deploy.ts",
31
8
  "// Utility Commands": "----------------",
32
9
  "schema:gen": "pnpm dubhe schemagen --configPath ./dubhe.config.ts",
10
+ "account:gen": "NODE_NO_WARNINGS=1 ts-node scripts/generateAccount.ts",
33
11
  "config:store": "ts-node scripts/storeConfig.ts",
12
+ "start:localnet": "pnpm dubhe localnode start",
13
+ "faucet": "pnpm dubhe faucet --network",
14
+ "check-balance": "NODE_NO_WARNINGS=1 ts-node scripts/checkBalance.ts",
15
+ "deploy:localnet": "NODE_NO_WARNINGS=1 ts-node scripts/deployment/localnet/deploy.ts",
16
+ "deploy:testnet": "NODE_NO_WARNINGS=1 ts-node scripts/deployment/testnet/deploy.ts",
17
+ "// Development Environment": "----------------",
18
+ "dev": "pnpm dev:localnet",
19
+ "dev:localnet": "pnpm setup:localnet && pnpm next",
20
+ "dev:testnet": "pnpm setup:testnet && pnpm next",
21
+ "setup:localnet": "pnpm account:gen && pnpm faucet localnet && pnpm deploy:localnet",
22
+ "setup:testnet": "pnpm account:gen && pnpm check-balance testnet && pnpm deploy:testnet",
34
23
  "build": "next build",
35
- "start": "next start"
24
+ "start": "next start",
25
+ "// Production Environment": "----------------",
26
+ "prod:localnet": "pnpm config:store localnet && pnpm next",
27
+ "prod:testnet": "pnpm config:store testnet && pnpm next"
36
28
  },
37
29
  "dependencies": {
38
- "@0xobelisk/sui-cli": "^0.5.23",
39
- "@0xobelisk/sui-client": "^0.5.27",
40
- "@0xobelisk/sui-common": "^0.5.19",
30
+ "@0xobelisk/sui-cli": "^0.5.25",
31
+ "@0xobelisk/sui-client": "v0.5.28",
32
+ "@0xobelisk/sui-common": "^0.5.21",
41
33
  "@mysten/sui": "1.7.0",
42
34
  "clsx": "^1.2.1",
43
35
  "dotenv": "^16.4.5",
@@ -4,7 +4,7 @@ import { dubheConfig } from '../../../dubhe.config';
4
4
  import fs from 'fs/promises';
5
5
  import path from 'path';
6
6
 
7
- const TESTNET_FRAMEWORK_ID = '0x1736475f476c5dec96f33c03c778843f572239d3a887d795eef66d2836484c28';
7
+ const TESTNET_FRAMEWORK_ID = '0x417ad1864a56a29ad0b5aaddd2e11bac1eeab6a68883ef53184a4cc5c293fec6';
8
8
 
9
9
  async function updateDubheMoveToml(projectName: string) {
10
10
  try {
@@ -14,7 +14,7 @@ async function updateDubheMoveToml(projectName: string) {
14
14
 
15
15
  content = content.replace(
16
16
  /Dubhe = \{[^}]+\}/,
17
- `Dubhe = { git = "https://github.com/0xobelisk/dubhe.git", subdir = "packages/dubhe-framework", rev = "main" }`,
17
+ `Dubhe = { git = "https://github.com/0xobelisk/dubhe.git", rev = "release-dubhe-v1.0.0-rc1" }`,
18
18
  );
19
19
 
20
20
  content = content.replace(/^dubhe\s+=\s+"0x[0-9a-fA-F]+"/m, `dubhe = "${TESTNET_FRAMEWORK_ID}"`);
@@ -1,7 +1,7 @@
1
1
  type NetworkType = 'testnet' | 'mainnet' | 'devnet' | 'localnet';
2
2
 
3
- export const NETWORK: NetworkType = 'testnet';
3
+ export const NETWORK: NetworkType = 'localnet';
4
4
 
5
- export const PACKAGE_ID = '0xc58411ca78d829dbc3bb104ee7e63b8c95c0b0fb110cc98332023a88c18837a6'
5
+ export const PACKAGE_ID = '0x578a4e578b31cc9a0e749e35a94e85adb2adf9f16794d5636b9f23b2ef02cf16'
6
6
 
7
- export const Counter_Object_Id = '0x35a38188257ee072283672fb112488737dda1a081f30f691063fd7dcd370a421'
7
+ export const Counter_Object_Id = '0x31bee9e1c6973d825480a645ce018e927a448b62f958e4aadd9e7c63b66233ee'
@@ -4562,6 +4562,26 @@ function numberToAddressHex(num) {
4562
4562
 
4563
4563
  // src/dubhe.ts
4564
4564
 
4565
+ // src/errors/index.ts
4566
+ var ContractDataParsingError = class extends Error {
4567
+ constructor(dryResult) {
4568
+ const error = dryResult?.effects?.status?.error || "";
4569
+ const functionMatch = error ? error.match(/function_name: Some\("([^"]+)"\)/) : null;
4570
+ const moduleMatch = error ? error.match(/address: ([a-fA-F0-9]+)/) : null;
4571
+ const functionName = functionMatch ? functionMatch[1] : "unknown";
4572
+ const moduleAddress = moduleMatch ? "0x" + moduleMatch[1] : "unknown";
4573
+ const errorMessage = dryResult.error ? dryResult.error : "UNKNOWN_ERROR";
4574
+ const message = [`
4575
+ - Function: ${functionName}`, `- Module Address: ${moduleAddress}`, `- Error Message: ${errorMessage}`].join("\n");
4576
+ super(message);
4577
+ this.errorType = "ContractDataParsingError";
4578
+ this.functionName = functionName;
4579
+ this.moduleAddress = moduleAddress;
4580
+ this.errorMessage = errorMessage;
4581
+ }
4582
+ };
4583
+
4584
+ // src/dubhe.ts
4565
4585
  function isUndefined(value) {
4566
4586
  return value === void 0;
4567
4587
  }
@@ -4953,7 +4973,7 @@ var Dubhe = class {
4953
4973
  }
4954
4974
  return returnValues;
4955
4975
  } else {
4956
- return void 0;
4976
+ throw new ContractDataParsingError(dryResult);
4957
4977
  }
4958
4978
  }
4959
4979
  /**
@@ -9,5 +9,5 @@ Dubhe = { git = "https://github.com/0xobelisk/dubhe.git", subdir = "packages/dub
9
9
 
10
10
  [addresses]
11
11
  sui = "0x2"
12
- dubhe = "0x1736475f476c5dec96f33c03c778843f572239d3a887d795eef66d2836484c28"
12
+ dubhe = "0x417ad1864a56a29ad0b5aaddd2e11bac1eeab6a68883ef53184a4cc5c293fec6"
13
13
  counter = "0x0"
@@ -15,9 +15,9 @@
15
15
  "generateAccount": "ts-node scripts/generateAccount.ts"
16
16
  },
17
17
  "dependencies": {
18
- "@0xobelisk/sui-cli": "^0.5.23",
19
- "@0xobelisk/sui-client": "^0.5.27",
20
- "@0xobelisk/sui-common": "^0.5.19"
18
+ "@0xobelisk/sui-cli": "^0.5.25",
19
+ "@0xobelisk/sui-client": "v0.5.28",
20
+ "@0xobelisk/sui-common": "^0.5.21"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@types/node": "18.16.16",
@@ -0,0 +1,13 @@
1
+ [package]
2
+ name = "counter"
3
+ version = "0.0.1"
4
+ edition = "2024.beta"
5
+
6
+ [dependencies]
7
+ Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "mainnet-v1.36.2" }
8
+ Dubhe = { git = "https://github.com/0xobelisk/dubhe-framework.git", rev = "release-dubhe-v1.0.0-rc1" }
9
+
10
+ [addresses]
11
+ sui = "0x2"
12
+ dubhe = "0x417ad1864a56a29ad0b5aaddd2e11bac1eeab6a68883ef53184a4cc5c293fec6"
13
+ counter = "0x0"
@@ -0,0 +1,16 @@
1
+ // Copyright (c) Obelisk Labs, Inc.
2
+ // SPDX-License-Identifier: MIT
3
+ #[allow(unused_use)]
4
+
5
+ /* Autogenerated file. Do not edit manually. */
6
+
7
+ module counter::dapp_key {
8
+
9
+ /// Authorization token for the app.
10
+
11
+ public struct DappKey has drop {}
12
+
13
+ public(package) fun new(): DappKey {
14
+ DappKey { }
15
+ }
16
+ }
@@ -0,0 +1,60 @@
1
+ // Copyright (c) Obelisk Labs, Inc.
2
+ // SPDX-License-Identifier: MIT
3
+ #[allow(unused_use)]
4
+
5
+ /* Autogenerated file. Do not edit manually. */
6
+
7
+ module counter::schema_hub {
8
+
9
+ use sui::transfer::public_share_object;
10
+
11
+ use sui::dynamic_field as df;
12
+
13
+ public struct SchemaHub has key, store {
14
+ id: UID,
15
+ admin: address,
16
+ }
17
+
18
+ public struct SchemaTypeWapper<phantom Schema: key + store> has copy, store, drop {}
19
+
20
+ /// Authorize an schema to access protected features of the SchemaHub.
21
+
22
+ public(package) fun authorize_schema<Schema: key + store>(self: &mut SchemaHub) {
23
+ df::add(&mut self.id, SchemaTypeWapper<Schema> {}, true);
24
+ }
25
+
26
+ /// Deauthorize an schema by removing its authorization key.
27
+
28
+ public(package) fun deauthorize_schema<Schema: key + store>(self: &mut SchemaHub) {
29
+ df::remove<SchemaTypeWapper<Schema>, bool>(&mut self.id, SchemaTypeWapper<Schema> {});
30
+ }
31
+
32
+ /// Check if an schema is authorized to access protected features of
33
+
34
+ /// the SchemaHub.
35
+
36
+ public fun is_schema_authorized<Schema: key + store>(self: &SchemaHub): bool {
37
+ df::exists_(&self.id, SchemaTypeWapper<Schema> {})
38
+ }
39
+
40
+ /// Assert that an schema is authorized to access protected features of
41
+
42
+ /// the SchemaHub. Aborts with `EAppNotAuthorized` if not.
43
+
44
+ public fun ensure_schema_authorized<Schema: key + store>(self: &SchemaHub) {
45
+ assert!(self.is_schema_authorized<Schema>(), 0);
46
+ }
47
+
48
+ fun init(ctx: &mut TxContext) {
49
+ public_share_object(SchemaHub {
50
+ id: object::new(ctx),
51
+ admin: ctx.sender(),
52
+ });
53
+ }
54
+
55
+ #[test_only]
56
+
57
+ public fun init_schema_hub_for_testing(ctx: &mut TxContext) {
58
+ init(ctx);
59
+ }
60
+ }
@@ -0,0 +1,60 @@
1
+ // Copyright (c) Obelisk Labs, Inc.
2
+ // SPDX-License-Identifier: MIT
3
+ #[allow(unused_use)]
4
+
5
+ /* Autogenerated file. Do not edit manually. */
6
+
7
+ module counter::counter_schema {
8
+
9
+ use std::ascii::String;
10
+
11
+ use std::ascii::string;
12
+
13
+ use sui::package::UpgradeCap;
14
+
15
+ use std::type_name;
16
+
17
+ use dubhe::dapps_system;
18
+
19
+ use dubhe::storage_migrate;
20
+
21
+ use dubhe::dapps_schema::Dapps;
22
+
23
+ use dubhe::storage_value::{Self, StorageValue};
24
+
25
+ use dubhe::storage_map::{Self, StorageMap};
26
+
27
+ use dubhe::storage_double_map::{Self, StorageDoubleMap};
28
+
29
+ use counter::dapp_key::DappKey;
30
+
31
+ use sui::dynamic_field as df;
32
+
33
+ public struct Counter has key, store {
34
+ id: UID,
35
+ }
36
+
37
+ public fun borrow_value(self: &Counter): &StorageValue<u32> {
38
+ storage_migrate::borrow_field(&self.id, b"value")
39
+ }
40
+
41
+ public(package) fun borrow_mut_value(self: &mut Counter): &mut StorageValue<u32> {
42
+ storage_migrate::borrow_mut_field(&mut self.id, b"value")
43
+ }
44
+
45
+ public(package) fun create(ctx: &mut TxContext): Counter {
46
+ let mut id = object::new(ctx);
47
+ storage_migrate::add_field<StorageValue<u32>>(&mut id, b"value", storage_value::new());
48
+ Counter { id }
49
+ }
50
+
51
+ public fun migrate(_counter: &mut Counter, _cap: &UpgradeCap) {}
52
+
53
+ // ======================================== View Functions ========================================
54
+
55
+ public fun get_value(self: &Counter): Option<u32> {
56
+ self.borrow_value().try_get()
57
+ }
58
+
59
+ // =========================================================================================================
60
+ }
@@ -0,0 +1,85 @@
1
+ #[allow(lint(share_owned))]
2
+
3
+ module counter::deploy_hook {
4
+
5
+ use dubhe::dapps_schema::Dapps;
6
+
7
+ use dubhe::dapps_system;
8
+
9
+ use counter::schema_hub::SchemaHub;
10
+
11
+ use std::ascii::string;
12
+
13
+ use sui::clock::Clock;
14
+
15
+ use sui::package::UpgradeCap;
16
+
17
+ use sui::transfer::public_share_object;
18
+
19
+ use counter::counter_schema::Counter;
20
+
21
+ #[test_only]
22
+
23
+ use sui::clock;
24
+
25
+ #[test_only]
26
+
27
+ use sui::test_scenario;
28
+
29
+ #[test_only]
30
+
31
+ use sui::package;
32
+
33
+ #[test_only]
34
+
35
+ use counter::schema_hub;
36
+
37
+ #[test_only]
38
+
39
+ use dubhe::dapps_schema;
40
+
41
+ #[test_only]
42
+
43
+ use sui::test_scenario::Scenario;
44
+
45
+ public entry fun run(
46
+ schema_hub: &mut SchemaHub,
47
+ dapps: &mut Dapps,
48
+ cap: &UpgradeCap,
49
+ clock: &Clock,
50
+ ctx: &mut TxContext,
51
+ ) {
52
+ // Register the dapp to dubhe.
53
+ dapps_system::register(dapps,cap,string(b"counter"),string(b"counter contract"),clock,ctx);
54
+ // Create schemas
55
+ let mut counter = counter::counter_schema::create(ctx);
56
+ // Logic that needs to be automated once the contract is deployed
57
+
58
+ counter.borrow_mut_value().set(0);
59
+ // Authorize schemas and public share objects
60
+ schema_hub.authorize_schema<Counter>();
61
+ public_share_object(counter);
62
+ }
63
+
64
+ #[test_only]
65
+
66
+ public fun deploy_hook_for_testing(): (Scenario, SchemaHub, Dapps) {
67
+ let mut scenario = test_scenario::begin(@0xA);
68
+ {
69
+ let ctx = test_scenario::ctx(&mut scenario);
70
+ dapps_schema::init_dapps_for_testing(ctx);
71
+ schema_hub::init_schema_hub_for_testing(ctx);
72
+ test_scenario::next_tx(&mut scenario,@0xA);
73
+ };
74
+ let mut dapps = test_scenario::take_shared<Dapps>(&scenario);
75
+ let mut schema_hub = test_scenario::take_shared<SchemaHub>(&scenario);
76
+ let ctx = test_scenario::ctx(&mut scenario);
77
+ let clock = clock::create_for_testing(ctx);
78
+ let upgrade_cap = package::test_publish(@0x42.to_id(), ctx);
79
+ run(&mut schema_hub, &mut dapps, &upgrade_cap, &clock, ctx);
80
+ clock::destroy_for_testing(clock);
81
+ upgrade_cap.make_immutable();
82
+ test_scenario::next_tx(&mut scenario,@0xA);
83
+ (scenario, schema_hub, dapps)
84
+ }
85
+ }
@@ -0,0 +1,8 @@
1
+ module counter::migrate {
2
+
3
+ const ON_CHAIN_VERSION: u32 = 0;
4
+
5
+ public fun on_chain_version(): u32 {
6
+ ON_CHAIN_VERSION
7
+ }
8
+ }
@@ -0,0 +1,14 @@
1
+ import { DubheConfig } from '@0xobelisk/sui-common';
2
+
3
+ export const dubheConfig = {
4
+ name: 'counter',
5
+ description: 'counter contract',
6
+ systems: ['counter'],
7
+ schemas: {
8
+ counter: {
9
+ structure: {
10
+ value: 'StorageValue<u32>',
11
+ },
12
+ },
13
+ },
14
+ } as DubheConfig;
@@ -0,0 +1,29 @@
1
+ [package]
2
+ name = "Dubhe"
3
+ edition = "2024.alpha"
4
+ version = "1.0.0"
5
+ published-at = "0x6e792e0532d681cf7c5cb461ca9ee27295e64eabdf9b534df276acb34111b3f5"
6
+ license = "MIT"
7
+ authors = ["Obelisk Labs"]
8
+
9
+ [dependencies]
10
+ Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "mainnet-v1.36.2" }
11
+
12
+ [addresses]
13
+ dubhe = "0x6e792e0532d681cf7c5cb461ca9ee27295e64eabdf9b534df276acb34111b3f5"
14
+ #dubhe = "0x0"
15
+
16
+ # Named addresses will be accessible in Move as `@name`. They're also exported:
17
+ # for example, `std = "0x1"` is exported by the Standard Library.
18
+ # alice = "0xA11CE"
19
+
20
+ [dev-dependencies]
21
+ # The dev-dependencies section allows overriding dependencies for `--test` and
22
+ # `--dev` modes. You can introduce test-only dependencies here.
23
+ # Local = { local = "../path/to/dev-build" }
24
+
25
+ [dev-addresses]
26
+ # The dev-addresses section allows overwriting named addresses for the `--test`
27
+ # and `--dev` modes.
28
+ # alice = "0xB0B"
29
+
@@ -11,7 +11,8 @@ module dubhe::dapps_schema {
11
11
  version: StorageMap<address, u32>,
12
12
  metadata: StorageMap<address, DappMetadata>,
13
13
  schemas: StorageMap<address, vector<String>>,
14
- safe_mode: StorageMap<address, bool>
14
+ safe_mode: StorageMap<address, bool>,
15
+ verified: StorageMap<address, bool>
15
16
  }
16
17
 
17
18
 
@@ -35,6 +36,10 @@ module dubhe::dapps_schema {
35
36
  &mut self.safe_mode
36
37
  }
37
38
 
39
+ public(package) fun borrow_mut_verified(self: &mut Dapps): &mut StorageMap<address, bool> {
40
+ &mut self.verified
41
+ }
42
+
38
43
  public fun borrow_admin(self: &Dapps): &StorageMap<address, address> {
39
44
  &self.admin
40
45
  }
@@ -55,6 +60,10 @@ module dubhe::dapps_schema {
55
60
  &self.safe_mode
56
61
  }
57
62
 
63
+ public fun borrow_verified(self: &mut Dapps): &StorageMap<address, bool> {
64
+ &self.verified
65
+ }
66
+
58
67
  fun init(ctx: &mut TxContext) {
59
68
  public_share_object(Dapps {
60
69
  id: object::new(ctx),
@@ -62,7 +71,8 @@ module dubhe::dapps_schema {
62
71
  version: storage_map::new(),
63
72
  metadata: storage_map::new(),
64
73
  schemas: storage_map::new(),
65
- safe_mode: storage_map::new()
74
+ safe_mode: storage_map::new(),
75
+ verified: storage_map::new(),
66
76
  });
67
77
  }
68
78