Fix GasPriceOracle: provide to its constructor valid RPC, which user defined in startup parameters - now gas for goerli calculates correctly

This commit is contained in:
Theo 2023-05-12 23:12:22 +03:00
parent 16d9efa60c
commit 38783848b5

4
cli.js

@ -26,6 +26,7 @@ const prompt = readline.createInterface({ input: process.stdin, output: process.
const gasSpeedPreferences = ['instant', 'fast', 'standard', 'low']; const gasSpeedPreferences = ['instant', 'fast', 'standard', 'low'];
let web3, let web3,
oracle,
torPort, torPort,
tornado, tornado,
tornadoContract, tornadoContract,
@ -834,11 +835,9 @@ async function fetchGasPrice() {
/** Gas preferences **/ /** Gas preferences **/
console.log('Gas speed preference: ', preferenceSpeed); console.log('Gas speed preference: ', preferenceSpeed);
/** ----------------------------------------------- **/ /** ----------------------------------------------- **/
const options = { chainId: netId };
try { try {
const isLegacy = !eipGasSupport; const isLegacy = !eipGasSupport;
const oracle = new GasPriceOracle(options);
const gas = await oracle.gasPrices({ isLegacy }); const gas = await oracle.gasPrices({ isLegacy });
if (netId === 1) { if (netId === 1) {
@ -1404,6 +1403,7 @@ async function init({ rpc, noteNetId, currency = 'dai', amount = '100', balanceC
console.log('Connecting to remote node'); console.log('Connecting to remote node');
web3 = new Web3(rpc, null, { transactionConfirmationBlocks: 1 }); web3 = new Web3(rpc, null, { transactionConfirmationBlocks: 1 });
} }
oracle = new GasPriceOracle({ chainId: web3.eth.getChainId(), defaultRpc: rpc });
const rpcHost = new URL(rpc).hostname; const rpcHost = new URL(rpc).hostname;
const isIpPrivate = is_ip_private(rpcHost); const isIpPrivate = is_ip_private(rpcHost);