@scallop-io/sui-kit 1.4.2 → 2.0.0

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.
Files changed (37) hide show
  1. package/README.md +2 -2
  2. package/dist/index.cjs +32 -0
  3. package/dist/index.d.cts +747 -0
  4. package/dist/index.d.ts +745 -6
  5. package/dist/index.js +13 -29
  6. package/package.json +14 -13
  7. package/src/index.ts +10 -6
  8. package/src/libs/multiSig/client.ts +1 -1
  9. package/src/libs/multiSig/index.ts +1 -1
  10. package/src/libs/suiAccountManager/index.ts +7 -4
  11. package/src/libs/suiAccountManager/keypair.ts +1 -1
  12. package/src/libs/suiInteractor/index.ts +7 -1
  13. package/src/libs/suiInteractor/suiInteractor.ts +150 -71
  14. package/src/libs/suiModel/index.ts +2 -2
  15. package/src/libs/suiModel/suiOwnedObject.ts +17 -8
  16. package/src/libs/suiTxBuilder/index.ts +24 -13
  17. package/src/libs/suiTxBuilder/util.ts +40 -5
  18. package/src/suiKit.ts +68 -38
  19. package/src/types/index.ts +17 -3
  20. package/dist/index.mjs +0 -15
  21. package/dist/libs/multiSig/client.d.ts +0 -15
  22. package/dist/libs/multiSig/index.d.ts +0 -1
  23. package/dist/libs/multiSig/publickey.d.ts +0 -2
  24. package/dist/libs/suiAccountManager/crypto.d.ts +0 -1
  25. package/dist/libs/suiAccountManager/index.d.ts +0 -39
  26. package/dist/libs/suiAccountManager/keypair.d.ts +0 -21
  27. package/dist/libs/suiAccountManager/util.d.ts +0 -29
  28. package/dist/libs/suiInteractor/index.d.ts +0 -1
  29. package/dist/libs/suiInteractor/suiInteractor.d.ts +0 -39
  30. package/dist/libs/suiInteractor/util.d.ts +0 -2
  31. package/dist/libs/suiModel/index.d.ts +0 -2
  32. package/dist/libs/suiModel/suiOwnedObject.d.ts +0 -24
  33. package/dist/libs/suiModel/suiSharedObject.d.ts +0 -11
  34. package/dist/libs/suiTxBuilder/index.d.ts +0 -637
  35. package/dist/libs/suiTxBuilder/util.d.ts +0 -43
  36. package/dist/suiKit.d.ts +0 -128
  37. package/dist/types/index.d.ts +0 -76
@@ -1,637 +0,0 @@
1
- import { Transaction, TransactionObjectInput } from '@mysten/sui/transactions';
2
- import type { SuiClient, SuiObjectRef } from '@mysten/sui/client';
3
- import type { Keypair } from '@mysten/sui/cryptography';
4
- import type { SuiTxArg, SuiAddressArg, SuiObjectArg, SuiVecTxArg, SuiAmountsArg } from 'src/types';
5
- import type { bcs } from '@mysten/sui/bcs';
6
- export declare class SuiTxBlock {
7
- txBlock: Transaction;
8
- constructor(transaction?: Transaction);
9
- get gas(): {
10
- $kind: "GasCoin";
11
- GasCoin: true;
12
- };
13
- /** @deprecated Use `getData()` instead. */
14
- get blockData(): {
15
- version: 1;
16
- inputs: ({
17
- kind: "Input";
18
- value: unknown;
19
- index: number;
20
- type?: "object" | undefined;
21
- } | {
22
- type: "pure";
23
- kind: "Input";
24
- value: unknown;
25
- index: number;
26
- })[];
27
- transactions: ({
28
- typeArguments: string[];
29
- arguments: ({
30
- kind: "Input";
31
- value: unknown;
32
- index: number;
33
- type?: "object" | undefined;
34
- } | {
35
- type: "pure";
36
- kind: "Input";
37
- value: unknown;
38
- index: number;
39
- } | {
40
- kind: "GasCoin";
41
- } | {
42
- kind: "Result";
43
- index: number;
44
- } | {
45
- kind: "NestedResult";
46
- index: number;
47
- resultIndex: number;
48
- })[];
49
- kind: "MoveCall";
50
- target: `${string}::${string}::${string}`;
51
- } | {
52
- address: {
53
- kind: "Input";
54
- value: unknown;
55
- index: number;
56
- type?: "object" | undefined;
57
- } | {
58
- type: "pure";
59
- kind: "Input";
60
- value: unknown;
61
- index: number;
62
- } | {
63
- kind: "GasCoin";
64
- } | {
65
- kind: "Result";
66
- index: number;
67
- } | {
68
- kind: "NestedResult";
69
- index: number;
70
- resultIndex: number;
71
- };
72
- objects: ({
73
- kind: "Input";
74
- value: unknown;
75
- index: number;
76
- type?: "object" | undefined;
77
- } | {
78
- type: "pure";
79
- kind: "Input";
80
- value: unknown;
81
- index: number;
82
- } | {
83
- kind: "GasCoin";
84
- } | {
85
- kind: "Result";
86
- index: number;
87
- } | {
88
- kind: "NestedResult";
89
- index: number;
90
- resultIndex: number;
91
- })[];
92
- kind: "TransferObjects";
93
- } | {
94
- coin: {
95
- kind: "Input";
96
- value: unknown;
97
- index: number;
98
- type?: "object" | undefined;
99
- } | {
100
- type: "pure";
101
- kind: "Input";
102
- value: unknown;
103
- index: number;
104
- } | {
105
- kind: "GasCoin";
106
- } | {
107
- kind: "Result";
108
- index: number;
109
- } | {
110
- kind: "NestedResult";
111
- index: number;
112
- resultIndex: number;
113
- };
114
- amounts: ({
115
- kind: "Input";
116
- value: unknown;
117
- index: number;
118
- type?: "object" | undefined;
119
- } | {
120
- type: "pure";
121
- kind: "Input";
122
- value: unknown;
123
- index: number;
124
- } | {
125
- kind: "GasCoin";
126
- } | {
127
- kind: "Result";
128
- index: number;
129
- } | {
130
- kind: "NestedResult";
131
- index: number;
132
- resultIndex: number;
133
- })[];
134
- kind: "SplitCoins";
135
- } | {
136
- destination: {
137
- kind: "Input";
138
- value: unknown;
139
- index: number;
140
- type?: "object" | undefined;
141
- } | {
142
- type: "pure";
143
- kind: "Input";
144
- value: unknown;
145
- index: number;
146
- } | {
147
- kind: "GasCoin";
148
- } | {
149
- kind: "Result";
150
- index: number;
151
- } | {
152
- kind: "NestedResult";
153
- index: number;
154
- resultIndex: number;
155
- };
156
- sources: ({
157
- kind: "Input";
158
- value: unknown;
159
- index: number;
160
- type?: "object" | undefined;
161
- } | {
162
- type: "pure";
163
- kind: "Input";
164
- value: unknown;
165
- index: number;
166
- } | {
167
- kind: "GasCoin";
168
- } | {
169
- kind: "Result";
170
- index: number;
171
- } | {
172
- kind: "NestedResult";
173
- index: number;
174
- resultIndex: number;
175
- })[];
176
- kind: "MergeCoins";
177
- } | {
178
- objects: ({
179
- kind: "Input";
180
- value: unknown;
181
- index: number;
182
- type?: "object" | undefined;
183
- } | {
184
- type: "pure";
185
- kind: "Input";
186
- value: unknown;
187
- index: number;
188
- } | {
189
- kind: "GasCoin";
190
- } | {
191
- kind: "Result";
192
- index: number;
193
- } | {
194
- kind: "NestedResult";
195
- index: number;
196
- resultIndex: number;
197
- })[];
198
- type: {
199
- Some: import("@mysten/sui/dist/cjs/bcs/types").TypeTag;
200
- } | {
201
- None: true | null;
202
- };
203
- kind: "MakeMoveVec";
204
- } | {
205
- modules: number[][];
206
- dependencies: string[];
207
- kind: "Publish";
208
- } | {
209
- modules: number[][];
210
- dependencies: string[];
211
- ticket: {
212
- kind: "Input";
213
- value: unknown;
214
- index: number;
215
- type?: "object" | undefined;
216
- } | {
217
- type: "pure";
218
- kind: "Input";
219
- value: unknown;
220
- index: number;
221
- } | {
222
- kind: "GasCoin";
223
- } | {
224
- kind: "Result";
225
- index: number;
226
- } | {
227
- kind: "NestedResult";
228
- index: number;
229
- resultIndex: number;
230
- };
231
- kind: "Upgrade";
232
- packageId: string;
233
- })[];
234
- gasConfig: {
235
- payment?: {
236
- version: string | number | bigint;
237
- objectId: string;
238
- digest: string;
239
- }[] | undefined;
240
- owner?: string | undefined;
241
- price?: string | number | bigint | undefined;
242
- budget?: string | number | bigint | undefined;
243
- };
244
- sender?: string | undefined;
245
- expiration?: {
246
- Epoch: number;
247
- } | {
248
- None: true | null;
249
- } | null | undefined;
250
- };
251
- get getData(): {
252
- version: 2;
253
- inputs: import("@mysten/bcs").EnumOutputShapeWithKeys<{
254
- Object: import("@mysten/bcs").EnumOutputShapeWithKeys<{
255
- ImmOrOwnedObject: {
256
- version: string | number;
257
- objectId: string;
258
- digest: string;
259
- };
260
- SharedObject: {
261
- objectId: string;
262
- initialSharedVersion: string | number;
263
- mutable: boolean;
264
- };
265
- Receiving: {
266
- version: string | number;
267
- objectId: string;
268
- digest: string;
269
- };
270
- }, "ImmOrOwnedObject" | "SharedObject" | "Receiving">;
271
- Pure: {
272
- bytes: string;
273
- };
274
- UnresolvedPure: {
275
- value: unknown;
276
- };
277
- UnresolvedObject: {
278
- objectId: string;
279
- version?: string | number | null | undefined;
280
- digest?: string | null | undefined;
281
- initialSharedVersion?: string | number | null | undefined;
282
- };
283
- }, "Pure" | "Object" | "UnresolvedPure" | "UnresolvedObject">[];
284
- commands: import("@mysten/bcs").EnumOutputShapeWithKeys<{
285
- MoveCall: {
286
- function: string;
287
- module: string;
288
- package: string;
289
- typeArguments: string[];
290
- arguments: ({
291
- $kind: "GasCoin";
292
- GasCoin: true;
293
- } | {
294
- $kind: "Input";
295
- Input: number;
296
- type?: "pure";
297
- } | {
298
- $kind: "Input";
299
- Input: number;
300
- type?: "object";
301
- } | {
302
- $kind: "Result";
303
- Result: number;
304
- } | {
305
- $kind: "NestedResult";
306
- NestedResult: [number, number];
307
- })[];
308
- _argumentTypes?: {
309
- ref: "&" | "&mut" | null;
310
- body: import("@mysten/sui/dist/cjs/transactions/data/internal").OpenMoveTypeSignatureBody;
311
- }[] | null | undefined;
312
- };
313
- TransferObjects: {
314
- address: {
315
- $kind: "GasCoin";
316
- GasCoin: true;
317
- } | {
318
- $kind: "Input";
319
- Input: number;
320
- type?: "pure";
321
- } | {
322
- $kind: "Input";
323
- Input: number;
324
- type?: "object";
325
- } | {
326
- $kind: "Result";
327
- Result: number;
328
- } | {
329
- $kind: "NestedResult";
330
- NestedResult: [number, number];
331
- };
332
- objects: ({
333
- $kind: "GasCoin";
334
- GasCoin: true;
335
- } | {
336
- $kind: "Input";
337
- Input: number;
338
- type?: "pure";
339
- } | {
340
- $kind: "Input";
341
- Input: number;
342
- type?: "object";
343
- } | {
344
- $kind: "Result";
345
- Result: number;
346
- } | {
347
- $kind: "NestedResult";
348
- NestedResult: [number, number];
349
- })[];
350
- };
351
- SplitCoins: {
352
- coin: {
353
- $kind: "GasCoin";
354
- GasCoin: true;
355
- } | {
356
- $kind: "Input";
357
- Input: number;
358
- type?: "pure";
359
- } | {
360
- $kind: "Input";
361
- Input: number;
362
- type?: "object";
363
- } | {
364
- $kind: "Result";
365
- Result: number;
366
- } | {
367
- $kind: "NestedResult";
368
- NestedResult: [number, number];
369
- };
370
- amounts: ({
371
- $kind: "GasCoin";
372
- GasCoin: true;
373
- } | {
374
- $kind: "Input";
375
- Input: number;
376
- type?: "pure";
377
- } | {
378
- $kind: "Input";
379
- Input: number;
380
- type?: "object";
381
- } | {
382
- $kind: "Result";
383
- Result: number;
384
- } | {
385
- $kind: "NestedResult";
386
- NestedResult: [number, number];
387
- })[];
388
- };
389
- MergeCoins: {
390
- destination: {
391
- $kind: "GasCoin";
392
- GasCoin: true;
393
- } | {
394
- $kind: "Input";
395
- Input: number;
396
- type?: "pure";
397
- } | {
398
- $kind: "Input";
399
- Input: number;
400
- type?: "object";
401
- } | {
402
- $kind: "Result";
403
- Result: number;
404
- } | {
405
- $kind: "NestedResult";
406
- NestedResult: [number, number];
407
- };
408
- sources: ({
409
- $kind: "GasCoin";
410
- GasCoin: true;
411
- } | {
412
- $kind: "Input";
413
- Input: number;
414
- type?: "pure";
415
- } | {
416
- $kind: "Input";
417
- Input: number;
418
- type?: "object";
419
- } | {
420
- $kind: "Result";
421
- Result: number;
422
- } | {
423
- $kind: "NestedResult";
424
- NestedResult: [number, number];
425
- })[];
426
- };
427
- Publish: {
428
- modules: string[];
429
- dependencies: string[];
430
- };
431
- MakeMoveVec: {
432
- type: string | null;
433
- elements: ({
434
- $kind: "GasCoin";
435
- GasCoin: true;
436
- } | {
437
- $kind: "Input";
438
- Input: number;
439
- type?: "pure";
440
- } | {
441
- $kind: "Input";
442
- Input: number;
443
- type?: "object";
444
- } | {
445
- $kind: "Result";
446
- Result: number;
447
- } | {
448
- $kind: "NestedResult";
449
- NestedResult: [number, number];
450
- })[];
451
- };
452
- Upgrade: {
453
- package: string;
454
- modules: string[];
455
- dependencies: string[];
456
- ticket: {
457
- $kind: "GasCoin";
458
- GasCoin: true;
459
- } | {
460
- $kind: "Input";
461
- Input: number;
462
- type?: "pure";
463
- } | {
464
- $kind: "Input";
465
- Input: number;
466
- type?: "object";
467
- } | {
468
- $kind: "Result";
469
- Result: number;
470
- } | {
471
- $kind: "NestedResult";
472
- NestedResult: [number, number];
473
- };
474
- };
475
- $Intent: {
476
- name: string;
477
- inputs: {
478
- [x: string]: {
479
- $kind: "GasCoin";
480
- GasCoin: true;
481
- } | {
482
- $kind: "Input";
483
- Input: number;
484
- type?: "pure";
485
- } | {
486
- $kind: "Input";
487
- Input: number;
488
- type?: "object";
489
- } | {
490
- $kind: "Result";
491
- Result: number;
492
- } | {
493
- $kind: "NestedResult";
494
- NestedResult: [number, number];
495
- } | ({
496
- $kind: "GasCoin";
497
- GasCoin: true;
498
- } | {
499
- $kind: "Input";
500
- Input: number;
501
- type?: "pure";
502
- } | {
503
- $kind: "Input";
504
- Input: number;
505
- type?: "object";
506
- } | {
507
- $kind: "Result";
508
- Result: number;
509
- } | {
510
- $kind: "NestedResult";
511
- NestedResult: [number, number];
512
- })[];
513
- };
514
- data: {
515
- [x: string]: unknown;
516
- };
517
- };
518
- }, "MoveCall" | "TransferObjects" | "SplitCoins" | "MergeCoins" | "Publish" | "MakeMoveVec" | "Upgrade" | "$Intent">[];
519
- gasData: {
520
- payment: {
521
- version: string | number;
522
- objectId: string;
523
- digest: string;
524
- }[] | null;
525
- owner: string | null;
526
- price: string | number | null;
527
- budget: string | number | null;
528
- };
529
- sender?: string | null | undefined;
530
- expiration?: import("@mysten/bcs").EnumOutputShapeWithKeys<{
531
- None: true;
532
- Epoch: string | number;
533
- }, "None" | "Epoch"> | null | undefined;
534
- };
535
- address(value: string): {
536
- $kind: "GasCoin";
537
- GasCoin: true;
538
- } | {
539
- $kind: "Input";
540
- Input: number;
541
- type?: "pure";
542
- } | {
543
- $kind: "Input";
544
- Input: number;
545
- type?: "object";
546
- } | {
547
- $kind: "Result";
548
- Result: number;
549
- } | {
550
- $kind: "NestedResult";
551
- NestedResult: [number, number];
552
- };
553
- get pure(): typeof this.txBlock.pure;
554
- object(value: string | TransactionObjectInput): {
555
- $kind: "Input";
556
- Input: number;
557
- type?: "object";
558
- };
559
- objectRef(ref: SuiObjectRef): {
560
- $kind: "Input";
561
- Input: number;
562
- type?: "object";
563
- };
564
- sharedObjectRef(ref: typeof bcs.SharedObjectRef.$inferType): {
565
- $kind: "Input";
566
- Input: number;
567
- type?: "object";
568
- };
569
- setSender(sender: string): void;
570
- setSenderIfNotSet(sender: string): void;
571
- setExpiration(expiration?: Parameters<typeof this.txBlock.setExpiration>[0]): void;
572
- setGasPrice(price: number | bigint): void;
573
- setGasBudget(budget: number | bigint): void;
574
- setGasOwner(owner: string): void;
575
- setGasPayment(payments: SuiObjectRef[]): void;
576
- /**
577
- * @deprecated Use toJSON instead.
578
- * For synchronous serialization, you can use `getData()`
579
- * */
580
- serialize(): string;
581
- toJSON(): Promise<string>;
582
- sign(params: {
583
- signer: Keypair;
584
- client?: SuiClient;
585
- onlyTransactionKind?: boolean;
586
- }): Promise<import("@mysten/sui/cryptography").SignatureWithBytes>;
587
- build(params?: {
588
- client?: SuiClient;
589
- onlyTransactionKind?: boolean;
590
- }): Promise<Uint8Array>;
591
- getDigest(params?: {
592
- client?: SuiClient;
593
- }): Promise<string>;
594
- add(...args: Parameters<typeof this.txBlock.add>): unknown;
595
- publish({ modules, dependencies, }: {
596
- modules: number[][] | string[];
597
- dependencies: string[];
598
- }): import("@mysten/sui/transactions").TransactionResult;
599
- upgrade(...args: Parameters<typeof this.txBlock.upgrade>): import("@mysten/sui/transactions").TransactionResult;
600
- makeMoveVec(...args: Parameters<typeof this.txBlock.makeMoveVec>): import("@mysten/sui/transactions").TransactionResult;
601
- transferObjects(objects: SuiObjectArg[], address: SuiAddressArg): import("@mysten/sui/transactions").TransactionResult;
602
- splitCoins(coin: SuiObjectArg, amounts: SuiAmountsArg[]): {
603
- $kind: "NestedResult";
604
- NestedResult: [number, number];
605
- }[];
606
- mergeCoins(destination: SuiObjectArg, sources: SuiObjectArg[]): import("@mysten/sui/transactions").TransactionResult;
607
- /**
608
- * @description Move call
609
- * @param target `${string}::${string}::${string}`, e.g. `0x3::sui_system::request_add_stake`
610
- * @param args the arguments of the move call, such as `['0x1', '0x2']`
611
- * @param typeArgs the type arguments of the move call, such as `['0x2::sui::SUI']`
612
- */
613
- moveCall(target: string, args?: (SuiTxArg | SuiVecTxArg)[], typeArgs?: string[]): import("@mysten/sui/transactions").TransactionResult;
614
- transferSuiToMany(recipients: SuiAddressArg[], amounts: SuiAmountsArg[]): this;
615
- transferSui(address: SuiAddressArg, amount: SuiAmountsArg): this;
616
- takeAmountFromCoins(coins: SuiObjectArg[], amount: SuiAmountsArg): import("@mysten/sui/transactions").TransactionObjectArgument[];
617
- splitSUIFromGas(amounts: SuiAmountsArg[]): {
618
- $kind: "Result";
619
- Result: number;
620
- } & {
621
- $kind: "NestedResult";
622
- NestedResult: [number, number];
623
- }[];
624
- splitMultiCoins(coins: SuiObjectArg[], amounts: SuiAmountsArg[]): {
625
- splitedCoins: {
626
- $kind: "Result";
627
- Result: number;
628
- } & {
629
- $kind: "NestedResult";
630
- NestedResult: [number, number];
631
- }[];
632
- mergedCoin: import("@mysten/sui/transactions").TransactionObjectArgument;
633
- };
634
- transferCoinToMany(coins: SuiObjectArg[], sender: SuiAddressArg, recipients: SuiAddressArg[], amounts: SuiAmountsArg[]): this;
635
- transferCoin(coins: SuiObjectArg[], sender: SuiAddressArg, recipient: SuiAddressArg, amount: SuiAmountsArg): this;
636
- stakeSui(amount: SuiAmountsArg, validatorAddr: SuiAddressArg): import("@mysten/sui/transactions").TransactionResult;
637
- }
@@ -1,43 +0,0 @@
1
- import type { TransactionArgument, Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
2
- import type { SuiObjectArg, SuiAddressArg, SuiTxArg, SuiVecTxArg, SuiInputTypes, SuiAmountsArg } from 'src/types';
3
- export declare const getDefaultSuiInputType: (value: SuiTxArg) => "u64" | "bool" | "object" | undefined;
4
- /**
5
- * Since we know the elements in the array are the same type
6
- * If type is not provided, we will try to infer the type from the first element
7
- * By default,
8
- *
9
- * string is hex and its length equal to 32 =====> object id
10
- * number, bigint ====> u64
11
- * boolean =====> bool
12
- *
13
- * If type is provided, we will use the type to convert the array
14
- * @param args
15
- * @param type 'address' | 'bool' | 'u8' | 'u16' | 'u32' | 'u64' | 'u128' | 'u256' | 'signer' | 'object' | string
16
- */
17
- export declare function makeVecParam(txBlock: Transaction, args: SuiTxArg[], type?: SuiInputTypes): TransactionArgument;
18
- /**
19
- * Convert any valid input into array of TransactionArgument.
20
- *
21
- * @param txb The Transaction Block
22
- * @param args The array of argument to convert.
23
- * @returns The converted array of TransactionArgument.
24
- */
25
- export declare function convertArgs(txBlock: Transaction, args: (SuiTxArg | SuiVecTxArg)[]): TransactionArgument[];
26
- /**
27
- * Convert any valid address input into a TransactionArgument.
28
- *
29
- * @param txb The Transaction Block
30
- * @param arg The address argument to convert.
31
- * @returns The converted TransactionArgument.
32
- */
33
- export declare function convertAddressArg(txBlock: Transaction, arg: SuiAddressArg): SuiTxArg;
34
- /**
35
- * Convert any valid object input into a TransactionArgument.
36
- *
37
- * @param txb The Transaction Block
38
- * @param arg The object argument to convert.
39
- * @returns The converted TransactionArgument.
40
- */
41
- export declare function convertObjArg(txb: Transaction, arg: SuiObjectArg): TransactionObjectArgument;
42
- export declare function convertAmounts(txBlock: Transaction, amounts: SuiAmountsArg[]): TransactionArgument[];
43
- export declare const partitionArray: <T>(array: T[], chunkSize: number) => T[][];