Created
April 20, 2021 18:36
-
-
Save ylv-io/62be8cde2fc15153ff4717037998e210 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/** | |
* Can't await on transactionSend because it will never resolve due to | |
* automine disabled. Save a promise instead and resolve it later. | |
* Should set gasLimit on txs because default gasLimit is blockGasLimit. | |
* promise = signer.sendTransaction({ | |
* to: signer.address, | |
* value: 1, | |
* }); | |
* const txReceipt = await promise; | |
* @param {func} Lambda to run within the same block. | |
*/ | |
async function mineInBlock(lambda) { | |
await ethers.provider.send('evm_setAutomine', [false]); | |
await lambda(); | |
await ethers.provider.send('evm_mine'); | |
await ethers.provider.send('evm_setAutomine', [true]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment