@0xobelisk/sui-client 0.5.18 → 0.5.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/index.d.ts +15 -0
  2. package/dist/index.js +340 -233
  3. package/dist/index.js.map +1 -1
  4. package/dist/index.mjs +337 -230
  5. package/dist/index.mjs.map +1 -1
  6. package/dist/libs/multiSig/client.d.ts +15 -0
  7. package/dist/libs/multiSig/index.d.ts +1 -0
  8. package/dist/libs/multiSig/publickey.d.ts +2 -0
  9. package/dist/libs/suiAccountManager/crypto.d.ts +1 -0
  10. package/dist/libs/suiAccountManager/index.d.ts +39 -0
  11. package/dist/libs/suiAccountManager/keypair.d.ts +21 -0
  12. package/dist/libs/suiAccountManager/util.d.ts +29 -0
  13. package/dist/libs/suiContractFactory/index.d.ts +20 -0
  14. package/dist/libs/suiContractFactory/types.d.ts +49 -0
  15. package/dist/libs/suiInteractor/index.d.ts +1 -0
  16. package/dist/libs/suiInteractor/suiInteractor.d.ts +50 -0
  17. package/dist/libs/suiInteractor/util.d.ts +1 -0
  18. package/dist/libs/suiModel/index.d.ts +2 -0
  19. package/dist/libs/suiModel/suiOwnedObject.d.ts +24 -0
  20. package/dist/libs/suiModel/suiSharedObject.d.ts +11 -0
  21. package/dist/libs/suiTxBuilder/index.d.ts +538 -0
  22. package/dist/libs/suiTxBuilder/util.d.ts +49 -0
  23. package/dist/metadata/index.d.ts +3 -0
  24. package/dist/obelisk.d.ts +140 -0
  25. package/dist/types/index.d.ts +199 -0
  26. package/dist/utils/index.d.ts +3 -0
  27. package/package.json +2 -5
  28. package/src/libs/multiSig/client.ts +1 -1
  29. package/src/libs/suiAccountManager/index.ts +4 -5
  30. package/src/libs/suiInteractor/index.ts +0 -1
  31. package/src/libs/suiModel/suiOwnedObject.ts +2 -2
  32. package/src/libs/suiModel/suiSharedObject.ts +2 -2
  33. package/src/libs/suiTxBuilder/index.ts +43 -49
  34. package/src/libs/suiTxBuilder/util.ts +65 -129
  35. package/src/obelisk.ts +329 -139
  36. package/src/types/index.ts +60 -44
@@ -0,0 +1,538 @@
1
+ import { Transaction } from '@mysten/sui/transactions';
2
+ import type { SuiClient, SuiObjectRef } from '@mysten/sui/client';
3
+ import type { TransactionObjectArgument, TransactionObjectInput } from '@mysten/sui/transactions';
4
+ import type { Keypair } from '@mysten/sui/cryptography';
5
+ import { SerializedBcs } from '@mysten/bcs';
6
+ import type { SuiTxArg, SuiAddressArg, SuiObjectArg, SuiVecTxArg, SuiAmountsArg } from '../../types';
7
+ import type { bcs } from '@mysten/sui/bcs';
8
+ export declare class SuiTx {
9
+ tx: Transaction;
10
+ constructor(transaction?: Transaction);
11
+ get gas(): {
12
+ $kind: "GasCoin";
13
+ GasCoin: true;
14
+ };
15
+ get blockData(): {
16
+ version: 1;
17
+ inputs: ({
18
+ kind: "Input";
19
+ value: unknown;
20
+ index: number;
21
+ type?: "object" | undefined;
22
+ } | {
23
+ type: "pure";
24
+ kind: "Input";
25
+ value: unknown;
26
+ index: number;
27
+ })[];
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
+ transactions: ({
44
+ typeArguments: string[];
45
+ arguments: ({
46
+ kind: "Input";
47
+ value: unknown;
48
+ index: number;
49
+ type?: "object" | undefined;
50
+ } | {
51
+ type: "pure";
52
+ kind: "Input";
53
+ value: unknown;
54
+ index: number;
55
+ } | {
56
+ kind: "GasCoin";
57
+ } | {
58
+ kind: "Result";
59
+ index: number;
60
+ } | {
61
+ kind: "NestedResult";
62
+ index: number;
63
+ resultIndex: number;
64
+ })[];
65
+ kind: "MoveCall";
66
+ target: `${string}::${string}::${string}`;
67
+ } | {
68
+ address: {
69
+ kind: "Input";
70
+ value: unknown;
71
+ index: number;
72
+ type?: "object" | undefined;
73
+ } | {
74
+ type: "pure";
75
+ kind: "Input";
76
+ value: unknown;
77
+ index: number;
78
+ } | {
79
+ kind: "GasCoin";
80
+ } | {
81
+ kind: "Result";
82
+ index: number;
83
+ } | {
84
+ kind: "NestedResult";
85
+ index: number;
86
+ resultIndex: number;
87
+ };
88
+ objects: ({
89
+ kind: "Input";
90
+ value: unknown;
91
+ index: number;
92
+ type?: "object" | undefined;
93
+ } | {
94
+ type: "pure";
95
+ kind: "Input";
96
+ value: unknown;
97
+ index: number;
98
+ } | {
99
+ kind: "GasCoin";
100
+ } | {
101
+ kind: "Result";
102
+ index: number;
103
+ } | {
104
+ kind: "NestedResult";
105
+ index: number;
106
+ resultIndex: number;
107
+ })[];
108
+ kind: "TransferObjects";
109
+ } | {
110
+ coin: {
111
+ kind: "Input";
112
+ value: unknown;
113
+ index: number;
114
+ type?: "object" | undefined;
115
+ } | {
116
+ type: "pure";
117
+ kind: "Input";
118
+ value: unknown;
119
+ index: number;
120
+ } | {
121
+ kind: "GasCoin";
122
+ } | {
123
+ kind: "Result";
124
+ index: number;
125
+ } | {
126
+ kind: "NestedResult";
127
+ index: number;
128
+ resultIndex: number;
129
+ };
130
+ amounts: ({
131
+ kind: "Input";
132
+ value: unknown;
133
+ index: number;
134
+ type?: "object" | undefined;
135
+ } | {
136
+ type: "pure";
137
+ kind: "Input";
138
+ value: unknown;
139
+ index: number;
140
+ } | {
141
+ kind: "GasCoin";
142
+ } | {
143
+ kind: "Result";
144
+ index: number;
145
+ } | {
146
+ kind: "NestedResult";
147
+ index: number;
148
+ resultIndex: number;
149
+ })[];
150
+ kind: "SplitCoins";
151
+ } | {
152
+ destination: {
153
+ kind: "Input";
154
+ value: unknown;
155
+ index: number;
156
+ type?: "object" | undefined;
157
+ } | {
158
+ type: "pure";
159
+ kind: "Input";
160
+ value: unknown;
161
+ index: number;
162
+ } | {
163
+ kind: "GasCoin";
164
+ } | {
165
+ kind: "Result";
166
+ index: number;
167
+ } | {
168
+ kind: "NestedResult";
169
+ index: number;
170
+ resultIndex: number;
171
+ };
172
+ sources: ({
173
+ kind: "Input";
174
+ value: unknown;
175
+ index: number;
176
+ type?: "object" | undefined;
177
+ } | {
178
+ type: "pure";
179
+ kind: "Input";
180
+ value: unknown;
181
+ index: number;
182
+ } | {
183
+ kind: "GasCoin";
184
+ } | {
185
+ kind: "Result";
186
+ index: number;
187
+ } | {
188
+ kind: "NestedResult";
189
+ index: number;
190
+ resultIndex: number;
191
+ })[];
192
+ kind: "MergeCoins";
193
+ } | {
194
+ objects: ({
195
+ kind: "Input";
196
+ value: unknown;
197
+ index: number;
198
+ type?: "object" | undefined;
199
+ } | {
200
+ type: "pure";
201
+ kind: "Input";
202
+ value: unknown;
203
+ index: number;
204
+ } | {
205
+ kind: "GasCoin";
206
+ } | {
207
+ kind: "Result";
208
+ index: number;
209
+ } | {
210
+ kind: "NestedResult";
211
+ index: number;
212
+ resultIndex: number;
213
+ })[];
214
+ type: {
215
+ Some: import("@mysten/sui/bcs").TypeTag;
216
+ } | {
217
+ None: true | null;
218
+ };
219
+ kind: "MakeMoveVec";
220
+ } | {
221
+ modules: number[][];
222
+ dependencies: string[];
223
+ kind: "Publish";
224
+ } | {
225
+ modules: number[][];
226
+ dependencies: string[];
227
+ ticket: {
228
+ kind: "Input";
229
+ value: unknown;
230
+ index: number;
231
+ type?: "object" | undefined;
232
+ } | {
233
+ type: "pure";
234
+ kind: "Input";
235
+ value: unknown;
236
+ index: number;
237
+ } | {
238
+ kind: "GasCoin";
239
+ } | {
240
+ kind: "Result";
241
+ index: number;
242
+ } | {
243
+ kind: "NestedResult";
244
+ index: number;
245
+ resultIndex: number;
246
+ };
247
+ kind: "Upgrade";
248
+ packageId: string;
249
+ })[];
250
+ sender?: string | undefined;
251
+ };
252
+ autoPure(value: SuiTxArg, type?: string): import("@mysten/sui/transactions").TransactionArgument[] | undefined;
253
+ address(value: string): {
254
+ $kind: "GasCoin";
255
+ GasCoin: true;
256
+ } | {
257
+ $kind: "Input";
258
+ Input: number;
259
+ type?: "pure" | undefined;
260
+ } | {
261
+ $kind: "Input";
262
+ Input: number;
263
+ type?: "object" | undefined;
264
+ } | {
265
+ $kind: "Result";
266
+ Result: number;
267
+ } | {
268
+ $kind: "NestedResult";
269
+ NestedResult: [number, number];
270
+ };
271
+ get pure(): {
272
+ (value: SerializedBcs<any, any> | Uint8Array): {
273
+ $kind: "GasCoin";
274
+ GasCoin: true;
275
+ } | {
276
+ $kind: "Input";
277
+ Input: number;
278
+ type?: "pure" | undefined;
279
+ } | {
280
+ $kind: "Input";
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
+ };
470
+ };
471
+ object(value: string | TransactionObjectInput): {
472
+ $kind: "Input";
473
+ Input: number;
474
+ type?: "object" | undefined;
475
+ };
476
+ objectRef(ref: SuiObjectRef): {
477
+ $kind: "Input";
478
+ Input: number;
479
+ type?: "object" | undefined;
480
+ };
481
+ sharedObjectRef(ref: typeof bcs.SharedObjectRef.$inferType): {
482
+ $kind: "Input";
483
+ Input: number;
484
+ type?: "object" | undefined;
485
+ };
486
+ setSender(sender: string): void;
487
+ setSenderIfNotSet(sender: string): void;
488
+ setExpiration(expiration?: Parameters<typeof this.tx.setExpiration>[0]): void;
489
+ setGasPrice(price: number | bigint): void;
490
+ setGasBudget(budget: number | bigint): void;
491
+ setGasOwner(owner: string): void;
492
+ setGasPayment(payments: SuiObjectRef[]): void;
493
+ serialize(): string;
494
+ toJSON(): Promise<string>;
495
+ sign(params: {
496
+ signer: Keypair;
497
+ client?: SuiClient;
498
+ onlyTransactionKind?: boolean;
499
+ }): Promise<import("@mysten/sui/cryptography").SignatureWithBytes>;
500
+ build(params?: {
501
+ client?: SuiClient;
502
+ onlyTransactionKind?: boolean;
503
+ }): Promise<Uint8Array>;
504
+ getDigest(params?: {
505
+ client?: SuiClient;
506
+ }): Promise<string>;
507
+ add(...args: Parameters<typeof this.tx.add>): import("@mysten/sui/transactions").TransactionResult;
508
+ publish({ modules, dependencies, }: {
509
+ modules: number[][] | string[];
510
+ dependencies: string[];
511
+ }): import("@mysten/sui/transactions").TransactionResult;
512
+ upgrade(...args: Parameters<typeof this.tx.upgrade>): import("@mysten/sui/transactions").TransactionResult;
513
+ makeMoveVec(...args: Parameters<typeof this.tx.makeMoveVec>): import("@mysten/sui/transactions").TransactionResult;
514
+ transferObjects(objects: SuiObjectArg[], address: SuiAddressArg): import("@mysten/sui/transactions").TransactionResult;
515
+ splitCoins(coin: SuiObjectArg, amounts: SuiTxArg[]): {
516
+ $kind: "NestedResult";
517
+ NestedResult: [number, number];
518
+ }[];
519
+ mergeCoins(destination: SuiObjectArg, sources: SuiObjectArg[]): import("@mysten/sui/transactions").TransactionResult;
520
+ /**
521
+ * @description Move call
522
+ * @param target `${string}::${string}::${string}`, e.g. `0x3::sui_system::request_add_stake`
523
+ * @param args the arguments of the move call, such as `['0x1', '0x2']`
524
+ * @param typeArgs the type arguments of the move call, such as `['0x2::sui::SUI']`
525
+ */
526
+ moveCall(target: string, args?: (SuiTxArg | SuiVecTxArg)[], typeArgs?: string[]): import("@mysten/sui/transactions").TransactionResult;
527
+ transferSuiToMany(recipients: SuiAddressArg[], amounts: (SuiTxArg | number | bigint)[]): this;
528
+ transferSui(address: SuiAddressArg, amount: SuiTxArg | number | bigint): this;
529
+ takeAmountFromCoins(coins: SuiObjectArg[], amount: SuiTxArg | number | bigint): TransactionObjectArgument[];
530
+ splitSUIFromGas(amounts: SuiTxArg[]): import("@mysten/sui/transactions").TransactionResult;
531
+ splitMultiCoins(coins: SuiObjectArg[], amounts: SuiAmountsArg[]): {
532
+ splitedCoins: import("@mysten/sui/transactions").TransactionResult;
533
+ mergedCoin: TransactionObjectArgument;
534
+ };
535
+ transferCoinToMany(coins: SuiObjectArg[], sender: SuiAddressArg, recipients: SuiAddressArg[], amounts: SuiAmountsArg[]): this;
536
+ transferCoin(coins: SuiObjectArg[], sender: SuiAddressArg, recipient: SuiAddressArg, amount: SuiTxArg): this;
537
+ stakeSui(amount: SuiTxArg | number | bigint, validatorAddr: SuiAddressArg): import("@mysten/sui/transactions").TransactionResult;
538
+ }
@@ -0,0 +1,49 @@
1
+ import type { TransactionArgument, Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
2
+ import type { SuiObjectArg, SuiAddressArg, SuiTxArg, SuiVecTxArg, SuiInputTypes } 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
+ * Check whether it is an valid move vec input.
20
+ *
21
+ * @param arg The argument to check.
22
+ * @returns boolean.
23
+ */
24
+ export declare function isMoveVecArg(arg: SuiTxArg | SuiVecTxArg): arg is SuiVecTxArg;
25
+ /**
26
+ * Convert any valid input into array of TransactionArgument.
27
+ *
28
+ * @param txb The Transaction Block
29
+ * @param args The array of argument to convert.
30
+ * @returns The converted array of TransactionArgument.
31
+ */
32
+ export declare function convertArgs(txBlock: Transaction, args: (SuiTxArg | SuiVecTxArg)[]): TransactionArgument[];
33
+ /**
34
+ * Convert any valid address input into a TransactionArgument.
35
+ *
36
+ * @param txb The Transaction Block
37
+ * @param arg The address argument to convert.
38
+ * @returns The converted TransactionArgument.
39
+ */
40
+ export declare function convertAddressArg(txBlock: Transaction, arg: SuiAddressArg): TransactionArgument;
41
+ /**
42
+ * Convert any valid object input into a TransactionArgument.
43
+ *
44
+ * @param txb The Transaction Block
45
+ * @param arg The object argument to convert.
46
+ * @returns The converted TransactionArgument.
47
+ */
48
+ export declare function convertObjArg(txb: Transaction, arg: SuiObjectArg): TransactionObjectArgument;
49
+ export declare function convertAmounts(txBlock: Transaction, amounts: (SuiTxArg | number | bigint)[]): (TransactionArgument | number | bigint)[];
@@ -0,0 +1,3 @@
1
+ import { SuiMoveNormalizedModules } from '@mysten/sui/client';
2
+ import { NetworkType } from '../types';
3
+ export declare function loadMetadata(networkType: NetworkType, packageId: string): Promise<SuiMoveNormalizedModules | undefined>;