@0xobelisk/sui-client 0.5.30 → 0.5.31
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.js +159 -133
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +56 -30
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/dubhe.ts +55 -29
package/dist/index.mjs
CHANGED
|
@@ -20,12 +20,13 @@ export * from "@mysten/sui/bcs";
|
|
|
20
20
|
export * from "@mysten/sui/keypairs/ed25519";
|
|
21
21
|
export * from "@mysten/sui/keypairs/secp256k1";
|
|
22
22
|
export * from "@mysten/sui/keypairs/secp256r1";
|
|
23
|
-
import { bcs as bcs3, BcsType } from "@mysten/bcs";
|
|
23
|
+
import { bcs as bcs3, BcsType as BcsType2 } from "@mysten/bcs";
|
|
24
24
|
|
|
25
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";
|
|
29
|
+
import { fromHex, toHex } from "@mysten/bcs";
|
|
29
30
|
|
|
30
31
|
// src/libs/suiAccountManager/index.ts
|
|
31
32
|
import { Ed25519Keypair as Ed25519Keypair2 } from "@mysten/sui/keypairs/ed25519";
|
|
@@ -1029,8 +1030,8 @@ var Dubhe = class {
|
|
|
1029
1030
|
bcs2.vector(
|
|
1030
1031
|
bcs2.bytes(32).transform({
|
|
1031
1032
|
// To change the input type, you need to provide a type definition for the input
|
|
1032
|
-
input: (val) =>
|
|
1033
|
-
output: (val) =>
|
|
1033
|
+
input: (val) => fromHex(val),
|
|
1034
|
+
output: (val) => toHex(val)
|
|
1034
1035
|
})
|
|
1035
1036
|
)
|
|
1036
1037
|
),
|
|
@@ -1044,8 +1045,8 @@ var Dubhe = class {
|
|
|
1044
1045
|
"vector<address>": bcs2.vector(
|
|
1045
1046
|
bcs2.bytes(32).transform({
|
|
1046
1047
|
// To change the input type, you need to provide a type definition for the input
|
|
1047
|
-
input: (val) =>
|
|
1048
|
-
output: (val) =>
|
|
1048
|
+
input: (val) => fromHex(val),
|
|
1049
|
+
output: (val) => toHex(val)
|
|
1049
1050
|
})
|
|
1050
1051
|
),
|
|
1051
1052
|
"vector<u8>": bcs2.vector(bcs2.u8()),
|
|
@@ -1059,8 +1060,8 @@ var Dubhe = class {
|
|
|
1059
1060
|
bcs2.vector(
|
|
1060
1061
|
bcs2.bytes(32).transform({
|
|
1061
1062
|
// To change the input type, you need to provide a type definition for the input
|
|
1062
|
-
input: (val) =>
|
|
1063
|
-
output: (val) =>
|
|
1063
|
+
input: (val) => fromHex(val),
|
|
1064
|
+
output: (val) => toHex(val)
|
|
1064
1065
|
})
|
|
1065
1066
|
)
|
|
1066
1067
|
),
|
|
@@ -1070,7 +1071,19 @@ var Dubhe = class {
|
|
|
1070
1071
|
"vector<vector<u64>>": bcs2.vector(bcs2.vector(bcs2.u64())),
|
|
1071
1072
|
"vector<vector<u128>>": bcs2.vector(bcs2.vector(bcs2.u128())),
|
|
1072
1073
|
"vector<vector<u256>>": bcs2.vector(bcs2.vector(bcs2.u256())),
|
|
1073
|
-
"vector<vector<bool>>": bcs2.vector(bcs2.vector(bcs2.bool()))
|
|
1074
|
+
"vector<vector<bool>>": bcs2.vector(bcs2.vector(bcs2.bool())),
|
|
1075
|
+
"0x2::coin::Coin<T>": bcs2.struct("Coin", {
|
|
1076
|
+
id: bcs2.fixedArray(32, bcs2.u8()).transform({
|
|
1077
|
+
input: (id) => fromHex(id),
|
|
1078
|
+
output: (id) => toHex(Uint8Array.from(id))
|
|
1079
|
+
}),
|
|
1080
|
+
balance: bcs2.struct("Balance", {
|
|
1081
|
+
value: bcs2.u64()
|
|
1082
|
+
})
|
|
1083
|
+
}),
|
|
1084
|
+
"0x2::balance::Balance<T>": bcs2.struct("Balance", {
|
|
1085
|
+
value: bcs2.u64()
|
|
1086
|
+
})
|
|
1074
1087
|
});
|
|
1075
1088
|
__privateAdd(this, _exec, async (meta, tx, params, typeArguments, isRaw) => {
|
|
1076
1089
|
if (isRaw === true) {
|
|
@@ -1348,33 +1361,46 @@ var Dubhe = class {
|
|
|
1348
1361
|
let baseValue = res[0];
|
|
1349
1362
|
let baseType = res[1];
|
|
1350
1363
|
const value = Uint8Array.from(baseValue);
|
|
1351
|
-
if (
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1364
|
+
if (__privateGet(this, _object)[baseType]) {
|
|
1365
|
+
returnValues.push(__privateGet(this, _object)[baseType].parse(value));
|
|
1366
|
+
continue;
|
|
1367
|
+
}
|
|
1368
|
+
const genericMatch = baseType.match(/^([^<]+)<(.+)>$/);
|
|
1369
|
+
if (genericMatch) {
|
|
1370
|
+
const [_, genericBase, _genericParam] = genericMatch;
|
|
1371
|
+
const genericKey = `${genericBase}<T>`;
|
|
1372
|
+
if (__privateGet(this, _object)[genericKey]) {
|
|
1373
|
+
returnValues.push(__privateGet(this, _object)[genericKey].parse(value));
|
|
1374
|
+
continue;
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
console.log(
|
|
1378
|
+
"\n\x1B[41m\x1B[37m ERROR \x1B[0m \x1B[31mUnsupported Type\x1B[0m"
|
|
1379
|
+
);
|
|
1380
|
+
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");
|
|
1381
|
+
console.log(`\x1B[95m\u2022\x1B[0m Type: \x1B[33m"${baseType}"\x1B[0m`);
|
|
1382
|
+
if (genericMatch) {
|
|
1362
1383
|
console.log(
|
|
1363
|
-
|
|
1384
|
+
`\x1B[95m\u2022\x1B[0m Generic Base Type: \x1B[33m"${genericMatch[1]}<T>"\x1B[0m`
|
|
1364
1385
|
);
|
|
1365
|
-
|
|
1366
|
-
|
|
1386
|
+
}
|
|
1387
|
+
console.log("\x1B[95m\n\u2728 Available Types:\x1B[0m");
|
|
1388
|
+
Object.keys(__privateGet(this, _object)).forEach((type) => {
|
|
1389
|
+
console.log(` \x1B[36m\u25C6\x1B[0m ${type}`);
|
|
1390
|
+
});
|
|
1391
|
+
console.log("\n\x1B[34m\u{1F4A1} How to Add Custom Type:\x1B[0m");
|
|
1392
|
+
console.log(
|
|
1393
|
+
` You can add custom type by extending the #object map in your code:`
|
|
1394
|
+
);
|
|
1395
|
+
console.log(
|
|
1396
|
+
` \x1B[32mdubhe.object["${baseType}"] = bcs.struct("YourTypeName", {
|
|
1367
1397
|
field1: bcs.string(),
|
|
1368
1398
|
field2: bcs.u64(),
|
|
1369
1399
|
// ... other fields
|
|
1370
1400
|
});\x1B[0m`
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
);
|
|
1375
|
-
throw new Error(`Unsupported type: ${baseType}`);
|
|
1376
|
-
}
|
|
1377
|
-
returnValues.push(__privateGet(this, _object)[baseType].parse(value));
|
|
1401
|
+
);
|
|
1402
|
+
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\n");
|
|
1403
|
+
throw new Error(`Unsupported type: ${baseType}`);
|
|
1378
1404
|
}
|
|
1379
1405
|
return returnValues;
|
|
1380
1406
|
} else {
|
|
@@ -1705,7 +1731,7 @@ async function loadMetadata(networkType, packageId, fullnodeUrls) {
|
|
|
1705
1731
|
}
|
|
1706
1732
|
}
|
|
1707
1733
|
export {
|
|
1708
|
-
BcsType,
|
|
1734
|
+
BcsType2 as BcsType,
|
|
1709
1735
|
Dubhe,
|
|
1710
1736
|
MultiSigClient,
|
|
1711
1737
|
SuiAccountManager,
|