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

feat: update thorswap transaction progress #3741

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
20 changes: 11 additions & 9 deletions packages/kit/src/views/Swap/History/HistoryItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,17 @@ const HistoryItemHorizontalView: FC<HistoryItemProps> = ({ tx }) => {
/>
</Box>
<Box flex="1">
<Typography.Body1Strong>
{formatTokenAmount({
token: tx.tokens?.to.token,
amount: tx.tokens?.to.amount,
})}
</Typography.Body1Strong>
<Box flexDirection="row" alignItems="center">
{!tx.actualReceived ? (
<Typography.Caption>~</Typography.Caption>
) : null}
<Typography.Body1Strong>
{formatTokenAmount({
token: tx.tokens?.to.token,
amount: tx.tokens?.to.amount,
})}
</Typography.Body1Strong>
</Box>
<Typography.Body2 color="text-subdued">
{toNetwork?.shortName}
</Typography.Body2>
Expand All @@ -130,9 +135,6 @@ const HistoryItemHorizontalView: FC<HistoryItemProps> = ({ tx }) => {
<Box flexDirection="row" alignItems="center" flex="1">
<Box flex="1">
<Box flexDirection="row" alignItems="center">
{!tx.actualReceived ? (
<Typography.Caption>~</Typography.Caption>
) : null}
<Box flex="1">
<Typography.Body1Strong isTruncated>
{formatTokenAmount({
Expand Down
3 changes: 2 additions & 1 deletion packages/kit/src/views/Swap/Main/Swap/SwapAlert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,14 @@ const RecipientAlert = () => {

const DepositLimitAlert = () => {
const limitsError = useInputLimitsError();
const loading = useAppSelector((s) => s.swap.loading);
const intl = useIntl();
const onAction = useCallback(() => {
if (limitsError?.value) {
backgroundApiProxy.serviceSwap.userInput('INPUT', limitsError.value);
}
}, [limitsError]);
if (limitsError) {
if (limitsError && !loading) {
return (
<Box mt="6">
<Alert
Expand Down
4 changes: 1 addition & 3 deletions packages/kit/src/views/Swap/quoter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -761,9 +761,7 @@ export class SwapQuoter {
) {
const info = await this.thorswap.getTransactionInfo(tx);
if (info) {
const { legs } = info.result;
const lastLegs = legs[legs.length - 1];
return lastLegs.toAmount;
return info.actualReceived;
}
} else {
const historyTx = await this.getHistoryTx(tx);
Expand Down
29 changes: 8 additions & 21 deletions packages/kit/src/views/Swap/quoter/thorswap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ export class ThorSwapQuoter implements Quoter {
if (hash && attachment?.thorswapQuoteId) {
const data = await this.getTransactionInfo(tx);
if (data && data.status === 'success') {
const { legs } = data.result;
const lastLegs = legs[legs.length - 1];
return { status: 'sucesss', destinationTransactionHash: lastLegs.hash };
return {
status: 'sucesss',
destinationTransactionHash: data.destinationTransactionHash,
};
}
return { status: 'pending' };
}
Expand All @@ -51,31 +52,17 @@ export class ThorSwapQuoter implements Quoter {
const { hash, attachment } = tx;
if (hash && attachment?.thorswapQuoteId) {
const baseUrl = await this.getBaseUrl();
const url = `${baseUrl}/transaction_status`;
const url = `${baseUrl}/transaction_status_v2`;
const res = await axios.get(url, {
params: {
hash,
quoteId: attachment?.thorswapQuoteId,
},
});
const data = res.data as {
status: string;
done: boolean;
result: {
quoteId: string;
firstTransactionHash: string;
status: string;
isLending: boolean;
isStreamingSwap: false;
legs: {
chain: string;
hash: string;
fromAsset: string;
fromAmount: string;
toAsset: string;
toAmount: string;
}[];
};
status: 'success' | 'failed' | 'pending';
destinationTransactionHash?: string;
actualReceived?: string;
};
return data;
}
Expand Down