(hre: HardhatRuntimeEnvironment)
| 39 | * We need to load the chain manually. |
| 40 | */ |
| 41 | export const getChain = (hre: HardhatRuntimeEnvironment) => { |
| 42 | const name = hre.network.name |
| 43 | const id = hre.network.config.chainId |
| 44 | const url = (hre.network.config as { url?: string }).url |
| 45 | |
| 46 | if (id == null) { |
| 47 | throw new Error(`chain ID for network ${name} is required`) |
| 48 | } |
| 49 | if (url == null || url === '') { |
| 50 | throw new Error(`url for network ${name} is required`) |
| 51 | } |
| 52 | |
| 53 | return defineChain({ |
| 54 | ...(chainDefinitions[name as keyof typeof chainDefinitions] ?? localhost), |
| 55 | // patch hardhat configurable fields |
| 56 | ...(id != null ? { id } : undefined), |
| 57 | ...(url != null ? { rpcUrls: { default: { http: [url] } } } : undefined), |
| 58 | }) |
| 59 | } |
| 60 | |
| 61 | export const createWalletClient = <T extends Account>(hre: HardhatRuntimeEnvironment, account: T) => |
| 62 | viemCreateWalletClient({ account, chain: getChain(hre), transport: http() }) |
no outgoing calls