@0xobelisk/sui-client 0.5.25 → 0.5.27

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/dist/index.mjs CHANGED
@@ -990,6 +990,22 @@ var Dubhe = class {
990
990
  "0x1::option::Option<u128>": bcs2.option(bcs2.u128()),
991
991
  "0x1::option::Option<u256>": bcs2.option(bcs2.u256()),
992
992
  "0x1::option::Option<bool>": bcs2.option(bcs2.bool()),
993
+ "0x1::option::Option<vector<address>>": bcs2.option(
994
+ bcs2.vector(
995
+ bcs2.bytes(32).transform({
996
+ // To change the input type, you need to provide a type definition for the input
997
+ input: (val) => fromHEX2(val),
998
+ output: (val) => toHEX(val)
999
+ })
1000
+ )
1001
+ ),
1002
+ "0x1::option::Option<vector<u8>>": bcs2.option(bcs2.vector(bcs2.u8())),
1003
+ "0x1::option::Option<vector<u16>>": bcs2.option(bcs2.vector(bcs2.u16())),
1004
+ "0x1::option::Option<vector<u32>>": bcs2.option(bcs2.vector(bcs2.u32())),
1005
+ "0x1::option::Option<vector<u64>>": bcs2.option(bcs2.vector(bcs2.u64())),
1006
+ "0x1::option::Option<vector<u128>>": bcs2.option(bcs2.vector(bcs2.u128())),
1007
+ "0x1::option::Option<vector<u256>>": bcs2.option(bcs2.vector(bcs2.u256())),
1008
+ "0x1::option::Option<vector<bool>>": bcs2.option(bcs2.vector(bcs2.bool())),
993
1009
  "vector<address>": bcs2.vector(
994
1010
  bcs2.bytes(32).transform({
995
1011
  // To change the input type, you need to provide a type definition for the input
@@ -1003,7 +1019,23 @@ var Dubhe = class {
1003
1019
  "vector<u64>": bcs2.vector(bcs2.u64()),
1004
1020
  "vector<u128>": bcs2.vector(bcs2.u128()),
1005
1021
  "vector<u256>": bcs2.vector(bcs2.u256()),
1006
- "vector<bool>": bcs2.vector(bcs2.bool())
1022
+ "vector<bool>": bcs2.vector(bcs2.bool()),
1023
+ "vector<vector<address>>": bcs2.vector(
1024
+ bcs2.vector(
1025
+ bcs2.bytes(32).transform({
1026
+ // To change the input type, you need to provide a type definition for the input
1027
+ input: (val) => fromHEX2(val),
1028
+ output: (val) => toHEX(val)
1029
+ })
1030
+ )
1031
+ ),
1032
+ "vector<vector<u8>>": bcs2.vector(bcs2.vector(bcs2.u8())),
1033
+ "vector<vector<u16>>": bcs2.vector(bcs2.vector(bcs2.u16())),
1034
+ "vector<vector<u32>>": bcs2.vector(bcs2.vector(bcs2.u32())),
1035
+ "vector<vector<u64>>": bcs2.vector(bcs2.vector(bcs2.u64())),
1036
+ "vector<vector<u128>>": bcs2.vector(bcs2.vector(bcs2.u128())),
1037
+ "vector<vector<u256>>": bcs2.vector(bcs2.vector(bcs2.u256())),
1038
+ "vector<vector<bool>>": bcs2.vector(bcs2.vector(bcs2.bool()))
1007
1039
  });
1008
1040
  __privateAdd(this, _exec, async (meta, tx, params, typeArguments, isRaw) => {
1009
1041
  if (isRaw === true) {
@@ -1212,8 +1244,9 @@ var Dubhe = class {
1212
1244
  const moduleName = data.name;
1213
1245
  const objMoudleId = `${packageId}::${moduleName}`;
1214
1246
  Object.entries(data.structs).forEach(([objectName, objectType]) => {
1215
- const objId = `${objMoudleId}::${objectName}`;
1247
+ const objectId = `${objMoudleId}::${objectName}`;
1216
1248
  const bcsmeta = {
1249
+ objectId,
1217
1250
  objectName,
1218
1251
  objectType
1219
1252
  };
@@ -1221,7 +1254,11 @@ var Dubhe = class {
1221
1254
  if (bcsObj.loopFlag === true) {
1222
1255
  loopFlag = bcsObj.loopFlag;
1223
1256
  }
1224
- __privateGet(this, _object)[objId] = bcsObj.bcs;
1257
+ __privateGet(this, _object)[objectId] = bcsObj.bcs;
1258
+ __privateGet(this, _object)[`vector<${objectId}>`] = bcs2.vector(bcsObj.bcs);
1259
+ __privateGet(this, _object)[`0x1::option::Option<${objectId}>`] = bcs2.option(
1260
+ bcsObj.bcs
1261
+ );
1225
1262
  });
1226
1263
  Object.entries(data.exposedFunctions).forEach(
1227
1264
  ([funcName, funcvalue]) => {
@@ -1276,7 +1313,33 @@ var Dubhe = class {
1276
1313
  let baseValue = res[0];
1277
1314
  let baseType = res[1];
1278
1315
  const value = Uint8Array.from(baseValue);
1279
- returnValues.push(this.object[baseType].parse(value));
1316
+ if (!__privateGet(this, _object)[baseType]) {
1317
+ console.log(
1318
+ "\n\x1B[41m\x1B[37m ERROR \x1B[0m \x1B[31mUnsupported Type\x1B[0m"
1319
+ );
1320
+ 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");
1321
+ console.log(`\x1B[95m\u2022\x1B[0m Type: \x1B[33m"${baseType}"\x1B[0m`);
1322
+ console.log("\x1B[95m\n\u2728 Available Types:\x1B[0m");
1323
+ Object.keys(__privateGet(this, _object)).forEach((type) => {
1324
+ console.log(` \x1B[36m\u25C6\x1B[0m ${type}`);
1325
+ });
1326
+ console.log("\n\x1B[34m\u{1F4A1} How to Add Custom Type:\x1B[0m");
1327
+ console.log(
1328
+ ` You can add custom type by extending the #object map in your code:`
1329
+ );
1330
+ console.log(
1331
+ ` \x1B[32mdubhe.object["${baseType}"] = bcs.struct("YourTypeName", {
1332
+ field1: bcs.string(),
1333
+ field2: bcs.u64(),
1334
+ // ... other fields
1335
+ });\x1B[0m`
1336
+ );
1337
+ console.log(
1338
+ "\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"
1339
+ );
1340
+ throw new Error(`Unsupported type: ${baseType}`);
1341
+ }
1342
+ returnValues.push(__privateGet(this, _object)[baseType].parse(value));
1280
1343
  }
1281
1344
  return returnValues;
1282
1345
  } else {
@@ -1478,46 +1541,6 @@ var Dubhe = class {
1478
1541
  sender: this.getAddress(derivePathParams)
1479
1542
  });
1480
1543
  }
1481
- async getWorld(worldObjectId) {
1482
- return this.suiInteractor.getObject(worldObjectId);
1483
- }
1484
- async listSchemaNames(worldId) {
1485
- const worldObject = await this.getObject(worldId);
1486
- const newObjectContent = worldObject.content;
1487
- if (newObjectContent != null) {
1488
- const objectContent = newObjectContent;
1489
- const objectFields = objectContent.fields;
1490
- return objectFields["schema_names"];
1491
- } else {
1492
- return [];
1493
- }
1494
- }
1495
- async getEntity(worldId, schemaName, entityId) {
1496
- const schemaModuleName = `${schemaName}_schema`;
1497
- const tx = new Transaction2();
1498
- const params = [tx.object(worldId)];
1499
- if (entityId !== void 0) {
1500
- params.push(tx.object(entityId));
1501
- }
1502
- const dryResult = await this.query[schemaModuleName].get(
1503
- tx,
1504
- params
1505
- );
1506
- return this.view(dryResult);
1507
- }
1508
- async containEntity(worldId, schemaName, entityId) {
1509
- const schemaModuleName = `${schemaName}_schema`;
1510
- const tx = new Transaction2();
1511
- const params = [tx.object(worldId)];
1512
- if (entityId !== void 0) {
1513
- params.push(tx.object(entityId));
1514
- }
1515
- const dryResult = await this.query[schemaModuleName].contains(
1516
- tx,
1517
- params
1518
- );
1519
- return this.view(dryResult);
1520
- }
1521
1544
  async getOwnedObjects(owner, cursor, limit) {
1522
1545
  const ownedObjects = await this.suiInteractor.getOwnedObjects(
1523
1546
  owner,