@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 +0 -4
- package/dist/index.js +34 -43
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -43
- package/dist/index.mjs.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/package.json +1 -1
- package/src/dubhe.ts +35 -67
- package/src/types/index.ts +1 -0
package/dist/index.mjs
CHANGED
|
@@ -1212,8 +1212,9 @@ var Dubhe = class {
|
|
|
1212
1212
|
const moduleName = data.name;
|
|
1213
1213
|
const objMoudleId = `${packageId}::${moduleName}`;
|
|
1214
1214
|
Object.entries(data.structs).forEach(([objectName, objectType]) => {
|
|
1215
|
-
const
|
|
1215
|
+
const objectId = `${objMoudleId}::${objectName}`;
|
|
1216
1216
|
const bcsmeta = {
|
|
1217
|
+
objectId,
|
|
1217
1218
|
objectName,
|
|
1218
1219
|
objectType
|
|
1219
1220
|
};
|
|
@@ -1221,7 +1222,11 @@ var Dubhe = class {
|
|
|
1221
1222
|
if (bcsObj.loopFlag === true) {
|
|
1222
1223
|
loopFlag = bcsObj.loopFlag;
|
|
1223
1224
|
}
|
|
1224
|
-
__privateGet(this, _object)[
|
|
1225
|
+
__privateGet(this, _object)[objectId] = bcsObj.bcs;
|
|
1226
|
+
__privateGet(this, _object)[`vector<${objectId}>`] = bcs2.vector(bcsObj.bcs);
|
|
1227
|
+
__privateGet(this, _object)[`0x1::option::Option<${objectId}>`] = bcs2.option(
|
|
1228
|
+
bcsObj.bcs
|
|
1229
|
+
);
|
|
1225
1230
|
});
|
|
1226
1231
|
Object.entries(data.exposedFunctions).forEach(
|
|
1227
1232
|
([funcName, funcvalue]) => {
|
|
@@ -1276,7 +1281,33 @@ var Dubhe = class {
|
|
|
1276
1281
|
let baseValue = res[0];
|
|
1277
1282
|
let baseType = res[1];
|
|
1278
1283
|
const value = Uint8Array.from(baseValue);
|
|
1279
|
-
|
|
1284
|
+
if (!__privateGet(this, _object)[baseType]) {
|
|
1285
|
+
console.log(
|
|
1286
|
+
"\n\x1B[41m\x1B[37m ERROR \x1B[0m \x1B[31mUnsupported Type\x1B[0m"
|
|
1287
|
+
);
|
|
1288
|
+
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");
|
|
1289
|
+
console.log(`\x1B[95m\u2022\x1B[0m Type: \x1B[33m"${baseType}"\x1B[0m`);
|
|
1290
|
+
console.log("\x1B[95m\n\u2728 Available Types:\x1B[0m");
|
|
1291
|
+
Object.keys(__privateGet(this, _object)).forEach((type) => {
|
|
1292
|
+
console.log(` \x1B[36m\u25C6\x1B[0m ${type}`);
|
|
1293
|
+
});
|
|
1294
|
+
console.log("\n\x1B[34m\u{1F4A1} How to Add Custom Type:\x1B[0m");
|
|
1295
|
+
console.log(
|
|
1296
|
+
` You can add custom type by extending the #object map in your code:`
|
|
1297
|
+
);
|
|
1298
|
+
console.log(
|
|
1299
|
+
` \x1B[32mdubhe.object["${baseType}"] = bcs.struct("YourTypeName", {
|
|
1300
|
+
field1: bcs.string(),
|
|
1301
|
+
field2: bcs.u64(),
|
|
1302
|
+
// ... other fields
|
|
1303
|
+
});\x1B[0m`
|
|
1304
|
+
);
|
|
1305
|
+
console.log(
|
|
1306
|
+
"\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"
|
|
1307
|
+
);
|
|
1308
|
+
throw new Error(`Unsupported type: ${baseType}`);
|
|
1309
|
+
}
|
|
1310
|
+
returnValues.push(__privateGet(this, _object)[baseType].parse(value));
|
|
1280
1311
|
}
|
|
1281
1312
|
return returnValues;
|
|
1282
1313
|
} else {
|
|
@@ -1478,46 +1509,6 @@ var Dubhe = class {
|
|
|
1478
1509
|
sender: this.getAddress(derivePathParams)
|
|
1479
1510
|
});
|
|
1480
1511
|
}
|
|
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
1512
|
async getOwnedObjects(owner, cursor, limit) {
|
|
1522
1513
|
const ownedObjects = await this.suiInteractor.getOwnedObjects(
|
|
1523
1514
|
owner,
|