Skip to content

Commit

Permalink
chore: exports all evm constants
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanofa committed May 22, 2024
1 parent 6d08004 commit 720ac05
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 19 deletions.
34 changes: 21 additions & 13 deletions src/chains/evm/common/constants/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,28 @@ import { avalancheFuji, baseSepolia, sepolia } from "viem/chains";
import type { EvmChainName, EvmFolksChainId } from "../types/chain.js";
import type { Chain } from "viem";

const EVM_CHAIN_NAMES_MAINNET = [] as const;
const EVM_CHAIN_NAMES_TESTNET = [
export const MAINNET_EVM_CHAIN_NAMES = [] as const;
export const TESTNET_EVM_CHAIN_NAMES = [
"AVALANCHE_FUJI",
"ETHEREUM_SEPOLIA",
"BASE_SEPOLIA",
] as const;
export const EVM_CHAIN_NAMES = [
...EVM_CHAIN_NAMES_MAINNET,
...EVM_CHAIN_NAMES_TESTNET,
...MAINNET_EVM_CHAIN_NAMES,
...TESTNET_EVM_CHAIN_NAMES,
] as const;

const EVM_CHAIN_ID_MAINNET = {} as const;
export const MAINNET_EVM_CHAIN_ID = {} as const;

const EVM_CHAIN_ID_TESTNET = {
export const TESTNET_EVM_CHAIN_ID = {
AVALANCHE_FUJI: avalancheFuji.id,
ETHEREUM_SEPOLIA: sepolia.id,
BASE_SEPOLIA: baseSepolia.id,
} as const;

export const EVM_CHAIN_ID = {
...EVM_CHAIN_ID_MAINNET,
...EVM_CHAIN_ID_TESTNET,
...MAINNET_EVM_CHAIN_ID,
...TESTNET_EVM_CHAIN_ID,
} as const satisfies Record<EvmChainName, number>;

export const MAINNET_EVM_FOLKS_CHAIN_ID = {} as const;
Expand All @@ -40,16 +40,24 @@ export const EVM_FOLKS_CHAIN_ID = {
...TESTNET_EVM_FOLKS_CHAIN_ID,
} as const satisfies Record<EvmChainName, number>;

export const CHAIN_VIEM: Record<EvmFolksChainId, Chain> = {
// testnet
export const MAINNET_CHAIN_VIEM = {} as const;
export const TESTNET_CHAIN_VIEM = {
[EVM_FOLKS_CHAIN_ID.AVALANCHE_FUJI]: avalancheFuji,
[EVM_FOLKS_CHAIN_ID.ETHEREUM_SEPOLIA]: sepolia,
[EVM_FOLKS_CHAIN_ID.BASE_SEPOLIA]: baseSepolia,
};
} as const;
export const CHAIN_VIEM = {
...MAINNET_CHAIN_VIEM,
...TESTNET_CHAIN_VIEM,
} as const satisfies Record<EvmFolksChainId, Chain>;

export const CHAIN_NODE: Record<EvmFolksChainId, Array<string>> = {
// testnet
export const MAINNET_CHAIN_NODE = {};
export const TESTNET_CHAIN_NODE = {
[EVM_FOLKS_CHAIN_ID.AVALANCHE_FUJI]: [...avalancheFuji.rpcUrls.default.http],
[EVM_FOLKS_CHAIN_ID.ETHEREUM_SEPOLIA]: [...sepolia.rpcUrls.default.http],
[EVM_FOLKS_CHAIN_ID.BASE_SEPOLIA]: [...baseSepolia.rpcUrls.default.http],
};
export const CHAIN_NODE = {
...MAINNET_CHAIN_NODE,
...TESTNET_CHAIN_NODE,
} as const satisfies Record<EvmFolksChainId, Array<string>>;
16 changes: 16 additions & 0 deletions src/chains/evm/common/types/chain.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
import type {
EVM_CHAIN_ID,
MAINNET_EVM_CHAIN_ID,
TESTNET_EVM_CHAIN_ID,
EVM_CHAIN_NAMES,
MAINNET_EVM_CHAIN_NAMES,
TESTNET_EVM_CHAIN_NAMES,
EVM_FOLKS_CHAIN_ID,
MAINNET_EVM_FOLKS_CHAIN_ID,
TESTNET_EVM_FOLKS_CHAIN_ID,
} from "../constants/chain.js";

export type MainnetEvmChainName = (typeof MAINNET_EVM_CHAIN_NAMES)[number];
export type TestnetEvmChainName = (typeof TESTNET_EVM_CHAIN_NAMES)[number];
export type EvmChainName = (typeof EVM_CHAIN_NAMES)[number];

export type MainnetEvmChainId =
(typeof MAINNET_EVM_CHAIN_ID)[keyof typeof MAINNET_EVM_CHAIN_ID];
export type TestnetEvmChainId =
(typeof TESTNET_EVM_CHAIN_ID)[keyof typeof TESTNET_EVM_CHAIN_ID];
export type EvmChainId = (typeof EVM_CHAIN_ID)[keyof typeof EVM_CHAIN_ID];

export type Mainnet =
(typeof MAINNET_EVM_FOLKS_CHAIN_ID)[keyof typeof MAINNET_EVM_FOLKS_CHAIN_ID];
export type TestnetEvmFolksChainId =
(typeof TESTNET_EVM_FOLKS_CHAIN_ID)[keyof typeof TESTNET_EVM_FOLKS_CHAIN_ID];
export type EvmFolksChainId =
(typeof EVM_FOLKS_CHAIN_ID)[keyof typeof EVM_FOLKS_CHAIN_ID];
7 changes: 1 addition & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,7 @@ export * from "./common/constants/message.js";
// === CHAINS ===

// - EVM
export {
CHAIN_VIEM,
CHAIN_NODE,
MAINNET_EVM_FOLKS_CHAIN_ID,
TESTNET_EVM_FOLKS_CHAIN_ID,
} from "./chains/evm/common/constants/chain.js";
export * from "./chains/evm/common/constants/chain.js";

export * from "./chains/evm/common/types/chain.js";

Expand Down

0 comments on commit 720ac05

Please sign in to comment.