mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
feat: Added impersonateAddress function
This commit is contained in:
parent
93334a94ab
commit
991a7d424f
|
@ -9,6 +9,7 @@ import { BuidlerRuntimeEnvironment } from '@nomiclabs/buidler/types';
|
||||||
import { tEthereumAddress } from './types';
|
import { tEthereumAddress } from './types';
|
||||||
import { isAddress } from 'ethers/lib/utils';
|
import { isAddress } from 'ethers/lib/utils';
|
||||||
import { isZeroAddress } from 'ethereumjs-util';
|
import { isZeroAddress } from 'ethereumjs-util';
|
||||||
|
import { SignerWithAddress } from '../test-suites/test-aave/helpers/make-suite';
|
||||||
|
|
||||||
export const toWad = (value: string | number) => new BigNumber(value).times(WAD).toFixed();
|
export const toWad = (value: string | number) => new BigNumber(value).times(WAD).toFixed();
|
||||||
|
|
||||||
|
@ -115,3 +116,16 @@ export const notFalsyOrZeroAddress = (address: tEthereumAddress | null | undefin
|
||||||
}
|
}
|
||||||
return isAddress(address) && !isZeroAddress(address);
|
return isAddress(address) && !isZeroAddress(address);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const impersonateAddress = async (address: tEthereumAddress): Promise<SignerWithAddress> => {
|
||||||
|
await (DRE as HardhatRuntimeEnvironment).network.provider.request({
|
||||||
|
method: 'hardhat_impersonateAccount',
|
||||||
|
params: [address],
|
||||||
|
});
|
||||||
|
const signer = await DRE.ethers.provider.getSigner(address);
|
||||||
|
|
||||||
|
return {
|
||||||
|
signer,
|
||||||
|
address,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user