Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dmy147 committed Nov 11, 2024
1 parent b993edd commit ed2d6b0
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 5 additions & 0 deletions src/ui/views/Bridge/Component/BridgeContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ export const BridgeContent = () => {
isCustomSlippage,
setAutoSlippage,
setIsCustomSlippage,

clearExpiredTimer,
} = useBridge();

const amountAvailable = useMemo(() => Number(amount) > 0, [amount]);
Expand Down Expand Up @@ -305,6 +307,7 @@ export const BridgeContent = () => {
) {
await runBuildSwapTxs();
setIsShowSign(true);
clearExpiredTimer();
} else {
gotoBridge();
}
Expand Down Expand Up @@ -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={() => {
Expand Down
1 change: 0 additions & 1 deletion src/ui/views/Bridge/Component/BridgeToTokenSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand Down
9 changes: 8 additions & 1 deletion src/ui/views/Bridge/Component/BridgeToken.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,19 @@ export const BridgeToken = ({

const openFeePopup = useSetSettingVisible();

const isMaxRef = useRef(false);

const inputRef = useRef<Input>();

useLayoutEffect(() => {
if (isFromToken) {
if (document?.activeElement !== inputRef.current?.input) {
if (
document?.activeElement !== inputRef.current?.input &&
!isMaxRef.current
) {
inputRef.current?.focus();
}
isMaxRef.current = false;
}
}, [value]);

Expand All @@ -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]);
Expand Down
8 changes: 8 additions & 0 deletions src/ui/views/Bridge/hooks/token.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]-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/[email protected]":
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"
Expand Down

0 comments on commit ed2d6b0

Please sign in to comment.