Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: minor changes to thorchain swapper tx status during swaps #7830

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ export const thorchainApi: SwapperApi = {
}

const latestOutTx = data.out_txs?.[data.out_txs.length - 1]
const hasOutboundTx = latestOutTx?.chain !== 'THOR'
const hasOutboundTx = latestOutTx !== undefined && latestOutTx.chain !== 'THOR'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So turns out, if there is no latestOutTx it means it doesn't actually have an outbound tx 😅


const buyTxHash = parseThorBuyTxHash(txHash, latestOutTx)

Expand All @@ -386,6 +386,7 @@ export const thorchainApi: SwapperApi = {
)

if (outboundTxConfirmations !== undefined && outboundTxConfirmations > 0) {
console.log({ outboundTxConfirmations, hasOutboundTx, buyTxHash })
return {
buyTxHash,
status: TxStatus.Confirmed,
Expand All @@ -396,6 +397,8 @@ export const thorchainApi: SwapperApi = {

const { message, status } = getLatestThorTxStatusMessage(data, hasOutboundTx)

console.log({ message, status })

return {
buyTxHash,
status,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,18 @@ export const getLatestThorTxStatusMessage = (
}
}

return { message: obj.pending ? 'Swap pending' : 'Swap complete', status: TxStatus.Pending }
return {
message: obj.pending ? 'Swap pending' : 'Swap complete, awaiting finalization',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not for this PR at all, but it occurred to me whilst reading this that all of these probably need actual translations!

status: TxStatus.Pending,
}
}
case 'swap_finalised': {
const obj = response.stages[key]
if (obj === undefined) continue

if (!hasOutboundTx && obj.completed) {
return {
message: 'Swap finalized',
message: 'Swap finalized, awaiting transaction confirmation',
status: TxStatus.Confirmed,
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const StreamingSwap = (props: StreamingSwapProps) => {
<Row>
<Row.Label>{translate('trade.streamStatus')}</Row.Label>
{totalSwapCount > 0 && (
<Row.Value>{`${attemptedSwapCount} of ${totalSwapCount}`}</Row.Value>
<Row.Value>{`${attemptedSwapCount - failedSwaps.length} of ${totalSwapCount}`}</Row.Value>
)}
</Row>
<Row>
Expand All @@ -36,7 +36,7 @@ export const StreamingSwap = (props: StreamingSwapProps) => {
size='sm'
min={0}
max={totalSwapCount}
value={attemptedSwapCount}
value={attemptedSwapCount - failedSwaps.length}
hasStripe={!isComplete}
isAnimated={!isComplete}
colorScheme={isComplete ? 'green' : 'blue'}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,11 @@ export const useThorStreamingProgress = (
}, [cancelPolling, dispatch, hopIndex, poll, sellTxHash, confirmedTradeId])

const result = useMemo(() => {
const numSuccessfulSwaps =
(streamingSwapMeta?.attemptedSwapCount ?? 0) - (streamingSwapMeta?.failedSwaps?.length ?? 0)

const isComplete =
streamingSwapMeta !== undefined &&
streamingSwapMeta.attemptedSwapCount === streamingSwapMeta.totalSwapCount
streamingSwapMeta !== undefined && numSuccessfulSwaps >= streamingSwapMeta.totalSwapCount

return {
isComplete,
Expand Down
Loading