transaction-retry-tool
Version:
Tool to retry transactions on a blockchain
53 lines • 2.24 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
require("@nomiclabs/hardhat-ethers");
const config_1 = require("hardhat/config");
const plugins_1 = require("hardhat/plugins");
const path_1 = __importDefault(require("path"));
const serveTasks_1 = __importDefault(require("./serveTasks"));
const TransactionRetry_1 = require("./TransactionRetry");
require("./type-extensions");
(0, config_1.extendConfig)(async (config, userConfig) => {
var _a;
const userPath = (_a = userConfig.paths) === null || _a === void 0 ? void 0 : _a.retry;
let retry;
if (userPath === undefined)
retry = path_1.default.join(config.paths.root, 'retry');
else {
if (path_1.default.isAbsolute(userPath))
retry = userPath;
else
retry = path_1.default.normalize(path_1.default.join(config.paths.root, userPath));
}
config.paths.retry = retry;
});
(0, config_1.extendEnvironment)(async (hre) => {
hre.transactionRetry = (0, plugins_1.lazyObject)(() => new TransactionRetry_1.TransactionRetry(hre));
});
/**
* retry task implementation
* @param {HardhatUserArgs} args
* @param {HardhatEnv} env
*/
(0, config_1.task)('retry', 'Retry a transaction with the current gas price or specify one')
.addParam('signerKey', 'The signer private key (or type hardhat to use hardhat.config private key)')
.addParam('txHash', 'The transaction hash of the transaction to retry')
.addOptionalParam('gasPrice', 'Specify a gas price to retry the transaction with (default: current network gas price)', '')
.setAction(async function (args, env) {
// Call function
await (0, serveTasks_1.default)('retry-transaction', args, env);
});
/**
* gas-cost task implementation
* @param {HardhatUserArgs} args
* @param {HardhatEnv} env
*/
(0, config_1.task)('gas-cost', 'Get the current gas price on the selected network in wei').setAction(async function (args, env) {
// Call function
await (0, serveTasks_1.default)('get-current-gas-cost', args, env);
});
//# sourceMappingURL=index.js.map