create-dubhe 0.0.2 → 0.0.4

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-dubhe",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "team@obelisk.build",
@@ -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.22",
39
- "@0xobelisk/sui-client": "^0.5.25",
40
- "@0xobelisk/sui-common": "^0.5.18",
38
+ "@0xobelisk/sui-cli": "^0.5.23",
39
+ "@0xobelisk/sui-client": "^0.5.27",
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.counter_system.get(tx, [
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]);
@@ -4631,6 +4631,18 @@ var Dubhe = class {
4631
4631
  "0x1::option::Option<u128>": _bcs3.bcs.option(_bcs3.bcs.u128()),
4632
4632
  "0x1::option::Option<u256>": _bcs3.bcs.option(_bcs3.bcs.u256()),
4633
4633
  "0x1::option::Option<bool>": _bcs3.bcs.option(_bcs3.bcs.bool()),
4634
+ "0x1::option::Option<vector<address>>": _bcs3.bcs.option(_bcs3.bcs.vector(_bcs3.bcs.bytes(32).transform({
4635
+ // To change the input type, you need to provide a type definition for the input
4636
+ input: val => (0, _bcs3.fromHEX)(val),
4637
+ output: val => (0, _bcs3.toHEX)(val)
4638
+ }))),
4639
+ "0x1::option::Option<vector<u8>>": _bcs3.bcs.option(_bcs3.bcs.vector(_bcs3.bcs.u8())),
4640
+ "0x1::option::Option<vector<u16>>": _bcs3.bcs.option(_bcs3.bcs.vector(_bcs3.bcs.u16())),
4641
+ "0x1::option::Option<vector<u32>>": _bcs3.bcs.option(_bcs3.bcs.vector(_bcs3.bcs.u32())),
4642
+ "0x1::option::Option<vector<u64>>": _bcs3.bcs.option(_bcs3.bcs.vector(_bcs3.bcs.u64())),
4643
+ "0x1::option::Option<vector<u128>>": _bcs3.bcs.option(_bcs3.bcs.vector(_bcs3.bcs.u128())),
4644
+ "0x1::option::Option<vector<u256>>": _bcs3.bcs.option(_bcs3.bcs.vector(_bcs3.bcs.u256())),
4645
+ "0x1::option::Option<vector<bool>>": _bcs3.bcs.option(_bcs3.bcs.vector(_bcs3.bcs.bool())),
4634
4646
  "vector<address>": _bcs3.bcs.vector(_bcs3.bcs.bytes(32).transform({
4635
4647
  // To change the input type, you need to provide a type definition for the input
4636
4648
  input: val => (0, _bcs3.fromHEX)(val),
@@ -4642,7 +4654,19 @@ var Dubhe = class {
4642
4654
  "vector<u64>": _bcs3.bcs.vector(_bcs3.bcs.u64()),
4643
4655
  "vector<u128>": _bcs3.bcs.vector(_bcs3.bcs.u128()),
4644
4656
  "vector<u256>": _bcs3.bcs.vector(_bcs3.bcs.u256()),
4645
- "vector<bool>": _bcs3.bcs.vector(_bcs3.bcs.bool())
4657
+ "vector<bool>": _bcs3.bcs.vector(_bcs3.bcs.bool()),
4658
+ "vector<vector<address>>": _bcs3.bcs.vector(_bcs3.bcs.vector(_bcs3.bcs.bytes(32).transform({
4659
+ // To change the input type, you need to provide a type definition for the input
4660
+ input: val => (0, _bcs3.fromHEX)(val),
4661
+ output: val => (0, _bcs3.toHEX)(val)
4662
+ }))),
4663
+ "vector<vector<u8>>": _bcs3.bcs.vector(_bcs3.bcs.vector(_bcs3.bcs.u8())),
4664
+ "vector<vector<u16>>": _bcs3.bcs.vector(_bcs3.bcs.vector(_bcs3.bcs.u16())),
4665
+ "vector<vector<u32>>": _bcs3.bcs.vector(_bcs3.bcs.vector(_bcs3.bcs.u32())),
4666
+ "vector<vector<u64>>": _bcs3.bcs.vector(_bcs3.bcs.vector(_bcs3.bcs.u64())),
4667
+ "vector<vector<u128>>": _bcs3.bcs.vector(_bcs3.bcs.vector(_bcs3.bcs.u128())),
4668
+ "vector<vector<u256>>": _bcs3.bcs.vector(_bcs3.bcs.vector(_bcs3.bcs.u256())),
4669
+ "vector<vector<bool>>": _bcs3.bcs.vector(_bcs3.bcs.vector(_bcs3.bcs.bool()))
4646
4670
  });
4647
4671
  __privateAdd(this, _exec, async (meta, tx, params, typeArguments, isRaw) => {
4648
4672
  if (isRaw === true) {
@@ -4849,8 +4873,9 @@ var Dubhe = class {
4849
4873
  const moduleName = data.name;
4850
4874
  const objMoudleId = `${packageId}::${moduleName}`;
4851
4875
  Object.entries(data.structs).forEach(([objectName, objectType]) => {
4852
- const objId = `${objMoudleId}::${objectName}`;
4876
+ const objectId = `${objMoudleId}::${objectName}`;
4853
4877
  const bcsmeta = {
4878
+ objectId,
4854
4879
  objectName,
4855
4880
  objectType
4856
4881
  };
@@ -4858,7 +4883,9 @@ var Dubhe = class {
4858
4883
  if (bcsObj.loopFlag === true) {
4859
4884
  loopFlag = bcsObj.loopFlag;
4860
4885
  }
4861
- __privateGet(this, _object)[objId] = bcsObj.bcs;
4886
+ __privateGet(this, _object)[objectId] = bcsObj.bcs;
4887
+ __privateGet(this, _object)[`vector<${objectId}>`] = _bcs3.bcs.vector(bcsObj.bcs);
4888
+ __privateGet(this, _object)[`0x1::option::Option<${objectId}>`] = _bcs3.bcs.option(bcsObj.bcs);
4862
4889
  });
4863
4890
  Object.entries(data.exposedFunctions).forEach(([funcName, funcvalue]) => {
4864
4891
  const meta = funcvalue;
@@ -4904,7 +4931,25 @@ var Dubhe = class {
4904
4931
  let baseValue = res[0];
4905
4932
  let baseType = res[1];
4906
4933
  const value = Uint8Array.from(baseValue);
4907
- returnValues.push(this.object[baseType].parse(value));
4934
+ if (!__privateGet(this, _object)[baseType]) {
4935
+ console.log("\n\x1B[41m\x1B[37m ERROR \x1B[0m \x1B[31mUnsupported Type\x1B[0m");
4936
+ 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");
4937
+ console.log(`\x1B[95m\u2022\x1B[0m Type: \x1B[33m"${baseType}"\x1B[0m`);
4938
+ console.log("\x1B[95m\n\u2728 Available Types:\x1B[0m");
4939
+ Object.keys(__privateGet(this, _object)).forEach(type => {
4940
+ console.log(` \x1B[36m\u25C6\x1B[0m ${type}`);
4941
+ });
4942
+ console.log("\n\x1B[34m\u{1F4A1} How to Add Custom Type:\x1B[0m");
4943
+ console.log(` You can add custom type by extending the #object map in your code:`);
4944
+ console.log(` \x1B[32mdubhe.object["${baseType}"] = bcs.struct("YourTypeName", {
4945
+ field1: bcs.string(),
4946
+ field2: bcs.u64(),
4947
+ // ... other fields
4948
+ });\x1B[0m`);
4949
+ 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");
4950
+ throw new Error(`Unsupported type: ${baseType}`);
4951
+ }
4952
+ returnValues.push(__privateGet(this, _object)[baseType].parse(value));
4908
4953
  }
4909
4954
  return returnValues;
4910
4955
  } else {
@@ -5103,40 +5148,6 @@ var Dubhe = class {
5103
5148
  sender: this.getAddress(derivePathParams)
5104
5149
  });
5105
5150
  }
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
5151
  async getOwnedObjects(owner, cursor, limit) {
5141
5152
  const ownedObjects = await this.suiInteractor.getOwnedObjects(owner, cursor, limit);
5142
5153
  const ownedObjectsRes = [];
@@ -15,9 +15,9 @@
15
15
  "generateAccount": "ts-node scripts/generateAccount.ts"
16
16
  },
17
17
  "dependencies": {
18
- "@0xobelisk/sui-common": "^0.5.18",
19
- "@0xobelisk/sui-client": "^0.5.25",
20
- "@0xobelisk/sui-cli": "^0.5.22"
18
+ "@0xobelisk/sui-cli": "^0.5.23",
19
+ "@0xobelisk/sui-client": "^0.5.27",
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.22",
39
- "@0xobelisk/sui-client": "^0.5.25",
40
- "@0xobelisk/sui-common": "^0.5.18",
38
+ "@0xobelisk/sui-cli": "^0.5.23",
39
+ "@0xobelisk/sui-client": "^0.5.27",
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.counter_system.get(tx, [
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]);