Skip to content

Commit

Permalink
Merge branch 'master' into release/kintsugi/2.41.10
Browse files Browse the repository at this point in the history
* master: (232 commits)
  Tom/bridge 0.5.1 (#1651)
  chore: release v2.41.9
  chore: bump bridge (#1648)
  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
  ...

# Conflicts:
#	package.json
#	src/pages/SendAndReceive/SendAndReceiveForms/components/BridgeForm/BridgeForm.tsx
#	yarn.lock
  • Loading branch information
tomjeatt committed Mar 1, 2024
2 parents 2c6126c + 3afbb64 commit 93b0ab9
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 93b0ab9

Please sign in to comment.