@0xobelisk/sui-client 0.5.29 → 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/dist/types/index.d.ts +0 -2
- package/package.json +1 -1
- package/src/dubhe.ts +55 -29
- package/src/types/index.ts +0 -2
package/dist/index.js
CHANGED
|
@@ -44,13 +44,13 @@ var __privateAdd = (obj, member, value) => {
|
|
|
44
44
|
// src/index.ts
|
|
45
45
|
var src_exports = {};
|
|
46
46
|
__export(src_exports, {
|
|
47
|
-
BcsType: () =>
|
|
47
|
+
BcsType: () => import_bcs4.BcsType,
|
|
48
48
|
Dubhe: () => Dubhe,
|
|
49
49
|
MultiSigClient: () => MultiSigClient,
|
|
50
50
|
SuiAccountManager: () => SuiAccountManager,
|
|
51
51
|
SuiContractFactory: () => SuiContractFactory,
|
|
52
52
|
SuiTx: () => SuiTx,
|
|
53
|
-
bcs: () =>
|
|
53
|
+
bcs: () => import_bcs4.bcs,
|
|
54
54
|
loadMetadata: () => loadMetadata
|
|
55
55
|
});
|
|
56
56
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -61,12 +61,13 @@ __reExport(src_exports, require("@mysten/sui/bcs"), module.exports);
|
|
|
61
61
|
__reExport(src_exports, require("@mysten/sui/keypairs/ed25519"), module.exports);
|
|
62
62
|
__reExport(src_exports, require("@mysten/sui/keypairs/secp256k1"), module.exports);
|
|
63
63
|
__reExport(src_exports, require("@mysten/sui/keypairs/secp256r1"), module.exports);
|
|
64
|
-
var
|
|
64
|
+
var import_bcs4 = require("@mysten/bcs");
|
|
65
65
|
|
|
66
66
|
// src/dubhe.ts
|
|
67
67
|
var import_keccak256 = __toESM(require("keccak256"));
|
|
68
68
|
var import_client2 = require("@mysten/sui/client");
|
|
69
69
|
var import_transactions3 = require("@mysten/sui/transactions");
|
|
70
|
+
var import_bcs2 = require("@mysten/bcs");
|
|
70
71
|
|
|
71
72
|
// src/libs/suiAccountManager/index.ts
|
|
72
73
|
var import_ed255192 = require("@mysten/sui/keypairs/ed25519");
|
|
@@ -945,7 +946,7 @@ function numberToAddressHex(num) {
|
|
|
945
946
|
}
|
|
946
947
|
|
|
947
948
|
// src/dubhe.ts
|
|
948
|
-
var
|
|
949
|
+
var import_bcs3 = require("@mysten/bcs");
|
|
949
950
|
|
|
950
951
|
// src/errors/index.ts
|
|
951
952
|
var ContractDataParsingError = class extends Error {
|
|
@@ -1030,80 +1031,92 @@ var Dubhe = class {
|
|
|
1030
1031
|
__privateAdd(this, _query, {});
|
|
1031
1032
|
__privateAdd(this, _tx, {});
|
|
1032
1033
|
__privateAdd(this, _object, {
|
|
1033
|
-
address:
|
|
1034
|
+
address: import_bcs3.bcs.bytes(32).transform({
|
|
1034
1035
|
// To change the input type, you need to provide a type definition for the input
|
|
1035
|
-
input: (val) => (0,
|
|
1036
|
-
output: (val) => (0,
|
|
1036
|
+
input: (val) => (0, import_bcs3.fromHEX)(val),
|
|
1037
|
+
output: (val) => (0, import_bcs3.toHEX)(val)
|
|
1037
1038
|
}),
|
|
1038
|
-
u8:
|
|
1039
|
-
u16:
|
|
1040
|
-
u32:
|
|
1041
|
-
u64:
|
|
1042
|
-
u128:
|
|
1043
|
-
u256:
|
|
1044
|
-
bool:
|
|
1045
|
-
"0x1::ascii::String":
|
|
1046
|
-
"0x1::string::String":
|
|
1047
|
-
"0x1::option::Option<address>":
|
|
1048
|
-
|
|
1039
|
+
u8: import_bcs3.bcs.u8(),
|
|
1040
|
+
u16: import_bcs3.bcs.u16(),
|
|
1041
|
+
u32: import_bcs3.bcs.u32(),
|
|
1042
|
+
u64: import_bcs3.bcs.u64(),
|
|
1043
|
+
u128: import_bcs3.bcs.u128(),
|
|
1044
|
+
u256: import_bcs3.bcs.u256(),
|
|
1045
|
+
bool: import_bcs3.bcs.bool(),
|
|
1046
|
+
"0x1::ascii::String": import_bcs3.bcs.string(),
|
|
1047
|
+
"0x1::string::String": import_bcs3.bcs.string(),
|
|
1048
|
+
"0x1::option::Option<address>": import_bcs3.bcs.option(
|
|
1049
|
+
import_bcs3.bcs.bytes(32).transform({
|
|
1049
1050
|
// To change the input type, you need to provide a type definition for the input
|
|
1050
|
-
input: (val) => (0,
|
|
1051
|
-
output: (val) => (0,
|
|
1051
|
+
input: (val) => (0, import_bcs3.fromHEX)(val),
|
|
1052
|
+
output: (val) => (0, import_bcs3.toHEX)(val)
|
|
1052
1053
|
})
|
|
1053
1054
|
),
|
|
1054
|
-
"0x1::option::Option<u8>":
|
|
1055
|
-
"0x1::option::Option<u16>":
|
|
1056
|
-
"0x1::option::Option<u32>":
|
|
1057
|
-
"0x1::option::Option<u64>":
|
|
1058
|
-
"0x1::option::Option<u128>":
|
|
1059
|
-
"0x1::option::Option<u256>":
|
|
1060
|
-
"0x1::option::Option<bool>":
|
|
1061
|
-
"0x1::option::Option<vector<address>>":
|
|
1062
|
-
|
|
1063
|
-
|
|
1055
|
+
"0x1::option::Option<u8>": import_bcs3.bcs.option(import_bcs3.bcs.u8()),
|
|
1056
|
+
"0x1::option::Option<u16>": import_bcs3.bcs.option(import_bcs3.bcs.u16()),
|
|
1057
|
+
"0x1::option::Option<u32>": import_bcs3.bcs.option(import_bcs3.bcs.u32()),
|
|
1058
|
+
"0x1::option::Option<u64>": import_bcs3.bcs.option(import_bcs3.bcs.u64()),
|
|
1059
|
+
"0x1::option::Option<u128>": import_bcs3.bcs.option(import_bcs3.bcs.u128()),
|
|
1060
|
+
"0x1::option::Option<u256>": import_bcs3.bcs.option(import_bcs3.bcs.u256()),
|
|
1061
|
+
"0x1::option::Option<bool>": import_bcs3.bcs.option(import_bcs3.bcs.bool()),
|
|
1062
|
+
"0x1::option::Option<vector<address>>": import_bcs3.bcs.option(
|
|
1063
|
+
import_bcs3.bcs.vector(
|
|
1064
|
+
import_bcs3.bcs.bytes(32).transform({
|
|
1064
1065
|
// To change the input type, you need to provide a type definition for the input
|
|
1065
|
-
input: (val) => (0, import_bcs2.
|
|
1066
|
-
output: (val) => (0, import_bcs2.
|
|
1066
|
+
input: (val) => (0, import_bcs2.fromHex)(val),
|
|
1067
|
+
output: (val) => (0, import_bcs2.toHex)(val)
|
|
1067
1068
|
})
|
|
1068
1069
|
)
|
|
1069
1070
|
),
|
|
1070
|
-
"0x1::option::Option<vector<u8>>":
|
|
1071
|
-
"0x1::option::Option<vector<u16>>":
|
|
1072
|
-
"0x1::option::Option<vector<u32>>":
|
|
1073
|
-
"0x1::option::Option<vector<u64>>":
|
|
1074
|
-
"0x1::option::Option<vector<u128>>":
|
|
1075
|
-
"0x1::option::Option<vector<u256>>":
|
|
1076
|
-
"0x1::option::Option<vector<bool>>":
|
|
1077
|
-
"vector<address>":
|
|
1078
|
-
|
|
1071
|
+
"0x1::option::Option<vector<u8>>": import_bcs3.bcs.option(import_bcs3.bcs.vector(import_bcs3.bcs.u8())),
|
|
1072
|
+
"0x1::option::Option<vector<u16>>": import_bcs3.bcs.option(import_bcs3.bcs.vector(import_bcs3.bcs.u16())),
|
|
1073
|
+
"0x1::option::Option<vector<u32>>": import_bcs3.bcs.option(import_bcs3.bcs.vector(import_bcs3.bcs.u32())),
|
|
1074
|
+
"0x1::option::Option<vector<u64>>": import_bcs3.bcs.option(import_bcs3.bcs.vector(import_bcs3.bcs.u64())),
|
|
1075
|
+
"0x1::option::Option<vector<u128>>": import_bcs3.bcs.option(import_bcs3.bcs.vector(import_bcs3.bcs.u128())),
|
|
1076
|
+
"0x1::option::Option<vector<u256>>": import_bcs3.bcs.option(import_bcs3.bcs.vector(import_bcs3.bcs.u256())),
|
|
1077
|
+
"0x1::option::Option<vector<bool>>": import_bcs3.bcs.option(import_bcs3.bcs.vector(import_bcs3.bcs.bool())),
|
|
1078
|
+
"vector<address>": import_bcs3.bcs.vector(
|
|
1079
|
+
import_bcs3.bcs.bytes(32).transform({
|
|
1079
1080
|
// To change the input type, you need to provide a type definition for the input
|
|
1080
|
-
input: (val) => (0, import_bcs2.
|
|
1081
|
-
output: (val) => (0, import_bcs2.
|
|
1081
|
+
input: (val) => (0, import_bcs2.fromHex)(val),
|
|
1082
|
+
output: (val) => (0, import_bcs2.toHex)(val)
|
|
1082
1083
|
})
|
|
1083
1084
|
),
|
|
1084
|
-
"vector<u8>":
|
|
1085
|
-
"vector<u16>":
|
|
1086
|
-
"vector<u32>":
|
|
1087
|
-
"vector<u64>":
|
|
1088
|
-
"vector<u128>":
|
|
1089
|
-
"vector<u256>":
|
|
1090
|
-
"vector<bool>":
|
|
1091
|
-
"vector<vector<address>>":
|
|
1092
|
-
|
|
1093
|
-
|
|
1085
|
+
"vector<u8>": import_bcs3.bcs.vector(import_bcs3.bcs.u8()),
|
|
1086
|
+
"vector<u16>": import_bcs3.bcs.vector(import_bcs3.bcs.u16()),
|
|
1087
|
+
"vector<u32>": import_bcs3.bcs.vector(import_bcs3.bcs.u32()),
|
|
1088
|
+
"vector<u64>": import_bcs3.bcs.vector(import_bcs3.bcs.u64()),
|
|
1089
|
+
"vector<u128>": import_bcs3.bcs.vector(import_bcs3.bcs.u128()),
|
|
1090
|
+
"vector<u256>": import_bcs3.bcs.vector(import_bcs3.bcs.u256()),
|
|
1091
|
+
"vector<bool>": import_bcs3.bcs.vector(import_bcs3.bcs.bool()),
|
|
1092
|
+
"vector<vector<address>>": import_bcs3.bcs.vector(
|
|
1093
|
+
import_bcs3.bcs.vector(
|
|
1094
|
+
import_bcs3.bcs.bytes(32).transform({
|
|
1094
1095
|
// To change the input type, you need to provide a type definition for the input
|
|
1095
|
-
input: (val) => (0, import_bcs2.
|
|
1096
|
-
output: (val) => (0, import_bcs2.
|
|
1096
|
+
input: (val) => (0, import_bcs2.fromHex)(val),
|
|
1097
|
+
output: (val) => (0, import_bcs2.toHex)(val)
|
|
1097
1098
|
})
|
|
1098
1099
|
)
|
|
1099
1100
|
),
|
|
1100
|
-
"vector<vector<u8>>":
|
|
1101
|
-
"vector<vector<u16>>":
|
|
1102
|
-
"vector<vector<u32>>":
|
|
1103
|
-
"vector<vector<u64>>":
|
|
1104
|
-
"vector<vector<u128>>":
|
|
1105
|
-
"vector<vector<u256>>":
|
|
1106
|
-
"vector<vector<bool>>":
|
|
1101
|
+
"vector<vector<u8>>": import_bcs3.bcs.vector(import_bcs3.bcs.vector(import_bcs3.bcs.u8())),
|
|
1102
|
+
"vector<vector<u16>>": import_bcs3.bcs.vector(import_bcs3.bcs.vector(import_bcs3.bcs.u16())),
|
|
1103
|
+
"vector<vector<u32>>": import_bcs3.bcs.vector(import_bcs3.bcs.vector(import_bcs3.bcs.u32())),
|
|
1104
|
+
"vector<vector<u64>>": import_bcs3.bcs.vector(import_bcs3.bcs.vector(import_bcs3.bcs.u64())),
|
|
1105
|
+
"vector<vector<u128>>": import_bcs3.bcs.vector(import_bcs3.bcs.vector(import_bcs3.bcs.u128())),
|
|
1106
|
+
"vector<vector<u256>>": import_bcs3.bcs.vector(import_bcs3.bcs.vector(import_bcs3.bcs.u256())),
|
|
1107
|
+
"vector<vector<bool>>": import_bcs3.bcs.vector(import_bcs3.bcs.vector(import_bcs3.bcs.bool())),
|
|
1108
|
+
"0x2::coin::Coin<T>": import_bcs3.bcs.struct("Coin", {
|
|
1109
|
+
id: import_bcs3.bcs.fixedArray(32, import_bcs3.bcs.u8()).transform({
|
|
1110
|
+
input: (id) => (0, import_bcs2.fromHex)(id),
|
|
1111
|
+
output: (id) => (0, import_bcs2.toHex)(Uint8Array.from(id))
|
|
1112
|
+
}),
|
|
1113
|
+
balance: import_bcs3.bcs.struct("Balance", {
|
|
1114
|
+
value: import_bcs3.bcs.u64()
|
|
1115
|
+
})
|
|
1116
|
+
}),
|
|
1117
|
+
"0x2::balance::Balance<T>": import_bcs3.bcs.struct("Balance", {
|
|
1118
|
+
value: import_bcs3.bcs.u64()
|
|
1119
|
+
})
|
|
1107
1120
|
});
|
|
1108
1121
|
__privateAdd(this, _exec, async (meta, tx, params, typeArguments, isRaw) => {
|
|
1109
1122
|
if (isRaw === true) {
|
|
@@ -1148,55 +1161,55 @@ var Dubhe = class {
|
|
|
1148
1161
|
case "Struct":
|
|
1149
1162
|
const structType = value;
|
|
1150
1163
|
if (structType.address === "0x1" && structType.module === "ascii" && structType.name === "String") {
|
|
1151
|
-
bcsJson[objName] =
|
|
1164
|
+
bcsJson[objName] = import_bcs3.bcs.string();
|
|
1152
1165
|
return;
|
|
1153
1166
|
} else if (structType.address === "0x2" && structType.module === "object" && structType.name === "UID") {
|
|
1154
|
-
bcsJson[objName] =
|
|
1155
|
-
input: (id) => (0,
|
|
1156
|
-
output: (id) => (0,
|
|
1167
|
+
bcsJson[objName] = import_bcs3.bcs.fixedArray(32, import_bcs3.bcs.u8()).transform({
|
|
1168
|
+
input: (id) => (0, import_bcs3.fromHEX)(id),
|
|
1169
|
+
output: (id) => (0, import_bcs3.toHEX)(Uint8Array.from(id))
|
|
1157
1170
|
});
|
|
1158
1171
|
return;
|
|
1159
1172
|
} else if (structType.address === "0x2" && structType.module === "object" && structType.name === "ID") {
|
|
1160
|
-
bcsJson[objName] =
|
|
1161
|
-
input: (id) => (0,
|
|
1162
|
-
output: (id) => (0,
|
|
1173
|
+
bcsJson[objName] = import_bcs3.bcs.fixedArray(32, import_bcs3.bcs.u8()).transform({
|
|
1174
|
+
input: (id) => (0, import_bcs3.fromHEX)(id),
|
|
1175
|
+
output: (id) => (0, import_bcs3.toHEX)(Uint8Array.from(id))
|
|
1163
1176
|
});
|
|
1164
1177
|
return;
|
|
1165
1178
|
} else if (structType.address === "0x2" && structType.module === "bag" && structType.name === "Bag") {
|
|
1166
|
-
bcsJson[objName] =
|
|
1167
|
-
input: (id) => (0,
|
|
1168
|
-
output: (id) => (0,
|
|
1179
|
+
bcsJson[objName] = import_bcs3.bcs.fixedArray(32, import_bcs3.bcs.u8()).transform({
|
|
1180
|
+
input: (id) => (0, import_bcs3.fromHEX)(id),
|
|
1181
|
+
output: (id) => (0, import_bcs3.toHEX)(Uint8Array.from(id))
|
|
1169
1182
|
});
|
|
1170
1183
|
return;
|
|
1171
1184
|
} else if (structType.address === "0x1" && structType.module === "option" && structType.name === "Option") {
|
|
1172
1185
|
switch (structType.typeArguments[0]) {
|
|
1173
1186
|
case "U8":
|
|
1174
|
-
bcsJson[objName] =
|
|
1187
|
+
bcsJson[objName] = import_bcs3.bcs.option(import_bcs3.bcs.u8());
|
|
1175
1188
|
return;
|
|
1176
1189
|
case "U16":
|
|
1177
|
-
bcsJson[objName] =
|
|
1190
|
+
bcsJson[objName] = import_bcs3.bcs.option(import_bcs3.bcs.u16());
|
|
1178
1191
|
return;
|
|
1179
1192
|
case "U32":
|
|
1180
|
-
bcsJson[objName] =
|
|
1193
|
+
bcsJson[objName] = import_bcs3.bcs.option(import_bcs3.bcs.u32());
|
|
1181
1194
|
return;
|
|
1182
1195
|
case "U64":
|
|
1183
|
-
bcsJson[objName] =
|
|
1196
|
+
bcsJson[objName] = import_bcs3.bcs.option(import_bcs3.bcs.u64());
|
|
1184
1197
|
return;
|
|
1185
1198
|
case "U128":
|
|
1186
|
-
bcsJson[objName] =
|
|
1199
|
+
bcsJson[objName] = import_bcs3.bcs.option(import_bcs3.bcs.u128());
|
|
1187
1200
|
return;
|
|
1188
1201
|
case "U256":
|
|
1189
|
-
bcsJson[objName] =
|
|
1202
|
+
bcsJson[objName] = import_bcs3.bcs.option(import_bcs3.bcs.u256());
|
|
1190
1203
|
return;
|
|
1191
1204
|
case "Bool":
|
|
1192
|
-
bcsJson[objName] =
|
|
1205
|
+
bcsJson[objName] = import_bcs3.bcs.option(import_bcs3.bcs.bool());
|
|
1193
1206
|
return;
|
|
1194
1207
|
case "Address":
|
|
1195
|
-
bcsJson[objName] =
|
|
1196
|
-
|
|
1208
|
+
bcsJson[objName] = import_bcs3.bcs.option(
|
|
1209
|
+
import_bcs3.bcs.bytes(32).transform({
|
|
1197
1210
|
// To change the input type, you need to provide a type definition for the input
|
|
1198
|
-
input: (val) => (0,
|
|
1199
|
-
output: (val) => (0,
|
|
1211
|
+
input: (val) => (0, import_bcs3.fromHEX)(val),
|
|
1212
|
+
output: (val) => (0, import_bcs3.toHEX)(val)
|
|
1200
1213
|
})
|
|
1201
1214
|
);
|
|
1202
1215
|
return;
|
|
@@ -1214,39 +1227,39 @@ var Dubhe = class {
|
|
|
1214
1227
|
case "Vector":
|
|
1215
1228
|
switch (value) {
|
|
1216
1229
|
case "U8":
|
|
1217
|
-
bcsJson[objName] =
|
|
1230
|
+
bcsJson[objName] = import_bcs3.bcs.vector(import_bcs3.bcs.u8());
|
|
1218
1231
|
return;
|
|
1219
1232
|
case "U16":
|
|
1220
|
-
bcsJson[objName] =
|
|
1233
|
+
bcsJson[objName] = import_bcs3.bcs.vector(import_bcs3.bcs.u16());
|
|
1221
1234
|
return;
|
|
1222
1235
|
case "U32":
|
|
1223
|
-
bcsJson[objName] =
|
|
1236
|
+
bcsJson[objName] = import_bcs3.bcs.vector(import_bcs3.bcs.u32());
|
|
1224
1237
|
return;
|
|
1225
1238
|
case "U64":
|
|
1226
|
-
bcsJson[objName] =
|
|
1239
|
+
bcsJson[objName] = import_bcs3.bcs.vector(import_bcs3.bcs.u64());
|
|
1227
1240
|
return;
|
|
1228
1241
|
case "U128":
|
|
1229
|
-
bcsJson[objName] =
|
|
1242
|
+
bcsJson[objName] = import_bcs3.bcs.vector(import_bcs3.bcs.u128());
|
|
1230
1243
|
return;
|
|
1231
1244
|
case "U256":
|
|
1232
|
-
bcsJson[objName] =
|
|
1245
|
+
bcsJson[objName] = import_bcs3.bcs.vector(import_bcs3.bcs.u256());
|
|
1233
1246
|
return;
|
|
1234
1247
|
case "Bool":
|
|
1235
|
-
bcsJson[objName] =
|
|
1248
|
+
bcsJson[objName] = import_bcs3.bcs.vector(import_bcs3.bcs.bool());
|
|
1236
1249
|
return;
|
|
1237
1250
|
case "Address":
|
|
1238
|
-
bcsJson[objName] =
|
|
1239
|
-
|
|
1251
|
+
bcsJson[objName] = import_bcs3.bcs.vector(
|
|
1252
|
+
import_bcs3.bcs.bytes(32).transform({
|
|
1240
1253
|
// To change the input type, you need to provide a type definition for the input
|
|
1241
|
-
input: (val) => (0,
|
|
1242
|
-
output: (val) => (0,
|
|
1254
|
+
input: (val) => (0, import_bcs3.fromHEX)(val),
|
|
1255
|
+
output: (val) => (0, import_bcs3.toHEX)(val)
|
|
1243
1256
|
})
|
|
1244
1257
|
);
|
|
1245
1258
|
return;
|
|
1246
1259
|
default:
|
|
1247
1260
|
}
|
|
1248
1261
|
case "TypeParameter":
|
|
1249
|
-
bcsJson[objName] =
|
|
1262
|
+
bcsJson[objName] = import_bcs3.bcs.u128();
|
|
1250
1263
|
return;
|
|
1251
1264
|
default:
|
|
1252
1265
|
throw new Error("Unsupported type");
|
|
@@ -1256,31 +1269,31 @@ var Dubhe = class {
|
|
|
1256
1269
|
case "string":
|
|
1257
1270
|
switch (objType) {
|
|
1258
1271
|
case "U8":
|
|
1259
|
-
bcsJson[objName] =
|
|
1272
|
+
bcsJson[objName] = import_bcs3.bcs.u8();
|
|
1260
1273
|
return;
|
|
1261
1274
|
case "U16":
|
|
1262
|
-
bcsJson[objName] =
|
|
1275
|
+
bcsJson[objName] = import_bcs3.bcs.u16();
|
|
1263
1276
|
return;
|
|
1264
1277
|
case "U32":
|
|
1265
|
-
bcsJson[objName] =
|
|
1278
|
+
bcsJson[objName] = import_bcs3.bcs.u32();
|
|
1266
1279
|
return;
|
|
1267
1280
|
case "U64":
|
|
1268
|
-
bcsJson[objName] =
|
|
1281
|
+
bcsJson[objName] = import_bcs3.bcs.u64();
|
|
1269
1282
|
return;
|
|
1270
1283
|
case "U128":
|
|
1271
|
-
bcsJson[objName] =
|
|
1284
|
+
bcsJson[objName] = import_bcs3.bcs.u128();
|
|
1272
1285
|
return;
|
|
1273
1286
|
case "U256":
|
|
1274
|
-
bcsJson[objName] =
|
|
1287
|
+
bcsJson[objName] = import_bcs3.bcs.u256();
|
|
1275
1288
|
return;
|
|
1276
1289
|
case "Bool":
|
|
1277
|
-
bcsJson[objName] =
|
|
1290
|
+
bcsJson[objName] = import_bcs3.bcs.bool();
|
|
1278
1291
|
return;
|
|
1279
1292
|
case "Address":
|
|
1280
|
-
bcsJson[objName] =
|
|
1293
|
+
bcsJson[objName] = import_bcs3.bcs.bytes(32).transform({
|
|
1281
1294
|
// To change the input type, you need to provide a type definition for the input
|
|
1282
|
-
input: (val) => (0,
|
|
1283
|
-
output: (val) => (0,
|
|
1295
|
+
input: (val) => (0, import_bcs3.fromHEX)(val),
|
|
1296
|
+
output: (val) => (0, import_bcs3.toHEX)(val)
|
|
1284
1297
|
});
|
|
1285
1298
|
return;
|
|
1286
1299
|
default:
|
|
@@ -1291,7 +1304,7 @@ var Dubhe = class {
|
|
|
1291
1304
|
}
|
|
1292
1305
|
});
|
|
1293
1306
|
return {
|
|
1294
|
-
bcs:
|
|
1307
|
+
bcs: import_bcs3.bcs.struct(bcsmeta.objectName, bcsJson),
|
|
1295
1308
|
loopFlag
|
|
1296
1309
|
};
|
|
1297
1310
|
});
|
|
@@ -1323,8 +1336,8 @@ var Dubhe = class {
|
|
|
1323
1336
|
loopFlag = bcsObj.loopFlag;
|
|
1324
1337
|
}
|
|
1325
1338
|
__privateGet(this, _object)[objectId] = bcsObj.bcs;
|
|
1326
|
-
__privateGet(this, _object)[`vector<${objectId}>`] =
|
|
1327
|
-
__privateGet(this, _object)[`0x1::option::Option<${objectId}>`] =
|
|
1339
|
+
__privateGet(this, _object)[`vector<${objectId}>`] = import_bcs3.bcs.vector(bcsObj.bcs);
|
|
1340
|
+
__privateGet(this, _object)[`0x1::option::Option<${objectId}>`] = import_bcs3.bcs.option(
|
|
1328
1341
|
bcsObj.bcs
|
|
1329
1342
|
);
|
|
1330
1343
|
});
|
|
@@ -1381,33 +1394,46 @@ var Dubhe = class {
|
|
|
1381
1394
|
let baseValue = res[0];
|
|
1382
1395
|
let baseType = res[1];
|
|
1383
1396
|
const value = Uint8Array.from(baseValue);
|
|
1384
|
-
if (
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1397
|
+
if (__privateGet(this, _object)[baseType]) {
|
|
1398
|
+
returnValues.push(__privateGet(this, _object)[baseType].parse(value));
|
|
1399
|
+
continue;
|
|
1400
|
+
}
|
|
1401
|
+
const genericMatch = baseType.match(/^([^<]+)<(.+)>$/);
|
|
1402
|
+
if (genericMatch) {
|
|
1403
|
+
const [_, genericBase, _genericParam] = genericMatch;
|
|
1404
|
+
const genericKey = `${genericBase}<T>`;
|
|
1405
|
+
if (__privateGet(this, _object)[genericKey]) {
|
|
1406
|
+
returnValues.push(__privateGet(this, _object)[genericKey].parse(value));
|
|
1407
|
+
continue;
|
|
1408
|
+
}
|
|
1409
|
+
}
|
|
1410
|
+
console.log(
|
|
1411
|
+
"\n\x1B[41m\x1B[37m ERROR \x1B[0m \x1B[31mUnsupported Type\x1B[0m"
|
|
1412
|
+
);
|
|
1413
|
+
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");
|
|
1414
|
+
console.log(`\x1B[95m\u2022\x1B[0m Type: \x1B[33m"${baseType}"\x1B[0m`);
|
|
1415
|
+
if (genericMatch) {
|
|
1395
1416
|
console.log(
|
|
1396
|
-
|
|
1417
|
+
`\x1B[95m\u2022\x1B[0m Generic Base Type: \x1B[33m"${genericMatch[1]}<T>"\x1B[0m`
|
|
1397
1418
|
);
|
|
1398
|
-
|
|
1399
|
-
|
|
1419
|
+
}
|
|
1420
|
+
console.log("\x1B[95m\n\u2728 Available Types:\x1B[0m");
|
|
1421
|
+
Object.keys(__privateGet(this, _object)).forEach((type) => {
|
|
1422
|
+
console.log(` \x1B[36m\u25C6\x1B[0m ${type}`);
|
|
1423
|
+
});
|
|
1424
|
+
console.log("\n\x1B[34m\u{1F4A1} How to Add Custom Type:\x1B[0m");
|
|
1425
|
+
console.log(
|
|
1426
|
+
` You can add custom type by extending the #object map in your code:`
|
|
1427
|
+
);
|
|
1428
|
+
console.log(
|
|
1429
|
+
` \x1B[32mdubhe.object["${baseType}"] = bcs.struct("YourTypeName", {
|
|
1400
1430
|
field1: bcs.string(),
|
|
1401
1431
|
field2: bcs.u64(),
|
|
1402
1432
|
// ... other fields
|
|
1403
1433
|
});\x1B[0m`
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
);
|
|
1408
|
-
throw new Error(`Unsupported type: ${baseType}`);
|
|
1409
|
-
}
|
|
1410
|
-
returnValues.push(__privateGet(this, _object)[baseType].parse(value));
|
|
1434
|
+
);
|
|
1435
|
+
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");
|
|
1436
|
+
throw new Error(`Unsupported type: ${baseType}`);
|
|
1411
1437
|
}
|
|
1412
1438
|
return returnValues;
|
|
1413
1439
|
} else {
|
|
@@ -1637,10 +1663,10 @@ var Dubhe = class {
|
|
|
1637
1663
|
const hashBytes = (0, import_keccak256.default)(bytes);
|
|
1638
1664
|
const hashU8Array = Array.from(hashBytes);
|
|
1639
1665
|
const value = Uint8Array.from(hashU8Array);
|
|
1640
|
-
const Address =
|
|
1666
|
+
const Address = import_bcs3.bcs.bytes(32).transform({
|
|
1641
1667
|
// To change the input type, you need to provide a type definition for the input
|
|
1642
|
-
input: (val) => (0,
|
|
1643
|
-
output: (val) => (0,
|
|
1668
|
+
input: (val) => (0, import_bcs3.fromHEX)(val),
|
|
1669
|
+
output: (val) => (0, import_bcs3.toHEX)(val)
|
|
1644
1670
|
});
|
|
1645
1671
|
const data = Address.parse(value);
|
|
1646
1672
|
return "0x" + data;
|
|
@@ -1661,7 +1687,7 @@ var Dubhe = class {
|
|
|
1661
1687
|
if (checkObjectId !== null) {
|
|
1662
1688
|
objectId = checkObjectId;
|
|
1663
1689
|
const bytes = Buffer.from(objectId.slice(2), "hex");
|
|
1664
|
-
const numberBytes =
|
|
1690
|
+
const numberBytes = import_bcs3.bcs.u256().serialize(x).toBytes();
|
|
1665
1691
|
return this.entity_key_from_bytes(Buffer.concat([bytes, numberBytes]));
|
|
1666
1692
|
} else {
|
|
1667
1693
|
return void 0;
|