Skip to content

Commit

Permalink
Merge pull request #1408 from Conflux-Chain/fix/tx-polling
Browse files Browse the repository at this point in the history
fix: remove if in tx send error handler
  • Loading branch information
iosh authored Sep 12, 2024
2 parents d054f29 + 7645981 commit b5fd72e
Showing 1 changed file with 39 additions and 42 deletions.
81 changes: 39 additions & 42 deletions packages/rpcs/wallet_handleUnfinishedETHTx/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,48 +221,45 @@ export const main = ({
const failed =
!sameAsSuccess && (shouldDiscard || resendPriceTooLow)

if (errorType === 'unknownError')
defs({
failed: failed && {errorType, err},
sameAsSuccess,
resend: !shouldDiscard && !sameAsSuccess,
})
.transform(
branchObj({
failed: [
sideEffect(
({err}) =>
typeof failedCb === 'function' && failedCb(err),
),
sideEffect(({errorType}) => {
if (setTxFailed({hash, error: errorType})) {
getExt().then(ext =>
ext.notifications.create(hash, {
title: 'Failed transaction',
message: `Transaction ${parseInt(
tx.txPayload.nonce,
16,
)} failed! ${err?.data || err?.message || ''}`,
}),
)
}
}),
sideEffect(() => {
updateBadge(getUnfinishedTxCount())
}),
],
resend: sideEffect(keepTrack),
// retry in next run
sameAsSuccess: [
sideEffect(() => setTxPending({hash})),
sideEffect(
() => typeof okCb === 'function' && okCb(hash),
),
sideEffect(keepTrack),
],
}),
)
.done()
defs({
failed: failed && {errorType, err},
sameAsSuccess,
resend: !shouldDiscard && !sameAsSuccess,
})
.transform(
branchObj({
failed: [
sideEffect(
({err}) =>
typeof failedCb === 'function' && failedCb(err),
),
sideEffect(({errorType}) => {
if (setTxFailed({hash, error: errorType})) {
getExt().then(ext =>
ext.notifications.create(hash, {
title: 'Failed transaction',
message: `Transaction ${parseInt(
tx.txPayload.nonce,
16,
)} failed! ${err?.data || err?.message || ''}`,
}),
)
}
}),
sideEffect(() => {
updateBadge(getUnfinishedTxCount())
}),
],
resend: sideEffect(keepTrack),
// retry in next run
sameAsSuccess: [
sideEffect(() => setTxPending({hash})),
sideEffect(() => typeof okCb === 'function' && okCb(hash)),
sideEffect(keepTrack),
],
}),
)
.done()
},
}),
)
Expand Down

0 comments on commit b5fd72e

Please sign in to comment.