Skip to content

Commit

Permalink
fix bigint rounding; fix etherscan api timeout; use proposeGasPrice f…
Browse files Browse the repository at this point in the history
…or L1
  • Loading branch information
yapishu committed Sep 11, 2024
1 parent 10a71f1 commit ca12b05
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmds/modify-l1_cmds/network-key.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ exports.handler = async function (argv) {
// set gas if not provided
gasPrices = await eth.fetchGasGwei();
if (argv.gas === 30000) {
argv.gas = gasPrices.safeGasPrice;
argv.gas = gasPrices.proposeGasPrice;
}

// Create and Send Tx
Expand Down
11 changes: 8 additions & 3 deletions utils/eth.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const files = require("./files");
const { Accounts } = require("web3-eth-accounts");
const { env } = require("yargs");
const ob = require("urbit-ob");
const sleep = (delay) => new Promise((resolve) => setTimeout(resolve, delay));

function initWeb3(argv) {
if (argv.useMainnet) {
Expand Down Expand Up @@ -117,11 +118,15 @@ async function fetchGasGwei() {
const proposeGasPrice = response.data.result.ProposeGasPrice;
const baseFee = response.data.result.suggestBaseFee;
return {
safeGasPrice: Web3.utils.toBN(parseFloat(safeGasPrice) * 1e9).toNumber(),
safeGasPrice: Web3.utils
.toBN(Math.round(parseFloat(safeGasPrice) * 1e9))
.toNumber(),
proposeGasPrice: Web3.utils
.toBN(parseFloat(proposeGasPrice) * 1e9)
.toBN(Math.round(parseFloat(proposeGasPrice) * 1e9))
.toNumber(),
baseFee: Web3.utils
.toBN(Math.round(parseFloat(baseFee) * 1e9))
.toNumber(),
baseFee: Web3.utils.toBN(parseFloat(baseFee) * 1e9).toNumber(),
};
} catch (error) {
console.error("Error fetching gas prices:", error);
Expand Down

0 comments on commit ca12b05

Please sign in to comment.