Skip to content

Commit

Permalink
Merge pull request #949 from n00b21337/947-add_other_EVMs
Browse files Browse the repository at this point in the history
947 add other evm chains to wallet
  • Loading branch information
odilitime authored Dec 10, 2024
2 parents e8ec603 + 6bfacd1 commit 2262723
Show file tree
Hide file tree
Showing 7 changed files with 464 additions and 80 deletions.
3 changes: 2 additions & 1 deletion packages/plugin-evm/src/actions/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {
ExtendedChain,
getRoutes,
} from "@lifi/sdk";
import { getChainConfigs, WalletProvider } from "../providers/wallet";
import { WalletProvider } from "../providers/wallet";
import { getChainConfigs } from "../providers/chainConfigs";
import { bridgeTemplate } from "../templates";
import type { BridgeParams, Transaction } from "../types";

Expand Down
3 changes: 2 additions & 1 deletion packages/plugin-evm/src/actions/swap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {
ExtendedChain,
getRoutes,
} from "@lifi/sdk";
import { getChainConfigs, WalletProvider } from "../providers/wallet";
import { WalletProvider } from "../providers/wallet";
import { getChainConfigs } from "../providers/chainConfigs";
import { swapTemplate } from "../templates";
import type { SwapParams, Transaction } from "../types";

Expand Down
339 changes: 339 additions & 0 deletions packages/plugin-evm/src/providers/chainConfigs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,339 @@
import {
mainnet,
base,
sepolia,
bsc,
arbitrum,
avalanche,
polygon,
optimism,
cronos,
gnosis,
fantom,
klaytn,
celo,
moonbeam,
aurora,
harmonyOne,
moonriver,
arbitrumNova,
mantle,
linea,
scroll,
filecoin,
taiko,
zksync,
canto,
} from "viem/chains";
import type { ChainMetadata, SupportedChain } from "../types";
import type { IAgentRuntime } from "@ai16z/eliza";

export const DEFAULT_CHAIN_CONFIGS: Record<SupportedChain, ChainMetadata> = {
ethereum: {
chainId: 1,
name: "Ethereum",
chain: mainnet,
rpcUrl: "https://eth.llamarpc.com",
nativeCurrency: {
name: "Ether",
symbol: "ETH",
decimals: 18,
},
blockExplorerUrl: "https://etherscan.io",
},
base: {
chainId: 8453,
name: "Base",
chain: base,
rpcUrl: "https://base.llamarpc.com",
nativeCurrency: {
name: "Ether",
symbol: "ETH",
decimals: 18,
},
blockExplorerUrl: "https://basescan.org",
},
sepolia: {
chainId: 11155111,
name: "Sepolia",
chain: sepolia,
rpcUrl: "https://rpc.sepolia.org",
nativeCurrency: {
name: "Sepolia Ether",
symbol: "ETH",
decimals: 18,
},
blockExplorerUrl: "https://sepolia.etherscan.io",
},
bsc: {
chainId: 56,
name: "BNB Smart Chain",
chain: bsc,
rpcUrl: "https://bsc-dataseed1.binance.org/",
nativeCurrency: {
name: "Binance Coin",
symbol: "BNB",
decimals: 18,
},
blockExplorerUrl: "https://bscscan.com",
},
arbitrum: {
chainId: 42161,
name: "Arbitrum One",
chain: arbitrum,
rpcUrl: "https://arb1.arbitrum.io/rpc",
nativeCurrency: {
name: "Ether",
symbol: "ETH",
decimals: 18,
},
blockExplorerUrl: "https://arbiscan.io",
},
avalanche: {
chainId: 43114,
name: "Avalanche C-Chain",
chain: avalanche,
rpcUrl: "https://api.avax.network/ext/bc/C/rpc",
nativeCurrency: {
name: "Avalanche",
symbol: "AVAX",
decimals: 18,
},
blockExplorerUrl: "https://snowtrace.io",
},
polygon: {
chainId: 137,
name: "Polygon",
chain: polygon,
rpcUrl: "https://polygon-rpc.com",
nativeCurrency: {
name: "MATIC",
symbol: "MATIC",
decimals: 18,
},
blockExplorerUrl: "https://polygonscan.com",
},
optimism: {
chainId: 10,
name: "Optimism",
chain: optimism,
rpcUrl: "https://mainnet.optimism.io",
nativeCurrency: {
name: "Ether",
symbol: "ETH",
decimals: 18,
},
blockExplorerUrl: "https://optimistic.etherscan.io",
},
cronos: {
chainId: 25,
name: "Cronos",
chain: cronos,
rpcUrl: "https://evm.cronos.org",
nativeCurrency: {
name: "Cronos",
symbol: "CRO",
decimals: 18,
},
blockExplorerUrl: "https://cronoscan.com",
},
gnosis: {
chainId: 100,
name: "Gnosis",
chain: gnosis,
rpcUrl: "https://rpc.gnosischain.com",
nativeCurrency: {
name: "xDAI",
symbol: "XDAI",
decimals: 18,
},
blockExplorerUrl: "https://gnosisscan.io",
},
fantom: {
chainId: 250,
name: "Fantom",
chain: fantom,
rpcUrl: "https://rpc.ftm.tools",
nativeCurrency: {
name: "Fantom",
symbol: "FTM",
decimals: 18,
},
blockExplorerUrl: "https://ftmscan.com",
},
klaytn: {
chainId: 8217,
name: "Klaytn",
chain: klaytn,
rpcUrl: "https://public-node-api.klaytnapi.com/v1/cypress",
nativeCurrency: {
name: "KLAY",
symbol: "KLAY",
decimals: 18,
},
blockExplorerUrl: "https://scope.klaytn.com",
},
celo: {
chainId: 42220,
name: "Celo",
chain: celo,
rpcUrl: "https://forno.celo.org",
nativeCurrency: {
name: "Celo",
symbol: "CELO",
decimals: 18,
},
blockExplorerUrl: "https://celoscan.io",
},
moonbeam: {
chainId: 1284,
name: "Moonbeam",
chain: moonbeam,
rpcUrl: "https://rpc.api.moonbeam.network",
nativeCurrency: {
name: "Glimmer",
symbol: "GLMR",
decimals: 18,
},
blockExplorerUrl: "https://moonscan.io",
},
aurora: {
chainId: 1313161554,
name: "Aurora",
chain: aurora,
rpcUrl: "https://mainnet.aurora.dev",
nativeCurrency: {
name: "Ether",
symbol: "ETH",
decimals: 18,
},
blockExplorerUrl: "https://aurorascan.dev",
},
harmonyOne: {
chainId: 1666600000,
name: "harmonyOne",
chain: harmonyOne,
rpcUrl: "https://api.harmonyOne.one",
nativeCurrency: {
name: "ONE",
symbol: "ONE",
decimals: 18,
},
blockExplorerUrl: "https://explorer.harmonyOne.one",
},
moonriver: {
chainId: 1285,
name: "Moonriver",
chain: moonriver,
rpcUrl: "https://rpc.api.moonriver.moonbeam.network",
nativeCurrency: {
name: "Moonriver",
symbol: "MOVR",
decimals: 18,
},
blockExplorerUrl: "https://moonriver.moonscan.io",
},
arbitrumNova: {
chainId: 42170,
name: "Arbitrum Nova",
chain: arbitrumNova,
rpcUrl: "https://nova.arbitrum.io/rpc",
nativeCurrency: {
name: "Ether",
symbol: "ETH",
decimals: 18,
},
blockExplorerUrl: "https://nova-explorer.arbitrum.io",
},
mantle: {
chainId: 5000,
name: "Mantle",
chain: mantle,
rpcUrl: "https://rpc.mantle.xyz",
nativeCurrency: {
name: "Mantle",
symbol: "MNT",
decimals: 18,
},
blockExplorerUrl: "https://explorer.mantle.xyz",
},
linea: {
chainId: 59144,
name: "Linea",
chain: linea,
rpcUrl: "https://linea-mainnet.rpc.build",
nativeCurrency: {
name: "Ether",
symbol: "ETH",
decimals: 18,
},
blockExplorerUrl: "https://lineascan.build",
},
scroll: {
chainId: 534353,
name: "Scroll Alpha Testnet",
chain: scroll,
rpcUrl: "https://alpha-rpc.scroll.io/l2",
nativeCurrency: {
name: "Ether",
symbol: "ETH",
decimals: 18,
},
blockExplorerUrl: "https://blockscout.scroll.io",
},
filecoin: {
chainId: 314,
name: "Filecoin",
chain: filecoin,
rpcUrl: "https://api.node.glif.io/rpc/v1",
nativeCurrency: {
name: "Filecoin",
symbol: "FIL",
decimals: 18,
},
blockExplorerUrl: "https://filfox.info/en",
},
taiko: {
chainId: 167005,
name: "Taiko (Alpha-3) Testnet",
chain: taiko,
rpcUrl: "https://rpc.a3.taiko.xyz",
nativeCurrency: {
name: "Ether",
symbol: "ETH",
decimals: 18,
},
blockExplorerUrl: "https://explorer.a3.taiko.xyz",
},
zksync: {
chainId: 324,
name: "zksync Era",
chain: zksync,
rpcUrl: "https://mainnet.era.zksync.io",
nativeCurrency: {
name: "Ether",
symbol: "ETH",
decimals: 18,
},
blockExplorerUrl: "https://explorer.zksync.io",
},
canto: {
chainId: 7700,
name: "Canto",
chain: canto,
rpcUrl: "https://canto.slingshot.finance",
nativeCurrency: {
name: "CANTO",
symbol: "CANTO",
decimals: 18,
},
blockExplorerUrl: "https://tuber.build",
},
} as const;

export const getChainConfigs = (runtime: IAgentRuntime) => {
return (
(runtime.character.settings.chains?.evm as ChainMetadata[]) ||
DEFAULT_CHAIN_CONFIGS
);
};
Loading

0 comments on commit 2262723

Please sign in to comment.