diff --git a/package.json b/package.json index a194811a6..6cd08920b 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "@craco/craco": "^6.1.1", "@headlessui/react": "^1.1.1", "@heroicons/react": "^2.0.18", - "@interlay/bridge": "^0.5.0", + "@interlay/bridge": "^0.5.1", "@interlay/interbtc-api": "2.6.0", "@interlay/monetary-js": "0.7.3", "@polkadot/api": "10.9.1", diff --git a/src/pages/SendAndReceive/SendAndReceiveForms/components/BridgeForm/BridgeForm.tsx b/src/pages/SendAndReceive/SendAndReceiveForms/components/BridgeForm/BridgeForm.tsx index b9efdc4c5..0176f48ee 100644 --- a/src/pages/SendAndReceive/SendAndReceiveForms/components/BridgeForm/BridgeForm.tsx +++ b/src/pages/SendAndReceive/SendAndReceiveForms/components/BridgeForm/BridgeForm.tsx @@ -1,6 +1,5 @@ import { ChainName } from '@interlay/bridge'; -import { CurrencyExt, newMonetaryAmount } from '@interlay/interbtc-api'; -import { MonetaryAmount } from '@interlay/monetary-js'; +import { newMonetaryAmount } from '@interlay/interbtc-api'; import { web3FromAddress } from '@polkadot/extension-dapp'; import { mergeProps } from '@react-aria/utils'; import { ChangeEventHandler, Key, useCallback, useEffect, useState } from 'react'; @@ -45,7 +44,6 @@ const BridgeForm = (): JSX.Element => { const [destinationChains, setDestinationChains] = useState([]); const [transferableTokens, setTransferableTokens] = useState([]); const [currentToken, setCurrentToken] = useState(); - const [maxTransferable, setMaxTransferable] = useState>(); const prices = useGetPrices(); const { t } = useTranslation(); @@ -66,7 +64,9 @@ const BridgeForm = (): JSX.Element => { minAmount: currentToken ? newMonetaryAmount(currentToken.minTransferAmount, getCurrencyFromTicker(currentToken.value), true) : undefined, - maxAmount: maxTransferable + maxAmount: currentToken + ? newMonetaryAmount(currentToken.balance, getCurrencyFromTicker(currentToken.value), true) + : undefined } }; @@ -193,25 +193,6 @@ const BridgeForm = (): JSX.Element => { // eslint-disable-next-line react-hooks/exhaustive-deps }, [accountId]); - // TODO: This is a hotfix for this issue: - // https://github.com/interlay/interbtc-ui/issues/1644 - // https://discord.com/channels/745259537707040778/1210509457902018600 - // Revert this change when fixed in the bridge and revert to currentToken.balance - useEffect(() => { - if (!currentToken) return; - - const fromField = form.values[BRIDGE_FROM_FIELD]; - const balance = newSafeMonetaryAmount(currentToken?.balance, getCurrencyFromTicker(currentToken.value), true); - - // An upstream change allows users to make transactions which fall below the ED when transferring from - // Polkadot or Kusama. This needs to be fixed in the bridge, but setting max balance to 95% mitigates - // the issue for now. - const transferable = fromField === 'polkadot' || fromField === 'kusama' ? balance.mul(0.95) : balance; - - setMaxTransferable(transferable); - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [currentToken]); - if (!originatingChains || !destinationChains || !transferableTokens.length) { return ( @@ -244,8 +225,8 @@ const BridgeForm = (): JSX.Element => { handleTickerChange(ticker as string, BRIDGE_TOKEN_FIELD), diff --git a/yarn.lock b/yarn.lock index 735eee2d6..6c26f1c53 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2966,10 +2966,10 @@ resolved "https://registry.yarnpkg.com/@iarna/toml/-/toml-2.2.5.tgz#b32366c89b43c6f8cefbdefac778b9c828e3ba8c" integrity sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg== -"@interlay/bridge@^0.5.0": - version "0.5.0" - resolved "https://registry.yarnpkg.com/@interlay/bridge/-/bridge-0.5.0.tgz#ed0441238aacdcb9ed68bc9ef955a867b0a498b4" - integrity sha512-oaOzVWqhMeyHFyUdPWXcslC9HWCpSb5uBC1yOBt4wBv83oAbZN4nYFz8jHn6ePFY5ABDcXn7JhVjKjtpRl3+VQ== +"@interlay/bridge@^0.5.1": + version "0.5.1" + resolved "https://registry.yarnpkg.com/@interlay/bridge/-/bridge-0.5.1.tgz#86524a64fe07ac663ea48b8645c73a707cf8efdb" + integrity sha512-AZdoo+NJkoFrONAiDIrvs1wxBwl7MayAjjCIpmWL58SnTtrhS76CewROoYPdP4vRkOx294snUW4lFL05+jf35w== dependencies: "@acala-network/api" "^5" "@acala-network/sdk" "^4.1.9-7"