on master help sign in
Added error message

- Cleaner format + error message

commit94ccbdba1afbeb5c8825534834026c69a6a9a0c9 authorShawn Tobin <shawn.david.tobin@gmail.com> dateWed 12 Feb 2025, 10:40 (2 years ago) parent35eb615
1 file changed+4−4
src/lib/txn.ts+4−4
src/lib/txn.ts+4−4
@@ -88,11 +88,11 @@ const signTransaction = async ({
8888 const from = wallet.address;
8989 const estimate = await estimateGasLimit({ ...txn, from }, web3);
9090
91− let block = await web3.eth.getBlock('pending');
91+ let block =
92+ (await web3.eth.getBlock('pending')) || (await web3.eth.getBlock('latest'));
9293
93− // in case pending block doesn't return anything
94− if (!block || !block.baseFeePerGas) {
95− block = await web3.eth.getBlock('latest');
94+ if (!block?.baseFeePerGas) {
95+ throw new Error('Unable to fetch baseFeePerGas from the network');
9696 }
9797
9898 const baseFeeWei = block.baseFeePerGas;