@qso-soft/shared
Version:
Shared library for QSO-soft
29 lines • 997 B
JavaScript
import { getClientByNetwork } from '../clients';
import { sleep } from '../utils';
import { getCurrentGas } from './get-gas';
export const waitGas = async ({ maxGas, logger, wallet, sleepSeconds }) => {
if (!maxGas) {
return;
}
const network = maxGas[0];
const maxGasValue = maxGas[1];
if (maxGasValue === 0) {
return;
}
const client = getClientByNetwork(network, wallet.privKey, logger);
let isGoodGas = false;
while (!isGoodGas) {
const currentGas = await getCurrentGas(client.publicClient);
if (currentGas > maxGasValue) {
logger.warning(`Ethereum gwei is too high. Current Gwei [${currentGas}] in ${network} > Max Gwei [${maxGasValue}]. Wait [${sleepSeconds}] sec`, {
status: 'in progress',
action: 'checkGasPrice',
});
await sleep(sleepSeconds);
}
else {
isGoodGas = true;
}
}
};
//# sourceMappingURL=wait-gas.js.map