@instadapp/avocado-base 0.0.0-dev.aceef3f → 0.0.0-dev.b0ffe91

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 (84) hide show
  1. package/abi/forwarder.json +1253 -149
  2. package/abi/multisigForwarder.json +697 -0
  3. package/app.vue +7 -0
  4. package/assets/images/icons/arrow-left.svg +5 -0
  5. package/assets/images/icons/arrow-right.svg +5 -0
  6. package/assets/images/icons/avocado.svg +4 -0
  7. package/assets/images/icons/bridge-2.svg +3 -0
  8. package/assets/images/icons/bridge.svg +7 -0
  9. package/assets/images/icons/calendar.svg +8 -0
  10. package/assets/images/icons/change-threshold.svg +4 -0
  11. package/assets/images/icons/check-circle.svg +4 -0
  12. package/assets/images/icons/chevron-down.svg +4 -0
  13. package/assets/images/icons/clipboard.svg +7 -0
  14. package/assets/images/icons/clock-circle.svg +5 -0
  15. package/assets/images/icons/copy.svg +5 -0
  16. package/assets/images/icons/cross-transfer.svg +7 -0
  17. package/assets/images/icons/dapp.svg +4 -0
  18. package/assets/images/icons/deploy.svg +12 -0
  19. package/assets/images/icons/error-circle.svg +6 -0
  20. package/assets/images/icons/exclamation-circle.svg +13 -0
  21. package/assets/images/icons/exclamation-octagon.svg +13 -0
  22. package/assets/images/icons/exclamation-triangle.svg +5 -0
  23. package/assets/images/icons/external-link.svg +6 -0
  24. package/assets/images/icons/eye.svg +4 -0
  25. package/assets/images/icons/flowers.svg +8 -0
  26. package/assets/images/icons/gas-emoji.svg +193 -0
  27. package/assets/images/icons/gas.svg +14 -0
  28. package/assets/images/icons/gift.svg +153 -0
  29. package/assets/images/icons/globe.svg +110 -0
  30. package/assets/images/icons/hamburger.svg +6 -0
  31. package/assets/images/icons/hammer.svg +5 -0
  32. package/assets/images/icons/info-2.svg +12 -0
  33. package/assets/images/icons/instadapp-pro.svg +4 -0
  34. package/assets/images/icons/logout.svg +3 -0
  35. package/assets/images/icons/moon.svg +3 -0
  36. package/assets/images/icons/multi-send.svg +7 -0
  37. package/assets/images/icons/network.svg +13 -0
  38. package/assets/images/icons/options.svg +5 -0
  39. package/assets/images/icons/permit-sign.svg +11 -0
  40. package/assets/images/icons/plus-circle.svg +6 -0
  41. package/assets/images/icons/plus.svg +5 -0
  42. package/assets/images/icons/power-off-bg.svg +24 -0
  43. package/assets/images/icons/power-off.svg +19 -0
  44. package/assets/images/icons/power-on.svg +19 -0
  45. package/assets/images/icons/qr.svg +20 -0
  46. package/assets/images/icons/question-circle.svg +14 -0
  47. package/assets/images/icons/refresh.svg +6 -0
  48. package/assets/images/icons/reject-proposal.svg +6 -0
  49. package/assets/images/icons/search.svg +12 -0
  50. package/assets/images/icons/sun.svg +3 -0
  51. package/assets/images/icons/transfer.svg +5 -0
  52. package/assets/images/icons/trash-2.svg +8 -0
  53. package/assets/images/icons/upgrade.svg +4 -0
  54. package/assets/images/icons/wave.svg +214 -0
  55. package/assets/images/icons/x.svg +5 -0
  56. package/components/ActionLogo.vue +40 -0
  57. package/components/ActionMetadata.vue +78 -0
  58. package/components/AuthorityAvatar.vue +38 -0
  59. package/components/ChainLogo.vue +14 -416
  60. package/components/CopyClipboard.vue +64 -0
  61. package/components/metadata/Bridge.vue +59 -0
  62. package/components/metadata/CrossTransfer.vue +79 -0
  63. package/components/metadata/GasTopup.vue +39 -0
  64. package/components/metadata/Permit2.vue +42 -0
  65. package/components/metadata/Signers.vue +63 -0
  66. package/components/metadata/Swap.vue +74 -0
  67. package/components/metadata/Transfer.vue +50 -0
  68. package/components.d.ts +13 -0
  69. package/contracts/Forwarder.ts +856 -2
  70. package/contracts/MultisigForwarder.ts +859 -0
  71. package/contracts/factories/Forwarder__factory.ts +816 -16
  72. package/contracts/factories/MultisigForwarder__factory.ts +721 -0
  73. package/contracts/factories/index.ts +1 -0
  74. package/contracts/index.ts +2 -0
  75. package/nuxt.config.ts +17 -1
  76. package/package.json +9 -4
  77. package/utils/avocado.ts +2 -0
  78. package/utils/bignumber.ts +20 -0
  79. package/utils/formatter.ts +49 -6
  80. package/utils/helper.ts +8 -0
  81. package/utils/metadata.ts +381 -134
  82. package/utils/network.ts +237 -91
  83. package/utils/services.ts +21 -0
  84. package/utils/utils.d.ts +124 -80
package/utils/network.ts CHANGED
@@ -1,33 +1,34 @@
1
1
  import { ethers } from "ethers";
2
+ import {
3
+ AVO_PROD_CHAIN_NAME,
4
+ AVO_PROD_CHAIN_ID,
5
+ AVO_PROD_RPC_URL,
6
+ AVO_PROD_EXPLORER_URL,
7
+ AVO_STAGING_CHAIN_NAME,
8
+ AVO_STAGING_CHAIN_ID,
9
+ AVO_STAGING_RPC_URL,
10
+ AVO_STAGING_EXPLORER_URL,
11
+ } from "./avocado";
2
12
 
3
- export const bridgeDisabledNetworks = [1101];
13
+ export const bridgeDisabledNetworks = [];
14
+
15
+ export const networksSimulationNotSupported = [1313161554, 1101];
4
16
 
5
17
  export const networks: Network[] = [
6
- {
7
- name: "Mainnet",
8
- debankName: "eth",
9
- ankrName: "eth",
10
- chainId: 1,
11
- params: {
12
- 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
- nativeCurrency: {
20
- name: "Ethereum",
21
- symbol: "ETH",
22
- decimals: 18,
23
- },
24
- },
25
- },
26
18
  {
27
19
  name: "Polygon",
28
20
  debankName: "matic",
29
21
  ankrName: "polygon",
22
+ zerionName: "polygon",
23
+ color: "#7A4ADD",
30
24
  chainId: 137,
25
+ balanceResolverAddress: "0x58632D23120b20650262b8A629a14e4F4043E0D9",
26
+ usdcAddress: "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
27
+ explorerUrl: "https://polygonscan.com",
28
+ apiURL: "https://api.polygonscan.com",
29
+ get serverRpcUrl() {
30
+ return process.env?.POLYGON_RPC_URL || this.params.rpcUrls[0];
31
+ },
31
32
  params: {
32
33
  chainName: "Matic(Polygon) Mainnet",
33
34
  nativeCurrency: {
@@ -35,20 +36,23 @@ export const networks: Network[] = [
35
36
  symbol: "MATIC",
36
37
  decimals: 18,
37
38
  },
38
- balanceResolverAddress: "0x58632D23120b20650262b8A629a14e4F4043E0D9",
39
- usdcAddress: "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
40
39
  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
40
  },
46
41
  },
47
42
  {
48
43
  name: "Arbitrum",
49
44
  debankName: "arb",
50
45
  ankrName: "arbitrum",
46
+ zerionName: "arbitrum",
47
+ color: "#2D374B",
51
48
  chainId: 42161,
49
+ usdcAddress: "0xff970a61a04b1ca14834a43f5de4533ebddb5cc8",
50
+ balanceResolverAddress: "0xca5f37e6D8bB24c5A7958d5eccE7Bd9Aacc944f2",
51
+ explorerUrl: "https://arbiscan.io",
52
+ apiURL: "https://api.arbiscan.io",
53
+ get serverRpcUrl() {
54
+ return process.env?.ARBITRUM_RPC_URL || this.params.rpcUrls[0];
55
+ },
52
56
  params: {
53
57
  chainName: "Arbitrum One",
54
58
  nativeCurrency: {
@@ -56,20 +60,68 @@ export const networks: Network[] = [
56
60
  symbol: "ETH",
57
61
  decimals: 18,
58
62
  },
59
- usdcAddress: "0xff970a61a04b1ca14834a43f5de4533ebddb5cc8",
60
- balanceResolverAddress: "0xca5f37e6D8bB24c5A7958d5eccE7Bd9Aacc944f2",
61
- get serverRpcUrl() {
62
- return process.env?.ARBITRUM_RPC_URL || this.rpcUrls[0];
63
- },
64
63
  rpcUrls: ["https://arb1.arbitrum.io/rpc"],
65
- explorerUrl: "https://arbiscan.io",
64
+ },
65
+ },
66
+ {
67
+ name: "Ethereum",
68
+ debankName: "eth",
69
+ ankrName: "eth",
70
+ zerionName: "ethereum",
71
+ chainId: 1,
72
+ explorerUrl: "https://etherscan.io",
73
+ apiURL: "https://api.etherscan.io",
74
+ color: "#5D5FEF",
75
+ get serverRpcUrl() {
76
+ return process.env?.MAINNET_RPC_URL || this.params.rpcUrls[0];
77
+ },
78
+ balanceResolverAddress: "0x5b7D61b389D12e1f5873d0cCEe7E675915AB5F43",
79
+ usdcAddress: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
80
+ params: {
81
+ rpcUrls: ["https://rpc.ankr.com/eth"],
82
+ nativeCurrency: {
83
+ name: "Ethereum",
84
+ symbol: "ETH",
85
+ decimals: 18,
86
+ },
87
+ },
88
+ },
89
+ {
90
+ name: "Base",
91
+ chainId: 8453,
92
+ color: "#1E2024",
93
+ ankrName: "base",
94
+ explorerUrl: "https://basescan.org",
95
+ apiURL: "https://api.basescan.org",
96
+ get serverRpcUrl() {
97
+ return process.env?.BASE_RPC_URL || this.params.rpcUrls[0];
98
+ },
99
+ usdcAddress: "0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA",
100
+ balanceResolverAddress: "0x23c8EAb8a4373dD16b0947Ebe8bf76Ff7A49d13C",
101
+ params: {
102
+ rpcUrls: ["https://rpc.ankr.com/base"],
103
+ chainName: "Base",
104
+ nativeCurrency: {
105
+ name: "Ethereum",
106
+ symbol: "ETH",
107
+ decimals: 18,
108
+ },
66
109
  },
67
110
  },
68
111
  {
69
112
  name: "Optimism",
70
113
  debankName: "op",
71
114
  ankrName: "optimism",
115
+ zerionName: "optimism",
116
+ color: "#FF0420",
72
117
  chainId: 10,
118
+ apiURL: "https://api-optimistic.etherscan.io",
119
+ usdcAddress: "0x7f5c764cbc14f9669b88837ca1490cca17c31607",
120
+ balanceResolverAddress: "0xca5f37e6D8bB24c5A7958d5eccE7Bd9Aacc944f2",
121
+ explorerUrl: "https://optimistic.etherscan.io",
122
+ get serverRpcUrl() {
123
+ return process.env?.OPTIMISM_RPC_URL || this.params.rpcUrls[0];
124
+ },
73
125
  params: {
74
126
  chainName: "Optimistic Ethereum",
75
127
  nativeCurrency: {
@@ -77,50 +129,48 @@ export const networks: Network[] = [
77
129
  symbol: "ETH",
78
130
  decimals: 18,
79
131
  },
80
- usdcAddress: "0x7f5c764cbc14f9669b88837ca1490cca17c31607",
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",
132
+ rpcUrls: ["https://rpc.ankr.com/optimism"],
87
133
  },
88
134
  },
89
135
  {
90
- name: "Avalanche",
91
- debankName: "avax",
92
- ankrName: "avalanche",
93
- chainId: 43114,
136
+ name: "Polygon zkEVM",
137
+ chainId: 1101,
138
+ color: "#8544f6",
139
+ ankrName: "polygon_zkevm",
140
+ explorerUrl: "https://zkevm.polygonscan.com",
141
+ apiURL: "https://api-zkevm.polygonscan.com",
142
+ balanceResolverAddress: "0x48D1Fa5Ee6691a1E0B45d2B515650997BEA27a01",
143
+ usdcAddress: "0xa8ce8aee21bc2a48a5ef670afcc9274c7bbbc035",
144
+ get serverRpcUrl() {
145
+ return process.env?.POLYGON_ZKEVM_RPC_URL || this.params.rpcUrls[0];
146
+ },
94
147
  params: {
95
- chainName: "Avalanche Network",
96
- get serverRpcUrl() {
97
- return process.env?.AVALANCHE_RPC_URL || this.rpcUrls[0];
98
- },
148
+ chainName: "polygon zkEVM",
149
+ rpcUrls: ["https://zkevm-rpc.com"],
99
150
  nativeCurrency: {
100
- name: "Avalanche",
101
- symbol: "AVAX",
151
+ name: "Ethereum",
152
+ symbol: "ETH",
102
153
  decimals: 18,
103
154
  },
104
- usdcAddress: "0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e",
105
- balanceResolverAddress: "0x63009f31D054E0ac9F321Cf0D642375236A4Bf1E",
106
- rpcUrls: ["https://api.avax.network/ext/bc/C/rpc"],
107
- explorerUrl: "https://snowtrace.io",
108
155
  },
109
156
  },
110
157
  {
111
158
  name: "BSC",
112
159
  debankName: "bsc",
113
160
  ankrName: "bsc",
161
+ zerionName: "binance-smart-chain",
162
+ color: "#F3BA2F",
114
163
  chainId: 56,
164
+ explorerUrl: "https://bscscan.com",
165
+ apiURL: "https://api.bscscan.com",
166
+ usdcAddress: "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d",
167
+ balanceResolverAddress: "0xb808cff38706e267067b0af427726aa099f69f89",
168
+ get serverRpcUrl() {
169
+ return process.env?.BSC_RPC_URL || this.params.rpcUrls[0];
170
+ },
115
171
  params: {
116
172
  chainName: "Binance Smart Chain",
117
- explorerUrl: "https://bscscan.com",
118
173
  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
174
  nativeCurrency: {
125
175
  name: "Binance Coin",
126
176
  symbol: "BNB",
@@ -128,20 +178,69 @@ export const networks: Network[] = [
128
178
  },
129
179
  },
130
180
  },
181
+ {
182
+ name: "Avalanche",
183
+ debankName: "avax",
184
+ ankrName: "avalanche",
185
+ zerionName: "avalanche",
186
+ color: "#EB5757",
187
+ chainId: 43114,
188
+ usdcAddress: "0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e",
189
+ balanceResolverAddress: "0x63009f31D054E0ac9F321Cf0D642375236A4Bf1E",
190
+ explorerUrl: "https://snowtrace.io",
191
+ apiURL: "https://api.snowtrace.io",
192
+ get serverRpcUrl() {
193
+ return process.env?.AVALANCHE_RPC_URL || this.params.rpcUrls[0];
194
+ },
195
+ params: {
196
+ chainName: "Avalanche Network",
197
+ nativeCurrency: {
198
+ name: "Avalanche",
199
+ symbol: "AVAX",
200
+ decimals: 18,
201
+ },
202
+ rpcUrls: ["https://rpc.ankr.com/avalanche"],
203
+ },
204
+ },
205
+ {
206
+ name: "Fantom",
207
+ chainId: 250,
208
+ zerionName: "fantom",
209
+ explorerUrl: "https://ftmscan.com",
210
+ ankrName: "fantom",
211
+ color: "#1969ff",
212
+ get serverRpcUrl() {
213
+ return process.env?.FANTOM_RPC_URL || this.params.rpcUrls[0];
214
+ },
215
+ usdcAddress: "0x04068da6c83afcfa0e13ba15a6696662335d5b75",
216
+ balanceResolverAddress: "0x929376c77a2fb8152375a089a4fccf84ff481479",
217
+ params: {
218
+ rpcUrls: ["https://rpc.ankr.com/fantom"],
219
+ chainName: "Fantom",
220
+ nativeCurrency: {
221
+ name: "Fantom",
222
+ symbol: "FTM",
223
+ decimals: 18,
224
+ },
225
+ },
226
+ },
131
227
  {
132
228
  name: "Gnosis",
133
229
  debankName: "xdai",
230
+ zerionName: "xdai",
231
+ color: "#04795C",
134
232
  ankrName: "gnosis",
135
233
  chainId: 100,
234
+ balanceResolverAddress: "0xfaa244e276b1597f663975ed007ee4ff70d27849",
235
+ explorerUrl: "https://gnosisscan.io",
236
+ apiURL: "https://api.gnosisscan.io",
237
+ usdcAddress: "0xddafbb505ad214d7b80b1f830fccc89b60fb7a83",
238
+ get serverRpcUrl() {
239
+ return process.env?.GNOSIS_RPC_URL || this.params.rpcUrls[0];
240
+ },
136
241
  params: {
137
242
  chainName: "Gnosis Safe",
138
- explorerUrl: "https://gnosisscan.io",
139
243
  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
244
  nativeCurrency: {
146
245
  name: "xdaistable",
147
246
  symbol: "xDAI",
@@ -150,21 +249,44 @@ export const networks: Network[] = [
150
249
  },
151
250
  },
152
251
  {
153
- name: "Polygon zkEVM",
154
- chainId: 1101,
252
+ name: "Aurora",
253
+ chainId: 1313161554,
254
+ zerionName: "aurora",
255
+ color: "#78d64b",
256
+ explorerUrl: "https://explorer.mainnet.aurora.dev",
257
+ get serverRpcUrl() {
258
+ return process.env?.AURORA_RPC_URL || this.params.rpcUrls[0];
259
+ },
260
+ usdcAddress: "0xB12BFcA5A55806AaF64E99521918A4bf0fC40802",
261
+ balanceResolverAddress: "0xdF19Da523DA64bBE82eE0E4DFf00d676A8386474",
155
262
  params: {
156
- chainName: "polygon zkEVM",
157
- explorerUrl: "https://zkevm.polygonscan.com",
158
- rpcUrls: ["https://rpc.ankr.com/polygon_zkevm"],
159
- get serverRpcUrl() {
160
- return process.env?.POLYGON_ZKEVM_RPC_URL || this.rpcUrls[0];
263
+ rpcUrls: ["https://mainnet.aurora.dev"],
264
+ chainName: "Aurora",
265
+ nativeCurrency: {
266
+ decimals: 18,
267
+ name: "Aurora ETH",
268
+ symbol: "AETH",
161
269
  },
162
- balanceResolverAddress: "0x48D1Fa5Ee6691a1E0B45d2B515650997BEA27a01",
163
- usdcAddress: "0xa8ce8aee21bc2a48a5ef670afcc9274c7bbbc035",
270
+ },
271
+ },
272
+ {
273
+ name: "Fuse",
274
+ chainId: 122,
275
+ zerionName: "fuse",
276
+ color: "#78d64b",
277
+ explorerUrl: "https://explorer.fuse.io",
278
+ get serverRpcUrl() {
279
+ return process.env?.FUSE_RPC_URL || this.params.rpcUrls[0];
280
+ },
281
+ usdcAddress: "",
282
+ balanceResolverAddress: "0xdF19Da523DA64bBE82eE0E4DFf00d676A8386474",
283
+ params: {
284
+ rpcUrls: ["https://fuse-mainnet.chainstacklabs.com"],
285
+ chainName: "Fuse",
164
286
  nativeCurrency: {
165
- name: "Ethereum",
166
- symbol: "ETH",
167
287
  decimals: 18,
288
+ name: "Fuse",
289
+ symbol: "fuse",
168
290
  },
169
291
  },
170
292
  },
@@ -172,6 +294,11 @@ export const networks: Network[] = [
172
294
  name: AVO_PROD_CHAIN_NAME,
173
295
  chainId: AVO_PROD_CHAIN_ID,
174
296
  isAvocado: true,
297
+ balanceResolverAddress: "",
298
+ color: "#16A34A",
299
+ usdcAddress: "",
300
+ serverRpcUrl: AVO_PROD_RPC_URL,
301
+ explorerUrl: AVO_PROD_EXPLORER_URL,
175
302
  params: {
176
303
  chainName: AVO_PROD_CHAIN_NAME,
177
304
  nativeCurrency: {
@@ -180,17 +307,18 @@ export const networks: Network[] = [
180
307
  decimals: 18,
181
308
  },
182
309
  iconUrls: ["https://avocado.instadapp.io/logo.svg"],
183
- balanceResolverAddress: "",
184
- usdcAddress: "",
185
- serverRpcUrl: AVO_PROD_RPC_URL,
186
310
  rpcUrls: [AVO_PROD_RPC_URL],
187
- explorerUrl: AVO_PROD_EXPLORER_URL,
188
311
  },
189
312
  },
190
313
  {
191
314
  name: AVO_STAGING_CHAIN_NAME,
192
315
  chainId: AVO_STAGING_CHAIN_ID,
316
+ serverRpcUrl: AVO_STAGING_RPC_URL,
317
+ color: "#16A34A",
318
+ explorerUrl: AVO_STAGING_EXPLORER_URL,
193
319
  isAvocado: true,
320
+ balanceResolverAddress: "",
321
+ usdcAddress: "",
194
322
  params: {
195
323
  chainName: AVO_STAGING_CHAIN_NAME,
196
324
  nativeCurrency: {
@@ -198,16 +326,31 @@ export const networks: Network[] = [
198
326
  symbol: "USDC",
199
327
  decimals: 18,
200
328
  },
201
- serverRpcUrl: AVO_STAGING_RPC_URL,
202
- balanceResolverAddress: "",
203
- usdcAddress: "",
204
329
  iconUrls: ["https://avocado.instadapp.io/logo.svg"],
205
330
  rpcUrls: [AVO_STAGING_RPC_URL],
206
- explorerUrl: AVO_STAGING_EXPLORER_URL,
207
331
  },
208
332
  },
209
333
  ];
210
334
 
335
+ export const chainUsdcAddresses = [
336
+ { chainId: 1, address: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48" },
337
+ { chainId: 10, address: "0x7f5c764cbc14f9669b88837ca1490cca17c31607" },
338
+ { chainId: 56, address: "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d" },
339
+ { chainId: 100, address: "0xddafbb505ad214d7b80b1f830fccc89b60fb7a83" },
340
+ { chainId: 137, address: "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174" },
341
+ { chainId: 250, address: "0x04068da6c83afcfa0e13ba15a6696662335d5b75" },
342
+ { chainId: 42161, address: "0xff970a61a04b1ca14834a43f5de4533ebddb5cc8" },
343
+ { chainId: 42161, address: "0xaf88d065e77c8cc2239327c5edb3a432268e5831" },
344
+ { chainId: 43114, address: "0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e" },
345
+ { chainId: 43114, address: "0xa7d7079b0fead91f3e65f86e8915cb59c1a4c664" },
346
+ { chainId: 1101, address: "0xa8ce8aee21bc2a48a5ef670afcc9274c7bbbc035" },
347
+ {
348
+ chainId: 1313161554,
349
+ address: "0xB12BFcA5A55806AaF64E99521918A4bf0fC40802",
350
+ },
351
+ { chainId: 8453, address: "0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA" },
352
+ ];
353
+
211
354
  export const getNetworkByChainId = (
212
355
  chainId: ChainId | number | string
213
356
  ): Network => {
@@ -235,14 +378,17 @@ export const RPCMap = networks.reduce((acc, network) => {
235
378
 
236
379
  export const networkIds = networks.map((network) => network.chainId);
237
380
 
238
- const rpcInstances: Record<string, ethers.providers.JsonRpcProvider> = {};
239
- const serverRpcInstances: Record<string, ethers.providers.JsonRpcProvider> = {};
381
+ const rpcInstances: Record<string, ethers.providers.StaticJsonRpcProvider> = {};
382
+ const serverRpcInstances: Record<
383
+ string,
384
+ ethers.providers.StaticJsonRpcProvider
385
+ > = {};
240
386
 
241
387
  export const getServerRpcProvider = (chainId: number | string) => {
242
388
  if (!rpcInstances[chainId]) {
243
389
  const network = networks.find((n) => n.chainId == chainId);
244
- serverRpcInstances[chainId] = new ethers.providers.JsonRpcProvider(
245
- network?.params.serverRpcUrl
390
+ serverRpcInstances[chainId] = new ethers.providers.StaticJsonRpcProvider(
391
+ network?.serverRpcUrl
246
392
  );
247
393
  }
248
394
 
@@ -251,7 +397,7 @@ export const getServerRpcProvider = (chainId: number | string) => {
251
397
 
252
398
  export const getRpcProvider = (chainId: number | string) => {
253
399
  if (!rpcInstances[chainId]) {
254
- rpcInstances[chainId] = new ethers.providers.JsonRpcProvider(
400
+ rpcInstances[chainId] = new ethers.providers.StaticJsonRpcProvider(
255
401
  getRpcURLByChainId(Number(chainId))
256
402
  );
257
403
  }
@@ -264,5 +410,5 @@ export const getExplorerUrl = (
264
410
  suffix: `/${string}` = "/"
265
411
  ) => {
266
412
  const network = getNetworkByChainId(chainId);
267
- return `${network.params.explorerUrl}${suffix}`;
413
+ return `${network.explorerUrl}${suffix}`;
268
414
  };
@@ -0,0 +1,21 @@
1
+ export const fetchTokenByAddress = async (
2
+ address: string,
3
+ chainId: string | number,
4
+ tokens?: ITokenPrice[]
5
+ ) => {
6
+ if (!address || !chainId) return null;
7
+
8
+ if (tokens?.length) {
9
+ const token = tokens.find((token) => token.address?.toLocaleLowerCase() === address?.toLocaleLowerCase() && token.chain_id == chainId);
10
+ if (token) return token;
11
+ }
12
+
13
+ const [token] = (await $fetch(`${blockQueryURL}/${chainId}/tokens`, {
14
+ params: {
15
+ sparkline: false,
16
+ "addresses[]": [address],
17
+ },
18
+ })) as ITokenPrice[];
19
+
20
+ return token;
21
+ };
package/utils/utils.d.ts CHANGED
@@ -1,88 +1,132 @@
1
- type ChainId = 1 | 137 | 42161 | 10 | 56 | 43114 | 100 | 1101 | 634 | 63400;
2
-
3
- type ISlackMessageType = "danger" | "error" | "success" | "banner";
4
-
5
- interface Network {
6
- name: string;
7
- debankName?: string;
8
- ankrName?: string;
9
- chainId: ChainId;
10
- isAvocado?: boolean;
11
- params: {
12
- chainName?: string;
13
- rpcUrls: string[];
1
+ declare global {
2
+ type ChainId =
3
+ | 1
4
+ | 137
5
+ | 42161
6
+ | 10
7
+ | 56
8
+ | 43114
9
+ | 100
10
+ | 1101
11
+ | 250
12
+ | 634
13
+ | 1313161554
14
+ | 8453
15
+ | 122
16
+ | 63400;
17
+
18
+ type ISlackMessageType = "danger" | "error" | "success" | "banner";
19
+
20
+ type MetadataTypes = keyof typeof MetadataEnums;
21
+
22
+ type PayloadFunction = (data: any, type: MetadataTypes) => any;
23
+
24
+ type IPayload = Record<MetadataTypes, PayloadFunction>;
25
+
26
+ interface Network {
27
+ name: string;
28
+ debankName?: string;
29
+ ankrName?: string;
30
+ zerionName?: string;
31
+ chainId: ChainId;
32
+ color: string;
33
+ isAvocado?: boolean;
14
34
  serverRpcUrl: string | undefined;
15
35
  balanceResolverAddress?: string;
16
36
  usdcAddress: string;
17
37
  explorerUrl: string;
18
- iconUrls?: string[];
19
- nativeCurrency?: {
20
- name: string;
21
- symbol: string;
22
- decimals: number;
38
+ apiURL?: string;
39
+ params: {
40
+ chainName?: string;
41
+ iconUrls?: string[];
42
+ rpcUrls: string[];
43
+ nativeCurrency?: {
44
+ name: string;
45
+ symbol: string;
46
+ decimals: number;
47
+ };
23
48
  };
49
+ }
50
+
51
+ type SignMetadataProps = {
52
+ token: string;
53
+ spender: string;
54
+ amount: string;
55
+ expiration: string;
24
56
  };
57
+
58
+ type DappMetadataProps = {
59
+ name: string;
60
+ url: string;
61
+ };
62
+
63
+ type SendMetadataProps = {
64
+ token: string;
65
+ amount: string;
66
+ receiver: string;
67
+ };
68
+
69
+ type CrossSendMetadataProps = {
70
+ fromToken: string;
71
+ toToken: string;
72
+ toChainId: string;
73
+ amount: string;
74
+ receiver: string;
75
+ };
76
+
77
+ type AuthMetadataProps = {
78
+ address: string;
79
+ chainId: string;
80
+ remove: boolean;
81
+ };
82
+
83
+ type UpgradeMetadataProps = {
84
+ version: string;
85
+ walletImpl: string;
86
+ };
87
+
88
+ type TopupMetadataProps = {
89
+ amount: string;
90
+ token: string;
91
+ onBehalf: string;
92
+ };
93
+
94
+ type BridgeMetadataProps = {
95
+ amount: string;
96
+ receiver: string;
97
+ fromToken: string;
98
+ toToken: string;
99
+ toChainId: string;
100
+ bridgeFee: string;
101
+ nativeToken: string;
102
+ };
103
+
104
+ type SwapMetadataProps = {
105
+ sellToken: string;
106
+ buyToken: string;
107
+ sellAmount: string;
108
+ buyAmount: string;
109
+ receiver: string;
110
+ protocol?: string;
111
+ };
112
+
113
+ type MetadataProps = {
114
+ type: MetadataTypes;
115
+ encodedData: string;
116
+ version?: string;
117
+ };
118
+
119
+ interface ITokenPrice {
120
+ address: string;
121
+ chain_id: string;
122
+ name: string;
123
+ symbol: string;
124
+ decimals: number;
125
+ logo_url: string;
126
+ price: string;
127
+ coingecko_id: string;
128
+ sparkline_price_7d: number[];
129
+ }
25
130
  }
26
131
 
27
- type SignMetadataProps = {
28
- token: string;
29
- spender: string;
30
- amount: string;
31
- expiration: string;
32
- };
33
-
34
- type DappMetadataProps = {
35
- name: string;
36
- url: string;
37
- };
38
-
39
- type SendMetadataProps = {
40
- token: string;
41
- amount: string;
42
- receiver: string;
43
- };
44
-
45
- type UpgradeMetadataProps = {
46
- version: string;
47
- walletImpl: string;
48
- };
49
-
50
- type TopupMetadataProps = {
51
- amount: string;
52
- token: string;
53
- onBehalf: string;
54
- };
55
-
56
- type BridgeMetadataProps = {
57
- amount: string;
58
- receiver: string;
59
- fromToken: string;
60
- toToken: string;
61
- toChainId: string;
62
- bridgeFee: string;
63
- nativeToken: string;
64
- };
65
-
66
- type SwapMetadataProps = {
67
- sellToken: string;
68
- buyToken: string;
69
- sellAmount: string;
70
- buyAmount: string;
71
- receiver: string;
72
- protocol?: string;
73
- };
74
-
75
- type MetadataProps = {
76
- type:
77
- | "transfer"
78
- | "bridge"
79
- | "swap"
80
- | "multi"
81
- | "gas-topup"
82
- | "upgrade"
83
- | "dapp"
84
- | "deploy"
85
- | "permit2";
86
- encodedData: string;
87
- version?: string;
88
- };
132
+ export {};