create-dubhe 0.0.18 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/package.json +1 -1
  2. package/template/{nextjs/sui-template/contracts/counter/sources/codegen/schemas/default → 101/sui-template/contracts/counter/sources/codegen}/dapp/metadata.move +6 -6
  3. package/template/101/sui-template/contracts/counter/sources/codegen/dapp/schema.move +112 -0
  4. package/template/{nextjs/sui-template/contracts/counter/sources/codegen/schemas/default → 101/sui-template/contracts/counter/sources/codegen}/dapp/system.move +17 -17
  5. package/template/101/sui-template/contracts/counter/sources/codegen/{events → data}/increment_event.move +0 -6
  6. package/template/101/sui-template/contracts/counter/sources/codegen/errors.move +16 -0
  7. package/template/101/sui-template/contracts/counter/sources/codegen/events.move +23 -0
  8. package/template/101/sui-template/contracts/counter/sources/codegen/genesis.move +20 -0
  9. package/template/101/sui-template/contracts/counter/sources/codegen/schema.move +54 -0
  10. package/template/101/sui-template/contracts/counter/sources/scripts/deploy_hook.move +12 -22
  11. package/template/101/sui-template/contracts/counter/sources/systems/counter.move +10 -13
  12. package/template/101/sui-template/contracts/counter/sources/tests/counter.move +8 -8
  13. package/template/101/sui-template/contracts/counter/sources/tests/init.move +1 -1
  14. package/template/101/sui-template/contracts/dubhe-framework/sources/events.move +33 -0
  15. package/template/101/sui-template/contracts/dubhe-framework/sources/storages/double_map.move +111 -153
  16. package/template/101/sui-template/contracts/dubhe-framework/sources/storages/map.move +87 -141
  17. package/template/{nextjs/sui-template/contracts/dubhe-framework/sources/storages/migration.move → 101/sui-template/contracts/dubhe-framework/sources/storages/storage.move} +3 -3
  18. package/template/101/sui-template/contracts/dubhe-framework/sources/storages/tests.move +82 -334
  19. package/template/101/sui-template/contracts/dubhe-framework/sources/storages/value.move +77 -83
  20. package/template/101/sui-template/dubhe.config.ts +1 -3
  21. package/template/101/sui-template/package.json +6 -4
  22. package/template/101/sui-template/src/chain/config.ts +2 -4
  23. package/template/101/sui-template/src/pages/home/index.tsx +4 -4
  24. package/template/contract/sui-template/contracts/dubhe-framework/sources/events.move +33 -0
  25. package/template/contract/sui-template/contracts/dubhe-framework/sources/storages/double_map.move +111 -153
  26. package/template/contract/sui-template/contracts/dubhe-framework/sources/storages/map.move +87 -141
  27. package/template/{101/sui-template/contracts/dubhe-framework/sources/storages/migration.move → contract/sui-template/contracts/dubhe-framework/sources/storages/storage.move} +3 -3
  28. package/template/contract/sui-template/contracts/dubhe-framework/sources/storages/tests.move +82 -334
  29. package/template/contract/sui-template/contracts/dubhe-framework/sources/storages/value.move +77 -83
  30. package/template/contract/sui-template/package.json +6 -4
  31. package/template/nextjs/sui-template/contracts/counter/Move.toml +1 -1
  32. package/template/{101/sui-template/contracts/counter/sources/codegen/schemas/default → nextjs/sui-template/contracts/counter/sources/codegen}/dapp/metadata.move +6 -6
  33. package/template/nextjs/sui-template/contracts/counter/sources/codegen/dapp/schema.move +112 -0
  34. package/template/{101/sui-template/contracts/counter/sources/codegen/schemas/default → nextjs/sui-template/contracts/counter/sources/codegen}/dapp/system.move +17 -17
  35. package/template/nextjs/sui-template/contracts/counter/sources/codegen/{events → data}/increment_event.move +0 -6
  36. package/template/nextjs/sui-template/contracts/counter/sources/codegen/errors.move +16 -0
  37. package/template/nextjs/sui-template/contracts/counter/sources/codegen/events.move +23 -0
  38. package/template/nextjs/sui-template/contracts/counter/sources/codegen/genesis.move +20 -0
  39. package/template/nextjs/sui-template/contracts/counter/sources/codegen/schema.move +54 -0
  40. package/template/nextjs/sui-template/contracts/counter/sources/scripts/deploy_hook.move +12 -22
  41. package/template/nextjs/sui-template/contracts/counter/sources/systems/counter.move +10 -13
  42. package/template/nextjs/sui-template/contracts/counter/sources/tests/counter.move +8 -8
  43. package/template/nextjs/sui-template/contracts/counter/sources/tests/init.move +1 -1
  44. package/template/nextjs/sui-template/contracts/dubhe-framework/sources/events.move +33 -0
  45. package/template/nextjs/sui-template/contracts/dubhe-framework/sources/storages/double_map.move +111 -153
  46. package/template/nextjs/sui-template/contracts/dubhe-framework/sources/storages/map.move +87 -141
  47. package/template/{contract/sui-template/contracts/dubhe-framework/sources/storages/migration.move → nextjs/sui-template/contracts/dubhe-framework/sources/storages/storage.move} +3 -3
  48. package/template/nextjs/sui-template/contracts/dubhe-framework/sources/storages/tests.move +82 -334
  49. package/template/nextjs/sui-template/contracts/dubhe-framework/sources/storages/value.move +77 -83
  50. package/template/nextjs/sui-template/dubhe.config.ts +1 -3
  51. package/template/nextjs/sui-template/package.json +7 -5
  52. package/template/nextjs/sui-template/src/chain/config.ts +3 -5
  53. package/template/nextjs/sui-template/src/pages/home/index.tsx +4 -4
  54. package/template/101/sui-template/contracts/counter/sources/codegen/errors/invalid_increment_error.move +0 -30
  55. package/template/101/sui-template/contracts/counter/sources/codegen/schemas/counter.move +0 -60
  56. package/template/101/sui-template/contracts/counter/sources/codegen/schemas/default/dapp/schema.move +0 -114
  57. package/template/nextjs/sui-template/contracts/counter/sources/codegen/errors/invalid_increment_error.move +0 -30
  58. package/template/nextjs/sui-template/contracts/counter/sources/codegen/schemas/counter.move +0 -60
  59. package/template/nextjs/sui-template/contracts/counter/sources/codegen/schemas/default/dapp/schema.move +0 -114
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-dubhe",
3
- "version": "0.0.18",
3
+ "version": "0.1.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "team@obelisk.build",
@@ -76,27 +76,27 @@
76
76
  self.partners = partners;
77
77
  }
78
78
 
79
- public fun get_name(self: DappMetadata): String {
79
+ public fun get_name(self: &DappMetadata): String {
80
80
  self.name
81
81
  }
82
82
 
83
- public fun get_description(self: DappMetadata): String {
83
+ public fun get_description(self: &DappMetadata): String {
84
84
  self.description
85
85
  }
86
86
 
87
- public fun get_icon_url(self: DappMetadata): String {
87
+ public fun get_icon_url(self: &DappMetadata): String {
88
88
  self.icon_url
89
89
  }
90
90
 
91
- public fun get_website_url(self: DappMetadata): String {
91
+ public fun get_website_url(self: &DappMetadata): String {
92
92
  self.website_url
93
93
  }
94
94
 
95
- public fun get_created_at(self: DappMetadata): u64 {
95
+ public fun get_created_at(self: &DappMetadata): u64 {
96
96
  self.created_at
97
97
  }
98
98
 
99
- public fun get_partners(self: DappMetadata): vector<String> {
99
+ public fun get_partners(self: &DappMetadata): vector<String> {
100
100
  self.partners
101
101
  }
102
102
  }
@@ -0,0 +1,112 @@
1
+ // Copyright (c) Obelisk Labs, Inc.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ #[allow(unused_use)]
4
+
5
+ /* Autogenerated file. Do not edit manually. */
6
+
7
+ module counter::dapp_schema {
8
+
9
+ use counter::dapp_metadata::DappMetadata;
10
+
11
+ use dubhe::storage_value;
12
+
13
+ use dubhe::storage_value::StorageValue;
14
+
15
+ use dubhe::storage;
16
+
17
+ use sui::transfer::public_share_object;
18
+
19
+ use dubhe::type_info;
20
+
21
+ public struct Dapp has key, store {
22
+ id: UID,
23
+ }
24
+
25
+ public fun borrow_admin(self: &Dapp): &StorageValue<address> {
26
+ storage::borrow_field(&self.id, b"admin")
27
+ }
28
+
29
+ public(package) fun admin(self: &mut Dapp): &mut StorageValue<address> {
30
+ storage::borrow_mut_field(&mut self.id, b"admin")
31
+ }
32
+
33
+ public fun borrow_package_id(self: &Dapp): &StorageValue<address> {
34
+ storage::borrow_field(&self.id, b"package_id")
35
+ }
36
+
37
+ public(package) fun package_id(self: &mut Dapp): &mut StorageValue<address> {
38
+ storage::borrow_mut_field(&mut self.id, b"package_id")
39
+ }
40
+
41
+ public fun borrow_version(self: &Dapp): &StorageValue<u32> {
42
+ storage::borrow_field(&self.id, b"version")
43
+ }
44
+
45
+ public(package) fun version(self: &mut Dapp): &mut StorageValue<u32> {
46
+ storage::borrow_mut_field(&mut self.id, b"version")
47
+ }
48
+
49
+ public fun borrow_metadata(self: &Dapp): &StorageValue<DappMetadata> {
50
+ storage::borrow_field(&self.id, b"metadata")
51
+ }
52
+
53
+ public(package) fun metadata(self: &mut Dapp): &mut StorageValue<DappMetadata> {
54
+ storage::borrow_mut_field(&mut self.id, b"metadata")
55
+ }
56
+
57
+ public fun borrow_safe_mode(self: &Dapp): &StorageValue<bool> {
58
+ storage::borrow_field(&self.id, b"safe_mode")
59
+ }
60
+
61
+ public(package) fun safe_mode(self: &mut Dapp): &mut StorageValue<bool> {
62
+ storage::borrow_mut_field(&mut self.id, b"safe_mode")
63
+ }
64
+
65
+ public(package) fun borrow_schemas(self: &Dapp): &StorageValue<vector<address>> {
66
+ storage::borrow_field(&self.id, b"schemas")
67
+ }
68
+
69
+ public(package) fun schemas(self: &mut Dapp): &mut StorageValue<vector<address>> {
70
+ storage::borrow_mut_field(&mut self.id, b"schemas")
71
+ }
72
+
73
+ public(package) fun create(ctx: &mut TxContext): Dapp {
74
+ let mut id = object::new(ctx);
75
+ storage::add_field<StorageValue<address>>(&mut id, b"admin", storage_value::new(b"admin", ctx));
76
+ storage::add_field<StorageValue<address>>(&mut id, b"package_id", storage_value::new(b"package_id", ctx));
77
+ storage::add_field<StorageValue<u32>>(&mut id, b"version", storage_value::new(b"version", ctx));
78
+ storage::add_field<StorageValue<DappMetadata>>(&mut id, b"metadata", storage_value::new(b"metadata", ctx));
79
+ storage::add_field<StorageValue<bool>>(&mut id, b"safe_mode", storage_value::new(b"safe_mode", ctx));
80
+ storage::add_field<StorageValue<vector<address>>>(&mut id, b"schemas", storage_value::new(b"schemas", ctx));
81
+ Dapp { id }
82
+ }
83
+
84
+ public(package) fun upgrade<DappKey: drop>(dapp: &mut Dapp, ctx: &TxContext) {
85
+ assert!(dapp.borrow_metadata().contains(), 0);
86
+ assert!(dapp.borrow_admin().get() == ctx.sender(), 0);
87
+ let new_package_id = type_info::current_package_id<DappKey>();
88
+ dapp.package_id().set(new_package_id);
89
+ let current_version = dapp.version()[];
90
+ dapp.version().set(current_version + 1);
91
+ }
92
+
93
+ public(package) fun add_schema<Schema: key + store>(dapp: &mut Dapp, schema: Schema) {
94
+ let mut schemas = dapp.schemas()[];
95
+ schemas.push_back(object::id_address<Schema>(&schema));
96
+ dapp.schemas().set(schemas);
97
+ public_share_object(schema);
98
+ }
99
+
100
+ #[test_only]
101
+
102
+ public fun create_dapp_for_testing(ctx: &mut TxContext): Dapp {
103
+ create(ctx)
104
+ }
105
+
106
+ #[test_only]
107
+
108
+ public fun distroy_dapp_for_testing(dapp: Dapp) {
109
+ let Dapp { id } = dapp;
110
+ id.delete();
111
+ }
112
+ }
@@ -23,7 +23,7 @@ module counter::dapp_system {
23
23
  public(package) fun create(name: String, description: String, clock: &Clock, ctx: &mut TxContext): Dapp {
24
24
  let mut dapp = dapp_schema::create(ctx);
25
25
  assert!(!dapp.borrow_metadata().contains(), 0);
26
- dapp.borrow_mut_metadata().set(
26
+ dapp.metadata().set(
27
27
  dapp_metadata::new(
28
28
  name,
29
29
  description,
@@ -34,11 +34,11 @@ module counter::dapp_system {
34
34
  )
35
35
  );
36
36
  let package_id = type_info::current_package_id<DappKey>();
37
- dapp.borrow_mut_package_id().set(package_id);
38
- dapp.borrow_mut_admin().set(ctx.sender());
39
- dapp.borrow_mut_version().set(1);
40
- dapp.borrow_mut_safe_mode().set(false);
41
- dapp.borrow_mut_schemas().set(vector[]);
37
+ dapp.package_id().set(package_id);
38
+ dapp.admin().set(ctx.sender());
39
+ dapp.version().set(1);
40
+ dapp.safe_mode().set(false);
41
+ dapp.schemas().set(vector[]);
42
42
  dapp
43
43
  }
44
44
 
@@ -51,10 +51,10 @@ module counter::dapp_system {
51
51
  partners: vector<String>,
52
52
  ctx: &TxContext,
53
53
  ) {
54
- assert!(dapp.borrow_admin().contains(), 0);
55
- assert!(dapp.borrow_admin().get() == ctx.sender(), 0);
56
- let created_at = dapp.borrow_mut_metadata().take().get_created_at();
57
- dapp.borrow_mut_metadata().set(
54
+ let admin = dapp.admin().try_get();
55
+ assert!(admin == option::some(ctx.sender()), 0);
56
+ let created_at = dapp.metadata().get().get_created_at();
57
+ dapp.metadata().set(
58
58
  dapp_metadata::new(
59
59
  name,
60
60
  description,
@@ -67,19 +67,19 @@ module counter::dapp_system {
67
67
  }
68
68
 
69
69
  public entry fun transfer_ownership(dapp: &mut Dapp, new_admin: address, ctx: &mut TxContext) {
70
- assert!(dapp.borrow_admin().contains(), 0);
71
- assert!(dapp.borrow_admin().get() == ctx.sender(), 0);
72
- dapp.borrow_mut_admin().set(new_admin);
70
+ let admin = dapp.admin().try_get();
71
+ assert!(admin == option::some(ctx.sender()), 0);
72
+ dapp.admin().set(new_admin);
73
73
  }
74
74
 
75
75
  public entry fun set_safe_mode(dapp: &mut Dapp, safe_mode: bool, ctx: &TxContext) {
76
- assert!(dapp.borrow_admin().contains(), 0);
77
- assert!(dapp.borrow_admin().get() == ctx.sender(), 0);
78
- dapp.borrow_mut_safe_mode().set(safe_mode);
76
+ let admin = dapp.admin().try_get();
77
+ assert!(admin == option::some(ctx.sender()), 0);
78
+ dapp.safe_mode().set(safe_mode);
79
79
  }
80
80
 
81
81
  public fun ensure_no_safe_mode(dapp: &Dapp) {
82
- assert!(!dapp.borrow_safe_mode().get(), 0);
82
+ assert!(!dapp.borrow_safe_mode()[], 0);
83
83
  }
84
84
 
85
85
  public fun ensure_has_authority(dapp: &Dapp, ctx: &TxContext) {
@@ -19,10 +19,4 @@
19
19
  value
20
20
  }
21
21
  }
22
-
23
- public fun emit(value: u32) {
24
- event::emit(IncrementEvent {
25
- value
26
- });
27
- }
28
22
  }
@@ -0,0 +1,16 @@
1
+ // Copyright (c) Obelisk Labs, Inc.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ #[allow(unused_use)]
4
+
5
+ /* Autogenerated file. Do not edit manually. */
6
+
7
+ module counter::errors {
8
+
9
+ #[error]
10
+
11
+ const InvalidIncrement: vector<u8> = b"Number can't be incremented, must be more than 0";
12
+
13
+ public fun invalid_increment_error(condition: bool) {
14
+ assert!(condition, InvalidIncrement)
15
+ }
16
+ }
@@ -0,0 +1,23 @@
1
+ // Copyright (c) Obelisk Labs, Inc.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ #[allow(unused_use)]
4
+
5
+ /* Autogenerated file. Do not edit manually. */
6
+
7
+ module counter::events {
8
+
9
+ use std::ascii::{String, string};
10
+
11
+ use counter::increment_event::IncrementEvent;
12
+
13
+ use counter::increment_event;
14
+
15
+ public fun increment_event(value: u32) {
16
+ dubhe::storage_event::emit_set_record<IncrementEvent, IncrementEvent, IncrementEvent>(
17
+ string(b"increment_event"),
18
+ option::none(),
19
+ option::none(),
20
+ option::some(increment_event::new(value))
21
+ )
22
+ }
23
+ }
@@ -0,0 +1,20 @@
1
+ #[allow(lint(share_owned))]module counter::genesis {
2
+
3
+ use std::ascii::string;
4
+
5
+ use sui::clock::Clock;
6
+
7
+ use counter::dapp_system;
8
+
9
+ public entry fun run(clock: &Clock, ctx: &mut TxContext) {
10
+ // Create a dapp.
11
+ let mut dapp = dapp_system::create(string(b"counter"),string(b"counter contract"), clock , ctx);
12
+ // Create schemas
13
+ let mut schema = counter::schema::create(ctx);
14
+ // Logic that needs to be automated once the contract is deployed
15
+ counter::deploy_hook::run(&mut schema, ctx);
16
+ // Authorize schemas and public share objects
17
+ dapp.add_schema(schema);
18
+ sui::transfer::public_share_object(dapp);
19
+ }
20
+ }
@@ -0,0 +1,54 @@
1
+ // Copyright (c) Obelisk Labs, Inc.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ #[allow(unused_use)]
4
+
5
+ /* Autogenerated file. Do not edit manually. */
6
+
7
+ module 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::storage;
18
+
19
+ use dubhe::storage_value::{Self, StorageValue};
20
+
21
+ use dubhe::storage_map::{Self, StorageMap};
22
+
23
+ use dubhe::storage_double_map::{Self, StorageDoubleMap};
24
+
25
+ use sui::dynamic_field as df;
26
+
27
+ public struct Schema has key, store {
28
+ id: UID,
29
+ }
30
+
31
+ public fun borrow_value(self: &Schema): &StorageValue<u32> {
32
+ storage::borrow_field(&self.id, b"value")
33
+ }
34
+
35
+ public(package) fun value(self: &mut Schema): &mut StorageValue<u32> {
36
+ storage::borrow_mut_field(&mut self.id, b"value")
37
+ }
38
+
39
+ public(package) fun create(ctx: &mut TxContext): Schema {
40
+ let mut id = object::new(ctx);
41
+ storage::add_field<StorageValue<u32>>(&mut id, b"value", storage_value::new(b"value", ctx));
42
+ Schema { id }
43
+ }
44
+
45
+ public fun migrate(_schema: &mut Schema, _cap: &UpgradeCap, _ctx: &mut TxContext) {}
46
+
47
+ // ======================================== View Functions ========================================
48
+
49
+ public fun get_value(self: &Schema): &u32 {
50
+ self.borrow_value().get()
51
+ }
52
+
53
+ // =========================================================================================================
54
+ }
@@ -1,24 +1,14 @@
1
- #[allow(lint(share_owned), unused_let_mut)]module counter::deploy_hook {
2
-
3
- use std::ascii::string;
4
-
5
- use sui::clock::Clock;
6
-
7
- use counter::dapp_system;
8
-
9
- use counter::counter_schema::Counter;
10
-
11
- public entry fun run(clock: &Clock, ctx: &mut TxContext) {
12
- // Create a dapp.
13
- let mut dapp = dapp_system::create(string(b"counter"),string(b"counter contract"), clock , ctx);
14
- // Create schemas
15
- let mut counter = counter::counter_schema::create(ctx);
16
- // Logic that needs to be automated once the contract is deployed
17
- {
18
- counter.value().set(0);
19
- };
20
- // Authorize schemas and public share objects
21
- dapp.add_schema<Counter>(counter, ctx);
22
- sui::transfer::public_share_object(dapp);
1
+ // Copyright (c) Obelisk Labs, Inc.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ #[allow(unused_use)]
4
+
5
+ /* Autogenerated file. Do not edit manually. */
6
+
7
+ module counter::deploy_hook {
8
+
9
+ use counter::schema::Schema;
10
+
11
+ public(package) fun run(_schema: &mut Schema, _ctx: &mut TxContext) {
12
+ _schema.value().set(0);
23
13
  }
24
14
  }
@@ -1,20 +1,17 @@
1
1
  module counter::counter_system {
2
- use counter::counter_schema::Counter;
3
- use counter::increment_event;
4
- use counter::invalid_increment_error;
2
+ use counter::schema::Schema;
3
+ use counter::events::increment_event;
4
+ use counter::errors::invalid_increment_error;
5
5
 
6
- public entry fun inc(counter: &mut Counter, number: u32) {
6
+ public entry fun inc(scheam: &mut Schema, number: u32) {
7
7
  // Check if the increment value is valid.
8
- invalid_increment_error::require(number > 0 && number < 100);
9
- counter.value().mutate!(|value| {
10
- // Increment the counter value.
11
- *value = *value + number;
12
- // Emit an event to notify the increment.
13
- increment_event::emit(number);
14
- });
8
+ invalid_increment_error(number > 0 && number < 100);
9
+ let value = scheam.value()[];
10
+ scheam.value().set(value + number);
11
+ increment_event(number);
15
12
  }
16
13
 
17
- public fun get(counter: &Counter) : u32 {
18
- counter.borrow_value().get()
14
+ public fun get(scheam: &Schema): u32 {
15
+ scheam.borrow_value()[]
19
16
  }
20
17
  }
@@ -2,24 +2,24 @@
2
2
  module counter::counter_test {
3
3
  use sui::test_scenario;
4
4
  use counter::counter_system;
5
- use counter::counter_schema::Counter;
6
5
  use counter::init_test;
6
+ use counter::schema::Schema;
7
7
 
8
8
  #[test]
9
9
  public fun inc() {
10
10
  let (scenario, dapp) = init_test::deploy_dapp_for_testing(@0xA);
11
11
 
12
- let mut counter = test_scenario::take_shared<Counter>(&scenario);
12
+ let mut schema = test_scenario::take_shared<Schema>(&scenario);
13
13
 
14
- assert!(counter.borrow_value().get() == 0);
14
+ assert!(schema.value().get() == 0);
15
15
 
16
- counter_system::inc(&mut counter, 10);
17
- assert!(counter.borrow_value().get() == 10);
16
+ counter_system::inc(&mut schema, 10);
17
+ assert!(schema.value().get() == 10);
18
18
 
19
- counter_system::inc(&mut counter, 10);
20
- assert!(counter.borrow_value().get() == 20);
19
+ counter_system::inc(&mut schema, 10);
20
+ assert!(schema.value().get() == 20);
21
21
 
22
- test_scenario::return_shared(counter);
22
+ test_scenario::return_shared(schema);
23
23
  dapp.distroy_dapp_for_testing();
24
24
  scenario.end();
25
25
  }
@@ -12,7 +12,7 @@
12
12
  let mut scenario = test_scenario::begin(sender);
13
13
  let ctx = test_scenario::ctx(&mut scenario);
14
14
  let clock = clock::create_for_testing(ctx);
15
- counter::deploy_hook::run(&clock, ctx);
15
+ counter::genesis::run(&clock, ctx);
16
16
  clock::destroy_for_testing(clock);
17
17
  test_scenario::next_tx(&mut scenario,sender);
18
18
  let dapp = test_scenario::take_shared<Dapp>(&scenario);
@@ -0,0 +1,33 @@
1
+ module dubhe::storage_event;
2
+ use std::ascii::String;
3
+ use sui::event;
4
+
5
+ public struct RemoveRecord<K1: copy + drop, K2: copy + drop> has copy, drop {
6
+ name: String,
7
+ key1: Option<K1>,
8
+ key2: Option<K2>
9
+ }
10
+
11
+ public struct SetRecord<K1: copy + drop, K2: copy + drop, V: copy + drop> has copy, drop {
12
+ name: String,
13
+ key1: Option<K1>,
14
+ key2: Option<K2>,
15
+ value: Option<V>
16
+ }
17
+
18
+ public fun emit_set_record<K1: copy + drop, K2: copy + drop, V: copy + drop>(name: String, key1: Option<K1>, key2: Option<K2>, value: Option<V>) {
19
+ event::emit(SetRecord {
20
+ name,
21
+ key1,
22
+ key2,
23
+ value
24
+ });
25
+ }
26
+
27
+ public fun emit_remove_record<K1: copy + drop, K2: copy + drop>(name: String, key1: Option<K1>, key2: Option<K2>) {
28
+ event::emit(RemoveRecord {
29
+ name,
30
+ key1,
31
+ key2,
32
+ });
33
+ }