import { Signer } from "ethers" ; import { Account } from "types" ; export const impersonate = async ( addr , fund = true ) : Promise < Signer > => { const { network , ethers } = await import ( "hardhat" ) ; await network . provider . request ( { method : "hardhat_impersonateAccount" , params : [ addr ] , } ) ; if ( fund ) { await network . provider . request ( { method : "hardhat_setBalance" , params : [ addr , "0x8AC7230489E80000" ] , } ) ; } return ethers . provider . getSigner ( addr ) ; } ; export const impersonateAccount = async ( address , fund = true ) : Promise < Account > => { const signer = await impersonate ( address , fund ) ; return { signer , address , } ; } ;