Skip to content

Commit

Permalink
update & use helper logic
Browse files Browse the repository at this point in the history
  • Loading branch information
k-xo committed May 16, 2022
1 parent 7dbd3b5 commit 4d0ccce
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
15 changes: 2 additions & 13 deletions scripts/pcvGuardianDeploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import hre, { ethers } from 'hardhat';
import { expect } from 'chai';
import config from './config';
import { Core, PCVGuardian } from '@custom-types/contracts';
import { getImpersonatedSigner } from '@test/helpers';

const {
CORE,
Expand Down Expand Up @@ -38,14 +39,7 @@ async function deploy() {
if (hre.network.name !== 'mainnet') {
const core = await ethers.getContractAt('Core', CORE);

await hre.network.provider.request({
method: 'hardhat_impersonateAccount',
params: [CORE]
});

await hre.network.provider.send('hardhat_setBalance', [CORE, ethers.utils.parseEther('10.0').toHexString()]);

const signer = await ethers.getSigner(CORE);
const signer = await getImpersonatedSigner(CORE);

// Grant PCV Controller and Guardian Roles to the PCV Guardian Contract
await core.connect(signer).grantPCVController(pcvGuardian.address);
Expand All @@ -61,11 +55,6 @@ async function deploy() {
await pcvGuardAdmin.connect(signer).grantPCVGuardRole(PCV_GUARD_EOA_2);

await validateDeployment(core, pcvGuardian);

await hre.network.provider.request({
method: 'hardhat_stopImpersonatingAccount',
params: [CORE]
});
}

if (hre.network.name == 'mainnet') {
Expand Down
2 changes: 2 additions & 0 deletions test/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ async function getImpersonatedSigner(address: string): Promise<SignerWithAddress

const signer = await ethers.getSigner(address);

await hre.network.provider.send('hardhat_setBalance', [address, ethers.utils.parseEther('10.0').toHexString()]);

return signer;
}

Expand Down

0 comments on commit 4d0ccce

Please sign in to comment.