Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cli-typescript/src/cmds/mainMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
berachain,
bsc,
eth,
megaeth,
monad,
polygon,
sei,
Expand All @@ -35,6 +36,7 @@ export const mainMenu = async () => {
program.addCommand(arbitrum);
program.addCommand(abstract);
program.addCommand(avalanche);
program.addCommand(megaeth);
program.addCommand(monad);

await program.parseAsync(process.argv);
Expand Down
2 changes: 2 additions & 0 deletions cli-typescript/src/cmds/networks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import base from './base';
import berachain from './berachain';
import bsc from './bsc';
import eth from './eth';
import megaeth from './megaeth';
import monad from './monad';
import polygon from './polygon';
import sei from './sei';
Expand All @@ -19,6 +20,7 @@ export {
berachain,
bsc,
eth,
megaeth,
monad,
polygon,
sei,
Expand Down
31 changes: 31 additions & 0 deletions cli-typescript/src/cmds/networks/megaeth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { SUPPORTED_CHAINS } from '../../utils/constants';
import { createEvmCommand } from '../createCommand';
import { EvmPlatform } from '../../utils/evmUtils';
import { getSymbolFromChainId } from '../../utils/getters';

// Supported chain names
export enum MegaETHChains {
MAINNET = 'mainnet',
}

// Chain ids by the chain names
export const megaethChainIdsByName = new Map([
[MegaETHChains.MAINNET, SUPPORTED_CHAINS.MEGAETH],
]);

const megaethPlatform = new EvmPlatform(
'MegaETH',
getSymbolFromChainId(SUPPORTED_CHAINS.MEGAETH),
megaethChainIdsByName,
MegaETHChains.MAINNET,
);

export const megaeth = createEvmCommand({
platform: megaethPlatform,
commandAliases: [
getSymbolFromChainId(SUPPORTED_CHAINS.MEGAETH).toLowerCase(),
'mega',
],
});

export default megaeth;
5 changes: 5 additions & 0 deletions cli-typescript/src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export enum SUPPORTED_CHAINS {
ABSTRACT = 2741,
BERACHAIN = 80094,
MONAD = 143,
MEGAETH = 4326,
}

export const supportedChainNames: { [key in SUPPORTED_CHAINS]: string } = {
Expand All @@ -92,6 +93,7 @@ export const supportedChainNames: { [key in SUPPORTED_CHAINS]: string } = {
[SUPPORTED_CHAINS.ABSTRACT]: 'abstract',
[SUPPORTED_CHAINS.BERACHAIN]: 'berachain',
[SUPPORTED_CHAINS.MONAD]: 'monad',
[SUPPORTED_CHAINS.MEGAETH]: 'megaeth',
};

export const rpcUrls: { [chainId in SUPPORTED_CHAINS]: string } = {
Expand All @@ -117,6 +119,8 @@ export const rpcUrls: { [chainId in SUPPORTED_CHAINS]: string } = {
'https://evm-router.magiceden.io/monad/mainnet/me2024', // Monad
[SUPPORTED_CHAINS.AVALANCHE]:
'https://evm-router.magiceden.io/avalanche/mainnet/me2024', // Avalanche
[SUPPORTED_CHAINS.MEGAETH]:
'https://evm-router.magiceden.io/megaeth/mainnet/me2024', // MegaETH
};

export const explorerUrls: { [chainId in SUPPORTED_CHAINS]: string } = {
Expand All @@ -132,6 +136,7 @@ export const explorerUrls: { [chainId in SUPPORTED_CHAINS]: string } = {
[SUPPORTED_CHAINS.BERACHAIN]: 'https://berascan.com', // Berachain
[SUPPORTED_CHAINS.MONAD]: 'https://monadvision.com', // Monad
[SUPPORTED_CHAINS.AVALANCHE]: 'https://snowtrace.io', // Avalanche
[SUPPORTED_CHAINS.MEGAETH]: 'https://TBD', // MegaETH
};

export const DEFAULT_TOKEN_URI_SUFFIX = '.json';
Expand Down
27 changes: 21 additions & 6 deletions cli-typescript/src/utils/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,23 @@ import {
} from 'viem/chains';
import { Hex } from 'viem';
import { setBaseDir } from './setters';
import { defineChain } from 'viem';
import { monad } from '../cmds/networks';

export const megaeth = defineChain({
id: 4326,
name: 'MegaETH',
nativeCurrency: { name: 'MEGA', symbol: 'MEGA', decimals: 18 },
rpcUrls: {
default: {
http: ['https://evm-router.magiceden.io/megaeth/mainnet/me2024'],
},
},
blockExplorers: {
default: { name: 'MegaETH Explorer', url: 'https://TBD' },
},
});

/**
* Retrieves the transfer validator address based on the network (chain ID).
* @param chainId The chain ID of the network.
Expand Down Expand Up @@ -98,6 +113,8 @@ export const getSymbolFromChainId = (chainId: SUPPORTED_CHAINS): string => {
return 'MON';
case SUPPORTED_CHAINS.AVALANCHE:
return 'AVAX';
case SUPPORTED_CHAINS.MEGAETH:
return 'MEGA';
default:
return 'Unknown';
}
Expand Down Expand Up @@ -149,14 +166,12 @@ export const getViemChainByChainId = (chainId: SUPPORTED_CHAINS) => {
return berachain;
case SUPPORTED_CHAINS.SEPOLIA:
return sepolia;
case SUPPORTED_CHAINS.ARBITRUM:
return arbitrum;
case SUPPORTED_CHAINS.ABSTRACT:
return abstract;
case SUPPORTED_CHAINS.MONAD:
return monad;
case SUPPORTED_CHAINS.AVALANCHE:
return avalanche;
// case SUPPORTED_CHAINS.MONAD:
// return monad;
case SUPPORTED_CHAINS.MEGAETH:
return megaeth;
default:
throw new Error(`Unsupported chain ID: ${chainId}`);
}
Expand Down
3 changes: 3 additions & 0 deletions cli/cmds/utils
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ set_rpc_url() {
80094) RPC_URL="https://rpc.berachain.com" ;; # Berachain
43114) RPC_URL="https://api.avax.network/ext/bc/C/rpc" ;; # Avalanche
143) RPC_URL="https://evm-router.magiceden.io/monad/mainnet/me2024" ;; # Monad
4326) RPC_URL="https://evm-router.magiceden.io/megaeth/mainnet/me2024" ;; # MegaETH
*) echo "Unsupported chain id"; exit 1 ;;
esac

Expand All @@ -40,6 +41,7 @@ chain_id_to_symbol() {
10143) echo "MON" ;;
43114) echo "AVAX" ;;
143) echo "MON" ;;
4326) echo "MEGA" ;;
*) echo "Unknown" ;;
esac
}
Expand All @@ -60,6 +62,7 @@ chain_id_to_explorer_url() {
10143) echo "https://testnet.monadexplorer.com" ;;
43114) echo "https://snowtrace.io" ;;
143) echo "https://monadvision.com" ;;
4326) echo "https://TBD" ;;
*) echo "Unknown" ;;
esac
}
Expand Down