Skip to content

Commit

Permalink
Tom/bridge 0.5.1 (#1651)
Browse files Browse the repository at this point in the history
* chore: bump bridge

* fix: revert xcm UI hotfix
  • Loading branch information
tomjeatt authored Mar 1, 2024
1 parent abd15cc commit 3afbb64
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 30 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -45,7 +44,6 @@ const BridgeForm = (): JSX.Element => {
const [destinationChains, setDestinationChains] = useState<Chains>([]);
const [transferableTokens, setTransferableTokens] = useState<XCMTokenData[]>([]);
const [currentToken, setCurrentToken] = useState<XCMTokenData>();
const [maxTransferable, setMaxTransferable] = useState<MonetaryAmount<CurrencyExt>>();

const prices = useGetPrices();
const { t } = useTranslation();
Expand All @@ -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
}
};

Expand Down Expand Up @@ -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 (
<Flex justifyContent='center'>
Expand Down Expand Up @@ -244,8 +225,8 @@ const BridgeForm = (): JSX.Element => {
<TokenInput
placeholder='0.00'
label='Transfer amount'
balance={maxTransferable?.toString() || 0}
humanBalance={maxTransferable?.toString() || 0}
balance={currentToken?.balance.toString() || 0}
humanBalance={currentToken?.balance.toString() || 0}
valueUSD={valueUSD || 0}
selectProps={mergeProps(form.getSelectFieldProps(BRIDGE_TOKEN_FIELD), {
onSelectionChange: (ticker: Key) => handleTickerChange(ticker as string, BRIDGE_TOKEN_FIELD),
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 3afbb64

Please sign in to comment.