diff --git a/package.json b/package.json index 72bbdf56849..bca2713f2f6 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,7 @@ "@rabby-wallet/gnosis-sdk": "1.3.9", "@rabby-wallet/page-provider": "0.4.2", "@rabby-wallet/rabby-action": "0.1.4", - "@rabby-wallet/rabby-api": "0.8.4-beta.0", + "@rabby-wallet/rabby-api": "0.8.4", "@rabby-wallet/rabby-security-engine": "2.0.7", "@rabby-wallet/rabby-swap": "0.0.40", "@rabby-wallet/widgets": "1.0.9", diff --git a/src/ui/views/Bridge/Component/BridgeContent.tsx b/src/ui/views/Bridge/Component/BridgeContent.tsx index 4648b9a2dc0..d2db4039161 100644 --- a/src/ui/views/Bridge/Component/BridgeContent.tsx +++ b/src/ui/views/Bridge/Component/BridgeContent.tsx @@ -67,6 +67,8 @@ export const BridgeContent = () => { isCustomSlippage, setAutoSlippage, setIsCustomSlippage, + + clearExpiredTimer, } = useBridge(); const amountAvailable = useMemo(() => Number(amount) > 0, [amount]); @@ -305,6 +307,7 @@ export const BridgeContent = () => { ) { await runBuildSwapTxs(); setIsShowSign(true); + clearExpiredTimer(); } else { gotoBridge(); } @@ -528,12 +531,14 @@ export const BridgeContent = () => { txs={txs} onClose={() => { setIsShowSign(false); + refresh((e) => e + 1); setTimeout(() => { mutateTxs([]); }, 500); }} onReject={() => { setIsShowSign(false); + refresh((e) => e + 1); mutateTxs([]); }} onResolve={() => { diff --git a/src/ui/views/Bridge/Component/BridgeToTokenSelect.tsx b/src/ui/views/Bridge/Component/BridgeToTokenSelect.tsx index 9e8bd0ad851..7f743d3bfae 100644 --- a/src/ui/views/Bridge/Component/BridgeToTokenSelect.tsx +++ b/src/ui/views/Bridge/Component/BridgeToTokenSelect.tsx @@ -137,7 +137,6 @@ const BridgeToTokenSelect = ({ const list = await wallet.openapi.getBridgeToTokenList({ from_chain_id: fromChainId, from_token_id: fromTokenId, - // @ts-expect-error to_chain_id to_chain_id: chainId, q: queryConds.keyword, }); diff --git a/src/ui/views/Bridge/Component/BridgeToken.tsx b/src/ui/views/Bridge/Component/BridgeToken.tsx index 3acf158e268..f009a7d0114 100644 --- a/src/ui/views/Bridge/Component/BridgeToken.tsx +++ b/src/ui/views/Bridge/Component/BridgeToken.tsx @@ -90,13 +90,19 @@ export const BridgeToken = ({ const openFeePopup = useSetSettingVisible(); + const isMaxRef = useRef(false); + const inputRef = useRef(); useLayoutEffect(() => { if (isFromToken) { - if (document?.activeElement !== inputRef.current?.input) { + if ( + document?.activeElement !== inputRef.current?.input && + !isMaxRef.current + ) { inputRef.current?.focus(); } + isMaxRef.current = false; } }, [value]); @@ -120,6 +126,7 @@ export const BridgeToken = ({ const handleMax = React.useCallback(() => { if (token) { + isMaxRef.current = true; onInputChange?.(tokenAmountBn(token)?.toString(10)); } }, [token?.raw_amount_hex_str, onInputChange]); diff --git a/src/ui/views/Bridge/hooks/token.tsx b/src/ui/views/Bridge/hooks/token.tsx index f45d2934c4f..b6754c806e4 100644 --- a/src/ui/views/Bridge/hooks/token.tsx +++ b/src/ui/views/Bridge/hooks/token.tsx @@ -601,7 +601,15 @@ export const useBridge = () => { return false; }, [fromToken, toToken, amount, selectedBridgeQuote]); + const clearExpiredTimer = useCallback(() => { + if (expiredTimer.current) { + clearTimeout(expiredTimer.current); + } + }, []); + return { + clearExpiredTimer, + fromChain, fromToken, setFromToken, diff --git a/yarn.lock b/yarn.lock index f0f55338848..155cc5a09fd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4781,10 +4781,10 @@ resolved "https://registry.yarnpkg.com/@rabby-wallet/rabby-action/-/rabby-action-0.1.4.tgz#c82e7c8b538b7dfd94506c4f89f78aca7ca880ef" integrity sha512-6ttnlpGHcO2v/qyYo8epBbSutfS9OZXfXr9mfapuveoBvzqUwvE6ej3bsmdtc+qFhFeH7HeiwASpY6xaTM4E1w== -"@rabby-wallet/rabby-api@0.8.4-beta.0": - version "0.8.4-beta.0" - resolved "https://registry.yarnpkg.com/@rabby-wallet/rabby-api/-/rabby-api-0.8.4-beta.0.tgz#1ae4418a79a6e9d3b50305f50d8951ae0a82e0cb" - integrity sha512-XsLXk2rtacIG4fh5NUa3CYT3oYvu9V9+56P+YdgsxBZGMpKQL+NJJ2Bq8oN7gLoz1g13FtRAWDHjHuR9DOiuSw== +"@rabby-wallet/rabby-api@0.8.4": + version "0.8.4" + resolved "https://registry.yarnpkg.com/@rabby-wallet/rabby-api/-/rabby-api-0.8.4.tgz#ef1979eea94eb5fe4e07fe123444a7213178ce15" + integrity sha512-pN6fL6YHhmW7MTmtJEftfvkljYdgcEtJKk2hX2uBfHJQVRXU+jiGOPhSHPE1yfKV4LNwptdV1jtBv3KaYyKa8Q== dependencies: "@rabby-wallet/rabby-sign" "0.4.0" axios "^0.27.2"