Skip to content

Commit

Permalink
Merge branch 'master' into release/kintsugi/2.41.8
Browse files Browse the repository at this point in the history
* master: (229 commits)
  chore: release v2.41.8
  hotfix: XCM polkadot/kintsugi max transferable balance (#1645)
  Revert "[release] Interlay 2.41.7 (#1639)" (#1641)
  [release] Interlay 2.41.7 (#1639)
  chore: release v2.41.7
  fix: chart counter enum and lower value for collateral (#1638)
  chore: release v2.41.6
  refactor: line chart config (#1635)
  chore: release v2.41.5
  chore: bump bridge (#1631)
  chore: release v2.41.4
  api: rewrite python functions in javascript (#1630)
  chore: release v2.41.3
  Switch Bifrost RPC node (#1627)
  chore: release v2.41.2
  api: add dia fair price feed (#1619)
  chore: release v2.41.1
  Tom/update parallel xcm nodes (#1621)
  Tom/hotfix/disable parallel xcm channel (#1620)
  chore: release v2.41.0
  ...

# Conflicts:
#	package.json
#	src/pages/SendAndReceive/SendAndReceiveForms/components/BridgeForm/BridgeForm.tsx
  • Loading branch information
tomjeatt committed Feb 23, 2024
2 parents cf9ecee + 709e416 commit 0f39586
Show file tree
Hide file tree
Showing 2 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
@@ -1,6 +1,6 @@
{
"name": "interbtc-ui",
"version": "2.41.7",
"version": "2.41.8",
"private": true,
"dependencies": {
"@craco/craco": "^6.1.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ChainName } from '@interlay/bridge';
import { newMonetaryAmount } from '@interlay/interbtc-api';
import { CurrencyExt, newMonetaryAmount } from '@interlay/interbtc-api';
import { MonetaryAmount } from '@interlay/monetary-js';
import { web3FromAddress } from '@polkadot/extension-dapp';
import { mergeProps } from '@react-aria/utils';
import { ChangeEventHandler, Key, useCallback, useEffect, useState } from 'react';
Expand Down Expand Up @@ -44,6 +45,7 @@ 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 @@ -64,9 +66,7 @@ const BridgeForm = (): JSX.Element => {
minAmount: currentToken
? newMonetaryAmount(currentToken.minTransferAmount, getCurrencyFromTicker(currentToken.value), true)
: undefined,
maxAmount: currentToken
? newMonetaryAmount(currentToken.balance, getCurrencyFromTicker(currentToken.value), true)
: undefined
maxAmount: maxTransferable
}
};

Expand Down Expand Up @@ -193,6 +193,25 @@ 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 @@ -225,8 +244,8 @@ const BridgeForm = (): JSX.Element => {
<TokenInput
placeholder='0.00'
label='Transfer amount'
balance={currentToken?.balance.toString() || 0}
humanBalance={currentToken?.balance.toString() || 0}
balance={maxTransferable?.toString() || 0}
humanBalance={maxTransferable?.toString() || 0}
valueUSD={valueUSD || 0}
selectProps={mergeProps(form.getSelectFieldProps(BRIDGE_TOKEN_FIELD), {
onSelectionChange: (ticker: Key) => handleTickerChange(ticker as string, BRIDGE_TOKEN_FIELD),
Expand Down

0 comments on commit 0f39586

Please sign in to comment.