Skip to content

Commit

Permalink
chore: validate gasPrice and nonce existence
Browse files Browse the repository at this point in the history
  • Loading branch information
zixiang2018 committed Sep 28, 2023
1 parent 6641afe commit 0f3f3ce
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/components/util/cancel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ethers, BigNumber } from "ethers";
interface pendingTransactionProps {
transactionHash: string;
nonce: number;
gasPrice: BigNumber | undefined;
gasPrice: BigNumber;
}

export const getPendingTransaction = async (
Expand All @@ -18,12 +18,15 @@ export const getPendingTransaction = async (
log ? log(`Retrieving Transaction Data.`) : null;
const defaultProvider = ethers.getDefaultProvider(wallet.network);
const { gasPrice, nonce } = await defaultProvider.getTransaction(transactionHash);
log ? log(`Transaction Data Retrieved.`) : null;
return {
transactionHash: transactionHash,
nonce: nonce,
gasPrice: gasPrice,
};
if (gasPrice && nonce) {
log ? log(`Transaction Data Retrieved.`) : null;
return {
transactionHash: transactionHash,
nonce: nonce,
gasPrice: gasPrice,
};
}
log ? log("Error in retrieving transaction.") : null;
} else {
log ? log("Error in retrieving wallet network.") : null;
}
Expand Down

0 comments on commit 0f3f3ce

Please sign in to comment.