create-dubhe 0.0.13 → 0.0.14
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/package.json +1 -1
- package/template/101/sui-template/contracts/counter/sources/codegen/errors/counter_error_invalid_increment.move +30 -0
- package/template/101/sui-template/contracts/counter/sources/codegen/events/counter_event_increment.move +28 -0
- package/template/101/sui-template/contracts/counter/sources/codegen/schemas/counter.move +13 -13
- package/template/101/sui-template/contracts/counter/sources/codegen/schemas/default/dapp/metadata.move +102 -0
- package/template/101/sui-template/contracts/counter/sources/codegen/schemas/default/dapp/schema.move +114 -0
- package/template/101/sui-template/contracts/counter/sources/codegen/schemas/default/dapp/system.move +93 -0
- package/template/101/sui-template/contracts/counter/sources/scripts/deploy_hook.move +10 -82
- package/template/101/sui-template/contracts/counter/sources/scripts/migrate.move +1 -2
- package/template/101/sui-template/contracts/counter/sources/systems/counter.move +13 -4
- package/template/101/sui-template/contracts/counter/sources/tests/counter.move +26 -0
- package/template/101/sui-template/contracts/counter/sources/tests/init.move +21 -0
- package/template/101/sui-template/contracts/dubhe-framework/sources/frames/utils/type_info.move +7 -0
- package/template/{nextjs/sui-template/contracts/dubhe-framework/sources/storages/migrate.move → 101/sui-template/contracts/dubhe-framework/sources/storages/migration.move} +3 -3
- package/template/101/sui-template/contracts/dubhe-framework/sources/storages/value.move +1 -1
- package/template/101/sui-template/dubhe.config.ts +23 -10
- package/template/101/sui-template/package.json +2 -2
- package/template/101/sui-template/src/pages/home/index.tsx +1 -1
- package/template/contract/sui-template/contracts/counter/sources/codegen/errors/counter_error_invalid_increment.move +6 -4
- package/template/contract/sui-template/contracts/counter/sources/codegen/events/counter_event_increment.move +1 -1
- package/template/contract/sui-template/contracts/counter/sources/codegen/schemas/counter.move +13 -13
- package/template/contract/sui-template/contracts/counter/sources/codegen/schemas/default/dapp/metadata.move +102 -0
- package/template/contract/sui-template/contracts/counter/sources/codegen/schemas/default/dapp/schema.move +114 -0
- package/template/contract/sui-template/contracts/counter/sources/codegen/schemas/default/dapp/system.move +93 -0
- package/template/contract/sui-template/contracts/counter/sources/scripts/deploy_hook.move +9 -81
- package/template/contract/sui-template/contracts/counter/sources/scripts/migrate.move +1 -1
- package/template/contract/sui-template/contracts/counter/sources/systems/counter.move +7 -7
- package/template/contract/sui-template/contracts/counter/sources/tests/counter.move +26 -0
- package/template/contract/sui-template/contracts/counter/sources/tests/init.move +21 -0
- package/template/contract/sui-template/contracts/dubhe-framework/sources/frames/utils/type_info.move +7 -0
- package/template/contract/sui-template/contracts/dubhe-framework/sources/storages/{migrate.move → migration.move} +3 -3
- package/template/contract/sui-template/contracts/dubhe-framework/sources/storages/value.move +1 -1
- package/template/contract/sui-template/dubhe.config.ts +1 -2
- package/template/contract/sui-template/package.json +2 -2
- package/template/nextjs/sui-template/contracts/counter/sources/codegen/errors/counter_error_invalid_increment.move +30 -0
- package/template/nextjs/sui-template/contracts/counter/sources/codegen/events/counter_event_increment.move +28 -0
- package/template/nextjs/sui-template/contracts/counter/sources/codegen/schemas/counter.move +13 -13
- package/template/nextjs/sui-template/contracts/counter/sources/codegen/schemas/default/dapp/metadata.move +102 -0
- package/template/nextjs/sui-template/contracts/counter/sources/codegen/schemas/default/dapp/schema.move +114 -0
- package/template/nextjs/sui-template/contracts/counter/sources/codegen/schemas/default/dapp/system.move +93 -0
- package/template/nextjs/sui-template/contracts/counter/sources/scripts/deploy_hook.move +9 -81
- package/template/nextjs/sui-template/contracts/counter/sources/scripts/migrate.move +1 -1
- package/template/nextjs/sui-template/contracts/counter/sources/systems/counter.move +13 -4
- package/template/nextjs/sui-template/contracts/counter/sources/tests/counter.move +26 -0
- package/template/nextjs/sui-template/contracts/counter/sources/tests/init.move +21 -0
- package/template/nextjs/sui-template/contracts/dubhe-framework/sources/frames/utils/type_info.move +7 -0
- package/template/{101/sui-template/contracts/dubhe-framework/sources/storages/migrate.move → nextjs/sui-template/contracts/dubhe-framework/sources/storages/migration.move} +3 -3
- package/template/nextjs/sui-template/contracts/dubhe-framework/sources/storages/value.move +1 -1
- package/template/nextjs/sui-template/dubhe.config.ts +23 -10
- package/template/nextjs/sui-template/package.json +2 -2
- package/template/nextjs/sui-template/src/pages/home/index.tsx +1 -1
- package/template/101/sui-template/contracts/counter/sources/codegen/dapp_key.move +0 -16
- package/template/101/sui-template/contracts/counter/sources/codegen/schema_hub.move +0 -60
- package/template/101/sui-template/contracts/dubhe-framework/sources/core/dapps/metadata.move +0 -96
- package/template/101/sui-template/contracts/dubhe-framework/sources/core/dapps/schema.move +0 -113
- package/template/101/sui-template/contracts/dubhe-framework/sources/core/dapps/system.move +0 -101
- package/template/101/sui-template/contracts/dubhe-framework/sources/core/dapps/tests.move +0 -66
- package/template/101/sui-template/contracts/dubhe-framework/sources/core/root/schema.move +0 -33
- package/template/101/sui-template/contracts/dubhe-framework/sources/core/root/system.move +0 -24
- package/template/101/sui-template/contracts/dubhe-framework/sources/core/root/tests.move +0 -39
- package/template/101/sui-template/contracts/dubhe-framework/tests/init.move +0 -6
- package/template/101/sui-template/contracts/dubhe-framework/tests/obelisk_framework_tests.move +0 -19
- package/template/contract/sui-template/contracts/counter/sources/codegen/dapp_key.move +0 -16
- package/template/contract/sui-template/contracts/counter/sources/codegen/schema_hub.move +0 -60
- package/template/contract/sui-template/contracts/dubhe-framework/sources/core/dapps/metadata.move +0 -96
- package/template/contract/sui-template/contracts/dubhe-framework/sources/core/dapps/schema.move +0 -113
- package/template/contract/sui-template/contracts/dubhe-framework/sources/core/dapps/system.move +0 -101
- package/template/contract/sui-template/contracts/dubhe-framework/sources/core/dapps/tests.move +0 -66
- package/template/contract/sui-template/contracts/dubhe-framework/sources/core/root/schema.move +0 -33
- package/template/contract/sui-template/contracts/dubhe-framework/sources/core/root/system.move +0 -24
- package/template/contract/sui-template/contracts/dubhe-framework/sources/core/root/tests.move +0 -39
- package/template/contract/sui-template/contracts/dubhe-framework/tests/init.move +0 -6
- package/template/contract/sui-template/contracts/dubhe-framework/tests/obelisk_framework_tests.move +0 -19
- package/template/nextjs/sui-template/contracts/counter/sources/codegen/dapp_key.move +0 -16
- package/template/nextjs/sui-template/contracts/counter/sources/codegen/schema_hub.move +0 -60
- package/template/nextjs/sui-template/contracts/dubhe-framework/sources/core/dapps/metadata.move +0 -96
- package/template/nextjs/sui-template/contracts/dubhe-framework/sources/core/dapps/schema.move +0 -113
- package/template/nextjs/sui-template/contracts/dubhe-framework/sources/core/dapps/system.move +0 -101
- package/template/nextjs/sui-template/contracts/dubhe-framework/sources/core/dapps/tests.move +0 -66
- package/template/nextjs/sui-template/contracts/dubhe-framework/sources/core/root/schema.move +0 -33
- package/template/nextjs/sui-template/contracts/dubhe-framework/sources/core/root/system.move +0 -24
- package/template/nextjs/sui-template/contracts/dubhe-framework/sources/core/root/tests.move +0 -39
- package/template/nextjs/sui-template/contracts/dubhe-framework/tests/init.move +0 -6
- package/template/nextjs/sui-template/contracts/dubhe-framework/tests/obelisk_framework_tests.move +0 -19
package/template/nextjs/sui-template/contracts/dubhe-framework/sources/core/dapps/metadata.move
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
module dubhe::dapp_metadata {
|
|
2
|
-
use std::ascii::String;
|
|
3
|
-
|
|
4
|
-
public struct DappMetadata has drop, copy, store {
|
|
5
|
-
name: String,
|
|
6
|
-
description: String,
|
|
7
|
-
icon_url: String,
|
|
8
|
-
website_url: String,
|
|
9
|
-
created_at: u64,
|
|
10
|
-
partners: vector<String>,
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
public fun new(
|
|
14
|
-
name: String,
|
|
15
|
-
description: String,
|
|
16
|
-
icon_url: String,
|
|
17
|
-
website_url: String,
|
|
18
|
-
created_at: u64,
|
|
19
|
-
partners: vector<String>,
|
|
20
|
-
): DappMetadata {
|
|
21
|
-
DappMetadata {
|
|
22
|
-
name,
|
|
23
|
-
description,
|
|
24
|
-
icon_url,
|
|
25
|
-
website_url,
|
|
26
|
-
created_at,
|
|
27
|
-
partners,
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
public fun set(
|
|
32
|
-
self: &mut DappMetadata,
|
|
33
|
-
name: String,
|
|
34
|
-
description: String,
|
|
35
|
-
icon_url: String,
|
|
36
|
-
website_url: String,
|
|
37
|
-
created_at: u64,
|
|
38
|
-
partners: vector<String>,
|
|
39
|
-
) {
|
|
40
|
-
self.name = name;
|
|
41
|
-
self.description = description;
|
|
42
|
-
self.icon_url = icon_url;
|
|
43
|
-
self.website_url = website_url;
|
|
44
|
-
self.created_at = created_at;
|
|
45
|
-
self.partners = partners;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
public fun set_name(self: &mut DappMetadata, name: String) {
|
|
49
|
-
self.name = name;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
public fun set_description(self: &mut DappMetadata, description: String) {
|
|
53
|
-
self.description = description;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
public fun set_icon_url(self: &mut DappMetadata, icon_url: String) {
|
|
57
|
-
self.icon_url = icon_url;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
public fun set_website_url(self: &mut DappMetadata, website_url: String) {
|
|
61
|
-
self.website_url = website_url;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
public fun set_created_at(self: &mut DappMetadata, created_at: u64) {
|
|
65
|
-
self.created_at = created_at;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
public fun set_partners(self: &mut DappMetadata, partners: vector<String>) {
|
|
69
|
-
self.partners = partners;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
public fun get_name(self: DappMetadata): String {
|
|
73
|
-
self.name
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
public fun get_description(self: DappMetadata): String {
|
|
77
|
-
self.description
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
public fun get_icon_url(self: DappMetadata): String {
|
|
81
|
-
self.icon_url
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
public fun get_website_url(self: DappMetadata): String {
|
|
85
|
-
self.website_url
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
public fun get_created_at(self: DappMetadata): u64 {
|
|
89
|
-
self.created_at
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
public fun get_partners(self: DappMetadata): vector<String> {
|
|
93
|
-
self.partners
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
}
|
package/template/nextjs/sui-template/contracts/dubhe-framework/sources/core/dapps/schema.move
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
module dubhe::dapps_schema {
|
|
2
|
-
use std::ascii::String;
|
|
3
|
-
use dubhe::storage_value;
|
|
4
|
-
use sui::balance::Balance;
|
|
5
|
-
use sui::sui::SUI;
|
|
6
|
-
use sui::balance;
|
|
7
|
-
use dubhe::storage_value::StorageValue;
|
|
8
|
-
use dubhe::storage_map;
|
|
9
|
-
use sui::transfer::public_share_object;
|
|
10
|
-
use dubhe::dapp_metadata::DappMetadata;
|
|
11
|
-
use dubhe::storage_map::StorageMap;
|
|
12
|
-
|
|
13
|
-
public struct Dapps has key, store {
|
|
14
|
-
id: UID,
|
|
15
|
-
admin: StorageMap<address, address>,
|
|
16
|
-
version: StorageMap<address, u32>,
|
|
17
|
-
metadata: StorageMap<address, DappMetadata>,
|
|
18
|
-
schemas: StorageMap<address, vector<String>>,
|
|
19
|
-
safe_mode: StorageMap<address, bool>,
|
|
20
|
-
verified: StorageMap<address, bool>,
|
|
21
|
-
reserved: StorageValue<Balance<SUI>>,
|
|
22
|
-
reserve_amount: StorageValue<u64>,
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
public(package) fun borrow_mut_version(self: &mut Dapps): &mut StorageMap<address, u32> {
|
|
27
|
-
&mut self.version
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
public(package) fun borrow_mut_admin(self: &mut Dapps): &mut StorageMap<address, address> {
|
|
31
|
-
&mut self.admin
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
public(package) fun borrow_mut_metadata(self: &mut Dapps): &mut StorageMap<address, DappMetadata> {
|
|
35
|
-
&mut self.metadata
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
public(package) fun borrow_mut_schemas(self: &mut Dapps): &mut StorageMap<address, vector<String>> {
|
|
39
|
-
&mut self.schemas
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
public(package) fun borrow_mut_safe_mode(self: &mut Dapps): &mut StorageMap<address, bool> {
|
|
43
|
-
&mut self.safe_mode
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
public(package) fun borrow_mut_verified(self: &mut Dapps): &mut StorageMap<address, bool> {
|
|
47
|
-
&mut self.verified
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
public(package) fun borrow_mut_reserved(self: &mut Dapps): &mut StorageValue<Balance<SUI>> {
|
|
51
|
-
&mut self.reserved
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
public(package) fun borrow_mut_reserve_amount(self: &mut Dapps): &mut StorageValue<u64> {
|
|
55
|
-
&mut self.reserve_amount
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
public fun borrow_admin(self: &Dapps): &StorageMap<address, address> {
|
|
59
|
-
&self.admin
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
public fun borrow_version(self: &Dapps): &StorageMap<address, u32> {
|
|
63
|
-
&self.version
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
public fun borrow_metadata(self: &Dapps): &StorageMap<address, DappMetadata> {
|
|
67
|
-
&self.metadata
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
public fun borrow_schemas(self: &Dapps): &StorageMap<address, vector<String>> {
|
|
71
|
-
&self.schemas
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
public fun borrow_safe_mode(self: &Dapps): &StorageMap<address, bool> {
|
|
75
|
-
&self.safe_mode
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
public fun borrow_verified(self: &mut Dapps): &StorageMap<address, bool> {
|
|
79
|
-
&self.verified
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
public fun borrow_reserved(self: &mut Dapps): &StorageValue<Balance<SUI>> {
|
|
83
|
-
&self.reserved
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
public fun borrow_reserve_amount(self: &mut Dapps): &StorageValue<u64> {
|
|
87
|
-
&self.reserve_amount
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
fun init(ctx: &mut TxContext) {
|
|
91
|
-
let mut reserved = storage_value::new();
|
|
92
|
-
reserved.put(balance::zero());
|
|
93
|
-
|
|
94
|
-
let mut reserve_amount = storage_value::new();
|
|
95
|
-
reserve_amount.put(1_000_000_000);
|
|
96
|
-
public_share_object(Dapps {
|
|
97
|
-
id: object::new(ctx),
|
|
98
|
-
admin: storage_map::new(),
|
|
99
|
-
version: storage_map::new(),
|
|
100
|
-
metadata: storage_map::new(),
|
|
101
|
-
schemas: storage_map::new(),
|
|
102
|
-
safe_mode: storage_map::new(),
|
|
103
|
-
verified: storage_map::new(),
|
|
104
|
-
reserved,
|
|
105
|
-
reserve_amount
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
#[test_only]
|
|
110
|
-
public fun init_dapps_for_testing(ctx: &mut TxContext){
|
|
111
|
-
init(ctx)
|
|
112
|
-
}
|
|
113
|
-
}
|
package/template/nextjs/sui-template/contracts/dubhe-framework/sources/core/dapps/system.move
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
module dubhe::dapps_system {
|
|
2
|
-
use std::ascii::String;
|
|
3
|
-
use std::ascii;
|
|
4
|
-
use dubhe::root_schema::Root;
|
|
5
|
-
use dubhe::dapp_metadata;
|
|
6
|
-
use sui::clock::Clock;
|
|
7
|
-
use sui::coin;
|
|
8
|
-
use sui::coin::Coin;
|
|
9
|
-
use sui::sui::SUI;
|
|
10
|
-
use dubhe::dapps_schema::Dapps;
|
|
11
|
-
use dubhe::root_system;
|
|
12
|
-
|
|
13
|
-
public entry fun register<UpgradeCap: key>(
|
|
14
|
-
dapps: &mut Dapps,
|
|
15
|
-
upgrade_cap: &UpgradeCap,
|
|
16
|
-
name: String,
|
|
17
|
-
description: String,
|
|
18
|
-
clock: &Clock,
|
|
19
|
-
coin: Coin<SUI>,
|
|
20
|
-
ctx: &mut TxContext
|
|
21
|
-
) {
|
|
22
|
-
let dapp_id = object::id_address<UpgradeCap>(upgrade_cap);
|
|
23
|
-
assert!(!dapps.borrow_metadata().contains_key(dapp_id), 0);
|
|
24
|
-
|
|
25
|
-
dapps.borrow_mut_metadata().set(
|
|
26
|
-
dapp_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_id, ctx.sender());
|
|
37
|
-
dapps.borrow_mut_version().set(dapp_id, 1);
|
|
38
|
-
dapps.borrow_mut_safe_mode().set(dapp_id, false);
|
|
39
|
-
|
|
40
|
-
let reserve_amount = dapps.borrow_reserve_amount().get();
|
|
41
|
-
assert!(coin.value() == reserve_amount, 0);
|
|
42
|
-
dapps.borrow_mut_reserved().borrow_mut().join(coin.into_balance());
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
public entry fun unregister<UpgradeCap: key>(
|
|
46
|
-
dapps: &mut Dapps,
|
|
47
|
-
upgrade_cap: &UpgradeCap,
|
|
48
|
-
ctx: &mut TxContext
|
|
49
|
-
) {
|
|
50
|
-
let dapp_id = object::id_address<UpgradeCap>(upgrade_cap);
|
|
51
|
-
assert!(dapps.borrow_metadata().contains_key(dapp_id), 0);
|
|
52
|
-
|
|
53
|
-
dapps.borrow_mut_metadata().remove(dapp_id);
|
|
54
|
-
dapps.borrow_mut_admin().remove(dapp_id);
|
|
55
|
-
dapps.borrow_mut_version().remove(dapp_id);
|
|
56
|
-
dapps.borrow_mut_safe_mode().remove(dapp_id);
|
|
57
|
-
|
|
58
|
-
let reserve_amount = dapps.borrow_reserve_amount().get();
|
|
59
|
-
let reserve_amount = dapps.borrow_mut_reserved().borrow_mut().split(reserve_amount);
|
|
60
|
-
let reserve_amount = coin::from_balance(reserve_amount, ctx);
|
|
61
|
-
transfer::public_transfer(reserve_amount, ctx.sender());
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
public entry fun set_metadata<UpgradeCap: key>(
|
|
65
|
-
dapps: &mut Dapps,
|
|
66
|
-
upgrade_cap: &UpgradeCap,
|
|
67
|
-
name: String,
|
|
68
|
-
description: String,
|
|
69
|
-
icon_url: String,
|
|
70
|
-
website_url: String,
|
|
71
|
-
partners: vector<String>
|
|
72
|
-
) {
|
|
73
|
-
let dapp_id = object::id_address<UpgradeCap>(upgrade_cap);
|
|
74
|
-
assert!(dapps.borrow_metadata().contains_key(dapp_id), 0);
|
|
75
|
-
let created_at = dapps.borrow_mut_metadata().take(dapp_id).get_created_at();
|
|
76
|
-
dapps.borrow_mut_metadata().set(dapp_id, dapp_metadata::new(name, description, icon_url, website_url, created_at, partners));
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
public entry fun transfer_ownership<UpgradeCap: key>(
|
|
80
|
-
dapps: &mut Dapps,
|
|
81
|
-
upgrade_cap: &UpgradeCap,
|
|
82
|
-
new_admin: address,
|
|
83
|
-
ctx: &mut TxContext
|
|
84
|
-
) {
|
|
85
|
-
let dapp_id = object::id_address<UpgradeCap>(upgrade_cap);
|
|
86
|
-
assert!(dapps.borrow_admin().get(dapp_id) == ctx.sender(), 0);
|
|
87
|
-
dapps.borrow_mut_admin().set(dapp_id, new_admin);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
public entry fun add_verification(dapps: &mut Dapps, root: &Root, dapp_id: address, ctx: &mut TxContext) {
|
|
91
|
-
root_system::ensure_root(root, ctx);
|
|
92
|
-
assert!(dapps.borrow_metadata().contains_key(dapp_id), 0);
|
|
93
|
-
dapps.borrow_mut_verified().set(dapp_id, true);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
public entry fun remove_verification(dapps: &mut Dapps, root: &Root, dapp_id: address, ctx: &mut TxContext) {
|
|
97
|
-
root_system::ensure_root(root, ctx);
|
|
98
|
-
assert!(dapps.borrow_metadata().contains_key(dapp_id), 0);
|
|
99
|
-
dapps.borrow_mut_verified().remove(dapp_id);
|
|
100
|
-
}
|
|
101
|
-
}
|
package/template/nextjs/sui-template/contracts/dubhe-framework/sources/core/dapps/tests.move
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
#[test_only]
|
|
2
|
-
module dubhe::dapps_tests {
|
|
3
|
-
use dubhe::dapps_schema::Dapps;
|
|
4
|
-
use dubhe::dapps_schema;
|
|
5
|
-
use dubhe::dapps_system;
|
|
6
|
-
use std::ascii::string;
|
|
7
|
-
use std::debug;
|
|
8
|
-
use sui::clock;
|
|
9
|
-
use sui::coin;
|
|
10
|
-
use sui::test_scenario;
|
|
11
|
-
use sui::package;
|
|
12
|
-
use sui::package::UpgradeCap;
|
|
13
|
-
use sui::sui::SUI;
|
|
14
|
-
|
|
15
|
-
public struct DappKey has drop {}
|
|
16
|
-
|
|
17
|
-
#[test]
|
|
18
|
-
public fun dapps_register() {
|
|
19
|
-
let mut scenario = test_scenario::begin(@0xA);
|
|
20
|
-
{
|
|
21
|
-
let ctx = test_scenario::ctx(&mut scenario);
|
|
22
|
-
dapps_schema::init_dapps_for_testing(ctx);
|
|
23
|
-
test_scenario::next_tx(&mut scenario,@0xA);
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
let mut dapps = test_scenario::take_shared<Dapps>(&scenario);
|
|
27
|
-
|
|
28
|
-
let upgrade_cap = package::test_publish(@0x42.to_id(), scenario.ctx());
|
|
29
|
-
debug::print(&object::id_address<UpgradeCap>(&upgrade_cap));
|
|
30
|
-
|
|
31
|
-
let coin = coin::mint_for_testing<SUI>(1_000_000_000, test_scenario::ctx(&mut scenario));
|
|
32
|
-
|
|
33
|
-
let clock = clock::create_for_testing(test_scenario::ctx(&mut scenario));
|
|
34
|
-
dapps_system::register<UpgradeCap>(
|
|
35
|
-
&mut dapps,
|
|
36
|
-
&upgrade_cap,
|
|
37
|
-
string(b"DappKey"),
|
|
38
|
-
string(b"DappKey"),
|
|
39
|
-
&clock,
|
|
40
|
-
coin,
|
|
41
|
-
test_scenario::ctx(&mut scenario),
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
test_scenario::next_tx(&mut scenario,@0xA);
|
|
45
|
-
|
|
46
|
-
let dapp_id = object::id_address<UpgradeCap>(&upgrade_cap);
|
|
47
|
-
assert!(dapps.borrow_version().get(dapp_id) == 1, 0);
|
|
48
|
-
assert!(dapps.borrow_metadata().contains_key(dapp_id));
|
|
49
|
-
assert!(dapps.borrow_admin().get(dapp_id) == test_scenario::ctx(&mut scenario).sender(), 0);
|
|
50
|
-
assert!(dapps.borrow_safe_mode().get(dapp_id) == false, 0);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
dapps_system::unregister(&mut dapps, &upgrade_cap, test_scenario::ctx(&mut scenario));
|
|
54
|
-
test_scenario::next_tx(&mut scenario,@0xA);
|
|
55
|
-
|
|
56
|
-
assert!(!dapps.borrow_version().contains_key(dapp_id));
|
|
57
|
-
assert!(!dapps.borrow_metadata().contains_key(dapp_id));
|
|
58
|
-
assert!(!dapps.borrow_admin().contains_key(dapp_id));
|
|
59
|
-
assert!(!dapps.borrow_safe_mode().contains_key(dapp_id));
|
|
60
|
-
|
|
61
|
-
clock::destroy_for_testing(clock);
|
|
62
|
-
test_scenario::return_shared<Dapps>(dapps);
|
|
63
|
-
upgrade_cap.make_immutable();
|
|
64
|
-
scenario.end();
|
|
65
|
-
}
|
|
66
|
-
}
|
package/template/nextjs/sui-template/contracts/dubhe-framework/sources/core/root/schema.move
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
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
|
-
}
|
package/template/nextjs/sui-template/contracts/dubhe-framework/sources/core/root/system.move
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
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
|
-
}
|
package/template/nextjs/sui-template/contracts/dubhe-framework/tests/obelisk_framework_tests.move
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
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
|
-
*/
|