@0xobelisk/sui-client 0.5.21 → 0.5.23
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 +14 -47
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -47
- package/dist/index.mjs.map +1 -1
- package/dist/libs/suiInteractor/suiInteractor.d.ts +1 -0
- package/dist/libs/suiTxBuilder/index.d.ts +29 -220
- package/dist/libs/suiTxBuilder/util.d.ts +2 -2
- package/dist/obelisk.d.ts +2 -2
- package/dist/types/index.d.ts +2 -0
- package/package.json +7 -7
- package/src/libs/suiInteractor/suiInteractor.ts +2 -0
- package/src/libs/suiTxBuilder/index.ts +22 -21
- package/src/libs/suiTxBuilder/util.ts +2 -4
- package/src/obelisk.ts +13 -41
- package/src/types/index.ts +5 -2
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Transaction } from '@mysten/sui/transactions';
|
|
2
2
|
import type { SuiClient, SuiObjectRef } from '@mysten/sui/client';
|
|
3
|
-
import type { TransactionObjectArgument, TransactionObjectInput } from '@mysten/sui/transactions';
|
|
3
|
+
import type { TransactionArgument, TransactionObjectArgument, TransactionObjectInput } from '@mysten/sui/transactions';
|
|
4
4
|
import type { Keypair } from '@mysten/sui/cryptography';
|
|
5
|
-
import { SerializedBcs } from '@mysten/bcs';
|
|
6
5
|
import type { SuiTxArg, SuiAddressArg, SuiObjectArg, SuiVecTxArg, SuiAmountsArg } from '../../types';
|
|
7
6
|
import type { bcs } from '@mysten/sui/bcs';
|
|
8
7
|
export declare class SuiTx {
|
|
@@ -25,21 +24,6 @@ export declare class SuiTx {
|
|
|
25
24
|
value: unknown;
|
|
26
25
|
index: number;
|
|
27
26
|
})[];
|
|
28
|
-
expiration: {
|
|
29
|
-
Epoch: number;
|
|
30
|
-
} | {
|
|
31
|
-
None: true | null;
|
|
32
|
-
} | null | undefined;
|
|
33
|
-
gasConfig: {
|
|
34
|
-
payment?: {
|
|
35
|
-
objectId: string;
|
|
36
|
-
version: string | number | bigint;
|
|
37
|
-
digest: string;
|
|
38
|
-
}[] | undefined;
|
|
39
|
-
owner?: string | undefined;
|
|
40
|
-
price?: string | number | bigint | undefined;
|
|
41
|
-
budget?: string | number | bigint | undefined;
|
|
42
|
-
};
|
|
43
27
|
transactions: ({
|
|
44
28
|
typeArguments: string[];
|
|
45
29
|
arguments: ({
|
|
@@ -247,9 +231,23 @@ export declare class SuiTx {
|
|
|
247
231
|
kind: "Upgrade";
|
|
248
232
|
packageId: string;
|
|
249
233
|
})[];
|
|
234
|
+
gasConfig: {
|
|
235
|
+
payment?: {
|
|
236
|
+
objectId: string;
|
|
237
|
+
version: string | number | bigint;
|
|
238
|
+
digest: string;
|
|
239
|
+
}[] | undefined;
|
|
240
|
+
owner?: string | undefined;
|
|
241
|
+
price?: string | number | bigint | undefined;
|
|
242
|
+
budget?: string | number | bigint | undefined;
|
|
243
|
+
};
|
|
250
244
|
sender?: string | undefined;
|
|
245
|
+
expiration?: {
|
|
246
|
+
Epoch: number;
|
|
247
|
+
} | {
|
|
248
|
+
None: true | null;
|
|
249
|
+
} | null | undefined;
|
|
251
250
|
};
|
|
252
|
-
autoPure(value: SuiTxArg, type?: string): import("@mysten/sui/transactions").TransactionArgument[] | undefined;
|
|
253
251
|
address(value: string): {
|
|
254
252
|
$kind: "GasCoin";
|
|
255
253
|
GasCoin: true;
|
|
@@ -269,204 +267,15 @@ export declare class SuiTx {
|
|
|
269
267
|
NestedResult: [number, number];
|
|
270
268
|
};
|
|
271
269
|
get pure(): {
|
|
272
|
-
(value:
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
Input: number;
|
|
282
|
-
type?: "object" | undefined;
|
|
283
|
-
} | {
|
|
284
|
-
$kind: "Result";
|
|
285
|
-
Result: number;
|
|
286
|
-
} | {
|
|
287
|
-
$kind: "NestedResult";
|
|
288
|
-
NestedResult: [number, number];
|
|
289
|
-
};
|
|
290
|
-
u8(value: number): {
|
|
291
|
-
$kind: "GasCoin";
|
|
292
|
-
GasCoin: true;
|
|
293
|
-
} | {
|
|
294
|
-
$kind: "Input";
|
|
295
|
-
Input: number;
|
|
296
|
-
type?: "pure" | undefined;
|
|
297
|
-
} | {
|
|
298
|
-
$kind: "Input";
|
|
299
|
-
Input: number;
|
|
300
|
-
type?: "object" | undefined;
|
|
301
|
-
} | {
|
|
302
|
-
$kind: "Result";
|
|
303
|
-
Result: number;
|
|
304
|
-
} | {
|
|
305
|
-
$kind: "NestedResult";
|
|
306
|
-
NestedResult: [number, number];
|
|
307
|
-
};
|
|
308
|
-
u16(value: number): {
|
|
309
|
-
$kind: "GasCoin";
|
|
310
|
-
GasCoin: true;
|
|
311
|
-
} | {
|
|
312
|
-
$kind: "Input";
|
|
313
|
-
Input: number;
|
|
314
|
-
type?: "pure" | undefined;
|
|
315
|
-
} | {
|
|
316
|
-
$kind: "Input";
|
|
317
|
-
Input: number;
|
|
318
|
-
type?: "object" | undefined;
|
|
319
|
-
} | {
|
|
320
|
-
$kind: "Result";
|
|
321
|
-
Result: number;
|
|
322
|
-
} | {
|
|
323
|
-
$kind: "NestedResult";
|
|
324
|
-
NestedResult: [number, number];
|
|
325
|
-
};
|
|
326
|
-
u32(value: number): {
|
|
327
|
-
$kind: "GasCoin";
|
|
328
|
-
GasCoin: true;
|
|
329
|
-
} | {
|
|
330
|
-
$kind: "Input";
|
|
331
|
-
Input: number;
|
|
332
|
-
type?: "pure" | undefined;
|
|
333
|
-
} | {
|
|
334
|
-
$kind: "Input";
|
|
335
|
-
Input: number;
|
|
336
|
-
type?: "object" | undefined;
|
|
337
|
-
} | {
|
|
338
|
-
$kind: "Result";
|
|
339
|
-
Result: number;
|
|
340
|
-
} | {
|
|
341
|
-
$kind: "NestedResult";
|
|
342
|
-
NestedResult: [number, number];
|
|
343
|
-
};
|
|
344
|
-
u64(value: string | number | bigint): {
|
|
345
|
-
$kind: "GasCoin";
|
|
346
|
-
GasCoin: true;
|
|
347
|
-
} | {
|
|
348
|
-
$kind: "Input";
|
|
349
|
-
Input: number;
|
|
350
|
-
type?: "pure" | undefined;
|
|
351
|
-
} | {
|
|
352
|
-
$kind: "Input";
|
|
353
|
-
Input: number;
|
|
354
|
-
type?: "object" | undefined;
|
|
355
|
-
} | {
|
|
356
|
-
$kind: "Result";
|
|
357
|
-
Result: number;
|
|
358
|
-
} | {
|
|
359
|
-
$kind: "NestedResult";
|
|
360
|
-
NestedResult: [number, number];
|
|
361
|
-
};
|
|
362
|
-
u128(value: string | number | bigint): {
|
|
363
|
-
$kind: "GasCoin";
|
|
364
|
-
GasCoin: true;
|
|
365
|
-
} | {
|
|
366
|
-
$kind: "Input";
|
|
367
|
-
Input: number;
|
|
368
|
-
type?: "pure" | undefined;
|
|
369
|
-
} | {
|
|
370
|
-
$kind: "Input";
|
|
371
|
-
Input: number;
|
|
372
|
-
type?: "object" | undefined;
|
|
373
|
-
} | {
|
|
374
|
-
$kind: "Result";
|
|
375
|
-
Result: number;
|
|
376
|
-
} | {
|
|
377
|
-
$kind: "NestedResult";
|
|
378
|
-
NestedResult: [number, number];
|
|
379
|
-
};
|
|
380
|
-
u256(value: string | number | bigint): {
|
|
381
|
-
$kind: "GasCoin";
|
|
382
|
-
GasCoin: true;
|
|
383
|
-
} | {
|
|
384
|
-
$kind: "Input";
|
|
385
|
-
Input: number;
|
|
386
|
-
type?: "pure" | undefined;
|
|
387
|
-
} | {
|
|
388
|
-
$kind: "Input";
|
|
389
|
-
Input: number;
|
|
390
|
-
type?: "object" | undefined;
|
|
391
|
-
} | {
|
|
392
|
-
$kind: "Result";
|
|
393
|
-
Result: number;
|
|
394
|
-
} | {
|
|
395
|
-
$kind: "NestedResult";
|
|
396
|
-
NestedResult: [number, number];
|
|
397
|
-
};
|
|
398
|
-
bool(value: boolean): {
|
|
399
|
-
$kind: "GasCoin";
|
|
400
|
-
GasCoin: true;
|
|
401
|
-
} | {
|
|
402
|
-
$kind: "Input";
|
|
403
|
-
Input: number;
|
|
404
|
-
type?: "pure" | undefined;
|
|
405
|
-
} | {
|
|
406
|
-
$kind: "Input";
|
|
407
|
-
Input: number;
|
|
408
|
-
type?: "object" | undefined;
|
|
409
|
-
} | {
|
|
410
|
-
$kind: "Result";
|
|
411
|
-
Result: number;
|
|
412
|
-
} | {
|
|
413
|
-
$kind: "NestedResult";
|
|
414
|
-
NestedResult: [number, number];
|
|
415
|
-
};
|
|
416
|
-
string(value: string): {
|
|
417
|
-
$kind: "GasCoin";
|
|
418
|
-
GasCoin: true;
|
|
419
|
-
} | {
|
|
420
|
-
$kind: "Input";
|
|
421
|
-
Input: number;
|
|
422
|
-
type?: "pure" | undefined;
|
|
423
|
-
} | {
|
|
424
|
-
$kind: "Input";
|
|
425
|
-
Input: number;
|
|
426
|
-
type?: "object" | undefined;
|
|
427
|
-
} | {
|
|
428
|
-
$kind: "Result";
|
|
429
|
-
Result: number;
|
|
430
|
-
} | {
|
|
431
|
-
$kind: "NestedResult";
|
|
432
|
-
NestedResult: [number, number];
|
|
433
|
-
};
|
|
434
|
-
address(value: string): {
|
|
435
|
-
$kind: "GasCoin";
|
|
436
|
-
GasCoin: true;
|
|
437
|
-
} | {
|
|
438
|
-
$kind: "Input";
|
|
439
|
-
Input: number;
|
|
440
|
-
type?: "pure" | undefined;
|
|
441
|
-
} | {
|
|
442
|
-
$kind: "Input";
|
|
443
|
-
Input: number;
|
|
444
|
-
type?: "object" | undefined;
|
|
445
|
-
} | {
|
|
446
|
-
$kind: "Result";
|
|
447
|
-
Result: number;
|
|
448
|
-
} | {
|
|
449
|
-
$kind: "NestedResult";
|
|
450
|
-
NestedResult: [number, number];
|
|
451
|
-
};
|
|
452
|
-
id: (value: string) => {
|
|
453
|
-
$kind: "GasCoin";
|
|
454
|
-
GasCoin: true;
|
|
455
|
-
} | {
|
|
456
|
-
$kind: "Input";
|
|
457
|
-
Input: number;
|
|
458
|
-
type?: "pure" | undefined;
|
|
459
|
-
} | {
|
|
460
|
-
$kind: "Input";
|
|
461
|
-
Input: number;
|
|
462
|
-
type?: "object" | undefined;
|
|
463
|
-
} | {
|
|
464
|
-
$kind: "Result";
|
|
465
|
-
Result: number;
|
|
466
|
-
} | {
|
|
467
|
-
$kind: "NestedResult";
|
|
468
|
-
NestedResult: [number, number];
|
|
469
|
-
};
|
|
270
|
+
<T extends TransactionArgument>(value: T): TransactionArgument;
|
|
271
|
+
address(value: string): TransactionArgument;
|
|
272
|
+
u8(value: number | bigint): TransactionArgument;
|
|
273
|
+
u16(value: number | bigint): TransactionArgument;
|
|
274
|
+
u32(value: number | bigint): TransactionArgument;
|
|
275
|
+
u64(value: number | bigint): TransactionArgument;
|
|
276
|
+
u128(value: number | bigint): TransactionArgument;
|
|
277
|
+
u256(value: number | bigint): TransactionArgument;
|
|
278
|
+
bool(value: boolean): TransactionArgument;
|
|
470
279
|
};
|
|
471
280
|
object(value: string | TransactionObjectInput): {
|
|
472
281
|
$kind: "Input";
|
|
@@ -504,7 +313,7 @@ export declare class SuiTx {
|
|
|
504
313
|
getDigest(params?: {
|
|
505
314
|
client?: SuiClient;
|
|
506
315
|
}): Promise<string>;
|
|
507
|
-
add(...args: Parameters<typeof this.tx.add>):
|
|
316
|
+
add(...args: Parameters<typeof this.tx.add>): unknown;
|
|
508
317
|
publish({ modules, dependencies, }: {
|
|
509
318
|
modules: number[][] | string[];
|
|
510
319
|
dependencies: string[];
|
|
@@ -512,7 +321,7 @@ export declare class SuiTx {
|
|
|
512
321
|
upgrade(...args: Parameters<typeof this.tx.upgrade>): import("@mysten/sui/transactions").TransactionResult;
|
|
513
322
|
makeMoveVec(...args: Parameters<typeof this.tx.makeMoveVec>): import("@mysten/sui/transactions").TransactionResult;
|
|
514
323
|
transferObjects(objects: SuiObjectArg[], address: SuiAddressArg): import("@mysten/sui/transactions").TransactionResult;
|
|
515
|
-
splitCoins(coin: SuiObjectArg, amounts:
|
|
324
|
+
splitCoins(coin: SuiObjectArg, amounts: SuiAmountsArg[]): {
|
|
516
325
|
$kind: "NestedResult";
|
|
517
326
|
NestedResult: [number, number];
|
|
518
327
|
}[];
|
|
@@ -527,12 +336,12 @@ export declare class SuiTx {
|
|
|
527
336
|
transferSuiToMany(recipients: SuiAddressArg[], amounts: (SuiTxArg | number | bigint)[]): this;
|
|
528
337
|
transferSui(address: SuiAddressArg, amount: SuiTxArg | number | bigint): this;
|
|
529
338
|
takeAmountFromCoins(coins: SuiObjectArg[], amount: SuiTxArg | number | bigint): TransactionObjectArgument[];
|
|
530
|
-
splitSUIFromGas(amounts:
|
|
339
|
+
splitSUIFromGas(amounts: SuiAmountsArg[]): import("@mysten/sui/transactions").TransactionResult;
|
|
531
340
|
splitMultiCoins(coins: SuiObjectArg[], amounts: SuiAmountsArg[]): {
|
|
532
341
|
splitedCoins: import("@mysten/sui/transactions").TransactionResult;
|
|
533
342
|
mergedCoin: TransactionObjectArgument;
|
|
534
343
|
};
|
|
535
344
|
transferCoinToMany(coins: SuiObjectArg[], sender: SuiAddressArg, recipients: SuiAddressArg[], amounts: SuiAmountsArg[]): this;
|
|
536
|
-
transferCoin(coins: SuiObjectArg[], sender: SuiAddressArg, recipient: SuiAddressArg, amount:
|
|
345
|
+
transferCoin(coins: SuiObjectArg[], sender: SuiAddressArg, recipient: SuiAddressArg, amount: SuiAmountsArg): this;
|
|
537
346
|
stakeSui(amount: SuiTxArg | number | bigint, validatorAddr: SuiAddressArg): import("@mysten/sui/transactions").TransactionResult;
|
|
538
347
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TransactionArgument, Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
|
|
2
|
-
import type { SuiObjectArg, SuiAddressArg, SuiTxArg, SuiVecTxArg, SuiInputTypes } from 'src/types';
|
|
2
|
+
import type { SuiObjectArg, SuiAddressArg, SuiTxArg, SuiVecTxArg, SuiInputTypes, SuiAmountsArg } from 'src/types';
|
|
3
3
|
export declare const getDefaultSuiInputType: (value: SuiTxArg) => 'u64' | 'bool' | 'object' | undefined;
|
|
4
4
|
/**
|
|
5
5
|
* Since we know the elements in the array are the same type
|
|
@@ -46,4 +46,4 @@ export declare function convertAddressArg(txBlock: Transaction, arg: SuiAddressA
|
|
|
46
46
|
* @returns The converted TransactionArgument.
|
|
47
47
|
*/
|
|
48
48
|
export declare function convertObjArg(txb: Transaction, arg: SuiObjectArg): TransactionObjectArgument;
|
|
49
|
-
export declare function convertAmounts(txBlock: Transaction, amounts:
|
|
49
|
+
export declare function convertAmounts(txBlock: Transaction, amounts: SuiAmountsArg[]): (number | bigint | TransactionArgument)[];
|
package/dist/obelisk.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { SuiInteractor } from './libs/suiInteractor';
|
|
|
7
7
|
import { MapObjectStruct } from './types';
|
|
8
8
|
import { SuiContractFactory } from './libs/suiContractFactory';
|
|
9
9
|
import { SuiMoveMoudleFuncType } from './libs/suiContractFactory/types';
|
|
10
|
-
import { DerivePathParams, FaucetNetworkType, MapMoudleFuncQuery, MapMoudleFuncTx, ObeliskParams, SuiTxArg, SuiVecTxArg } from './types';
|
|
10
|
+
import { DerivePathParams, FaucetNetworkType, MapMoudleFuncQuery, MapMoudleFuncTx, ObeliskParams, SuiTxArg, SuiObjectArg, SuiVecTxArg } from './types';
|
|
11
11
|
export declare function isUndefined(value?: unknown): value is undefined;
|
|
12
12
|
export declare function withMeta<T extends {
|
|
13
13
|
meta: SuiMoveMoudleFuncType;
|
|
@@ -97,7 +97,7 @@ export declare class Obelisk {
|
|
|
97
97
|
*/
|
|
98
98
|
transferCoinToMany(recipients: string[], amounts: number[], coinType: string, derivePathParams?: DerivePathParams): Promise<SuiTransactionBlockResponse>;
|
|
99
99
|
transferCoin(recipient: string, amount: number, coinType: string, derivePathParams?: DerivePathParams): Promise<SuiTransactionBlockResponse>;
|
|
100
|
-
transferObjects(objects:
|
|
100
|
+
transferObjects(objects: SuiObjectArg[], recipient: string, derivePathParams?: DerivePathParams): Promise<SuiTransactionBlockResponse>;
|
|
101
101
|
moveCall(callParams: {
|
|
102
102
|
target: string;
|
|
103
103
|
arguments?: (SuiTxArg | SuiVecTxArg)[];
|
package/dist/types/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { BcsType, SerializedBcs } from '@mysten/bcs';
|
|
|
3
3
|
import type { TransactionArgument } from '@mysten/sui/transactions';
|
|
4
4
|
import type { Transaction, TransactionObjectArgument, TransactionResult, Argument, Inputs } from '@mysten/sui/transactions';
|
|
5
5
|
import type { SuiMoveNormalizedModules, DevInspectResults, SuiTransactionBlockResponse, DisplayFieldsResponse, SuiMoveNormalizedType, MoveStruct } from '@mysten/sui/client';
|
|
6
|
+
import { SuiTx } from '../libs/suiTxBuilder';
|
|
6
7
|
import { SuiMoveMoudleFuncType } from '../libs/suiContractFactory/types';
|
|
7
8
|
export declare const ObjectContentFields: import("superstruct").Struct<Record<string, any>, null>;
|
|
8
9
|
export type ObjectContentFields = Infer<typeof ObjectContentFields>;
|
|
@@ -196,4 +197,5 @@ export type ObjectContent = {
|
|
|
196
197
|
hasPublicTransfer: boolean;
|
|
197
198
|
dataType: string;
|
|
198
199
|
};
|
|
200
|
+
export type SuiObeliskReturnType<T extends boolean> = T extends true ? SuiTransactionBlockResponse : SuiTx;
|
|
199
201
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xobelisk/sui-client",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.23",
|
|
4
4
|
"description": "Tookit for interacting with move eps framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sui",
|
|
@@ -37,13 +37,13 @@
|
|
|
37
37
|
"src"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@mysten/bcs": "^1.0.
|
|
41
|
-
"@mysten/sui": "^1.
|
|
40
|
+
"@mysten/bcs": "^1.0.4",
|
|
41
|
+
"@mysten/sui": "^1.7.0",
|
|
42
|
+
"@noble/curves": "^1.4.2",
|
|
43
|
+
"@noble/hashes": "^1.4.0",
|
|
44
|
+
"@scure/bip39": "^1.3.0",
|
|
42
45
|
"@mysten/zklogin": "^0.7.8",
|
|
43
46
|
"@graphql-typed-document-node/core": "^3.2.0",
|
|
44
|
-
"@noble/curves": "^1.2.0",
|
|
45
|
-
"@noble/hashes": "^1.3.2",
|
|
46
|
-
"@scure/bip39": "^1.2.1",
|
|
47
47
|
"@suchipi/femver": "^1.0.0",
|
|
48
48
|
"assert": "^2.1.0",
|
|
49
49
|
"bech32": "^2.0.0",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"gql.tada": "^1.7.0",
|
|
58
58
|
"graphql": "^16.8.1",
|
|
59
59
|
"tmp": "^0.2.1",
|
|
60
|
-
"valibot": "
|
|
60
|
+
"valibot": "0.36.0"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@commitlint/cli": "^18.0.0",
|
|
@@ -254,6 +254,7 @@ export class SuiInteractor {
|
|
|
254
254
|
objectId: string;
|
|
255
255
|
digest: string;
|
|
256
256
|
version: string;
|
|
257
|
+
balance: string;
|
|
257
258
|
}[] = [];
|
|
258
259
|
let totalAmount = 0;
|
|
259
260
|
let hasNext = true,
|
|
@@ -271,6 +272,7 @@ export class SuiInteractor {
|
|
|
271
272
|
objectId: coinData.coinObjectId,
|
|
272
273
|
digest: coinData.digest,
|
|
273
274
|
version: coinData.version,
|
|
275
|
+
balance: coinData.balance,
|
|
274
276
|
});
|
|
275
277
|
totalAmount = totalAmount + parseInt(coinData.balance);
|
|
276
278
|
if (totalAmount >= amount) {
|
|
@@ -2,6 +2,7 @@ import { Transaction } from '@mysten/sui/transactions';
|
|
|
2
2
|
import { SUI_SYSTEM_STATE_OBJECT_ID } from '@mysten/sui/utils';
|
|
3
3
|
import type { SuiClient, SuiObjectRef } from '@mysten/sui/client';
|
|
4
4
|
import type {
|
|
5
|
+
TransactionArgument,
|
|
5
6
|
TransactionObjectArgument,
|
|
6
7
|
TransactionObjectInput,
|
|
7
8
|
} from '@mysten/sui/transactions';
|
|
@@ -43,20 +44,21 @@ export class SuiTx {
|
|
|
43
44
|
get blockData() {
|
|
44
45
|
return this.tx.blockData;
|
|
45
46
|
}
|
|
46
|
-
|
|
47
|
-
autoPure(value: SuiTxArg, type?: string) {
|
|
48
|
-
if (type === undefined) {
|
|
49
|
-
return convertArgs(this.tx, [value]);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
47
|
address(value: string) {
|
|
56
48
|
return this.tx.pure.address(value);
|
|
57
49
|
}
|
|
58
|
-
get pure() {
|
|
59
|
-
|
|
50
|
+
get pure(): {
|
|
51
|
+
<T extends TransactionArgument>(value: T): TransactionArgument;
|
|
52
|
+
address(value: string): TransactionArgument;
|
|
53
|
+
u8(value: number | bigint): TransactionArgument;
|
|
54
|
+
u16(value: number | bigint): TransactionArgument;
|
|
55
|
+
u32(value: number | bigint): TransactionArgument;
|
|
56
|
+
u64(value: number | bigint): TransactionArgument;
|
|
57
|
+
u128(value: number | bigint): TransactionArgument;
|
|
58
|
+
u256(value: number | bigint): TransactionArgument;
|
|
59
|
+
bool(value: boolean): TransactionArgument;
|
|
60
|
+
} {
|
|
61
|
+
return this.tx.pure;
|
|
60
62
|
}
|
|
61
63
|
object(value: string | TransactionObjectInput) {
|
|
62
64
|
return this.tx.object(value);
|
|
@@ -140,10 +142,10 @@ export class SuiTx {
|
|
|
140
142
|
);
|
|
141
143
|
}
|
|
142
144
|
|
|
143
|
-
splitCoins(coin: SuiObjectArg, amounts:
|
|
145
|
+
splitCoins(coin: SuiObjectArg, amounts: SuiAmountsArg[]) {
|
|
144
146
|
const res = this.tx.splitCoins(
|
|
145
147
|
convertObjArg(this.tx, coin),
|
|
146
|
-
|
|
148
|
+
convertAmounts(this.tx, amounts)
|
|
147
149
|
);
|
|
148
150
|
return amounts.map((_, i) => res[i]);
|
|
149
151
|
}
|
|
@@ -225,16 +227,15 @@ export class SuiTx {
|
|
|
225
227
|
if (coins.length > 1) {
|
|
226
228
|
this.tx.mergeCoins(mergedCoin, coinObjects.slice(1));
|
|
227
229
|
}
|
|
228
|
-
const [sendCoin] = this.tx.splitCoins(
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
]);
|
|
230
|
+
const [sendCoin] = this.tx.splitCoins(
|
|
231
|
+
mergedCoin,
|
|
232
|
+
convertAmounts(this.tx, [amount])
|
|
233
|
+
);
|
|
233
234
|
return [sendCoin, mergedCoin];
|
|
234
235
|
}
|
|
235
236
|
|
|
236
|
-
splitSUIFromGas(amounts:
|
|
237
|
-
return this.tx.splitCoins(this.tx.gas,
|
|
237
|
+
splitSUIFromGas(amounts: SuiAmountsArg[]) {
|
|
238
|
+
return this.tx.splitCoins(this.tx.gas, convertAmounts(this.tx, amounts));
|
|
238
239
|
}
|
|
239
240
|
|
|
240
241
|
splitMultiCoins(coins: SuiObjectArg[], amounts: SuiAmountsArg[]) {
|
|
@@ -281,7 +282,7 @@ export class SuiTx {
|
|
|
281
282
|
coins: SuiObjectArg[],
|
|
282
283
|
sender: SuiAddressArg,
|
|
283
284
|
recipient: SuiAddressArg,
|
|
284
|
-
amount:
|
|
285
|
+
amount: SuiAmountsArg
|
|
285
286
|
) {
|
|
286
287
|
return this.transferCoinToMany(coins, sender, [recipient], [amount]);
|
|
287
288
|
}
|
|
@@ -17,6 +17,7 @@ import type {
|
|
|
17
17
|
SuiTxArg,
|
|
18
18
|
SuiVecTxArg,
|
|
19
19
|
SuiInputTypes,
|
|
20
|
+
SuiAmountsArg,
|
|
20
21
|
} from 'src/types';
|
|
21
22
|
|
|
22
23
|
export const getDefaultSuiInputType = (
|
|
@@ -191,10 +192,7 @@ export function convertObjArg(
|
|
|
191
192
|
throw new Error('Invalid argument type');
|
|
192
193
|
}
|
|
193
194
|
|
|
194
|
-
export function convertAmounts(
|
|
195
|
-
txBlock: Transaction,
|
|
196
|
-
amounts: (SuiTxArg | number | bigint)[]
|
|
197
|
-
): (TransactionArgument | number | bigint)[] {
|
|
195
|
+
export function convertAmounts(txBlock: Transaction, amounts: SuiAmountsArg[]) {
|
|
198
196
|
return amounts.map((amount) => {
|
|
199
197
|
if (typeof amount === 'number' || typeof amount === 'bigint') {
|
|
200
198
|
return amount;
|
package/src/obelisk.ts
CHANGED
|
@@ -13,7 +13,12 @@ import type {
|
|
|
13
13
|
import { SuiAccountManager } from './libs/suiAccountManager';
|
|
14
14
|
import { SuiTx } from './libs/suiTxBuilder';
|
|
15
15
|
import { SuiInteractor } from './libs/suiInteractor';
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
MapObjectStruct,
|
|
18
|
+
MoveStructType,
|
|
19
|
+
ObeliskObjectContent,
|
|
20
|
+
SuiObeliskReturnType,
|
|
21
|
+
} from './types';
|
|
17
22
|
import { SuiContractFactory } from './libs/suiContractFactory';
|
|
18
23
|
import {
|
|
19
24
|
SuiMoveMoudleFuncType,
|
|
@@ -29,6 +34,7 @@ import {
|
|
|
29
34
|
ObeliskParams,
|
|
30
35
|
SuiTxArg,
|
|
31
36
|
// SuiTxArgument,
|
|
37
|
+
SuiObjectArg,
|
|
32
38
|
SuiVecTxArg,
|
|
33
39
|
} from './types';
|
|
34
40
|
import { normalizeHexAddress, numberToAddressHex } from './utils';
|
|
@@ -121,6 +127,7 @@ export class Obelisk {
|
|
|
121
127
|
u256: bcs.u256(),
|
|
122
128
|
bool: bcs.bool(),
|
|
123
129
|
'0x1::ascii::String': bcs.string(),
|
|
130
|
+
'0x1::string::String': bcs.string(),
|
|
124
131
|
'0x1::option::Option<address>': bcs.option(
|
|
125
132
|
bcs.bytes(32).transform({
|
|
126
133
|
// To change the input type, you need to provide a type definition for the input
|
|
@@ -727,7 +734,7 @@ export class Obelisk {
|
|
|
727
734
|
}
|
|
728
735
|
|
|
729
736
|
async transferObjects(
|
|
730
|
-
objects:
|
|
737
|
+
objects: SuiObjectArg[],
|
|
731
738
|
recipient: string,
|
|
732
739
|
derivePathParams?: DerivePathParams
|
|
733
740
|
) {
|
|
@@ -832,17 +839,16 @@ export class Obelisk {
|
|
|
832
839
|
): Promise<any[] | undefined> {
|
|
833
840
|
const schemaModuleName = `${schemaName}_schema`;
|
|
834
841
|
const tx = new Transaction();
|
|
835
|
-
const params = [tx.
|
|
842
|
+
const params = [tx.object(worldId)] as TransactionArgument[];
|
|
836
843
|
|
|
837
844
|
if (entityId !== undefined) {
|
|
838
|
-
params.push(tx.
|
|
845
|
+
params.push(tx.object(entityId));
|
|
839
846
|
}
|
|
840
847
|
|
|
841
848
|
const dryResult = (await this.query[schemaModuleName].get(
|
|
842
849
|
tx,
|
|
843
850
|
params
|
|
844
851
|
)) as DevInspectResults;
|
|
845
|
-
|
|
846
852
|
// "success" | "failure";
|
|
847
853
|
return this.view(dryResult);
|
|
848
854
|
}
|
|
@@ -854,10 +860,10 @@ export class Obelisk {
|
|
|
854
860
|
): Promise<boolean | undefined> {
|
|
855
861
|
const schemaModuleName = `${schemaName}_schema`;
|
|
856
862
|
const tx = new Transaction();
|
|
857
|
-
const params = [tx.
|
|
863
|
+
const params = [tx.object(worldId)] as TransactionArgument[];
|
|
858
864
|
|
|
859
865
|
if (entityId !== undefined) {
|
|
860
|
-
params.push(tx.
|
|
866
|
+
params.push(tx.object(entityId));
|
|
861
867
|
}
|
|
862
868
|
|
|
863
869
|
const dryResult = (await this.query[schemaModuleName].contains(
|
|
@@ -868,40 +874,6 @@ export class Obelisk {
|
|
|
868
874
|
return this.view(dryResult) as boolean | undefined;
|
|
869
875
|
}
|
|
870
876
|
|
|
871
|
-
// async getEntities(
|
|
872
|
-
// worldId: string,
|
|
873
|
-
// schemaName: string,
|
|
874
|
-
// cursor?: string,
|
|
875
|
-
// limit?: number
|
|
876
|
-
// ) {
|
|
877
|
-
// let schemaModuleName = `${schemaName}_schema`;
|
|
878
|
-
|
|
879
|
-
// const tx = new TransactionBlock();
|
|
880
|
-
// let params = [tx.pure(worldId)] as SuiTxArgument[];
|
|
881
|
-
|
|
882
|
-
// const tableResult = (await this.query[schemaonentModuleName].entities(
|
|
883
|
-
// tx,
|
|
884
|
-
// params
|
|
885
|
-
// )) as DevInspectResults;
|
|
886
|
-
// const entities = tableResult.results as SuiReturnValues;
|
|
887
|
-
// const bcs = new BCS(getSuiMoveConfig());
|
|
888
|
-
|
|
889
|
-
// let value = Uint8Array.from(entities[0].returnValues[0][0]);
|
|
890
|
-
// let tableId = '0x' + bcs.de('address', value);
|
|
891
|
-
// let dynamicFields = await this.suiInteractor.getDynamicFields(
|
|
892
|
-
// tableId,
|
|
893
|
-
// cursor,
|
|
894
|
-
// limit
|
|
895
|
-
// );
|
|
896
|
-
// let objectIds = dynamicFields.data.map((field) => field.objectId);
|
|
897
|
-
// let objectDatas = await this.suiInteractor.getEntitiesObjects(objectIds);
|
|
898
|
-
// return {
|
|
899
|
-
// data: objectDatas,
|
|
900
|
-
// nextCursor: dynamicFields.nextCursor,
|
|
901
|
-
// hasNextPage: dynamicFields.hasNextPage,
|
|
902
|
-
// };
|
|
903
|
-
// }
|
|
904
|
-
|
|
905
877
|
async getOwnedObjects(owner: string, cursor?: string, limit?: number) {
|
|
906
878
|
const ownedObjects = await this.suiInteractor.getOwnedObjects(
|
|
907
879
|
owner,
|
package/src/types/index.ts
CHANGED
|
@@ -18,8 +18,7 @@ import type {
|
|
|
18
18
|
SuiMoveNormalizedType,
|
|
19
19
|
MoveStruct,
|
|
20
20
|
} from '@mysten/sui/client';
|
|
21
|
-
import {
|
|
22
|
-
import { bcs as BCS } from '@mysten/bcs';
|
|
21
|
+
import { SuiTx } from '../libs/suiTxBuilder';
|
|
23
22
|
|
|
24
23
|
import { SuiMoveMoudleFuncType } from '../libs/suiContractFactory/types';
|
|
25
24
|
|
|
@@ -275,3 +274,7 @@ export type ObjectContent = {
|
|
|
275
274
|
hasPublicTransfer: boolean;
|
|
276
275
|
dataType: string;
|
|
277
276
|
};
|
|
277
|
+
|
|
278
|
+
export type SuiObeliskReturnType<T extends boolean> = T extends true
|
|
279
|
+
? SuiTransactionBlockResponse
|
|
280
|
+
: SuiTx;
|