on master help sign in
Added error message
94ccbdbShawn Tobin
src/lib/txn.ts+4−4
@@ -88,11 +88,11 @@ const signTransaction = async ({
88 const from = wallet.address;
88 const from = wallet.address;
89 const estimate = await estimateGasLimit({ ...txn, from }, web3);
89 const estimate = await estimateGasLimit({ ...txn, from }, web3);
90
90
91+ let block =
91− let block = await web3.eth.getBlock('pending');
92+ (await web3.eth.getBlock('pending')) || (await web3.eth.getBlock('latest'));
92
93
93− // in case pending block doesn't return anything
94− if (!block || !block.baseFeePerGas) {
94+ if (!block?.baseFeePerGas) {
95− block = await web3.eth.getBlock('latest');
95+ throw new Error('Unable to fetch baseFeePerGas from the network');
96 }
96 }
97
97
98 const baseFeeWei = block.baseFeePerGas;
98 const baseFeeWei = block.baseFeePerGas;