@imtbl/bridge-sdk 2.0.0-alpha.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.
- package/LICENSE.md +176 -0
- package/README.md +3 -0
- package/dist/browser/index.js +2 -0
- package/dist/node/index.cjs +2 -0
- package/dist/node/index.js +2 -0
- package/dist/types/config/config.test.d.ts +1 -0
- package/dist/types/config/index.d.ts +32 -0
- package/dist/types/constants/bridges.d.ts +121 -0
- package/dist/types/constants/values.d.ts +1 -0
- package/dist/types/contracts/ABIs/ChildERC20.d.ts +28 -0
- package/dist/types/contracts/ABIs/ChildERC20Bridge.d.ts +78 -0
- package/dist/types/contracts/ABIs/ERC20.d.ts +39 -0
- package/dist/types/contracts/ABIs/RootAxelarBridgeAdaptor.d.ts +67 -0
- package/dist/types/contracts/ABIs/RootERC20BridgeFlowRate.d.ts +98 -0
- package/dist/types/contracts/createContract.d.ts +2 -0
- package/dist/types/errors/index.d.ts +52 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/types/lib/axelar.test.d.ts +1 -0
- package/dist/types/lib/axelarUtils.d.ts +20 -0
- package/dist/types/lib/gas.d.ts +3 -0
- package/dist/types/lib/gas.test.d.ts +1 -0
- package/dist/types/lib/gmpRecovery.d.ts +2 -0
- package/dist/types/lib/tenderly.d.ts +31 -0
- package/dist/types/lib/tenderly.test.d.ts +1 -0
- package/dist/types/lib/transactions.d.ts +11 -0
- package/dist/types/lib/transactions.test.d.ts +1 -0
- package/dist/types/lib/utils.d.ts +34 -0
- package/dist/types/lib/utils.test.d.ts +1 -0
- package/dist/types/lib/validation.d.ts +7 -0
- package/dist/types/lib/validation.test.d.ts +1 -0
- package/dist/types/tokenBridge.d.ts +354 -0
- package/dist/types/tokenBridge.test.d.ts +1 -0
- package/dist/types/types/axelar.d.ts +43 -0
- package/dist/types/types/index.d.ts +462 -0
- package/dist/types/types/tenderly.d.ts +13 -0
- package/package.json +71 -0
|
@@ -0,0 +1,462 @@
|
|
|
1
|
+
import { ModuleConfiguration } from '@imtbl/config';
|
|
2
|
+
import { Provider, TransactionRequest } from 'ethers';
|
|
3
|
+
/**
|
|
4
|
+
* @typedef {Object} BridgeInstance
|
|
5
|
+
* @property {string} rootChainID - The root chain ID.
|
|
6
|
+
* @property {string} childChainID - The child chain ID.
|
|
7
|
+
*/
|
|
8
|
+
export type BridgeInstance = {
|
|
9
|
+
rootChainID: string;
|
|
10
|
+
childChainID: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* @typedef {Object} BridgeOverrides
|
|
14
|
+
* @property {BridgeContracts} bridgeContracts - The bridge contracts configuration.
|
|
15
|
+
*/
|
|
16
|
+
export interface BridgeOverrides {
|
|
17
|
+
bridgeContracts: BridgeContracts;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* @typedef {Object} AxelarChainDetails
|
|
21
|
+
* @property {string} id - The ChainId of the network.
|
|
22
|
+
* @property {string} symbol - The Symbol of the native token.
|
|
23
|
+
*/
|
|
24
|
+
export interface AxelarChainDetails {
|
|
25
|
+
id: string;
|
|
26
|
+
symbol: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* @typedef {Object} BridgeContracts
|
|
30
|
+
* @property {Address} rootChainERC20Predicate - The address of the root chain ERC20 predicate contract.
|
|
31
|
+
* @property {Address} rootChainStateSender - The address of the root chain state sender contract.
|
|
32
|
+
* @property {Address} childChainERC20Predicate - The address of the child chain ERC20 predicate contract.
|
|
33
|
+
* @property {Address} childChainStateReceiver - The address of the child chain state receiver contract.
|
|
34
|
+
*/
|
|
35
|
+
export type BridgeContracts = {
|
|
36
|
+
rootERC20BridgeFlowRate: Address;
|
|
37
|
+
childERC20Bridge: Address;
|
|
38
|
+
rootChainIMX: Address;
|
|
39
|
+
rootChainWrappedETH: Address;
|
|
40
|
+
childChainWrappedETH: Address;
|
|
41
|
+
childChainWrappedIMX: Address;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* @typedef {Object} BridgeModuleConfiguration
|
|
45
|
+
* @extends {ModuleConfiguration<BridgeOverrides>}
|
|
46
|
+
* @property {BridgeInstance} bridgeInstance - The bridge instance configuration.
|
|
47
|
+
* @property {Provider} rootProvider - The root chain provider.
|
|
48
|
+
* @property {Provider} childProvider - The child chain provider.
|
|
49
|
+
*/
|
|
50
|
+
export interface BridgeModuleConfiguration extends ModuleConfiguration<BridgeOverrides> {
|
|
51
|
+
bridgeInstance: BridgeInstance;
|
|
52
|
+
rootProvider: Provider;
|
|
53
|
+
childProvider: Provider;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* @typedef {string} Address - Represents an Ethereum address.
|
|
57
|
+
*/
|
|
58
|
+
export type Address = string;
|
|
59
|
+
/**
|
|
60
|
+
* @typedef {Address | 'NATIVE'} FungibleToken - Represents a fungible token, either an ERC20 token address or the native token.
|
|
61
|
+
*/
|
|
62
|
+
export type FungibleToken = Address | 'NATIVE';
|
|
63
|
+
/**
|
|
64
|
+
* @typedef {Object} CompletionStatus
|
|
65
|
+
* @property {string} SUCCESS - The transaction has been successfully synced.
|
|
66
|
+
* @property {string} PENDING - The transaction is still pending.
|
|
67
|
+
* @property {string} FAILED - The transaction has failed.
|
|
68
|
+
*/
|
|
69
|
+
export declare enum CompletionStatus {
|
|
70
|
+
SUCCESS = "SUCCESS",
|
|
71
|
+
PENDING = "PENDING",
|
|
72
|
+
FAILED = "FAILED"
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* @typedef {Object} BridgeFeeActions
|
|
76
|
+
* @property {string} DEPOSIT - The transaction has been successfully synced.
|
|
77
|
+
* @property {string} WITHDRAW - The transaction is still pending.
|
|
78
|
+
* @property {string} FINALISE_WITHDRAWAL - Calculate gas .
|
|
79
|
+
*/
|
|
80
|
+
export declare enum BridgeFeeActions {
|
|
81
|
+
DEPOSIT = "DEPOSIT",
|
|
82
|
+
WITHDRAW = "WITHDRAW",
|
|
83
|
+
FINALISE_WITHDRAWAL = "FINALISE_WITHDRAWAL"
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* @typedef {Object} BridgeMethodGas
|
|
87
|
+
* @property {string} DEPOSIT_SOURCE - The gas required to deposit to the bridge.
|
|
88
|
+
* @property {string} DEPOSIT_DESTINATION - The gas required to process the deposit on the destination chain.
|
|
89
|
+
* @property {string} WITHDRAW_SOURCE - The gas required to withdraw from the bridge.
|
|
90
|
+
* @property {string} WITHDRAW_DESTINATION - The gas required to process the withdrawal on the destination chain.
|
|
91
|
+
* @property {string} FINALISE_WITHDRAWAL - The gas required to finalise a withdrawal from the flow rate queue.
|
|
92
|
+
*/
|
|
93
|
+
export declare enum BridgeMethodsGasLimit {
|
|
94
|
+
DEPOSIT_SOURCE = 150000,
|
|
95
|
+
DEPOSIT_DESTINATION = 250000,
|
|
96
|
+
WITHDRAW_SOURCE = 250000,
|
|
97
|
+
WITHDRAW_DESTINATION = 250000,
|
|
98
|
+
MAP_TOKEN_SOURCE = 200000,
|
|
99
|
+
MAP_TOKEN_DESTINATION = 200000,
|
|
100
|
+
FINALISE_WITHDRAWAL = 200000,
|
|
101
|
+
APPROVE_TOKEN = 55000
|
|
102
|
+
}
|
|
103
|
+
export interface FeeData {
|
|
104
|
+
lastBaseFeePerGas: null | bigint;
|
|
105
|
+
maxFeePerGas: null | bigint;
|
|
106
|
+
maxPriorityFeePerGas: null | bigint;
|
|
107
|
+
gasPrice: null | bigint;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* @typedef {Object} BridgeFeeRequest
|
|
111
|
+
* @dev Union type of DepositFeeRequest|WithdrawFeeRequest|FinaliseFeeRequest|MapTokenFeeRequest
|
|
112
|
+
* ensures the correct params are supplied when trying to calculate the fees
|
|
113
|
+
*/
|
|
114
|
+
export type BridgeFeeRequest = DepositNativeFeeRequest | DepositERC20FeeRequest | WithdrawNativeFeeRequest | WithdrawERC20FeeRequest | FinaliseFeeRequest;
|
|
115
|
+
/**
|
|
116
|
+
* @typedef {Object} DepositNativeFeeRequest
|
|
117
|
+
* @property {BridgeFeeActions} method - The method for which the bridge fee is being requested.
|
|
118
|
+
* @property {number} gasMultiplier - How much buffer to add to the gas fee, or 'auto' to use Axelar's automatic gas multiplier
|
|
119
|
+
* @property {string} sourceChainId - The chain ID of the source chain.
|
|
120
|
+
* @property {string} destinationChainId - The chain ID of the destination chain.
|
|
121
|
+
*/
|
|
122
|
+
export interface DepositNativeFeeRequest {
|
|
123
|
+
action: BridgeFeeActions.DEPOSIT;
|
|
124
|
+
gasMultiplier: number | string;
|
|
125
|
+
sourceChainId: string;
|
|
126
|
+
destinationChainId: string;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* @typedef {Object} DepositERC20FeeRequest
|
|
130
|
+
* @property {BridgeFeeActions} method - The method for which the bridge fee is being requested.
|
|
131
|
+
* @property {number} gasMultiplier - How much buffer to add to the gas fee, or 'auto' to use Axelar's automatic gas multiplier
|
|
132
|
+
* @property {string} sourceChainId - The chain ID of the source chain.
|
|
133
|
+
* @property {string} destinationChainId - The chain ID of the destination chain.
|
|
134
|
+
* @property {FungibleToken} token - The token to be deposited.
|
|
135
|
+
* @property {bigint} amount - The amount to be deposited.
|
|
136
|
+
*/
|
|
137
|
+
export interface DepositERC20FeeRequest {
|
|
138
|
+
action: BridgeFeeActions.DEPOSIT;
|
|
139
|
+
gasMultiplier: number | string;
|
|
140
|
+
sourceChainId: string;
|
|
141
|
+
destinationChainId: string;
|
|
142
|
+
token: FungibleToken;
|
|
143
|
+
amount: bigint;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* @typedef {Object} WithdrawNativeFeeRequest
|
|
147
|
+
* @property {BridgeFeeActions} method - The method for which the bridge fee is being requested.
|
|
148
|
+
* @property {number} gasMultiplier - How much buffer to add to the gas fee, or 'auto' to use Axelar's automatic gas multiplier
|
|
149
|
+
* @property {string} sourceChainId - The chain ID of the source chain.
|
|
150
|
+
* @property {string} destinationChainId - The chain ID of the destination chain.
|
|
151
|
+
*/
|
|
152
|
+
export interface WithdrawNativeFeeRequest {
|
|
153
|
+
action: BridgeFeeActions.WITHDRAW;
|
|
154
|
+
gasMultiplier: number | string;
|
|
155
|
+
sourceChainId: string;
|
|
156
|
+
destinationChainId: string;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* @typedef {Object} WithdrawERC20FeeRequest
|
|
160
|
+
* @property {BridgeFeeActions} method - The method for which the bridge fee is being requested.
|
|
161
|
+
* @property {number} gasMultiplier - How much buffer to add to the gas fee, or 'auto' to use Axelar's automatic gas multiplier
|
|
162
|
+
* @property {string} sourceChainId - The chain ID of the source chain.
|
|
163
|
+
* @property {string} destinationChainId - The chain ID of the destination chain.
|
|
164
|
+
* @property {FungibleToken} token - The token to be withdrawn.
|
|
165
|
+
* @property {bigint} amount - The amount to be withdrawn.
|
|
166
|
+
*/
|
|
167
|
+
export interface WithdrawERC20FeeRequest {
|
|
168
|
+
action: BridgeFeeActions.WITHDRAW;
|
|
169
|
+
gasMultiplier: number | string;
|
|
170
|
+
sourceChainId: string;
|
|
171
|
+
destinationChainId: string;
|
|
172
|
+
token: FungibleToken;
|
|
173
|
+
amount: bigint;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* @typedef {Object} FinaliseFeeRequest
|
|
177
|
+
* @property {BridgeFeeActions} method - The method for which the bridge fee is being requested.
|
|
178
|
+
* @property {string} sourceChainId - The chain ID of the chain we are finalising the withdrawal on. This is ALWAYS the root chain.
|
|
179
|
+
*/
|
|
180
|
+
export interface FinaliseFeeRequest {
|
|
181
|
+
action: BridgeFeeActions.FINALISE_WITHDRAWAL;
|
|
182
|
+
sourceChainId: string;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* @typedef {Object} BridgeFeeResponse
|
|
186
|
+
* @property {bigint} sourceChainGas - Gas cost to send tokens to the bridge contract on the source chain.
|
|
187
|
+
* - priced in the source chain's native token.
|
|
188
|
+
* @property {bigint} approvalFee - Gas cost to approve bridge contract to spend tokens on the source chain.
|
|
189
|
+
* - priced in the source chain's native token.
|
|
190
|
+
* @property {bigint} bridgeFee - destinationChainGas + validatorFee.
|
|
191
|
+
* This will be added to the tx.value of the bridge transaction and forwarded to the Axelar Gas Service contract.
|
|
192
|
+
* - priced in the source chain's native token.
|
|
193
|
+
* @property {bigint} imtblFee - The fee charged by Immutable to facilitate the bridge.
|
|
194
|
+
* - priced in the source chain's native token.
|
|
195
|
+
* @property {bigint} totalFees - The total fees the user will be charged which is;
|
|
196
|
+
* sourceChainGas + approvalFee + bridgeFee + imtblFee.
|
|
197
|
+
* - priced in the source chain's native token.
|
|
198
|
+
*/
|
|
199
|
+
export interface BridgeFeeResponse {
|
|
200
|
+
sourceChainGas: bigint;
|
|
201
|
+
approvalFee: bigint;
|
|
202
|
+
bridgeFee: bigint;
|
|
203
|
+
imtblFee: bigint;
|
|
204
|
+
totalFees: bigint;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* @typedef {Object} ApproveBridgeRequest
|
|
208
|
+
* @property {string} senderAddress - The address of the depositor.
|
|
209
|
+
* @property {FungibleToken} token - The token to be approved.
|
|
210
|
+
* @property {bigint} amount - The amount to be approved for deposit.
|
|
211
|
+
* @property {string} sourceChainId - The chain ID of the source chain.
|
|
212
|
+
* @property {string} destinationChainId - The chain ID of the destination chain.
|
|
213
|
+
*/
|
|
214
|
+
export interface ApproveBridgeRequest {
|
|
215
|
+
senderAddress: Address;
|
|
216
|
+
token: FungibleToken;
|
|
217
|
+
amount: bigint;
|
|
218
|
+
sourceChainId: string;
|
|
219
|
+
destinationChainId: string;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* @typedef {Object} ApproveBridgeResponse
|
|
223
|
+
* @property {TransactionRequest | null} unsignedTx - The unsigned transaction for the token approval,
|
|
224
|
+
* or null if no approval is required.
|
|
225
|
+
*/
|
|
226
|
+
export interface ApproveBridgeResponse {
|
|
227
|
+
contractToApprove: string | null;
|
|
228
|
+
unsignedTx: TransactionRequest | null;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* @typedef {Object} BridgeTxRequest
|
|
232
|
+
* @property {Address} senderAddress - The address of the depositor.
|
|
233
|
+
* @property {Address} recipientAddress - The address of the recipient.
|
|
234
|
+
* @property {FungibleToken} token - The token to be deposited.
|
|
235
|
+
* @property {bigint} amount - The amount to be deposited.
|
|
236
|
+
* @property {string} sourceChainId - The chain ID of the source chain.
|
|
237
|
+
* @property {string} destinationChainId - The chain ID of the destination chain.
|
|
238
|
+
*/
|
|
239
|
+
export interface BridgeTxRequest {
|
|
240
|
+
senderAddress: Address;
|
|
241
|
+
recipientAddress: Address;
|
|
242
|
+
token: FungibleToken;
|
|
243
|
+
amount: bigint;
|
|
244
|
+
sourceChainId: string;
|
|
245
|
+
destinationChainId: string;
|
|
246
|
+
gasMultiplier: number | string;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* @typedef {Object} BridgeTxResponse
|
|
250
|
+
* @property {BridgeFeeResponse} fees - The fees associated with the Bridge transaction.
|
|
251
|
+
* @property {TransactionRequest} unsignedTx - The unsigned transaction for the deposit.
|
|
252
|
+
*/
|
|
253
|
+
export interface BridgeTxResponse {
|
|
254
|
+
feeData: BridgeFeeResponse;
|
|
255
|
+
unsignedTx: TransactionRequest;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* @typedef {Object} BridgeBundledTxRequest
|
|
259
|
+
* @property {Address} senderAddress - The address of the depositor.
|
|
260
|
+
* @property {Address} recipientAddress - The address of the recipient.
|
|
261
|
+
* @property {FungibleToken} token - The token to be deposited.
|
|
262
|
+
* @property {bigint} amount - The amount to be deposited.
|
|
263
|
+
* @property {string} sourceChainId - The chain ID of the source chain.
|
|
264
|
+
* @property {string} destinationChainId - The chain ID of the destination chain.
|
|
265
|
+
*/
|
|
266
|
+
export interface BridgeBundledTxRequest {
|
|
267
|
+
senderAddress: Address;
|
|
268
|
+
recipientAddress: Address;
|
|
269
|
+
token: FungibleToken;
|
|
270
|
+
amount: bigint;
|
|
271
|
+
sourceChainId: string;
|
|
272
|
+
destinationChainId: string;
|
|
273
|
+
gasMultiplier: number | string;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* @typedef {Object} BridgeBundledTxResponse
|
|
277
|
+
* @property {BridgeFeeResponse} fees - The fees associated with the Bridge transaction.
|
|
278
|
+
* @property {string | null} contractToApprove - The contract to approve for the approval transaction, or null if no approval is required.
|
|
279
|
+
* @property {TransactionRequest | null} unsignedApprovalTx - The unsigned transaction for the token approval, or null
|
|
280
|
+
* if no approval is required.
|
|
281
|
+
* @property {TransactionRequest} unsignedBridgeTx - The unsigned transaction for the deposit / withdrawal.
|
|
282
|
+
* @property {boolean | null} delayWithdrawalLargeAmount - If withdrawal gets queued due to large amount.
|
|
283
|
+
* @property {boolean | null} delayWithdrawalUnknownToken - If withdrawal gets queued due to unknown token.
|
|
284
|
+
* @property {boolean | null} withdrawalQueueActivated - If withdrawal gets queued due to activated queue.
|
|
285
|
+
* @property {number | null} largeTransferThresholds - The configured large transfer threshold for given withdrawal token.
|
|
286
|
+
*/
|
|
287
|
+
export interface BridgeBundledTxResponse {
|
|
288
|
+
feeData: BridgeFeeResponse;
|
|
289
|
+
contractToApprove: string | null;
|
|
290
|
+
unsignedApprovalTx: TransactionRequest | null;
|
|
291
|
+
unsignedBridgeTx: TransactionRequest;
|
|
292
|
+
delayWithdrawalLargeAmount: boolean | null;
|
|
293
|
+
delayWithdrawalUnknownToken: boolean | null;
|
|
294
|
+
withdrawalQueueActivated: boolean | null;
|
|
295
|
+
largeTransferThresholds: number | null;
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* @typedef {Object} TxStatusRequest
|
|
299
|
+
* @property {string} sourceChainId - The chain ID of the source chain.
|
|
300
|
+
* @property {Array<TxStatusRequestItem>} transactions - The transaction items to query the status for.
|
|
301
|
+
*/
|
|
302
|
+
export interface TxStatusRequest {
|
|
303
|
+
transactions: Array<TxStatusRequestItem>;
|
|
304
|
+
sourceChainId: string;
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* @typedef {Object} TxStatusRequestItem
|
|
308
|
+
* @property {string} txHash - The transaction hash on the source chain of the bridge transaction.
|
|
309
|
+
*/
|
|
310
|
+
export interface TxStatusRequestItem {
|
|
311
|
+
txHash: string;
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* @typedef {Object} TxStatusResponse
|
|
315
|
+
* @property {Array<TxStatusResponseItem>} transactions - The status items of the requested transactions.
|
|
316
|
+
*/
|
|
317
|
+
export interface TxStatusResponse {
|
|
318
|
+
transactions: Array<TxStatusResponseItem>;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* @typedef {Object} AxelarStatusResponse
|
|
322
|
+
* @property {Array<TxStatusResponseItem>} txStatusItems - The status items of the requested transactions.
|
|
323
|
+
* @property {Array<string>} uniqueReceivers - The unique receivers to look up in the flow rate queue.
|
|
324
|
+
*/
|
|
325
|
+
export interface AxelarStatusResponse {
|
|
326
|
+
txStatusItems: Array<TxStatusResponseItem>;
|
|
327
|
+
uniqueReceivers: Array<string>;
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* @typedef {Object} TxStatusResponseItem
|
|
331
|
+
* @property {string} txHash - The transaction hash on the source chain of the bridge transaction.
|
|
332
|
+
* @property {Address} sender - The address of the sender on the source chain.
|
|
333
|
+
* @property {Address} recipient - The address of the recipient on the destination chain.
|
|
334
|
+
* @property {FungibleToken} token - The token being bridged.
|
|
335
|
+
* @property {bigint} amount - The amount of the transaction.
|
|
336
|
+
* @property {StatusResponse} status - The status of the transaction.
|
|
337
|
+
* @property {any} data - Any extra data relevant to the transaction.
|
|
338
|
+
*/
|
|
339
|
+
export interface TxStatusResponseItem {
|
|
340
|
+
txHash: string;
|
|
341
|
+
sender: Address;
|
|
342
|
+
recipient: Address;
|
|
343
|
+
token: FungibleToken;
|
|
344
|
+
amount: bigint;
|
|
345
|
+
status: StatusResponse;
|
|
346
|
+
data: any;
|
|
347
|
+
}
|
|
348
|
+
export declare enum StatusResponse {
|
|
349
|
+
PENDING = "PENDING",
|
|
350
|
+
PROCESSING = "PROCESSING",
|
|
351
|
+
COMPLETE = "COMPLETE",
|
|
352
|
+
RETRY = "RETRY",
|
|
353
|
+
ERROR = "ERROR",
|
|
354
|
+
NOT_ENOUGH_GAS = "NOT_ENOUGH_GAS",
|
|
355
|
+
FLOW_RATE_CONTROLLED = "FLOW_RATE_CONTROLLED"
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* @typedef {Object} FlowRateInfoRequest
|
|
359
|
+
* @property {FungibleToken} token - Optional param to filter the flowRate info by. If not specified info for all tokens will be returned.
|
|
360
|
+
*/
|
|
361
|
+
export interface FlowRateInfoRequest {
|
|
362
|
+
tokens: Array<FungibleToken>;
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* @typedef {Object} FlowRateInfoResponse
|
|
366
|
+
* @property {boolean} withdrawalQueueActivated - True if the withdrawal queue has been activated across all tokens.
|
|
367
|
+
* @property {number} withdrawalDelay - Delay in seconds before queued withdrawal can be procesed.
|
|
368
|
+
* @property {Record<FungibleToken, FlowRateInfoItem>} tokens - The information on the flow rate for each bridgeable token.
|
|
369
|
+
*/
|
|
370
|
+
export interface FlowRateInfoResponse {
|
|
371
|
+
withdrawalQueueActivated: boolean;
|
|
372
|
+
withdrawalDelay: number;
|
|
373
|
+
tokens: Record<FungibleToken, FlowRateInfoItem>;
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* @typedef {Object} FlowRateInfoItem
|
|
377
|
+
* @property {string} capacity - The number of tokens that can fit in the bucket, Zero means flow rate is not configured.
|
|
378
|
+
* @property {string} depth - The number of tokens in the bucket.
|
|
379
|
+
* @property {string} refillTime - The last time the bucket was updated.
|
|
380
|
+
* @property {string} refillRate - The number of tokens added per second.
|
|
381
|
+
*/
|
|
382
|
+
export interface FlowRateInfoItem {
|
|
383
|
+
capacity: bigint;
|
|
384
|
+
depth: bigint;
|
|
385
|
+
refillTime: number;
|
|
386
|
+
refillRate: bigint;
|
|
387
|
+
largeTransferThreshold: bigint;
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* @typedef {Object} PendingWithdrawalsRequest
|
|
391
|
+
* @property {Address} recipient - The address for which the pending withdrawals should be retrieved.
|
|
392
|
+
*/
|
|
393
|
+
export interface PendingWithdrawalsRequest {
|
|
394
|
+
recipient: Address;
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* @typedef {Object} PendingWithdrawalsResponse
|
|
398
|
+
* @property {Address} rootToken - The address of the corresponding token on the root chain.
|
|
399
|
+
* @property {Address} childToken - The address of the corresponding token on the child chain.
|
|
400
|
+
*/
|
|
401
|
+
export interface PendingWithdrawalsResponse {
|
|
402
|
+
pending: Array<PendingWithdrawal>;
|
|
403
|
+
}
|
|
404
|
+
export interface PendingWithdrawal {
|
|
405
|
+
canWithdraw: boolean;
|
|
406
|
+
withdrawer: Address;
|
|
407
|
+
recipient: Address;
|
|
408
|
+
token: FungibleToken;
|
|
409
|
+
amount: bigint;
|
|
410
|
+
timeoutStart: number;
|
|
411
|
+
timeoutEnd: number;
|
|
412
|
+
}
|
|
413
|
+
export interface RootBridgePendingWithdrawal {
|
|
414
|
+
withdrawer: Address;
|
|
415
|
+
token: FungibleToken;
|
|
416
|
+
amount: bigint;
|
|
417
|
+
timestamp: bigint;
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* @typedef {Object} FlowRateWithdrawRequest
|
|
421
|
+
* @property {FungibleToken} recipient - The address for which the flow rate withdrawal transaction should be constructed.
|
|
422
|
+
* @property {number} index - The index of the flow rate withdrawal to be processed.
|
|
423
|
+
*/
|
|
424
|
+
export interface FlowRateWithdrawRequest {
|
|
425
|
+
recipient: Address;
|
|
426
|
+
index: number;
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* @typedef {Object} FlowRateWithdrawResponse
|
|
430
|
+
* @property {TransactionRequest} unsignedTx - The unsigned transaction for the flow rate withdrawal.
|
|
431
|
+
*/
|
|
432
|
+
export interface FlowRateWithdrawResponse {
|
|
433
|
+
pendingWithdrawal: PendingWithdrawal;
|
|
434
|
+
unsignedTx: TransactionRequest | null;
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* @typedef {Object} TokenMappingRequest
|
|
438
|
+
* @property {FungibleToken} rootToken - The token on the root chain for which the corresponding token on the child chain is required.
|
|
439
|
+
*/
|
|
440
|
+
export interface TokenMappingRequest {
|
|
441
|
+
rootToken: FungibleToken;
|
|
442
|
+
rootChainId: string;
|
|
443
|
+
childChainId: string;
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* @typedef {Object} TokenMappingResponse
|
|
447
|
+
* @property {FungibleToken} rootToken - The address of the corresponding token on the root chain.
|
|
448
|
+
* @property {FungibleToken} childToken - The address of the corresponding token on the child chain.
|
|
449
|
+
*/
|
|
450
|
+
export interface TokenMappingResponse {
|
|
451
|
+
rootToken: FungibleToken;
|
|
452
|
+
childToken: FungibleToken | null;
|
|
453
|
+
}
|
|
454
|
+
export interface DynamicGasEstimatesResponse {
|
|
455
|
+
approvalGas: number;
|
|
456
|
+
sourceChainGas: number;
|
|
457
|
+
}
|
|
458
|
+
export interface BridgeDirection {
|
|
459
|
+
action: BridgeFeeActions.DEPOSIT | BridgeFeeActions.WITHDRAW;
|
|
460
|
+
sourceChainId: string;
|
|
461
|
+
destinationChainId: string;
|
|
462
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type TenderlySimulation = {
|
|
2
|
+
from: string;
|
|
3
|
+
to: string;
|
|
4
|
+
data?: string;
|
|
5
|
+
value?: string;
|
|
6
|
+
};
|
|
7
|
+
export type TenderlyResult = {
|
|
8
|
+
gas: Array<number>;
|
|
9
|
+
delayWithdrawalLargeAmount: boolean;
|
|
10
|
+
delayWithdrawalUnknownToken: boolean;
|
|
11
|
+
withdrawalQueueActivated: boolean;
|
|
12
|
+
largeTransferThresholds: number;
|
|
13
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@imtbl/bridge-sdk",
|
|
3
|
+
"description": "Bridge Provider package for the Immutable SDK",
|
|
4
|
+
"version": "2.0.0-alpha.0",
|
|
5
|
+
"author": "Immutable",
|
|
6
|
+
"bugs": "https://github.com/immutable/ts-immutable-sdk/issues",
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"@imtbl/config": "2.0.0-alpha.0",
|
|
9
|
+
"@jest/globals": "^29.5.0",
|
|
10
|
+
"axios": "^1.6.5",
|
|
11
|
+
"ethers": "^6.13.4"
|
|
12
|
+
},
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"@swc/core": "^1.3.36",
|
|
15
|
+
"@swc/jest": "^0.2.24",
|
|
16
|
+
"@typechain/ethers-v6": "^0.5.1",
|
|
17
|
+
"@types/jest": "^29.4.3",
|
|
18
|
+
"@types/node": "^18.14.2",
|
|
19
|
+
"jest": "^29.4.3",
|
|
20
|
+
"jest-environment-jsdom": "^29.4.3",
|
|
21
|
+
"ts-node": "^10.9.1",
|
|
22
|
+
"tsup": "^8.3.5",
|
|
23
|
+
"typechain": "^8.1.1",
|
|
24
|
+
"typescript": "^5.6.2"
|
|
25
|
+
},
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=20.11.0"
|
|
28
|
+
},
|
|
29
|
+
"exports": {
|
|
30
|
+
"development": {
|
|
31
|
+
"types": "./src/index.ts",
|
|
32
|
+
"browser": "./dist/browser/index.js",
|
|
33
|
+
"require": "./dist/node/index.cjs",
|
|
34
|
+
"default": "./dist/node/index.js"
|
|
35
|
+
},
|
|
36
|
+
"default": {
|
|
37
|
+
"types": "./dist/types/index.d.ts",
|
|
38
|
+
"browser": "./dist/browser/index.js",
|
|
39
|
+
"require": "./dist/node/index.cjs",
|
|
40
|
+
"default": "./dist/node/index.js"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"files": [
|
|
44
|
+
"dist"
|
|
45
|
+
],
|
|
46
|
+
"homepage": "https://github.com/immutable/ts-immutable-sdk#readme",
|
|
47
|
+
"keywords": [
|
|
48
|
+
"immutablex"
|
|
49
|
+
],
|
|
50
|
+
"license": "Apache-2.0",
|
|
51
|
+
"main": "dist/node/index.cjs",
|
|
52
|
+
"module": "dist/node/index.js",
|
|
53
|
+
"browser": "dist/browser/index.js",
|
|
54
|
+
"publishConfig": {
|
|
55
|
+
"access": "public"
|
|
56
|
+
},
|
|
57
|
+
"repository": "immutable/ts-immutable-sdk.git",
|
|
58
|
+
"source": "src/index.ts",
|
|
59
|
+
"type": "module",
|
|
60
|
+
"types": "./dist/types/index.d.ts",
|
|
61
|
+
"scripts": {
|
|
62
|
+
"build": "pnpm transpile && pnpm typegen",
|
|
63
|
+
"transpile": "tsup src/index.ts --config ../../../../tsup.config.js",
|
|
64
|
+
"typegen": "tsc --customConditions default --emitDeclarationOnly --outDir dist/types",
|
|
65
|
+
"lint": "eslint ./src --ext .ts --max-warnings=0",
|
|
66
|
+
"lint:fix": "cd ../../../../ && pnpm wsrun -p @imtbl/bridge-sdk -c lint --fix",
|
|
67
|
+
"test": "jest test -- --silent=false",
|
|
68
|
+
"test:watch": "jest --watch",
|
|
69
|
+
"typecheck": "tsc --customConditions default --noEmit"
|
|
70
|
+
}
|
|
71
|
+
}
|