@yodlpay/tokenlists 1.1.5 → 1.1.7
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/dist/abis-ts.cjs +6938 -0
- package/dist/abis-ts.d.ts +5396 -0
- package/dist/abis-ts.js +6935 -0
- package/dist/chains.cjs +195 -0
- package/dist/chains.d.ts +45 -0
- package/dist/chains.js +185 -0
- package/dist/index.cjs +21 -21
- package/dist/index.d.ts +3 -10909
- package/dist/index.js +3 -1
- package/dist/tokens.cjs +12583 -0
- package/dist/tokens.d.ts +118 -0
- package/dist/tokens.js +12573 -0
- package/package.json +19 -2
- package/dist/ccip-CDL0XQMl.cjs +0 -184
- package/dist/ccip-Dv296j_Q.js +0 -181
- package/dist/index-BqYpjiy9.cjs +0 -40120
- package/dist/index-CIWcrB8e.js +0 -40089
- package/dist/tokens/tokenlist-featured.json +0 -1137
- package/dist/tokens/tokenlist-generated.json +0 -3318
- package/dist/tokens/tokenlist-overrides.json +0 -265
- package/dist/tokens/tokenlist.schema.json +0 -329
package/dist/chains.cjs
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
+
|
|
3
|
+
var viem = require('viem');
|
|
4
|
+
var chains$1 = require('viem/chains');
|
|
5
|
+
|
|
6
|
+
// Chain definitions using viem chains as base
|
|
7
|
+
const chains = [
|
|
8
|
+
{
|
|
9
|
+
...chains$1.mainnet,
|
|
10
|
+
shortName: 'eth',
|
|
11
|
+
coinGeckoPlatform: 'ethereum',
|
|
12
|
+
logoUri: 'https://kuezuu6pdfndtxdd.public.blob.vercel-storage.com/chains/1/logo.svg',
|
|
13
|
+
wrappedNativeToken: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
|
|
14
|
+
feeTreasury: '0x9C48d180e4eEE0dA2A899EE1E4c533cA5e92db77',
|
|
15
|
+
router: {
|
|
16
|
+
address: '0x0487C9fE08dB1c21a9c3Cf373a4d93623B8169Ee',
|
|
17
|
+
version: '0.8',
|
|
18
|
+
fee: '0.002'
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
...chains$1.arbitrum,
|
|
23
|
+
shortName: 'arb1',
|
|
24
|
+
coinGeckoPlatform: 'arbitrum-one',
|
|
25
|
+
logoUri: 'https://kuezuu6pdfndtxdd.public.blob.vercel-storage.com/chains/42161/logo.svg',
|
|
26
|
+
wrappedNativeToken: '0x82aF49447D8a07e3bd95BD0d56f35241523fBab1',
|
|
27
|
+
feeTreasury: '0x5f0947253a8218894af13438ac2e2e0ced30d234',
|
|
28
|
+
router: {
|
|
29
|
+
address: '0x1F7c4f45c8A398381616C74269f9fB8060E3DdC9',
|
|
30
|
+
version: '0.8',
|
|
31
|
+
fee: '0.002'
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
...chains$1.arbitrumSepolia,
|
|
36
|
+
shortName: 'arbitrum-sepolia',
|
|
37
|
+
logoUri: 'https://kuezuu6pdfndtxdd.public.blob.vercel-storage.com/chains/42161/logo.svg',
|
|
38
|
+
wrappedNativeToken: '0x82aF49447D8a07e3bd95BD0d56f35241523fBab1',
|
|
39
|
+
feeTreasury: '0x5f0947253a8218894af13438ac2e2e0ced30d234',
|
|
40
|
+
router: {
|
|
41
|
+
address: '0x1F7c4f45c8A398381616C74269f9fB8060E3DdC9',
|
|
42
|
+
version: '0.8',
|
|
43
|
+
fee: '0.002'
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
...chains$1.bscTestnet,
|
|
48
|
+
shortName: 'bsc-testnet',
|
|
49
|
+
logoUri: 'https://kuezuu6pdfndtxdd.public.blob.vercel-storage.com/chains/56/logo.svg',
|
|
50
|
+
wrappedNativeToken: '0x82aF49447D8a07e3bd95BD0d56f35241523fBab1',
|
|
51
|
+
feeTreasury: '0x5f0947253a8218894af13438ac2e2e0ced30d234',
|
|
52
|
+
router: {
|
|
53
|
+
address: '0x1F7c4f45c8A398381616C74269f9fB8060E3DdC9',
|
|
54
|
+
version: '0.8',
|
|
55
|
+
fee: '0.002'
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
...chains$1.optimism,
|
|
60
|
+
shortName: 'oeth',
|
|
61
|
+
coinGeckoPlatform: 'optimistic-ethereum',
|
|
62
|
+
logoUri: 'https://kuezuu6pdfndtxdd.public.blob.vercel-storage.com/chains/10/logo.svg',
|
|
63
|
+
wrappedNativeToken: '0x4200000000000000000000000000000000000006',
|
|
64
|
+
feeTreasury: '0x5f0947253a8218894af13438ac2e2e0ced30d234',
|
|
65
|
+
router: {
|
|
66
|
+
address: '0x1F7c4f45c8A398381616C74269f9fB8060E3DdC9',
|
|
67
|
+
version: '0.8',
|
|
68
|
+
fee: '0.002'
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
...chains$1.gnosis,
|
|
73
|
+
shortName: 'gno',
|
|
74
|
+
coinGeckoPlatform: 'xdai',
|
|
75
|
+
logoUri: 'https://kuezuu6pdfndtxdd.public.blob.vercel-storage.com/chains/100/logo.svg',
|
|
76
|
+
wrappedNativeToken: '0xe91d153e0b41518a2ce8dd3d7944fa863463a97d',
|
|
77
|
+
feeTreasury: '0x775aaf73a50C25eEBd308BBb9C34C73D081B423b',
|
|
78
|
+
router: {
|
|
79
|
+
address: '0x3160aE35D64c03182cAe1d64626894b563123E94',
|
|
80
|
+
version: '0.8',
|
|
81
|
+
fee: '0.002'
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
...chains$1.base,
|
|
86
|
+
shortName: 'base',
|
|
87
|
+
coinGeckoPlatform: 'base',
|
|
88
|
+
logoUri: 'https://kuezuu6pdfndtxdd.public.blob.vercel-storage.com/chains/8453/logo.svg',
|
|
89
|
+
wrappedNativeToken: '0x4200000000000000000000000000000000000006',
|
|
90
|
+
feeTreasury: '0x46959a8a332eca1a05Bd4F18115b8F2E1C2F2f05',
|
|
91
|
+
router: {
|
|
92
|
+
address: '0x1F7c4f45c8A398381616C74269f9fB8060E3DdC9',
|
|
93
|
+
version: '0.8',
|
|
94
|
+
fee: '0.002'
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
...chains$1.polygon,
|
|
99
|
+
shortName: 'pol',
|
|
100
|
+
coinGeckoPlatform: 'polygon-pos',
|
|
101
|
+
logoUri: 'https://kuezuu6pdfndtxdd.public.blob.vercel-storage.com/chains/137/logo.svg',
|
|
102
|
+
wrappedNativeToken: '0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270',
|
|
103
|
+
feeTreasury: '0x5f0947253a8218894af13438ac2e2E0CeD30d234',
|
|
104
|
+
router: {
|
|
105
|
+
address: '0x1F7c4f45c8A398381616C74269f9fB8060E3DdC9',
|
|
106
|
+
version: '0.8',
|
|
107
|
+
fee: '0.002'
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
...chains$1.bsc,
|
|
112
|
+
shortName: 'bsc',
|
|
113
|
+
coinGeckoPlatform: 'binance-smart-chain',
|
|
114
|
+
logoUri: 'https://kuezuu6pdfndtxdd.public.blob.vercel-storage.com/chains/56/logo.svg',
|
|
115
|
+
wrappedNativeToken: '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c',
|
|
116
|
+
feeTreasury: '0x698609f1ae8E0ce7e65d3028d1f00297A6bF21e5',
|
|
117
|
+
router: {
|
|
118
|
+
address: '0x1F7c4f45c8A398381616C74269f9fB8060E3DdC9',
|
|
119
|
+
version: '0.8',
|
|
120
|
+
fee: '0.002'
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
];
|
|
124
|
+
// Map for quick lookups by chainId
|
|
125
|
+
const chainById = new Map(chains.map((c)=>[
|
|
126
|
+
c.id,
|
|
127
|
+
c
|
|
128
|
+
]));
|
|
129
|
+
// Helper functions
|
|
130
|
+
function getChainById(chainId) {
|
|
131
|
+
const chain = chainById.get(chainId);
|
|
132
|
+
if (!chain) {
|
|
133
|
+
throw new Error(`Chain with id ${chainId} not found`);
|
|
134
|
+
}
|
|
135
|
+
return chain;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Native token placeholder address (ERC-7528 standard)
|
|
139
|
+
const NATIVE_TOKEN_ADDRESS = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE';
|
|
140
|
+
/**
|
|
141
|
+
* Check if an address is the native token placeholder address
|
|
142
|
+
*/ function isNativeToken(address) {
|
|
143
|
+
return viem.isAddressEqual(address, NATIVE_TOKEN_ADDRESS);
|
|
144
|
+
}
|
|
145
|
+
// Cache for PublicClients by chainId
|
|
146
|
+
const clientCache = new Map();
|
|
147
|
+
/**
|
|
148
|
+
* Get or create a PublicClient for a given chain using viem's chain definitions
|
|
149
|
+
*/ function getPublicClient(chainId) {
|
|
150
|
+
const cached = clientCache.get(chainId);
|
|
151
|
+
if (cached) return cached;
|
|
152
|
+
const chain = getChainById(chainId);
|
|
153
|
+
const rpcUrl = chain.rpcUrls.default.http[0];
|
|
154
|
+
const client = viem.createPublicClient({
|
|
155
|
+
chain,
|
|
156
|
+
transport: viem.http(rpcUrl, {
|
|
157
|
+
timeout: 30000,
|
|
158
|
+
retryCount: 3,
|
|
159
|
+
retryDelay: 1000
|
|
160
|
+
})
|
|
161
|
+
});
|
|
162
|
+
clientCache.set(chainId, client);
|
|
163
|
+
return client;
|
|
164
|
+
}
|
|
165
|
+
function getShortNames() {
|
|
166
|
+
return chains.map((chain)=>chain.shortName);
|
|
167
|
+
}
|
|
168
|
+
function getNativeToken(chainId) {
|
|
169
|
+
return getChainById(chainId).nativeCurrency.symbol;
|
|
170
|
+
}
|
|
171
|
+
function getRouter(chainId) {
|
|
172
|
+
return {
|
|
173
|
+
...getChainById(chainId).router
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
function getRouterByAddress(address, chainId) {
|
|
177
|
+
const matchingChain = chains.find((chain)=>{
|
|
178
|
+
const addressMatch = viem.isAddressEqual(chain.router.address, address);
|
|
179
|
+
return chainId ? addressMatch && chain.id === chainId : addressMatch;
|
|
180
|
+
});
|
|
181
|
+
if (!matchingChain) throw new Error(`Router with address ${address} not found`);
|
|
182
|
+
return {
|
|
183
|
+
...matchingChain.router
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
exports.NATIVE_TOKEN_ADDRESS = NATIVE_TOKEN_ADDRESS;
|
|
188
|
+
exports.chains = chains;
|
|
189
|
+
exports.getChainById = getChainById;
|
|
190
|
+
exports.getNativeToken = getNativeToken;
|
|
191
|
+
exports.getPublicClient = getPublicClient;
|
|
192
|
+
exports.getRouter = getRouter;
|
|
193
|
+
exports.getRouterByAddress = getRouterByAddress;
|
|
194
|
+
exports.getShortNames = getShortNames;
|
|
195
|
+
exports.isNativeToken = isNativeToken;
|
package/dist/chains.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Address, Chain, PublicClient } from 'viem';
|
|
2
|
+
|
|
3
|
+
type AbiVersion = 'test' | '0.1' | '0.2' | '0.3' | '0.4' | '0.5' | '0.6' | '0.7' | '0.8' | '0.9';
|
|
4
|
+
|
|
5
|
+
interface RouterConfig {
|
|
6
|
+
address: Address;
|
|
7
|
+
version: AbiVersion;
|
|
8
|
+
fee: string;
|
|
9
|
+
}
|
|
10
|
+
interface YodlChainExtension {
|
|
11
|
+
shortName: string;
|
|
12
|
+
coinGeckoPlatform?: string;
|
|
13
|
+
logoUri: string;
|
|
14
|
+
wrappedNativeToken: Address;
|
|
15
|
+
feeTreasury: Address;
|
|
16
|
+
router: RouterConfig;
|
|
17
|
+
}
|
|
18
|
+
type YodlChain = Chain & YodlChainExtension;
|
|
19
|
+
declare const chains: YodlChain[];
|
|
20
|
+
declare function getChainById(chainId: number): YodlChain;
|
|
21
|
+
|
|
22
|
+
declare const NATIVE_TOKEN_ADDRESS: Address;
|
|
23
|
+
/**
|
|
24
|
+
* Check if an address is the native token placeholder address
|
|
25
|
+
*/
|
|
26
|
+
declare function isNativeToken(address: string): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Get or create a PublicClient for a given chain using viem's chain definitions
|
|
29
|
+
*/
|
|
30
|
+
declare function getPublicClient(chainId: number): PublicClient | null;
|
|
31
|
+
declare function getShortNames(): string[];
|
|
32
|
+
declare function getNativeToken(chainId: number): string;
|
|
33
|
+
declare function getRouter(chainId: number): {
|
|
34
|
+
address: Address;
|
|
35
|
+
version: AbiVersion;
|
|
36
|
+
fee: string;
|
|
37
|
+
};
|
|
38
|
+
declare function getRouterByAddress(address: string, chainId?: number): {
|
|
39
|
+
address: Address;
|
|
40
|
+
version: AbiVersion;
|
|
41
|
+
fee: string;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export { NATIVE_TOKEN_ADDRESS, chains, getChainById, getNativeToken, getPublicClient, getRouter, getRouterByAddress, getShortNames, isNativeToken };
|
|
45
|
+
export type { RouterConfig, YodlChain, YodlChainExtension };
|
package/dist/chains.js
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { createPublicClient, http, isAddressEqual } from 'viem';
|
|
2
|
+
import { mainnet, arbitrum, arbitrumSepolia, bscTestnet, optimism, gnosis, base, polygon, bsc } from 'viem/chains';
|
|
3
|
+
|
|
4
|
+
// Chain definitions using viem chains as base
|
|
5
|
+
const chains = [
|
|
6
|
+
{
|
|
7
|
+
...mainnet,
|
|
8
|
+
shortName: 'eth',
|
|
9
|
+
coinGeckoPlatform: 'ethereum',
|
|
10
|
+
logoUri: 'https://kuezuu6pdfndtxdd.public.blob.vercel-storage.com/chains/1/logo.svg',
|
|
11
|
+
wrappedNativeToken: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
|
|
12
|
+
feeTreasury: '0x9C48d180e4eEE0dA2A899EE1E4c533cA5e92db77',
|
|
13
|
+
router: {
|
|
14
|
+
address: '0x0487C9fE08dB1c21a9c3Cf373a4d93623B8169Ee',
|
|
15
|
+
version: '0.8',
|
|
16
|
+
fee: '0.002'
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
...arbitrum,
|
|
21
|
+
shortName: 'arb1',
|
|
22
|
+
coinGeckoPlatform: 'arbitrum-one',
|
|
23
|
+
logoUri: 'https://kuezuu6pdfndtxdd.public.blob.vercel-storage.com/chains/42161/logo.svg',
|
|
24
|
+
wrappedNativeToken: '0x82aF49447D8a07e3bd95BD0d56f35241523fBab1',
|
|
25
|
+
feeTreasury: '0x5f0947253a8218894af13438ac2e2e0ced30d234',
|
|
26
|
+
router: {
|
|
27
|
+
address: '0x1F7c4f45c8A398381616C74269f9fB8060E3DdC9',
|
|
28
|
+
version: '0.8',
|
|
29
|
+
fee: '0.002'
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
...arbitrumSepolia,
|
|
34
|
+
shortName: 'arbitrum-sepolia',
|
|
35
|
+
logoUri: 'https://kuezuu6pdfndtxdd.public.blob.vercel-storage.com/chains/42161/logo.svg',
|
|
36
|
+
wrappedNativeToken: '0x82aF49447D8a07e3bd95BD0d56f35241523fBab1',
|
|
37
|
+
feeTreasury: '0x5f0947253a8218894af13438ac2e2e0ced30d234',
|
|
38
|
+
router: {
|
|
39
|
+
address: '0x1F7c4f45c8A398381616C74269f9fB8060E3DdC9',
|
|
40
|
+
version: '0.8',
|
|
41
|
+
fee: '0.002'
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
...bscTestnet,
|
|
46
|
+
shortName: 'bsc-testnet',
|
|
47
|
+
logoUri: 'https://kuezuu6pdfndtxdd.public.blob.vercel-storage.com/chains/56/logo.svg',
|
|
48
|
+
wrappedNativeToken: '0x82aF49447D8a07e3bd95BD0d56f35241523fBab1',
|
|
49
|
+
feeTreasury: '0x5f0947253a8218894af13438ac2e2e0ced30d234',
|
|
50
|
+
router: {
|
|
51
|
+
address: '0x1F7c4f45c8A398381616C74269f9fB8060E3DdC9',
|
|
52
|
+
version: '0.8',
|
|
53
|
+
fee: '0.002'
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
...optimism,
|
|
58
|
+
shortName: 'oeth',
|
|
59
|
+
coinGeckoPlatform: 'optimistic-ethereum',
|
|
60
|
+
logoUri: 'https://kuezuu6pdfndtxdd.public.blob.vercel-storage.com/chains/10/logo.svg',
|
|
61
|
+
wrappedNativeToken: '0x4200000000000000000000000000000000000006',
|
|
62
|
+
feeTreasury: '0x5f0947253a8218894af13438ac2e2e0ced30d234',
|
|
63
|
+
router: {
|
|
64
|
+
address: '0x1F7c4f45c8A398381616C74269f9fB8060E3DdC9',
|
|
65
|
+
version: '0.8',
|
|
66
|
+
fee: '0.002'
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
...gnosis,
|
|
71
|
+
shortName: 'gno',
|
|
72
|
+
coinGeckoPlatform: 'xdai',
|
|
73
|
+
logoUri: 'https://kuezuu6pdfndtxdd.public.blob.vercel-storage.com/chains/100/logo.svg',
|
|
74
|
+
wrappedNativeToken: '0xe91d153e0b41518a2ce8dd3d7944fa863463a97d',
|
|
75
|
+
feeTreasury: '0x775aaf73a50C25eEBd308BBb9C34C73D081B423b',
|
|
76
|
+
router: {
|
|
77
|
+
address: '0x3160aE35D64c03182cAe1d64626894b563123E94',
|
|
78
|
+
version: '0.8',
|
|
79
|
+
fee: '0.002'
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
...base,
|
|
84
|
+
shortName: 'base',
|
|
85
|
+
coinGeckoPlatform: 'base',
|
|
86
|
+
logoUri: 'https://kuezuu6pdfndtxdd.public.blob.vercel-storage.com/chains/8453/logo.svg',
|
|
87
|
+
wrappedNativeToken: '0x4200000000000000000000000000000000000006',
|
|
88
|
+
feeTreasury: '0x46959a8a332eca1a05Bd4F18115b8F2E1C2F2f05',
|
|
89
|
+
router: {
|
|
90
|
+
address: '0x1F7c4f45c8A398381616C74269f9fB8060E3DdC9',
|
|
91
|
+
version: '0.8',
|
|
92
|
+
fee: '0.002'
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
...polygon,
|
|
97
|
+
shortName: 'pol',
|
|
98
|
+
coinGeckoPlatform: 'polygon-pos',
|
|
99
|
+
logoUri: 'https://kuezuu6pdfndtxdd.public.blob.vercel-storage.com/chains/137/logo.svg',
|
|
100
|
+
wrappedNativeToken: '0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270',
|
|
101
|
+
feeTreasury: '0x5f0947253a8218894af13438ac2e2E0CeD30d234',
|
|
102
|
+
router: {
|
|
103
|
+
address: '0x1F7c4f45c8A398381616C74269f9fB8060E3DdC9',
|
|
104
|
+
version: '0.8',
|
|
105
|
+
fee: '0.002'
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
...bsc,
|
|
110
|
+
shortName: 'bsc',
|
|
111
|
+
coinGeckoPlatform: 'binance-smart-chain',
|
|
112
|
+
logoUri: 'https://kuezuu6pdfndtxdd.public.blob.vercel-storage.com/chains/56/logo.svg',
|
|
113
|
+
wrappedNativeToken: '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c',
|
|
114
|
+
feeTreasury: '0x698609f1ae8E0ce7e65d3028d1f00297A6bF21e5',
|
|
115
|
+
router: {
|
|
116
|
+
address: '0x1F7c4f45c8A398381616C74269f9fB8060E3DdC9',
|
|
117
|
+
version: '0.8',
|
|
118
|
+
fee: '0.002'
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
];
|
|
122
|
+
// Map for quick lookups by chainId
|
|
123
|
+
const chainById = new Map(chains.map((c)=>[
|
|
124
|
+
c.id,
|
|
125
|
+
c
|
|
126
|
+
]));
|
|
127
|
+
// Helper functions
|
|
128
|
+
function getChainById(chainId) {
|
|
129
|
+
const chain = chainById.get(chainId);
|
|
130
|
+
if (!chain) {
|
|
131
|
+
throw new Error(`Chain with id ${chainId} not found`);
|
|
132
|
+
}
|
|
133
|
+
return chain;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Native token placeholder address (ERC-7528 standard)
|
|
137
|
+
const NATIVE_TOKEN_ADDRESS = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE';
|
|
138
|
+
/**
|
|
139
|
+
* Check if an address is the native token placeholder address
|
|
140
|
+
*/ function isNativeToken(address) {
|
|
141
|
+
return isAddressEqual(address, NATIVE_TOKEN_ADDRESS);
|
|
142
|
+
}
|
|
143
|
+
// Cache for PublicClients by chainId
|
|
144
|
+
const clientCache = new Map();
|
|
145
|
+
/**
|
|
146
|
+
* Get or create a PublicClient for a given chain using viem's chain definitions
|
|
147
|
+
*/ function getPublicClient(chainId) {
|
|
148
|
+
const cached = clientCache.get(chainId);
|
|
149
|
+
if (cached) return cached;
|
|
150
|
+
const chain = getChainById(chainId);
|
|
151
|
+
const rpcUrl = chain.rpcUrls.default.http[0];
|
|
152
|
+
const client = createPublicClient({
|
|
153
|
+
chain,
|
|
154
|
+
transport: http(rpcUrl, {
|
|
155
|
+
timeout: 30000,
|
|
156
|
+
retryCount: 3,
|
|
157
|
+
retryDelay: 1000
|
|
158
|
+
})
|
|
159
|
+
});
|
|
160
|
+
clientCache.set(chainId, client);
|
|
161
|
+
return client;
|
|
162
|
+
}
|
|
163
|
+
function getShortNames() {
|
|
164
|
+
return chains.map((chain)=>chain.shortName);
|
|
165
|
+
}
|
|
166
|
+
function getNativeToken(chainId) {
|
|
167
|
+
return getChainById(chainId).nativeCurrency.symbol;
|
|
168
|
+
}
|
|
169
|
+
function getRouter(chainId) {
|
|
170
|
+
return {
|
|
171
|
+
...getChainById(chainId).router
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
function getRouterByAddress(address, chainId) {
|
|
175
|
+
const matchingChain = chains.find((chain)=>{
|
|
176
|
+
const addressMatch = isAddressEqual(chain.router.address, address);
|
|
177
|
+
return chainId ? addressMatch && chain.id === chainId : addressMatch;
|
|
178
|
+
});
|
|
179
|
+
if (!matchingChain) throw new Error(`Router with address ${address} not found`);
|
|
180
|
+
return {
|
|
181
|
+
...matchingChain.router
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export { NATIVE_TOKEN_ADDRESS, chains, getChainById, getNativeToken, getPublicClient, getRouter, getRouterByAddress, getShortNames, isNativeToken };
|
package/dist/index.cjs
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var abisTs_cjs = require('./abis-ts.cjs');
|
|
4
|
+
var tokens_cjs = require('./tokens.cjs');
|
|
5
|
+
var chains_cjs = require('./chains.cjs');
|
|
4
6
|
|
|
5
7
|
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
exports.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
exports.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
exports.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
exports.tokenlist = index.tokenlist;
|
|
26
|
-
exports.validateTokenList = index.validateTokenList;
|
|
9
|
+
Object.keys(abisTs_cjs).forEach(function (k) {
|
|
10
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () { return abisTs_cjs[k]; }
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
Object.keys(tokens_cjs).forEach(function (k) {
|
|
16
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () { return tokens_cjs[k]; }
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
Object.keys(chains_cjs).forEach(function (k) {
|
|
22
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: function () { return chains_cjs[k]; }
|
|
25
|
+
});
|
|
26
|
+
});
|