@0xobelisk/sui-client 0.5.19 → 0.5.20
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 +274 -126
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +274 -126
- package/dist/index.mjs.map +1 -1
- package/dist/obelisk.d.ts +4 -4
- package/dist/types/index.d.ts +18 -21
- package/package.json +1 -1
- package/src/obelisk.ts +329 -139
- package/src/types/index.ts +20 -28
package/dist/index.js
CHANGED
|
@@ -974,7 +974,7 @@ function createTx(meta, fn) {
|
|
|
974
974
|
}
|
|
975
975
|
);
|
|
976
976
|
}
|
|
977
|
-
var _query, _tx,
|
|
977
|
+
var _query, _tx, _object, _exec, _read, _bcs;
|
|
978
978
|
var Obelisk = class {
|
|
979
979
|
/**
|
|
980
980
|
* Support the following ways to init the ObeliskClient:
|
|
@@ -998,7 +998,49 @@ var Obelisk = class {
|
|
|
998
998
|
} = {}) {
|
|
999
999
|
__privateAdd(this, _query, {});
|
|
1000
1000
|
__privateAdd(this, _tx, {});
|
|
1001
|
-
__privateAdd(this,
|
|
1001
|
+
__privateAdd(this, _object, {
|
|
1002
|
+
address: import_bcs2.bcs.bytes(32).transform({
|
|
1003
|
+
// To change the input type, you need to provide a type definition for the input
|
|
1004
|
+
input: (val) => (0, import_bcs2.fromHEX)(val),
|
|
1005
|
+
output: (val) => (0, import_bcs2.toHEX)(val)
|
|
1006
|
+
}),
|
|
1007
|
+
u8: import_bcs2.bcs.u8(),
|
|
1008
|
+
u16: import_bcs2.bcs.u16(),
|
|
1009
|
+
u32: import_bcs2.bcs.u32(),
|
|
1010
|
+
u64: import_bcs2.bcs.u64(),
|
|
1011
|
+
u128: import_bcs2.bcs.u128(),
|
|
1012
|
+
u256: import_bcs2.bcs.u256(),
|
|
1013
|
+
bool: import_bcs2.bcs.bool(),
|
|
1014
|
+
"0x1::ascii::String": import_bcs2.bcs.string(),
|
|
1015
|
+
"0x1::option::Option<address>": import_bcs2.bcs.option(
|
|
1016
|
+
import_bcs2.bcs.bytes(32).transform({
|
|
1017
|
+
// To change the input type, you need to provide a type definition for the input
|
|
1018
|
+
input: (val) => (0, import_bcs2.fromHEX)(val),
|
|
1019
|
+
output: (val) => (0, import_bcs2.toHEX)(val)
|
|
1020
|
+
})
|
|
1021
|
+
),
|
|
1022
|
+
"0x1::option::Option<u8>": import_bcs2.bcs.option(import_bcs2.bcs.u8()),
|
|
1023
|
+
"0x1::option::Option<u16>": import_bcs2.bcs.option(import_bcs2.bcs.u16()),
|
|
1024
|
+
"0x1::option::Option<u32>": import_bcs2.bcs.option(import_bcs2.bcs.u32()),
|
|
1025
|
+
"0x1::option::Option<u64>": import_bcs2.bcs.option(import_bcs2.bcs.u64()),
|
|
1026
|
+
"0x1::option::Option<u128>": import_bcs2.bcs.option(import_bcs2.bcs.u128()),
|
|
1027
|
+
"0x1::option::Option<u256>": import_bcs2.bcs.option(import_bcs2.bcs.u256()),
|
|
1028
|
+
"0x1::option::Option<bool>": import_bcs2.bcs.option(import_bcs2.bcs.bool()),
|
|
1029
|
+
"vector<address>": import_bcs2.bcs.vector(
|
|
1030
|
+
import_bcs2.bcs.bytes(32).transform({
|
|
1031
|
+
// To change the input type, you need to provide a type definition for the input
|
|
1032
|
+
input: (val) => (0, import_bcs2.fromHEX)(val),
|
|
1033
|
+
output: (val) => (0, import_bcs2.toHEX)(val)
|
|
1034
|
+
})
|
|
1035
|
+
),
|
|
1036
|
+
"vector<u8>": import_bcs2.bcs.vector(import_bcs2.bcs.u8()),
|
|
1037
|
+
"vector<u16>": import_bcs2.bcs.vector(import_bcs2.bcs.u16()),
|
|
1038
|
+
"vector<u32>": import_bcs2.bcs.vector(import_bcs2.bcs.u32()),
|
|
1039
|
+
"vector<u64>": import_bcs2.bcs.vector(import_bcs2.bcs.u64()),
|
|
1040
|
+
"vector<u128>": import_bcs2.bcs.vector(import_bcs2.bcs.u128()),
|
|
1041
|
+
"vector<u256>": import_bcs2.bcs.vector(import_bcs2.bcs.u256()),
|
|
1042
|
+
"vector<bool>": import_bcs2.bcs.vector(import_bcs2.bcs.bool())
|
|
1043
|
+
});
|
|
1002
1044
|
__privateAdd(this, _exec, async (meta, tx, params, typeArguments, isRaw) => {
|
|
1003
1045
|
if (isRaw === true) {
|
|
1004
1046
|
return tx.moveCall({
|
|
@@ -1029,43 +1071,221 @@ var Obelisk = class {
|
|
|
1029
1071
|
});
|
|
1030
1072
|
return await this.inspectTxn(tx);
|
|
1031
1073
|
});
|
|
1074
|
+
__privateAdd(this, _bcs, (bcsmeta) => {
|
|
1075
|
+
let loopFlag = false;
|
|
1076
|
+
const bcsJson = {};
|
|
1077
|
+
Object.entries(bcsmeta.objectType.fields).forEach(([index, type]) => {
|
|
1078
|
+
const objName = type.name;
|
|
1079
|
+
const objType = type.type;
|
|
1080
|
+
switch (typeof objType) {
|
|
1081
|
+
case "object":
|
|
1082
|
+
for (const [key, value] of Object.entries(objType)) {
|
|
1083
|
+
switch (key) {
|
|
1084
|
+
case "Struct":
|
|
1085
|
+
const structType = value;
|
|
1086
|
+
if (structType.address === "0x1" && structType.module === "ascii" && structType.name === "String") {
|
|
1087
|
+
bcsJson[objName] = import_bcs2.bcs.string();
|
|
1088
|
+
return;
|
|
1089
|
+
} else if (structType.address === "0x2" && structType.module === "object" && structType.name === "UID") {
|
|
1090
|
+
bcsJson[objName] = import_bcs2.bcs.fixedArray(32, import_bcs2.bcs.u8()).transform({
|
|
1091
|
+
input: (id) => (0, import_bcs2.fromHEX)(id),
|
|
1092
|
+
output: (id) => (0, import_bcs2.toHEX)(Uint8Array.from(id))
|
|
1093
|
+
});
|
|
1094
|
+
return;
|
|
1095
|
+
} else if (structType.address === "0x2" && structType.module === "object" && structType.name === "ID") {
|
|
1096
|
+
bcsJson[objName] = import_bcs2.bcs.fixedArray(32, import_bcs2.bcs.u8()).transform({
|
|
1097
|
+
input: (id) => (0, import_bcs2.fromHEX)(id),
|
|
1098
|
+
output: (id) => (0, import_bcs2.toHEX)(Uint8Array.from(id))
|
|
1099
|
+
});
|
|
1100
|
+
return;
|
|
1101
|
+
} else if (structType.address === "0x2" && structType.module === "bag" && structType.name === "Bag") {
|
|
1102
|
+
bcsJson[objName] = import_bcs2.bcs.fixedArray(32, import_bcs2.bcs.u8()).transform({
|
|
1103
|
+
input: (id) => (0, import_bcs2.fromHEX)(id),
|
|
1104
|
+
output: (id) => (0, import_bcs2.toHEX)(Uint8Array.from(id))
|
|
1105
|
+
});
|
|
1106
|
+
return;
|
|
1107
|
+
} else if (structType.address === "0x1" && structType.module === "option" && structType.name === "Option") {
|
|
1108
|
+
switch (structType.typeArguments[0]) {
|
|
1109
|
+
case "U8":
|
|
1110
|
+
bcsJson[objName] = import_bcs2.bcs.option(import_bcs2.bcs.u8());
|
|
1111
|
+
return;
|
|
1112
|
+
case "U16":
|
|
1113
|
+
bcsJson[objName] = import_bcs2.bcs.option(import_bcs2.bcs.u16());
|
|
1114
|
+
return;
|
|
1115
|
+
case "U32":
|
|
1116
|
+
bcsJson[objName] = import_bcs2.bcs.option(import_bcs2.bcs.u32());
|
|
1117
|
+
return;
|
|
1118
|
+
case "U64":
|
|
1119
|
+
bcsJson[objName] = import_bcs2.bcs.option(import_bcs2.bcs.u64());
|
|
1120
|
+
return;
|
|
1121
|
+
case "U128":
|
|
1122
|
+
bcsJson[objName] = import_bcs2.bcs.option(import_bcs2.bcs.u128());
|
|
1123
|
+
return;
|
|
1124
|
+
case "U256":
|
|
1125
|
+
bcsJson[objName] = import_bcs2.bcs.option(import_bcs2.bcs.u256());
|
|
1126
|
+
return;
|
|
1127
|
+
case "Bool":
|
|
1128
|
+
bcsJson[objName] = import_bcs2.bcs.option(import_bcs2.bcs.bool());
|
|
1129
|
+
return;
|
|
1130
|
+
case "Address":
|
|
1131
|
+
bcsJson[objName] = import_bcs2.bcs.option(
|
|
1132
|
+
import_bcs2.bcs.bytes(32).transform({
|
|
1133
|
+
// To change the input type, you need to provide a type definition for the input
|
|
1134
|
+
input: (val) => (0, import_bcs2.fromHEX)(val),
|
|
1135
|
+
output: (val) => (0, import_bcs2.toHEX)(val)
|
|
1136
|
+
})
|
|
1137
|
+
);
|
|
1138
|
+
return;
|
|
1139
|
+
default:
|
|
1140
|
+
}
|
|
1141
|
+
} else {
|
|
1142
|
+
if (this.object[`${structType.address}::${structType.module}::${structType.name}`] === void 0) {
|
|
1143
|
+
loopFlag = true;
|
|
1144
|
+
} else {
|
|
1145
|
+
bcsJson[objName] = this.object[`${structType.address}::${structType.module}::${structType.name}`];
|
|
1146
|
+
return;
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
return;
|
|
1150
|
+
case "Vector":
|
|
1151
|
+
switch (value) {
|
|
1152
|
+
case "U8":
|
|
1153
|
+
bcsJson[objName] = import_bcs2.bcs.vector(import_bcs2.bcs.u8());
|
|
1154
|
+
return;
|
|
1155
|
+
case "U16":
|
|
1156
|
+
bcsJson[objName] = import_bcs2.bcs.vector(import_bcs2.bcs.u16());
|
|
1157
|
+
return;
|
|
1158
|
+
case "U32":
|
|
1159
|
+
bcsJson[objName] = import_bcs2.bcs.vector(import_bcs2.bcs.u32());
|
|
1160
|
+
return;
|
|
1161
|
+
case "U64":
|
|
1162
|
+
bcsJson[objName] = import_bcs2.bcs.vector(import_bcs2.bcs.u64());
|
|
1163
|
+
return;
|
|
1164
|
+
case "U128":
|
|
1165
|
+
bcsJson[objName] = import_bcs2.bcs.vector(import_bcs2.bcs.u128());
|
|
1166
|
+
return;
|
|
1167
|
+
case "U256":
|
|
1168
|
+
bcsJson[objName] = import_bcs2.bcs.vector(import_bcs2.bcs.u256());
|
|
1169
|
+
return;
|
|
1170
|
+
case "Bool":
|
|
1171
|
+
bcsJson[objName] = import_bcs2.bcs.vector(import_bcs2.bcs.bool());
|
|
1172
|
+
return;
|
|
1173
|
+
case "Address":
|
|
1174
|
+
bcsJson[objName] = import_bcs2.bcs.vector(
|
|
1175
|
+
import_bcs2.bcs.bytes(32).transform({
|
|
1176
|
+
// To change the input type, you need to provide a type definition for the input
|
|
1177
|
+
input: (val) => (0, import_bcs2.fromHEX)(val),
|
|
1178
|
+
output: (val) => (0, import_bcs2.toHEX)(val)
|
|
1179
|
+
})
|
|
1180
|
+
);
|
|
1181
|
+
return;
|
|
1182
|
+
default:
|
|
1183
|
+
}
|
|
1184
|
+
case "TypeParameter":
|
|
1185
|
+
bcsJson[objName] = import_bcs2.bcs.u128();
|
|
1186
|
+
return;
|
|
1187
|
+
default:
|
|
1188
|
+
throw new Error("Unsupported type");
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1191
|
+
return;
|
|
1192
|
+
case "string":
|
|
1193
|
+
switch (objType) {
|
|
1194
|
+
case "U8":
|
|
1195
|
+
bcsJson[objName] = import_bcs2.bcs.u8();
|
|
1196
|
+
return;
|
|
1197
|
+
case "U16":
|
|
1198
|
+
bcsJson[objName] = import_bcs2.bcs.u16();
|
|
1199
|
+
return;
|
|
1200
|
+
case "U32":
|
|
1201
|
+
bcsJson[objName] = import_bcs2.bcs.u32();
|
|
1202
|
+
return;
|
|
1203
|
+
case "U64":
|
|
1204
|
+
bcsJson[objName] = import_bcs2.bcs.u64();
|
|
1205
|
+
return;
|
|
1206
|
+
case "U128":
|
|
1207
|
+
bcsJson[objName] = import_bcs2.bcs.u128();
|
|
1208
|
+
return;
|
|
1209
|
+
case "U256":
|
|
1210
|
+
bcsJson[objName] = import_bcs2.bcs.u256();
|
|
1211
|
+
return;
|
|
1212
|
+
case "Bool":
|
|
1213
|
+
bcsJson[objName] = import_bcs2.bcs.bool();
|
|
1214
|
+
return;
|
|
1215
|
+
case "Address":
|
|
1216
|
+
bcsJson[objName] = import_bcs2.bcs.bytes(32).transform({
|
|
1217
|
+
// To change the input type, you need to provide a type definition for the input
|
|
1218
|
+
input: (val) => (0, import_bcs2.fromHEX)(val),
|
|
1219
|
+
output: (val) => (0, import_bcs2.toHEX)(val)
|
|
1220
|
+
});
|
|
1221
|
+
return;
|
|
1222
|
+
default:
|
|
1223
|
+
return;
|
|
1224
|
+
}
|
|
1225
|
+
default:
|
|
1226
|
+
throw new Error("Unsupported type");
|
|
1227
|
+
}
|
|
1228
|
+
});
|
|
1229
|
+
return {
|
|
1230
|
+
bcs: import_bcs2.bcs.struct(bcsmeta.objectName, bcsJson),
|
|
1231
|
+
loopFlag
|
|
1232
|
+
};
|
|
1233
|
+
});
|
|
1032
1234
|
this.accountManager = new SuiAccountManager({ mnemonics, secretKey });
|
|
1033
1235
|
fullnodeUrls = fullnodeUrls || [(0, import_client2.getFullnodeUrl)(networkType ?? "mainnet")];
|
|
1034
1236
|
this.suiInteractor = new SuiInteractor(fullnodeUrls, networkType);
|
|
1035
1237
|
this.packageId = packageId;
|
|
1036
1238
|
if (metadata !== void 0) {
|
|
1037
1239
|
this.metadata = metadata;
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
}
|
|
1056
|
-
if (isUndefined(__privateGet(this, _tx)[moduleName])) {
|
|
1057
|
-
__privateGet(this, _tx)[moduleName] = {};
|
|
1240
|
+
let stillNeedFormat = true;
|
|
1241
|
+
while (stillNeedFormat === true) {
|
|
1242
|
+
let loopFlag = false;
|
|
1243
|
+
Object.values(metadata).forEach(
|
|
1244
|
+
(moudlevalue) => {
|
|
1245
|
+
const data = moudlevalue;
|
|
1246
|
+
const moduleName = data.name;
|
|
1247
|
+
const objMoudleId = `${packageId}::${moduleName}`;
|
|
1248
|
+
Object.entries(data.structs).forEach(([objectName, objectType]) => {
|
|
1249
|
+
const objId = `${objMoudleId}::${objectName}`;
|
|
1250
|
+
const bcsmeta = {
|
|
1251
|
+
objectName,
|
|
1252
|
+
objectType
|
|
1253
|
+
};
|
|
1254
|
+
let bcsObj = __privateGet(this, _bcs).call(this, bcsmeta);
|
|
1255
|
+
if (bcsObj.loopFlag === true) {
|
|
1256
|
+
loopFlag = bcsObj.loopFlag;
|
|
1058
1257
|
}
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1258
|
+
__privateGet(this, _object)[objId] = bcsObj.bcs;
|
|
1259
|
+
});
|
|
1260
|
+
Object.entries(data.exposedFunctions).forEach(
|
|
1261
|
+
([funcName, funcvalue]) => {
|
|
1262
|
+
const meta = funcvalue;
|
|
1263
|
+
meta.moduleName = moduleName;
|
|
1264
|
+
meta.funcName = funcName;
|
|
1265
|
+
if (isUndefined(__privateGet(this, _query)[moduleName])) {
|
|
1266
|
+
__privateGet(this, _query)[moduleName] = {};
|
|
1267
|
+
}
|
|
1268
|
+
if (isUndefined(__privateGet(this, _query)[moduleName][funcName])) {
|
|
1269
|
+
__privateGet(this, _query)[moduleName][funcName] = createQuery(
|
|
1270
|
+
meta,
|
|
1271
|
+
(tx, p, typeArguments, isRaw) => __privateGet(this, _read).call(this, meta, tx, p, typeArguments, isRaw)
|
|
1272
|
+
);
|
|
1273
|
+
}
|
|
1274
|
+
if (isUndefined(__privateGet(this, _tx)[moduleName])) {
|
|
1275
|
+
__privateGet(this, _tx)[moduleName] = {};
|
|
1276
|
+
}
|
|
1277
|
+
if (isUndefined(__privateGet(this, _tx)[moduleName][funcName])) {
|
|
1278
|
+
__privateGet(this, _tx)[moduleName][funcName] = createTx(
|
|
1279
|
+
meta,
|
|
1280
|
+
(tx, p, typeArguments, isRaw) => __privateGet(this, _exec).call(this, meta, tx, p, typeArguments, isRaw)
|
|
1281
|
+
);
|
|
1282
|
+
}
|
|
1064
1283
|
}
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1284
|
+
);
|
|
1285
|
+
}
|
|
1286
|
+
);
|
|
1287
|
+
stillNeedFormat = loopFlag;
|
|
1288
|
+
}
|
|
1069
1289
|
}
|
|
1070
1290
|
this.contractFactory = new SuiContractFactory({
|
|
1071
1291
|
packageId,
|
|
@@ -1078,8 +1298,23 @@ var Obelisk = class {
|
|
|
1078
1298
|
get tx() {
|
|
1079
1299
|
return __privateGet(this, _tx);
|
|
1080
1300
|
}
|
|
1081
|
-
get
|
|
1082
|
-
return __privateGet(this,
|
|
1301
|
+
get object() {
|
|
1302
|
+
return __privateGet(this, _object);
|
|
1303
|
+
}
|
|
1304
|
+
view(dryResult) {
|
|
1305
|
+
let returnValues = [];
|
|
1306
|
+
if (dryResult.effects.status.status === "success") {
|
|
1307
|
+
const resultList = dryResult.results[0].returnValues;
|
|
1308
|
+
for (const res of resultList) {
|
|
1309
|
+
let baseValue = res[0];
|
|
1310
|
+
let baseType = res[1];
|
|
1311
|
+
const value = Uint8Array.from(baseValue);
|
|
1312
|
+
returnValues.push(this.object[baseType].parse(value));
|
|
1313
|
+
}
|
|
1314
|
+
return returnValues;
|
|
1315
|
+
} else {
|
|
1316
|
+
return void 0;
|
|
1317
|
+
}
|
|
1083
1318
|
}
|
|
1084
1319
|
/**
|
|
1085
1320
|
* if derivePathParams is not provided or mnemonics is empty, it will return the keypair.
|
|
@@ -1297,50 +1532,11 @@ var Obelisk = class {
|
|
|
1297
1532
|
if (entityId !== void 0) {
|
|
1298
1533
|
params.push(tx.pure.address(entityId));
|
|
1299
1534
|
}
|
|
1300
|
-
const
|
|
1535
|
+
const dryResult = await this.query[schemaModuleName].get(
|
|
1301
1536
|
tx,
|
|
1302
1537
|
params
|
|
1303
1538
|
);
|
|
1304
|
-
|
|
1305
|
-
if (getResult.effects.status.status === "success") {
|
|
1306
|
-
const resultList = getResult.results[0].returnValues;
|
|
1307
|
-
for (const res of resultList) {
|
|
1308
|
-
let baseValue = res[0];
|
|
1309
|
-
let baseType = res[1];
|
|
1310
|
-
const value = Uint8Array.from(baseValue);
|
|
1311
|
-
if (baseType === "address") {
|
|
1312
|
-
const Address = import_bcs2.bcs.bytes(32).transform({
|
|
1313
|
-
// To change the input type, you need to provide a type definition for the input
|
|
1314
|
-
input: (val) => (0, import_bcs2.fromHEX)(val),
|
|
1315
|
-
output: (val) => (0, import_bcs2.toHEX)(val)
|
|
1316
|
-
});
|
|
1317
|
-
returnValues.push(Address.parse(value));
|
|
1318
|
-
} else if (baseType === "u8") {
|
|
1319
|
-
returnValues.push(import_bcs2.bcs.u8().parse(value));
|
|
1320
|
-
} else if (baseType === "u16") {
|
|
1321
|
-
returnValues.push(import_bcs2.bcs.u16().parse(value));
|
|
1322
|
-
} else if (baseType === "u32") {
|
|
1323
|
-
returnValues.push(import_bcs2.bcs.u32().parse(value));
|
|
1324
|
-
} else if (baseType === "u64") {
|
|
1325
|
-
returnValues.push(import_bcs2.bcs.u64().parse(value));
|
|
1326
|
-
} else if (baseType === "u128") {
|
|
1327
|
-
returnValues.push(import_bcs2.bcs.u128().parse(value));
|
|
1328
|
-
} else if (baseType === "u256") {
|
|
1329
|
-
returnValues.push(import_bcs2.bcs.u256().parse(value));
|
|
1330
|
-
} else if (baseType === "bool") {
|
|
1331
|
-
returnValues.push(import_bcs2.bcs.bool().parse(value));
|
|
1332
|
-
} else if (baseType === "0x1::ascii::String") {
|
|
1333
|
-
returnValues.push(import_bcs2.bcs.string().parse(value));
|
|
1334
|
-
} else if (baseType === "vector<u8>") {
|
|
1335
|
-
returnValues.push(import_bcs2.bcs.vector(import_bcs2.bcs.u8()).parse(value));
|
|
1336
|
-
} else if (baseType === "0x1::option::Option<u8>") {
|
|
1337
|
-
returnValues.push(import_bcs2.bcs.option(import_bcs2.bcs.u8()).parse(value));
|
|
1338
|
-
}
|
|
1339
|
-
}
|
|
1340
|
-
return returnValues;
|
|
1341
|
-
} else {
|
|
1342
|
-
return void 0;
|
|
1343
|
-
}
|
|
1539
|
+
return this.view(dryResult);
|
|
1344
1540
|
}
|
|
1345
1541
|
async containEntity(worldId, schemaName, entityId) {
|
|
1346
1542
|
const schemaModuleName = `${schemaName}_schema`;
|
|
@@ -1349,18 +1545,11 @@ var Obelisk = class {
|
|
|
1349
1545
|
if (entityId !== void 0) {
|
|
1350
1546
|
params.push(tx.pure.address(entityId));
|
|
1351
1547
|
}
|
|
1352
|
-
const
|
|
1548
|
+
const dryResult = await this.query[schemaModuleName].contains(
|
|
1353
1549
|
tx,
|
|
1354
1550
|
params
|
|
1355
1551
|
);
|
|
1356
|
-
|
|
1357
|
-
const res = getResult.results[0].returnValues[0];
|
|
1358
|
-
let baseValue = res[0];
|
|
1359
|
-
const value = Uint8Array.from(baseValue);
|
|
1360
|
-
return import_bcs2.bcs.bool().parse(value);
|
|
1361
|
-
} else {
|
|
1362
|
-
return void 0;
|
|
1363
|
-
}
|
|
1552
|
+
return this.view(dryResult);
|
|
1364
1553
|
}
|
|
1365
1554
|
// async getEntities(
|
|
1366
1555
|
// worldId: string,
|
|
@@ -1457,54 +1646,13 @@ var Obelisk = class {
|
|
|
1457
1646
|
// const u8Value = Uint8Array.from(value);
|
|
1458
1647
|
// return bcs.de(type, u8Value);
|
|
1459
1648
|
// }
|
|
1460
|
-
async autoFormatDryValue(value) {
|
|
1461
|
-
let returnValues = [];
|
|
1462
|
-
if (value.effects.status.status === "success") {
|
|
1463
|
-
const resultList = value.results[0].returnValues;
|
|
1464
|
-
for (const res of resultList) {
|
|
1465
|
-
let baseValue = res[0];
|
|
1466
|
-
let baseType = res[1];
|
|
1467
|
-
const value2 = Uint8Array.from(baseValue);
|
|
1468
|
-
if (baseType === "address") {
|
|
1469
|
-
const Address = import_bcs2.bcs.bytes(32).transform({
|
|
1470
|
-
// To change the input type, you need to provide a type definition for the input
|
|
1471
|
-
input: (val) => (0, import_bcs2.fromHEX)(val),
|
|
1472
|
-
output: (val) => (0, import_bcs2.toHEX)(val)
|
|
1473
|
-
});
|
|
1474
|
-
returnValues.push(Address.parse(value2));
|
|
1475
|
-
} else if (baseType === "u8") {
|
|
1476
|
-
returnValues.push(import_bcs2.bcs.u8().parse(value2));
|
|
1477
|
-
} else if (baseType === "u16") {
|
|
1478
|
-
returnValues.push(import_bcs2.bcs.u16().parse(value2));
|
|
1479
|
-
} else if (baseType === "u32") {
|
|
1480
|
-
returnValues.push(import_bcs2.bcs.u32().parse(value2));
|
|
1481
|
-
} else if (baseType === "u64") {
|
|
1482
|
-
returnValues.push(import_bcs2.bcs.u64().parse(value2));
|
|
1483
|
-
} else if (baseType === "u128") {
|
|
1484
|
-
returnValues.push(import_bcs2.bcs.u128().parse(value2));
|
|
1485
|
-
} else if (baseType === "u256") {
|
|
1486
|
-
returnValues.push(import_bcs2.bcs.u256().parse(value2));
|
|
1487
|
-
} else if (baseType === "bool") {
|
|
1488
|
-
returnValues.push(import_bcs2.bcs.bool().parse(value2));
|
|
1489
|
-
} else if (baseType === "0x1::ascii::String") {
|
|
1490
|
-
returnValues.push(import_bcs2.bcs.string().parse(value2));
|
|
1491
|
-
} else if (baseType === "vector<u8>") {
|
|
1492
|
-
returnValues.push(import_bcs2.bcs.vector(import_bcs2.bcs.u8()).parse(value2));
|
|
1493
|
-
} else if (baseType === "0x1::option::Option<u8>") {
|
|
1494
|
-
returnValues.push(import_bcs2.bcs.option(import_bcs2.bcs.u8()).parse(value2));
|
|
1495
|
-
}
|
|
1496
|
-
}
|
|
1497
|
-
return returnValues;
|
|
1498
|
-
} else {
|
|
1499
|
-
return void 0;
|
|
1500
|
-
}
|
|
1501
|
-
}
|
|
1502
1649
|
};
|
|
1503
1650
|
_query = new WeakMap();
|
|
1504
1651
|
_tx = new WeakMap();
|
|
1505
|
-
|
|
1652
|
+
_object = new WeakMap();
|
|
1506
1653
|
_exec = new WeakMap();
|
|
1507
1654
|
_read = new WeakMap();
|
|
1655
|
+
_bcs = new WeakMap();
|
|
1508
1656
|
|
|
1509
1657
|
// src/libs/multiSig/client.ts
|
|
1510
1658
|
var import_multisig = require("@mysten/sui/multisig");
|