-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds
patch-package
to apply fix for Arbitrum Nitro (#701)
- Loading branch information
Showing
7 changed files
with
984 additions
and
68 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { | ||
asyncForEach, | ||
impersonateAccount, | ||
setEtherBalance, | ||
} from "../../test/testUtils" | ||
|
||
import { DeployFunction } from "hardhat-deploy/types" | ||
import { GenericERC20 } from "../../build/typechain/" | ||
import { HardhatRuntimeEnvironment } from "hardhat/types" | ||
import dotenv from "dotenv" | ||
import { ethers } from "hardhat" | ||
import { isMainnet } from "../../utils/network" | ||
import path from "path" | ||
import { getHardhatTestSigners } from "../../scripts/utils" | ||
|
||
dotenv.config() | ||
|
||
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { | ||
const { deployments, getNamedAccounts, getChainId } = hre | ||
const { execute, log, read, all, get } = deployments | ||
const { deployer } = await getNamedAccounts() | ||
|
||
// These addresses are for large holders of the given token (used in forked mainnet testing) | ||
// You can find whales' addresses on etherscan's holders page. | ||
// Example: https://etherscan.io/token/0x6b175474e89094c44da98b954eedeac495271d0f#balances | ||
// Note that some addresses may be blacklisted so if the top address didnt work, try another instead. | ||
// key = token deployment name, value = array of addresses | ||
const tokenToAccountsMap: Record<string, string[]> = { | ||
// USD | ||
USDC: ["0x489ee077994B6658eAfA855C308275EAd8097C4A"], | ||
FRAX: ["0x489ee077994b6658eafa855c308275ead8097c4a"], | ||
USDT: ["0x489ee077994b6658eafa855c308275ead8097c4a"], | ||
} | ||
|
||
if ( | ||
isMainnet(await getChainId()) && | ||
process.env.HARDHAT_DEPLOY_FORK && | ||
process.env.FUND_FORK_NETWORK | ||
) { | ||
// Give the deployer tokens from each token holder for testing | ||
for (const [tokenName, holders] of Object.entries(tokenToAccountsMap)) { | ||
const contract = (await ethers.getContract(tokenName)) as GenericERC20 | ||
|
||
await asyncForEach(holders, async (holder) => { | ||
const balance = await contract.balanceOf(holder) | ||
await setEtherBalance(holder, ethers.constants.WeiPerEther.mul(1000)) | ||
await contract | ||
.connect(await impersonateAccount(holder)) | ||
.transfer(deployer, await contract.balanceOf(holder)) | ||
log( | ||
`Sent ${ethers.utils.formatUnits( | ||
balance, | ||
await contract.decimals(), | ||
)} ${tokenName} from ${holder} to ${deployer}`, | ||
) | ||
}) | ||
} | ||
// Give the deployer some ether to use for testing | ||
await setEtherBalance(deployer, ethers.constants.WeiPerEther.mul(1000)) | ||
// Give hardhat test account some ether | ||
await setEtherBalance( | ||
await getHardhatTestSigners()[0].getAddress(), | ||
ethers.constants.WeiPerEther.mul(1000), | ||
) | ||
} else { | ||
log(`skipping ${path.basename(__filename)}`) | ||
} | ||
} | ||
|
||
export default func |
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.