UNPKG

@contractjs/aave-v3

Version:

A TypeScript utility library for Aave V3 contracts.

41 lines 1.36 kB
import { supportedChains } from "../constants/supportedChains"; export const normalizeChainToChainId = (chain) => { let chainId; if (typeof chain === 'number') { chainId = chain; } else if (typeof chain === 'string') { const chainObject = supportedChains[chain]; if (!chainObject) { throw new Error(`[Pool Utility] Chain with name "${chain}" is not a valid viem chain.`); } chainId = chainObject.id; } else if (typeof chain === 'object' && chain.id) { chainId = chain.id; } else { throw new Error('[Pool Utility] Invalid input. Please provide a chain name, chain ID, or viem Chain object.'); } return chainId; }; export const normalizeChain = (chain) => { let _chain; if (typeof chain === 'number') { _chain = supportedChains[chain]; } else if (typeof chain === 'string') { _chain = supportedChains[chain]; if (!_chain) { throw new Error(`[Pool Utility] Chain with name "${chain}" is not a valid viem chain.`); } } else if (typeof chain === 'object' && chain.id) { _chain = chain; } else { throw new Error('[Pool Utility] Invalid input. Please provide a chain name, chain ID, or viem Chain object.'); } return _chain; }; //# sourceMappingURL=index.js.map