@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.mjs
CHANGED
|
@@ -13,25 +13,25 @@ var __privateAdd = (obj, member, value) => {
|
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
// src/index.ts
|
|
16
|
-
export * from "@mysten/sui
|
|
17
|
-
export * from "@mysten/sui
|
|
18
|
-
export * from "@mysten/sui
|
|
19
|
-
export * from "@mysten/sui
|
|
20
|
-
export * from "@mysten/sui
|
|
21
|
-
export * from "@mysten/sui
|
|
22
|
-
|
|
16
|
+
export * from "@mysten/sui/client";
|
|
17
|
+
export * from "@mysten/sui/utils";
|
|
18
|
+
export * from "@mysten/sui/transactions";
|
|
19
|
+
export * from "@mysten/sui/bcs";
|
|
20
|
+
export * from "@mysten/sui/keypairs/ed25519";
|
|
21
|
+
export * from "@mysten/sui/keypairs/secp256k1";
|
|
22
|
+
export * from "@mysten/sui/keypairs/secp256r1";
|
|
23
|
+
import { bcs as bcs3, BcsType } from "@mysten/bcs";
|
|
23
24
|
|
|
24
25
|
// src/obelisk.ts
|
|
25
|
-
import
|
|
26
|
-
import {
|
|
27
|
-
|
|
28
|
-
} from "@mysten/sui.js/transactions";
|
|
26
|
+
import keccak256 from "keccak256";
|
|
27
|
+
import { getFullnodeUrl } from "@mysten/sui/client";
|
|
28
|
+
import { Transaction as Transaction2 } from "@mysten/sui/transactions";
|
|
29
29
|
|
|
30
30
|
// src/libs/suiAccountManager/index.ts
|
|
31
|
-
import { Ed25519Keypair as Ed25519Keypair2 } from "@mysten/sui
|
|
31
|
+
import { Ed25519Keypair as Ed25519Keypair2 } from "@mysten/sui/keypairs/ed25519";
|
|
32
32
|
|
|
33
33
|
// src/libs/suiAccountManager/keypair.ts
|
|
34
|
-
import { Ed25519Keypair } from "@mysten/sui
|
|
34
|
+
import { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519";
|
|
35
35
|
var getDerivePathForSUI = (derivePathParams = {}) => {
|
|
36
36
|
const {
|
|
37
37
|
accountIndex = 0,
|
|
@@ -46,7 +46,7 @@ var getKeyPair = (mnemonics, derivePathParams = {}) => {
|
|
|
46
46
|
};
|
|
47
47
|
|
|
48
48
|
// src/libs/suiAccountManager/util.ts
|
|
49
|
-
import { fromB64 } from "@mysten/sui
|
|
49
|
+
import { fromB64 } from "@mysten/sui/utils";
|
|
50
50
|
var isHex = (str) => /^0x[0-9a-fA-F]+$|^[0-9a-fA-F]+$/.test(str);
|
|
51
51
|
var isBase64 = (str) => /^[a-zA-Z0-9+/]+={0,2}$/g.test(str);
|
|
52
52
|
var fromHEX = (hexStr) => {
|
|
@@ -93,7 +93,7 @@ var generateMnemonic = (numberOfWords = 24) => {
|
|
|
93
93
|
import {
|
|
94
94
|
SUI_PRIVATE_KEY_PREFIX,
|
|
95
95
|
decodeSuiPrivateKey
|
|
96
|
-
} from "@mysten/sui
|
|
96
|
+
} from "@mysten/sui/cryptography";
|
|
97
97
|
var SuiAccountManager = class {
|
|
98
98
|
/**
|
|
99
99
|
* Support the following ways to init the SuiToolkit:
|
|
@@ -160,8 +160,8 @@ var SuiAccountManager = class {
|
|
|
160
160
|
};
|
|
161
161
|
|
|
162
162
|
// src/libs/suiTxBuilder/index.ts
|
|
163
|
-
import {
|
|
164
|
-
import { SUI_SYSTEM_STATE_OBJECT_ID } from "@mysten/sui
|
|
163
|
+
import { Transaction } from "@mysten/sui/transactions";
|
|
164
|
+
import { SUI_SYSTEM_STATE_OBJECT_ID } from "@mysten/sui/utils";
|
|
165
165
|
|
|
166
166
|
// src/libs/suiTxBuilder/util.ts
|
|
167
167
|
import {
|
|
@@ -169,10 +169,9 @@ import {
|
|
|
169
169
|
normalizeSuiAddress,
|
|
170
170
|
isValidSuiObjectId,
|
|
171
171
|
isValidSuiAddress
|
|
172
|
-
} from "@mysten/sui
|
|
173
|
-
import { Inputs } from "@mysten/sui
|
|
174
|
-
import {
|
|
175
|
-
import { isSerializedBcs } from "@mysten/bcs";
|
|
172
|
+
} from "@mysten/sui/utils";
|
|
173
|
+
import { Inputs, getPureBcsSchema } from "@mysten/sui/transactions";
|
|
174
|
+
import { SerializedBcs, bcs, isSerializedBcs } from "@mysten/bcs";
|
|
176
175
|
var getDefaultSuiInputType = (value) => {
|
|
177
176
|
if (typeof value === "string" && isValidSuiObjectId(value)) {
|
|
178
177
|
return "object";
|
|
@@ -192,17 +191,18 @@ function makeVecParam(txBlock, args, type) {
|
|
|
192
191
|
const STRUCT_REGEX = /^([^:]+)::([^:]+)::([^<]+)(<(.+)>)?/;
|
|
193
192
|
type = type || defaultSuiType;
|
|
194
193
|
if (type === "object") {
|
|
195
|
-
const
|
|
194
|
+
const elements = args.map(
|
|
196
195
|
(arg) => typeof arg === "string" && isValidSuiObjectId(arg) ? txBlock.object(normalizeSuiObjectId(arg)) : convertObjArg(txBlock, arg)
|
|
197
196
|
);
|
|
198
|
-
return txBlock.makeMoveVec({
|
|
197
|
+
return txBlock.makeMoveVec({ elements });
|
|
199
198
|
} else if (typeof type === "string" && !VECTOR_REGEX.test(type) && !STRUCT_REGEX.test(type)) {
|
|
200
|
-
|
|
199
|
+
const bcsSchema = getPureBcsSchema(type);
|
|
200
|
+
return txBlock.pure(bcs.vector(bcsSchema).serialize(args));
|
|
201
201
|
} else {
|
|
202
|
-
const
|
|
202
|
+
const elements = args.map(
|
|
203
203
|
(arg) => convertObjArg(txBlock, arg)
|
|
204
204
|
);
|
|
205
|
-
return txBlock.makeMoveVec({
|
|
205
|
+
return txBlock.makeMoveVec({ elements, type });
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
208
|
function isMoveVecArg(arg) {
|
|
@@ -215,29 +215,21 @@ function isMoveVecArg(arg) {
|
|
|
215
215
|
}
|
|
216
216
|
function convertArgs(txBlock, args) {
|
|
217
217
|
return args.map((arg) => {
|
|
218
|
-
if (
|
|
219
|
-
return txBlock.
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
} else if (isMoveVecArg(arg)) {
|
|
218
|
+
if (arg instanceof SerializedBcs || isSerializedBcs(arg)) {
|
|
219
|
+
return txBlock.pure(arg);
|
|
220
|
+
}
|
|
221
|
+
if (isMoveVecArg(arg)) {
|
|
223
222
|
const vecType = "vecType" in arg;
|
|
224
223
|
return vecType ? makeVecParam(txBlock, arg.value, arg.vecType) : makeVecParam(txBlock, arg);
|
|
225
|
-
} else if (isSerializedBcs(arg)) {
|
|
226
|
-
return arg;
|
|
227
|
-
} else {
|
|
228
|
-
return txBlock.pure(arg);
|
|
229
224
|
}
|
|
225
|
+
return arg;
|
|
230
226
|
});
|
|
231
227
|
}
|
|
232
228
|
function convertAddressArg(txBlock, arg) {
|
|
233
229
|
if (typeof arg === "string" && isValidSuiAddress(arg)) {
|
|
234
230
|
return txBlock.pure.address(normalizeSuiAddress(arg));
|
|
235
|
-
} else if (typeof arg == "object" && !isSerializedBcs(arg) && !isPureArg(arg)) {
|
|
236
|
-
return convertObjArg(txBlock, arg);
|
|
237
|
-
} else if (isPureArg(arg)) {
|
|
238
|
-
return txBlock.pure(arg);
|
|
239
231
|
} else {
|
|
240
|
-
return arg;
|
|
232
|
+
return convertArgs(txBlock, [arg])[0];
|
|
241
233
|
}
|
|
242
234
|
}
|
|
243
235
|
function convertObjArg(txb, arg) {
|
|
@@ -251,123 +243,140 @@ function convertObjArg(txb, arg) {
|
|
|
251
243
|
return txb.sharedObjectRef(arg);
|
|
252
244
|
}
|
|
253
245
|
if ("Object" in arg) {
|
|
254
|
-
if ("
|
|
255
|
-
return txb.object(Inputs.ObjectRef(arg.Object.
|
|
256
|
-
} else if ("
|
|
257
|
-
return txb.object(Inputs.SharedObjectRef(arg.Object.
|
|
246
|
+
if ("ImmOrOwnedObject" in arg.Object) {
|
|
247
|
+
return txb.object(Inputs.ObjectRef(arg.Object.ImmOrOwnedObject));
|
|
248
|
+
} else if ("SharedObject" in arg.Object) {
|
|
249
|
+
return txb.object(Inputs.SharedObjectRef(arg.Object.SharedObject));
|
|
258
250
|
} else {
|
|
259
251
|
throw new Error("Invalid argument type");
|
|
260
252
|
}
|
|
261
253
|
}
|
|
262
|
-
if ("
|
|
254
|
+
if (typeof arg === "function") {
|
|
255
|
+
return arg;
|
|
256
|
+
}
|
|
257
|
+
if ("GasCoin" in arg || "Input" in arg || "Result" in arg || "NestedResult" in arg) {
|
|
263
258
|
return arg;
|
|
264
259
|
}
|
|
265
260
|
throw new Error("Invalid argument type");
|
|
266
261
|
}
|
|
262
|
+
function convertAmounts(txBlock, amounts) {
|
|
263
|
+
return amounts.map((amount) => {
|
|
264
|
+
if (typeof amount === "number" || typeof amount === "bigint") {
|
|
265
|
+
return amount;
|
|
266
|
+
} else {
|
|
267
|
+
return convertArgs(txBlock, [amount])[0];
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
}
|
|
267
271
|
|
|
268
272
|
// src/libs/suiTxBuilder/index.ts
|
|
269
|
-
var
|
|
273
|
+
var SuiTx = class {
|
|
270
274
|
constructor(transaction) {
|
|
271
|
-
|
|
275
|
+
if (transaction !== void 0) {
|
|
276
|
+
this.tx = Transaction.from(transaction);
|
|
277
|
+
} else {
|
|
278
|
+
this.tx = new Transaction();
|
|
279
|
+
}
|
|
272
280
|
}
|
|
273
281
|
/* Directly wrap methods and properties of TransactionBlock */
|
|
274
282
|
get gas() {
|
|
275
|
-
return this.
|
|
283
|
+
return this.tx.gas;
|
|
276
284
|
}
|
|
277
285
|
get blockData() {
|
|
278
|
-
return this.
|
|
286
|
+
return this.tx.blockData;
|
|
287
|
+
}
|
|
288
|
+
autoPure(value, type) {
|
|
289
|
+
if (type === void 0) {
|
|
290
|
+
return convertArgs(this.tx, [value]);
|
|
291
|
+
}
|
|
292
|
+
return;
|
|
279
293
|
}
|
|
280
294
|
address(value) {
|
|
281
|
-
return this.
|
|
295
|
+
return this.tx.pure.address(value);
|
|
282
296
|
}
|
|
283
|
-
pure(
|
|
284
|
-
return this.
|
|
297
|
+
get pure() {
|
|
298
|
+
return this.tx.pure.bind(this.tx);
|
|
285
299
|
}
|
|
286
300
|
object(value) {
|
|
287
|
-
return this.
|
|
301
|
+
return this.tx.object(value);
|
|
288
302
|
}
|
|
289
303
|
objectRef(ref) {
|
|
290
|
-
return this.
|
|
304
|
+
return this.tx.objectRef(ref);
|
|
291
305
|
}
|
|
292
306
|
sharedObjectRef(ref) {
|
|
293
|
-
return this.
|
|
307
|
+
return this.tx.sharedObjectRef(ref);
|
|
294
308
|
}
|
|
295
309
|
setSender(sender) {
|
|
296
|
-
return this.
|
|
310
|
+
return this.tx.setSender(sender);
|
|
297
311
|
}
|
|
298
312
|
setSenderIfNotSet(sender) {
|
|
299
|
-
return this.
|
|
313
|
+
return this.tx.setSenderIfNotSet(sender);
|
|
300
314
|
}
|
|
301
315
|
setExpiration(expiration) {
|
|
302
|
-
return this.
|
|
316
|
+
return this.tx.setExpiration(expiration);
|
|
303
317
|
}
|
|
304
318
|
setGasPrice(price) {
|
|
305
|
-
return this.
|
|
319
|
+
return this.tx.setGasPrice(price);
|
|
306
320
|
}
|
|
307
321
|
setGasBudget(budget) {
|
|
308
|
-
return this.
|
|
322
|
+
return this.tx.setGasBudget(budget);
|
|
309
323
|
}
|
|
310
324
|
setGasOwner(owner) {
|
|
311
|
-
return this.
|
|
325
|
+
return this.tx.setGasOwner(owner);
|
|
312
326
|
}
|
|
313
327
|
setGasPayment(payments) {
|
|
314
|
-
return this.
|
|
328
|
+
return this.tx.setGasPayment(payments);
|
|
315
329
|
}
|
|
316
330
|
serialize() {
|
|
317
|
-
return this.
|
|
331
|
+
return this.tx.serialize();
|
|
332
|
+
}
|
|
333
|
+
toJSON() {
|
|
334
|
+
return this.tx.toJSON();
|
|
318
335
|
}
|
|
319
336
|
sign(params) {
|
|
320
|
-
return this.
|
|
337
|
+
return this.tx.sign(params);
|
|
321
338
|
}
|
|
322
339
|
build(params = {}) {
|
|
323
|
-
return this.
|
|
340
|
+
return this.tx.build(params);
|
|
324
341
|
}
|
|
325
342
|
getDigest(params = {}) {
|
|
326
|
-
return this.
|
|
343
|
+
return this.tx.getDigest(params);
|
|
327
344
|
}
|
|
328
345
|
add(...args) {
|
|
329
|
-
return this.
|
|
346
|
+
return this.tx.add(...args);
|
|
330
347
|
}
|
|
331
348
|
publish({
|
|
332
349
|
modules,
|
|
333
350
|
dependencies
|
|
334
351
|
}) {
|
|
335
|
-
return this.
|
|
352
|
+
return this.tx.publish({ modules, dependencies });
|
|
336
353
|
}
|
|
337
|
-
upgrade({
|
|
338
|
-
|
|
339
|
-
dependencies,
|
|
340
|
-
packageId,
|
|
341
|
-
ticket
|
|
342
|
-
}) {
|
|
343
|
-
return this.txBlock.upgrade({ modules, dependencies, packageId, ticket });
|
|
354
|
+
upgrade(...args) {
|
|
355
|
+
return this.tx.upgrade(...args);
|
|
344
356
|
}
|
|
345
|
-
makeMoveVec({
|
|
346
|
-
|
|
347
|
-
type
|
|
348
|
-
}) {
|
|
349
|
-
return this.txBlock.makeMoveVec({ objects, type });
|
|
357
|
+
makeMoveVec(...args) {
|
|
358
|
+
return this.tx.makeMoveVec(...args);
|
|
350
359
|
}
|
|
351
360
|
/* Override methods of TransactionBlock */
|
|
352
361
|
transferObjects(objects, address) {
|
|
353
|
-
return this.
|
|
354
|
-
objects.map((object) => convertObjArg(this.
|
|
355
|
-
convertAddressArg(this.
|
|
362
|
+
return this.tx.transferObjects(
|
|
363
|
+
objects.map((object) => convertObjArg(this.tx, object)),
|
|
364
|
+
convertAddressArg(this.tx, address)
|
|
356
365
|
);
|
|
357
366
|
}
|
|
358
367
|
splitCoins(coin, amounts) {
|
|
359
|
-
const res = this.
|
|
360
|
-
convertObjArg(this.
|
|
361
|
-
convertArgs(this.
|
|
368
|
+
const res = this.tx.splitCoins(
|
|
369
|
+
convertObjArg(this.tx, coin),
|
|
370
|
+
convertArgs(this.tx, amounts)
|
|
362
371
|
);
|
|
363
372
|
return amounts.map((_, i) => res[i]);
|
|
364
373
|
}
|
|
365
374
|
mergeCoins(destination, sources) {
|
|
366
|
-
const destinationObject = convertObjArg(this.
|
|
375
|
+
const destinationObject = convertObjArg(this.tx, destination);
|
|
367
376
|
const sourceObjects = sources.map(
|
|
368
|
-
(source) => convertObjArg(this.
|
|
377
|
+
(source) => convertObjArg(this.tx, source)
|
|
369
378
|
);
|
|
370
|
-
return this.
|
|
379
|
+
return this.tx.mergeCoins(destinationObject, sourceObjects);
|
|
371
380
|
}
|
|
372
381
|
/**
|
|
373
382
|
* @description Move call
|
|
@@ -382,8 +391,8 @@ var SuiTxBlock = class {
|
|
|
382
391
|
throw new Error(
|
|
383
392
|
"Invalid target format. Expected `${string}::${string}::${string}`"
|
|
384
393
|
);
|
|
385
|
-
const convertedArgs = convertArgs(this.
|
|
386
|
-
return this.
|
|
394
|
+
const convertedArgs = convertArgs(this.tx, args);
|
|
395
|
+
return this.tx.moveCall({
|
|
387
396
|
target,
|
|
388
397
|
arguments: convertedArgs,
|
|
389
398
|
typeArguments: typeArgs
|
|
@@ -396,15 +405,17 @@ var SuiTxBlock = class {
|
|
|
396
405
|
"transferSuiToMany: recipients.length !== amounts.length"
|
|
397
406
|
);
|
|
398
407
|
}
|
|
399
|
-
const coins = this.
|
|
400
|
-
this.
|
|
401
|
-
|
|
408
|
+
const coins = this.tx.splitCoins(
|
|
409
|
+
this.tx.gas,
|
|
410
|
+
amounts.map(
|
|
411
|
+
(amount) => typeof amount === "number" || typeof amount === "bigint" ? amount : convertArgs(this.tx, [amount])[0]
|
|
412
|
+
)
|
|
402
413
|
);
|
|
403
414
|
const recipientObjects = recipients.map(
|
|
404
|
-
(recipient) => convertAddressArg(this.
|
|
415
|
+
(recipient) => convertAddressArg(this.tx, recipient)
|
|
405
416
|
);
|
|
406
417
|
recipientObjects.forEach((address, index) => {
|
|
407
|
-
this.
|
|
418
|
+
this.tx.transferObjects([coins[index]], address);
|
|
408
419
|
});
|
|
409
420
|
return this;
|
|
410
421
|
}
|
|
@@ -412,32 +423,28 @@ var SuiTxBlock = class {
|
|
|
412
423
|
return this.transferSuiToMany([address], [amount]);
|
|
413
424
|
}
|
|
414
425
|
takeAmountFromCoins(coins, amount) {
|
|
415
|
-
const coinObjects = coins.map((coin) => convertObjArg(this.
|
|
426
|
+
const coinObjects = coins.map((coin) => convertObjArg(this.tx, coin));
|
|
416
427
|
const mergedCoin = coinObjects[0];
|
|
417
428
|
if (coins.length > 1) {
|
|
418
|
-
this.
|
|
429
|
+
this.tx.mergeCoins(mergedCoin, coinObjects.slice(1));
|
|
419
430
|
}
|
|
420
|
-
const [sendCoin] = this.
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
);
|
|
431
|
+
const [sendCoin] = this.tx.splitCoins(mergedCoin, [
|
|
432
|
+
typeof amount === "number" || typeof amount === "bigint" ? amount : convertArgs(this.tx, [amount])[0]
|
|
433
|
+
]);
|
|
424
434
|
return [sendCoin, mergedCoin];
|
|
425
435
|
}
|
|
426
436
|
splitSUIFromGas(amounts) {
|
|
427
|
-
return this.
|
|
428
|
-
this.txBlock.gas,
|
|
429
|
-
convertArgs(this.txBlock, amounts)
|
|
430
|
-
);
|
|
437
|
+
return this.tx.splitCoins(this.tx.gas, convertArgs(this.tx, amounts));
|
|
431
438
|
}
|
|
432
439
|
splitMultiCoins(coins, amounts) {
|
|
433
|
-
const coinObjects = coins.map((coin) => convertObjArg(this.
|
|
440
|
+
const coinObjects = coins.map((coin) => convertObjArg(this.tx, coin));
|
|
434
441
|
const mergedCoin = coinObjects[0];
|
|
435
442
|
if (coins.length > 1) {
|
|
436
|
-
this.
|
|
443
|
+
this.tx.mergeCoins(mergedCoin, coinObjects.slice(1));
|
|
437
444
|
}
|
|
438
|
-
const splitedCoins = this.
|
|
445
|
+
const splitedCoins = this.tx.splitCoins(
|
|
439
446
|
mergedCoin,
|
|
440
|
-
|
|
447
|
+
convertAmounts(this.tx, amounts)
|
|
441
448
|
);
|
|
442
449
|
return { splitedCoins, mergedCoin };
|
|
443
450
|
}
|
|
@@ -447,45 +454,42 @@ var SuiTxBlock = class {
|
|
|
447
454
|
"transferSuiToMany: recipients.length !== amounts.length"
|
|
448
455
|
);
|
|
449
456
|
}
|
|
450
|
-
const coinObjects = coins.map((coin) => convertObjArg(this.
|
|
457
|
+
const coinObjects = coins.map((coin) => convertObjArg(this.tx, coin));
|
|
451
458
|
const { splitedCoins, mergedCoin } = this.splitMultiCoins(
|
|
452
459
|
coinObjects,
|
|
453
460
|
amounts
|
|
454
461
|
);
|
|
455
462
|
const recipientObjects = recipients.map(
|
|
456
|
-
(recipient) => convertAddressArg(this.
|
|
463
|
+
(recipient) => convertAddressArg(this.tx, recipient)
|
|
457
464
|
);
|
|
458
465
|
recipientObjects.forEach((address, index) => {
|
|
459
|
-
this.
|
|
466
|
+
this.tx.transferObjects([splitedCoins[index]], address);
|
|
460
467
|
});
|
|
461
|
-
this.
|
|
462
|
-
[mergedCoin],
|
|
463
|
-
convertAddressArg(this.txBlock, sender)
|
|
464
|
-
);
|
|
468
|
+
this.tx.transferObjects([mergedCoin], convertAddressArg(this.tx, sender));
|
|
465
469
|
return this;
|
|
466
470
|
}
|
|
467
471
|
transferCoin(coins, sender, recipient, amount) {
|
|
468
472
|
return this.transferCoinToMany(coins, sender, [recipient], [amount]);
|
|
469
473
|
}
|
|
470
474
|
stakeSui(amount, validatorAddr) {
|
|
471
|
-
const [stakeCoin] = this.
|
|
472
|
-
this.
|
|
473
|
-
|
|
475
|
+
const [stakeCoin] = this.tx.splitCoins(
|
|
476
|
+
this.tx.gas,
|
|
477
|
+
convertAmounts(this.tx, [amount])
|
|
474
478
|
);
|
|
475
|
-
return this.
|
|
479
|
+
return this.tx.moveCall({
|
|
476
480
|
target: "0x3::sui_system::request_add_stake",
|
|
477
|
-
arguments: convertArgs(this.
|
|
478
|
-
SUI_SYSTEM_STATE_OBJECT_ID,
|
|
481
|
+
arguments: convertArgs(this.tx, [
|
|
482
|
+
this.tx.object(SUI_SYSTEM_STATE_OBJECT_ID),
|
|
479
483
|
stakeCoin,
|
|
480
|
-
this.
|
|
484
|
+
convertAddressArg(this.tx, validatorAddr)
|
|
481
485
|
])
|
|
482
486
|
});
|
|
483
487
|
}
|
|
484
488
|
};
|
|
485
489
|
|
|
486
490
|
// src/libs/suiInteractor/suiInteractor.ts
|
|
487
|
-
import { SuiClient } from "@mysten/sui
|
|
488
|
-
import { requestSuiFromFaucetV0, getFaucetHost } from "@mysten/sui
|
|
491
|
+
import { SuiClient } from "@mysten/sui/client";
|
|
492
|
+
import { requestSuiFromFaucetV0, getFaucetHost } from "@mysten/sui/faucet";
|
|
489
493
|
|
|
490
494
|
// src/libs/suiModel/suiOwnedObject.ts
|
|
491
495
|
var SuiOwnedObject = class {
|
|
@@ -507,8 +511,10 @@ var SuiOwnedObject = class {
|
|
|
507
511
|
return this.objectId;
|
|
508
512
|
}
|
|
509
513
|
return {
|
|
514
|
+
$kind: "Object",
|
|
510
515
|
Object: {
|
|
511
|
-
|
|
516
|
+
$kind: "ImmOrOwnedObject",
|
|
517
|
+
ImmOrOwnedObject: {
|
|
512
518
|
objectId: this.objectId,
|
|
513
519
|
version: this.version,
|
|
514
520
|
digest: this.digest
|
|
@@ -547,8 +553,10 @@ var SuiSharedObject = class {
|
|
|
547
553
|
return this.objectId;
|
|
548
554
|
}
|
|
549
555
|
return {
|
|
556
|
+
$kind: "Object",
|
|
550
557
|
Object: {
|
|
551
|
-
|
|
558
|
+
$kind: "SharedObject",
|
|
559
|
+
SharedObject: {
|
|
552
560
|
objectId: this.objectId,
|
|
553
561
|
initialSharedVersion: this.initialSharedVersion,
|
|
554
562
|
mutable
|
|
@@ -908,8 +916,7 @@ function numberToAddressHex(num) {
|
|
|
908
916
|
}
|
|
909
917
|
|
|
910
918
|
// src/obelisk.ts
|
|
911
|
-
import
|
|
912
|
-
import { BCS, getSuiMoveConfig } from "@mysten/bcs";
|
|
919
|
+
import { bcs as bcs2, fromHEX as fromHEX2, toHEX } from "@mysten/bcs";
|
|
913
920
|
function isUndefined(value) {
|
|
914
921
|
return value === void 0;
|
|
915
922
|
}
|
|
@@ -934,7 +941,7 @@ function createTx(meta, fn) {
|
|
|
934
941
|
}
|
|
935
942
|
);
|
|
936
943
|
}
|
|
937
|
-
var _query, _tx, _exec, _read;
|
|
944
|
+
var _query, _tx, _struct, _exec, _read;
|
|
938
945
|
var Obelisk = class {
|
|
939
946
|
/**
|
|
940
947
|
* Support the following ways to init the ObeliskClient:
|
|
@@ -958,6 +965,7 @@ var Obelisk = class {
|
|
|
958
965
|
} = {}) {
|
|
959
966
|
__privateAdd(this, _query, {});
|
|
960
967
|
__privateAdd(this, _tx, {});
|
|
968
|
+
__privateAdd(this, _struct, {});
|
|
961
969
|
__privateAdd(this, _exec, async (meta, tx, params, typeArguments, isRaw) => {
|
|
962
970
|
if (isRaw === true) {
|
|
963
971
|
return tx.moveCall({
|
|
@@ -994,33 +1002,37 @@ var Obelisk = class {
|
|
|
994
1002
|
this.packageId = packageId;
|
|
995
1003
|
if (metadata !== void 0) {
|
|
996
1004
|
this.metadata = metadata;
|
|
997
|
-
Object.values(metadata).forEach(
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1005
|
+
Object.values(metadata).forEach(
|
|
1006
|
+
(moudlevalue) => {
|
|
1007
|
+
const data = moudlevalue;
|
|
1008
|
+
const moduleName = data.name;
|
|
1009
|
+
Object.entries(data.exposedFunctions).forEach(
|
|
1010
|
+
([funcName, funcvalue]) => {
|
|
1011
|
+
const meta = funcvalue;
|
|
1012
|
+
meta.moduleName = moduleName;
|
|
1013
|
+
meta.funcName = funcName;
|
|
1014
|
+
if (isUndefined(__privateGet(this, _query)[moduleName])) {
|
|
1015
|
+
__privateGet(this, _query)[moduleName] = {};
|
|
1016
|
+
}
|
|
1017
|
+
if (isUndefined(__privateGet(this, _query)[moduleName][funcName])) {
|
|
1018
|
+
__privateGet(this, _query)[moduleName][funcName] = createQuery(
|
|
1019
|
+
meta,
|
|
1020
|
+
(tx, p, typeArguments, isRaw) => __privateGet(this, _read).call(this, meta, tx, p, typeArguments, isRaw)
|
|
1021
|
+
);
|
|
1022
|
+
}
|
|
1023
|
+
if (isUndefined(__privateGet(this, _tx)[moduleName])) {
|
|
1024
|
+
__privateGet(this, _tx)[moduleName] = {};
|
|
1025
|
+
}
|
|
1026
|
+
if (isUndefined(__privateGet(this, _tx)[moduleName][funcName])) {
|
|
1027
|
+
__privateGet(this, _tx)[moduleName][funcName] = createTx(
|
|
1028
|
+
meta,
|
|
1029
|
+
(tx, p, typeArguments, isRaw) => __privateGet(this, _exec).call(this, meta, tx, p, typeArguments, isRaw)
|
|
1030
|
+
);
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
);
|
|
1034
|
+
}
|
|
1035
|
+
);
|
|
1024
1036
|
}
|
|
1025
1037
|
this.contractFactory = new SuiContractFactory({
|
|
1026
1038
|
packageId,
|
|
@@ -1033,6 +1045,9 @@ var Obelisk = class {
|
|
|
1033
1045
|
get tx() {
|
|
1034
1046
|
return __privateGet(this, _tx);
|
|
1035
1047
|
}
|
|
1048
|
+
get struct() {
|
|
1049
|
+
return __privateGet(this, _struct);
|
|
1050
|
+
}
|
|
1036
1051
|
/**
|
|
1037
1052
|
* if derivePathParams is not provided or mnemonics is empty, it will return the keypair.
|
|
1038
1053
|
* else:
|
|
@@ -1065,11 +1080,20 @@ var Obelisk = class {
|
|
|
1065
1080
|
getMetadata() {
|
|
1066
1081
|
return this.contractFactory.metadata;
|
|
1067
1082
|
}
|
|
1083
|
+
getNetwork() {
|
|
1084
|
+
return this.suiInteractor.network;
|
|
1085
|
+
}
|
|
1068
1086
|
/**
|
|
1069
1087
|
* Request some SUI from faucet
|
|
1070
1088
|
* @Returns {Promise<boolean>}, true if the request is successful, false otherwise.
|
|
1071
1089
|
*/
|
|
1072
|
-
async requestFaucet(address, network) {
|
|
1090
|
+
async requestFaucet(address, network, derivePathParams) {
|
|
1091
|
+
if (address === void 0) {
|
|
1092
|
+
address = this.accountManager.getAddress(derivePathParams);
|
|
1093
|
+
}
|
|
1094
|
+
if (network === void 0) {
|
|
1095
|
+
network = this.getNetwork();
|
|
1096
|
+
}
|
|
1073
1097
|
return this.suiInteractor.requestFaucet(address, network);
|
|
1074
1098
|
}
|
|
1075
1099
|
async getBalance(coinType, derivePathParams) {
|
|
@@ -1093,18 +1117,21 @@ var Obelisk = class {
|
|
|
1093
1117
|
return this.suiInteractor.getObjects(objectIds);
|
|
1094
1118
|
}
|
|
1095
1119
|
async signTxn(tx, derivePathParams) {
|
|
1096
|
-
if (tx instanceof
|
|
1120
|
+
if (tx instanceof SuiTx || tx instanceof Transaction2) {
|
|
1097
1121
|
tx.setSender(this.getAddress(derivePathParams));
|
|
1098
1122
|
}
|
|
1099
|
-
const txBlock = tx instanceof
|
|
1100
|
-
const txBytes = txBlock instanceof
|
|
1123
|
+
const txBlock = tx instanceof SuiTx ? tx.tx : tx;
|
|
1124
|
+
const txBytes = txBlock instanceof Transaction2 ? await txBlock.build({ client: this.client() }) : txBlock;
|
|
1101
1125
|
const keyPair = this.getKeypair(derivePathParams);
|
|
1102
|
-
return await keyPair.
|
|
1126
|
+
return await keyPair.signTransaction(txBytes);
|
|
1103
1127
|
}
|
|
1104
1128
|
async signAndSendTxn(tx, derivePathParams) {
|
|
1105
1129
|
const { bytes, signature } = await this.signTxn(tx, derivePathParams);
|
|
1106
1130
|
return this.suiInteractor.sendTx(bytes, signature);
|
|
1107
1131
|
}
|
|
1132
|
+
async sendTxn(transactionBlock, signature) {
|
|
1133
|
+
return this.suiInteractor.sendTx(transactionBlock, signature);
|
|
1134
|
+
}
|
|
1108
1135
|
/**
|
|
1109
1136
|
* Transfer the given amount of SUI to the recipient
|
|
1110
1137
|
* @param recipient
|
|
@@ -1112,7 +1139,7 @@ var Obelisk = class {
|
|
|
1112
1139
|
* @param derivePathParams
|
|
1113
1140
|
*/
|
|
1114
1141
|
async transferSui(recipient, amount, derivePathParams) {
|
|
1115
|
-
const tx = new
|
|
1142
|
+
const tx = new SuiTx();
|
|
1116
1143
|
tx.transferSui(recipient, amount);
|
|
1117
1144
|
return this.signAndSendTxn(tx, derivePathParams);
|
|
1118
1145
|
}
|
|
@@ -1123,7 +1150,7 @@ var Obelisk = class {
|
|
|
1123
1150
|
* @param derivePathParams
|
|
1124
1151
|
*/
|
|
1125
1152
|
async transferSuiToMany(recipients, amounts, derivePathParams) {
|
|
1126
|
-
const tx = new
|
|
1153
|
+
const tx = new SuiTx();
|
|
1127
1154
|
tx.transferSuiToMany(recipients, amounts);
|
|
1128
1155
|
return this.signAndSendTxn(tx, derivePathParams);
|
|
1129
1156
|
}
|
|
@@ -1135,7 +1162,7 @@ var Obelisk = class {
|
|
|
1135
1162
|
* @param derivePathParams the derive path params for the current signer
|
|
1136
1163
|
*/
|
|
1137
1164
|
async transferCoinToMany(recipients, amounts, coinType, derivePathParams) {
|
|
1138
|
-
const tx = new
|
|
1165
|
+
const tx = new SuiTx();
|
|
1139
1166
|
const owner = this.accountManager.getAddress(derivePathParams);
|
|
1140
1167
|
const totalAmount = amounts.reduce((a, b) => a + b, 0);
|
|
1141
1168
|
const coins = await this.suiInteractor.selectCoins(
|
|
@@ -1160,7 +1187,7 @@ var Obelisk = class {
|
|
|
1160
1187
|
);
|
|
1161
1188
|
}
|
|
1162
1189
|
async transferObjects(objects, recipient, derivePathParams) {
|
|
1163
|
-
const tx = new
|
|
1190
|
+
const tx = new SuiTx();
|
|
1164
1191
|
tx.transferObjects(objects, recipient);
|
|
1165
1192
|
return this.signAndSendTxn(tx, derivePathParams);
|
|
1166
1193
|
}
|
|
@@ -1171,7 +1198,7 @@ var Obelisk = class {
|
|
|
1171
1198
|
typeArguments = [],
|
|
1172
1199
|
derivePathParams
|
|
1173
1200
|
} = callParams;
|
|
1174
|
-
const tx = new
|
|
1201
|
+
const tx = new SuiTx();
|
|
1175
1202
|
tx.moveCall(target, args, typeArguments);
|
|
1176
1203
|
return this.signAndSendTxn(tx, derivePathParams);
|
|
1177
1204
|
}
|
|
@@ -1198,7 +1225,7 @@ var Obelisk = class {
|
|
|
1198
1225
|
* @param derivePathParams the derive path params for the current signer
|
|
1199
1226
|
*/
|
|
1200
1227
|
async stakeSui(amount, validatorAddr, derivePathParams) {
|
|
1201
|
-
const tx = new
|
|
1228
|
+
const tx = new SuiTx();
|
|
1202
1229
|
tx.stakeSui(amount, validatorAddr);
|
|
1203
1230
|
return this.signAndSendTxn(tx, derivePathParams);
|
|
1204
1231
|
}
|
|
@@ -1210,7 +1237,7 @@ var Obelisk = class {
|
|
|
1210
1237
|
* @returns the effects and events of the transaction, such as object changes, gas cost, event emitted.
|
|
1211
1238
|
*/
|
|
1212
1239
|
async inspectTxn(tx, derivePathParams) {
|
|
1213
|
-
const txBlock = tx instanceof
|
|
1240
|
+
const txBlock = tx instanceof SuiTx ? tx.tx : tx;
|
|
1214
1241
|
return this.suiInteractor.currentClient.devInspectTransactionBlock({
|
|
1215
1242
|
transactionBlock: txBlock,
|
|
1216
1243
|
sender: this.getAddress(derivePathParams)
|
|
@@ -1232,36 +1259,62 @@ var Obelisk = class {
|
|
|
1232
1259
|
}
|
|
1233
1260
|
async getEntity(worldId, schemaName, entityId) {
|
|
1234
1261
|
const schemaModuleName = `${schemaName}_schema`;
|
|
1235
|
-
const tx = new
|
|
1236
|
-
const params = [tx.pure(worldId)];
|
|
1262
|
+
const tx = new Transaction2();
|
|
1263
|
+
const params = [tx.pure.address(worldId)];
|
|
1237
1264
|
if (entityId !== void 0) {
|
|
1238
|
-
params.push(tx.pure(entityId));
|
|
1265
|
+
params.push(tx.pure.address(entityId));
|
|
1239
1266
|
}
|
|
1240
1267
|
const getResult = await this.query[schemaModuleName].get(
|
|
1241
1268
|
tx,
|
|
1242
1269
|
params
|
|
1243
1270
|
);
|
|
1244
|
-
let
|
|
1271
|
+
let returnValues = [];
|
|
1245
1272
|
if (getResult.effects.status.status === "success") {
|
|
1246
1273
|
const resultList = getResult.results[0].returnValues;
|
|
1247
1274
|
for (const res of resultList) {
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
const
|
|
1251
|
-
|
|
1252
|
-
|
|
1275
|
+
let baseValue = res[0];
|
|
1276
|
+
let baseType = res[1];
|
|
1277
|
+
const value = Uint8Array.from(baseValue);
|
|
1278
|
+
if (baseType === "address") {
|
|
1279
|
+
const Address = bcs2.bytes(32).transform({
|
|
1280
|
+
// To change the input type, you need to provide a type definition for the input
|
|
1281
|
+
input: (val) => fromHEX2(val),
|
|
1282
|
+
output: (val) => toHEX(val)
|
|
1283
|
+
});
|
|
1284
|
+
returnValues.push(Address.parse(value));
|
|
1285
|
+
} else if (baseType === "u8") {
|
|
1286
|
+
returnValues.push(bcs2.u8().parse(value));
|
|
1287
|
+
} else if (baseType === "u16") {
|
|
1288
|
+
returnValues.push(bcs2.u16().parse(value));
|
|
1289
|
+
} else if (baseType === "u32") {
|
|
1290
|
+
returnValues.push(bcs2.u32().parse(value));
|
|
1291
|
+
} else if (baseType === "u64") {
|
|
1292
|
+
returnValues.push(bcs2.u64().parse(value));
|
|
1293
|
+
} else if (baseType === "u128") {
|
|
1294
|
+
returnValues.push(bcs2.u128().parse(value));
|
|
1295
|
+
} else if (baseType === "u256") {
|
|
1296
|
+
returnValues.push(bcs2.u256().parse(value));
|
|
1297
|
+
} else if (baseType === "bool") {
|
|
1298
|
+
returnValues.push(bcs2.bool().parse(value));
|
|
1299
|
+
} else if (baseType === "0x1::ascii::String") {
|
|
1300
|
+
returnValues.push(bcs2.string().parse(value));
|
|
1301
|
+
} else if (baseType === "vector<u8>") {
|
|
1302
|
+
returnValues.push(bcs2.vector(bcs2.u8()).parse(value));
|
|
1303
|
+
} else if (baseType === "0x1::option::Option<u8>") {
|
|
1304
|
+
returnValues.push(bcs2.option(bcs2.u8()).parse(value));
|
|
1305
|
+
}
|
|
1253
1306
|
}
|
|
1254
|
-
return
|
|
1307
|
+
return returnValues;
|
|
1255
1308
|
} else {
|
|
1256
1309
|
return void 0;
|
|
1257
1310
|
}
|
|
1258
1311
|
}
|
|
1259
1312
|
async containEntity(worldId, schemaName, entityId) {
|
|
1260
1313
|
const schemaModuleName = `${schemaName}_schema`;
|
|
1261
|
-
const tx = new
|
|
1262
|
-
const params = [tx.pure(worldId)];
|
|
1314
|
+
const tx = new Transaction2();
|
|
1315
|
+
const params = [tx.pure.address(worldId)];
|
|
1263
1316
|
if (entityId !== void 0) {
|
|
1264
|
-
params.push(tx.pure(entityId));
|
|
1317
|
+
params.push(tx.pure.address(entityId));
|
|
1265
1318
|
}
|
|
1266
1319
|
const getResult = await this.query[schemaModuleName].contains(
|
|
1267
1320
|
tx,
|
|
@@ -1269,9 +1322,9 @@ var Obelisk = class {
|
|
|
1269
1322
|
);
|
|
1270
1323
|
if (getResult.effects.status.status === "success") {
|
|
1271
1324
|
const res = getResult.results[0].returnValues[0];
|
|
1272
|
-
|
|
1273
|
-
const value = Uint8Array.from(
|
|
1274
|
-
return
|
|
1325
|
+
let baseValue = res[0];
|
|
1326
|
+
const value = Uint8Array.from(baseValue);
|
|
1327
|
+
return bcs2.bool().parse(value);
|
|
1275
1328
|
} else {
|
|
1276
1329
|
return void 0;
|
|
1277
1330
|
}
|
|
@@ -1333,9 +1386,13 @@ var Obelisk = class {
|
|
|
1333
1386
|
async entity_key_from_bytes(bytes) {
|
|
1334
1387
|
const hashBytes = keccak256(bytes);
|
|
1335
1388
|
const hashU8Array = Array.from(hashBytes);
|
|
1336
|
-
const bcs = new BCS(getSuiMoveConfig());
|
|
1337
1389
|
const value = Uint8Array.from(hashU8Array);
|
|
1338
|
-
const
|
|
1390
|
+
const Address = bcs2.bytes(32).transform({
|
|
1391
|
+
// To change the input type, you need to provide a type definition for the input
|
|
1392
|
+
input: (val) => fromHEX2(val),
|
|
1393
|
+
output: (val) => toHEX(val)
|
|
1394
|
+
});
|
|
1395
|
+
const data = Address.parse(value);
|
|
1339
1396
|
return "0x" + data;
|
|
1340
1397
|
}
|
|
1341
1398
|
async entity_key_from_address_with_seed(objectId, seed) {
|
|
@@ -1353,9 +1410,8 @@ var Obelisk = class {
|
|
|
1353
1410
|
const checkObjectId = normalizeHexAddress(objectId);
|
|
1354
1411
|
if (checkObjectId !== null) {
|
|
1355
1412
|
objectId = checkObjectId;
|
|
1356
|
-
const bcs = new BCS(getSuiMoveConfig());
|
|
1357
1413
|
const bytes = Buffer.from(objectId.slice(2), "hex");
|
|
1358
|
-
const numberBytes =
|
|
1414
|
+
const numberBytes = bcs2.u256().serialize(x).toBytes();
|
|
1359
1415
|
return this.entity_key_from_bytes(Buffer.concat([bytes, numberBytes]));
|
|
1360
1416
|
} else {
|
|
1361
1417
|
return void 0;
|
|
@@ -1364,23 +1420,65 @@ var Obelisk = class {
|
|
|
1364
1420
|
async entity_key_from_u256(x) {
|
|
1365
1421
|
return numberToAddressHex(x);
|
|
1366
1422
|
}
|
|
1367
|
-
async formatData(type, value) {
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1423
|
+
// async formatData(type: string, value: Buffer | number[] | Uint8Array) {
|
|
1424
|
+
// const u8Value = Uint8Array.from(value);
|
|
1425
|
+
// return bcs.de(type, u8Value);
|
|
1426
|
+
// }
|
|
1427
|
+
async autoFormatDryValue(value) {
|
|
1428
|
+
let returnValues = [];
|
|
1429
|
+
if (value.effects.status.status === "success") {
|
|
1430
|
+
const resultList = value.results[0].returnValues;
|
|
1431
|
+
for (const res of resultList) {
|
|
1432
|
+
let baseValue = res[0];
|
|
1433
|
+
let baseType = res[1];
|
|
1434
|
+
const value2 = Uint8Array.from(baseValue);
|
|
1435
|
+
if (baseType === "address") {
|
|
1436
|
+
const Address = bcs2.bytes(32).transform({
|
|
1437
|
+
// To change the input type, you need to provide a type definition for the input
|
|
1438
|
+
input: (val) => fromHEX2(val),
|
|
1439
|
+
output: (val) => toHEX(val)
|
|
1440
|
+
});
|
|
1441
|
+
returnValues.push(Address.parse(value2));
|
|
1442
|
+
} else if (baseType === "u8") {
|
|
1443
|
+
returnValues.push(bcs2.u8().parse(value2));
|
|
1444
|
+
} else if (baseType === "u16") {
|
|
1445
|
+
returnValues.push(bcs2.u16().parse(value2));
|
|
1446
|
+
} else if (baseType === "u32") {
|
|
1447
|
+
returnValues.push(bcs2.u32().parse(value2));
|
|
1448
|
+
} else if (baseType === "u64") {
|
|
1449
|
+
returnValues.push(bcs2.u64().parse(value2));
|
|
1450
|
+
} else if (baseType === "u128") {
|
|
1451
|
+
returnValues.push(bcs2.u128().parse(value2));
|
|
1452
|
+
} else if (baseType === "u256") {
|
|
1453
|
+
returnValues.push(bcs2.u256().parse(value2));
|
|
1454
|
+
} else if (baseType === "bool") {
|
|
1455
|
+
returnValues.push(bcs2.bool().parse(value2));
|
|
1456
|
+
} else if (baseType === "0x1::ascii::String") {
|
|
1457
|
+
returnValues.push(bcs2.string().parse(value2));
|
|
1458
|
+
} else if (baseType === "vector<u8>") {
|
|
1459
|
+
returnValues.push(bcs2.vector(bcs2.u8()).parse(value2));
|
|
1460
|
+
} else if (baseType === "0x1::option::Option<u8>") {
|
|
1461
|
+
returnValues.push(bcs2.option(bcs2.u8()).parse(value2));
|
|
1462
|
+
}
|
|
1463
|
+
}
|
|
1464
|
+
return returnValues;
|
|
1465
|
+
} else {
|
|
1466
|
+
return void 0;
|
|
1467
|
+
}
|
|
1371
1468
|
}
|
|
1372
1469
|
};
|
|
1373
1470
|
_query = new WeakMap();
|
|
1374
1471
|
_tx = new WeakMap();
|
|
1472
|
+
_struct = new WeakMap();
|
|
1375
1473
|
_exec = new WeakMap();
|
|
1376
1474
|
_read = new WeakMap();
|
|
1377
1475
|
|
|
1378
1476
|
// src/libs/multiSig/client.ts
|
|
1379
|
-
import { MultiSigPublicKey } from "@mysten/sui
|
|
1477
|
+
import { MultiSigPublicKey } from "@mysten/sui/multisig";
|
|
1380
1478
|
|
|
1381
1479
|
// src/libs/multiSig/publickey.ts
|
|
1382
|
-
import { Ed25519PublicKey } from "@mysten/sui
|
|
1383
|
-
import { fromB64 as fromB642 } from "@mysten/sui
|
|
1480
|
+
import { Ed25519PublicKey } from "@mysten/sui/keypairs/ed25519";
|
|
1481
|
+
import { fromB64 as fromB642 } from "@mysten/sui/utils";
|
|
1384
1482
|
function ed25519PublicKeyFromBase64(rawPubkey) {
|
|
1385
1483
|
let bytes = fromB642(rawPubkey);
|
|
1386
1484
|
if (bytes.length !== 32 && bytes.length !== 33)
|
|
@@ -1417,7 +1515,7 @@ var MultiSigClient = class _MultiSigClient {
|
|
|
1417
1515
|
};
|
|
1418
1516
|
|
|
1419
1517
|
// src/metadata/index.ts
|
|
1420
|
-
import { getFullnodeUrl as getFullnodeUrl2 } from "@mysten/sui
|
|
1518
|
+
import { getFullnodeUrl as getFullnodeUrl2 } from "@mysten/sui/client";
|
|
1421
1519
|
async function loadMetadata(networkType, packageId) {
|
|
1422
1520
|
const fullnodeUrls = [getFullnodeUrl2(networkType)];
|
|
1423
1521
|
const suiInteractor = new SuiInteractor(fullnodeUrls);
|
|
@@ -1431,13 +1529,13 @@ async function loadMetadata(networkType, packageId) {
|
|
|
1431
1529
|
}
|
|
1432
1530
|
}
|
|
1433
1531
|
export {
|
|
1434
|
-
|
|
1532
|
+
BcsType,
|
|
1435
1533
|
MultiSigClient,
|
|
1436
1534
|
Obelisk,
|
|
1437
1535
|
SuiAccountManager,
|
|
1438
1536
|
SuiContractFactory,
|
|
1439
|
-
|
|
1440
|
-
|
|
1537
|
+
SuiTx,
|
|
1538
|
+
bcs3 as bcs,
|
|
1441
1539
|
loadMetadata
|
|
1442
1540
|
};
|
|
1443
1541
|
//# sourceMappingURL=index.mjs.map
|