create-dubhe 0.0.2 → 0.0.3
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/schemas/counter.move +8 -0
- package/template/101/sui-template/package.json +3 -3
- package/template/101/sui-template/src/pages/home/index.tsx +1 -1
- package/template/cocos/sui-template/assets/lib/dubhe.js +24 -37
- package/template/cocos/sui-template/package.json +3 -3
- package/template/nextjs/sui-template/contracts/counter/sources/codegen/schemas/counter.move +8 -0
- package/template/nextjs/sui-template/package.json +3 -3
- package/template/nextjs/sui-template/src/pages/home/index.tsx +1 -1
package/package.json
CHANGED
|
@@ -47,4 +47,12 @@
|
|
|
47
47
|
value: storage_value::new(),
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
+
|
|
51
|
+
// ======================================== View Functions ========================================
|
|
52
|
+
|
|
53
|
+
public fun get_value(self: &Counter): Option<u32> {
|
|
54
|
+
self.value.try_get()
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// =========================================================================================================
|
|
50
58
|
}
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
"start": "next start"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@0xobelisk/sui-cli": "^0.5.
|
|
39
|
-
"@0xobelisk/sui-client": "^0.5.
|
|
40
|
-
"@0xobelisk/sui-common": "^0.5.
|
|
38
|
+
"@0xobelisk/sui-cli": "^0.5.23",
|
|
39
|
+
"@0xobelisk/sui-client": "^0.5.26",
|
|
40
|
+
"@0xobelisk/sui-common": "^0.5.19",
|
|
41
41
|
"@mysten/sui": "1.7.0",
|
|
42
42
|
"clsx": "^1.2.1",
|
|
43
43
|
"dotenv": "^16.4.5",
|
|
@@ -20,7 +20,7 @@ const Home = () => {
|
|
|
20
20
|
});
|
|
21
21
|
const tx = new Transaction();
|
|
22
22
|
console.log('counterObjectId:', Counter_Object_Id);
|
|
23
|
-
const query_value = (await dubhe.query.
|
|
23
|
+
const query_value = (await dubhe.query.counter_schema.get_value(tx, [
|
|
24
24
|
tx.object(Counter_Object_Id),
|
|
25
25
|
])) as DevInspectResults;
|
|
26
26
|
console.log(dubhe.view(query_value)[0]);
|
|
@@ -4849,8 +4849,9 @@ var Dubhe = class {
|
|
|
4849
4849
|
const moduleName = data.name;
|
|
4850
4850
|
const objMoudleId = `${packageId}::${moduleName}`;
|
|
4851
4851
|
Object.entries(data.structs).forEach(([objectName, objectType]) => {
|
|
4852
|
-
const
|
|
4852
|
+
const objectId = `${objMoudleId}::${objectName}`;
|
|
4853
4853
|
const bcsmeta = {
|
|
4854
|
+
objectId,
|
|
4854
4855
|
objectName,
|
|
4855
4856
|
objectType
|
|
4856
4857
|
};
|
|
@@ -4858,7 +4859,9 @@ var Dubhe = class {
|
|
|
4858
4859
|
if (bcsObj.loopFlag === true) {
|
|
4859
4860
|
loopFlag = bcsObj.loopFlag;
|
|
4860
4861
|
}
|
|
4861
|
-
__privateGet(this, _object)[
|
|
4862
|
+
__privateGet(this, _object)[objectId] = bcsObj.bcs;
|
|
4863
|
+
__privateGet(this, _object)[`vector<${objectId}>`] = _bcs3.bcs.vector(bcsObj.bcs);
|
|
4864
|
+
__privateGet(this, _object)[`0x1::option::Option<${objectId}>`] = _bcs3.bcs.option(bcsObj.bcs);
|
|
4862
4865
|
});
|
|
4863
4866
|
Object.entries(data.exposedFunctions).forEach(([funcName, funcvalue]) => {
|
|
4864
4867
|
const meta = funcvalue;
|
|
@@ -4904,7 +4907,25 @@ var Dubhe = class {
|
|
|
4904
4907
|
let baseValue = res[0];
|
|
4905
4908
|
let baseType = res[1];
|
|
4906
4909
|
const value = Uint8Array.from(baseValue);
|
|
4907
|
-
|
|
4910
|
+
if (!__privateGet(this, _object)[baseType]) {
|
|
4911
|
+
console.log("\n\x1B[41m\x1B[37m ERROR \x1B[0m \x1B[31mUnsupported Type\x1B[0m");
|
|
4912
|
+
console.log("\x1B[90m\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\x1B[0m");
|
|
4913
|
+
console.log(`\x1B[95m\u2022\x1B[0m Type: \x1B[33m"${baseType}"\x1B[0m`);
|
|
4914
|
+
console.log("\x1B[95m\n\u2728 Available Types:\x1B[0m");
|
|
4915
|
+
Object.keys(__privateGet(this, _object)).forEach(type => {
|
|
4916
|
+
console.log(` \x1B[36m\u25C6\x1B[0m ${type}`);
|
|
4917
|
+
});
|
|
4918
|
+
console.log("\n\x1B[34m\u{1F4A1} How to Add Custom Type:\x1B[0m");
|
|
4919
|
+
console.log(` You can add custom type by extending the #object map in your code:`);
|
|
4920
|
+
console.log(` \x1B[32mdubhe.object["${baseType}"] = bcs.struct("YourTypeName", {
|
|
4921
|
+
field1: bcs.string(),
|
|
4922
|
+
field2: bcs.u64(),
|
|
4923
|
+
// ... other fields
|
|
4924
|
+
});\x1B[0m`);
|
|
4925
|
+
console.log("\x1B[90m\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\x1B[0m\n");
|
|
4926
|
+
throw new Error(`Unsupported type: ${baseType}`);
|
|
4927
|
+
}
|
|
4928
|
+
returnValues.push(__privateGet(this, _object)[baseType].parse(value));
|
|
4908
4929
|
}
|
|
4909
4930
|
return returnValues;
|
|
4910
4931
|
} else {
|
|
@@ -5103,40 +5124,6 @@ var Dubhe = class {
|
|
|
5103
5124
|
sender: this.getAddress(derivePathParams)
|
|
5104
5125
|
});
|
|
5105
5126
|
}
|
|
5106
|
-
async getWorld(worldObjectId) {
|
|
5107
|
-
return this.suiInteractor.getObject(worldObjectId);
|
|
5108
|
-
}
|
|
5109
|
-
async listSchemaNames(worldId) {
|
|
5110
|
-
const worldObject = await this.getObject(worldId);
|
|
5111
|
-
const newObjectContent = worldObject.content;
|
|
5112
|
-
if (newObjectContent != null) {
|
|
5113
|
-
const objectContent = newObjectContent;
|
|
5114
|
-
const objectFields = objectContent.fields;
|
|
5115
|
-
return objectFields["schema_names"];
|
|
5116
|
-
} else {
|
|
5117
|
-
return [];
|
|
5118
|
-
}
|
|
5119
|
-
}
|
|
5120
|
-
async getEntity(worldId, schemaName, entityId) {
|
|
5121
|
-
const schemaModuleName = `${schemaName}_schema`;
|
|
5122
|
-
const tx = new _transactions.Transaction();
|
|
5123
|
-
const params = [tx.object(worldId)];
|
|
5124
|
-
if (entityId !== void 0) {
|
|
5125
|
-
params.push(tx.object(entityId));
|
|
5126
|
-
}
|
|
5127
|
-
const dryResult = await this.query[schemaModuleName].get(tx, params);
|
|
5128
|
-
return this.view(dryResult);
|
|
5129
|
-
}
|
|
5130
|
-
async containEntity(worldId, schemaName, entityId) {
|
|
5131
|
-
const schemaModuleName = `${schemaName}_schema`;
|
|
5132
|
-
const tx = new _transactions.Transaction();
|
|
5133
|
-
const params = [tx.object(worldId)];
|
|
5134
|
-
if (entityId !== void 0) {
|
|
5135
|
-
params.push(tx.object(entityId));
|
|
5136
|
-
}
|
|
5137
|
-
const dryResult = await this.query[schemaModuleName].contains(tx, params);
|
|
5138
|
-
return this.view(dryResult);
|
|
5139
|
-
}
|
|
5140
5127
|
async getOwnedObjects(owner, cursor, limit) {
|
|
5141
5128
|
const ownedObjects = await this.suiInteractor.getOwnedObjects(owner, cursor, limit);
|
|
5142
5129
|
const ownedObjectsRes = [];
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
"generateAccount": "ts-node scripts/generateAccount.ts"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@0xobelisk/sui-
|
|
19
|
-
"@0xobelisk/sui-client": "^0.5.
|
|
20
|
-
"@0xobelisk/sui-
|
|
18
|
+
"@0xobelisk/sui-cli": "^0.5.23",
|
|
19
|
+
"@0xobelisk/sui-client": "^0.5.26",
|
|
20
|
+
"@0xobelisk/sui-common": "^0.5.19"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@types/node": "18.16.16",
|
|
@@ -47,4 +47,12 @@
|
|
|
47
47
|
value: storage_value::new(),
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
+
|
|
51
|
+
// ======================================== View Functions ========================================
|
|
52
|
+
|
|
53
|
+
public fun get_value(self: &Counter): Option<u32> {
|
|
54
|
+
self.value.try_get()
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// =========================================================================================================
|
|
50
58
|
}
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
"start": "next start"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@0xobelisk/sui-cli": "^0.5.
|
|
39
|
-
"@0xobelisk/sui-client": "^0.5.
|
|
40
|
-
"@0xobelisk/sui-common": "^0.5.
|
|
38
|
+
"@0xobelisk/sui-cli": "^0.5.23",
|
|
39
|
+
"@0xobelisk/sui-client": "^0.5.26",
|
|
40
|
+
"@0xobelisk/sui-common": "^0.5.19",
|
|
41
41
|
"@mysten/dapp-kit": "0.14.9",
|
|
42
42
|
"@mysten/sui": "1.7.0",
|
|
43
43
|
"dotenv": "^16.4.5",
|
|
@@ -33,7 +33,7 @@ const Home: React.FC = () => {
|
|
|
33
33
|
});
|
|
34
34
|
const tx = new Transaction();
|
|
35
35
|
console.log('Counter Object ID:', Counter_Object_Id);
|
|
36
|
-
const queryValue = (await dubhe.query.
|
|
36
|
+
const queryValue = (await dubhe.query.counter_schema.get_value(tx, [
|
|
37
37
|
tx.object(Counter_Object_Id),
|
|
38
38
|
])) as DevInspectResults;
|
|
39
39
|
console.log('Counter value:', dubhe.view(queryValue)[0]);
|