@instadapp/avocado-base 0.0.0-dev.aceef3f → 0.0.0-dev.b9e4c6c
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/abi/forwarder.json +1253 -149
- package/components/ChainLogo.vue +140 -0
- package/contracts/Forwarder.ts +856 -2
- package/contracts/factories/Forwarder__factory.ts +816 -16
- package/package.json +1 -1
- package/utils/formatter.ts +49 -6
- package/utils/metadata.ts +56 -2
- package/utils/network.ts +127 -64
- package/utils/utils.d.ts +30 -7
package/package.json
CHANGED
package/utils/formatter.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
export function formatPercent(
|
|
2
|
-
value
|
|
2
|
+
value?: number | string,
|
|
3
3
|
fractionDigits = 2,
|
|
4
4
|
maxValue = null
|
|
5
5
|
) {
|
|
6
|
-
if (isZero(value)) return "0.00%";
|
|
6
|
+
if (!value || isZero(value)) return "0.00%";
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
const valueAsNumber = toBN(value).toNumber();
|
|
9
|
+
|
|
10
|
+
if (maxValue && gt(times(valueAsNumber, "100"), maxValue))
|
|
11
|
+
return `>${maxValue}%`;
|
|
9
12
|
|
|
10
13
|
const formatter = new Intl.NumberFormat("en-US", {
|
|
11
14
|
style: "percent",
|
|
@@ -13,7 +16,7 @@ export function formatPercent(
|
|
|
13
16
|
maximumFractionDigits: fractionDigits,
|
|
14
17
|
});
|
|
15
18
|
|
|
16
|
-
return formatter.format(
|
|
19
|
+
return formatter.format(valueAsNumber);
|
|
17
20
|
}
|
|
18
21
|
|
|
19
22
|
export function shortenHash(hash: string, length: number = 4) {
|
|
@@ -42,10 +45,50 @@ export function signedNumber(numb: string | number) {
|
|
|
42
45
|
}).format(toBN(numb).toNumber());
|
|
43
46
|
}
|
|
44
47
|
|
|
45
|
-
|
|
48
|
+
function getFractionDigits(value: string | number) {
|
|
49
|
+
const absoluteValue = toBN(value).abs();
|
|
50
|
+
|
|
51
|
+
if (isZero(absoluteValue)) {
|
|
52
|
+
return 2;
|
|
53
|
+
} else if (lt(absoluteValue, 0.01)) {
|
|
54
|
+
return 6;
|
|
55
|
+
} else if (lt(absoluteValue, 1)) {
|
|
56
|
+
return 4;
|
|
57
|
+
} else if (lt(absoluteValue, 10000)) {
|
|
58
|
+
return 2;
|
|
59
|
+
} else {
|
|
60
|
+
return 0;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function formatDecimal(value: string | number, fractionDigits?: number) {
|
|
46
65
|
if (!value) {
|
|
47
66
|
value = "0";
|
|
48
67
|
}
|
|
68
|
+
if (lt(value, "0.0001") && gt(value, "0")) {
|
|
69
|
+
return "< 0.0001";
|
|
70
|
+
} else {
|
|
71
|
+
const num = toBN(value);
|
|
72
|
+
let decimals;
|
|
73
|
+
|
|
74
|
+
if (num.lt(1)) {
|
|
75
|
+
decimals = 8;
|
|
76
|
+
} else if (num.lt(10)) {
|
|
77
|
+
decimals = 6;
|
|
78
|
+
} else if (num.lt(100)) {
|
|
79
|
+
decimals = 4;
|
|
80
|
+
} else if (num.lt(1000)) {
|
|
81
|
+
decimals = 3;
|
|
82
|
+
} else if (num.lt(10000)) {
|
|
83
|
+
decimals = 2;
|
|
84
|
+
} else if (num.lt(100000)) {
|
|
85
|
+
decimals = 1;
|
|
86
|
+
} else {
|
|
87
|
+
decimals = 0;
|
|
88
|
+
}
|
|
49
89
|
|
|
50
|
-
|
|
90
|
+
const formattedNumber = num.toFixed(fractionDigits || decimals);
|
|
91
|
+
|
|
92
|
+
return toBN(formattedNumber).toFormat();
|
|
93
|
+
}
|
|
51
94
|
}
|
package/utils/metadata.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ethers, utils } from "ethers";
|
|
2
|
-
import { Forwarder__factory } from "
|
|
2
|
+
import { Forwarder__factory } from "../contracts";
|
|
3
3
|
|
|
4
4
|
const multiMetadataTypes = ["bytes[]"];
|
|
5
5
|
|
|
@@ -7,6 +7,13 @@ const metadataTypes = ["bytes32 type", "uint8 version", "bytes data"];
|
|
|
7
7
|
|
|
8
8
|
const actionMetadataTypes = {
|
|
9
9
|
transfer: ["address token", "uint256 amount", "address receiver"],
|
|
10
|
+
"cross-transfer": [
|
|
11
|
+
"address fromToken",
|
|
12
|
+
"address toToken",
|
|
13
|
+
"uint256 toChainId",
|
|
14
|
+
"uint256 amount",
|
|
15
|
+
"address receiver",
|
|
16
|
+
],
|
|
10
17
|
bridge: [
|
|
11
18
|
"uint256 amount",
|
|
12
19
|
"address receiver",
|
|
@@ -78,6 +85,29 @@ export const encodeTransferMetadata = (
|
|
|
78
85
|
return single ? encodeMultipleActions(data) : data;
|
|
79
86
|
};
|
|
80
87
|
|
|
88
|
+
export const encodeCrossTransferMetadata = (
|
|
89
|
+
params: CrossSendMetadataProps,
|
|
90
|
+
single = true
|
|
91
|
+
) => {
|
|
92
|
+
const encodedData = ethers.utils.defaultAbiCoder.encode(
|
|
93
|
+
actionMetadataTypes["cross-transfer"],
|
|
94
|
+
[
|
|
95
|
+
params.fromToken,
|
|
96
|
+
params.toToken,
|
|
97
|
+
params.toChainId,
|
|
98
|
+
params.amount,
|
|
99
|
+
params.receiver,
|
|
100
|
+
]
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
const data = encodeMetadata({
|
|
104
|
+
type: "cross-transfer",
|
|
105
|
+
encodedData,
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
return single ? encodeMultipleActions(data) : data;
|
|
109
|
+
};
|
|
110
|
+
|
|
81
111
|
export const encodeDeployMetadata = (single = true) => {
|
|
82
112
|
const data = encodeMetadata({
|
|
83
113
|
type: "deploy",
|
|
@@ -208,7 +238,7 @@ export const decodeMetadata = (data: string) => {
|
|
|
208
238
|
} else {
|
|
209
239
|
metadata = executeData.metadata_;
|
|
210
240
|
}
|
|
211
|
-
} else {
|
|
241
|
+
} else if (data.startsWith("0x14f80a8d")) {
|
|
212
242
|
const executeDataV2 = iface.decodeFunctionData("executeV2", data);
|
|
213
243
|
if (
|
|
214
244
|
executeDataV2.params_.metadata === "0x" ||
|
|
@@ -218,6 +248,16 @@ export const decodeMetadata = (data: string) => {
|
|
|
218
248
|
} else {
|
|
219
249
|
metadata = executeDataV2.params_.metadata;
|
|
220
250
|
}
|
|
251
|
+
} else {
|
|
252
|
+
const executeDataV3 = iface.decodeFunctionData("executeV3", data);
|
|
253
|
+
if (
|
|
254
|
+
executeDataV3.params_.metadata === "0x" ||
|
|
255
|
+
!executeDataV3.params_.metadata
|
|
256
|
+
) {
|
|
257
|
+
return null;
|
|
258
|
+
} else {
|
|
259
|
+
metadata = executeDataV3.params_.metadata;
|
|
260
|
+
}
|
|
221
261
|
}
|
|
222
262
|
|
|
223
263
|
const metadataArr = [];
|
|
@@ -302,6 +342,7 @@ export const decodeMetadata = (data: string) => {
|
|
|
302
342
|
payload = {
|
|
303
343
|
type,
|
|
304
344
|
};
|
|
345
|
+
break;
|
|
305
346
|
|
|
306
347
|
case "permit2":
|
|
307
348
|
payload = {
|
|
@@ -311,6 +352,19 @@ export const decodeMetadata = (data: string) => {
|
|
|
311
352
|
amount: toBN(decodedData.amount).toFixed(),
|
|
312
353
|
expiration: decodedData.expiration,
|
|
313
354
|
};
|
|
355
|
+
break;
|
|
356
|
+
|
|
357
|
+
case "cross-transfer":
|
|
358
|
+
payload = {
|
|
359
|
+
type,
|
|
360
|
+
fromToken: decodedData.fromToken,
|
|
361
|
+
toToken: decodedData.toToken,
|
|
362
|
+
toChainId: decodedData.toChainId
|
|
363
|
+
? decodedData.toChainId.toString()
|
|
364
|
+
: null,
|
|
365
|
+
amount: toBN(decodedData.amount).toFixed(),
|
|
366
|
+
receiver: decodedData.receiver,
|
|
367
|
+
};
|
|
314
368
|
|
|
315
369
|
break;
|
|
316
370
|
}
|
package/utils/network.ts
CHANGED
|
@@ -7,15 +7,17 @@ export const networks: Network[] = [
|
|
|
7
7
|
name: "Mainnet",
|
|
8
8
|
debankName: "eth",
|
|
9
9
|
ankrName: "eth",
|
|
10
|
+
zerionName: "ethereum",
|
|
10
11
|
chainId: 1,
|
|
12
|
+
explorerUrl: "https://etherscan.io",
|
|
13
|
+
color: "#5D5FEF",
|
|
14
|
+
get serverRpcUrl() {
|
|
15
|
+
return process.env?.MAINNET_RPC_URL || this.params.rpcUrls[0];
|
|
16
|
+
},
|
|
17
|
+
balanceResolverAddress: "0x5b7D61b389D12e1f5873d0cCEe7E675915AB5F43",
|
|
18
|
+
usdcAddress: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
|
|
11
19
|
params: {
|
|
12
20
|
rpcUrls: ["https://rpc.ankr.com/eth"],
|
|
13
|
-
explorerUrl: "https://etherscan.io",
|
|
14
|
-
get serverRpcUrl() {
|
|
15
|
-
return process.env?.MAINNET_RPC_URL || this.rpcUrls[0];
|
|
16
|
-
},
|
|
17
|
-
balanceResolverAddress: "0x5b7D61b389D12e1f5873d0cCEe7E675915AB5F43",
|
|
18
|
-
usdcAddress: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
|
|
19
21
|
nativeCurrency: {
|
|
20
22
|
name: "Ethereum",
|
|
21
23
|
symbol: "ETH",
|
|
@@ -27,7 +29,15 @@ export const networks: Network[] = [
|
|
|
27
29
|
name: "Polygon",
|
|
28
30
|
debankName: "matic",
|
|
29
31
|
ankrName: "polygon",
|
|
32
|
+
zerionName: "polygon",
|
|
33
|
+
color: "#7A4ADD",
|
|
30
34
|
chainId: 137,
|
|
35
|
+
balanceResolverAddress: "0x58632D23120b20650262b8A629a14e4F4043E0D9",
|
|
36
|
+
usdcAddress: "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
|
|
37
|
+
explorerUrl: "https://polygonscan.com",
|
|
38
|
+
get serverRpcUrl() {
|
|
39
|
+
return process.env?.POLYGON_RPC_URL || this.params.rpcUrls[0];
|
|
40
|
+
},
|
|
31
41
|
params: {
|
|
32
42
|
chainName: "Matic(Polygon) Mainnet",
|
|
33
43
|
nativeCurrency: {
|
|
@@ -35,20 +45,22 @@ export const networks: Network[] = [
|
|
|
35
45
|
symbol: "MATIC",
|
|
36
46
|
decimals: 18,
|
|
37
47
|
},
|
|
38
|
-
balanceResolverAddress: "0x58632D23120b20650262b8A629a14e4F4043E0D9",
|
|
39
|
-
usdcAddress: "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
|
|
40
48
|
rpcUrls: ["https://polygon-rpc.com"],
|
|
41
|
-
get serverRpcUrl() {
|
|
42
|
-
return process.env?.POLYGON_RPC_URL || this.rpcUrls[0];
|
|
43
|
-
},
|
|
44
|
-
explorerUrl: "https://polygonscan.com",
|
|
45
49
|
},
|
|
46
50
|
},
|
|
47
51
|
{
|
|
48
52
|
name: "Arbitrum",
|
|
49
53
|
debankName: "arb",
|
|
50
54
|
ankrName: "arbitrum",
|
|
55
|
+
zerionName: "arbitrum",
|
|
56
|
+
color: "#2D374B",
|
|
51
57
|
chainId: 42161,
|
|
58
|
+
usdcAddress: "0xff970a61a04b1ca14834a43f5de4533ebddb5cc8",
|
|
59
|
+
balanceResolverAddress: "0xca5f37e6D8bB24c5A7958d5eccE7Bd9Aacc944f2",
|
|
60
|
+
explorerUrl: "https://arbiscan.io",
|
|
61
|
+
get serverRpcUrl() {
|
|
62
|
+
return process.env?.ARBITRUM_RPC_URL || this.params.rpcUrls[0];
|
|
63
|
+
},
|
|
52
64
|
params: {
|
|
53
65
|
chainName: "Arbitrum One",
|
|
54
66
|
nativeCurrency: {
|
|
@@ -56,20 +68,22 @@ export const networks: Network[] = [
|
|
|
56
68
|
symbol: "ETH",
|
|
57
69
|
decimals: 18,
|
|
58
70
|
},
|
|
59
|
-
usdcAddress: "0xff970a61a04b1ca14834a43f5de4533ebddb5cc8",
|
|
60
|
-
balanceResolverAddress: "0xca5f37e6D8bB24c5A7958d5eccE7Bd9Aacc944f2",
|
|
61
|
-
get serverRpcUrl() {
|
|
62
|
-
return process.env?.ARBITRUM_RPC_URL || this.rpcUrls[0];
|
|
63
|
-
},
|
|
64
71
|
rpcUrls: ["https://arb1.arbitrum.io/rpc"],
|
|
65
|
-
explorerUrl: "https://arbiscan.io",
|
|
66
72
|
},
|
|
67
73
|
},
|
|
68
74
|
{
|
|
69
75
|
name: "Optimism",
|
|
70
76
|
debankName: "op",
|
|
71
77
|
ankrName: "optimism",
|
|
78
|
+
zerionName: "optimism",
|
|
79
|
+
color: "#FF0420",
|
|
72
80
|
chainId: 10,
|
|
81
|
+
usdcAddress: "0x7f5c764cbc14f9669b88837ca1490cca17c31607",
|
|
82
|
+
balanceResolverAddress: "0xca5f37e6D8bB24c5A7958d5eccE7Bd9Aacc944f2",
|
|
83
|
+
explorerUrl: "https://optimistic.etherscan.io",
|
|
84
|
+
get serverRpcUrl() {
|
|
85
|
+
return process.env?.OPTIMISM_RPC_URL || this.params.rpcUrls[0];
|
|
86
|
+
},
|
|
73
87
|
params: {
|
|
74
88
|
chainName: "Optimistic Ethereum",
|
|
75
89
|
nativeCurrency: {
|
|
@@ -77,50 +91,48 @@ export const networks: Network[] = [
|
|
|
77
91
|
symbol: "ETH",
|
|
78
92
|
decimals: 18,
|
|
79
93
|
},
|
|
80
|
-
|
|
81
|
-
balanceResolverAddress: "0xca5f37e6D8bB24c5A7958d5eccE7Bd9Aacc944f2",
|
|
82
|
-
get serverRpcUrl() {
|
|
83
|
-
return process.env?.OPTIMISM_RPC_URL || this.rpcUrls[0];
|
|
84
|
-
},
|
|
85
|
-
rpcUrls: ["https://mainnet.optimism.io"],
|
|
86
|
-
explorerUrl: "https://optimistic.etherscan.io",
|
|
94
|
+
rpcUrls: ["https://rpc.ankr.com/optimism"],
|
|
87
95
|
},
|
|
88
96
|
},
|
|
89
97
|
{
|
|
90
98
|
name: "Avalanche",
|
|
91
99
|
debankName: "avax",
|
|
92
100
|
ankrName: "avalanche",
|
|
101
|
+
zerionName: "avalanche",
|
|
102
|
+
color: "#EB5757",
|
|
93
103
|
chainId: 43114,
|
|
104
|
+
usdcAddress: "0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e",
|
|
105
|
+
balanceResolverAddress: "0x63009f31D054E0ac9F321Cf0D642375236A4Bf1E",
|
|
106
|
+
explorerUrl: "https://snowtrace.io",
|
|
107
|
+
get serverRpcUrl() {
|
|
108
|
+
return process.env?.AVALANCHE_RPC_URL || this.params.rpcUrls[0];
|
|
109
|
+
},
|
|
94
110
|
params: {
|
|
95
111
|
chainName: "Avalanche Network",
|
|
96
|
-
get serverRpcUrl() {
|
|
97
|
-
return process.env?.AVALANCHE_RPC_URL || this.rpcUrls[0];
|
|
98
|
-
},
|
|
99
112
|
nativeCurrency: {
|
|
100
113
|
name: "Avalanche",
|
|
101
114
|
symbol: "AVAX",
|
|
102
115
|
decimals: 18,
|
|
103
116
|
},
|
|
104
|
-
usdcAddress: "0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e",
|
|
105
|
-
balanceResolverAddress: "0x63009f31D054E0ac9F321Cf0D642375236A4Bf1E",
|
|
106
117
|
rpcUrls: ["https://api.avax.network/ext/bc/C/rpc"],
|
|
107
|
-
explorerUrl: "https://snowtrace.io",
|
|
108
118
|
},
|
|
109
119
|
},
|
|
110
120
|
{
|
|
111
121
|
name: "BSC",
|
|
112
122
|
debankName: "bsc",
|
|
113
123
|
ankrName: "bsc",
|
|
124
|
+
zerionName: "binance-smart-chain",
|
|
125
|
+
color: "#F3BA2F",
|
|
114
126
|
chainId: 56,
|
|
127
|
+
explorerUrl: "https://bscscan.com",
|
|
128
|
+
usdcAddress: "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d",
|
|
129
|
+
balanceResolverAddress: "0xb808cff38706e267067b0af427726aa099f69f89",
|
|
130
|
+
get serverRpcUrl() {
|
|
131
|
+
return process.env?.BSC_RPC_URL || this.params.rpcUrls[0];
|
|
132
|
+
},
|
|
115
133
|
params: {
|
|
116
134
|
chainName: "Binance Smart Chain",
|
|
117
|
-
explorerUrl: "https://bscscan.com",
|
|
118
135
|
rpcUrls: ["https://rpc.ankr.com/bsc"],
|
|
119
|
-
get serverRpcUrl() {
|
|
120
|
-
return process.env?.BSC_RPC_URL || this.rpcUrls[0];
|
|
121
|
-
},
|
|
122
|
-
usdcAddress: "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d",
|
|
123
|
-
balanceResolverAddress: "0xb808cff38706e267067b0af427726aa099f69f89",
|
|
124
136
|
nativeCurrency: {
|
|
125
137
|
name: "Binance Coin",
|
|
126
138
|
symbol: "BNB",
|
|
@@ -131,17 +143,18 @@ export const networks: Network[] = [
|
|
|
131
143
|
{
|
|
132
144
|
name: "Gnosis",
|
|
133
145
|
debankName: "xdai",
|
|
134
|
-
|
|
146
|
+
zerionName: "xdai",
|
|
147
|
+
color: "#04795C",
|
|
135
148
|
chainId: 100,
|
|
149
|
+
balanceResolverAddress: "0xfaa244e276b1597f663975ed007ee4ff70d27849",
|
|
150
|
+
explorerUrl: "https://gnosisscan.io",
|
|
151
|
+
usdcAddress: "0xddafbb505ad214d7b80b1f830fccc89b60fb7a83",
|
|
152
|
+
get serverRpcUrl() {
|
|
153
|
+
return process.env?.GNOSIS_RPC_URL || this.params.rpcUrls[0];
|
|
154
|
+
},
|
|
136
155
|
params: {
|
|
137
156
|
chainName: "Gnosis Safe",
|
|
138
|
-
explorerUrl: "https://gnosisscan.io",
|
|
139
157
|
rpcUrls: ["https://rpc.ankr.com/gnosis"],
|
|
140
|
-
get serverRpcUrl() {
|
|
141
|
-
return process.env?.GNOSIS_RPC_URL || this.rpcUrls[0];
|
|
142
|
-
},
|
|
143
|
-
balanceResolverAddress: "0xfaa244e276b1597f663975ed007ee4ff70d27849",
|
|
144
|
-
usdcAddress: "0xddafbb505ad214d7b80b1f830fccc89b60fb7a83",
|
|
145
158
|
nativeCurrency: {
|
|
146
159
|
name: "xdaistable",
|
|
147
160
|
symbol: "xDAI",
|
|
@@ -152,15 +165,17 @@ export const networks: Network[] = [
|
|
|
152
165
|
{
|
|
153
166
|
name: "Polygon zkEVM",
|
|
154
167
|
chainId: 1101,
|
|
168
|
+
color: "#8544f6",
|
|
169
|
+
explorerUrl: "https://zkevm.polygonscan.com",
|
|
170
|
+
balanceResolverAddress: "0x48D1Fa5Ee6691a1E0B45d2B515650997BEA27a01",
|
|
171
|
+
usdcAddress: "0xa8ce8aee21bc2a48a5ef670afcc9274c7bbbc035",
|
|
172
|
+
get serverRpcUrl() {
|
|
173
|
+
return process.env?.POLYGON_ZKEVM_RPC_URL || this.params.rpcUrls[0];
|
|
174
|
+
},
|
|
155
175
|
params: {
|
|
156
176
|
chainName: "polygon zkEVM",
|
|
157
|
-
explorerUrl: "https://zkevm.polygonscan.com",
|
|
158
177
|
rpcUrls: ["https://rpc.ankr.com/polygon_zkevm"],
|
|
159
|
-
|
|
160
|
-
return process.env?.POLYGON_ZKEVM_RPC_URL || this.rpcUrls[0];
|
|
161
|
-
},
|
|
162
|
-
balanceResolverAddress: "0x48D1Fa5Ee6691a1E0B45d2B515650997BEA27a01",
|
|
163
|
-
usdcAddress: "0xa8ce8aee21bc2a48a5ef670afcc9274c7bbbc035",
|
|
178
|
+
|
|
164
179
|
nativeCurrency: {
|
|
165
180
|
name: "Ethereum",
|
|
166
181
|
symbol: "ETH",
|
|
@@ -168,10 +183,58 @@ export const networks: Network[] = [
|
|
|
168
183
|
},
|
|
169
184
|
},
|
|
170
185
|
},
|
|
186
|
+
{
|
|
187
|
+
name: "Aurora",
|
|
188
|
+
chainId: 1313161554,
|
|
189
|
+
zerionName: "aurora",
|
|
190
|
+
color: "#78d64b",
|
|
191
|
+
explorerUrl: "https://explorer.mainnet.aurora.dev",
|
|
192
|
+
get serverRpcUrl() {
|
|
193
|
+
return process.env?.AURORA_RPC_URL || this.params.rpcUrls[0];
|
|
194
|
+
},
|
|
195
|
+
usdcAddress: "0xB12BFcA5A55806AaF64E99521918A4bf0fC40802",
|
|
196
|
+
balanceResolverAddress: "0xdF19Da523DA64bBE82eE0E4DFf00d676A8386474",
|
|
197
|
+
params: {
|
|
198
|
+
rpcUrls: ["https://mainnet.aurora.dev"],
|
|
199
|
+
chainName: "Aurora",
|
|
200
|
+
nativeCurrency: {
|
|
201
|
+
decimals: 18,
|
|
202
|
+
name: "Aurora ETH",
|
|
203
|
+
symbol: "AETH",
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
name: "Fantom",
|
|
209
|
+
chainId: 250,
|
|
210
|
+
zerionName: "fantom",
|
|
211
|
+
explorerUrl: "https://ftmscan.com",
|
|
212
|
+
ankrName: "fantom",
|
|
213
|
+
color: "#1969ff",
|
|
214
|
+
get serverRpcUrl() {
|
|
215
|
+
return process.env?.FANTOM_RPC_URL || this.params.rpcUrls[0];
|
|
216
|
+
},
|
|
217
|
+
usdcAddress: "0x04068da6c83afcfa0e13ba15a6696662335d5b75",
|
|
218
|
+
balanceResolverAddress: "0x929376c77a2fb8152375a089a4fccf84ff481479",
|
|
219
|
+
params: {
|
|
220
|
+
rpcUrls: ["https://rpc.ankr.com/fantom"],
|
|
221
|
+
chainName: "Fantom",
|
|
222
|
+
nativeCurrency: {
|
|
223
|
+
name: "Fantom",
|
|
224
|
+
symbol: "FTM",
|
|
225
|
+
decimals: 18,
|
|
226
|
+
},
|
|
227
|
+
},
|
|
228
|
+
},
|
|
171
229
|
{
|
|
172
230
|
name: AVO_PROD_CHAIN_NAME,
|
|
173
231
|
chainId: AVO_PROD_CHAIN_ID,
|
|
174
232
|
isAvocado: true,
|
|
233
|
+
balanceResolverAddress: "",
|
|
234
|
+
color: "#16A34A",
|
|
235
|
+
usdcAddress: "",
|
|
236
|
+
serverRpcUrl: AVO_PROD_RPC_URL,
|
|
237
|
+
explorerUrl: AVO_PROD_EXPLORER_URL,
|
|
175
238
|
params: {
|
|
176
239
|
chainName: AVO_PROD_CHAIN_NAME,
|
|
177
240
|
nativeCurrency: {
|
|
@@ -180,17 +243,18 @@ export const networks: Network[] = [
|
|
|
180
243
|
decimals: 18,
|
|
181
244
|
},
|
|
182
245
|
iconUrls: ["https://avocado.instadapp.io/logo.svg"],
|
|
183
|
-
balanceResolverAddress: "",
|
|
184
|
-
usdcAddress: "",
|
|
185
|
-
serverRpcUrl: AVO_PROD_RPC_URL,
|
|
186
246
|
rpcUrls: [AVO_PROD_RPC_URL],
|
|
187
|
-
explorerUrl: AVO_PROD_EXPLORER_URL,
|
|
188
247
|
},
|
|
189
248
|
},
|
|
190
249
|
{
|
|
191
250
|
name: AVO_STAGING_CHAIN_NAME,
|
|
192
251
|
chainId: AVO_STAGING_CHAIN_ID,
|
|
252
|
+
serverRpcUrl: AVO_STAGING_RPC_URL,
|
|
253
|
+
color: "#16A34A",
|
|
254
|
+
explorerUrl: AVO_STAGING_EXPLORER_URL,
|
|
193
255
|
isAvocado: true,
|
|
256
|
+
balanceResolverAddress: "",
|
|
257
|
+
usdcAddress: "",
|
|
194
258
|
params: {
|
|
195
259
|
chainName: AVO_STAGING_CHAIN_NAME,
|
|
196
260
|
nativeCurrency: {
|
|
@@ -198,12 +262,8 @@ export const networks: Network[] = [
|
|
|
198
262
|
symbol: "USDC",
|
|
199
263
|
decimals: 18,
|
|
200
264
|
},
|
|
201
|
-
serverRpcUrl: AVO_STAGING_RPC_URL,
|
|
202
|
-
balanceResolverAddress: "",
|
|
203
|
-
usdcAddress: "",
|
|
204
265
|
iconUrls: ["https://avocado.instadapp.io/logo.svg"],
|
|
205
266
|
rpcUrls: [AVO_STAGING_RPC_URL],
|
|
206
|
-
explorerUrl: AVO_STAGING_EXPLORER_URL,
|
|
207
267
|
},
|
|
208
268
|
},
|
|
209
269
|
];
|
|
@@ -235,14 +295,17 @@ export const RPCMap = networks.reduce((acc, network) => {
|
|
|
235
295
|
|
|
236
296
|
export const networkIds = networks.map((network) => network.chainId);
|
|
237
297
|
|
|
238
|
-
const rpcInstances: Record<string, ethers.providers.
|
|
239
|
-
const serverRpcInstances: Record<
|
|
298
|
+
const rpcInstances: Record<string, ethers.providers.StaticJsonRpcProvider> = {};
|
|
299
|
+
const serverRpcInstances: Record<
|
|
300
|
+
string,
|
|
301
|
+
ethers.providers.StaticJsonRpcProvider
|
|
302
|
+
> = {};
|
|
240
303
|
|
|
241
304
|
export const getServerRpcProvider = (chainId: number | string) => {
|
|
242
305
|
if (!rpcInstances[chainId]) {
|
|
243
306
|
const network = networks.find((n) => n.chainId == chainId);
|
|
244
|
-
serverRpcInstances[chainId] = new ethers.providers.
|
|
245
|
-
network?.
|
|
307
|
+
serverRpcInstances[chainId] = new ethers.providers.StaticJsonRpcProvider(
|
|
308
|
+
network?.serverRpcUrl
|
|
246
309
|
);
|
|
247
310
|
}
|
|
248
311
|
|
|
@@ -251,7 +314,7 @@ export const getServerRpcProvider = (chainId: number | string) => {
|
|
|
251
314
|
|
|
252
315
|
export const getRpcProvider = (chainId: number | string) => {
|
|
253
316
|
if (!rpcInstances[chainId]) {
|
|
254
|
-
rpcInstances[chainId] = new ethers.providers.
|
|
317
|
+
rpcInstances[chainId] = new ethers.providers.StaticJsonRpcProvider(
|
|
255
318
|
getRpcURLByChainId(Number(chainId))
|
|
256
319
|
);
|
|
257
320
|
}
|
|
@@ -264,5 +327,5 @@ export const getExplorerUrl = (
|
|
|
264
327
|
suffix: `/${string}` = "/"
|
|
265
328
|
) => {
|
|
266
329
|
const network = getNetworkByChainId(chainId);
|
|
267
|
-
return `${network.
|
|
330
|
+
return `${network.explorerUrl}${suffix}`;
|
|
268
331
|
};
|
package/utils/utils.d.ts
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
|
-
type ChainId =
|
|
1
|
+
type ChainId =
|
|
2
|
+
| 1
|
|
3
|
+
| 137
|
|
4
|
+
| 42161
|
|
5
|
+
| 10
|
|
6
|
+
| 56
|
|
7
|
+
| 43114
|
|
8
|
+
| 100
|
|
9
|
+
| 1101
|
|
10
|
+
| 250
|
|
11
|
+
| 634
|
|
12
|
+
| 1313161554
|
|
13
|
+
| 63400;
|
|
2
14
|
|
|
3
15
|
type ISlackMessageType = "danger" | "error" | "success" | "banner";
|
|
4
16
|
|
|
@@ -6,16 +18,18 @@ interface Network {
|
|
|
6
18
|
name: string;
|
|
7
19
|
debankName?: string;
|
|
8
20
|
ankrName?: string;
|
|
21
|
+
zerionName?: string;
|
|
9
22
|
chainId: ChainId;
|
|
23
|
+
color: string;
|
|
10
24
|
isAvocado?: boolean;
|
|
25
|
+
serverRpcUrl: string | undefined;
|
|
26
|
+
balanceResolverAddress?: string;
|
|
27
|
+
usdcAddress: string;
|
|
28
|
+
explorerUrl: string;
|
|
11
29
|
params: {
|
|
12
30
|
chainName?: string;
|
|
13
|
-
rpcUrls: string[];
|
|
14
|
-
serverRpcUrl: string | undefined;
|
|
15
|
-
balanceResolverAddress?: string;
|
|
16
|
-
usdcAddress: string;
|
|
17
|
-
explorerUrl: string;
|
|
18
31
|
iconUrls?: string[];
|
|
32
|
+
rpcUrls: string[];
|
|
19
33
|
nativeCurrency?: {
|
|
20
34
|
name: string;
|
|
21
35
|
symbol: string;
|
|
@@ -42,6 +56,14 @@ type SendMetadataProps = {
|
|
|
42
56
|
receiver: string;
|
|
43
57
|
};
|
|
44
58
|
|
|
59
|
+
type CrossSendMetadataProps = {
|
|
60
|
+
fromToken: string;
|
|
61
|
+
toToken: string;
|
|
62
|
+
toChainId: string;
|
|
63
|
+
amount: string;
|
|
64
|
+
receiver: string;
|
|
65
|
+
};
|
|
66
|
+
|
|
45
67
|
type UpgradeMetadataProps = {
|
|
46
68
|
version: string;
|
|
47
69
|
walletImpl: string;
|
|
@@ -82,7 +104,8 @@ type MetadataProps = {
|
|
|
82
104
|
| "upgrade"
|
|
83
105
|
| "dapp"
|
|
84
106
|
| "deploy"
|
|
85
|
-
| "permit2"
|
|
107
|
+
| "permit2"
|
|
108
|
+
| "cross-transfer";
|
|
86
109
|
encodedData: string;
|
|
87
110
|
version?: string;
|
|
88
111
|
};
|