@deserialize/multi-vm-wallet 1.0.12 → 1.0.21

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 (48) hide show
  1. package/dist/IChainWallet.d.ts +17 -0
  2. package/dist/IChainWallet.js +23 -0
  3. package/dist/IChainWallet.js.map +1 -0
  4. package/dist/bip32.d.ts +11 -0
  5. package/dist/bip32.js +100 -0
  6. package/dist/bip32.js.map +1 -0
  7. package/dist/evm/evm.d.ts +39 -0
  8. package/dist/evm/evm.js +234 -0
  9. package/dist/evm/evm.js.map +1 -0
  10. package/dist/evm/index.d.ts +2 -0
  11. package/dist/evm/index.js +19 -0
  12. package/dist/evm/index.js.map +1 -0
  13. package/dist/evm/utils.d.ts +207 -0
  14. package/dist/evm/utils.js +538 -0
  15. package/dist/evm/utils.js.map +1 -0
  16. package/dist/index.d.ts +7 -0
  17. package/dist/index.js +24 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/svm/index.d.ts +1 -0
  20. package/dist/svm/index.js +18 -0
  21. package/dist/svm/index.js.map +1 -0
  22. package/dist/svm/svm.d.ts +36 -0
  23. package/dist/svm/svm.js +167 -0
  24. package/dist/svm/svm.js.map +1 -0
  25. package/dist/svm/transactionSender.d.ts +8 -0
  26. package/dist/svm/transactionSender.js +84 -0
  27. package/dist/svm/transactionSender.js.map +1 -0
  28. package/dist/svm/utils.d.ts +85 -0
  29. package/dist/svm/utils.js +305 -0
  30. package/dist/svm/utils.js.map +1 -0
  31. package/dist/tsconfig.tsbuildinfo +1 -1
  32. package/dist/types.d.ts +44 -0
  33. package/dist/types.js +10 -0
  34. package/dist/types.js.map +1 -0
  35. package/dist/utils/evm/evm.d.ts +4 -3
  36. package/dist/utils/evm/evm.js +18 -6
  37. package/dist/utils/svm/svm.d.ts +3 -2
  38. package/dist/utils/svm/svm.js +17 -5
  39. package/dist/utils/vm.d.ts +2 -3
  40. package/dist/utils/vm.js +5 -6
  41. package/dist/vm.d.ts +12 -0
  42. package/dist/vm.js +49 -0
  43. package/dist/vm.js.map +1 -0
  44. package/package.json +1 -1
  45. package/tsconfig.json +11 -111
  46. package/utils/evm/evm.ts +22 -10
  47. package/utils/svm/svm.ts +17 -5
  48. package/utils/vm.ts +5 -5
@@ -0,0 +1,207 @@
1
+ import { Balance } from '../types';
2
+ import { JsonRpcProvider, Wallet, TransactionReceipt } from 'ethers';
3
+ export interface TransactionParams {
4
+ to: string;
5
+ value?: string | bigint;
6
+ data?: string;
7
+ gasLimit?: string | bigint;
8
+ gasPrice?: string | bigint;
9
+ maxFeePerGas?: string | bigint;
10
+ maxPriorityFeePerGas?: string | bigint;
11
+ nonce?: number;
12
+ }
13
+ interface TransactionResult {
14
+ hash: string;
15
+ receipt: TransactionReceipt | null;
16
+ success: boolean;
17
+ gasUsed?: bigint;
18
+ effectiveGasPrice?: bigint;
19
+ blockNumber?: number;
20
+ confirmations: number;
21
+ }
22
+ export interface SwapParams {
23
+ tokenIn: string;
24
+ tokenOut: string;
25
+ amountIn: string;
26
+ slippageTolerance?: number;
27
+ recipient?: string;
28
+ deadline?: number;
29
+ feeAmount?: string;
30
+ feeReceiver?: string;
31
+ isInBps?: boolean;
32
+ chargeFeeBy?: 'currency_in' | 'currency_out';
33
+ }
34
+ export interface KyberRoute {
35
+ tokenIn: string;
36
+ amountIn: string;
37
+ tokenOut: string;
38
+ amountOut: string;
39
+ gas: string;
40
+ gasPrice: string;
41
+ gasUsd: number;
42
+ amountOutUsd: string;
43
+ receivedUsd: string;
44
+ swaps: Array<{
45
+ pool: string;
46
+ tokenIn: string;
47
+ tokenOut: string;
48
+ swapAmount: string;
49
+ amountOut: string;
50
+ limitReturnAmount: string;
51
+ maxPrice: string;
52
+ exchange: string;
53
+ poolLength: number;
54
+ poolType: string;
55
+ }>;
56
+ tokens: {
57
+ [address: string]: {
58
+ address: string;
59
+ symbol: string;
60
+ name: string;
61
+ decimals: number;
62
+ price: number;
63
+ };
64
+ };
65
+ }
66
+ export interface KyberSwapResponse {
67
+ code: number;
68
+ message: string;
69
+ data: {
70
+ routeSummary: KyberRoute;
71
+ routerAddress: string;
72
+ };
73
+ }
74
+ export interface KyberBuildResponse {
75
+ code: number;
76
+ message: string;
77
+ data: {
78
+ amountIn: string;
79
+ amountInUsd: string;
80
+ amountOut: string;
81
+ amountOutUsd: string;
82
+ gas: string;
83
+ gasUsd: string;
84
+ outputChange: {
85
+ amount: string;
86
+ percent: number;
87
+ level: number;
88
+ };
89
+ data: string;
90
+ routerAddress: string;
91
+ };
92
+ }
93
+ interface KyberSwapParams {
94
+ chainId: string;
95
+ tokenIn: string;
96
+ tokenOut: string;
97
+ amountIn: string;
98
+ slippageTolerance?: number;
99
+ recipient?: string;
100
+ sender?: string;
101
+ deadline?: number;
102
+ feeAmount?: string;
103
+ feeReceiver?: string;
104
+ isInBps?: boolean;
105
+ chargeFeeBy?: 'currency_in' | 'currency_out';
106
+ clientId?: string;
107
+ }
108
+ export declare const getNativeBalance: (address: string, provider: JsonRpcProvider) => Promise<Balance>;
109
+ export declare const getTokenBalance: (tokenAddress: string, walletAddress: string, provider: JsonRpcProvider) => Promise<Balance>;
110
+ /**
111
+ * Sign, send, and confirm any EVM transaction
112
+ */
113
+ export declare const signSendAndConfirm: (wallet: Wallet, transactionParams: TransactionParams, confirmations?: number, timeout?: number) => Promise<TransactionResult>;
114
+ /**
115
+ * Send native token (ETH, BNB, MATIC, etc.)
116
+ */
117
+ export declare const sendNativeToken: (wallet: Wallet, to: string, amount: string | bigint, gasLimit?: string | bigint, confirmations?: number) => Promise<TransactionResult>;
118
+ /**
119
+ * Send ERC-20 token
120
+ */
121
+ export declare const sendERC20Token: (wallet: Wallet, tokenAddress: string, to: string, amount: string | bigint, gasLimit?: string | bigint, confirmations?: number) => Promise<TransactionResult>;
122
+ /**
123
+ * Execute any contract method
124
+ */
125
+ export declare const executeContractMethod: (wallet: Wallet, contractAddress: string, abi: any[], methodName: string, methodParams?: any[], value?: string | bigint, gasLimit?: string | bigint, confirmations?: number) => Promise<TransactionResult>;
126
+ /**
127
+ * Get current gas prices (both legacy and EIP-1559)
128
+ */
129
+ export declare const getGasPrices: (provider: JsonRpcProvider) => Promise<{
130
+ gasPrice: bigint | null;
131
+ maxFeePerGas: bigint | null;
132
+ maxPriorityFeePerGas: bigint | null;
133
+ }>;
134
+ /**
135
+ * Estimate gas for a transaction
136
+ */
137
+ export declare const estimateGas: (provider: JsonRpcProvider, transactionParams: TransactionParams) => Promise<bigint>;
138
+ /**
139
+ * Check ERC-20 token allowance
140
+ */
141
+ export declare const checkAllowance: (tokenAddress: string, owner: string, spender: string, provider: JsonRpcProvider) => Promise<{
142
+ allowance: bigint;
143
+ formatted: string;
144
+ decimals: number;
145
+ }>;
146
+ /**
147
+ * Check if allowance is sufficient for a transaction
148
+ */
149
+ export declare const isAllowanceSufficient: (tokenAddress: string, owner: string, spender: string, requiredAmount: string | bigint, provider: JsonRpcProvider) => Promise<boolean>;
150
+ /**
151
+ * Approve ERC-20 token spending
152
+ */
153
+ export declare const approveToken: (wallet: Wallet, tokenAddress: string, spender: string, amount: string | bigint, gasLimit?: string | bigint, confirmations?: number) => Promise<TransactionResult>;
154
+ /**
155
+ * Approve unlimited token spending (MaxUint256)
156
+ */
157
+ export declare const approveTokenUnlimited: (wallet: Wallet, tokenAddress: string, spender: string, gasLimit?: string | bigint, confirmations?: number) => Promise<TransactionResult>;
158
+ /**
159
+ * Check allowance and approve if necessary
160
+ */
161
+ export declare const checkAndApprove: (wallet: Wallet, tokenAddress: string, spender: string, requiredAmount: string | bigint, approvalAmount?: string | bigint, gasLimit?: string | bigint, confirmations?: number) => Promise<{
162
+ approvalNeeded: boolean;
163
+ currentAllowance: bigint;
164
+ approvalResult?: TransactionResult;
165
+ }>;
166
+ /**
167
+ * Reset token allowance to zero (security best practice before setting new allowance)
168
+ */
169
+ export declare const resetAllowance: (wallet: Wallet, tokenAddress: string, spender: string, gasLimit?: string | bigint, confirmations?: number) => Promise<TransactionResult>;
170
+ /**
171
+ * Safe approve: Reset to zero first, then approve the desired amount
172
+ * (Some tokens like USDT require this)
173
+ */
174
+ export declare const safeApprove: (wallet: Wallet, tokenAddress: string, spender: string, amount: string | bigint, gasLimit?: string | bigint, confirmations?: number) => Promise<{
175
+ resetResult: TransactionResult;
176
+ approveResult: TransactionResult;
177
+ }>;
178
+ export declare function getKyberSwapRoute(params: KyberSwapParams): Promise<KyberSwapResponse>;
179
+ export declare function buildKyberSwapTransaction(chainId: string, routeSummary: KyberRoute, sender: string, recipient: string, slippageTolerance?: number, deadline?: number, clientId?: string): Promise<KyberBuildResponse>;
180
+ export declare function performSwap(params: {
181
+ chainId: string;
182
+ tokenIn: string;
183
+ tokenOut: string;
184
+ amountIn: string;
185
+ sender: string;
186
+ recipient?: string;
187
+ slippageTolerance?: number;
188
+ deadline?: number;
189
+ feeAmount?: string;
190
+ feeReceiver?: string;
191
+ isInBps?: boolean;
192
+ chargeFeeBy?: 'currency_in' | 'currency_out';
193
+ clientId?: string;
194
+ }): Promise<TransactionParams>;
195
+ export declare function getKyberSupportedChains(): {
196
+ [key: string]: string;
197
+ };
198
+ export declare function isChainSupportedByKyber(chainId: string): boolean;
199
+ export declare function getNativeTokenAddress(): string;
200
+ export declare function formatAmountToWei(amount: string, decimals: number): string;
201
+ export declare function formatAmountFromWei(amountWei: string, decimals: number): string;
202
+ export declare function prepareSwapParams(tokenIn: string, tokenOut: string, amountIn: string, tokenInDecimals: number, isNativeIn?: boolean, isNativeOut?: boolean): {
203
+ tokenInAddress: string;
204
+ tokenOutAddress: string;
205
+ formattedAmountIn: string;
206
+ };
207
+ export {};