Skip to content

Commit 519a80b

Browse files
committed
feat: add MegaETH testnet
1 parent 80e55ec commit 519a80b

File tree

5 files changed

+18
-2
lines changed

5 files changed

+18
-2
lines changed

src/labels/sources/erc20/tokens.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
GNOSIS,
2222
BSC,
2323
MONAD_TESTNET,
24+
MEGAETH_TESTNET,
2425
} from '@/utils/chains.js';
2526

2627
import { Asset } from '.';
@@ -444,6 +445,7 @@ async function fetch(chain: ChainId): Promise<Asset[]> {
444445
[GNOSIS]: {},
445446
[BSC]: {},
446447
[MONAD_TESTNET]: {},
448+
[MEGAETH_TESTNET]: {},
447449
};
448450
const chainTokens = tokens[chain] || {};
449451
const chainAssets = Object.entries(chainTokens)

src/labels/sources/erc20/trustwallet.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
GNOSIS,
2222
BSC,
2323
MONAD_TESTNET,
24+
MEGAETH_TESTNET,
2425
} from '@/utils/chains.js';
2526
import type { ChainId } from '@/utils/chains.js';
2627
import { getErc20Metadata, isErc20Ignored } from '@/utils/fetching.js';
@@ -120,6 +121,8 @@ async function getAssets(chainId: ChainId): Promise<string[]> {
120121
return 'binance';
121122
case MONAD_TESTNET:
122123
return null;
124+
case MEGAETH_TESTNET:
125+
return null;
123126
}
124127
}
125128

src/labels/sources/erc20/wrapped.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
GNOSIS,
2222
BSC,
2323
MONAD_TESTNET,
24+
MEGAETH_TESTNET,
2425
} from '@/utils/chains.js';
2526

2627
import { type Asset } from './index.js';
@@ -100,6 +101,7 @@ async function fetch(chain: ChainId): Promise<Asset[]> {
100101
symbol: 'WBNB',
101102
},
102103
[MONAD_TESTNET]: null,
104+
[MEGAETH_TESTNET]: null,
103105
};
104106

105107
const chainAsset = assets[chain];

src/utils/chains.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
gnosis,
2020
bsc,
2121
monadTestnet,
22+
megaethTestnet,
2223
} from 'viem/chains';
2324

2425
const ETHEREUM = mainnet.id;
@@ -40,6 +41,7 @@ const AVALANCHE_FUJI = avalancheFuji.id;
4041
const GNOSIS = gnosis.id;
4142
const BSC = bsc.id;
4243
const MONAD_TESTNET = monadTestnet.id;
44+
const MEGAETH_TESTNET = megaethTestnet.id;
4345

4446
const CHAINS: ChainId[] = [
4547
ETHEREUM,
@@ -61,6 +63,7 @@ const CHAINS: ChainId[] = [
6163
GNOSIS,
6264
BSC,
6365
MONAD_TESTNET,
66+
MEGAETH_TESTNET,
6467
];
6568

6669
type ChainId =
@@ -82,7 +85,8 @@ type ChainId =
8285
| typeof AVALANCHE_FUJI
8386
| typeof GNOSIS
8487
| typeof BSC
85-
| typeof MONAD_TESTNET;
88+
| typeof MONAD_TESTNET
89+
| typeof MEGAETH_TESTNET;
8690

8791
function getChainData(chainId: ChainId): ChainData {
8892
switch (chainId) {
@@ -124,6 +128,8 @@ function getChainData(chainId: ChainId): ChainData {
124128
return bsc;
125129
case MONAD_TESTNET:
126130
return monadTestnet;
131+
case MEGAETH_TESTNET:
132+
return megaethTestnet;
127133
}
128134
}
129135

@@ -148,6 +154,7 @@ export {
148154
GNOSIS,
149155
BSC,
150156
MONAD_TESTNET,
157+
MEGAETH_TESTNET,
151158
getChainData,
152159
};
153160
export type { ChainId };

src/utils/fetching.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
OPTIMISM,
1313
POLYGON,
1414
CELO,
15+
MEGAETH_TESTNET,
1516
} from './chains.js';
1617
import type { ChainId } from './chains.js';
1718
import { type Log } from './db.js';
@@ -28,7 +29,8 @@ function getClient(chain: ChainId): PublicClient | null {
2829
function getEndpointUrl(chain: ChainId): string {
2930
switch (chain) {
3031
case MODE:
31-
case CELO: {
32+
case CELO:
33+
case MEGAETH_TESTNET: {
3234
const chainData = getChainData(chain);
3335
return chainData.rpcUrls.default.http[0] as string;
3436
}

0 commit comments

Comments
 (0)