create-dubhe 0.1.10 → 0.1.12
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/core/schema.move +11 -1
- package/template/101/sui-template/contracts/counter/sources/codegen/core/system.move +1 -16
- package/template/101/sui-template/package.json +4 -4
- package/template/contract/sui-template/package.json +4 -4
- package/template/nextjs/sui-template/contracts/counter/sources/codegen/core/schema.move +11 -1
- package/template/nextjs/sui-template/contracts/counter/sources/codegen/core/system.move +1 -16
- package/template/nextjs/sui-template/package.json +4 -4
package/package.json
CHANGED
|
@@ -106,7 +106,17 @@
|
|
|
106
106
|
&self.id
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
public fun migrate(_schema: &mut Schema,
|
|
109
|
+
public fun migrate(_schema: &mut Schema, _ctx: &mut TxContext) {}
|
|
110
|
+
|
|
111
|
+
public(package) fun upgrade(schema: &mut Schema, new_package_id: address, new_version: u32, ctx: &mut TxContext) {
|
|
112
|
+
assert!(schema.dapp__metadata().contains(), 0);
|
|
113
|
+
assert!(schema.dapp__admin().get() == ctx.sender(), 0);
|
|
114
|
+
schema.dapp__package_id().set(new_package_id);
|
|
115
|
+
let current_version = schema.dapp__version()[];
|
|
116
|
+
assert!(current_version < new_version, 0);
|
|
117
|
+
schema.dapp__version().set(new_version);
|
|
118
|
+
schema.migrate(ctx);
|
|
119
|
+
}
|
|
110
120
|
|
|
111
121
|
// ======================================== View Functions ========================================
|
|
112
122
|
|
|
@@ -22,12 +22,6 @@ module counter::counter_dapp_system {
|
|
|
22
22
|
|
|
23
23
|
use dubhe::storage_value::StorageValue;
|
|
24
24
|
|
|
25
|
-
public struct DappKey has drop {}
|
|
26
|
-
|
|
27
|
-
public(package) fun new(): DappKey {
|
|
28
|
-
DappKey { }
|
|
29
|
-
}
|
|
30
|
-
|
|
31
25
|
public entry fun set_metadata(
|
|
32
26
|
schema: &mut Schema,
|
|
33
27
|
name: String,
|
|
@@ -100,7 +94,7 @@ module counter::counter_dapp_system {
|
|
|
100
94
|
vector[]
|
|
101
95
|
)
|
|
102
96
|
);
|
|
103
|
-
let package_id = type_info::current_package_id<
|
|
97
|
+
let package_id = type_info::current_package_id<Schema>();
|
|
104
98
|
schema.dapp__package_id().set(package_id);
|
|
105
99
|
schema.dapp__admin().set(ctx.sender());
|
|
106
100
|
schema.dapp__version().set(1);
|
|
@@ -108,15 +102,6 @@ module counter::counter_dapp_system {
|
|
|
108
102
|
schema.dapp__authorised_schemas().set(vector[]);
|
|
109
103
|
}
|
|
110
104
|
|
|
111
|
-
public(package) fun upgrade<DappKey: drop>(schema: &mut Schema, ctx: &TxContext) {
|
|
112
|
-
assert!(schema.dapp__metadata().contains(), 0);
|
|
113
|
-
assert!(schema.dapp__admin().get() == ctx.sender(), 0);
|
|
114
|
-
let new_package_id = type_info::current_package_id<DappKey>();
|
|
115
|
-
schema.dapp__package_id().set(new_package_id);
|
|
116
|
-
let current_version = schema.dapp__version()[];
|
|
117
|
-
schema.dapp__version().set(current_version + 1);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
105
|
public(package) fun add_schema<S: key + store>(schema: &mut Schema, new_schema: S) {
|
|
121
106
|
let mut schemas = schema.dapp__authorised_schemas()[];
|
|
122
107
|
schemas.push_back(object::id_address<S>(&new_schema));
|
|
@@ -35,10 +35,10 @@
|
|
|
35
35
|
"prod:mainnet": "pnpm config:store mainnet && pnpm next"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@0xobelisk/sui-cli": "^1.1.
|
|
39
|
-
"@0xobelisk/sui-client": "^1.1.
|
|
40
|
-
"@0xobelisk/sui-common": "^1.1.
|
|
41
|
-
"@0xobelisk/sui-indexer": "^1.1.
|
|
38
|
+
"@0xobelisk/sui-cli": "^1.1.9",
|
|
39
|
+
"@0xobelisk/sui-client": "^1.1.12",
|
|
40
|
+
"@0xobelisk/sui-common": "^1.1.10",
|
|
41
|
+
"@0xobelisk/sui-indexer": "^1.1.14",
|
|
42
42
|
"jotai": "^1.7.2",
|
|
43
43
|
"dotenv": "^16.4.5",
|
|
44
44
|
"react": "^19.0.0",
|
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
"indexer:sqlite": "pnpm sqlite-indexer --force-regenesis --network"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@0xobelisk/sui-cli": "^1.1.
|
|
19
|
-
"@0xobelisk/sui-client": "^1.1.
|
|
20
|
-
"@0xobelisk/sui-common": "^1.1.
|
|
21
|
-
"@0xobelisk/sui-indexer": "^1.1.
|
|
18
|
+
"@0xobelisk/sui-cli": "^1.1.9",
|
|
19
|
+
"@0xobelisk/sui-client": "^1.1.12",
|
|
20
|
+
"@0xobelisk/sui-common": "^1.1.10",
|
|
21
|
+
"@0xobelisk/sui-indexer": "^1.1.14",
|
|
22
22
|
"dotenv": "^16.4.5",
|
|
23
23
|
"chalk": "^4.1.2"
|
|
24
24
|
},
|
|
@@ -106,7 +106,17 @@
|
|
|
106
106
|
&self.id
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
public fun migrate(_schema: &mut Schema,
|
|
109
|
+
public fun migrate(_schema: &mut Schema, _ctx: &mut TxContext) {}
|
|
110
|
+
|
|
111
|
+
public(package) fun upgrade(schema: &mut Schema, new_package_id: address, new_version: u32, ctx: &mut TxContext) {
|
|
112
|
+
assert!(schema.dapp__metadata().contains(), 0);
|
|
113
|
+
assert!(schema.dapp__admin().get() == ctx.sender(), 0);
|
|
114
|
+
schema.dapp__package_id().set(new_package_id);
|
|
115
|
+
let current_version = schema.dapp__version()[];
|
|
116
|
+
assert!(current_version < new_version, 0);
|
|
117
|
+
schema.dapp__version().set(new_version);
|
|
118
|
+
schema.migrate(ctx);
|
|
119
|
+
}
|
|
110
120
|
|
|
111
121
|
// ======================================== View Functions ========================================
|
|
112
122
|
|
|
@@ -22,12 +22,6 @@ module counter::counter_dapp_system {
|
|
|
22
22
|
|
|
23
23
|
use dubhe::storage_value::StorageValue;
|
|
24
24
|
|
|
25
|
-
public struct DappKey has drop {}
|
|
26
|
-
|
|
27
|
-
public(package) fun new(): DappKey {
|
|
28
|
-
DappKey { }
|
|
29
|
-
}
|
|
30
|
-
|
|
31
25
|
public entry fun set_metadata(
|
|
32
26
|
schema: &mut Schema,
|
|
33
27
|
name: String,
|
|
@@ -100,7 +94,7 @@ module counter::counter_dapp_system {
|
|
|
100
94
|
vector[]
|
|
101
95
|
)
|
|
102
96
|
);
|
|
103
|
-
let package_id = type_info::current_package_id<
|
|
97
|
+
let package_id = type_info::current_package_id<Schema>();
|
|
104
98
|
schema.dapp__package_id().set(package_id);
|
|
105
99
|
schema.dapp__admin().set(ctx.sender());
|
|
106
100
|
schema.dapp__version().set(1);
|
|
@@ -108,15 +102,6 @@ module counter::counter_dapp_system {
|
|
|
108
102
|
schema.dapp__authorised_schemas().set(vector[]);
|
|
109
103
|
}
|
|
110
104
|
|
|
111
|
-
public(package) fun upgrade<DappKey: drop>(schema: &mut Schema, ctx: &TxContext) {
|
|
112
|
-
assert!(schema.dapp__metadata().contains(), 0);
|
|
113
|
-
assert!(schema.dapp__admin().get() == ctx.sender(), 0);
|
|
114
|
-
let new_package_id = type_info::current_package_id<DappKey>();
|
|
115
|
-
schema.dapp__package_id().set(new_package_id);
|
|
116
|
-
let current_version = schema.dapp__version()[];
|
|
117
|
-
schema.dapp__version().set(current_version + 1);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
105
|
public(package) fun add_schema<S: key + store>(schema: &mut Schema, new_schema: S) {
|
|
121
106
|
let mut schemas = schema.dapp__authorised_schemas()[];
|
|
122
107
|
schemas.push_back(object::id_address<S>(&new_schema));
|
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
"prod:mainnet": "pnpm config:store mainnet && pnpm next"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@0xobelisk/sui-cli": "^1.1.
|
|
40
|
-
"@0xobelisk/sui-client": "^1.1.
|
|
41
|
-
"@0xobelisk/sui-common": "^1.1.
|
|
42
|
-
"@0xobelisk/sui-indexer": "^1.1.
|
|
39
|
+
"@0xobelisk/sui-cli": "^1.1.9",
|
|
40
|
+
"@0xobelisk/sui-client": "^1.1.12",
|
|
41
|
+
"@0xobelisk/sui-common": "^1.1.10",
|
|
42
|
+
"@0xobelisk/sui-indexer": "^1.1.14",
|
|
43
43
|
"@mysten/dapp-kit": "0.14.46",
|
|
44
44
|
"@tanstack/react-query": "^5.17.19",
|
|
45
45
|
"dotenv": "^16.4.5",
|