Skip to content

Commit

Permalink
add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
alissacrane-cb committed Aug 15, 2024
1 parent 0766676 commit c079132
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/transaction/components/TransactionButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export function TransactionButton({
});

const buttonContent = useMemo(() => {
// txn successful
if (receipt) {
return 'View transaction';
}
Expand All @@ -62,8 +63,10 @@ export function TransactionButton({
}, [buttonText, errorMessage, receipt]);

const handleSubmit = useCallback(() => {
// SW will have txn id so open in wallet
if (receipt && transactionId) {
showCallsStatus({ id: transactionId });
// EOA will not have txn id so open in explorer
} else if (receipt) {
const chainExplorer = getChainExplorer(accountChainId);
window.open(
Expand All @@ -72,6 +75,7 @@ export function TransactionButton({
'noopener,noreferrer',
);
} else {
// if no receipt, submit txn
onSubmit();
}
}, [
Expand Down
1 change: 1 addition & 0 deletions src/transaction/components/TransactionToastIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export function TransactionToastIcon({ className }: TransactionToastIconReact) {
const isInProgress = isLoading || !!transactionId || !!transactionHash;

const icon = useMemo(() => {
// txn successful
if (receipt) {
return successSvg;
}
Expand Down
3 changes: 3 additions & 0 deletions src/transaction/hooks/useGetTransactionStatusLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ export function useGetTransactionStatusLabel() {
transactionHash,
transactionId,
} = useTransactionContext();
// user confirmed in wallet, txn in progress
const isInProgress = isLoading || !!transactionId || !!transactionHash;

// user started txn and needs to confirm in wallet
const isPending =
statusWriteContract === 'pending' || statusWriteContracts === 'pending';

Expand Down
2 changes: 2 additions & 0 deletions src/transaction/hooks/useGetTransactionToastLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { useTransactionContext } from '../components/TransactionProvider';
export function useGetTransactionToastLabel() {
const { errorMessage, isLoading, receipt, transactionHash, transactionId } =
useTransactionContext();

// user confirmed in wallet, txn in progress
const isInProgress = isLoading || !!transactionId || !!transactionHash;

return useMemo(() => {
Expand Down

0 comments on commit c079132

Please sign in to comment.