test-pkg-ngn
Version:
A library containing helper functions that facilitate scripting for keepers of the Keep3r Network
31 lines • 1.91 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.populateTransactions = void 0;
const tslib_1 = require("tslib");
/**
* @notice Helper function to populate transactions with their respective data and parameters.
*
* @param contract An instance of the contract we wish to call.
* @param functionName The name of the function we wish to call.
* @param functionArgs The arguments for the different transactions we want to populate. The function arguments must be provided
* as an array of arrays, each array containing the arguments for a different transaction in case transactions
* with different data are needed. If this were the case, ensure functionArgs' length is the same as burstSize.
* For example: if we were to send [[arg1, arg2], [arg3, arg4]] as functionArgs, the resulting transactions would be:
* [tx1[arg1, arg2], tx2[arg3, arg4]]
* @param chainId The chainId of the network to which we will be sending our bundles.
* @param options Optional parameter. It includes all optional properties to add to a transaction. See ethers Overrides type.
*
* @return Array of populated transactions.
*/
function populateTransactions(props) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const { contract, functionName, functionArgs, chainId } = props;
// Second map is due to flashbots having trouble inferring chainId from signer, so we add it explicitly
const txs = (yield Promise.all(functionArgs.map((args) => {
return contract.populateTransaction[functionName](...args, Object.assign({}, props.options));
}))).map((tx) => (Object.assign(Object.assign({}, tx), { chainId })));
return txs;
});
}
exports.populateTransactions = populateTransactions;
//# sourceMappingURL=populateTransactions.js.map