@0xobelisk/sui-client 0.5.17 → 0.5.19
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.d.ts +9 -8
- package/dist/index.js +309 -208
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +299 -201
- package/dist/index.mjs.map +1 -1
- package/dist/libs/multiSig/client.d.ts +2 -2
- package/dist/libs/multiSig/publickey.d.ts +1 -1
- package/dist/libs/suiAccountManager/index.d.ts +1 -1
- package/dist/libs/suiAccountManager/keypair.d.ts +1 -1
- package/dist/libs/suiContractFactory/index.d.ts +1 -1
- package/dist/libs/suiContractFactory/types.d.ts +1 -1
- package/dist/libs/suiInteractor/suiInteractor.d.ts +5 -5
- package/dist/libs/suiModel/suiOwnedObject.d.ts +2 -2
- package/dist/libs/suiModel/suiSharedObject.d.ts +1 -1
- package/dist/libs/suiTxBuilder/index.d.ts +365 -160
- package/dist/libs/suiTxBuilder/util.d.ts +8 -17
- package/dist/metadata/index.d.ts +1 -1
- package/dist/obelisk.d.ts +16 -12
- package/dist/types/index.d.ts +65 -15
- package/package.json +11 -8
- package/src/index.ts +9 -8
- package/src/libs/multiSig/client.ts +2 -2
- package/src/libs/multiSig/publickey.ts +3 -3
- package/src/libs/suiAccountManager/index.ts +2 -2
- package/src/libs/suiAccountManager/keypair.ts +1 -1
- package/src/libs/suiAccountManager/util.ts +1 -1
- package/src/libs/suiContractFactory/index.ts +1 -1
- package/src/libs/suiContractFactory/types.ts +1 -1
- package/src/libs/suiInteractor/index.ts +0 -1
- package/src/libs/suiInteractor/suiInteractor.ts +4 -4
- package/src/libs/suiModel/suiOwnedObject.ts +5 -3
- package/src/libs/suiModel/suiSharedObject.ts +4 -2
- package/src/libs/suiTxBuilder/index.ts +120 -108
- package/src/libs/suiTxBuilder/util.ts +55 -48
- package/src/metadata/index.ts +2 -3
- package/src/obelisk.ts +199 -90
- package/src/types/index.ts +82 -44
package/dist/index.js
CHANGED
|
@@ -44,33 +44,35 @@ var __privateAdd = (obj, member, value) => {
|
|
|
44
44
|
// src/index.ts
|
|
45
45
|
var src_exports = {};
|
|
46
46
|
__export(src_exports, {
|
|
47
|
-
|
|
47
|
+
BcsType: () => import_bcs3.BcsType,
|
|
48
48
|
MultiSigClient: () => MultiSigClient,
|
|
49
49
|
Obelisk: () => Obelisk,
|
|
50
50
|
SuiAccountManager: () => SuiAccountManager,
|
|
51
51
|
SuiContractFactory: () => SuiContractFactory,
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
SuiTx: () => SuiTx,
|
|
53
|
+
bcs: () => import_bcs3.bcs,
|
|
54
54
|
loadMetadata: () => loadMetadata
|
|
55
55
|
});
|
|
56
56
|
module.exports = __toCommonJS(src_exports);
|
|
57
|
-
__reExport(src_exports, require("@mysten/sui
|
|
58
|
-
__reExport(src_exports, require("@mysten/sui
|
|
59
|
-
__reExport(src_exports, require("@mysten/sui
|
|
60
|
-
__reExport(src_exports, require("@mysten/sui
|
|
61
|
-
__reExport(src_exports, require("@mysten/sui
|
|
62
|
-
__reExport(src_exports, require("@mysten/sui
|
|
63
|
-
|
|
57
|
+
__reExport(src_exports, require("@mysten/sui/client"), module.exports);
|
|
58
|
+
__reExport(src_exports, require("@mysten/sui/utils"), module.exports);
|
|
59
|
+
__reExport(src_exports, require("@mysten/sui/transactions"), module.exports);
|
|
60
|
+
__reExport(src_exports, require("@mysten/sui/bcs"), module.exports);
|
|
61
|
+
__reExport(src_exports, require("@mysten/sui/keypairs/ed25519"), module.exports);
|
|
62
|
+
__reExport(src_exports, require("@mysten/sui/keypairs/secp256k1"), module.exports);
|
|
63
|
+
__reExport(src_exports, require("@mysten/sui/keypairs/secp256r1"), module.exports);
|
|
64
|
+
var import_bcs3 = require("@mysten/bcs");
|
|
64
65
|
|
|
65
66
|
// src/obelisk.ts
|
|
66
|
-
var
|
|
67
|
-
var
|
|
67
|
+
var import_keccak256 = __toESM(require("keccak256"));
|
|
68
|
+
var import_client2 = require("@mysten/sui/client");
|
|
69
|
+
var import_transactions3 = require("@mysten/sui/transactions");
|
|
68
70
|
|
|
69
71
|
// src/libs/suiAccountManager/index.ts
|
|
70
|
-
var import_ed255192 = require("@mysten/sui
|
|
72
|
+
var import_ed255192 = require("@mysten/sui/keypairs/ed25519");
|
|
71
73
|
|
|
72
74
|
// src/libs/suiAccountManager/keypair.ts
|
|
73
|
-
var import_ed25519 = require("@mysten/sui
|
|
75
|
+
var import_ed25519 = require("@mysten/sui/keypairs/ed25519");
|
|
74
76
|
var getDerivePathForSUI = (derivePathParams = {}) => {
|
|
75
77
|
const {
|
|
76
78
|
accountIndex = 0,
|
|
@@ -85,7 +87,7 @@ var getKeyPair = (mnemonics, derivePathParams = {}) => {
|
|
|
85
87
|
};
|
|
86
88
|
|
|
87
89
|
// src/libs/suiAccountManager/util.ts
|
|
88
|
-
var import_utils = require("@mysten/sui
|
|
90
|
+
var import_utils = require("@mysten/sui/utils");
|
|
89
91
|
var isHex = (str) => /^0x[0-9a-fA-F]+$|^[0-9a-fA-F]+$/.test(str);
|
|
90
92
|
var isBase64 = (str) => /^[a-zA-Z0-9+/]+={0,2}$/g.test(str);
|
|
91
93
|
var fromHEX = (hexStr) => {
|
|
@@ -129,7 +131,7 @@ var generateMnemonic = (numberOfWords = 24) => {
|
|
|
129
131
|
};
|
|
130
132
|
|
|
131
133
|
// src/libs/suiAccountManager/index.ts
|
|
132
|
-
var import_cryptography = require("@mysten/sui
|
|
134
|
+
var import_cryptography = require("@mysten/sui/cryptography");
|
|
133
135
|
var SuiAccountManager = class {
|
|
134
136
|
/**
|
|
135
137
|
* Support the following ways to init the SuiToolkit:
|
|
@@ -196,14 +198,13 @@ var SuiAccountManager = class {
|
|
|
196
198
|
};
|
|
197
199
|
|
|
198
200
|
// src/libs/suiTxBuilder/index.ts
|
|
199
|
-
var import_transactions2 = require("@mysten/sui
|
|
200
|
-
var import_utils3 = require("@mysten/sui
|
|
201
|
+
var import_transactions2 = require("@mysten/sui/transactions");
|
|
202
|
+
var import_utils3 = require("@mysten/sui/utils");
|
|
201
203
|
|
|
202
204
|
// src/libs/suiTxBuilder/util.ts
|
|
203
|
-
var import_utils2 = require("@mysten/sui
|
|
204
|
-
var import_transactions = require("@mysten/sui
|
|
205
|
-
var import_bcs = require("@mysten/
|
|
206
|
-
var import_bcs2 = require("@mysten/bcs");
|
|
205
|
+
var import_utils2 = require("@mysten/sui/utils");
|
|
206
|
+
var import_transactions = require("@mysten/sui/transactions");
|
|
207
|
+
var import_bcs = require("@mysten/bcs");
|
|
207
208
|
var getDefaultSuiInputType = (value) => {
|
|
208
209
|
if (typeof value === "string" && (0, import_utils2.isValidSuiObjectId)(value)) {
|
|
209
210
|
return "object";
|
|
@@ -223,17 +224,18 @@ function makeVecParam(txBlock, args, type) {
|
|
|
223
224
|
const STRUCT_REGEX = /^([^:]+)::([^:]+)::([^<]+)(<(.+)>)?/;
|
|
224
225
|
type = type || defaultSuiType;
|
|
225
226
|
if (type === "object") {
|
|
226
|
-
const
|
|
227
|
+
const elements = args.map(
|
|
227
228
|
(arg) => typeof arg === "string" && (0, import_utils2.isValidSuiObjectId)(arg) ? txBlock.object((0, import_utils2.normalizeSuiObjectId)(arg)) : convertObjArg(txBlock, arg)
|
|
228
229
|
);
|
|
229
|
-
return txBlock.makeMoveVec({
|
|
230
|
+
return txBlock.makeMoveVec({ elements });
|
|
230
231
|
} else if (typeof type === "string" && !VECTOR_REGEX.test(type) && !STRUCT_REGEX.test(type)) {
|
|
231
|
-
|
|
232
|
+
const bcsSchema = (0, import_transactions.getPureBcsSchema)(type);
|
|
233
|
+
return txBlock.pure(import_bcs.bcs.vector(bcsSchema).serialize(args));
|
|
232
234
|
} else {
|
|
233
|
-
const
|
|
235
|
+
const elements = args.map(
|
|
234
236
|
(arg) => convertObjArg(txBlock, arg)
|
|
235
237
|
);
|
|
236
|
-
return txBlock.makeMoveVec({
|
|
238
|
+
return txBlock.makeMoveVec({ elements, type });
|
|
237
239
|
}
|
|
238
240
|
}
|
|
239
241
|
function isMoveVecArg(arg) {
|
|
@@ -246,29 +248,21 @@ function isMoveVecArg(arg) {
|
|
|
246
248
|
}
|
|
247
249
|
function convertArgs(txBlock, args) {
|
|
248
250
|
return args.map((arg) => {
|
|
249
|
-
if (
|
|
250
|
-
return txBlock.
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
} else if (isMoveVecArg(arg)) {
|
|
251
|
+
if (arg instanceof import_bcs.SerializedBcs || (0, import_bcs.isSerializedBcs)(arg)) {
|
|
252
|
+
return txBlock.pure(arg);
|
|
253
|
+
}
|
|
254
|
+
if (isMoveVecArg(arg)) {
|
|
254
255
|
const vecType = "vecType" in arg;
|
|
255
256
|
return vecType ? makeVecParam(txBlock, arg.value, arg.vecType) : makeVecParam(txBlock, arg);
|
|
256
|
-
} else if ((0, import_bcs2.isSerializedBcs)(arg)) {
|
|
257
|
-
return arg;
|
|
258
|
-
} else {
|
|
259
|
-
return txBlock.pure(arg);
|
|
260
257
|
}
|
|
258
|
+
return arg;
|
|
261
259
|
});
|
|
262
260
|
}
|
|
263
261
|
function convertAddressArg(txBlock, arg) {
|
|
264
262
|
if (typeof arg === "string" && (0, import_utils2.isValidSuiAddress)(arg)) {
|
|
265
263
|
return txBlock.pure.address((0, import_utils2.normalizeSuiAddress)(arg));
|
|
266
|
-
} else if (typeof arg == "object" && !(0, import_bcs2.isSerializedBcs)(arg) && !(0, import_bcs.isPureArg)(arg)) {
|
|
267
|
-
return convertObjArg(txBlock, arg);
|
|
268
|
-
} else if ((0, import_bcs.isPureArg)(arg)) {
|
|
269
|
-
return txBlock.pure(arg);
|
|
270
264
|
} else {
|
|
271
|
-
return arg;
|
|
265
|
+
return convertArgs(txBlock, [arg])[0];
|
|
272
266
|
}
|
|
273
267
|
}
|
|
274
268
|
function convertObjArg(txb, arg) {
|
|
@@ -282,123 +276,140 @@ function convertObjArg(txb, arg) {
|
|
|
282
276
|
return txb.sharedObjectRef(arg);
|
|
283
277
|
}
|
|
284
278
|
if ("Object" in arg) {
|
|
285
|
-
if ("
|
|
286
|
-
return txb.object(import_transactions.Inputs.ObjectRef(arg.Object.
|
|
287
|
-
} else if ("
|
|
288
|
-
return txb.object(import_transactions.Inputs.SharedObjectRef(arg.Object.
|
|
279
|
+
if ("ImmOrOwnedObject" in arg.Object) {
|
|
280
|
+
return txb.object(import_transactions.Inputs.ObjectRef(arg.Object.ImmOrOwnedObject));
|
|
281
|
+
} else if ("SharedObject" in arg.Object) {
|
|
282
|
+
return txb.object(import_transactions.Inputs.SharedObjectRef(arg.Object.SharedObject));
|
|
289
283
|
} else {
|
|
290
284
|
throw new Error("Invalid argument type");
|
|
291
285
|
}
|
|
292
286
|
}
|
|
293
|
-
if ("
|
|
287
|
+
if (typeof arg === "function") {
|
|
288
|
+
return arg;
|
|
289
|
+
}
|
|
290
|
+
if ("GasCoin" in arg || "Input" in arg || "Result" in arg || "NestedResult" in arg) {
|
|
294
291
|
return arg;
|
|
295
292
|
}
|
|
296
293
|
throw new Error("Invalid argument type");
|
|
297
294
|
}
|
|
295
|
+
function convertAmounts(txBlock, amounts) {
|
|
296
|
+
return amounts.map((amount) => {
|
|
297
|
+
if (typeof amount === "number" || typeof amount === "bigint") {
|
|
298
|
+
return amount;
|
|
299
|
+
} else {
|
|
300
|
+
return convertArgs(txBlock, [amount])[0];
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
}
|
|
298
304
|
|
|
299
305
|
// src/libs/suiTxBuilder/index.ts
|
|
300
|
-
var
|
|
306
|
+
var SuiTx = class {
|
|
301
307
|
constructor(transaction) {
|
|
302
|
-
|
|
308
|
+
if (transaction !== void 0) {
|
|
309
|
+
this.tx = import_transactions2.Transaction.from(transaction);
|
|
310
|
+
} else {
|
|
311
|
+
this.tx = new import_transactions2.Transaction();
|
|
312
|
+
}
|
|
303
313
|
}
|
|
304
314
|
/* Directly wrap methods and properties of TransactionBlock */
|
|
305
315
|
get gas() {
|
|
306
|
-
return this.
|
|
316
|
+
return this.tx.gas;
|
|
307
317
|
}
|
|
308
318
|
get blockData() {
|
|
309
|
-
return this.
|
|
319
|
+
return this.tx.blockData;
|
|
320
|
+
}
|
|
321
|
+
autoPure(value, type) {
|
|
322
|
+
if (type === void 0) {
|
|
323
|
+
return convertArgs(this.tx, [value]);
|
|
324
|
+
}
|
|
325
|
+
return;
|
|
310
326
|
}
|
|
311
327
|
address(value) {
|
|
312
|
-
return this.
|
|
328
|
+
return this.tx.pure.address(value);
|
|
313
329
|
}
|
|
314
|
-
pure(
|
|
315
|
-
return this.
|
|
330
|
+
get pure() {
|
|
331
|
+
return this.tx.pure.bind(this.tx);
|
|
316
332
|
}
|
|
317
333
|
object(value) {
|
|
318
|
-
return this.
|
|
334
|
+
return this.tx.object(value);
|
|
319
335
|
}
|
|
320
336
|
objectRef(ref) {
|
|
321
|
-
return this.
|
|
337
|
+
return this.tx.objectRef(ref);
|
|
322
338
|
}
|
|
323
339
|
sharedObjectRef(ref) {
|
|
324
|
-
return this.
|
|
340
|
+
return this.tx.sharedObjectRef(ref);
|
|
325
341
|
}
|
|
326
342
|
setSender(sender) {
|
|
327
|
-
return this.
|
|
343
|
+
return this.tx.setSender(sender);
|
|
328
344
|
}
|
|
329
345
|
setSenderIfNotSet(sender) {
|
|
330
|
-
return this.
|
|
346
|
+
return this.tx.setSenderIfNotSet(sender);
|
|
331
347
|
}
|
|
332
348
|
setExpiration(expiration) {
|
|
333
|
-
return this.
|
|
349
|
+
return this.tx.setExpiration(expiration);
|
|
334
350
|
}
|
|
335
351
|
setGasPrice(price) {
|
|
336
|
-
return this.
|
|
352
|
+
return this.tx.setGasPrice(price);
|
|
337
353
|
}
|
|
338
354
|
setGasBudget(budget) {
|
|
339
|
-
return this.
|
|
355
|
+
return this.tx.setGasBudget(budget);
|
|
340
356
|
}
|
|
341
357
|
setGasOwner(owner) {
|
|
342
|
-
return this.
|
|
358
|
+
return this.tx.setGasOwner(owner);
|
|
343
359
|
}
|
|
344
360
|
setGasPayment(payments) {
|
|
345
|
-
return this.
|
|
361
|
+
return this.tx.setGasPayment(payments);
|
|
346
362
|
}
|
|
347
363
|
serialize() {
|
|
348
|
-
return this.
|
|
364
|
+
return this.tx.serialize();
|
|
365
|
+
}
|
|
366
|
+
toJSON() {
|
|
367
|
+
return this.tx.toJSON();
|
|
349
368
|
}
|
|
350
369
|
sign(params) {
|
|
351
|
-
return this.
|
|
370
|
+
return this.tx.sign(params);
|
|
352
371
|
}
|
|
353
372
|
build(params = {}) {
|
|
354
|
-
return this.
|
|
373
|
+
return this.tx.build(params);
|
|
355
374
|
}
|
|
356
375
|
getDigest(params = {}) {
|
|
357
|
-
return this.
|
|
376
|
+
return this.tx.getDigest(params);
|
|
358
377
|
}
|
|
359
378
|
add(...args) {
|
|
360
|
-
return this.
|
|
379
|
+
return this.tx.add(...args);
|
|
361
380
|
}
|
|
362
381
|
publish({
|
|
363
382
|
modules,
|
|
364
383
|
dependencies
|
|
365
384
|
}) {
|
|
366
|
-
return this.
|
|
385
|
+
return this.tx.publish({ modules, dependencies });
|
|
367
386
|
}
|
|
368
|
-
upgrade({
|
|
369
|
-
|
|
370
|
-
dependencies,
|
|
371
|
-
packageId,
|
|
372
|
-
ticket
|
|
373
|
-
}) {
|
|
374
|
-
return this.txBlock.upgrade({ modules, dependencies, packageId, ticket });
|
|
387
|
+
upgrade(...args) {
|
|
388
|
+
return this.tx.upgrade(...args);
|
|
375
389
|
}
|
|
376
|
-
makeMoveVec({
|
|
377
|
-
|
|
378
|
-
type
|
|
379
|
-
}) {
|
|
380
|
-
return this.txBlock.makeMoveVec({ objects, type });
|
|
390
|
+
makeMoveVec(...args) {
|
|
391
|
+
return this.tx.makeMoveVec(...args);
|
|
381
392
|
}
|
|
382
393
|
/* Override methods of TransactionBlock */
|
|
383
394
|
transferObjects(objects, address) {
|
|
384
|
-
return this.
|
|
385
|
-
objects.map((object) => convertObjArg(this.
|
|
386
|
-
convertAddressArg(this.
|
|
395
|
+
return this.tx.transferObjects(
|
|
396
|
+
objects.map((object) => convertObjArg(this.tx, object)),
|
|
397
|
+
convertAddressArg(this.tx, address)
|
|
387
398
|
);
|
|
388
399
|
}
|
|
389
400
|
splitCoins(coin, amounts) {
|
|
390
|
-
const res = this.
|
|
391
|
-
convertObjArg(this.
|
|
392
|
-
convertArgs(this.
|
|
401
|
+
const res = this.tx.splitCoins(
|
|
402
|
+
convertObjArg(this.tx, coin),
|
|
403
|
+
convertArgs(this.tx, amounts)
|
|
393
404
|
);
|
|
394
405
|
return amounts.map((_, i) => res[i]);
|
|
395
406
|
}
|
|
396
407
|
mergeCoins(destination, sources) {
|
|
397
|
-
const destinationObject = convertObjArg(this.
|
|
408
|
+
const destinationObject = convertObjArg(this.tx, destination);
|
|
398
409
|
const sourceObjects = sources.map(
|
|
399
|
-
(source) => convertObjArg(this.
|
|
410
|
+
(source) => convertObjArg(this.tx, source)
|
|
400
411
|
);
|
|
401
|
-
return this.
|
|
412
|
+
return this.tx.mergeCoins(destinationObject, sourceObjects);
|
|
402
413
|
}
|
|
403
414
|
/**
|
|
404
415
|
* @description Move call
|
|
@@ -413,8 +424,8 @@ var SuiTxBlock = class {
|
|
|
413
424
|
throw new Error(
|
|
414
425
|
"Invalid target format. Expected `${string}::${string}::${string}`"
|
|
415
426
|
);
|
|
416
|
-
const convertedArgs = convertArgs(this.
|
|
417
|
-
return this.
|
|
427
|
+
const convertedArgs = convertArgs(this.tx, args);
|
|
428
|
+
return this.tx.moveCall({
|
|
418
429
|
target,
|
|
419
430
|
arguments: convertedArgs,
|
|
420
431
|
typeArguments: typeArgs
|
|
@@ -427,15 +438,17 @@ var SuiTxBlock = class {
|
|
|
427
438
|
"transferSuiToMany: recipients.length !== amounts.length"
|
|
428
439
|
);
|
|
429
440
|
}
|
|
430
|
-
const coins = this.
|
|
431
|
-
this.
|
|
432
|
-
|
|
441
|
+
const coins = this.tx.splitCoins(
|
|
442
|
+
this.tx.gas,
|
|
443
|
+
amounts.map(
|
|
444
|
+
(amount) => typeof amount === "number" || typeof amount === "bigint" ? amount : convertArgs(this.tx, [amount])[0]
|
|
445
|
+
)
|
|
433
446
|
);
|
|
434
447
|
const recipientObjects = recipients.map(
|
|
435
|
-
(recipient) => convertAddressArg(this.
|
|
448
|
+
(recipient) => convertAddressArg(this.tx, recipient)
|
|
436
449
|
);
|
|
437
450
|
recipientObjects.forEach((address, index) => {
|
|
438
|
-
this.
|
|
451
|
+
this.tx.transferObjects([coins[index]], address);
|
|
439
452
|
});
|
|
440
453
|
return this;
|
|
441
454
|
}
|
|
@@ -443,32 +456,28 @@ var SuiTxBlock = class {
|
|
|
443
456
|
return this.transferSuiToMany([address], [amount]);
|
|
444
457
|
}
|
|
445
458
|
takeAmountFromCoins(coins, amount) {
|
|
446
|
-
const coinObjects = coins.map((coin) => convertObjArg(this.
|
|
459
|
+
const coinObjects = coins.map((coin) => convertObjArg(this.tx, coin));
|
|
447
460
|
const mergedCoin = coinObjects[0];
|
|
448
461
|
if (coins.length > 1) {
|
|
449
|
-
this.
|
|
462
|
+
this.tx.mergeCoins(mergedCoin, coinObjects.slice(1));
|
|
450
463
|
}
|
|
451
|
-
const [sendCoin] = this.
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
);
|
|
464
|
+
const [sendCoin] = this.tx.splitCoins(mergedCoin, [
|
|
465
|
+
typeof amount === "number" || typeof amount === "bigint" ? amount : convertArgs(this.tx, [amount])[0]
|
|
466
|
+
]);
|
|
455
467
|
return [sendCoin, mergedCoin];
|
|
456
468
|
}
|
|
457
469
|
splitSUIFromGas(amounts) {
|
|
458
|
-
return this.
|
|
459
|
-
this.txBlock.gas,
|
|
460
|
-
convertArgs(this.txBlock, amounts)
|
|
461
|
-
);
|
|
470
|
+
return this.tx.splitCoins(this.tx.gas, convertArgs(this.tx, amounts));
|
|
462
471
|
}
|
|
463
472
|
splitMultiCoins(coins, amounts) {
|
|
464
|
-
const coinObjects = coins.map((coin) => convertObjArg(this.
|
|
473
|
+
const coinObjects = coins.map((coin) => convertObjArg(this.tx, coin));
|
|
465
474
|
const mergedCoin = coinObjects[0];
|
|
466
475
|
if (coins.length > 1) {
|
|
467
|
-
this.
|
|
476
|
+
this.tx.mergeCoins(mergedCoin, coinObjects.slice(1));
|
|
468
477
|
}
|
|
469
|
-
const splitedCoins = this.
|
|
478
|
+
const splitedCoins = this.tx.splitCoins(
|
|
470
479
|
mergedCoin,
|
|
471
|
-
|
|
480
|
+
convertAmounts(this.tx, amounts)
|
|
472
481
|
);
|
|
473
482
|
return { splitedCoins, mergedCoin };
|
|
474
483
|
}
|
|
@@ -478,45 +487,42 @@ var SuiTxBlock = class {
|
|
|
478
487
|
"transferSuiToMany: recipients.length !== amounts.length"
|
|
479
488
|
);
|
|
480
489
|
}
|
|
481
|
-
const coinObjects = coins.map((coin) => convertObjArg(this.
|
|
490
|
+
const coinObjects = coins.map((coin) => convertObjArg(this.tx, coin));
|
|
482
491
|
const { splitedCoins, mergedCoin } = this.splitMultiCoins(
|
|
483
492
|
coinObjects,
|
|
484
493
|
amounts
|
|
485
494
|
);
|
|
486
495
|
const recipientObjects = recipients.map(
|
|
487
|
-
(recipient) => convertAddressArg(this.
|
|
496
|
+
(recipient) => convertAddressArg(this.tx, recipient)
|
|
488
497
|
);
|
|
489
498
|
recipientObjects.forEach((address, index) => {
|
|
490
|
-
this.
|
|
499
|
+
this.tx.transferObjects([splitedCoins[index]], address);
|
|
491
500
|
});
|
|
492
|
-
this.
|
|
493
|
-
[mergedCoin],
|
|
494
|
-
convertAddressArg(this.txBlock, sender)
|
|
495
|
-
);
|
|
501
|
+
this.tx.transferObjects([mergedCoin], convertAddressArg(this.tx, sender));
|
|
496
502
|
return this;
|
|
497
503
|
}
|
|
498
504
|
transferCoin(coins, sender, recipient, amount) {
|
|
499
505
|
return this.transferCoinToMany(coins, sender, [recipient], [amount]);
|
|
500
506
|
}
|
|
501
507
|
stakeSui(amount, validatorAddr) {
|
|
502
|
-
const [stakeCoin] = this.
|
|
503
|
-
this.
|
|
504
|
-
|
|
508
|
+
const [stakeCoin] = this.tx.splitCoins(
|
|
509
|
+
this.tx.gas,
|
|
510
|
+
convertAmounts(this.tx, [amount])
|
|
505
511
|
);
|
|
506
|
-
return this.
|
|
512
|
+
return this.tx.moveCall({
|
|
507
513
|
target: "0x3::sui_system::request_add_stake",
|
|
508
|
-
arguments: convertArgs(this.
|
|
509
|
-
import_utils3.SUI_SYSTEM_STATE_OBJECT_ID,
|
|
514
|
+
arguments: convertArgs(this.tx, [
|
|
515
|
+
this.tx.object(import_utils3.SUI_SYSTEM_STATE_OBJECT_ID),
|
|
510
516
|
stakeCoin,
|
|
511
|
-
this.
|
|
517
|
+
convertAddressArg(this.tx, validatorAddr)
|
|
512
518
|
])
|
|
513
519
|
});
|
|
514
520
|
}
|
|
515
521
|
};
|
|
516
522
|
|
|
517
523
|
// src/libs/suiInteractor/suiInteractor.ts
|
|
518
|
-
var import_client = require("@mysten/sui
|
|
519
|
-
var import_faucet = require("@mysten/sui
|
|
524
|
+
var import_client = require("@mysten/sui/client");
|
|
525
|
+
var import_faucet = require("@mysten/sui/faucet");
|
|
520
526
|
|
|
521
527
|
// src/libs/suiModel/suiOwnedObject.ts
|
|
522
528
|
var SuiOwnedObject = class {
|
|
@@ -538,8 +544,10 @@ var SuiOwnedObject = class {
|
|
|
538
544
|
return this.objectId;
|
|
539
545
|
}
|
|
540
546
|
return {
|
|
547
|
+
$kind: "Object",
|
|
541
548
|
Object: {
|
|
542
|
-
|
|
549
|
+
$kind: "ImmOrOwnedObject",
|
|
550
|
+
ImmOrOwnedObject: {
|
|
543
551
|
objectId: this.objectId,
|
|
544
552
|
version: this.version,
|
|
545
553
|
digest: this.digest
|
|
@@ -578,8 +586,10 @@ var SuiSharedObject = class {
|
|
|
578
586
|
return this.objectId;
|
|
579
587
|
}
|
|
580
588
|
return {
|
|
589
|
+
$kind: "Object",
|
|
581
590
|
Object: {
|
|
582
|
-
|
|
591
|
+
$kind: "SharedObject",
|
|
592
|
+
SharedObject: {
|
|
583
593
|
objectId: this.objectId,
|
|
584
594
|
initialSharedVersion: this.initialSharedVersion,
|
|
585
595
|
mutable
|
|
@@ -939,8 +949,7 @@ function numberToAddressHex(num) {
|
|
|
939
949
|
}
|
|
940
950
|
|
|
941
951
|
// src/obelisk.ts
|
|
942
|
-
var
|
|
943
|
-
var import_bcs3 = require("@mysten/bcs");
|
|
952
|
+
var import_bcs2 = require("@mysten/bcs");
|
|
944
953
|
function isUndefined(value) {
|
|
945
954
|
return value === void 0;
|
|
946
955
|
}
|
|
@@ -965,7 +974,7 @@ function createTx(meta, fn) {
|
|
|
965
974
|
}
|
|
966
975
|
);
|
|
967
976
|
}
|
|
968
|
-
var _query, _tx, _exec, _read;
|
|
977
|
+
var _query, _tx, _struct, _exec, _read;
|
|
969
978
|
var Obelisk = class {
|
|
970
979
|
/**
|
|
971
980
|
* Support the following ways to init the ObeliskClient:
|
|
@@ -989,6 +998,7 @@ var Obelisk = class {
|
|
|
989
998
|
} = {}) {
|
|
990
999
|
__privateAdd(this, _query, {});
|
|
991
1000
|
__privateAdd(this, _tx, {});
|
|
1001
|
+
__privateAdd(this, _struct, {});
|
|
992
1002
|
__privateAdd(this, _exec, async (meta, tx, params, typeArguments, isRaw) => {
|
|
993
1003
|
if (isRaw === true) {
|
|
994
1004
|
return tx.moveCall({
|
|
@@ -1025,33 +1035,37 @@ var Obelisk = class {
|
|
|
1025
1035
|
this.packageId = packageId;
|
|
1026
1036
|
if (metadata !== void 0) {
|
|
1027
1037
|
this.metadata = metadata;
|
|
1028
|
-
Object.values(metadata).forEach(
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1038
|
+
Object.values(metadata).forEach(
|
|
1039
|
+
(moudlevalue) => {
|
|
1040
|
+
const data = moudlevalue;
|
|
1041
|
+
const moduleName = data.name;
|
|
1042
|
+
Object.entries(data.exposedFunctions).forEach(
|
|
1043
|
+
([funcName, funcvalue]) => {
|
|
1044
|
+
const meta = funcvalue;
|
|
1045
|
+
meta.moduleName = moduleName;
|
|
1046
|
+
meta.funcName = funcName;
|
|
1047
|
+
if (isUndefined(__privateGet(this, _query)[moduleName])) {
|
|
1048
|
+
__privateGet(this, _query)[moduleName] = {};
|
|
1049
|
+
}
|
|
1050
|
+
if (isUndefined(__privateGet(this, _query)[moduleName][funcName])) {
|
|
1051
|
+
__privateGet(this, _query)[moduleName][funcName] = createQuery(
|
|
1052
|
+
meta,
|
|
1053
|
+
(tx, p, typeArguments, isRaw) => __privateGet(this, _read).call(this, meta, tx, p, typeArguments, isRaw)
|
|
1054
|
+
);
|
|
1055
|
+
}
|
|
1056
|
+
if (isUndefined(__privateGet(this, _tx)[moduleName])) {
|
|
1057
|
+
__privateGet(this, _tx)[moduleName] = {};
|
|
1058
|
+
}
|
|
1059
|
+
if (isUndefined(__privateGet(this, _tx)[moduleName][funcName])) {
|
|
1060
|
+
__privateGet(this, _tx)[moduleName][funcName] = createTx(
|
|
1061
|
+
meta,
|
|
1062
|
+
(tx, p, typeArguments, isRaw) => __privateGet(this, _exec).call(this, meta, tx, p, typeArguments, isRaw)
|
|
1063
|
+
);
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
);
|
|
1067
|
+
}
|
|
1068
|
+
);
|
|
1055
1069
|
}
|
|
1056
1070
|
this.contractFactory = new SuiContractFactory({
|
|
1057
1071
|
packageId,
|
|
@@ -1064,6 +1078,9 @@ var Obelisk = class {
|
|
|
1064
1078
|
get tx() {
|
|
1065
1079
|
return __privateGet(this, _tx);
|
|
1066
1080
|
}
|
|
1081
|
+
get struct() {
|
|
1082
|
+
return __privateGet(this, _struct);
|
|
1083
|
+
}
|
|
1067
1084
|
/**
|
|
1068
1085
|
* if derivePathParams is not provided or mnemonics is empty, it will return the keypair.
|
|
1069
1086
|
* else:
|
|
@@ -1096,11 +1113,20 @@ var Obelisk = class {
|
|
|
1096
1113
|
getMetadata() {
|
|
1097
1114
|
return this.contractFactory.metadata;
|
|
1098
1115
|
}
|
|
1116
|
+
getNetwork() {
|
|
1117
|
+
return this.suiInteractor.network;
|
|
1118
|
+
}
|
|
1099
1119
|
/**
|
|
1100
1120
|
* Request some SUI from faucet
|
|
1101
1121
|
* @Returns {Promise<boolean>}, true if the request is successful, false otherwise.
|
|
1102
1122
|
*/
|
|
1103
|
-
async requestFaucet(address, network) {
|
|
1123
|
+
async requestFaucet(address, network, derivePathParams) {
|
|
1124
|
+
if (address === void 0) {
|
|
1125
|
+
address = this.accountManager.getAddress(derivePathParams);
|
|
1126
|
+
}
|
|
1127
|
+
if (network === void 0) {
|
|
1128
|
+
network = this.getNetwork();
|
|
1129
|
+
}
|
|
1104
1130
|
return this.suiInteractor.requestFaucet(address, network);
|
|
1105
1131
|
}
|
|
1106
1132
|
async getBalance(coinType, derivePathParams) {
|
|
@@ -1124,18 +1150,21 @@ var Obelisk = class {
|
|
|
1124
1150
|
return this.suiInteractor.getObjects(objectIds);
|
|
1125
1151
|
}
|
|
1126
1152
|
async signTxn(tx, derivePathParams) {
|
|
1127
|
-
if (tx instanceof
|
|
1153
|
+
if (tx instanceof SuiTx || tx instanceof import_transactions3.Transaction) {
|
|
1128
1154
|
tx.setSender(this.getAddress(derivePathParams));
|
|
1129
1155
|
}
|
|
1130
|
-
const txBlock = tx instanceof
|
|
1131
|
-
const txBytes = txBlock instanceof import_transactions3.
|
|
1156
|
+
const txBlock = tx instanceof SuiTx ? tx.tx : tx;
|
|
1157
|
+
const txBytes = txBlock instanceof import_transactions3.Transaction ? await txBlock.build({ client: this.client() }) : txBlock;
|
|
1132
1158
|
const keyPair = this.getKeypair(derivePathParams);
|
|
1133
|
-
return await keyPair.
|
|
1159
|
+
return await keyPair.signTransaction(txBytes);
|
|
1134
1160
|
}
|
|
1135
1161
|
async signAndSendTxn(tx, derivePathParams) {
|
|
1136
1162
|
const { bytes, signature } = await this.signTxn(tx, derivePathParams);
|
|
1137
1163
|
return this.suiInteractor.sendTx(bytes, signature);
|
|
1138
1164
|
}
|
|
1165
|
+
async sendTxn(transactionBlock, signature) {
|
|
1166
|
+
return this.suiInteractor.sendTx(transactionBlock, signature);
|
|
1167
|
+
}
|
|
1139
1168
|
/**
|
|
1140
1169
|
* Transfer the given amount of SUI to the recipient
|
|
1141
1170
|
* @param recipient
|
|
@@ -1143,7 +1172,7 @@ var Obelisk = class {
|
|
|
1143
1172
|
* @param derivePathParams
|
|
1144
1173
|
*/
|
|
1145
1174
|
async transferSui(recipient, amount, derivePathParams) {
|
|
1146
|
-
const tx = new
|
|
1175
|
+
const tx = new SuiTx();
|
|
1147
1176
|
tx.transferSui(recipient, amount);
|
|
1148
1177
|
return this.signAndSendTxn(tx, derivePathParams);
|
|
1149
1178
|
}
|
|
@@ -1154,7 +1183,7 @@ var Obelisk = class {
|
|
|
1154
1183
|
* @param derivePathParams
|
|
1155
1184
|
*/
|
|
1156
1185
|
async transferSuiToMany(recipients, amounts, derivePathParams) {
|
|
1157
|
-
const tx = new
|
|
1186
|
+
const tx = new SuiTx();
|
|
1158
1187
|
tx.transferSuiToMany(recipients, amounts);
|
|
1159
1188
|
return this.signAndSendTxn(tx, derivePathParams);
|
|
1160
1189
|
}
|
|
@@ -1166,7 +1195,7 @@ var Obelisk = class {
|
|
|
1166
1195
|
* @param derivePathParams the derive path params for the current signer
|
|
1167
1196
|
*/
|
|
1168
1197
|
async transferCoinToMany(recipients, amounts, coinType, derivePathParams) {
|
|
1169
|
-
const tx = new
|
|
1198
|
+
const tx = new SuiTx();
|
|
1170
1199
|
const owner = this.accountManager.getAddress(derivePathParams);
|
|
1171
1200
|
const totalAmount = amounts.reduce((a, b) => a + b, 0);
|
|
1172
1201
|
const coins = await this.suiInteractor.selectCoins(
|
|
@@ -1191,7 +1220,7 @@ var Obelisk = class {
|
|
|
1191
1220
|
);
|
|
1192
1221
|
}
|
|
1193
1222
|
async transferObjects(objects, recipient, derivePathParams) {
|
|
1194
|
-
const tx = new
|
|
1223
|
+
const tx = new SuiTx();
|
|
1195
1224
|
tx.transferObjects(objects, recipient);
|
|
1196
1225
|
return this.signAndSendTxn(tx, derivePathParams);
|
|
1197
1226
|
}
|
|
@@ -1202,7 +1231,7 @@ var Obelisk = class {
|
|
|
1202
1231
|
typeArguments = [],
|
|
1203
1232
|
derivePathParams
|
|
1204
1233
|
} = callParams;
|
|
1205
|
-
const tx = new
|
|
1234
|
+
const tx = new SuiTx();
|
|
1206
1235
|
tx.moveCall(target, args, typeArguments);
|
|
1207
1236
|
return this.signAndSendTxn(tx, derivePathParams);
|
|
1208
1237
|
}
|
|
@@ -1229,7 +1258,7 @@ var Obelisk = class {
|
|
|
1229
1258
|
* @param derivePathParams the derive path params for the current signer
|
|
1230
1259
|
*/
|
|
1231
1260
|
async stakeSui(amount, validatorAddr, derivePathParams) {
|
|
1232
|
-
const tx = new
|
|
1261
|
+
const tx = new SuiTx();
|
|
1233
1262
|
tx.stakeSui(amount, validatorAddr);
|
|
1234
1263
|
return this.signAndSendTxn(tx, derivePathParams);
|
|
1235
1264
|
}
|
|
@@ -1241,7 +1270,7 @@ var Obelisk = class {
|
|
|
1241
1270
|
* @returns the effects and events of the transaction, such as object changes, gas cost, event emitted.
|
|
1242
1271
|
*/
|
|
1243
1272
|
async inspectTxn(tx, derivePathParams) {
|
|
1244
|
-
const txBlock = tx instanceof
|
|
1273
|
+
const txBlock = tx instanceof SuiTx ? tx.tx : tx;
|
|
1245
1274
|
return this.suiInteractor.currentClient.devInspectTransactionBlock({
|
|
1246
1275
|
transactionBlock: txBlock,
|
|
1247
1276
|
sender: this.getAddress(derivePathParams)
|
|
@@ -1263,36 +1292,62 @@ var Obelisk = class {
|
|
|
1263
1292
|
}
|
|
1264
1293
|
async getEntity(worldId, schemaName, entityId) {
|
|
1265
1294
|
const schemaModuleName = `${schemaName}_schema`;
|
|
1266
|
-
const tx = new import_transactions3.
|
|
1267
|
-
const params = [tx.pure(worldId)];
|
|
1295
|
+
const tx = new import_transactions3.Transaction();
|
|
1296
|
+
const params = [tx.pure.address(worldId)];
|
|
1268
1297
|
if (entityId !== void 0) {
|
|
1269
|
-
params.push(tx.pure(entityId));
|
|
1298
|
+
params.push(tx.pure.address(entityId));
|
|
1270
1299
|
}
|
|
1271
1300
|
const getResult = await this.query[schemaModuleName].get(
|
|
1272
1301
|
tx,
|
|
1273
1302
|
params
|
|
1274
1303
|
);
|
|
1275
|
-
let
|
|
1304
|
+
let returnValues = [];
|
|
1276
1305
|
if (getResult.effects.status.status === "success") {
|
|
1277
1306
|
const resultList = getResult.results[0].returnValues;
|
|
1278
1307
|
for (const res of resultList) {
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
const
|
|
1282
|
-
|
|
1283
|
-
|
|
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
|
+
}
|
|
1284
1339
|
}
|
|
1285
|
-
return
|
|
1340
|
+
return returnValues;
|
|
1286
1341
|
} else {
|
|
1287
1342
|
return void 0;
|
|
1288
1343
|
}
|
|
1289
1344
|
}
|
|
1290
1345
|
async containEntity(worldId, schemaName, entityId) {
|
|
1291
1346
|
const schemaModuleName = `${schemaName}_schema`;
|
|
1292
|
-
const tx = new import_transactions3.
|
|
1293
|
-
const params = [tx.pure(worldId)];
|
|
1347
|
+
const tx = new import_transactions3.Transaction();
|
|
1348
|
+
const params = [tx.pure.address(worldId)];
|
|
1294
1349
|
if (entityId !== void 0) {
|
|
1295
|
-
params.push(tx.pure(entityId));
|
|
1350
|
+
params.push(tx.pure.address(entityId));
|
|
1296
1351
|
}
|
|
1297
1352
|
const getResult = await this.query[schemaModuleName].contains(
|
|
1298
1353
|
tx,
|
|
@@ -1300,9 +1355,9 @@ var Obelisk = class {
|
|
|
1300
1355
|
);
|
|
1301
1356
|
if (getResult.effects.status.status === "success") {
|
|
1302
1357
|
const res = getResult.results[0].returnValues[0];
|
|
1303
|
-
|
|
1304
|
-
const value = Uint8Array.from(
|
|
1305
|
-
return bcs.
|
|
1358
|
+
let baseValue = res[0];
|
|
1359
|
+
const value = Uint8Array.from(baseValue);
|
|
1360
|
+
return import_bcs2.bcs.bool().parse(value);
|
|
1306
1361
|
} else {
|
|
1307
1362
|
return void 0;
|
|
1308
1363
|
}
|
|
@@ -1364,9 +1419,13 @@ var Obelisk = class {
|
|
|
1364
1419
|
async entity_key_from_bytes(bytes) {
|
|
1365
1420
|
const hashBytes = (0, import_keccak256.default)(bytes);
|
|
1366
1421
|
const hashU8Array = Array.from(hashBytes);
|
|
1367
|
-
const bcs = new import_bcs3.BCS((0, import_bcs3.getSuiMoveConfig)());
|
|
1368
1422
|
const value = Uint8Array.from(hashU8Array);
|
|
1369
|
-
const
|
|
1423
|
+
const Address = import_bcs2.bcs.bytes(32).transform({
|
|
1424
|
+
// To change the input type, you need to provide a type definition for the input
|
|
1425
|
+
input: (val) => (0, import_bcs2.fromHEX)(val),
|
|
1426
|
+
output: (val) => (0, import_bcs2.toHEX)(val)
|
|
1427
|
+
});
|
|
1428
|
+
const data = Address.parse(value);
|
|
1370
1429
|
return "0x" + data;
|
|
1371
1430
|
}
|
|
1372
1431
|
async entity_key_from_address_with_seed(objectId, seed) {
|
|
@@ -1384,9 +1443,8 @@ var Obelisk = class {
|
|
|
1384
1443
|
const checkObjectId = normalizeHexAddress(objectId);
|
|
1385
1444
|
if (checkObjectId !== null) {
|
|
1386
1445
|
objectId = checkObjectId;
|
|
1387
|
-
const bcs = new import_bcs3.BCS((0, import_bcs3.getSuiMoveConfig)());
|
|
1388
1446
|
const bytes = Buffer.from(objectId.slice(2), "hex");
|
|
1389
|
-
const numberBytes = bcs.
|
|
1447
|
+
const numberBytes = import_bcs2.bcs.u256().serialize(x).toBytes();
|
|
1390
1448
|
return this.entity_key_from_bytes(Buffer.concat([bytes, numberBytes]));
|
|
1391
1449
|
} else {
|
|
1392
1450
|
return void 0;
|
|
@@ -1395,23 +1453,65 @@ var Obelisk = class {
|
|
|
1395
1453
|
async entity_key_from_u256(x) {
|
|
1396
1454
|
return numberToAddressHex(x);
|
|
1397
1455
|
}
|
|
1398
|
-
async formatData(type, value) {
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1456
|
+
// async formatData(type: string, value: Buffer | number[] | Uint8Array) {
|
|
1457
|
+
// const u8Value = Uint8Array.from(value);
|
|
1458
|
+
// return bcs.de(type, u8Value);
|
|
1459
|
+
// }
|
|
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
|
+
}
|
|
1402
1501
|
}
|
|
1403
1502
|
};
|
|
1404
1503
|
_query = new WeakMap();
|
|
1405
1504
|
_tx = new WeakMap();
|
|
1505
|
+
_struct = new WeakMap();
|
|
1406
1506
|
_exec = new WeakMap();
|
|
1407
1507
|
_read = new WeakMap();
|
|
1408
1508
|
|
|
1409
1509
|
// src/libs/multiSig/client.ts
|
|
1410
|
-
var import_multisig = require("@mysten/sui
|
|
1510
|
+
var import_multisig = require("@mysten/sui/multisig");
|
|
1411
1511
|
|
|
1412
1512
|
// src/libs/multiSig/publickey.ts
|
|
1413
|
-
var import_ed255193 = require("@mysten/sui
|
|
1414
|
-
var import_utils5 = require("@mysten/sui
|
|
1513
|
+
var import_ed255193 = require("@mysten/sui/keypairs/ed25519");
|
|
1514
|
+
var import_utils5 = require("@mysten/sui/utils");
|
|
1415
1515
|
function ed25519PublicKeyFromBase64(rawPubkey) {
|
|
1416
1516
|
let bytes = (0, import_utils5.fromB64)(rawPubkey);
|
|
1417
1517
|
if (bytes.length !== 32 && bytes.length !== 33)
|
|
@@ -1448,7 +1548,7 @@ var MultiSigClient = class _MultiSigClient {
|
|
|
1448
1548
|
};
|
|
1449
1549
|
|
|
1450
1550
|
// src/metadata/index.ts
|
|
1451
|
-
var import_client4 = require("@mysten/sui
|
|
1551
|
+
var import_client4 = require("@mysten/sui/client");
|
|
1452
1552
|
async function loadMetadata(networkType, packageId) {
|
|
1453
1553
|
const fullnodeUrls = [(0, import_client4.getFullnodeUrl)(networkType)];
|
|
1454
1554
|
const suiInteractor = new SuiInteractor(fullnodeUrls);
|
|
@@ -1463,19 +1563,20 @@ async function loadMetadata(networkType, packageId) {
|
|
|
1463
1563
|
}
|
|
1464
1564
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1465
1565
|
0 && (module.exports = {
|
|
1466
|
-
|
|
1566
|
+
BcsType,
|
|
1467
1567
|
MultiSigClient,
|
|
1468
1568
|
Obelisk,
|
|
1469
1569
|
SuiAccountManager,
|
|
1470
1570
|
SuiContractFactory,
|
|
1471
|
-
|
|
1472
|
-
|
|
1571
|
+
SuiTx,
|
|
1572
|
+
bcs,
|
|
1473
1573
|
loadMetadata,
|
|
1474
|
-
...require("@mysten/sui
|
|
1475
|
-
...require("@mysten/sui
|
|
1476
|
-
...require("@mysten/sui
|
|
1477
|
-
...require("@mysten/sui
|
|
1478
|
-
...require("@mysten/sui
|
|
1479
|
-
...require("@mysten/sui
|
|
1574
|
+
...require("@mysten/sui/client"),
|
|
1575
|
+
...require("@mysten/sui/utils"),
|
|
1576
|
+
...require("@mysten/sui/transactions"),
|
|
1577
|
+
...require("@mysten/sui/bcs"),
|
|
1578
|
+
...require("@mysten/sui/keypairs/ed25519"),
|
|
1579
|
+
...require("@mysten/sui/keypairs/secp256k1"),
|
|
1580
|
+
...require("@mysten/sui/keypairs/secp256r1")
|
|
1480
1581
|
});
|
|
1481
1582
|
//# sourceMappingURL=index.js.map
|