@instadapp/avocado-base 0.0.0-dev.9e8d2fb → 0.0.0-dev.a08c651

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 (77) hide show
  1. package/abi/forwarder.json +1253 -149
  2. package/app.vue +27 -0
  3. package/assets/images/icons/arrow-left.svg +5 -0
  4. package/assets/images/icons/arrow-right.svg +5 -0
  5. package/assets/images/icons/avocado.svg +4 -0
  6. package/assets/images/icons/bridge-2.svg +3 -0
  7. package/assets/images/icons/bridge.svg +7 -0
  8. package/assets/images/icons/calendar.svg +8 -0
  9. package/assets/images/icons/change-threshold.svg +4 -0
  10. package/assets/images/icons/check-circle.svg +4 -0
  11. package/assets/images/icons/chevron-down.svg +4 -0
  12. package/assets/images/icons/clipboard.svg +7 -0
  13. package/assets/images/icons/clock-circle.svg +5 -0
  14. package/assets/images/icons/copy.svg +5 -0
  15. package/assets/images/icons/cross-transfer.svg +7 -0
  16. package/assets/images/icons/dapp.svg +4 -0
  17. package/assets/images/icons/deploy.svg +12 -0
  18. package/assets/images/icons/error-circle.svg +6 -0
  19. package/assets/images/icons/exclamation-circle.svg +13 -0
  20. package/assets/images/icons/exclamation-octagon.svg +13 -0
  21. package/assets/images/icons/exclamation-triangle.svg +5 -0
  22. package/assets/images/icons/external-link.svg +6 -0
  23. package/assets/images/icons/eye.svg +4 -0
  24. package/assets/images/icons/flowers.svg +8 -0
  25. package/assets/images/icons/gas-emoji.svg +193 -0
  26. package/assets/images/icons/gas.svg +14 -0
  27. package/assets/images/icons/gift.svg +153 -0
  28. package/assets/images/icons/globe.svg +110 -0
  29. package/assets/images/icons/hamburger.svg +6 -0
  30. package/assets/images/icons/instadapp-pro.svg +4 -0
  31. package/assets/images/icons/logout.svg +3 -0
  32. package/assets/images/icons/moon.svg +3 -0
  33. package/assets/images/icons/multi-send.svg +7 -0
  34. package/assets/images/icons/network.svg +13 -0
  35. package/assets/images/icons/options.svg +5 -0
  36. package/assets/images/icons/permit-sign.svg +11 -0
  37. package/assets/images/icons/plus-circle.svg +6 -0
  38. package/assets/images/icons/plus.svg +5 -0
  39. package/assets/images/icons/power-off-bg.svg +24 -0
  40. package/assets/images/icons/power-off.svg +19 -0
  41. package/assets/images/icons/power-on.svg +19 -0
  42. package/assets/images/icons/qr.svg +20 -0
  43. package/assets/images/icons/question-circle.svg +14 -0
  44. package/assets/images/icons/refresh.svg +6 -0
  45. package/assets/images/icons/reject-proposal.svg +6 -0
  46. package/assets/images/icons/search.svg +12 -0
  47. package/assets/images/icons/sun.svg +3 -0
  48. package/assets/images/icons/transfer.svg +5 -0
  49. package/assets/images/icons/trash-2.svg +8 -0
  50. package/assets/images/icons/upgrade.svg +4 -0
  51. package/assets/images/icons/wave.svg +214 -0
  52. package/assets/images/icons/x.svg +5 -0
  53. package/components/ActionLogo.vue +38 -0
  54. package/components/ActionMetadata.vue +75 -0
  55. package/components/ChainLogo.vue +141 -1
  56. package/components/CopyClipboard.vue +64 -0
  57. package/components/metadata/Bridge.vue +43 -0
  58. package/components/metadata/CrossTransfer.vue +71 -0
  59. package/components/metadata/GasTopup.vue +39 -0
  60. package/components/metadata/Permit2.vue +42 -0
  61. package/components/metadata/Swap.vue +74 -0
  62. package/components/metadata/Transfer.vue +50 -0
  63. package/components.d.ts +13 -0
  64. package/contracts/Forwarder.ts +856 -2
  65. package/contracts/factories/Forwarder__factory.ts +816 -16
  66. package/nuxt.config.ts +18 -2
  67. package/package.json +7 -3
  68. package/server/utils/index.ts +2 -0
  69. package/utils/avocado.ts +2 -0
  70. package/utils/bignumber.ts +51 -0
  71. package/utils/formatter.ts +94 -0
  72. package/utils/helper.ts +33 -0
  73. package/utils/metadata.ts +343 -134
  74. package/utils/network.ts +164 -67
  75. package/utils/services.ts +21 -0
  76. package/utils/utils.d.ts +124 -80
  77. package/utils/index.ts +0 -93
package/utils/network.ts CHANGED
@@ -4,18 +4,20 @@ export const bridgeDisabledNetworks = [1101];
4
4
 
5
5
  export const networks: Network[] = [
6
6
  {
7
- name: "Mainnet",
7
+ name: "Ethereum",
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
- 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",
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
- rpcUrls: ["https://api.avax.network/ext/bc/C/rpc"],
107
- explorerUrl: "https://snowtrace.io",
117
+ rpcUrls: ["https://rpc.ankr.com/avalanche"],
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
- ankrName: "gnosis",
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,16 @@ 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
- rpcUrls: ["https://rpc.ankr.com/polygon_zkevm"],
159
- get serverRpcUrl() {
160
- return process.env?.POLYGON_ZKEVM_RPC_URL || this.rpcUrls[0];
161
- },
162
- balanceResolverAddress: "0x48D1Fa5Ee6691a1E0B45d2B515650997BEA27a01",
163
- usdcAddress: "0xa8ce8aee21bc2a48a5ef670afcc9274c7bbbc035",
177
+ rpcUrls: ["https://zkevm-rpc.com"],
164
178
  nativeCurrency: {
165
179
  name: "Ethereum",
166
180
  symbol: "ETH",
@@ -168,10 +182,78 @@ export const networks: Network[] = [
168
182
  },
169
183
  },
170
184
  },
185
+ {
186
+ name: "Aurora",
187
+ chainId: 1313161554,
188
+ zerionName: "aurora",
189
+ color: "#78d64b",
190
+ explorerUrl: "https://explorer.mainnet.aurora.dev",
191
+ get serverRpcUrl() {
192
+ return process.env?.AURORA_RPC_URL || this.params.rpcUrls[0];
193
+ },
194
+ usdcAddress: "0xB12BFcA5A55806AaF64E99521918A4bf0fC40802",
195
+ balanceResolverAddress: "0xdF19Da523DA64bBE82eE0E4DFf00d676A8386474",
196
+ params: {
197
+ rpcUrls: ["https://mainnet.aurora.dev"],
198
+ chainName: "Aurora",
199
+ nativeCurrency: {
200
+ decimals: 18,
201
+ name: "Aurora ETH",
202
+ symbol: "AETH",
203
+ },
204
+ },
205
+ },
206
+ {
207
+ name: "Fantom",
208
+ chainId: 250,
209
+ zerionName: "fantom",
210
+ explorerUrl: "https://ftmscan.com",
211
+ ankrName: "fantom",
212
+ color: "#1969ff",
213
+ get serverRpcUrl() {
214
+ return process.env?.FANTOM_RPC_URL || this.params.rpcUrls[0];
215
+ },
216
+ usdcAddress: "0x04068da6c83afcfa0e13ba15a6696662335d5b75",
217
+ balanceResolverAddress: "0x929376c77a2fb8152375a089a4fccf84ff481479",
218
+ params: {
219
+ rpcUrls: ["https://rpc.ankr.com/fantom"],
220
+ chainName: "Fantom",
221
+ nativeCurrency: {
222
+ name: "Fantom",
223
+ symbol: "FTM",
224
+ decimals: 18,
225
+ },
226
+ },
227
+ },
228
+ {
229
+ name: 'Base',
230
+ chainId: 8453,
231
+ color: '#1E2024',
232
+ explorerUrl: 'https://basescan.org',
233
+ get serverRpcUrl() {
234
+ return process.env?.BASE_RPC_URL || this.params.rpcUrls[0];
235
+ },
236
+ usdcAddress: '0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA',
237
+ balanceResolverAddress: '0x3fB128aA5AC254C8539996B11C587E521AE0d3ab',
238
+ params: {
239
+ rpcUrls: ['https://rpc.ankr.com/base'],
240
+ chainName: "Base",
241
+ nativeCurrency: {
242
+ name: "Ethereum",
243
+ symbol: "ETH",
244
+ decimals: 18,
245
+ },
246
+ }
247
+ },
171
248
  {
172
249
  name: AVO_PROD_CHAIN_NAME,
173
250
  chainId: AVO_PROD_CHAIN_ID,
174
251
  isAvocado: true,
252
+ balanceResolverAddress: "",
253
+ color: "#16A34A",
254
+ usdcAddress: "",
255
+ serverRpcUrl: AVO_PROD_RPC_URL,
256
+ explorerUrl: AVO_PROD_EXPLORER_URL,
175
257
  params: {
176
258
  chainName: AVO_PROD_CHAIN_NAME,
177
259
  nativeCurrency: {
@@ -180,17 +262,18 @@ export const networks: Network[] = [
180
262
  decimals: 18,
181
263
  },
182
264
  iconUrls: ["https://avocado.instadapp.io/logo.svg"],
183
- balanceResolverAddress: "",
184
- usdcAddress: "",
185
- serverRpcUrl: AVO_PROD_RPC_URL,
186
265
  rpcUrls: [AVO_PROD_RPC_URL],
187
- explorerUrl: AVO_PROD_EXPLORER_URL,
188
266
  },
189
267
  },
190
268
  {
191
269
  name: AVO_STAGING_CHAIN_NAME,
192
270
  chainId: AVO_STAGING_CHAIN_ID,
271
+ serverRpcUrl: AVO_STAGING_RPC_URL,
272
+ color: "#16A34A",
273
+ explorerUrl: AVO_STAGING_EXPLORER_URL,
193
274
  isAvocado: true,
275
+ balanceResolverAddress: "",
276
+ usdcAddress: "",
194
277
  params: {
195
278
  chainName: AVO_STAGING_CHAIN_NAME,
196
279
  nativeCurrency: {
@@ -198,16 +281,27 @@ export const networks: Network[] = [
198
281
  symbol: "USDC",
199
282
  decimals: 18,
200
283
  },
201
- serverRpcUrl: AVO_STAGING_RPC_URL,
202
- balanceResolverAddress: "",
203
- usdcAddress: "",
204
284
  iconUrls: ["https://avocado.instadapp.io/logo.svg"],
205
285
  rpcUrls: [AVO_STAGING_RPC_URL],
206
- explorerUrl: AVO_STAGING_EXPLORER_URL,
207
286
  },
208
287
  },
209
288
  ];
210
289
 
290
+ export const chainUsdcAddresses = [
291
+ { chainId: 1, address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48' },
292
+ { chainId: 10, address: '0x7f5c764cbc14f9669b88837ca1490cca17c31607' },
293
+ { chainId: 56, address: '0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d' },
294
+ { chainId: 100, address: '0xddafbb505ad214d7b80b1f830fccc89b60fb7a83' },
295
+ { chainId: 137, address: '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174' },
296
+ { chainId: 250, address: '0x04068da6c83afcfa0e13ba15a6696662335d5b75' },
297
+ { chainId: 42161, address: '0xff970a61a04b1ca14834a43f5de4533ebddb5cc8' },
298
+ { chainId: 42161, address: '0xaf88d065e77c8cc2239327c5edb3a432268e5831' },
299
+ { chainId: 43114, address: '0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e' },
300
+ { chainId: 43114, address: '0xa7d7079b0fead91f3e65f86e8915cb59c1a4c664' },
301
+ { chainId: 1101, address: '0xa8ce8aee21bc2a48a5ef670afcc9274c7bbbc035' },
302
+ { chainId: 1313161554, address: '0xB12BFcA5A55806AaF64E99521918A4bf0fC40802' },
303
+ ];
304
+
211
305
  export const getNetworkByChainId = (
212
306
  chainId: ChainId | number | string
213
307
  ): Network => {
@@ -235,14 +329,17 @@ export const RPCMap = networks.reduce((acc, network) => {
235
329
 
236
330
  export const networkIds = networks.map((network) => network.chainId);
237
331
 
238
- const rpcInstances: Record<string, ethers.providers.JsonRpcProvider> = {};
239
- const serverRpcInstances: Record<string, ethers.providers.JsonRpcProvider> = {};
332
+ const rpcInstances: Record<string, ethers.providers.StaticJsonRpcProvider> = {};
333
+ const serverRpcInstances: Record<
334
+ string,
335
+ ethers.providers.StaticJsonRpcProvider
336
+ > = {};
240
337
 
241
338
  export const getServerRpcProvider = (chainId: number | string) => {
242
339
  if (!rpcInstances[chainId]) {
243
340
  const network = networks.find((n) => n.chainId == chainId);
244
- serverRpcInstances[chainId] = new ethers.providers.JsonRpcProvider(
245
- network?.params.serverRpcUrl
341
+ serverRpcInstances[chainId] = new ethers.providers.StaticJsonRpcProvider(
342
+ network?.serverRpcUrl
246
343
  );
247
344
  }
248
345
 
@@ -251,7 +348,7 @@ export const getServerRpcProvider = (chainId: number | string) => {
251
348
 
252
349
  export const getRpcProvider = (chainId: number | string) => {
253
350
  if (!rpcInstances[chainId]) {
254
- rpcInstances[chainId] = new ethers.providers.JsonRpcProvider(
351
+ rpcInstances[chainId] = new ethers.providers.StaticJsonRpcProvider(
255
352
  getRpcURLByChainId(Number(chainId))
256
353
  );
257
354
  }
@@ -264,5 +361,5 @@ export const getExplorerUrl = (
264
361
  suffix: `/${string}` = "/"
265
362
  ) => {
266
363
  const network = getNetworkByChainId(chainId);
267
- return `${network.params.explorerUrl}${suffix}`;
364
+ return `${network.explorerUrl}${suffix}`;
268
365
  };
@@ -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
+ | 63400;
16
+
17
+ type ISlackMessageType = "danger" | "error" | "success" | "banner";
18
+
19
+ type MetadataTypes = keyof typeof MetadataEnums;
20
+
21
+ type PayloadFunction = (data: any, type: MetadataTypes) => any;
22
+
23
+ type IPayload = Record<MetadataTypes, PayloadFunction>;
24
+
25
+ interface Network {
26
+ name: string;
27
+ debankName?: string;
28
+ ankrName?: string;
29
+ zerionName?: string;
30
+ chainId: ChainId;
31
+ color: string;
32
+ isAvocado?: boolean;
14
33
  serverRpcUrl: string | undefined;
15
34
  balanceResolverAddress?: string;
16
35
  usdcAddress: string;
17
36
  explorerUrl: string;
18
- iconUrls?: string[];
19
- nativeCurrency?: {
20
- name: string;
21
- symbol: string;
22
- decimals: number;
37
+ params: {
38
+ chainName?: string;
39
+ iconUrls?: string[];
40
+ rpcUrls: string[];
41
+ nativeCurrency?: {
42
+ name: string;
43
+ symbol: string;
44
+ decimals: number;
45
+ };
23
46
  };
47
+ }
48
+
49
+ type SignMetadataProps = {
50
+ token: string;
51
+ spender: string;
52
+ amount: string;
53
+ expiration: string;
54
+ };
55
+
56
+ type DappMetadataProps = {
57
+ name: string;
58
+ url: string;
59
+ };
60
+
61
+ type SendMetadataProps = {
62
+ token: string;
63
+ amount: string;
64
+ receiver: string;
65
+ };
66
+
67
+ type CrossSendMetadataProps = {
68
+ fromToken: string;
69
+ toToken: string;
70
+ toChainId: string;
71
+ amount: string;
72
+ receiver: string;
73
+ };
74
+
75
+ type AuthMetadataProps = {
76
+ address: string;
77
+ chainId: string;
78
+ remove: boolean;
24
79
  };
80
+
81
+ type UpgradeMetadataProps = {
82
+ version: string;
83
+ walletImpl: string;
84
+ };
85
+
86
+ type TopupMetadataProps = {
87
+ amount: string;
88
+ token: string;
89
+ onBehalf: string;
90
+ };
91
+
92
+ type BridgeMetadataProps = {
93
+ amount: string;
94
+ receiver: string;
95
+ fromToken: string;
96
+ toToken: string;
97
+ toChainId: string;
98
+ bridgeFee: string;
99
+ nativeToken: string;
100
+ };
101
+
102
+ type SwapMetadataProps = {
103
+ sellToken: string;
104
+ buyToken: string;
105
+ sellAmount: string;
106
+ buyAmount: string;
107
+ receiver: string;
108
+ protocol?: string;
109
+ };
110
+
111
+ type MetadataProps = {
112
+ type: MetadataTypes,
113
+ encodedData: string;
114
+ version?: string;
115
+ };
116
+
117
+ interface ITokenPrice {
118
+ address: string;
119
+ chain_id: string;
120
+ name: string;
121
+ symbol: string;
122
+ decimals: number;
123
+ logo_url: string;
124
+ price: string;
125
+ coingecko_id: string;
126
+ sparkline_price_7d: number[];
127
+ }
128
+
25
129
  }
26
130
 
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
- };
131
+ export { }
132
+