@instadapp/avocado-base 0.0.0-dev.9dbd5b5 → 0.0.0-dev.9df0ab2

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/utils/network.ts CHANGED
@@ -1,4 +1,23 @@
1
1
  import { ethers } from "ethers";
2
+ import {
3
+ polygon,
4
+ arbitrum,
5
+ mainnet,
6
+ base,
7
+ optimism,
8
+ polygonZkEvm,
9
+ bsc,
10
+ avalanche,
11
+ fantom,
12
+ gnosis,
13
+ aurora,
14
+ fuse,
15
+ scroll,
16
+ opBNB,
17
+ mode,
18
+ blast,
19
+ linea
20
+ } from "viem/chains";
2
21
  import {
3
22
  AVO_PROD_CHAIN_NAME,
4
23
  AVO_PROD_CHAIN_ID,
@@ -9,11 +28,44 @@ import {
9
28
  AVO_STAGING_RPC_URL,
10
29
  AVO_STAGING_EXPLORER_URL,
11
30
  } from "./avocado";
31
+ import { defineChain } from "viem";
12
32
 
13
33
  export const bridgeDisabledNetworks = [];
14
34
 
15
35
  export const networksSimulationNotSupported = [1313161554, 1101];
16
36
 
37
+ const avocado = defineChain({
38
+ id: AVO_PROD_CHAIN_ID,
39
+ name: AVO_PROD_CHAIN_NAME,
40
+ nativeCurrency: {
41
+ name: "Avocado",
42
+ symbol: "USDC",
43
+ decimals: 18,
44
+ },
45
+ rpcUrls: {
46
+ default: { http: [AVO_PROD_RPC_URL] },
47
+ },
48
+ blockExplorers: {
49
+ default: { name: "Avoscan", url: AVO_PROD_EXPLORER_URL },
50
+ },
51
+ });
52
+
53
+ const avocadoStaging = defineChain({
54
+ id: AVO_STAGING_CHAIN_ID,
55
+ name: AVO_STAGING_CHAIN_NAME,
56
+ nativeCurrency: {
57
+ name: "Avocado",
58
+ symbol: "USDC",
59
+ decimals: 18,
60
+ },
61
+ rpcUrls: {
62
+ default: { http: [AVO_STAGING_RPC_URL] },
63
+ },
64
+ blockExplorers: {
65
+ default: { name: "Avoscan", url: AVO_STAGING_EXPLORER_URL },
66
+ },
67
+ });
68
+
17
69
  export const networks: Network[] = [
18
70
  {
19
71
  name: "Polygon",
@@ -22,10 +74,13 @@ export const networks: Network[] = [
22
74
  zerionName: "polygon",
23
75
  color: "#7A4ADD",
24
76
  chainId: 137,
77
+ viemChain: polygon,
25
78
  balanceResolverAddress: "0x58632D23120b20650262b8A629a14e4F4043E0D9",
26
79
  usdcAddress: "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
27
80
  explorerUrl: "https://polygonscan.com",
28
- apiURL: "https://api.polygonscan.com",
81
+ apiURL: "https://api.polygonscan.com/api",
82
+ fakeTransactionHash:
83
+ "0x906c551abd5873a428505b6530ac14d91367820706c7ee525f6d7313265d1c92",
29
84
  get serverRpcUrl() {
30
85
  return process.env?.POLYGON_RPC_URL || this.params.rpcUrls[0];
31
86
  },
@@ -44,12 +99,15 @@ export const networks: Network[] = [
44
99
  debankName: "arb",
45
100
  ankrName: "arbitrum",
46
101
  zerionName: "arbitrum",
102
+ viemChain: arbitrum,
47
103
  color: "#2D374B",
48
104
  chainId: 42161,
49
105
  usdcAddress: "0xff970a61a04b1ca14834a43f5de4533ebddb5cc8",
50
106
  balanceResolverAddress: "0xca5f37e6D8bB24c5A7958d5eccE7Bd9Aacc944f2",
107
+ fakeTransactionHash:
108
+ "0x9fa291c3b09d31f19b1fa5dd05f30169d1364036d5f7c14b026410bc07bd8843",
51
109
  explorerUrl: "https://arbiscan.io",
52
- apiURL: "https://api.arbiscan.io",
110
+ apiURL: "https://api.arbiscan.io/api",
53
111
  get serverRpcUrl() {
54
112
  return process.env?.ARBITRUM_RPC_URL || this.params.rpcUrls[0];
55
113
  },
@@ -68,9 +126,12 @@ export const networks: Network[] = [
68
126
  debankName: "eth",
69
127
  ankrName: "eth",
70
128
  zerionName: "ethereum",
129
+ viemChain: mainnet,
71
130
  chainId: 1,
72
131
  explorerUrl: "https://etherscan.io",
73
- apiURL: "https://api.etherscan.io",
132
+ fakeTransactionHash:
133
+ "0x13232dd32cef2f641ead890a507710c96560c8c9c3d5fab6facb5ec563c49433",
134
+ apiURL: "https://api.etherscan.io/api",
74
135
  color: "#5D5FEF",
75
136
  get serverRpcUrl() {
76
137
  return process.env?.MAINNET_RPC_URL || this.params.rpcUrls[0];
@@ -91,8 +152,11 @@ export const networks: Network[] = [
91
152
  chainId: 8453,
92
153
  color: "#1E2024",
93
154
  ankrName: "base",
155
+ viemChain: base,
94
156
  explorerUrl: "https://basescan.org",
95
- apiURL: "https://api.basescan.org",
157
+ fakeTransactionHash:
158
+ "0xf7833d80da33730c4fc5d4c64151f0eaa64c0c0535be022af0228a44cc4e9c8e",
159
+ apiURL: "https://api.basescan.org/api",
96
160
  get serverRpcUrl() {
97
161
  return process.env?.BASE_RPC_URL || this.params.rpcUrls[0];
98
162
  },
@@ -114,10 +178,13 @@ export const networks: Network[] = [
114
178
  ankrName: "optimism",
115
179
  zerionName: "optimism",
116
180
  color: "#FF0420",
181
+ viemChain: optimism,
117
182
  chainId: 10,
118
- apiURL: "https://api-optimistic.etherscan.io",
183
+ apiURL: "https://api-optimistic.etherscan.io/api",
119
184
  usdcAddress: "0x7f5c764cbc14f9669b88837ca1490cca17c31607",
120
185
  balanceResolverAddress: "0xca5f37e6D8bB24c5A7958d5eccE7Bd9Aacc944f2",
186
+ fakeTransactionHash:
187
+ "0xee7311d68059732b05088f2144dfec6c7a4f5fd0433eb85306afcd6bdf17cebc",
121
188
  explorerUrl: "https://optimistic.etherscan.io",
122
189
  get serverRpcUrl() {
123
190
  return process.env?.OPTIMISM_RPC_URL || this.params.rpcUrls[0];
@@ -137,9 +204,12 @@ export const networks: Network[] = [
137
204
  chainId: 1101,
138
205
  color: "#8544f6",
139
206
  ankrName: "polygon_zkevm",
207
+ viemChain: polygonZkEvm,
140
208
  explorerUrl: "https://zkevm.polygonscan.com",
141
- apiURL: "https://api-zkevm.polygonscan.com",
209
+ apiURL: "https://api-zkevm.polygonscan.com/api",
142
210
  balanceResolverAddress: "0x48D1Fa5Ee6691a1E0B45d2B515650997BEA27a01",
211
+ fakeTransactionHash:
212
+ "0x1077130463ade91ad4e9c43c3195298e26a99970975238128912490eea12bf41",
143
213
  usdcAddress: "0xa8ce8aee21bc2a48a5ef670afcc9274c7bbbc035",
144
214
  get serverRpcUrl() {
145
215
  return process.env?.POLYGON_ZKEVM_RPC_URL || this.params.rpcUrls[0];
@@ -162,7 +232,10 @@ export const networks: Network[] = [
162
232
  color: "#F3BA2F",
163
233
  chainId: 56,
164
234
  explorerUrl: "https://bscscan.com",
165
- apiURL: "https://api.bscscan.com",
235
+ viemChain: bsc,
236
+ fakeTransactionHash:
237
+ "0x897d54bf8e492f840bd4d8f1e743bfcab8226ab4d5a899e47ee433dcd6d6abf7",
238
+ apiURL: "https://api.bscscan.com/api",
166
239
  usdcAddress: "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d",
167
240
  balanceResolverAddress: "0xb808cff38706e267067b0af427726aa099f69f89",
168
241
  get serverRpcUrl() {
@@ -184,11 +257,14 @@ export const networks: Network[] = [
184
257
  ankrName: "avalanche",
185
258
  zerionName: "avalanche",
186
259
  color: "#EB5757",
260
+ viemChain: avalanche,
187
261
  chainId: 43114,
188
262
  usdcAddress: "0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e",
189
263
  balanceResolverAddress: "0x63009f31D054E0ac9F321Cf0D642375236A4Bf1E",
190
264
  explorerUrl: "https://snowtrace.io",
191
- apiURL: "https://api.snowtrace.io",
265
+ fakeTransactionHash:
266
+ "0x233aac7402558dd4e23f938a50f983e67f5c9604233981c7ac74e63737b8294e",
267
+ apiURL: "https://api.routescan.io/v2/network/mainnet/evm/43114/etherscan/api",
192
268
  get serverRpcUrl() {
193
269
  return process.env?.AVALANCHE_RPC_URL || this.params.rpcUrls[0];
194
270
  },
@@ -207,13 +283,17 @@ export const networks: Network[] = [
207
283
  chainId: 250,
208
284
  zerionName: "fantom",
209
285
  explorerUrl: "https://ftmscan.com",
286
+ apiURL: 'https://api.ftmscan.com/api',
210
287
  ankrName: "fantom",
211
288
  color: "#1969ff",
289
+ viemChain: fantom,
212
290
  get serverRpcUrl() {
213
291
  return process.env?.FANTOM_RPC_URL || this.params.rpcUrls[0];
214
292
  },
215
293
  usdcAddress: "0x04068da6c83afcfa0e13ba15a6696662335d5b75",
216
294
  balanceResolverAddress: "0x929376c77a2fb8152375a089a4fccf84ff481479",
295
+ fakeTransactionHash:
296
+ "0x1e9a8405d660172314124e06896212c0786d7fb1550b89410d4bc87e9e8054e4",
217
297
  params: {
218
298
  rpcUrls: ["https://rpc.ankr.com/fantom"],
219
299
  chainName: "Fantom",
@@ -230,10 +310,13 @@ export const networks: Network[] = [
230
310
  zerionName: "xdai",
231
311
  color: "#04795C",
232
312
  ankrName: "gnosis",
313
+ viemChain: gnosis,
233
314
  chainId: 100,
234
315
  balanceResolverAddress: "0xfaa244e276b1597f663975ed007ee4ff70d27849",
235
316
  explorerUrl: "https://gnosisscan.io",
236
- apiURL: "https://api.gnosisscan.io",
317
+ fakeTransactionHash:
318
+ "0x1513033806310a2c3b29f2276f8aa7388461b0ef9f8499c297e68c12187c179b",
319
+ apiURL: "https://api.gnosisscan.io/api",
237
320
  usdcAddress: "0xddafbb505ad214d7b80b1f830fccc89b60fb7a83",
238
321
  get serverRpcUrl() {
239
322
  return process.env?.GNOSIS_RPC_URL || this.params.rpcUrls[0];
@@ -253,7 +336,11 @@ export const networks: Network[] = [
253
336
  chainId: 1313161554,
254
337
  zerionName: "aurora",
255
338
  color: "#78d64b",
339
+ viemChain: aurora,
256
340
  explorerUrl: "https://explorer.mainnet.aurora.dev",
341
+ apiURL:'https://explorer.mainnet.aurora.dev/api/v2',
342
+ fakeTransactionHash:
343
+ "0x0923401c5a80c39a5cd57c098a6c4729edbefd0db6894def7d349493f4ff3ec6",
257
344
  get serverRpcUrl() {
258
345
  return process.env?.AURORA_RPC_URL || this.params.rpcUrls[0];
259
346
  },
@@ -269,32 +356,167 @@ export const networks: Network[] = [
269
356
  },
270
357
  },
271
358
  },
359
+ {
360
+ name: "Fuse",
361
+ chainId: 122,
362
+ zerionName: "fuse",
363
+ color: "#78d64b",
364
+ explorerUrl: "https://explorer.fuse.io",
365
+ apiURL: 'https://explorer.fuse.io/api/v2',
366
+ viemChain: fuse,
367
+ fakeTransactionHash:
368
+ "0xf22a8031de9b978a57c728e18c6b54633356c39db4d0466e53b9b7c3ee7f8def",
369
+ get serverRpcUrl() {
370
+ return process.env?.FUSE_RPC_URL || this.params.rpcUrls[0];
371
+ },
372
+ usdcAddress: "",
373
+ balanceResolverAddress: "0xdF19Da523DA64bBE82eE0E4DFf00d676A8386474",
374
+ params: {
375
+ rpcUrls: ["https://fuse-mainnet.chainstacklabs.com"],
376
+ chainName: "Fuse",
377
+ nativeCurrency: {
378
+ decimals: 18,
379
+ name: "Fuse",
380
+ symbol: "fuse",
381
+ },
382
+ },
383
+ },
384
+ {
385
+ name: "Scroll",
386
+ chainId: 534352,
387
+ color: "#78d64b",
388
+ ankrName: 'scroll',
389
+ explorerUrl: "https://scrollscan.com",
390
+ apiURL: 'https://api.scrollscan.com/api',
391
+ viemChain: scroll,
392
+ fakeTransactionHash:
393
+ "0x6bf297c414264fc8cddd47224632b4426a02138df2f50fe891eca87f6aefea01",
394
+ get serverRpcUrl() {
395
+ return process.env?.SCROLL_RPC_URL || this.params.rpcUrls[0];
396
+ },
397
+ params: {
398
+ rpcUrls: ["https://rpc.scroll.io"],
399
+ chainName: "Scroll",
400
+ nativeCurrency: {
401
+ name: "Ethereum",
402
+ symbol: "ETH",
403
+ decimals: 18,
404
+ },
405
+ },
406
+ },
407
+ {
408
+ name: "opBNB",
409
+ chainId: 204,
410
+ color: "#78d64b",
411
+ explorerUrl: "https://opbnbscan.com",
412
+ apiURL: null,
413
+ viemChain: opBNB,
414
+ fakeTransactionHash:
415
+ "0xb9438a3eae61442bc7d419d79930370ce09ac0f46e0695025751e3bfe1a931e7",
416
+ get serverRpcUrl() {
417
+ return process.env?.OPBNB_RPC_URL || this.params.rpcUrls[0];
418
+ },
419
+ params: {
420
+ rpcUrls: ["https://opbnb-mainnet-rpc.bnbchain.org"],
421
+ chainName: "opBNB",
422
+ nativeCurrency: {
423
+ name: "BNB",
424
+ symbol: "BNB",
425
+ decimals: 18,
426
+ },
427
+ },
428
+ },
429
+ {
430
+ chainId: 34443,
431
+ name: "Mode",
432
+ color: "#d7ff00",
433
+ explorerUrl: 'https://explorer.mode.network',
434
+ fakeTransactionHash: '0xb58002db3481f2c51855a91280ec940d0bebec075c4b362b9f90c21a2b14edbe',
435
+ apiURL: 'https://explorer.mode.network/api/v2',
436
+ params: {
437
+ rpcUrls: ["https://1rpc.io/mode"],
438
+ chainName: "Mode",
439
+ nativeCurrency: {
440
+ name: "Ethereum",
441
+ symbol: "ETH",
442
+ decimals: 18,
443
+ }
444
+ },
445
+ get serverRpcUrl() {
446
+ return process.env?.MODE_RPC_URL || this.params.rpcUrls[0];
447
+ },
448
+ viemChain: mode,
449
+ },
450
+ {
451
+ chainId: 81457,
452
+ name: "Blast",
453
+ color: "#78d64b",
454
+ explorerUrl: 'https://blastscan.io',
455
+ apiURL:'https://api.blastscan.io/api',
456
+ fakeTransactionHash: '0x934ed8516242f8c08bb9e0e90bb1f989d92ceb6b0333e86ac2d555f25ac27e58',
457
+ params: {
458
+ rpcUrls: ['https://rpc.ankr.com/blast'],
459
+ chainName: "Blast",
460
+ nativeCurrency: {
461
+ name: "Ethereum",
462
+ symbol: "ETH",
463
+ decimals: 18,
464
+ }
465
+ },
466
+ get serverRpcUrl() {
467
+ return process.env?.BLAST_RPC_URL || this.params.rpcUrls[0];
468
+ },
469
+ viemChain: blast,
470
+ },
272
471
  // {
273
- // name: "Fuse",
274
- // chainId: 122,
275
- // zerionName: "fuse",
472
+ // chainId: 59144,
473
+ // name: "Linea",
474
+ // apiURL: "https://api.lineascan.build/api",
276
475
  // color: "#78d64b",
277
- // explorerUrl: "https://explorer.fuse.io",
476
+ // explorerUrl: "https://lineascan.build",
477
+ // params: {
478
+ // rpcUrls: ["https://linea-mainnet.public.blastapi.io"],
479
+ // chainName: "Linea",
480
+ // "nativeCurrency": {
481
+ // "name": "Linea Ether",
482
+ // "symbol": "ETH",
483
+ // "decimals": 18
484
+ // },
485
+ // },
486
+ // fakeTransactionHash: '0x62d068a66eb1515a09e993200e8a495c7fead512689ba78e50523c8e83bbf5b5',
278
487
  // get serverRpcUrl() {
279
- // return process.env?.FUSE_RPC_URL || this.params.rpcUrls[0];
488
+ // return process.env?.LINEA_RPC_URL || this.params.rpcUrls[0];
280
489
  // },
281
- // usdcAddress: "",
282
- // balanceResolverAddress: "0xdF19Da523DA64bBE82eE0E4DFf00d676A8386474",
490
+ // viemChain: linea,
491
+ // ankrName:'linea',
492
+ // },
493
+ // {
494
+ // name: "Manta Pacific",
495
+ // chainId: 169,
496
+ // explorerUrl: "https://pacific-explorer.manta.network",
283
497
  // params: {
284
- // rpcUrls: ["https://fuse-mainnet.chainstacklabs.com"],
285
- // chainName: "Fuse",
498
+ // rpcUrls: ["https://pacific-rpc.manta.network/http"],
499
+ // chainName: "Manta Pacific",
286
500
  // nativeCurrency: {
501
+ // name: "Ethereum",
502
+ // symbol: "ETH",
287
503
  // decimals: 18,
288
- // name: "Fuse",
289
- // symbol: "fuse",
290
504
  // },
291
505
  // },
506
+ // color: "#78d64b",
507
+ // fakeTransactionHash: "0x3fB128aA5AC254C8539996B11C587E521AE0d3ab",
508
+ // get serverRpcUrl() {
509
+ // return process.env?.MANTA_RPC_URL || this.params.rpcUrls[0];
510
+ // },
292
511
  // },
293
512
  {
294
513
  name: AVO_PROD_CHAIN_NAME,
295
514
  chainId: AVO_PROD_CHAIN_ID,
515
+ apiURL:null,
296
516
  isAvocado: true,
297
517
  balanceResolverAddress: "",
518
+ fakeTransactionHash: "",
519
+ viemChain: avocado,
298
520
  color: "#16A34A",
299
521
  usdcAddress: "",
300
522
  serverRpcUrl: AVO_PROD_RPC_URL,
@@ -312,10 +534,13 @@ export const networks: Network[] = [
312
534
  },
313
535
  {
314
536
  name: AVO_STAGING_CHAIN_NAME,
537
+ apiURL: null,
315
538
  chainId: AVO_STAGING_CHAIN_ID,
316
539
  serverRpcUrl: AVO_STAGING_RPC_URL,
317
540
  color: "#16A34A",
318
541
  explorerUrl: AVO_STAGING_EXPLORER_URL,
542
+ viemChain: avocadoStaging,
543
+ fakeTransactionHash: "",
319
544
  isAvocado: true,
320
545
  balanceResolverAddress: "",
321
546
  usdcAddress: "",
@@ -338,6 +563,7 @@ export const chainUsdcAddresses = [
338
563
  { chainId: 56, address: "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d" },
339
564
  { chainId: 100, address: "0xddafbb505ad214d7b80b1f830fccc89b60fb7a83" },
340
565
  { chainId: 137, address: "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174" },
566
+ { chainId: 137, address: "0x3c499c542cef5e3811e1192ce70d8cc03d5c3359" },
341
567
  { chainId: 250, address: "0x04068da6c83afcfa0e13ba15a6696662335d5b75" },
342
568
  { chainId: 42161, address: "0xff970a61a04b1ca14834a43f5de4533ebddb5cc8" },
343
569
  { chainId: 42161, address: "0xaf88d065e77c8cc2239327c5edb3a432268e5831" },
@@ -363,12 +589,16 @@ export const availableNetworks = networks.filter(
363
589
 
364
590
  export const chainIdToName = (chainId: ChainId | number | string) => {
365
591
  const network = getNetworkByChainId(chainId);
366
- return network.name;
592
+ return network?.name;
367
593
  };
368
594
 
369
595
  export const getRpcURLByChainId = (chainId: ChainId | number | string) => {
370
- const network = getNetworkByChainId(chainId);
371
- return network.params.rpcUrls[0];
596
+ try {
597
+ const network = getNetworkByChainId(chainId);
598
+ return network.params.rpcUrls[0];
599
+ } catch (e) {
600
+ return "";
601
+ }
372
602
  };
373
603
 
374
604
  export const RPCMap = networks.reduce((acc, network) => {
@@ -410,5 +640,6 @@ export const getExplorerUrl = (
410
640
  suffix: `/${string}` = "/"
411
641
  ) => {
412
642
  const network = getNetworkByChainId(chainId);
643
+ if (!network) return "";
413
644
  return `${network.explorerUrl}${suffix}`;
414
645
  };
package/utils/utils.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import type { Chain } from "viem";
2
+
1
3
  declare global {
2
4
  type ChainId =
3
5
  | 1
@@ -13,7 +15,13 @@ declare global {
13
15
  | 1313161554
14
16
  | 8453
15
17
  | 122
16
- | 63400;
18
+ | 534352
19
+ | 204
20
+ | 63400
21
+ | 169
22
+ | 34443
23
+ | 81457
24
+ | 59144
17
25
 
18
26
  type ISlackMessageType = "danger" | "error" | "success" | "banner";
19
27
 
@@ -33,9 +41,12 @@ declare global {
33
41
  isAvocado?: boolean;
34
42
  serverRpcUrl: string | undefined;
35
43
  balanceResolverAddress?: string;
36
- usdcAddress: string;
44
+ usdcAddress?: string;
37
45
  explorerUrl: string;
38
- apiURL?: string;
46
+ fakeTransactionHash: string;
47
+ viemChain: Chain;
48
+ // must start with https://
49
+ apiURL: `https://${string}` | null;
39
50
  params: {
40
51
  chainName?: string;
41
52
  iconUrls?: string[];
@@ -72,8 +83,10 @@ declare global {
72
83
  toChainId: string;
73
84
  amount: string;
74
85
  receiver: string;
86
+ provider?: string;
75
87
  };
76
88
 
89
+
77
90
  type AuthMetadataProps = {
78
91
  address: string;
79
92
  chainId: string;
@@ -99,6 +112,8 @@ declare global {
99
112
  toChainId: string;
100
113
  bridgeFee: string;
101
114
  nativeToken: string;
115
+ version?: string;
116
+ provider: string;
102
117
  };
103
118
 
104
119
  type SwapMetadataProps = {