Skip to content

Commit

Permalink
fix: check tx status right after submitting
Browse files Browse the repository at this point in the history
  • Loading branch information
swkatmask committed Oct 11, 2024
1 parent 0cdbb0f commit 7d5b8ed
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -304,25 +304,32 @@ export const BridgeConfirm = memo(function BridgeConfirm() {
return
}
queryClient.invalidateQueries({ queryKey: ['fungible-token', 'balance'] })
showSnackbar(t`Bridge`, {
message: (
<MuiLink
sx={{ wordBreak: 'break-word' }}
className={classes.link}
color="inherit"
href={Utils.explorerResolver.transactionLink(fromChainId, hash)}
tabIndex={-1}
target="_blank"
rel="noopener noreferrer">
<Typography
color={theme.palette.maskColor.success}
component="span">{t`Transaction submitted.`}</Typography>
<Icons.LinkOut size={16} sx={{ ml: 0.5 }} />
</MuiLink>
),
variant: 'default',
processing: true,
})
const receipt = await Web3.getTransactionReceipt(hash)
if (!receipt?.status) {
showSnackbar(t`Bridge`, {
message: t`Failed to bridge`,
})
} else {
showSnackbar(t`Bridge`, {
message: (
<MuiLink
sx={{ wordBreak: 'break-word' }}
className={classes.link}
color="inherit"
href={Utils.explorerResolver.transactionLink(fromChainId, hash)}
tabIndex={-1}
target="_blank"
rel="noopener noreferrer">
<Typography
color={theme.palette.maskColor.success}
component="span">{t`Transaction submitted.`}</Typography>
<Icons.LinkOut size={16} sx={{ ml: 0.5 }} />
</MuiLink>
),
variant: 'default',
processing: true,
})
}
await addTransaction(account, {
kind: 'bridge',
hash,
Expand Down Expand Up @@ -386,6 +393,7 @@ export const BridgeConfirm = memo(function BridgeConfirm() {
gasConfig.gasPrice,
router,
mode,
Web3,
])

const loading = isSending || isCheckingApprove || isApproving || submitting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,17 +292,6 @@ export const Transaction = memo(function Transaction() {
)
}, [setParams])

useAsync(async () => {
if (!isPending || !hash) return
const fromReceipt = await waitForTransaction({ chainId: fromChainId, hash, confirmationCount: 1 })
if (!fromReceipt.status) {
showSnackbar(t`Bridge`, {
message: t`Failed to bridge`,
})
removePendingParam()
}
}, [isPending, fromChainId, hash, removePendingParam])

useAsync(async () => {
if (!isPending || !toChainId || !toTxHash || !toToken) return
const receipt = await waitForTransaction({ chainId: toChainId, hash: toTxHash, confirmationCount: 1 })
Expand Down

0 comments on commit 7d5b8ed

Please sign in to comment.