@instadapp/avocado-base 0.0.0-dev.19925f5 → 0.0.0-dev.2177c3e

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