Skip to content

Commit

Permalink
script to clear nonce when stuff gets stuck
Browse files Browse the repository at this point in the history
  • Loading branch information
edmundedgar committed Jun 13, 2024
1 parent 98abc84 commit 58e079b
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions src/scripts/clearNextNonce.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/* eslint-disable no-await-in-loop, no-use-before-define, no-lonely-if, import/no-dynamic-require, global-require */
/* eslint-disable no-console, no-inner-declarations, no-undef, import/no-unresolved, no-restricted-syntax */
const path = require('path');
const { ethers } = require('hardhat');

Check failure on line 4 in src/scripts/clearNextNonce.js

View workflow job for this annotation

GitHub Actions / Code linting (16.x, ubuntu-latest)

'ethers' is assigned a value but never used. Allowed unused vars must match /export^/u
require('dotenv').config({ path: path.resolve(__dirname, '../.env') });
const common = require('../common/common');


Check failure on line 8 in src/scripts/clearNextNonce.js

View workflow job for this annotation

GitHub Actions / Code linting (16.x, ubuntu-latest)

More than 1 blank line not allowed
async function main() {
const args = process.argv.slice(2);
const deploymentName = args[0];

const deployParameters = require(`../../deployments/${deploymentName}/deploy_parameters.json`);
const currentProvider = await common.loadProvider(deployParameters, process.env);
const deployer = await common.loadDeployer(currentProvider, deployParameters);

const pendingTxCount = await currentProvider.getTransactionCount(deployer.address, 'pending');
const txCount = await currentProvider.getTransactionCount(deployer.address);

if (pendingTxCount == txCount) {

Check failure on line 20 in src/scripts/clearNextNonce.js

View workflow job for this annotation

GitHub Actions / Code linting (16.x, ubuntu-latest)

Expected '===' and instead saw '=='
console.log('Nothing to clear');
return;
}

console.log('Cancelling tx with nonce', txCount);

// let gasPrice = await currentProvider.getGasPrice();

const tx = await deployer.sendTransaction({
to: deployer.address,
value: 0,
nonce: txCount,
// gasPrice: gasPrice,
gasLimit: 21000

Check failure on line 34 in src/scripts/clearNextNonce.js

View workflow job for this annotation

GitHub Actions / Code linting (16.x, ubuntu-latest)

Missing trailing comma
});

console.log('sending tx', tx);
await tx.wait();
console.log('setnd tx', tx.hash);
}

main().catch((e) => {
console.error(e);
process.exit(1);
});

0 comments on commit 58e079b

Please sign in to comment.