@scallop-io/sui-kit 1.4.3 → 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 +1 -1
  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 +62 -32
  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
package/dist/suiKit.d.ts DELETED
@@ -1,128 +0,0 @@
1
- import { Transaction } from '@mysten/sui/transactions';
2
- import { SuiAccountManager } from './libs/suiAccountManager';
3
- import { SuiTxBlock } from './libs/suiTxBuilder';
4
- import { SuiInteractor } from './libs/suiInteractor';
5
- import type { SuiTransactionBlockResponse, DevInspectResults, SuiObjectDataOptions, DryRunTransactionBlockResponse } from '@mysten/sui/client';
6
- import type { SuiSharedObject, SuiOwnedObject } from './libs/suiModel';
7
- import type { SuiKitParams, DerivePathParams, SuiTxArg, SuiVecTxArg, SuiKitReturnType, SuiObjectArg } from './types';
8
- /**
9
- * @class SuiKit
10
- * @description This class is used to aggregate the tools that used to interact with SUI network.
11
- */
12
- export declare class SuiKit {
13
- accountManager: SuiAccountManager;
14
- suiInteractor: SuiInteractor;
15
- /**
16
- * Support the following ways to init the SuiToolkit:
17
- * 1. mnemonics
18
- * 2. secretKey (base64 or hex)
19
- * If none of them is provided, will generate a random mnemonics with 24 words.
20
- *
21
- * @param mnemonics, 12 or 24 mnemonics words, separated by space
22
- * @param secretKey, base64 or hex string or bech32, when mnemonics is provided, secretKey will be ignored
23
- * @param networkType, 'testnet' | 'mainnet' | 'devnet' | 'localnet', default is 'mainnet'
24
- * @param fullnodeUrls, the fullnode url, default is the preconfig fullnode url for the given network type
25
- */
26
- constructor(params: SuiKitParams);
27
- /**
28
- * Create SuiTxBlock with sender set to the current signer
29
- * @returns SuiTxBlock with sender set to the current signer
30
- */
31
- createTxBlock(): SuiTxBlock;
32
- /**
33
- * if derivePathParams is not provided or mnemonics is empty, it will return the keypair.
34
- * else:
35
- * it will generate signer from the mnemonic with the given derivePathParams.
36
- * @param derivePathParams, such as { accountIndex: 2, isExternal: false, addressIndex: 10 }, comply with the BIP44 standard
37
- */
38
- getKeypair(derivePathParams?: DerivePathParams): import("@mysten/sui/dist/cjs/keypairs/ed25519").Ed25519Keypair;
39
- /**
40
- * @description Switch the current account with the given derivePathParams
41
- * @param derivePathParams, such as { accountIndex: 2, isExternal: false, addressIndex: 10 }, comply with the BIP44 standard
42
- */
43
- switchAccount(derivePathParams: DerivePathParams): void;
44
- /**
45
- * @description Get the address of the account for the given derivePathParams
46
- * @param derivePathParams, such as { accountIndex: 2, isExternal: false, addressIndex: 10 }, comply with the BIP44 standard
47
- */
48
- getAddress(derivePathParams?: DerivePathParams): string;
49
- get currentAddress(): string;
50
- getBalance(coinType?: string, derivePathParams?: DerivePathParams): Promise<import("@mysten/sui/client").CoinBalance>;
51
- get client(): import("@mysten/sui/client").SuiClient;
52
- getObjects(objectIds: string[], options?: SuiObjectDataOptions & {
53
- batchSize?: number;
54
- switchClientDelay?: number;
55
- }): Promise<import("@mysten/sui/client").SuiObjectData[]>;
56
- /**
57
- * @description Update objects in a batch
58
- * @param suiObjects
59
- */
60
- updateObjects(suiObjects: (SuiSharedObject | SuiOwnedObject)[]): Promise<void>;
61
- signTxn(tx: Uint8Array | Transaction | SuiTxBlock, derivePathParams?: DerivePathParams): Promise<import("@mysten/sui/dist/cjs/cryptography").SignatureWithBytes>;
62
- signAndSendTxn(tx: Uint8Array | Transaction | SuiTxBlock, derivePathParams?: DerivePathParams): Promise<SuiTransactionBlockResponse>;
63
- dryRunTxn(tx: Uint8Array | Transaction | SuiTxBlock, derivePathParams?: DerivePathParams): Promise<DryRunTransactionBlockResponse>;
64
- /**
65
- * Transfer the given amount of SUI to the recipient
66
- * @param recipient
67
- * @param amount
68
- * @param derivePathParams
69
- */
70
- transferSui(recipient: string, amount: number, derivePathParams?: DerivePathParams): Promise<SuiTransactionBlockResponse>;
71
- transferSui<S extends boolean>(recipient: string, amount: number, sign?: S, derivePathParams?: DerivePathParams): Promise<SuiKitReturnType<S>>;
72
- /**
73
- * Transfer to mutliple recipients
74
- * @param recipients the recipients addresses
75
- * @param amounts the amounts of SUI to transfer to each recipient, the length of amounts should be the same as the length of recipients
76
- * @param derivePathParams
77
- */
78
- transferSuiToMany(recipients: string[], amounts: number[], derivePathParams?: DerivePathParams): Promise<SuiTransactionBlockResponse>;
79
- transferSuiToMany<S extends boolean>(recipients: string[], amounts: number[], sign?: S, derivePathParams?: DerivePathParams): Promise<SuiKitReturnType<S>>;
80
- /**
81
- * Transfer the given amounts of coin to multiple recipients
82
- * @param recipients the list of recipient address
83
- * @param amounts the amounts to transfer for each recipient
84
- * @param coinType any custom coin type but not SUI
85
- * @param derivePathParams the derive path params for the current signer
86
- */
87
- transferCoinToMany(recipients: string[], amounts: number[], coinType: string, derivePathParams?: DerivePathParams): Promise<SuiTransactionBlockResponse>;
88
- transferCoinToMany<S extends boolean>(recipients: string[], amounts: number[], coinType: string, sign?: S, derivePathParams?: DerivePathParams): Promise<SuiKitReturnType<S>>;
89
- transferCoin(recipient: string, amount: number, coinType: string, derivePathParams?: DerivePathParams): Promise<SuiTransactionBlockResponse>;
90
- transferCoin<S extends boolean>(recipient: string, amount: number, coinType: string, sign?: S, derivePathParams?: DerivePathParams): Promise<SuiKitReturnType<S>>;
91
- transferObjects(objects: SuiObjectArg[], recipient: string, derivePathParams?: DerivePathParams): Promise<SuiTransactionBlockResponse>;
92
- transferObjects<S extends boolean>(objects: SuiObjectArg[], recipient: string, sign?: S, derivePathParams?: DerivePathParams): Promise<SuiKitReturnType<S>>;
93
- moveCall(callParams: {
94
- target: string;
95
- arguments?: (SuiTxArg | SuiVecTxArg)[];
96
- typeArguments?: string[];
97
- derivePathParams?: DerivePathParams;
98
- }): Promise<SuiTransactionBlockResponse>;
99
- /**
100
- * Select coins with the given amount and coin type, the total amount is greater than or equal to the given amount
101
- * @param amount
102
- * @param coinType
103
- * @param owner
104
- */
105
- selectCoinsWithAmount(amount: number, coinType: string, owner?: string): Promise<{
106
- objectId: string;
107
- digest: string;
108
- version: string;
109
- balance: string;
110
- }[]>;
111
- /**
112
- * stake the given amount of SUI to the validator
113
- * @param amount the amount of SUI to stake
114
- * @param validatorAddr the validator address
115
- * @param sign whether to sign and send the transaction, default is true
116
- * @param derivePathParams the derive path params for the current signer
117
- */
118
- stakeSui(amount: number, validatorAddr: string, derivePathParams?: DerivePathParams): Promise<SuiTransactionBlockResponse>;
119
- stakeSui<S extends boolean>(amount: number, validatorAddr: string, sign?: S, derivePathParams?: DerivePathParams): Promise<SuiKitReturnType<S>>;
120
- /**
121
- * Execute the transaction with on-chain data but without really submitting. Useful for querying the effects of a transaction.
122
- * Since the transaction is not submitted, its gas cost is not charged.
123
- * @param tx the transaction to execute
124
- * @param derivePathParams the derive path params
125
- * @returns the effects and events of the transaction, such as object changes, gas cost, event emitted.
126
- */
127
- inspectTxn(tx: Uint8Array | Transaction | SuiTxBlock, derivePathParams?: DerivePathParams): Promise<DevInspectResults>;
128
- }
@@ -1,76 +0,0 @@
1
- import type { Transaction, TransactionObjectArgument, Argument, Inputs, TransactionArgument } from '@mysten/sui/transactions';
2
- import type { SerializedBcs } from '@mysten/bcs';
3
- import { SuiClient, SuiTransactionBlockResponse } from '@mysten/sui/client';
4
- import { SuiTxBlock } from 'src/libs/suiTxBuilder';
5
- export type SuiKitParams = (AccountManagerParams & {
6
- faucetUrl?: string;
7
- networkType?: NetworkType;
8
- }) & Partial<SuiInteractorParams>;
9
- export type SuiInteractorParams = {
10
- fullnodeUrls: string[];
11
- } | {
12
- suiClients: SuiClient[];
13
- };
14
- export type NetworkType = 'testnet' | 'mainnet' | 'devnet' | 'localnet';
15
- export type AccountManagerParams = {
16
- mnemonics?: string;
17
- secretKey?: string;
18
- };
19
- export type DerivePathParams = {
20
- accountIndex?: number;
21
- isExternal?: boolean;
22
- addressIndex?: number;
23
- };
24
- type TransactionBlockType = InstanceType<typeof Transaction>;
25
- export type PureCallArg = {
26
- Pure: number[];
27
- };
28
- type SharedObjectRef = {
29
- /** Hex code as string representing the object id */
30
- objectId: string;
31
- /** The version the object was shared at */
32
- initialSharedVersion: number | string;
33
- /** Whether reference is mutable */
34
- mutable: boolean;
35
- };
36
- type SuiObjectRef = {
37
- /** Base64 string representing the object digest */
38
- objectId: string;
39
- /** Object version */
40
- version: number | string;
41
- /** Hex code as string representing the object id */
42
- digest: string;
43
- };
44
- /**
45
- * An object argument.
46
- */
47
- type ObjectArg = {
48
- ImmOrOwnedObject: SuiObjectRef;
49
- } | {
50
- SharedObject: SharedObjectRef;
51
- } | {
52
- Receiving: SuiObjectRef;
53
- };
54
- export type ObjectCallArg = {
55
- Object: ObjectArg;
56
- };
57
- export type TransactionType = Parameters<TransactionBlockType['add']>;
58
- export type TransactionPureArgument = Extract<Argument, {
59
- $kind: 'Input';
60
- type?: 'pure';
61
- }>;
62
- export type SuiTxArg = TransactionArgument | SerializedBcs<any>;
63
- export type SuiAddressArg = Argument | SerializedBcs<any> | string;
64
- export type SuiAmountsArg = SuiTxArg | number | bigint;
65
- export type SuiObjectArg = TransactionObjectArgument | string | Parameters<typeof Inputs.ObjectRef>[0] | Parameters<typeof Inputs.SharedObjectRef>[0] | ObjectCallArg;
66
- export type SuiVecTxArg = {
67
- value: SuiTxArg[];
68
- vecType: SuiInputTypes;
69
- } | SuiTxArg[];
70
- /**
71
- * These are the basics types that can be used in the SUI
72
- */
73
- export type SuiBasicTypes = 'address' | 'bool' | 'u8' | 'u16' | 'u32' | 'u64' | 'u128' | 'u256';
74
- export type SuiInputTypes = 'object' | SuiBasicTypes;
75
- export type SuiKitReturnType<T extends boolean> = T extends true ? SuiTransactionBlockResponse : SuiTxBlock;
76
- export {};