@instadapp/avocado-base 0.0.0-dev.21292ef → 0.0.0-dev.22b3a7d

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,
@@ -64,6 +64,33 @@ const avocadoStaging = defineChain({
64
64
  blockExplorers: {
65
65
  default: { name: 'Avoscan', url: AVO_STAGING_EXPLORER_URL },
66
66
  },
67
+
68
+ })
69
+
70
+ const sonic = defineChain({
71
+ id: 146,
72
+ name: 'Sonic',
73
+ nativeCurrency: {
74
+ decimals: 18,
75
+ name: 'Sonic',
76
+ symbol: 'S',
77
+ },
78
+ rpcUrls: {
79
+ default: { http: ['https://rpc.soniclabs.com'] },
80
+ },
81
+ blockExplorers: {
82
+ default: {
83
+ name: 'Sonic Explorer',
84
+ url: 'https://sonicscan.org',
85
+ },
86
+ },
87
+ testnet: false,
88
+ contracts: {
89
+ multicall3: {
90
+ address: '0x266F33e4E7B44Af88F5B9171d3b5222cc1502b27',
91
+ blockCreated: 269715,
92
+ },
93
+ },
67
94
  })
68
95
 
69
96
  export const networks: Network[] = [
@@ -88,8 +115,8 @@ export const networks: Network[] = [
88
115
  params: {
89
116
  chainName: 'Matic(Polygon) Mainnet',
90
117
  nativeCurrency: {
91
- name: 'Matic',
92
- symbol: 'MATIC',
118
+ name: 'POL (ex-MATIC)',
119
+ symbol: 'POL',
93
120
  decimals: 18,
94
121
  },
95
122
  rpcUrls: ['https://polygon-rpc.com'],
@@ -508,6 +535,24 @@ export const networks: Network[] = [
508
535
  ankrName: 'linea',
509
536
  },
510
537
  // {
538
+ // name: sonic.name,
539
+ // chainId: sonic.id,
540
+ // explorerUrl: sonic.blockExplorers.default.url,
541
+ // legacySupported: false,
542
+ // viemChain: sonic,
543
+ // color: '#78d64b',
544
+ // apiURL: null,
545
+ // fakeTransactionHash: '0xc8fe01a980987295c36e898b4681fa8c937eb8dfd48a3ae080956b36a66195ee',
546
+ // get serverRpcUrl() {
547
+ // return process.env?.SONIC_RPC_URL || this.params.rpcUrls[0]
548
+ // },
549
+ // params: {
550
+ // rpcUrls: sonic.rpcUrls.default.http as any,
551
+ // chainName: sonic.name,
552
+ // nativeCurrency: sonic.nativeCurrency,
553
+ // },
554
+ // },
555
+ // {
511
556
  // name: "Manta Pacific",
512
557
  // chainId: 169,
513
558
  // explorerUrl: "https://pacific-explorer.manta.network",
@@ -614,7 +659,7 @@ export function getRpcURLByChainId(chainId: ChainId | number | string) {
614
659
  const network = getNetworkByChainId(chainId)
615
660
  return network.params.rpcUrls[0]
616
661
  }
617
- catch (e) {
662
+ catch {
618
663
  return ''
619
664
  }
620
665
  }
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
@@ -22,6 +22,7 @@ declare global {
22
22
  | 34443
23
23
  | 81457
24
24
  | 59144
25
+ | 146
25
26
 
26
27
  type ISlackMessageType = 'danger' | 'error' | 'success' | 'banner'
27
28