-
-
Notifications
You must be signed in to change notification settings - Fork 656
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More Swap testing with hardhat (#3968)
* Played around with Hardhat * Remove API key * Clean up PR * Add more timeout * Move out code * Revert hardhat config .ts to .js * Remove commented code * Add whitespace
- Loading branch information
1 parent
8d1b7c2
commit 9fba72e
Showing
7 changed files
with
151 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { Contract } from '@ethersproject/contracts'; | ||
import { JsonRpcProvider } from '@ethersproject/providers'; | ||
|
||
import { FIXTURE_WEB3_ADDRESS } from './fixtures'; | ||
|
||
export const resetFork = async () => { | ||
const provider = new JsonRpcProvider('http://127.0.0.1:8546/'); | ||
|
||
await provider.send('hardhat_reset', [ | ||
{ | ||
forking: { | ||
jsonRpcUrl: `https://eth-mainnet.alchemyapi.io/v2/${process.env.ALCHEMY_API_KEY}` | ||
} | ||
} | ||
]); | ||
}; | ||
|
||
// Transfers DAI to the test address | ||
export const setupDAI = async () => { | ||
const provider = new JsonRpcProvider('http://127.0.0.1:8546/'); | ||
|
||
await provider.send('hardhat_impersonateAccount', ['0xf977814e90da44bfa03b6295a0616a897441acec']); | ||
|
||
const signer = await provider.getSigner('0xf977814e90da44bfa03b6295a0616a897441acec'); | ||
|
||
const abi = [ | ||
// Read-Only Functions | ||
'function balanceOf(address owner) view returns (uint256)', | ||
'function decimals() view returns (uint8)', | ||
'function symbol() view returns (string)', | ||
|
||
// Authenticated Functions | ||
'function transfer(address to, uint amount) returns (boolean)', | ||
|
||
// Events | ||
'event Transfer(address indexed from, address indexed to, uint amount)' | ||
]; | ||
|
||
// send ERC20 | ||
const erc20 = new Contract('0x6b175474e89094c44da98b954eedeac495271d0f', abi, signer); | ||
const tx = await erc20.populateTransaction.transfer( | ||
FIXTURE_WEB3_ADDRESS, | ||
'100000000000000000000' | ||
); | ||
const sent = await signer.sendTransaction(tx); | ||
|
||
await sent.wait(); | ||
|
||
await provider.send('hardhat_stopImpersonatingAccount', [ | ||
'0xf977814e90da44bfa03b6295a0616a897441acec' | ||
]); | ||
}; |
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
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 |
---|---|---|
|
@@ -1380,6 +1380,21 @@ | |
rustbn.js "~0.2.0" | ||
util.promisify "^1.0.1" | ||
|
||
"@ethersproject/abi@^5.1.0": | ||
version "5.1.2" | ||
resolved "https://registry.yarnpkg.com/@ethersproject/abi/-/abi-5.1.2.tgz#a8e75cd0455e6dc9e4861c3d1c22bbe436c1d775" | ||
integrity sha512-uMhoQVPX0UtfzTpekYQSEUcJGDgsJ25ifz+SV6PDETWaUFhcR8RNgb1QPTASP13inW8r6iy0/Xdq9D5hK2pNvA== | ||
dependencies: | ||
"@ethersproject/address" "^5.1.0" | ||
"@ethersproject/bignumber" "^5.1.0" | ||
"@ethersproject/bytes" "^5.1.0" | ||
"@ethersproject/constants" "^5.1.0" | ||
"@ethersproject/hash" "^5.1.0" | ||
"@ethersproject/keccak256" "^5.1.0" | ||
"@ethersproject/logger" "^5.1.0" | ||
"@ethersproject/properties" "^5.1.0" | ||
"@ethersproject/strings" "^5.1.0" | ||
|
||
"@ethersproject/[email protected]", "@ethersproject/abstract-provider@^5.1.0": | ||
version "5.1.0" | ||
resolved "https://registry.yarnpkg.com/@ethersproject/abstract-provider/-/abstract-provider-5.1.0.tgz#1f24c56cda5524ef4ed3cfc562a01d6b6f8eeb0b" | ||
|
@@ -1453,6 +1468,22 @@ | |
dependencies: | ||
"@ethersproject/bignumber" "^5.1.0" | ||
|
||
"@ethersproject/[email protected]": | ||
version "5.1.1" | ||
resolved "https://registry.yarnpkg.com/@ethersproject/contracts/-/contracts-5.1.1.tgz#c66cb6d618fcbd73e20a6b808e8f768b2b781d0b" | ||
integrity sha512-6WwktLJ0DFWU8pDkgH4IGttQHhQN4SnwKFu9h+QYVe48VGWtbDu4W8/q/7QA1u/HWlWMrKxqawPiZUJj0UMvOw== | ||
dependencies: | ||
"@ethersproject/abi" "^5.1.0" | ||
"@ethersproject/abstract-provider" "^5.1.0" | ||
"@ethersproject/abstract-signer" "^5.1.0" | ||
"@ethersproject/address" "^5.1.0" | ||
"@ethersproject/bignumber" "^5.1.0" | ||
"@ethersproject/bytes" "^5.1.0" | ||
"@ethersproject/constants" "^5.1.0" | ||
"@ethersproject/logger" "^5.1.0" | ||
"@ethersproject/properties" "^5.1.0" | ||
"@ethersproject/transactions" "^5.1.0" | ||
|
||
"@ethersproject/hash@^5.1.0": | ||
version "5.1.0" | ||
resolved "https://registry.yarnpkg.com/@ethersproject/hash/-/hash-5.1.0.tgz#40961d64837d57f580b7b055e0d74174876d891e" | ||
|