@vleap/warps-adapter-evm 0.2.0-alpha.22 → 0.2.0-alpha.24
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/index.d.cts +18 -21
- package/dist/index.d.ts +18 -21
- package/dist/index.js +243 -235
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +239 -234
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -26,6 +26,7 @@ __export(index_exports, {
|
|
|
26
26
|
EvmExplorers: () => EvmExplorers,
|
|
27
27
|
EvmLogoService: () => EvmLogoService,
|
|
28
28
|
ExplorerUrls: () => ExplorerUrls,
|
|
29
|
+
KnownTokens: () => KnownTokens,
|
|
29
30
|
NativeTokenArb: () => NativeTokenArb,
|
|
30
31
|
NativeTokenBase: () => NativeTokenBase,
|
|
31
32
|
NativeTokenEth: () => NativeTokenEth,
|
|
@@ -36,11 +37,13 @@ __export(index_exports, {
|
|
|
36
37
|
WarpEvmResults: () => WarpEvmResults,
|
|
37
38
|
WarpEvmSerializer: () => WarpEvmSerializer,
|
|
38
39
|
createEvmAdapter: () => createEvmAdapter,
|
|
40
|
+
findKnownTokenById: () => findKnownTokenById,
|
|
39
41
|
getAllEvmAdapters: () => getAllEvmAdapters,
|
|
40
42
|
getAllEvmChainNames: () => getAllEvmChainNames,
|
|
41
43
|
getArbitrumAdapter: () => getArbitrumAdapter,
|
|
42
44
|
getBaseAdapter: () => getBaseAdapter,
|
|
43
|
-
getEthereumAdapter: () => getEthereumAdapter
|
|
45
|
+
getEthereumAdapter: () => getEthereumAdapter,
|
|
46
|
+
getKnownTokensForChain: () => getKnownTokensForChain
|
|
44
47
|
});
|
|
45
48
|
module.exports = __toCommonJS(index_exports);
|
|
46
49
|
|
|
@@ -74,7 +77,7 @@ var FALLBACK_LOGOS = {
|
|
|
74
77
|
"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913": "https://assets.coingecko.com/coins/images/6319/small/USD_Coin_icon.png",
|
|
75
78
|
"0x4200000000000000000000000000000000000006": "https://assets.coingecko.com/coins/images/2518/small/weth.png",
|
|
76
79
|
"0x036CbD53842c5426634e7929541eC2318f3dCF7e": "https://assets.coingecko.com/coins/images/6319/small/USD_Coin_icon.png",
|
|
77
|
-
"0x808456652fdb597867f38412077A9182bf77359F": "https://assets.coingecko.com/coins/images/
|
|
80
|
+
"0x808456652fdb597867f38412077A9182bf77359F": "https://assets.coingecko.com/coins/images/26045/standard/euro.png",
|
|
78
81
|
"0xcbB7C0006F23900c38EB856149F799620fcb8A4a": "https://assets.coingecko.com/coins/images/7598/small/wrapped_bitcoin_wbtc.png"
|
|
79
82
|
}
|
|
80
83
|
};
|
|
@@ -216,6 +219,143 @@ var EvmLogoService = class {
|
|
|
216
219
|
}
|
|
217
220
|
};
|
|
218
221
|
|
|
222
|
+
// src/tokens.ts
|
|
223
|
+
var KnownTokens = {
|
|
224
|
+
ethereum: {
|
|
225
|
+
mainnet: [
|
|
226
|
+
{
|
|
227
|
+
id: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
228
|
+
name: "USD Coin",
|
|
229
|
+
symbol: "USDC",
|
|
230
|
+
decimals: 6,
|
|
231
|
+
logoUrl: "https://assets.coingecko.com/coins/images/6319/small/USD_Coin_icon.png"
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
id: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
|
|
235
|
+
name: "Tether USD",
|
|
236
|
+
symbol: "USDT",
|
|
237
|
+
decimals: 6,
|
|
238
|
+
logoUrl: "https://assets.coingecko.com/coins/images/325/small/Tether.png"
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
id: "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599",
|
|
242
|
+
name: "Wrapped Bitcoin",
|
|
243
|
+
symbol: "WBTC",
|
|
244
|
+
decimals: 8,
|
|
245
|
+
logoUrl: "https://assets.coingecko.com/coins/images/7598/small/wrapped_bitcoin_wbtc.png"
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
id: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
|
|
249
|
+
name: "Wrapped Ether",
|
|
250
|
+
symbol: "WETH",
|
|
251
|
+
decimals: 18,
|
|
252
|
+
logoUrl: "https://assets.coingecko.com/coins/images/2518/small/weth.png"
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
id: "0x6B175474E89094C44Da98b954EedeAC495271d0F",
|
|
256
|
+
name: "Dai Stablecoin",
|
|
257
|
+
symbol: "DAI",
|
|
258
|
+
decimals: 18,
|
|
259
|
+
logoUrl: "https://assets.coingecko.com/coins/images/9956/small/4943.png"
|
|
260
|
+
}
|
|
261
|
+
],
|
|
262
|
+
testnet: [
|
|
263
|
+
{
|
|
264
|
+
id: "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",
|
|
265
|
+
name: "USD Coin",
|
|
266
|
+
symbol: "USDC",
|
|
267
|
+
decimals: 6,
|
|
268
|
+
logoUrl: "https://assets.coingecko.com/coins/images/6319/small/USD_Coin_icon.png"
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
id: "0x7169D38820dfd117C3FA1f22a697dBA58d90BA06",
|
|
272
|
+
name: "Tether USD",
|
|
273
|
+
symbol: "USDT",
|
|
274
|
+
decimals: 6,
|
|
275
|
+
logoUrl: "https://assets.coingecko.com/coins/images/325/small/Tether.png"
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
id: "0x7b79995e5f793A07Bc00c21412e50Ecae098E7f9",
|
|
279
|
+
name: "Wrapped Ether",
|
|
280
|
+
symbol: "WETH",
|
|
281
|
+
decimals: 18,
|
|
282
|
+
logoUrl: "https://assets.coingecko.com/coins/images/2518/small/weth.png"
|
|
283
|
+
}
|
|
284
|
+
]
|
|
285
|
+
},
|
|
286
|
+
arbitrum: {
|
|
287
|
+
mainnet: [
|
|
288
|
+
{
|
|
289
|
+
id: "0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8",
|
|
290
|
+
name: "USD Coin",
|
|
291
|
+
symbol: "USDC",
|
|
292
|
+
decimals: 6,
|
|
293
|
+
logoUrl: "https://assets.coingecko.com/coins/images/6319/small/USD_Coin_icon.png"
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
id: "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",
|
|
297
|
+
name: "Tether USD",
|
|
298
|
+
symbol: "USDT",
|
|
299
|
+
decimals: 6,
|
|
300
|
+
logoUrl: "https://assets.coingecko.com/coins/images/325/small/Tether.png"
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
id: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
|
|
304
|
+
name: "Wrapped Ether",
|
|
305
|
+
symbol: "WETH",
|
|
306
|
+
decimals: 18,
|
|
307
|
+
logoUrl: "https://assets.coingecko.com/coins/images/2518/small/weth.png"
|
|
308
|
+
}
|
|
309
|
+
]
|
|
310
|
+
},
|
|
311
|
+
base: {
|
|
312
|
+
mainnet: [
|
|
313
|
+
{
|
|
314
|
+
id: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
315
|
+
name: "USD Coin",
|
|
316
|
+
symbol: "USDC",
|
|
317
|
+
decimals: 6,
|
|
318
|
+
logoUrl: "https://assets.coingecko.com/coins/images/6319/small/USD_Coin_icon.png"
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
id: "0x4200000000000000000000000000000000000006",
|
|
322
|
+
name: "Wrapped Ether",
|
|
323
|
+
symbol: "WETH",
|
|
324
|
+
decimals: 18,
|
|
325
|
+
logoUrl: "https://assets.coingecko.com/coins/images/2518/small/weth.png"
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
id: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
|
|
329
|
+
name: "USD Coin",
|
|
330
|
+
symbol: "USDC",
|
|
331
|
+
decimals: 6,
|
|
332
|
+
logoUrl: "https://assets.coingecko.com/coins/images/6319/small/USD_Coin_icon.png"
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
id: "0x808456652fdb597867f38412077A9182bf77359F",
|
|
336
|
+
name: "Euro Coin",
|
|
337
|
+
symbol: "EURC",
|
|
338
|
+
decimals: 6,
|
|
339
|
+
logoUrl: "https://assets.coingecko.com/coins/images/26045/standard/euro.png"
|
|
340
|
+
},
|
|
341
|
+
{
|
|
342
|
+
id: "0xcbB7C0006F23900c38EB856149F799620fcb8A4a",
|
|
343
|
+
name: "Coinbase Wrapped BTC",
|
|
344
|
+
symbol: "CBETH",
|
|
345
|
+
decimals: 8,
|
|
346
|
+
logoUrl: "https://assets.coingecko.com/coins/images/7598/small/wrapped_bitcoin_wbtc.png"
|
|
347
|
+
}
|
|
348
|
+
]
|
|
349
|
+
}
|
|
350
|
+
};
|
|
351
|
+
var findKnownTokenById = (chainName, id, env = "mainnet") => {
|
|
352
|
+
const chainTokens = KnownTokens[chainName]?.[env] || [];
|
|
353
|
+
return chainTokens.find((token) => token.id === id) || null;
|
|
354
|
+
};
|
|
355
|
+
var getKnownTokensForChain = (chainName, env = "mainnet") => {
|
|
356
|
+
return KnownTokens[chainName]?.[env] || [];
|
|
357
|
+
};
|
|
358
|
+
|
|
219
359
|
// src/WarpEvmDataLoader.ts
|
|
220
360
|
var ERC20_ABI = [
|
|
221
361
|
"function balanceOf(address owner) view returns (uint256)",
|
|
@@ -224,111 +364,6 @@ var ERC20_ABI = [
|
|
|
224
364
|
"function symbol() view returns (string)",
|
|
225
365
|
"function totalSupply() view returns (uint256)"
|
|
226
366
|
];
|
|
227
|
-
var KNOWN_TOKENS = {
|
|
228
|
-
ethereum: {
|
|
229
|
-
"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48": {
|
|
230
|
-
name: "USD Coin",
|
|
231
|
-
symbol: "USDC",
|
|
232
|
-
decimals: 6,
|
|
233
|
-
logoUrl: "https://assets.coingecko.com/coins/images/6319/small/USD_Coin_icon.png"
|
|
234
|
-
},
|
|
235
|
-
"0xdAC17F958D2ee523a2206206994597C13D831ec7": {
|
|
236
|
-
name: "Tether USD",
|
|
237
|
-
symbol: "USDT",
|
|
238
|
-
decimals: 6,
|
|
239
|
-
logoUrl: "https://assets.coingecko.com/coins/images/325/small/Tether.png"
|
|
240
|
-
},
|
|
241
|
-
"0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599": {
|
|
242
|
-
name: "Wrapped Bitcoin",
|
|
243
|
-
symbol: "WBTC",
|
|
244
|
-
decimals: 8,
|
|
245
|
-
logoUrl: "https://assets.coingecko.com/coins/images/7598/small/wrapped_bitcoin_wbtc.png"
|
|
246
|
-
},
|
|
247
|
-
"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2": {
|
|
248
|
-
name: "Wrapped Ether",
|
|
249
|
-
symbol: "WETH",
|
|
250
|
-
decimals: 18,
|
|
251
|
-
logoUrl: "https://assets.coingecko.com/coins/images/2518/small/weth.png"
|
|
252
|
-
},
|
|
253
|
-
"0x6B175474E89094C44Da98b954EedeAC495271d0F": {
|
|
254
|
-
name: "Dai Stablecoin",
|
|
255
|
-
symbol: "DAI",
|
|
256
|
-
decimals: 18,
|
|
257
|
-
logoUrl: "https://assets.coingecko.com/coins/images/9956/small/4943.png"
|
|
258
|
-
},
|
|
259
|
-
// Sepolia testnet tokens
|
|
260
|
-
"0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238": {
|
|
261
|
-
name: "USD Coin",
|
|
262
|
-
symbol: "USDC",
|
|
263
|
-
decimals: 6,
|
|
264
|
-
logoUrl: "https://assets.coingecko.com/coins/images/6319/small/USD_Coin_icon.png"
|
|
265
|
-
},
|
|
266
|
-
"0x7169D38820dfd117C3FA1f22a697dBA58d90BA06": {
|
|
267
|
-
name: "Tether USD",
|
|
268
|
-
symbol: "USDT",
|
|
269
|
-
decimals: 6,
|
|
270
|
-
logoUrl: "https://assets.coingecko.com/coins/images/325/small/Tether.png"
|
|
271
|
-
},
|
|
272
|
-
"0x7b79995e5f793A07Bc00c21412e50Ecae098E7f9": {
|
|
273
|
-
name: "Wrapped Ether",
|
|
274
|
-
symbol: "WETH",
|
|
275
|
-
decimals: 18,
|
|
276
|
-
logoUrl: "https://assets.coingecko.com/coins/images/2518/small/weth.png"
|
|
277
|
-
}
|
|
278
|
-
},
|
|
279
|
-
arbitrum: {
|
|
280
|
-
"0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8": {
|
|
281
|
-
name: "USD Coin",
|
|
282
|
-
symbol: "USDC",
|
|
283
|
-
decimals: 6,
|
|
284
|
-
logoUrl: "https://assets.coingecko.com/coins/images/6319/small/USD_Coin_icon.png"
|
|
285
|
-
},
|
|
286
|
-
"0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9": {
|
|
287
|
-
name: "Tether USD",
|
|
288
|
-
symbol: "USDT",
|
|
289
|
-
decimals: 6,
|
|
290
|
-
logoUrl: "https://assets.coingecko.com/coins/images/325/small/Tether.png"
|
|
291
|
-
},
|
|
292
|
-
"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1": {
|
|
293
|
-
name: "Wrapped Ether",
|
|
294
|
-
symbol: "WETH",
|
|
295
|
-
decimals: 18,
|
|
296
|
-
logoUrl: "https://assets.coingecko.com/coins/images/2518/small/weth.png"
|
|
297
|
-
}
|
|
298
|
-
},
|
|
299
|
-
base: {
|
|
300
|
-
"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913": {
|
|
301
|
-
name: "USD Coin",
|
|
302
|
-
symbol: "USDC",
|
|
303
|
-
decimals: 6,
|
|
304
|
-
logoUrl: "https://assets.coingecko.com/coins/images/6319/small/USD_Coin_icon.png"
|
|
305
|
-
},
|
|
306
|
-
"0x4200000000000000000000000000000000000006": {
|
|
307
|
-
name: "Wrapped Ether",
|
|
308
|
-
symbol: "WETH",
|
|
309
|
-
decimals: 18,
|
|
310
|
-
logoUrl: "https://assets.coingecko.com/coins/images/2518/small/weth.png"
|
|
311
|
-
},
|
|
312
|
-
"0x036CbD53842c5426634e7929541eC2318f3dCF7e": {
|
|
313
|
-
name: "USD Coin",
|
|
314
|
-
symbol: "USDC",
|
|
315
|
-
decimals: 6,
|
|
316
|
-
logoUrl: "https://assets.coingecko.com/coins/images/6319/small/USD_Coin_icon.png"
|
|
317
|
-
},
|
|
318
|
-
"0x808456652fdb597867f38412077A9182bf77359F": {
|
|
319
|
-
name: "Euro Coin",
|
|
320
|
-
symbol: "EURC",
|
|
321
|
-
decimals: 6,
|
|
322
|
-
logoUrl: "https://assets.coingecko.com/coins/images/3318/small/euro-coin.png"
|
|
323
|
-
},
|
|
324
|
-
"0xcbB7C0006F23900c38EB856149F799620fcb8A4a": {
|
|
325
|
-
name: "Coinbase Wrapped BTC",
|
|
326
|
-
symbol: "CBETH",
|
|
327
|
-
decimals: 8,
|
|
328
|
-
logoUrl: "https://assets.coingecko.com/coins/images/7598/small/wrapped_bitcoin_wbtc.png"
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
};
|
|
332
367
|
var WarpEvmDataLoader = class {
|
|
333
368
|
constructor(config, chain) {
|
|
334
369
|
this.config = config;
|
|
@@ -338,47 +373,79 @@ var WarpEvmDataLoader = class {
|
|
|
338
373
|
this.provider = new import_ethers.ethers.JsonRpcProvider(apiUrl, network);
|
|
339
374
|
}
|
|
340
375
|
async getAccount(address) {
|
|
376
|
+
const balance = await this.provider.getBalance(address);
|
|
377
|
+
return {
|
|
378
|
+
chain: this.chain.name,
|
|
379
|
+
address,
|
|
380
|
+
balance
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
async getAccountAssets(address) {
|
|
384
|
+
const account = await this.getAccount(address);
|
|
385
|
+
const tokenBalances = await this.getERC20TokenBalances(address);
|
|
386
|
+
let assets = account.balance > 0 ? [{ ...this.chain.nativeToken, amount: account.balance }] : [];
|
|
387
|
+
for (const tokenBalance of tokenBalances) {
|
|
388
|
+
if (tokenBalance.balance > 0n) {
|
|
389
|
+
const logoUrl = tokenBalance.metadata.logoUrl || await this.getLogoUrl(tokenBalance);
|
|
390
|
+
assets.push({
|
|
391
|
+
chain: this.chain.name,
|
|
392
|
+
identifier: tokenBalance.tokenAddress,
|
|
393
|
+
name: tokenBalance.metadata.name,
|
|
394
|
+
amount: tokenBalance.balance,
|
|
395
|
+
decimals: tokenBalance.metadata.decimals,
|
|
396
|
+
logoUrl: logoUrl || ""
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
return assets;
|
|
401
|
+
}
|
|
402
|
+
async getAsset(identifier) {
|
|
341
403
|
try {
|
|
342
|
-
const
|
|
404
|
+
const metadata = await this.getTokenMetadata(identifier);
|
|
405
|
+
if (!metadata) return null;
|
|
343
406
|
return {
|
|
344
407
|
chain: this.chain.name,
|
|
345
|
-
|
|
346
|
-
|
|
408
|
+
identifier,
|
|
409
|
+
name: metadata.name,
|
|
410
|
+
amount: 0n,
|
|
411
|
+
decimals: metadata.decimals,
|
|
412
|
+
logoUrl: metadata.logoUrl || ""
|
|
347
413
|
};
|
|
348
414
|
} catch (error) {
|
|
349
|
-
|
|
415
|
+
return null;
|
|
350
416
|
}
|
|
351
417
|
}
|
|
352
|
-
async
|
|
418
|
+
async getAction(identifier, awaitCompleted = false) {
|
|
353
419
|
try {
|
|
354
|
-
const
|
|
355
|
-
|
|
356
|
-
const
|
|
357
|
-
const
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
420
|
+
const tx = await this.provider.getTransaction(identifier);
|
|
421
|
+
if (!tx) return null;
|
|
422
|
+
const receipt = await this.provider.getTransactionReceipt(identifier);
|
|
423
|
+
const block = await this.provider.getBlock(tx.blockNumber || "latest");
|
|
424
|
+
return {
|
|
425
|
+
chain: this.chain.name,
|
|
426
|
+
id: tx.hash || identifier,
|
|
427
|
+
receiver: tx.to || "",
|
|
428
|
+
sender: tx.from,
|
|
429
|
+
value: tx.value,
|
|
430
|
+
function: tx.data && tx.data !== "0x" ? "contract_call" : "",
|
|
431
|
+
status: receipt?.status === 1 ? "success" : receipt?.status === 0 ? "failed" : "pending",
|
|
432
|
+
createdAt: block?.timestamp ? new Date(Number(block.timestamp) * 1e3).toISOString() : (/* @__PURE__ */ new Date()).toISOString(),
|
|
433
|
+
error: receipt?.status === 0 ? "Transaction failed" : null,
|
|
434
|
+
tx: {
|
|
435
|
+
hash: tx.hash || "",
|
|
436
|
+
from: tx.from,
|
|
437
|
+
to: tx.to || "",
|
|
438
|
+
value: tx.value.toString(),
|
|
439
|
+
data: tx.data || "0x",
|
|
440
|
+
gasLimit: tx.gasLimit?.toString() || "0",
|
|
441
|
+
gasPrice: tx.gasPrice?.toString() || "0",
|
|
442
|
+
blockNumber: tx.blockNumber || 0,
|
|
443
|
+
blockHash: tx.blockHash || "",
|
|
444
|
+
transactionIndex: tx.index || 0
|
|
377
445
|
}
|
|
378
|
-
}
|
|
379
|
-
return assets;
|
|
446
|
+
};
|
|
380
447
|
} catch (error) {
|
|
381
|
-
|
|
448
|
+
return null;
|
|
382
449
|
}
|
|
383
450
|
}
|
|
384
451
|
async getAccountActions(address, options) {
|
|
@@ -386,15 +453,16 @@ var WarpEvmDataLoader = class {
|
|
|
386
453
|
}
|
|
387
454
|
async getERC20TokenBalances(address) {
|
|
388
455
|
const tokenBalances = [];
|
|
389
|
-
const
|
|
390
|
-
|
|
456
|
+
const env = this.config.env === "devnet" ? "testnet" : this.config.env;
|
|
457
|
+
const knownTokens = getKnownTokensForChain(this.chain.name, env);
|
|
458
|
+
for (const token of knownTokens) {
|
|
391
459
|
try {
|
|
392
|
-
const balance = await this.getTokenBalance(address,
|
|
460
|
+
const balance = await this.getTokenBalance(address, token.id);
|
|
393
461
|
if (balance > 0n) {
|
|
394
462
|
tokenBalances.push({
|
|
395
|
-
tokenAddress,
|
|
463
|
+
tokenAddress: token.id,
|
|
396
464
|
balance,
|
|
397
|
-
metadata
|
|
465
|
+
metadata: token
|
|
398
466
|
});
|
|
399
467
|
}
|
|
400
468
|
} catch (error) {
|
|
@@ -402,7 +470,7 @@ var WarpEvmDataLoader = class {
|
|
|
402
470
|
}
|
|
403
471
|
const additionalTokens = await this.detectTokensFromEvents(address);
|
|
404
472
|
for (const tokenAddress of additionalTokens) {
|
|
405
|
-
if (!
|
|
473
|
+
if (!findKnownTokenById(this.chain.name, tokenAddress, env)) {
|
|
406
474
|
try {
|
|
407
475
|
const metadata = await this.getTokenMetadata(tokenAddress);
|
|
408
476
|
const balance = await this.getTokenBalance(address, tokenAddress);
|
|
@@ -420,40 +488,32 @@ var WarpEvmDataLoader = class {
|
|
|
420
488
|
return tokenBalances;
|
|
421
489
|
}
|
|
422
490
|
async getTokenBalance(address, tokenAddress) {
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
return balance;
|
|
427
|
-
} catch (error) {
|
|
428
|
-
throw new Error(`Failed to get token balance: ${error}`);
|
|
429
|
-
}
|
|
491
|
+
const contract = new import_ethers.ethers.Contract(tokenAddress, ERC20_ABI, this.provider);
|
|
492
|
+
const balance = await contract.balanceOf(address);
|
|
493
|
+
return balance;
|
|
430
494
|
}
|
|
431
495
|
async getTokenMetadata(tokenAddress) {
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
if (tokenInfo.name && tokenInfo.symbol && tokenInfo.decimals !== void 0) {
|
|
435
|
-
return {
|
|
436
|
-
name: tokenInfo.name,
|
|
437
|
-
symbol: tokenInfo.symbol,
|
|
438
|
-
decimals: tokenInfo.decimals,
|
|
439
|
-
logoUrl: tokenInfo.logoURI
|
|
440
|
-
};
|
|
441
|
-
}
|
|
442
|
-
const contract = new import_ethers.ethers.Contract(tokenAddress, ERC20_ABI, this.provider);
|
|
443
|
-
const [name, symbol, decimals] = await Promise.all([
|
|
444
|
-
contract.name().catch(() => tokenInfo.name || "Unknown Token"),
|
|
445
|
-
contract.symbol().catch(() => tokenInfo.symbol || "UNKNOWN"),
|
|
446
|
-
contract.decimals().catch(() => tokenInfo.decimals || 18)
|
|
447
|
-
]);
|
|
496
|
+
const tokenInfo = await EvmLogoService.getTokenInfo(this.chain.name, tokenAddress);
|
|
497
|
+
if (tokenInfo.name && tokenInfo.symbol && tokenInfo.decimals !== void 0) {
|
|
448
498
|
return {
|
|
449
|
-
name:
|
|
450
|
-
symbol:
|
|
451
|
-
decimals:
|
|
499
|
+
name: tokenInfo.name,
|
|
500
|
+
symbol: tokenInfo.symbol,
|
|
501
|
+
decimals: tokenInfo.decimals,
|
|
452
502
|
logoUrl: tokenInfo.logoURI
|
|
453
503
|
};
|
|
454
|
-
} catch (error) {
|
|
455
|
-
throw new Error(`Failed to get token metadata: ${error}`);
|
|
456
504
|
}
|
|
505
|
+
const contract = new import_ethers.ethers.Contract(tokenAddress, ERC20_ABI, this.provider);
|
|
506
|
+
const [name, symbol, decimals] = await Promise.all([
|
|
507
|
+
contract.name().catch(() => tokenInfo.name || "Unknown Token"),
|
|
508
|
+
contract.symbol().catch(() => tokenInfo.symbol || "UNKNOWN"),
|
|
509
|
+
contract.decimals().catch(() => tokenInfo.decimals || 18)
|
|
510
|
+
]);
|
|
511
|
+
return {
|
|
512
|
+
name: name || tokenInfo.name || "Unknown Token",
|
|
513
|
+
symbol: symbol || tokenInfo.symbol || "UNKNOWN",
|
|
514
|
+
decimals: decimals || tokenInfo.decimals || 18,
|
|
515
|
+
logoUrl: tokenInfo.logoURI
|
|
516
|
+
};
|
|
457
517
|
}
|
|
458
518
|
async detectTokensFromEvents(address) {
|
|
459
519
|
try {
|
|
@@ -462,13 +522,7 @@ var WarpEvmDataLoader = class {
|
|
|
462
522
|
const filter = {
|
|
463
523
|
fromBlock,
|
|
464
524
|
toBlock: currentBlock,
|
|
465
|
-
topics: [
|
|
466
|
-
import_ethers.ethers.id("Transfer(address,address,uint256)"),
|
|
467
|
-
null,
|
|
468
|
-
// from address (any)
|
|
469
|
-
import_ethers.ethers.zeroPadValue(address, 32)
|
|
470
|
-
// to address (our target)
|
|
471
|
-
]
|
|
525
|
+
topics: [import_ethers.ethers.id("Transfer(address,address,uint256)"), null, import_ethers.ethers.zeroPadValue(address, 32)]
|
|
472
526
|
};
|
|
473
527
|
const logs = await this.provider.getLogs(filter);
|
|
474
528
|
const tokenAddresses = /* @__PURE__ */ new Set();
|
|
@@ -480,62 +534,13 @@ var WarpEvmDataLoader = class {
|
|
|
480
534
|
return [];
|
|
481
535
|
}
|
|
482
536
|
}
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
async getTokenBalanceForAddress(address, tokenAddress) {
|
|
492
|
-
try {
|
|
493
|
-
return await this.getTokenBalance(address, tokenAddress);
|
|
494
|
-
} catch (error) {
|
|
495
|
-
throw new Error(`Failed to get token balance for ${tokenAddress}: ${error}`);
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
async getMultipleTokenBalances(address, tokenAddresses) {
|
|
499
|
-
const balances = /* @__PURE__ */ new Map();
|
|
500
|
-
await Promise.all(
|
|
501
|
-
tokenAddresses.map(async (tokenAddress) => {
|
|
502
|
-
try {
|
|
503
|
-
const balance = await this.getTokenBalance(address, tokenAddress);
|
|
504
|
-
balances.set(tokenAddress, balance);
|
|
505
|
-
} catch (error) {
|
|
506
|
-
balances.set(tokenAddress, 0n);
|
|
507
|
-
}
|
|
508
|
-
})
|
|
537
|
+
async getLogoUrl(tokenBalance) {
|
|
538
|
+
return await EvmLogoService.getLogoUrl(
|
|
539
|
+
this.chain.name,
|
|
540
|
+
tokenBalance.tokenAddress,
|
|
541
|
+
tokenBalance.metadata.name,
|
|
542
|
+
tokenBalance.metadata.symbol
|
|
509
543
|
);
|
|
510
|
-
return balances;
|
|
511
|
-
}
|
|
512
|
-
async getAccountTokens(address) {
|
|
513
|
-
return this.getAccountAssets(address);
|
|
514
|
-
}
|
|
515
|
-
async getTokenMetadataPublic(tokenAddress) {
|
|
516
|
-
try {
|
|
517
|
-
return await this.getTokenMetadata(tokenAddress);
|
|
518
|
-
} catch (error) {
|
|
519
|
-
return null;
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
async getChainInfo() {
|
|
523
|
-
try {
|
|
524
|
-
const network = await this.provider.getNetwork();
|
|
525
|
-
const latestBlock = await this.provider.getBlock("latest");
|
|
526
|
-
return {
|
|
527
|
-
chainId: network.chainId.toString(),
|
|
528
|
-
blockTime: latestBlock?.timestamp ? Date.now() / 1e3 - latestBlock.timestamp : 12
|
|
529
|
-
};
|
|
530
|
-
} catch (error) {
|
|
531
|
-
throw new Error(`Failed to get chain info: ${error}`);
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
async getAsset(identifier) {
|
|
535
|
-
return null;
|
|
536
|
-
}
|
|
537
|
-
async getAction(identifier, awaitCompleted = false) {
|
|
538
|
-
return null;
|
|
539
544
|
}
|
|
540
545
|
};
|
|
541
546
|
|
|
@@ -1388,6 +1393,7 @@ var getAllEvmChainNames = () => [import_warps8.WarpChainName.Ethereum, import_wa
|
|
|
1388
1393
|
EvmExplorers,
|
|
1389
1394
|
EvmLogoService,
|
|
1390
1395
|
ExplorerUrls,
|
|
1396
|
+
KnownTokens,
|
|
1391
1397
|
NativeTokenArb,
|
|
1392
1398
|
NativeTokenBase,
|
|
1393
1399
|
NativeTokenEth,
|
|
@@ -1398,10 +1404,12 @@ var getAllEvmChainNames = () => [import_warps8.WarpChainName.Ethereum, import_wa
|
|
|
1398
1404
|
WarpEvmResults,
|
|
1399
1405
|
WarpEvmSerializer,
|
|
1400
1406
|
createEvmAdapter,
|
|
1407
|
+
findKnownTokenById,
|
|
1401
1408
|
getAllEvmAdapters,
|
|
1402
1409
|
getAllEvmChainNames,
|
|
1403
1410
|
getArbitrumAdapter,
|
|
1404
1411
|
getBaseAdapter,
|
|
1405
|
-
getEthereumAdapter
|
|
1412
|
+
getEthereumAdapter,
|
|
1413
|
+
getKnownTokensForChain
|
|
1406
1414
|
});
|
|
1407
1415
|
//# sourceMappingURL=index.js.map
|