@instadapp/avocado-base 0.0.0-dev.a52088d → 0.0.0-dev.ab8794d

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,5 @@
1
1
  import { ethers } from 'ethers'
2
+ import { defineChain } from 'viem'
2
3
  import {
3
4
  arbitrum,
4
5
  aurora,
@@ -18,7 +19,6 @@ import {
18
19
  polygonZkEvm,
19
20
  scroll,
20
21
  } from 'viem/chains'
21
- import { defineChain } from 'viem'
22
22
  import {
23
23
  AVO_PROD_CHAIN_ID,
24
24
  AVO_PROD_CHAIN_NAME,
@@ -66,6 +66,26 @@ const avocadoStaging = defineChain({
66
66
  },
67
67
  })
68
68
 
69
+ const sonic = /* #__PURE__ */ defineChain({
70
+ id: 146,
71
+ name: 'Sonic',
72
+ nativeCurrency: {
73
+ decimals: 18,
74
+ name: 'Sonic',
75
+ symbol: 'S',
76
+ },
77
+ rpcUrls: {
78
+ default: { http: ['https://rpc.soniclabs.com'] },
79
+ },
80
+ blockExplorers: {
81
+ default: {
82
+ name: 'Sonic Explorer',
83
+ url: 'https://explorer.soniclabs.com',
84
+ },
85
+ },
86
+ testnet: false,
87
+ })
88
+
69
89
  export const networks: Network[] = [
70
90
  {
71
91
  name: 'Polygon',
@@ -74,6 +94,7 @@ export const networks: Network[] = [
74
94
  zerionName: 'polygon',
75
95
  color: '#7A4ADD',
76
96
  chainId: 137,
97
+ legacySupported: true,
77
98
  viemChain: polygon,
78
99
  balanceResolverAddress: '0x58632D23120b20650262b8A629a14e4F4043E0D9',
79
100
  usdcAddress: '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174',
@@ -99,6 +120,7 @@ export const networks: Network[] = [
99
120
  debankName: 'arb',
100
121
  ankrName: 'arbitrum',
101
122
  zerionName: 'arbitrum',
123
+ legacySupported: true,
102
124
  viemChain: arbitrum,
103
125
  color: '#2D374B',
104
126
  chainId: 42161,
@@ -129,6 +151,7 @@ export const networks: Network[] = [
129
151
  viemChain: mainnet,
130
152
  chainId: 1,
131
153
  explorerUrl: 'https://etherscan.io',
154
+ legacySupported: true,
132
155
  fakeTransactionHash:
133
156
  '0x13232dd32cef2f641ead890a507710c96560c8c9c3d5fab6facb5ec563c49433',
134
157
  apiURL: 'https://api.etherscan.io/api',
@@ -154,6 +177,7 @@ export const networks: Network[] = [
154
177
  ankrName: 'base',
155
178
  viemChain: base,
156
179
  explorerUrl: 'https://basescan.org',
180
+ legacySupported: true,
157
181
  fakeTransactionHash:
158
182
  '0xf7833d80da33730c4fc5d4c64151f0eaa64c0c0535be022af0228a44cc4e9c8e',
159
183
  apiURL: 'https://api.basescan.org/api',
@@ -178,6 +202,7 @@ export const networks: Network[] = [
178
202
  ankrName: 'optimism',
179
203
  zerionName: 'optimism',
180
204
  color: '#FF0420',
205
+ legacySupported: true,
181
206
  viemChain: optimism,
182
207
  chainId: 10,
183
208
  apiURL: 'https://api-optimistic.etherscan.io/api',
@@ -205,6 +230,7 @@ export const networks: Network[] = [
205
230
  color: '#8544f6',
206
231
  ankrName: 'polygon_zkevm',
207
232
  viemChain: polygonZkEvm,
233
+ legacySupported: true,
208
234
  explorerUrl: 'https://zkevm.polygonscan.com',
209
235
  apiURL: 'https://api-zkevm.polygonscan.com/api',
210
236
  balanceResolverAddress: '0x48D1Fa5Ee6691a1E0B45d2B515650997BEA27a01',
@@ -231,6 +257,7 @@ export const networks: Network[] = [
231
257
  zerionName: 'binance-smart-chain',
232
258
  color: '#F3BA2F',
233
259
  chainId: 56,
260
+ legacySupported: true,
234
261
  explorerUrl: 'https://bscscan.com',
235
262
  viemChain: bsc,
236
263
  fakeTransactionHash:
@@ -258,6 +285,7 @@ export const networks: Network[] = [
258
285
  zerionName: 'avalanche',
259
286
  color: '#EB5757',
260
287
  viemChain: avalanche,
288
+ legacySupported: true,
261
289
  chainId: 43114,
262
290
  usdcAddress: '0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e',
263
291
  balanceResolverAddress: '0x63009f31D054E0ac9F321Cf0D642375236A4Bf1E',
@@ -286,6 +314,7 @@ export const networks: Network[] = [
286
314
  apiURL: 'https://api.ftmscan.com/api',
287
315
  ankrName: 'fantom',
288
316
  color: '#1969ff',
317
+ legacySupported: true,
289
318
  viemChain: fantom,
290
319
  get serverRpcUrl() {
291
320
  return process.env?.FANTOM_RPC_URL || this.params.rpcUrls[0]
@@ -311,6 +340,7 @@ export const networks: Network[] = [
311
340
  color: '#04795C',
312
341
  ankrName: 'gnosis',
313
342
  viemChain: gnosis,
343
+ legacySupported: true,
314
344
  chainId: 100,
315
345
  balanceResolverAddress: '0xfaa244e276b1597f663975ed007ee4ff70d27849',
316
346
  explorerUrl: 'https://gnosisscan.io',
@@ -337,6 +367,7 @@ export const networks: Network[] = [
337
367
  zerionName: 'aurora',
338
368
  color: '#78d64b',
339
369
  viemChain: aurora,
370
+ legacySupported: true,
340
371
  explorerUrl: 'https://explorer.mainnet.aurora.dev',
341
372
  apiURL: 'https://explorer.mainnet.aurora.dev/api/v2',
342
373
  fakeTransactionHash:
@@ -364,6 +395,7 @@ export const networks: Network[] = [
364
395
  explorerUrl: 'https://explorer.fuse.io',
365
396
  apiURL: 'https://explorer.fuse.io/api/v2',
366
397
  viemChain: fuse,
398
+ legacySupported: false,
367
399
  fakeTransactionHash:
368
400
  '0xf22a8031de9b978a57c728e18c6b54633356c39db4d0466e53b9b7c3ee7f8def',
369
401
  get serverRpcUrl() {
@@ -386,6 +418,7 @@ export const networks: Network[] = [
386
418
  chainId: 534352,
387
419
  color: '#78d64b',
388
420
  ankrName: 'scroll',
421
+ legacySupported: false,
389
422
  explorerUrl: 'https://scrollscan.com',
390
423
  apiURL: 'https://api.scrollscan.com/api',
391
424
  viemChain: scroll,
@@ -411,6 +444,7 @@ export const networks: Network[] = [
411
444
  explorerUrl: 'https://opbnbscan.com',
412
445
  apiURL: null,
413
446
  viemChain: opBNB,
447
+ legacySupported: false,
414
448
  fakeTransactionHash:
415
449
  '0xb9438a3eae61442bc7d419d79930370ce09ac0f46e0695025751e3bfe1a931e7',
416
450
  get serverRpcUrl() {
@@ -431,6 +465,7 @@ export const networks: Network[] = [
431
465
  name: 'Mode',
432
466
  color: '#d7ff00',
433
467
  explorerUrl: 'https://explorer.mode.network',
468
+ legacySupported: false,
434
469
  fakeTransactionHash: '0xb58002db3481f2c51855a91280ec940d0bebec075c4b362b9f90c21a2b14edbe',
435
470
  apiURL: 'https://explorer.mode.network/api/v2',
436
471
  params: {
@@ -453,6 +488,7 @@ export const networks: Network[] = [
453
488
  color: '#78d64b',
454
489
  explorerUrl: 'https://blastscan.io',
455
490
  apiURL: 'https://api.blastscan.io/api',
491
+ legacySupported: false,
456
492
  fakeTransactionHash: '0x934ed8516242f8c08bb9e0e90bb1f989d92ceb6b0333e86ac2d555f25ac27e58',
457
493
  params: {
458
494
  rpcUrls: ['https://rpc.ankr.com/blast'],
@@ -468,28 +504,47 @@ export const networks: Network[] = [
468
504
  },
469
505
  viemChain: blast,
470
506
  },
471
- // {
472
- // chainId: 59144,
473
- // name: 'Linea',
474
- // apiURL: 'https://api.lineascan.build/api',
475
- // color: '#78d64b',
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',
487
- // get serverRpcUrl() {
488
- // return process.env?.LINEA_RPC_URL || this.params.rpcUrls[0]
489
- // },
490
- // viemChain: linea,
491
- // ankrName: 'linea',
492
- // },
507
+ {
508
+ chainId: 59144,
509
+ name: 'Linea',
510
+ apiURL: 'https://api.lineascan.build/api',
511
+ color: '#78d64b',
512
+ explorerUrl: 'https://lineascan.build',
513
+ legacySupported: false,
514
+ params: {
515
+ rpcUrls: ['https://linea-mainnet.public.blastapi.io'],
516
+ chainName: 'Linea',
517
+ nativeCurrency: {
518
+ name: 'Linea Ether',
519
+ symbol: 'ETH',
520
+ decimals: 18,
521
+ },
522
+ },
523
+ fakeTransactionHash: '0x62d068a66eb1515a09e993200e8a495c7fead512689ba78e50523c8e83bbf5b5',
524
+ get serverRpcUrl() {
525
+ return process.env?.LINEA_RPC_URL || this.params.rpcUrls[0]
526
+ },
527
+ viemChain: linea,
528
+ ankrName: 'linea',
529
+ },
530
+ {
531
+ name: sonic.name,
532
+ chainId: sonic.id,
533
+ explorerUrl: sonic.blockExplorers.default.url,
534
+ legacySupported: false,
535
+ viemChain: sonic,
536
+ color: '#78d64b',
537
+ apiURL: null,
538
+ fakeTransactionHash: '0xc8fe01a980987295c36e898b4681fa8c937eb8dfd48a3ae080956b36a66195ee',
539
+ get serverRpcUrl() {
540
+ return process.env?.SONIC_RPC_URL || this.params.rpcUrls[0]
541
+ },
542
+ params: {
543
+ rpcUrls: sonic.rpcUrls.default.http as any,
544
+ chainName: sonic.name,
545
+ nativeCurrency: sonic.nativeCurrency,
546
+ },
547
+ },
493
548
  // {
494
549
  // name: "Manta Pacific",
495
550
  // chainId: 169,
@@ -516,6 +571,7 @@ export const networks: Network[] = [
516
571
  isAvocado: true,
517
572
  balanceResolverAddress: '',
518
573
  fakeTransactionHash: '',
574
+ legacySupported: false,
519
575
  viemChain: avocado,
520
576
  color: '#16A34A',
521
577
  usdcAddress: '',
@@ -539,6 +595,7 @@ export const networks: Network[] = [
539
595
  serverRpcUrl: AVO_STAGING_RPC_URL,
540
596
  color: '#16A34A',
541
597
  explorerUrl: AVO_STAGING_EXPLORER_URL,
598
+ legacySupported: false,
542
599
  viemChain: avocadoStaging,
543
600
  fakeTransactionHash: '',
544
601
  isAvocado: true,
@@ -595,7 +652,7 @@ export function getRpcURLByChainId(chainId: ChainId | number | string) {
595
652
  const network = getNetworkByChainId(chainId)
596
653
  return network.params.rpcUrls[0]
597
654
  }
598
- catch (e) {
655
+ catch {
599
656
  return ''
600
657
  }
601
658
  }
package/utils/services.ts CHANGED
@@ -1,21 +1,19 @@
1
- export const fetchTokenByAddress = async (
2
- address: string,
3
- chainId: string | number,
4
- tokens?: ITokenPrice[]
5
- ) => {
6
- if (!address || !chainId) return null;
1
+ export async function fetchTokenByAddress(address: string, chainId: string | number, tokens?: ITokenPrice[]) {
2
+ if (!address || !chainId)
3
+ return null
7
4
 
8
5
  if (tokens?.length) {
9
- const token = tokens.find((token) => token.address?.toLocaleLowerCase() === address?.toLocaleLowerCase() && token.chain_id == chainId);
10
- if (token) return token;
6
+ const token = tokens.find(token => token.address?.toLocaleLowerCase() === address?.toLocaleLowerCase() && token.chain_id == chainId)
7
+ if (token)
8
+ return token
11
9
  }
12
10
 
13
11
  const [token] = (await $fetch(`${blockQueryURL}/${chainId}/tokens`, {
14
12
  params: {
15
- sparkline: false,
16
- "addresses[]": [address],
13
+ 'sparkline': false,
14
+ 'addresses[]': [address],
17
15
  },
18
- })) as ITokenPrice[];
16
+ })) as ITokenPrice[]
19
17
 
20
- return token;
21
- };
18
+ return token
19
+ }
package/utils/utils.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Chain } from "viem";
1
+ import type { Chain } from 'viem'
2
2
 
3
3
  declare global {
4
4
  type ChainId =
@@ -22,126 +22,127 @@ declare global {
22
22
  | 34443
23
23
  | 81457
24
24
  | 59144
25
+ | 146
25
26
 
26
- type ISlackMessageType = "danger" | "error" | "success" | "banner";
27
+ type ISlackMessageType = 'danger' | 'error' | 'success' | 'banner'
27
28
 
28
- type MetadataTypes = keyof typeof MetadataEnums;
29
+ type MetadataTypes = keyof typeof MetadataEnums
29
30
 
30
- type PayloadFunction = (data: any, type: MetadataTypes) => any;
31
+ type PayloadFunction = (data: any, type: MetadataTypes) => any
31
32
 
32
- type IPayload = Record<MetadataTypes, PayloadFunction>;
33
+ type IPayload = Record<MetadataTypes, PayloadFunction>
33
34
 
34
35
  interface Network {
35
- name: string;
36
- debankName?: string;
37
- ankrName?: string;
38
- zerionName?: string;
39
- chainId: ChainId;
40
- color: string;
41
- isAvocado?: boolean;
42
- serverRpcUrl: string | undefined;
43
- balanceResolverAddress?: string;
44
- usdcAddress?: string;
45
- explorerUrl: string;
46
- fakeTransactionHash: string;
47
- viemChain: Chain;
36
+ name: string
37
+ debankName?: string
38
+ ankrName?: string
39
+ zerionName?: string
40
+ chainId: ChainId
41
+ color: string
42
+ isAvocado?: boolean
43
+ serverRpcUrl: string | undefined
44
+ balanceResolverAddress?: string
45
+ usdcAddress?: string
46
+ explorerUrl: string
47
+ fakeTransactionHash: string
48
+ viemChain: Chain
49
+ legacySupported: boolean
48
50
  // must start with https://
49
- apiURL: `https://${string}` | null;
51
+ apiURL: `https://${string}` | null
50
52
  params: {
51
- chainName?: string;
52
- iconUrls?: string[];
53
- rpcUrls: string[];
53
+ chainName?: string
54
+ iconUrls?: string[]
55
+ rpcUrls: string[]
54
56
  nativeCurrency?: {
55
- name: string;
56
- symbol: string;
57
- decimals: number;
58
- };
59
- };
57
+ name: string
58
+ symbol: string
59
+ decimals: number
60
+ }
61
+ }
60
62
  }
61
63
 
62
- type SignMetadataProps = {
63
- token: string;
64
- spender: string;
65
- amount: string;
66
- expiration: string;
67
- };
68
-
69
- type DappMetadataProps = {
70
- name: string;
71
- url: string;
72
- };
73
-
74
- type SendMetadataProps = {
75
- token: string;
76
- amount: string;
77
- receiver: string;
78
- };
79
-
80
- type CrossSendMetadataProps = {
81
- fromToken: string;
82
- toToken: string;
83
- toChainId: string;
84
- amount: string;
85
- receiver: string;
86
- provider?: string;
87
- };
88
-
89
-
90
- type AuthMetadataProps = {
91
- address: string;
92
- chainId: string;
93
- remove: boolean;
94
- };
95
-
96
- type UpgradeMetadataProps = {
97
- version: string;
98
- walletImpl: string;
99
- };
100
-
101
- type TopupMetadataProps = {
102
- amount: string;
103
- token: string;
104
- onBehalf: string;
105
- };
106
-
107
- type BridgeMetadataProps = {
108
- amount: string;
109
- receiver: string;
110
- fromToken: string;
111
- toToken: string;
112
- toChainId: string;
113
- bridgeFee: string;
114
- nativeToken: string;
115
- version?: string;
116
- provider: string;
117
- };
118
-
119
- type SwapMetadataProps = {
120
- sellToken: string;
121
- buyToken: string;
122
- sellAmount: string;
123
- buyAmount: string;
124
- receiver: string;
125
- protocol?: string;
126
- };
127
-
128
- type MetadataProps = {
129
- type: MetadataTypes;
130
- encodedData: string;
131
- version?: string;
132
- };
64
+ interface SignMetadataProps {
65
+ token: string
66
+ spender: string
67
+ amount: string
68
+ expiration: string
69
+ }
70
+
71
+ interface DappMetadataProps {
72
+ name: string
73
+ url: string
74
+ }
75
+
76
+ interface SendMetadataProps {
77
+ token: string
78
+ amount: string
79
+ receiver: string
80
+ }
81
+
82
+ interface CrossSendMetadataProps {
83
+ fromToken: string
84
+ toToken: string
85
+ toChainId: string
86
+ amount: string
87
+ receiver: string
88
+ provider?: string
89
+ }
90
+
91
+ interface AuthMetadataProps {
92
+ address: string
93
+ chainId: string
94
+ remove: boolean
95
+ }
96
+
97
+ interface UpgradeMetadataProps {
98
+ version: string
99
+ walletImpl: string
100
+ }
101
+
102
+ interface TopupMetadataProps {
103
+ amount: string
104
+ token: string
105
+ onBehalf: string
106
+ }
107
+
108
+ interface BridgeMetadataProps {
109
+ amount: string
110
+ receiver: string
111
+ fromToken: string
112
+ toToken: string
113
+ toChainId: string
114
+ bridgeFee: string
115
+ nativeToken: string
116
+ version?: string
117
+ provider: string
118
+ }
119
+
120
+ interface SwapMetadataProps {
121
+ sellToken: string
122
+ buyToken: string
123
+ sellAmount: string
124
+ buyAmount: string
125
+ receiver: string
126
+ protocol?: string
127
+ }
128
+
129
+ interface MetadataProps {
130
+ type: MetadataTypes
131
+ encodedData: string
132
+ version?: string
133
+ }
133
134
 
134
135
  interface ITokenPrice {
135
- address: string;
136
- chain_id: string;
137
- name: string;
138
- symbol: string;
139
- decimals: number;
140
- logo_url: string;
141
- price: string;
142
- coingecko_id: string;
143
- sparkline_price_7d: number[];
136
+ address: string
137
+ chain_id: string
138
+ name: string
139
+ symbol: string
140
+ decimals: number
141
+ logo_url: string
142
+ price: string
143
+ coingecko_id: string
144
+ sparkline_price_7d: number[]
144
145
  }
145
146
  }
146
147
 
147
- export {};
148
+ export {}