Skip to content
Closed
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
49 changes: 43 additions & 6 deletions src/ui/views/Swap/Component/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ export const Main = () => {
} = useTwoStepSwap({
txs,
chain,
enable: !!canUseDirectSubmitTx && !!currentAccount?.type,
enable: true, //!!canUseDirectSubmitTx && !!currentAccount?.type,
type: 'approveSwap',
onApprovePending,
});
Expand Down Expand Up @@ -574,19 +574,56 @@ export const Main = () => {
setMiniSignLoading(false);
}
return;
} else if (shouldTwoStepSwap) {
if (shouldTwoStepSwap && isApprove && currentTxs?.[0]) {
wallet.addCacheHistoryData(
`${chain}-${currentTxs?.[0].data}`,
{
address: userAddress,
chainId: findChain({ enum: chain })?.id || 0,
amount: Number(inputAmount),
token: payToken,
status: 'pending',
createdAt: Date.now(),
} as any,
'approveSwap'
);
}
// not supported miniSign account
try {
clearExpiredTimer();
setMiniSignLoading(true);
const hash = await wallet.sendRequest<string>({
$ctx: {
category: 'Swap',
source: 'swap',
trigger: rbiSource,
swapUseSlider,
},
method: 'eth_sendTransaction',
params: currentTxs,
});
miniSignNextStep(hash);
if (!isApprove) {
refresh((e) => e + 1);
mutateTxs([]);
}
} catch (error) {
console.log('two step swap fail:', error);
refresh((e) => e + 1);
mutateTxs([]);
}
} else {
gotoSwap();
}
});

useEffect(() => {
if (!swapBtnDisabled && activeProvider) {
if (canUseDirectSubmitTx) {
mutateTxs([]);
runBuildSwapTxs();
}
mutateTxs([]);
runBuildSwapTxs();
}
}, [swapBtnDisabled, canUseDirectSubmitTx, activeProvider]);
}, [swapBtnDisabled, activeProvider]);

const history = useHistory();

Expand Down
Loading