Skip to content

Commit 273bd60

Browse files
committed
fix: fix status rejected BTC and BTC based due to dust amount transactions in chat
1 parent 15da562 commit 273bd60

File tree

7 files changed

+39
-10
lines changed

7 files changed

+39
-10
lines changed

src/hooks/queries/transaction/useBtcTransactionQuery.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,14 @@ export function useBtcTransactionQuery(
2727
return pendingTransaction
2828
}
2929
},
30-
retry: retryFactory(Cryptos.BTC, unref(transactionId)),
30+
retry: (failureCount: number): boolean => {
31+
// Don't retry dust amount BTC transactions
32+
const dustedIds = store.state.btc.dustedTransactionsIds || []
33+
if (dustedIds.length > 0 && dustedIds.includes(unref(transactionId))) {
34+
return false
35+
}
36+
return retryFactory(Cryptos.BTC, unref(transactionId))(failureCount)
37+
},
3138
retryDelay: retryDelayFactory(Cryptos.BTC, unref(transactionId)),
3239
refetchInterval: ({ state }) => refetchIntervalFactory(Cryptos.BTC, state.status, state.data),
3340
refetchOnWindowFocus: false,

src/hooks/queries/transaction/useDashTransactionQuery.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,14 @@ export function useDashTransactionQuery(
2727
return pendingTransaction
2828
}
2929
},
30-
retry: retryFactory(Cryptos.DASH, unref(transactionId)),
30+
retry: (failureCount: number): boolean => {
31+
// Don't retry dust amount DASH transactions
32+
const dustedIds = store.state.dash.dustedTransactionsIds || []
33+
if (dustedIds.length > 0 && dustedIds.includes(unref(transactionId))) {
34+
return false
35+
}
36+
return retryFactory(Cryptos.DASH, unref(transactionId))(failureCount)
37+
},
3138
retryDelay: retryDelayFactory(Cryptos.DASH, unref(transactionId)),
3239
refetchInterval: ({ state }) => refetchIntervalFactory(Cryptos.DASH, state.status, state.data),
3340
refetchOnWindowFocus: false,

src/hooks/queries/transaction/useDogeTransactionQuery.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,14 @@ export function useDogeTransactionQuery(
2727
return pendingTransaction
2828
}
2929
},
30-
retry: retryFactory(Cryptos.DOGE, unref(transactionId)),
30+
retry: (failureCount: number): boolean => {
31+
// Don't retry dust amount DOGE transactions
32+
const dustedIds = store.state.doge.dustedTransactionsIds || []
33+
if (dustedIds.length > 0 && dustedIds.includes(unref(transactionId))) {
34+
return false
35+
}
36+
return retryFactory(Cryptos.DOGE, unref(transactionId))(failureCount)
37+
},
3138
retryDelay: retryDelayFactory(Cryptos.DOGE, unref(transactionId)),
3239
refetchInterval: ({ state }) => refetchIntervalFactory(Cryptos.DOGE, state.status, state.data),
3340
refetchOnWindowFocus: false,

src/hooks/queries/transaction/utils.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,7 @@ import {
1515
export function retryFactory(crypto: CryptoSymbol, transactionId: string) {
1616
const txFetchInfo = getTxFetchInfo(crypto)
1717

18-
return (failureCount: number, error: any): boolean => {
19-
// Don't retry BTC transactions on 404 (dust amount rejections)
20-
if (crypto === 'BTC' && error?.response?.status === 404) {
21-
return false
22-
}
23-
18+
return (failureCount: number): boolean => {
2419
const pendingTransaction = PendingTxStore.get(crypto)
2520
const isPendingTransaction = pendingTransaction?.id === transactionId
2621

src/store/modules/btc-base/btc-base-actions.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,15 @@ function createActions(options) {
231231

232232
return hash
233233
} catch (error) {
234+
if (error.response && error.response.data) {
235+
if (
236+
((crypto === 'BTC' || crypto === 'DOGE') && error.response.data.includes('dust')) ||
237+
(crypto === 'DASH' && error.response.data.error.message.includes('dust'))
238+
)
239+
context.commit('dustedTransactionsIds', signedTransaction.txid)
240+
}
234241
context.commit('transactions', [{ hash: signedTransaction.txid, status: 'REJECTED' }])
242+
235243
PendingTxStore.remove(context.state.crypto)
236244
throw error
237245
}

src/store/modules/btc-base/btc-base-mutations.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ export default (initialState) => ({
4444
})
4545
},
4646

47+
dustedTransactionsIds(state, dustedTransactionId) {
48+
state.dustedTransactionsIds.push(dustedTransactionId)
49+
},
50+
4751
areOlderLoading(state, areLoading) {
4852
state.areOlderLoading = areLoading
4953
},

src/store/modules/btc-base/btc-base-state.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ export default () => ({
99
areTransactionsLoading: false,
1010
areRecentLoading: false,
1111
areOlderLoading: false,
12-
bottomReached: false
12+
bottomReached: false,
13+
dustedTransactionsIds: []
1314
})

0 commit comments

Comments
 (0)