-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added simulation of Defender relayer via hardhat impersonation.…
… Added expected script to submit Incentives proposal
- Loading branch information
Showing
8 changed files
with
220 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,31 @@ | ||
import { formatEther } from '@ethersproject/units'; | ||
import { DefenderRelaySigner, DefenderRelayProvider } from 'defender-relay-client/lib/ethers'; | ||
import { Signer } from 'ethers'; | ||
import { DRE, impersonateAccountsHardhat } from './misc-utils'; | ||
|
||
export const getDefenderRelaySigner = async () => { | ||
const { DEFENDER_API_KEY, DEFENDER_SECRET_KEY } = process.env; | ||
let signer: Signer; | ||
|
||
if (!DEFENDER_API_KEY || !DEFENDER_SECRET_KEY) { | ||
throw new Error('Defender secrets required'); | ||
} | ||
|
||
const credentials = { apiKey: DEFENDER_API_KEY, apiSecret: DEFENDER_SECRET_KEY }; | ||
const signer = new DefenderRelaySigner(credentials, new DefenderRelayProvider(credentials), { | ||
|
||
signer = new DefenderRelaySigner(credentials, new DefenderRelayProvider(credentials), { | ||
speed: 'fast', | ||
}); | ||
const address = await signer.getAddress(); | ||
|
||
return { signer, address }; | ||
const defenderAddress = await signer.getAddress(); | ||
|
||
// Reemplace signer if MAINNET_FORK is active | ||
if (process.env.MAINNET_FORK === 'true') { | ||
console.log(' - Impersonating Defender Relay'); | ||
await impersonateAccountsHardhat([defenderAddress]); | ||
signer = await DRE.ethers.getSigner(defenderAddress); | ||
} | ||
console.log(' - Balance: ', formatEther(await signer.getBalance())); | ||
|
||
return { signer, address: defenderAddress }; | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.