@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/dubhe.d.ts CHANGED
@@ -127,10 +127,6 @@ export declare class Dubhe {
127
127
  * @returns the effects and events of the transaction, such as object changes, gas cost, event emitted.
128
128
  */
129
129
  inspectTxn(tx: Uint8Array | Transaction | SuiTx, derivePathParams?: DerivePathParams): Promise<DevInspectResults>;
130
- getWorld(worldObjectId: string): Promise<SuiObjectData>;
131
- listSchemaNames(worldId: string): Promise<any>;
132
- getEntity(worldId: string, schemaName: string, entityId?: string): Promise<any[] | undefined>;
133
- containEntity(worldId: string, schemaName: string, entityId?: string): Promise<boolean | undefined>;
134
130
  getOwnedObjects(owner: string, cursor?: string, limit?: number): Promise<SuiObjectData[]>;
135
131
  entity_key_from_object(objectId: string): Promise<string | undefined>;
136
132
  entity_key_from_bytes(bytes: Uint8Array | Buffer | string): Promise<string>;
package/dist/index.js CHANGED
@@ -1023,6 +1023,22 @@ var Dubhe = class {
1023
1023
  "0x1::option::Option<u128>": import_bcs2.bcs.option(import_bcs2.bcs.u128()),
1024
1024
  "0x1::option::Option<u256>": import_bcs2.bcs.option(import_bcs2.bcs.u256()),
1025
1025
  "0x1::option::Option<bool>": import_bcs2.bcs.option(import_bcs2.bcs.bool()),
1026
+ "0x1::option::Option<vector<address>>": import_bcs2.bcs.option(
1027
+ import_bcs2.bcs.vector(
1028
+ import_bcs2.bcs.bytes(32).transform({
1029
+ // To change the input type, you need to provide a type definition for the input
1030
+ input: (val) => (0, import_bcs2.fromHEX)(val),
1031
+ output: (val) => (0, import_bcs2.toHEX)(val)
1032
+ })
1033
+ )
1034
+ ),
1035
+ "0x1::option::Option<vector<u8>>": import_bcs2.bcs.option(import_bcs2.bcs.vector(import_bcs2.bcs.u8())),
1036
+ "0x1::option::Option<vector<u16>>": import_bcs2.bcs.option(import_bcs2.bcs.vector(import_bcs2.bcs.u16())),
1037
+ "0x1::option::Option<vector<u32>>": import_bcs2.bcs.option(import_bcs2.bcs.vector(import_bcs2.bcs.u32())),
1038
+ "0x1::option::Option<vector<u64>>": import_bcs2.bcs.option(import_bcs2.bcs.vector(import_bcs2.bcs.u64())),
1039
+ "0x1::option::Option<vector<u128>>": import_bcs2.bcs.option(import_bcs2.bcs.vector(import_bcs2.bcs.u128())),
1040
+ "0x1::option::Option<vector<u256>>": import_bcs2.bcs.option(import_bcs2.bcs.vector(import_bcs2.bcs.u256())),
1041
+ "0x1::option::Option<vector<bool>>": import_bcs2.bcs.option(import_bcs2.bcs.vector(import_bcs2.bcs.bool())),
1026
1042
  "vector<address>": import_bcs2.bcs.vector(
1027
1043
  import_bcs2.bcs.bytes(32).transform({
1028
1044
  // To change the input type, you need to provide a type definition for the input
@@ -1036,7 +1052,23 @@ var Dubhe = class {
1036
1052
  "vector<u64>": import_bcs2.bcs.vector(import_bcs2.bcs.u64()),
1037
1053
  "vector<u128>": import_bcs2.bcs.vector(import_bcs2.bcs.u128()),
1038
1054
  "vector<u256>": import_bcs2.bcs.vector(import_bcs2.bcs.u256()),
1039
- "vector<bool>": import_bcs2.bcs.vector(import_bcs2.bcs.bool())
1055
+ "vector<bool>": import_bcs2.bcs.vector(import_bcs2.bcs.bool()),
1056
+ "vector<vector<address>>": import_bcs2.bcs.vector(
1057
+ import_bcs2.bcs.vector(
1058
+ import_bcs2.bcs.bytes(32).transform({
1059
+ // To change the input type, you need to provide a type definition for the input
1060
+ input: (val) => (0, import_bcs2.fromHEX)(val),
1061
+ output: (val) => (0, import_bcs2.toHEX)(val)
1062
+ })
1063
+ )
1064
+ ),
1065
+ "vector<vector<u8>>": import_bcs2.bcs.vector(import_bcs2.bcs.vector(import_bcs2.bcs.u8())),
1066
+ "vector<vector<u16>>": import_bcs2.bcs.vector(import_bcs2.bcs.vector(import_bcs2.bcs.u16())),
1067
+ "vector<vector<u32>>": import_bcs2.bcs.vector(import_bcs2.bcs.vector(import_bcs2.bcs.u32())),
1068
+ "vector<vector<u64>>": import_bcs2.bcs.vector(import_bcs2.bcs.vector(import_bcs2.bcs.u64())),
1069
+ "vector<vector<u128>>": import_bcs2.bcs.vector(import_bcs2.bcs.vector(import_bcs2.bcs.u128())),
1070
+ "vector<vector<u256>>": import_bcs2.bcs.vector(import_bcs2.bcs.vector(import_bcs2.bcs.u256())),
1071
+ "vector<vector<bool>>": import_bcs2.bcs.vector(import_bcs2.bcs.vector(import_bcs2.bcs.bool()))
1040
1072
  });
1041
1073
  __privateAdd(this, _exec, async (meta, tx, params, typeArguments, isRaw) => {
1042
1074
  if (isRaw === true) {
@@ -1245,8 +1277,9 @@ var Dubhe = class {
1245
1277
  const moduleName = data.name;
1246
1278
  const objMoudleId = `${packageId}::${moduleName}`;
1247
1279
  Object.entries(data.structs).forEach(([objectName, objectType]) => {
1248
- const objId = `${objMoudleId}::${objectName}`;
1280
+ const objectId = `${objMoudleId}::${objectName}`;
1249
1281
  const bcsmeta = {
1282
+ objectId,
1250
1283
  objectName,
1251
1284
  objectType
1252
1285
  };
@@ -1254,7 +1287,11 @@ var Dubhe = class {
1254
1287
  if (bcsObj.loopFlag === true) {
1255
1288
  loopFlag = bcsObj.loopFlag;
1256
1289
  }
1257
- __privateGet(this, _object)[objId] = bcsObj.bcs;
1290
+ __privateGet(this, _object)[objectId] = bcsObj.bcs;
1291
+ __privateGet(this, _object)[`vector<${objectId}>`] = import_bcs2.bcs.vector(bcsObj.bcs);
1292
+ __privateGet(this, _object)[`0x1::option::Option<${objectId}>`] = import_bcs2.bcs.option(
1293
+ bcsObj.bcs
1294
+ );
1258
1295
  });
1259
1296
  Object.entries(data.exposedFunctions).forEach(
1260
1297
  ([funcName, funcvalue]) => {
@@ -1309,7 +1346,33 @@ var Dubhe = class {
1309
1346
  let baseValue = res[0];
1310
1347
  let baseType = res[1];
1311
1348
  const value = Uint8Array.from(baseValue);
1312
- returnValues.push(this.object[baseType].parse(value));
1349
+ if (!__privateGet(this, _object)[baseType]) {
1350
+ console.log(
1351
+ "\n\x1B[41m\x1B[37m ERROR \x1B[0m \x1B[31mUnsupported Type\x1B[0m"
1352
+ );
1353
+ 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");
1354
+ console.log(`\x1B[95m\u2022\x1B[0m Type: \x1B[33m"${baseType}"\x1B[0m`);
1355
+ console.log("\x1B[95m\n\u2728 Available Types:\x1B[0m");
1356
+ Object.keys(__privateGet(this, _object)).forEach((type) => {
1357
+ console.log(` \x1B[36m\u25C6\x1B[0m ${type}`);
1358
+ });
1359
+ console.log("\n\x1B[34m\u{1F4A1} How to Add Custom Type:\x1B[0m");
1360
+ console.log(
1361
+ ` You can add custom type by extending the #object map in your code:`
1362
+ );
1363
+ console.log(
1364
+ ` \x1B[32mdubhe.object["${baseType}"] = bcs.struct("YourTypeName", {
1365
+ field1: bcs.string(),
1366
+ field2: bcs.u64(),
1367
+ // ... other fields
1368
+ });\x1B[0m`
1369
+ );
1370
+ console.log(
1371
+ "\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"
1372
+ );
1373
+ throw new Error(`Unsupported type: ${baseType}`);
1374
+ }
1375
+ returnValues.push(__privateGet(this, _object)[baseType].parse(value));
1313
1376
  }
1314
1377
  return returnValues;
1315
1378
  } else {
@@ -1511,46 +1574,6 @@ var Dubhe = class {
1511
1574
  sender: this.getAddress(derivePathParams)
1512
1575
  });
1513
1576
  }
1514
- async getWorld(worldObjectId) {
1515
- return this.suiInteractor.getObject(worldObjectId);
1516
- }
1517
- async listSchemaNames(worldId) {
1518
- const worldObject = await this.getObject(worldId);
1519
- const newObjectContent = worldObject.content;
1520
- if (newObjectContent != null) {
1521
- const objectContent = newObjectContent;
1522
- const objectFields = objectContent.fields;
1523
- return objectFields["schema_names"];
1524
- } else {
1525
- return [];
1526
- }
1527
- }
1528
- async getEntity(worldId, schemaName, entityId) {
1529
- const schemaModuleName = `${schemaName}_schema`;
1530
- const tx = new import_transactions3.Transaction();
1531
- const params = [tx.object(worldId)];
1532
- if (entityId !== void 0) {
1533
- params.push(tx.object(entityId));
1534
- }
1535
- const dryResult = await this.query[schemaModuleName].get(
1536
- tx,
1537
- params
1538
- );
1539
- return this.view(dryResult);
1540
- }
1541
- async containEntity(worldId, schemaName, entityId) {
1542
- const schemaModuleName = `${schemaName}_schema`;
1543
- const tx = new import_transactions3.Transaction();
1544
- const params = [tx.object(worldId)];
1545
- if (entityId !== void 0) {
1546
- params.push(tx.object(entityId));
1547
- }
1548
- const dryResult = await this.query[schemaModuleName].contains(
1549
- tx,
1550
- params
1551
- );
1552
- return this.view(dryResult);
1553
- }
1554
1577
  async getOwnedObjects(owner, cursor, limit) {
1555
1578
  const ownedObjects = await this.suiInteractor.getOwnedObjects(
1556
1579
  owner,