@0xobelisk/sui-client 0.5.24 → 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/LICENSE +1 -1
- package/README.md +18 -18
- package/dist/{obelisk.d.ts → dubhe.d.ts} +5 -9
- package/dist/index.d.ts +1 -1
- package/dist/index.js +40 -49
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +39 -48
- package/dist/index.mjs.map +1 -1
- package/dist/types/index.d.ts +5 -4
- package/package.json +4 -4
- package/src/{obelisk.ts → dubhe.ts} +42 -74
- package/src/index.ts +1 -1
- package/src/types/index.ts +5 -4
package/dist/index.mjs
CHANGED
|
@@ -22,7 +22,7 @@ export * from "@mysten/sui/keypairs/secp256k1";
|
|
|
22
22
|
export * from "@mysten/sui/keypairs/secp256r1";
|
|
23
23
|
import { bcs as bcs3, BcsType } from "@mysten/bcs";
|
|
24
24
|
|
|
25
|
-
// src/
|
|
25
|
+
// src/dubhe.ts
|
|
26
26
|
import keccak256 from "keccak256";
|
|
27
27
|
import { getFullnodeUrl } from "@mysten/sui/client";
|
|
28
28
|
import { Transaction as Transaction2 } from "@mysten/sui/transactions";
|
|
@@ -911,7 +911,7 @@ function numberToAddressHex(num) {
|
|
|
911
911
|
return paddedHex;
|
|
912
912
|
}
|
|
913
913
|
|
|
914
|
-
// src/
|
|
914
|
+
// src/dubhe.ts
|
|
915
915
|
import { bcs as bcs2, fromHEX as fromHEX2, toHEX } from "@mysten/bcs";
|
|
916
916
|
function isUndefined(value) {
|
|
917
917
|
return value === void 0;
|
|
@@ -938,9 +938,9 @@ function createTx(meta, fn) {
|
|
|
938
938
|
);
|
|
939
939
|
}
|
|
940
940
|
var _query, _tx, _object, _exec, _read, _bcs;
|
|
941
|
-
var
|
|
941
|
+
var Dubhe = class {
|
|
942
942
|
/**
|
|
943
|
-
* Support the following ways to init the
|
|
943
|
+
* Support the following ways to init the DubheClient:
|
|
944
944
|
* 1. mnemonics
|
|
945
945
|
* 2. secretKey (base64 or hex)
|
|
946
946
|
* If none of them is provided, will generate a random mnemonics with 24 words.
|
|
@@ -1212,8 +1212,9 @@ var Obelisk = 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 Obelisk = 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 Obelisk = 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 Obelisk = 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,
|
|
@@ -1648,8 +1639,8 @@ async function loadMetadata(networkType, packageId, fullnodeUrls) {
|
|
|
1648
1639
|
}
|
|
1649
1640
|
export {
|
|
1650
1641
|
BcsType,
|
|
1642
|
+
Dubhe,
|
|
1651
1643
|
MultiSigClient,
|
|
1652
|
-
Obelisk,
|
|
1653
1644
|
SuiAccountManager,
|
|
1654
1645
|
SuiContractFactory,
|
|
1655
1646
|
SuiTx,
|