diff --git a/package.json b/package.json index 35a5f32c3..a3cce73a9 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "@galacticcouncil/math-xyk": "^1.0.0", "@galacticcouncil/sdk": "^5.0.1", "@galacticcouncil/ui": "^5.2.3", - "@galacticcouncil/xcm-cfg": "^5.5.1", + "@galacticcouncil/xcm-cfg": "^5.6.0", "@galacticcouncil/xcm-core": "^5.4.0", "@galacticcouncil/xcm-sdk": "^7.0.0", "@hookform/resolvers": "^3.3.4", diff --git a/src/api/payments.ts b/src/api/payments.ts index b80976402..999e08ab9 100644 --- a/src/api/payments.ts +++ b/src/api/payments.ts @@ -32,23 +32,46 @@ export const getAcceptedCurrency = (api: ApiPromise) => async () => { } export const useAcceptedCurrencies = (ids: string[]) => { - const { api, isLoaded } = useRpcProvider() + const { api, isLoaded, tradeRouter } = useRpcProvider() const { native } = useAssets() - return useQuery(QUERY_KEYS.acceptedCurrencies, getAcceptedCurrency(api), { - enabled: isLoaded && ids.length > 0, - select: (assets) => { + return useQuery( + QUERY_KEYS.acceptedCurrencies(ids), + async () => { + const [pools, acceptedCurrency] = await Promise.all([ + tradeRouter.getPools(), + getAcceptedCurrency(api)(), + ]) + return ids.map((id) => { - const response = assets.find((asset) => asset.id === id) + const currency = acceptedCurrency.find((currency) => currency.id === id) + + if (currency) { + return currency + } + + if (id === native.id) { + return { id, accepted: true, data: undefined } + } + + const hasPoolWithDOT = !!pools.find((pool) => { + return ( + pool.tokens.find((token) => token.id === id) && + pool.tokens.find((token) => token.id === "5") + ) + }) - return response - ? response - : id === native.id - ? { id, accepted: true, data: undefined } - : { id, accepted: false, data: undefined } + if (hasPoolWithDOT) { + return { id, accepted: true, data: undefined } + } + + return { id, accepted: false, data: undefined } }) }, - }) + { + enabled: isLoaded && ids.length > 0, + }, + ) } export const useSetAsFeePayment = () => { diff --git a/src/i18n/locales/en/translations.json b/src/i18n/locales/en/translations.json index 153934dc8..5c6b83549 100644 --- a/src/i18n/locales/en/translations.json +++ b/src/i18n/locales/en/translations.json @@ -844,7 +844,7 @@ "staking.dashboard.rewards.legend.current": "Current rewards", "staking.dashboard.rewards.legend.future": "Rewards after voting", "staking.dashboard.rewards.legend.tooltip": "You have to vote max conviction with whole staking position", - "staking.dashboard.graph.axisY": "Paylable Percentage", + "staking.dashboard.graph.axisY": "Payable Percentage", "staking.dashboard.graph.axisX": "Days", "staking.dashboard.rewards.button": "Claim", "staking.dashboard.stats.chart.label": "Staked HDX", diff --git a/src/sections/assets/AssetsModal.utils.tsx b/src/sections/assets/AssetsModal.utils.tsx index afbf4531f..a0f437727 100644 --- a/src/sections/assets/AssetsModal.utils.tsx +++ b/src/sections/assets/AssetsModal.utils.tsx @@ -18,6 +18,7 @@ interface useAssetsModalProps { allAssets?: boolean confirmRequired?: boolean defaultSelectedAsssetId?: string + withExternal?: boolean } export const useAssetsModal = ({ @@ -28,6 +29,7 @@ export const useAssetsModal = ({ allAssets, confirmRequired, defaultSelectedAsssetId, + withExternal, }: useAssetsModalProps) => { const { t } = useTranslation() const [isOpen, setIsOpen] = useState(false) @@ -61,6 +63,7 @@ export const useAssetsModal = ({ allAssets={allAssets} confirmRequired={confirmRequired} defaultSelectedAsssetId={defaultSelectedAsssetId} + withExternal={withExternal} /> ) : null diff --git a/src/sections/pools/modals/AddLiquidity/AddLiquidityInfoCard.tsx b/src/sections/pools/modals/AddLiquidity/AddLiquidityInfoCard.tsx index fb9f8f27f..b0580dc53 100644 --- a/src/sections/pools/modals/AddLiquidity/AddLiquidityInfoCard.tsx +++ b/src/sections/pools/modals/AddLiquidity/AddLiquidityInfoCard.tsx @@ -13,7 +13,10 @@ export const PoolAddLiquidityInformationCard = () => { {t("liquidity.add.modal.information.text")} - + {t("liquidity.add.modal.information.linkText")} diff --git a/src/sections/staking/StakingPage.utils.ts b/src/sections/staking/StakingPage.utils.ts index 9b8cbdfaa..3678de517 100644 --- a/src/sections/staking/StakingPage.utils.ts +++ b/src/sections/staking/StakingPage.utils.ts @@ -543,9 +543,9 @@ export const useClaimReward = () => { stakePosition.accumulatedSlashPoints.toString(), ) - const extraPaylablePercentage = wasm.sigmoid(extraPoints, a, b) + const extraPayablePercentage = wasm.sigmoid(extraPoints, a, b) - extraPayablePercentageHuman = scaleHuman(extraPaylablePercentage, "q") + extraPayablePercentageHuman = scaleHuman(extraPayablePercentage, "q") .multipliedBy(100) .toString() } @@ -571,7 +571,7 @@ export const useClaimReward = () => { BN(payablePercentageHuman).gte(chartPoints.y) && (arr[i + 1] ? BN(payablePercentageHuman).lt(arr[i + 1].y) : true) - //calculate paylable percentage if vote ongoing referendas + // calculate payable percentage if vote ongoing referendas const currentSecondary = extraPayablePercentageHuman ? BN(extraPayablePercentageHuman).gte(chartPoints.y) && (arr[i + 1] ? BN(extraPayablePercentageHuman).lt(arr[i + 1].y) : true) diff --git a/src/sections/transaction/ReviewTransactionForm.utils.tsx b/src/sections/transaction/ReviewTransactionForm.utils.tsx index 672485caa..af9785e9a 100644 --- a/src/sections/transaction/ReviewTransactionForm.utils.tsx +++ b/src/sections/transaction/ReviewTransactionForm.utils.tsx @@ -266,6 +266,7 @@ export const useEditFeePaymentAsset = ( defaultSelectedAsssetId: feePaymentAssetId, allowedAssets: acceptedFeePaymentAssets, onSelect: (asset) => feeAsPayment.mutate(asset.id), + withExternal: true, }) return { diff --git a/src/sections/wallet/assets/table/actions/WalletAssetsTableActions.tsx b/src/sections/wallet/assets/table/actions/WalletAssetsTableActions.tsx index 8e391f6ee..ccecccc9c 100644 --- a/src/sections/wallet/assets/table/actions/WalletAssetsTableActions.tsx +++ b/src/sections/wallet/assets/table/actions/WalletAssetsTableActions.tsx @@ -91,7 +91,7 @@ export const WalletAssetsTableActions = (props: Props) => { icon: , label: t("wallet.assets.table.actions.deposit"), onSelect: () => navigate({ to: LINKS.cross_chain }), - disabled: account?.isExternalWalletConnected, + disabled: account?.isExternalWalletConnected || props.asset.meta.isErc20, }, ] @@ -176,8 +176,10 @@ export const WalletAssetsTableActions = (props: Props) => { account?.isExternalWalletConnected ? [] : [ - ...buttons.filter((button) => - hiddenElementsKeys.includes(button.key), + ...buttons.filter( + (button) => + hiddenElementsKeys.includes(button.key) && + !button.disabled, ), ...actionItems, ] diff --git a/src/sections/wallet/assets/table/actions/WalletAssetsTableActionsMob.tsx b/src/sections/wallet/assets/table/actions/WalletAssetsTableActionsMob.tsx index 8d9289ac6..f0b43f6f2 100644 --- a/src/sections/wallet/assets/table/actions/WalletAssetsTableActionsMob.tsx +++ b/src/sections/wallet/assets/table/actions/WalletAssetsTableActionsMob.tsx @@ -195,7 +195,9 @@ export const WalletAssetsTableActionsMob = ({