@0xobelisk/sui-client 0.5.25 → 0.5.26

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
@@ -1245,8 +1245,9 @@ var Dubhe = class {
1245
1245
  const moduleName = data.name;
1246
1246
  const objMoudleId = `${packageId}::${moduleName}`;
1247
1247
  Object.entries(data.structs).forEach(([objectName, objectType]) => {
1248
- const objId = `${objMoudleId}::${objectName}`;
1248
+ const objectId = `${objMoudleId}::${objectName}`;
1249
1249
  const bcsmeta = {
1250
+ objectId,
1250
1251
  objectName,
1251
1252
  objectType
1252
1253
  };
@@ -1254,7 +1255,11 @@ var Dubhe = class {
1254
1255
  if (bcsObj.loopFlag === true) {
1255
1256
  loopFlag = bcsObj.loopFlag;
1256
1257
  }
1257
- __privateGet(this, _object)[objId] = bcsObj.bcs;
1258
+ __privateGet(this, _object)[objectId] = bcsObj.bcs;
1259
+ __privateGet(this, _object)[`vector<${objectId}>`] = import_bcs2.bcs.vector(bcsObj.bcs);
1260
+ __privateGet(this, _object)[`0x1::option::Option<${objectId}>`] = import_bcs2.bcs.option(
1261
+ bcsObj.bcs
1262
+ );
1258
1263
  });
1259
1264
  Object.entries(data.exposedFunctions).forEach(
1260
1265
  ([funcName, funcvalue]) => {
@@ -1309,7 +1314,33 @@ var Dubhe = class {
1309
1314
  let baseValue = res[0];
1310
1315
  let baseType = res[1];
1311
1316
  const value = Uint8Array.from(baseValue);
1312
- returnValues.push(this.object[baseType].parse(value));
1317
+ if (!__privateGet(this, _object)[baseType]) {
1318
+ console.log(
1319
+ "\n\x1B[41m\x1B[37m ERROR \x1B[0m \x1B[31mUnsupported Type\x1B[0m"
1320
+ );
1321
+ 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");
1322
+ console.log(`\x1B[95m\u2022\x1B[0m Type: \x1B[33m"${baseType}"\x1B[0m`);
1323
+ console.log("\x1B[95m\n\u2728 Available Types:\x1B[0m");
1324
+ Object.keys(__privateGet(this, _object)).forEach((type) => {
1325
+ console.log(` \x1B[36m\u25C6\x1B[0m ${type}`);
1326
+ });
1327
+ console.log("\n\x1B[34m\u{1F4A1} How to Add Custom Type:\x1B[0m");
1328
+ console.log(
1329
+ ` You can add custom type by extending the #object map in your code:`
1330
+ );
1331
+ console.log(
1332
+ ` \x1B[32mdubhe.object["${baseType}"] = bcs.struct("YourTypeName", {
1333
+ field1: bcs.string(),
1334
+ field2: bcs.u64(),
1335
+ // ... other fields
1336
+ });\x1B[0m`
1337
+ );
1338
+ console.log(
1339
+ "\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"
1340
+ );
1341
+ throw new Error(`Unsupported type: ${baseType}`);
1342
+ }
1343
+ returnValues.push(__privateGet(this, _object)[baseType].parse(value));
1313
1344
  }
1314
1345
  return returnValues;
1315
1346
  } else {
@@ -1511,46 +1542,6 @@ var Dubhe = class {
1511
1542
  sender: this.getAddress(derivePathParams)
1512
1543
  });
1513
1544
  }
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
1545
  async getOwnedObjects(owner, cursor, limit) {
1555
1546
  const ownedObjects = await this.suiInteractor.getOwnedObjects(
1556
1547
  owner,