@0xobelisk/sui-client 0.5.26 → 0.5.28
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/README.md +89 -196
- package/dist/dubhe.d.ts +1 -1
- package/dist/errors/index.d.ts +7 -0
- package/dist/index.js +59 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +59 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/dubhe.ts +34 -1
- package/src/errors/index.ts +31 -0
package/dist/index.mjs
CHANGED
|
@@ -913,6 +913,31 @@ function numberToAddressHex(num) {
|
|
|
913
913
|
|
|
914
914
|
// src/dubhe.ts
|
|
915
915
|
import { bcs as bcs2, fromHEX as fromHEX2, toHEX } from "@mysten/bcs";
|
|
916
|
+
|
|
917
|
+
// src/errors/index.ts
|
|
918
|
+
var ContractDataParsingError = class extends Error {
|
|
919
|
+
constructor(dryResult) {
|
|
920
|
+
const error = dryResult?.effects?.status?.error || "";
|
|
921
|
+
const functionMatch = error ? error.match(/function_name: Some\("([^"]+)"\)/) : null;
|
|
922
|
+
const moduleMatch = error ? error.match(/address: ([a-fA-F0-9]+)/) : null;
|
|
923
|
+
const functionName = functionMatch ? functionMatch[1] : "unknown";
|
|
924
|
+
const moduleAddress = moduleMatch ? "0x" + moduleMatch[1] : "unknown";
|
|
925
|
+
const errorMessage = dryResult.error ? dryResult.error : "UNKNOWN_ERROR";
|
|
926
|
+
const message = [
|
|
927
|
+
`
|
|
928
|
+
- Function: ${functionName}`,
|
|
929
|
+
`- Module Address: ${moduleAddress}`,
|
|
930
|
+
`- Error Message: ${errorMessage}`
|
|
931
|
+
].join("\n");
|
|
932
|
+
super(message);
|
|
933
|
+
this.errorType = "ContractDataParsingError";
|
|
934
|
+
this.functionName = functionName;
|
|
935
|
+
this.moduleAddress = moduleAddress;
|
|
936
|
+
this.errorMessage = errorMessage;
|
|
937
|
+
}
|
|
938
|
+
};
|
|
939
|
+
|
|
940
|
+
// src/dubhe.ts
|
|
916
941
|
function isUndefined(value) {
|
|
917
942
|
return value === void 0;
|
|
918
943
|
}
|
|
@@ -990,6 +1015,22 @@ var Dubhe = class {
|
|
|
990
1015
|
"0x1::option::Option<u128>": bcs2.option(bcs2.u128()),
|
|
991
1016
|
"0x1::option::Option<u256>": bcs2.option(bcs2.u256()),
|
|
992
1017
|
"0x1::option::Option<bool>": bcs2.option(bcs2.bool()),
|
|
1018
|
+
"0x1::option::Option<vector<address>>": bcs2.option(
|
|
1019
|
+
bcs2.vector(
|
|
1020
|
+
bcs2.bytes(32).transform({
|
|
1021
|
+
// To change the input type, you need to provide a type definition for the input
|
|
1022
|
+
input: (val) => fromHEX2(val),
|
|
1023
|
+
output: (val) => toHEX(val)
|
|
1024
|
+
})
|
|
1025
|
+
)
|
|
1026
|
+
),
|
|
1027
|
+
"0x1::option::Option<vector<u8>>": bcs2.option(bcs2.vector(bcs2.u8())),
|
|
1028
|
+
"0x1::option::Option<vector<u16>>": bcs2.option(bcs2.vector(bcs2.u16())),
|
|
1029
|
+
"0x1::option::Option<vector<u32>>": bcs2.option(bcs2.vector(bcs2.u32())),
|
|
1030
|
+
"0x1::option::Option<vector<u64>>": bcs2.option(bcs2.vector(bcs2.u64())),
|
|
1031
|
+
"0x1::option::Option<vector<u128>>": bcs2.option(bcs2.vector(bcs2.u128())),
|
|
1032
|
+
"0x1::option::Option<vector<u256>>": bcs2.option(bcs2.vector(bcs2.u256())),
|
|
1033
|
+
"0x1::option::Option<vector<bool>>": bcs2.option(bcs2.vector(bcs2.bool())),
|
|
993
1034
|
"vector<address>": bcs2.vector(
|
|
994
1035
|
bcs2.bytes(32).transform({
|
|
995
1036
|
// To change the input type, you need to provide a type definition for the input
|
|
@@ -1003,7 +1044,23 @@ var Dubhe = class {
|
|
|
1003
1044
|
"vector<u64>": bcs2.vector(bcs2.u64()),
|
|
1004
1045
|
"vector<u128>": bcs2.vector(bcs2.u128()),
|
|
1005
1046
|
"vector<u256>": bcs2.vector(bcs2.u256()),
|
|
1006
|
-
"vector<bool>": bcs2.vector(bcs2.bool())
|
|
1047
|
+
"vector<bool>": bcs2.vector(bcs2.bool()),
|
|
1048
|
+
"vector<vector<address>>": bcs2.vector(
|
|
1049
|
+
bcs2.vector(
|
|
1050
|
+
bcs2.bytes(32).transform({
|
|
1051
|
+
// To change the input type, you need to provide a type definition for the input
|
|
1052
|
+
input: (val) => fromHEX2(val),
|
|
1053
|
+
output: (val) => toHEX(val)
|
|
1054
|
+
})
|
|
1055
|
+
)
|
|
1056
|
+
),
|
|
1057
|
+
"vector<vector<u8>>": bcs2.vector(bcs2.vector(bcs2.u8())),
|
|
1058
|
+
"vector<vector<u16>>": bcs2.vector(bcs2.vector(bcs2.u16())),
|
|
1059
|
+
"vector<vector<u32>>": bcs2.vector(bcs2.vector(bcs2.u32())),
|
|
1060
|
+
"vector<vector<u64>>": bcs2.vector(bcs2.vector(bcs2.u64())),
|
|
1061
|
+
"vector<vector<u128>>": bcs2.vector(bcs2.vector(bcs2.u128())),
|
|
1062
|
+
"vector<vector<u256>>": bcs2.vector(bcs2.vector(bcs2.u256())),
|
|
1063
|
+
"vector<vector<bool>>": bcs2.vector(bcs2.vector(bcs2.bool()))
|
|
1007
1064
|
});
|
|
1008
1065
|
__privateAdd(this, _exec, async (meta, tx, params, typeArguments, isRaw) => {
|
|
1009
1066
|
if (isRaw === true) {
|
|
@@ -1311,7 +1368,7 @@ var Dubhe = class {
|
|
|
1311
1368
|
}
|
|
1312
1369
|
return returnValues;
|
|
1313
1370
|
} else {
|
|
1314
|
-
|
|
1371
|
+
throw new ContractDataParsingError(dryResult);
|
|
1315
1372
|
}
|
|
1316
1373
|
}
|
|
1317
1374
|
/**
|