@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,121 @@
|
|
|
1
|
+
import { AxelarChainDetails, BridgeInstance } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* @constant {string} NATIVE - The native token representation.
|
|
4
|
+
*/
|
|
5
|
+
export declare const NATIVE = "NATIVE";
|
|
6
|
+
/**
|
|
7
|
+
* @constant {string} ETH_SEPOLIA_CHAIN_ID - The chain ID for the Ethereum Sepolia testnet (EIP-155 compatible format).
|
|
8
|
+
*/
|
|
9
|
+
export declare const ETH_SEPOLIA_CHAIN_ID = "11155111";
|
|
10
|
+
/**
|
|
11
|
+
* @constant {string} ETH_MAINNET_CHAIN_ID - The chain ID for the Ethereum mainnet (EIP-155 compatible format).
|
|
12
|
+
*/
|
|
13
|
+
export declare const ETH_MAINNET_CHAIN_ID = "1";
|
|
14
|
+
/**
|
|
15
|
+
* @constant {string} ZKEVM_DEVNET_CHAIN_ID - The chain ID for the zkEVM devnet (EIP-155 compatible format).
|
|
16
|
+
*/
|
|
17
|
+
export declare const ZKEVM_DEVNET_CHAIN_ID = "15003";
|
|
18
|
+
/**
|
|
19
|
+
* @constant {string} ZKEVM_TESTNET_CHAIN_ID - The chain ID for the zkEVM testnet (EIP-155 compatible format).
|
|
20
|
+
*/
|
|
21
|
+
export declare const ZKEVM_TESTNET_CHAIN_ID = "13473";
|
|
22
|
+
/**
|
|
23
|
+
* @constant {string} ZKEVM_MAINNET_CHAIN_ID - The chain ID for the zkEVM mainnet (EIP-155 compatible format).
|
|
24
|
+
*/
|
|
25
|
+
export declare const ZKEVM_MAINNET_CHAIN_ID = "13371";
|
|
26
|
+
/**
|
|
27
|
+
* @constant {string} IMTBL_ZKEVM_NATIVE_TOKEN_ADDRESS - Address of the native token on the child chain.
|
|
28
|
+
*/
|
|
29
|
+
export declare const IMTBL_ZKEVM_NATIVE_TOKEN_ADDRESS = "0x0000000000000000000000000000000000000fff";
|
|
30
|
+
/**
|
|
31
|
+
* @constant {string} CHILD_CHAIN_NATIVE_TOKEN_ADDRESS - Address of the native token on the child chain.
|
|
32
|
+
*/
|
|
33
|
+
export declare const ETHEREUM_NATIVE_TOKEN_ADDRESS = "0x0000000000000000000000000000000000000eee";
|
|
34
|
+
/**
|
|
35
|
+
* @constant {string} WITHDRAW_SIG - Signature of the withdraw command, this is keccak256("WITHDRAW").
|
|
36
|
+
*/
|
|
37
|
+
export declare const WITHDRAW_SIG = "0x7a8dc26796a1e50e6e190b70259f58f6a4edd5b22280ceecc82b687b8e982869";
|
|
38
|
+
/**
|
|
39
|
+
* @constant {string} SLOT_PREFIX_CONTRACT_CALL_APPROVED - The prefix of the storage slot to store contract call approved mapping
|
|
40
|
+
* in axelar gateway proxy.
|
|
41
|
+
*/
|
|
42
|
+
export declare const SLOT_PREFIX_CONTRACT_CALL_APPROVED = "0x07b0d4304f82012bd3b70b1d531c160e326067c90829e2a3d386722ad10b89c3";
|
|
43
|
+
/**
|
|
44
|
+
* @constant {string} SLOT_POS_CONTRACT_CALL_APPROVED - The position of the storage slot to store contract call approved mapping.
|
|
45
|
+
*/
|
|
46
|
+
export declare const SLOT_POS_CONTRACT_CALL_APPROVED = 4;
|
|
47
|
+
/**
|
|
48
|
+
* @typedef {Object} childWIMXs - Child Wrapped IMX address for the testnet & mainnet.
|
|
49
|
+
*/
|
|
50
|
+
export declare const childWIMXs: Record<string, string>;
|
|
51
|
+
/**
|
|
52
|
+
* @typedef {Object} rootIMXs - Root IMX address for the testnet & mainnet.
|
|
53
|
+
*/
|
|
54
|
+
export declare const rootIMXs: Record<string, string>;
|
|
55
|
+
/**
|
|
56
|
+
* @typedef {Object} childETHs - Child ETH address for the testnet & mainnet.
|
|
57
|
+
*/
|
|
58
|
+
export declare const childETHs: Record<string, string>;
|
|
59
|
+
/**
|
|
60
|
+
* @typedef {Object} childAdaptors - Child Adaptor address for the testnet & mainnet.
|
|
61
|
+
*/
|
|
62
|
+
export declare const childAdaptors: Record<string, string>;
|
|
63
|
+
/**
|
|
64
|
+
* @typedef {Object} rootAdaptors - Root Adaptor address for the testnet & mainnet.
|
|
65
|
+
*/
|
|
66
|
+
export declare const rootAdaptors: Record<string, string>;
|
|
67
|
+
/**
|
|
68
|
+
* @typedef {Object} childChains - Child Chain name for the testnet & mainnet.
|
|
69
|
+
*/
|
|
70
|
+
export declare const childChains: Record<string, string>;
|
|
71
|
+
/**
|
|
72
|
+
* @typedef {Object} axelarGateways - Axelar gateway address for the testnet & mainnet.
|
|
73
|
+
*/
|
|
74
|
+
export declare const axelarGateways: Record<string, string>;
|
|
75
|
+
/**
|
|
76
|
+
* @constant {BridgeInstance} ETH_SEPOLIA_TO_ZKEVM_DEVNET - A bridge instance configuration for bridging between
|
|
77
|
+
* the Ethereum Sepolia testnet and the zkEVM devnet.
|
|
78
|
+
*/
|
|
79
|
+
export declare const ETH_SEPOLIA_TO_ZKEVM_DEVNET: BridgeInstance;
|
|
80
|
+
/**
|
|
81
|
+
* @constant {BridgeInstance} ETH_SEPOLIA_TO_ZKEVM_TESTNET - A bridge instance configuration for bridging
|
|
82
|
+
* between the Ethereum Sepolia testnet and the zkEVM testnet.
|
|
83
|
+
*/
|
|
84
|
+
export declare const ETH_SEPOLIA_TO_ZKEVM_TESTNET: BridgeInstance;
|
|
85
|
+
/**
|
|
86
|
+
* @constant {BridgeInstance} ETH_MAINNET_TO_ZKEVM_MAINNET - A bridge instance configuration for bridging
|
|
87
|
+
* between the Ethereum mainnet and the zkEVM mainnet.
|
|
88
|
+
*/
|
|
89
|
+
export declare const ETH_MAINNET_TO_ZKEVM_MAINNET: BridgeInstance;
|
|
90
|
+
/**
|
|
91
|
+
* @typedef {Object} axelarAPIEndpoints - API endpoints for the testnet & mainnet Axelar environment configurations
|
|
92
|
+
*/
|
|
93
|
+
export declare const axelarAPIEndpoints: Record<string, string>;
|
|
94
|
+
/**
|
|
95
|
+
* @typedef {Object} tenderlyAPIEndpoints - API endpoints for the testnet & mainnet Axelar environment configurations
|
|
96
|
+
*/
|
|
97
|
+
export declare const tenderlyAPIEndpoints: Record<string, string>;
|
|
98
|
+
/**
|
|
99
|
+
* @typedef {Object} axelarChains
|
|
100
|
+
* @property {AxelarChainDetails} [chainId] - Mapping of the ChainId to the Axelar chain id string and symbol.
|
|
101
|
+
*/
|
|
102
|
+
export declare const axelarChains: Record<string, AxelarChainDetails>;
|
|
103
|
+
/**
|
|
104
|
+
* @typedef {Object} bridgeMethods
|
|
105
|
+
* @property {string} deposit - The set of contract methods for depositing.
|
|
106
|
+
* @property {string} withdraw - The set of contract methods for withdrawing.
|
|
107
|
+
*/
|
|
108
|
+
export declare const bridgeMethods: {
|
|
109
|
+
deposit: {
|
|
110
|
+
token: string;
|
|
111
|
+
tokenTo: string;
|
|
112
|
+
native: string;
|
|
113
|
+
nativeTo: string;
|
|
114
|
+
};
|
|
115
|
+
withdraw: {
|
|
116
|
+
token: string;
|
|
117
|
+
tokenTo: string;
|
|
118
|
+
native: string;
|
|
119
|
+
nativeTo: string;
|
|
120
|
+
};
|
|
121
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const trueInHex = "0x0000000000000000000000000000000000000000000000000000000000000001";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare const CHILD_ERC20: ({
|
|
2
|
+
anonymous: boolean;
|
|
3
|
+
inputs: {
|
|
4
|
+
indexed: boolean;
|
|
5
|
+
internalType: string;
|
|
6
|
+
name: string;
|
|
7
|
+
type: string;
|
|
8
|
+
}[];
|
|
9
|
+
name: string;
|
|
10
|
+
type: string;
|
|
11
|
+
outputs?: undefined;
|
|
12
|
+
stateMutability?: undefined;
|
|
13
|
+
} | {
|
|
14
|
+
inputs: {
|
|
15
|
+
internalType: string;
|
|
16
|
+
name: string;
|
|
17
|
+
type: string;
|
|
18
|
+
}[];
|
|
19
|
+
name: string;
|
|
20
|
+
outputs: {
|
|
21
|
+
internalType: string;
|
|
22
|
+
name: string;
|
|
23
|
+
type: string;
|
|
24
|
+
}[];
|
|
25
|
+
stateMutability: string;
|
|
26
|
+
type: string;
|
|
27
|
+
anonymous?: undefined;
|
|
28
|
+
})[];
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
export declare const CHILD_ERC20_BRIDGE: ({
|
|
2
|
+
inputs: {
|
|
3
|
+
internalType: string;
|
|
4
|
+
name: string;
|
|
5
|
+
type: string;
|
|
6
|
+
}[];
|
|
7
|
+
stateMutability: string;
|
|
8
|
+
type: string;
|
|
9
|
+
name?: undefined;
|
|
10
|
+
anonymous?: undefined;
|
|
11
|
+
outputs?: undefined;
|
|
12
|
+
} | {
|
|
13
|
+
inputs: {
|
|
14
|
+
internalType: string;
|
|
15
|
+
name: string;
|
|
16
|
+
type: string;
|
|
17
|
+
}[];
|
|
18
|
+
name: string;
|
|
19
|
+
type: string;
|
|
20
|
+
stateMutability?: undefined;
|
|
21
|
+
anonymous?: undefined;
|
|
22
|
+
outputs?: undefined;
|
|
23
|
+
} | {
|
|
24
|
+
anonymous: boolean;
|
|
25
|
+
inputs: {
|
|
26
|
+
indexed: boolean;
|
|
27
|
+
internalType: string;
|
|
28
|
+
name: string;
|
|
29
|
+
type: string;
|
|
30
|
+
}[];
|
|
31
|
+
name: string;
|
|
32
|
+
type: string;
|
|
33
|
+
stateMutability?: undefined;
|
|
34
|
+
outputs?: undefined;
|
|
35
|
+
} | {
|
|
36
|
+
inputs: {
|
|
37
|
+
internalType: string;
|
|
38
|
+
name: string;
|
|
39
|
+
type: string;
|
|
40
|
+
}[];
|
|
41
|
+
name: string;
|
|
42
|
+
outputs: {
|
|
43
|
+
internalType: string;
|
|
44
|
+
name: string;
|
|
45
|
+
type: string;
|
|
46
|
+
}[];
|
|
47
|
+
stateMutability: string;
|
|
48
|
+
type: string;
|
|
49
|
+
anonymous?: undefined;
|
|
50
|
+
} | {
|
|
51
|
+
inputs: ({
|
|
52
|
+
components: {
|
|
53
|
+
internalType: string;
|
|
54
|
+
name: string;
|
|
55
|
+
type: string;
|
|
56
|
+
}[];
|
|
57
|
+
internalType: string;
|
|
58
|
+
name: string;
|
|
59
|
+
type: string;
|
|
60
|
+
} | {
|
|
61
|
+
internalType: string;
|
|
62
|
+
name: string;
|
|
63
|
+
type: string;
|
|
64
|
+
components?: undefined;
|
|
65
|
+
})[];
|
|
66
|
+
name: string;
|
|
67
|
+
outputs: never[];
|
|
68
|
+
stateMutability: string;
|
|
69
|
+
type: string;
|
|
70
|
+
anonymous?: undefined;
|
|
71
|
+
} | {
|
|
72
|
+
stateMutability: string;
|
|
73
|
+
type: string;
|
|
74
|
+
inputs?: undefined;
|
|
75
|
+
name?: undefined;
|
|
76
|
+
anonymous?: undefined;
|
|
77
|
+
outputs?: undefined;
|
|
78
|
+
})[];
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export declare const ERC20: ({
|
|
2
|
+
inputs: {
|
|
3
|
+
internalType: string;
|
|
4
|
+
name: string;
|
|
5
|
+
type: string;
|
|
6
|
+
}[];
|
|
7
|
+
stateMutability: string;
|
|
8
|
+
type: string;
|
|
9
|
+
anonymous?: undefined;
|
|
10
|
+
name?: undefined;
|
|
11
|
+
outputs?: undefined;
|
|
12
|
+
} | {
|
|
13
|
+
anonymous: boolean;
|
|
14
|
+
inputs: {
|
|
15
|
+
indexed: boolean;
|
|
16
|
+
internalType: string;
|
|
17
|
+
name: string;
|
|
18
|
+
type: string;
|
|
19
|
+
}[];
|
|
20
|
+
name: string;
|
|
21
|
+
type: string;
|
|
22
|
+
stateMutability?: undefined;
|
|
23
|
+
outputs?: undefined;
|
|
24
|
+
} | {
|
|
25
|
+
inputs: {
|
|
26
|
+
internalType: string;
|
|
27
|
+
name: string;
|
|
28
|
+
type: string;
|
|
29
|
+
}[];
|
|
30
|
+
name: string;
|
|
31
|
+
outputs: {
|
|
32
|
+
internalType: string;
|
|
33
|
+
name: string;
|
|
34
|
+
type: string;
|
|
35
|
+
}[];
|
|
36
|
+
stateMutability: string;
|
|
37
|
+
type: string;
|
|
38
|
+
anonymous?: undefined;
|
|
39
|
+
})[];
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export declare const ROOT_AXELAR_ADAPTOR: ({
|
|
2
|
+
inputs: {
|
|
3
|
+
internalType: string;
|
|
4
|
+
name: string;
|
|
5
|
+
type: string;
|
|
6
|
+
}[];
|
|
7
|
+
stateMutability: string;
|
|
8
|
+
type: string;
|
|
9
|
+
name?: undefined;
|
|
10
|
+
anonymous?: undefined;
|
|
11
|
+
outputs?: undefined;
|
|
12
|
+
} | {
|
|
13
|
+
inputs: never[];
|
|
14
|
+
name: string;
|
|
15
|
+
type: string;
|
|
16
|
+
stateMutability?: undefined;
|
|
17
|
+
anonymous?: undefined;
|
|
18
|
+
outputs?: undefined;
|
|
19
|
+
} | {
|
|
20
|
+
anonymous: boolean;
|
|
21
|
+
inputs: {
|
|
22
|
+
indexed: boolean;
|
|
23
|
+
internalType: string;
|
|
24
|
+
name: string;
|
|
25
|
+
type: string;
|
|
26
|
+
}[];
|
|
27
|
+
name: string;
|
|
28
|
+
type: string;
|
|
29
|
+
stateMutability?: undefined;
|
|
30
|
+
outputs?: undefined;
|
|
31
|
+
} | {
|
|
32
|
+
inputs: {
|
|
33
|
+
internalType: string;
|
|
34
|
+
name: string;
|
|
35
|
+
type: string;
|
|
36
|
+
}[];
|
|
37
|
+
name: string;
|
|
38
|
+
outputs: {
|
|
39
|
+
internalType: string;
|
|
40
|
+
name: string;
|
|
41
|
+
type: string;
|
|
42
|
+
}[];
|
|
43
|
+
stateMutability: string;
|
|
44
|
+
type: string;
|
|
45
|
+
anonymous?: undefined;
|
|
46
|
+
} | {
|
|
47
|
+
inputs: ({
|
|
48
|
+
components: {
|
|
49
|
+
internalType: string;
|
|
50
|
+
name: string;
|
|
51
|
+
type: string;
|
|
52
|
+
}[];
|
|
53
|
+
internalType: string;
|
|
54
|
+
name: string;
|
|
55
|
+
type: string;
|
|
56
|
+
} | {
|
|
57
|
+
internalType: string;
|
|
58
|
+
name: string;
|
|
59
|
+
type: string;
|
|
60
|
+
components?: undefined;
|
|
61
|
+
})[];
|
|
62
|
+
name: string;
|
|
63
|
+
outputs: never[];
|
|
64
|
+
stateMutability: string;
|
|
65
|
+
type: string;
|
|
66
|
+
anonymous?: undefined;
|
|
67
|
+
})[];
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
export declare const ROOT_ERC20_BRIDGE_FLOW_RATE: ({
|
|
2
|
+
inputs: {
|
|
3
|
+
internalType: string;
|
|
4
|
+
name: string;
|
|
5
|
+
type: string;
|
|
6
|
+
}[];
|
|
7
|
+
stateMutability: string;
|
|
8
|
+
type: string;
|
|
9
|
+
name?: undefined;
|
|
10
|
+
anonymous?: undefined;
|
|
11
|
+
outputs?: undefined;
|
|
12
|
+
} | {
|
|
13
|
+
inputs: {
|
|
14
|
+
internalType: string;
|
|
15
|
+
name: string;
|
|
16
|
+
type: string;
|
|
17
|
+
}[];
|
|
18
|
+
name: string;
|
|
19
|
+
type: string;
|
|
20
|
+
stateMutability?: undefined;
|
|
21
|
+
anonymous?: undefined;
|
|
22
|
+
outputs?: undefined;
|
|
23
|
+
} | {
|
|
24
|
+
anonymous: boolean;
|
|
25
|
+
inputs: {
|
|
26
|
+
indexed: boolean;
|
|
27
|
+
internalType: string;
|
|
28
|
+
name: string;
|
|
29
|
+
type: string;
|
|
30
|
+
}[];
|
|
31
|
+
name: string;
|
|
32
|
+
type: string;
|
|
33
|
+
stateMutability?: undefined;
|
|
34
|
+
outputs?: undefined;
|
|
35
|
+
} | {
|
|
36
|
+
inputs: {
|
|
37
|
+
internalType: string;
|
|
38
|
+
name: string;
|
|
39
|
+
type: string;
|
|
40
|
+
}[];
|
|
41
|
+
name: string;
|
|
42
|
+
outputs: {
|
|
43
|
+
components: {
|
|
44
|
+
internalType: string;
|
|
45
|
+
name: string;
|
|
46
|
+
type: string;
|
|
47
|
+
}[];
|
|
48
|
+
internalType: string;
|
|
49
|
+
name: string;
|
|
50
|
+
type: string;
|
|
51
|
+
}[];
|
|
52
|
+
stateMutability: string;
|
|
53
|
+
type: string;
|
|
54
|
+
anonymous?: undefined;
|
|
55
|
+
} | {
|
|
56
|
+
inputs: {
|
|
57
|
+
internalType: string;
|
|
58
|
+
name: string;
|
|
59
|
+
type: string;
|
|
60
|
+
}[];
|
|
61
|
+
name: string;
|
|
62
|
+
outputs: {
|
|
63
|
+
internalType: string;
|
|
64
|
+
name: string;
|
|
65
|
+
type: string;
|
|
66
|
+
}[];
|
|
67
|
+
stateMutability: string;
|
|
68
|
+
type: string;
|
|
69
|
+
anonymous?: undefined;
|
|
70
|
+
} | {
|
|
71
|
+
inputs: ({
|
|
72
|
+
components: {
|
|
73
|
+
internalType: string;
|
|
74
|
+
name: string;
|
|
75
|
+
type: string;
|
|
76
|
+
}[];
|
|
77
|
+
internalType: string;
|
|
78
|
+
name: string;
|
|
79
|
+
type: string;
|
|
80
|
+
} | {
|
|
81
|
+
internalType: string;
|
|
82
|
+
name: string;
|
|
83
|
+
type: string;
|
|
84
|
+
components?: undefined;
|
|
85
|
+
})[];
|
|
86
|
+
name: string;
|
|
87
|
+
outputs: never[];
|
|
88
|
+
stateMutability: string;
|
|
89
|
+
type: string;
|
|
90
|
+
anonymous?: undefined;
|
|
91
|
+
} | {
|
|
92
|
+
stateMutability: string;
|
|
93
|
+
type: string;
|
|
94
|
+
inputs?: undefined;
|
|
95
|
+
name?: undefined;
|
|
96
|
+
anonymous?: undefined;
|
|
97
|
+
outputs?: undefined;
|
|
98
|
+
})[];
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @enum {string} BridgeErrorType - Enumeration of different types of bridge errors.
|
|
3
|
+
*/
|
|
4
|
+
export declare enum BridgeErrorType {
|
|
5
|
+
UNSUPPORTED_ERROR = "UNSUPPORTED_ERROR",
|
|
6
|
+
INVALID_ADDRESS = "INVALID_ADDRESS",
|
|
7
|
+
INVALID_AMOUNT = "INVALID_AMOUNT",
|
|
8
|
+
INTERNAL_ERROR = "INTERNAL_ERROR",
|
|
9
|
+
PROVIDER_ERROR = "PROVIDER_ERROR",
|
|
10
|
+
ROOT_PROVIDER_ERROR = "ROOT_PROVIDER_ERROR",
|
|
11
|
+
CHILD_PROVIDER_ERROR = "CHILD_PROVIDER_ERROR",
|
|
12
|
+
TRANSACTION_REVERTED = "TRANSACTION_REVERTED",
|
|
13
|
+
INVALID_TOKEN = "INVALID_TOKEN",
|
|
14
|
+
INVALID_TRANSACTION = "INVALID_TRANSACTION",
|
|
15
|
+
INVALID_SOURCE_CHAIN_ID = "INVALID_SOURCE_CHAIN_ID",
|
|
16
|
+
INVALID_DESTINATION_CHAIN_ID = "INVALID_DESTINATION_CHAIN_ID",
|
|
17
|
+
INVALID_SOURCE_OR_DESTINATION_CHAIN = "INVALID_SOURCE_OR_DESTINATION_CHAIN",
|
|
18
|
+
CHAIN_IDS_MATCH = "CHAIN_IDS_MATCH",
|
|
19
|
+
AXELAR_CHAIN_NOT_FOUND = "AXELAR_CHAIN_NOT_FOUND",
|
|
20
|
+
AXELAR_GAS_ESTIMATE_FAILED = "AXELAR_GAS_ESTIMATE_FAILED",
|
|
21
|
+
TENDERLY_GAS_ESTIMATE_FAILED = "TENDERLY_GAS_ESTIMATE_FAILED",
|
|
22
|
+
INVALID_RECIPIENT = "INVALID_RECIPIENT",
|
|
23
|
+
FLOW_RATE_ERROR = "FLOW_RATE_ERROR",
|
|
24
|
+
INVALID_FLOWRATE_INDEX = "INVALID_FLOWRATE_INDEX"
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Represents a custom error for bridge operations.
|
|
28
|
+
* @extends Error
|
|
29
|
+
*/
|
|
30
|
+
export declare class BridgeError extends Error {
|
|
31
|
+
/**
|
|
32
|
+
* @property {BridgeErrorType} type - The type of the bridge error.
|
|
33
|
+
*/
|
|
34
|
+
type: BridgeErrorType;
|
|
35
|
+
/**
|
|
36
|
+
* Constructs a BridgeError instance.
|
|
37
|
+
*
|
|
38
|
+
* @param {string} message - The error message.
|
|
39
|
+
* @param {BridgeErrorType} type - The type of the bridge error.
|
|
40
|
+
*/
|
|
41
|
+
constructor(message: string, type: BridgeErrorType);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* A helper function that wraps a Promise function with error handling for bridge operations.
|
|
45
|
+
*
|
|
46
|
+
* @template T - The type of the value that the Promise resolves to.
|
|
47
|
+
* @param {() => Promise<T>} fn - The function to wrap with error handling.
|
|
48
|
+
* @param {BridgeErrorType} customErrorType - The custom error type to use for the error.
|
|
49
|
+
* @param {string} [details] - Additional details to add to the error message.
|
|
50
|
+
* @returns {Promise<T>} The result of the wrapped function or a rejected promise with a BridgeError.
|
|
51
|
+
*/
|
|
52
|
+
export declare const withBridgeError: <T>(fn: () => Promise<T>, customErrorType: BridgeErrorType, details?: string) => Promise<T>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './tokenBridge';
|
|
2
|
+
export * from './constants/bridges';
|
|
3
|
+
export * from './errors/index';
|
|
4
|
+
export * from './config/index';
|
|
5
|
+
export * from './types/axelar';
|
|
6
|
+
export { CompletionStatus, BridgeFeeActions, BridgeMethodsGasLimit, StatusResponse, } from './types/index';
|
|
7
|
+
export type { BridgeInstance, BridgeOverrides, AxelarChainDetails, BridgeContracts, BridgeModuleConfiguration, Address, FungibleToken, FeeData, BridgeFeeRequest, DepositNativeFeeRequest, DepositERC20FeeRequest, WithdrawNativeFeeRequest, WithdrawERC20FeeRequest, FinaliseFeeRequest, BridgeFeeResponse, ApproveBridgeRequest, ApproveBridgeResponse, BridgeTxRequest, BridgeTxResponse, TxStatusRequest, TxStatusRequestItem, TxStatusResponse, TxStatusResponseItem, FlowRateInfoRequest, FlowRateInfoResponse, FlowRateInfoItem, PendingWithdrawalsRequest, PendingWithdrawalsResponse, PendingWithdrawal, FlowRateWithdrawRequest, FlowRateWithdrawResponse, TokenMappingRequest, TokenMappingResponse, } from './types/index';
|
|
8
|
+
export * from './contracts/ABIs/ERC20';
|
|
9
|
+
export * from './contracts/ABIs/RootERC20BridgeFlowRate';
|
|
10
|
+
export * from './contracts/ABIs/ChildERC20Bridge';
|
|
11
|
+
export * from './contracts/ABIs/ChildERC20';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Provider, Contract } from 'ethers';
|
|
2
|
+
/**
|
|
3
|
+
* We need the Axelar command ID to be unique, otherwise the simulation could fail.
|
|
4
|
+
* We don't necessarily care if the command is what would actually be used by the
|
|
5
|
+
* Axelar network.
|
|
6
|
+
* @param payload The Axelar GMP payload.
|
|
7
|
+
* @returns hash of payload and current time.
|
|
8
|
+
*/
|
|
9
|
+
export declare function genUniqueAxelarCommandId(payload: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Generates an Axelar GMP payload for a withdrawal.
|
|
12
|
+
* Note that this is not the payload *hash*. It can be any length of bytes.
|
|
13
|
+
*/
|
|
14
|
+
export declare function genAxelarWithdrawPayload(rootToken: string, sender: string, recipient: string, amount: string): string;
|
|
15
|
+
export declare function createChildErc20Contract(token: string, childProvider: Provider): Promise<Contract>;
|
|
16
|
+
/**
|
|
17
|
+
* Given a child chain token address (or NATIVE), returns its corresponding root token address.
|
|
18
|
+
* This is done by calling the `rootToken` function on the child token contract.
|
|
19
|
+
*/
|
|
20
|
+
export declare function getWithdrawRootToken(childToken: string, destinationChainId: string, childProvider: Provider): Promise<string>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { TenderlySimulation, TenderlyResult } from '../types/tenderly';
|
|
2
|
+
export type StateObject = {
|
|
3
|
+
contractAddress: string;
|
|
4
|
+
stateDiff: StateDiff;
|
|
5
|
+
};
|
|
6
|
+
export type StateDiff = {
|
|
7
|
+
storageSlot: string;
|
|
8
|
+
value: string;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* We want to convert a StateObject type to the following format (Record<string, Record<string, Record<string, string>>>):
|
|
12
|
+
* @example An example of a state object that changes the state at slot 0xe1b959...2585e to 1 at address 0xe43215...8E31:
|
|
13
|
+
* {
|
|
14
|
+
* "0xe432150cce91c13a887f7D836923d5597adD8E31": {
|
|
15
|
+
* "stateDiff": {
|
|
16
|
+
* "0xe1b959a280d5c994e402bc258b5edd82e525f0ef1de9e4c9c7e7e184b2f2585e":
|
|
17
|
+
* "0x0000000000000000000000000000000000000000000000000000000000000001"
|
|
18
|
+
* }
|
|
19
|
+
* }
|
|
20
|
+
* }
|
|
21
|
+
*/
|
|
22
|
+
export declare function unwrapStateObjects(stateObjects: StateObject[]): Record<string, Record<string, Record<string, string>>>;
|
|
23
|
+
/**
|
|
24
|
+
* Submits tenderly simulations, returning an array of gas usage estimates
|
|
25
|
+
* @param chainId ID of network to estimate transactions on
|
|
26
|
+
* @param simulations Array of TenderlySimulation objects (transactions) to estimate gas usage for
|
|
27
|
+
* @param stateObjects An array of `StateObject`s. Each `StateObject` represents one smart contract state change.
|
|
28
|
+
* These `StateObject`s get unwrapped into Tenderly's required format.
|
|
29
|
+
* @returns Array of gas usage estimates.
|
|
30
|
+
*/
|
|
31
|
+
export declare function submitTenderlySimulations(chainId: string, simulations: Array<TenderlySimulation>, stateObjects?: StateObject[]): Promise<TenderlyResult>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Contract } from 'ethers';
|
|
2
|
+
/**
|
|
3
|
+
* @param sender Bridge depositer/withdrawer
|
|
4
|
+
* @param recipient Deposit or withdrawal recipient
|
|
5
|
+
* @param amount Amount to deposit or withdraw
|
|
6
|
+
* @param token Token to deposit or withdraw. NATIVE if native asset on the source chain.
|
|
7
|
+
* @param currentBridgeMethods A Record mapping bridge operation names to contract method names
|
|
8
|
+
* @param bridgeContract: The bridge contract to be interacting with dependinig on network and if it's a deposit or withdrawal
|
|
9
|
+
* @returns calldata for the requested bridge transaction (i.e. tx.data)
|
|
10
|
+
*/
|
|
11
|
+
export declare function getBridgeTxCalldata(sender: string, recipient: string, amount: bigint, token: string, currentBridgeMethods: Record<string, string>, bridgeContract: Contract): Promise<string>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { BridgeDirection, BridgeFeeRequest, BridgeInstance, FungibleToken } from '../types';
|
|
2
|
+
declare function getAddresses(source: string, addresses: Record<string, string>): string;
|
|
3
|
+
export declare function isChildETH(token: FungibleToken, source: string): boolean;
|
|
4
|
+
export declare function getRootIMX(source: string): string;
|
|
5
|
+
export declare function isRootIMX(token: FungibleToken, source: string): boolean;
|
|
6
|
+
export declare function getChildAdaptor(source: string): string;
|
|
7
|
+
export declare function getRootAdaptor(source: string): string;
|
|
8
|
+
export declare function getChildchain(source: string): string;
|
|
9
|
+
export declare function getAxelarGateway(source: string): string;
|
|
10
|
+
export declare function getAxelarEndpoint(source: string): string;
|
|
11
|
+
export declare function getTenderlyEndpoint(source: string): string;
|
|
12
|
+
export declare function isWrappedIMX(token: FungibleToken, source: string): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Checks that the source and destination chains are such that this is a valid deposit bridge transaction.
|
|
15
|
+
*/
|
|
16
|
+
export declare function isValidDeposit(direction: BridgeDirection, bridgeInstance: BridgeInstance): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* @returns true if and only if the source chain is the root chain,
|
|
19
|
+
* indicating that this should be a deposit or withdraw finalisation, without doing validation.
|
|
20
|
+
* Useful for if we believe a transaction should be a deposit or withdraw finalisation,
|
|
21
|
+
* so you can construct relevant data types to then do the checks
|
|
22
|
+
*/
|
|
23
|
+
export declare function shouldBeDepositOrFinaliseWithdraw(sourceChainId: string, bridgeInstance: BridgeInstance): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Checks that the source and destination chains are such that this is a valid withdraw bridge transaction.
|
|
26
|
+
*/
|
|
27
|
+
export declare function isValidWithdraw(direction: BridgeDirection, bridgeInstance: BridgeInstance): boolean;
|
|
28
|
+
export declare function isWithdrawNativeIMX(token: FungibleToken, direction: BridgeDirection, bridgeInstance: BridgeInstance): boolean;
|
|
29
|
+
export declare function isNativeTokenBridgeFeeRequest(req: BridgeFeeRequest): boolean;
|
|
30
|
+
export declare function isWithdrawWrappedIMX(token: FungibleToken, direction: BridgeDirection, bridgeInstance: BridgeInstance): boolean;
|
|
31
|
+
export declare const exportedForTesting: {
|
|
32
|
+
getAddresses: typeof getAddresses;
|
|
33
|
+
};
|
|
34
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { BridgeBundledTxRequest, BridgeFeeRequest, FungibleToken } from '../types';
|
|
2
|
+
import { BridgeConfiguration } from '../config';
|
|
3
|
+
export declare function validateChainConfiguration(config: BridgeConfiguration): Promise<void>;
|
|
4
|
+
export declare function checkReceiver(tokenSent: FungibleToken, destinationChainId: string, address: string, config: BridgeConfiguration): Promise<void>;
|
|
5
|
+
export declare function validateChainIds(sourceChainId: string, destinationChainId: string, config: BridgeConfiguration): Promise<void>;
|
|
6
|
+
export declare function validateBridgeReqArgs(req: BridgeBundledTxRequest, config: BridgeConfiguration): Promise<void>;
|
|
7
|
+
export declare function validateGetFee(req: BridgeFeeRequest, config: BridgeConfiguration): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|