diff --git a/public/_locales/en/messages.json b/public/_locales/en/messages.json index 67635dfdb..10b091d43 100644 --- a/public/_locales/en/messages.json +++ b/public/_locales/en/messages.json @@ -2642,8 +2642,13 @@ "enterCardNumber": { "message": "Enter card number" }, - "onlyForUkrainianCards": { - "message": "Only for Ukrainian banking cards" + "onlyForCountryBankingCards": { + "message": "Only for $country$ banking cards", + "placeholders": { + "country": { + "content": "$1" + } + } }, "buyWithCrypto": { "message": "Buy with Crypto" @@ -2651,14 +2656,6 @@ "buyWithExolix": { "message": "Buy With Exolix" }, - "buyWithExolixDescription": { - "message": "Exchange $number$ cryptocurrencies to TEZ or USDT Tezos instantly and without registration", - "placeholders": { - "number": { - "content": "$1" - } - } - }, "buyWithRamp": { "message": "Buy With Ramp" }, @@ -2666,10 +2663,10 @@ "message": "Buy TEZ using Visa, Mastercard, and all major debit and credit cards. Ramp is available in 160+ countries and territories." }, "sellWithAliceBob": { - "message": "Sell TEZ with Alice-Bob (UAH only)" + "message": "Sell TEZ with Alice-Bob" }, "sellWithAliceBobDescription": { - "message": "Fast and cost-effective exchange of TEZ to UAH." + "message": "Fast and cost-effective exchange of TEZ." }, "selectPaymentProvider": { "message": "Select payment provider" @@ -2781,7 +2778,7 @@ "message": "Sell TEZ details" }, "sellDetailsDescription": { - "message": "Sell TEZ to fiat. Get fiat to Visa, Mastercard Ukrainian cards." + "message": "Sell TEZ to fiat. Get fiat to Visa, Mastercard cards." }, "privacyAndPolicyLinks": { "message": "By clicking $buttonContent$ you agree with \n$termsOfUse$ and $privacyPolicy$", diff --git a/src/app/hooks/AliceBob/useDisabledProceed.ts b/src/app/hooks/AliceBob/use-disabled-proceed.ts similarity index 96% rename from src/app/hooks/AliceBob/useDisabledProceed.ts rename to src/app/hooks/AliceBob/use-disabled-proceed.ts index 8114c5567..5b602004c 100644 --- a/src/app/hooks/AliceBob/useDisabledProceed.ts +++ b/src/app/hooks/AliceBob/use-disabled-proceed.ts @@ -6,8 +6,8 @@ import { useAccount, useBalance } from 'lib/temple/front'; export const useDisabledProceed = ( inputAmount: number | undefined, - minExchangeAmount: number, - maxExchangeAmount: number, + minExchangeAmount = 0, + maxExchangeAmount = 0, isWithdraw = false ) => { const { publicKeyHash } = useAccount(); diff --git a/src/app/hooks/AliceBob/use-output-currencies.ts b/src/app/hooks/AliceBob/use-output-currencies.ts new file mode 100644 index 000000000..a08a3983a --- /dev/null +++ b/src/app/hooks/AliceBob/use-output-currencies.ts @@ -0,0 +1,75 @@ +import { useCallback, useEffect, useState } from 'react'; + +import { getCurrencyNameByCode, knownAliceBobFiatCurrencies } from 'app/store/buy-with-credit-card/utils'; +import { getAliceBobPairsInfo } from 'lib/apis/temple'; +import { FIAT_ICONS_SRC } from 'lib/icons'; + +export interface AliceBobWithdrawCurrency { + name: string; + code: string; + icon: string; + minAmount?: number; + maxAmount?: number; +} + +export const DEFAULT_OUTPUT_CURRENCY = { + name: getCurrencyNameByCode('UAH'), + code: 'UAH', + icon: FIAT_ICONS_SRC.UAH +}; + +export const useOutputCurrencies = ( + setIsApiError: (v: boolean) => void, + outputCurrency: AliceBobWithdrawCurrency, + setOutputCurrency: (currency: AliceBobWithdrawCurrency) => void +) => { + const [isCurrenciesLoading, setIsCurrenciesLoading] = useState(false); + + const [currencies, setCurrencies] = useState([]); + + const getCurrenciesRequest = useCallback(() => { + setIsCurrenciesLoading(true); + + getAliceBobPairsInfo(true) + .then(response => { + const newCurrencies = response.data.pairsInfo.map(pair => { + const code = pair.to.slice(-3); + const minAmount = Number(pair.minamount.split(' ')[0]); + const maxAmount = Number(pair.maxamount.split(' ')[0]); + + if (knownAliceBobFiatCurrencies[code]) { + return { + ...knownAliceBobFiatCurrencies[code], + minAmount, + maxAmount + }; + } + + return { + name: getCurrencyNameByCode(code), + code, + icon: `https://static.moonpay.com/widget/currencies/${code.toLowerCase()}.svg`, + minAmount, + maxAmount + }; + }); + + setCurrencies(newCurrencies); + + if (!outputCurrency.minAmount) { + setOutputCurrency(newCurrencies.find(currency => currency.code === 'UAH') ?? DEFAULT_OUTPUT_CURRENCY); + } + }) + .catch(() => setIsApiError(true)) + .finally(() => setIsCurrenciesLoading(false)); + }, [outputCurrency.minAmount, setIsApiError, setOutputCurrency]); + + useEffect(() => { + getCurrenciesRequest(); + }, [getCurrenciesRequest]); + + return { + isCurrenciesLoading, + currencies + }; +}; diff --git a/src/app/hooks/AliceBob/useOutputEstimation.ts b/src/app/hooks/AliceBob/use-output-estimation.ts similarity index 84% rename from src/app/hooks/AliceBob/useOutputEstimation.ts rename to src/app/hooks/AliceBob/use-output-estimation.ts index 06c5e42ef..2ea5156a6 100644 --- a/src/app/hooks/AliceBob/useOutputEstimation.ts +++ b/src/app/hooks/AliceBob/use-output-estimation.ts @@ -6,10 +6,10 @@ import { estimateAliceBobOutput } from 'lib/apis/temple'; export const useOutputEstimation = ( inputAmount = 0, + outputAssetCode: string, isMinAmountError: boolean, isMaxAmountError: boolean, - setIsApiError: (v: boolean) => void, - isWithdraw = false + setIsApiError: (v: boolean) => void ) => { const [outputAmount, setOutputAmount] = useState(0); const [estimationIsLoading, setLoading] = useState(false); @@ -23,14 +23,14 @@ export const useOutputEstimation = ( if (isValidInput) { setLoading(true); - estimateAliceBobOutput(isWithdraw, inputAmount.toString()) + estimateAliceBobOutput(inputAmount.toString(), 'XTZ', outputAssetCode) .then(response => { setOutputAmount(new BigNumber(response.data.outputAmount).dp(2, BigNumber.ROUND_FLOOR).toNumber()); }) .catch(() => setIsApiError(true)) .finally(() => setLoading(false)); } - }, [inputAmount, isValidInput, isWithdraw, setIsApiError, setLoading]); + }, [inputAmount, isValidInput, outputAssetCode, setIsApiError]); useEffect(() => { getOutputEstimation(); diff --git a/src/app/hooks/AliceBob/useMinMaxExchangeAmounts.ts b/src/app/hooks/AliceBob/useMinMaxExchangeAmounts.ts deleted file mode 100644 index 20844e586..000000000 --- a/src/app/hooks/AliceBob/useMinMaxExchangeAmounts.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { useCallback, useEffect, useState } from 'react'; - -import BigNumber from 'bignumber.js'; - -import { getAliceBobPairInfo } from 'lib/apis/temple'; - -const PENNY = 0.000001; - -export const useMinMaxExchangeAmounts = (setIsApiError: (v: boolean) => void, isWithdraw = false) => { - const [isMinMaxLoading, setIsMinMaxLoading] = useState(false); - - const [minExchangeAmount, setMinExchangeAmount] = useState(0); - const [maxExchangeAmount, setMaxExchangeAmount] = useState(0); - - const updateMinMaxRequest = useCallback(() => { - setIsMinMaxLoading(true); - getAliceBobPairInfo(isWithdraw) - .then(response => { - const normalizedMin = new BigNumber(response.data.pairInfo.minAmount) - .dp(6) - .plus(isWithdraw ? PENNY : 0) - .toNumber(); - const normalizedMax = new BigNumber(response.data.pairInfo.maxAmount).dp(6, BigNumber.ROUND_FLOOR).toNumber(); - - setMinExchangeAmount(normalizedMin); - setMaxExchangeAmount(normalizedMax); - }) - .catch(() => setIsApiError(true)) - .finally(() => setIsMinMaxLoading(false)); - }, [isWithdraw]); - - useEffect(() => { - updateMinMaxRequest(); - }, [updateMinMaxRequest]); - - return { - minExchangeAmount, - maxExchangeAmount, - isMinMaxLoading - }; -}; diff --git a/src/app/pages/BuyWithCreditCard/BuyWithCreditCard.tsx b/src/app/pages/BuyWithCreditCard/BuyWithCreditCard.tsx index 551ddb393..6a4aab33e 100644 --- a/src/app/pages/BuyWithCreditCard/BuyWithCreditCard.tsx +++ b/src/app/pages/BuyWithCreditCard/BuyWithCreditCard.tsx @@ -19,6 +19,7 @@ import { getAssetSymbolToDisplay } from 'lib/buy-with-credit-card/get-asset-symb import { TopUpInputInterface } from 'lib/buy-with-credit-card/topup.interface'; import { shouldShowFieldError } from 'lib/form/should-show-field-error'; import { t, T, toLocalFormat } from 'lib/i18n'; +import { FIAT_ICONS_SRC } from 'lib/icons'; import { useInterval } from 'lib/ui/hooks'; import { BuyWithCreditCardSelectors } from './BuyWithCreditCard.selectors'; @@ -32,7 +33,10 @@ import { usePaymentProviders } from './hooks/use-payment-providers'; import { useUpdateCurrentProvider } from './hooks/use-update-current-provider'; import { AmountErrorType } from './types/amount-error-type'; -const fitFiatIconFn = (currency: TopUpInputInterface) => !currency.icon.startsWith(MOONPAY_ASSETS_BASE_URL); +const FORM_REFRESH_INTERVAL = 20000; + +const fitFiatIconFn = (currency: TopUpInputInterface) => + !currency.icon.startsWith(MOONPAY_ASSETS_BASE_URL) && currency.icon !== FIAT_ICONS_SRC.UAH; export const BuyWithCreditCard: FC = () => { const dispatch = useDispatch(); @@ -130,7 +134,7 @@ export const BuyWithCreditCard: FC = () => { isLoading ); - useInterval(refreshForm, 10000, [refreshForm], false); + useInterval(refreshForm, FORM_REFRESH_INTERVAL, [refreshForm], false); const minAmountStr = useMemo( () => diff --git a/src/app/pages/BuyWithCreditCard/hooks/use-buy-with-credit-card-form.ts b/src/app/pages/BuyWithCreditCard/hooks/use-buy-with-credit-card-form.ts index 7a84fb021..8ec415aaa 100644 --- a/src/app/pages/BuyWithCreditCard/hooks/use-buy-with-credit-card-form.ts +++ b/src/app/pages/BuyWithCreditCard/hooks/use-buy-with-credit-card-form.ts @@ -121,7 +121,13 @@ export const useBuyWithCreditCardForm = () => { url = await createUtorgOrder(outputAmount, inputCurrency.code, publicKeyHash, outputToken.code); break; case TopUpProviderId.AliceBob: - const { data } = await createAliceBobOrder(false, inputAmount.toFixed(), userId, publicKeyHash); + const { data } = await createAliceBobOrder( + inputAmount.toFixed(), + inputCurrency.code, + outputToken.code, + userId, + publicKeyHash + ); url = data.orderInfo.payUrl; break; default: diff --git a/src/app/pages/BuyWithCreditCard/hooks/use-one-payment-provider.ts b/src/app/pages/BuyWithCreditCard/hooks/use-one-payment-provider.ts index 9e6299ca6..b1044bb51 100644 --- a/src/app/pages/BuyWithCreditCard/hooks/use-one-payment-provider.ts +++ b/src/app/pages/BuyWithCreditCard/hooks/use-one-payment-provider.ts @@ -59,8 +59,8 @@ const getOutputAmountFunctions: Record }, [TopUpProviderId.Utorg]: async (inputAmount, inputAsset, outputAsset) => convertFiatAmountToCrypto(inputAsset.code, outputAsset.code, inputAmount), - [TopUpProviderId.AliceBob]: async inputAmount => { - const response = await estimateAliceBobOutput(false, inputAmount.toString()); + [TopUpProviderId.AliceBob]: async (inputAmount, inputAsset, outputAsset) => { + const response = await estimateAliceBobOutput(inputAmount.toString(), inputAsset.code, outputAsset.code); return response.data.outputAmount; } diff --git a/src/app/pages/Withdraw/Debit/AliceBob/steps/InitialStep.tsx b/src/app/pages/Withdraw/Debit/AliceBob/steps/InitialStep.tsx index c25275f73..f660728a3 100644 --- a/src/app/pages/Withdraw/Debit/AliceBob/steps/InitialStep.tsx +++ b/src/app/pages/Withdraw/Debit/AliceBob/steps/InitialStep.tsx @@ -4,9 +4,13 @@ import BigNumber from 'bignumber.js'; import classNames from 'clsx'; import { FormSubmitButton } from 'app/atoms/FormSubmitButton'; -import { useDisabledProceed } from 'app/hooks/AliceBob/useDisabledProceed'; -import { useMinMaxExchangeAmounts } from 'app/hooks/AliceBob/useMinMaxExchangeAmounts'; -import { useOutputEstimation } from 'app/hooks/AliceBob/useOutputEstimation'; +import { useDisabledProceed } from 'app/hooks/AliceBob/use-disabled-proceed'; +import { + AliceBobWithdrawCurrency, + DEFAULT_OUTPUT_CURRENCY, + useOutputCurrencies +} from 'app/hooks/AliceBob/use-output-currencies'; +import { useOutputEstimation } from 'app/hooks/AliceBob/use-output-estimation'; import { ReactComponent as AlertIcon } from 'app/icons/alert.svg'; import styles from 'app/pages/Buy/Crypto/Exolix/Exolix.module.css'; import { WithdrawSelectors } from 'app/pages/Withdraw/Withdraw.selectors'; @@ -14,7 +18,6 @@ import { useUserIdSelector } from 'app/store/settings/selectors'; import { TopUpInput } from 'app/templates/TopUpInput'; import { createAliceBobOrder } from 'lib/apis/temple'; import { t, T } from 'lib/i18n/react'; -import { FIAT_ICONS_SRC } from 'lib/icons'; import { CardNumberInput } from '../components/CardNumberInput'; import { useCardNumberInput } from '../components/use-card-number-input.hook'; @@ -28,15 +31,17 @@ export const InitialStep: FC> = ({ isApiError, setO const [orderIsProcessing, setOrderIsProcessing] = useState(false); const [isFormSubmitted, setIsFormSubmitted] = useState(false); - const [inputAmount, setInputAmount] = useState(undefined); + const [inputAmount, setInputAmount] = useState(); + const [outputCurrency, setOutputCurrency] = useState(DEFAULT_OUTPUT_CURRENCY); + const cardNumberInput = useCardNumberInput(isFormSubmitted); - const { minExchangeAmount, maxExchangeAmount, isMinMaxLoading } = useMinMaxExchangeAmounts(setIsApiError, true); + const { currencies, isCurrenciesLoading } = useOutputCurrencies(setIsApiError, outputCurrency, setOutputCurrency); const { isMinAmountError, isMaxAmountError, isInsufficientTezBalanceError, disabledProceed } = useDisabledProceed( inputAmount, - minExchangeAmount, - maxExchangeAmount, + outputCurrency?.minAmount, + outputCurrency?.maxAmount, true ); @@ -47,10 +52,10 @@ export const InitialStep: FC> = ({ isApiError, setO const { estimationIsLoading, outputAmount } = useOutputEstimation( inputAmount, + outputCurrency.code, isMinAmountError, isMaxAmountError, - setIsApiError, - true + setIsApiError ); const exchangeRate = useMemo( @@ -64,20 +69,20 @@ export const InitialStep: FC> = ({ isApiError, setO const handleSubmit = () => { setIsFormSubmitted(true); - if (!isFormValid) { + if (!isFormValid || !outputCurrency?.code || !inputAmount) { return; } setOrderIsProcessing(true); - createAliceBobOrder(true, inputAmount?.toString() ?? '0', userId, undefined, cardNumberInput.value) + createAliceBobOrder(inputAmount?.toString(), 'XTZ', outputCurrency?.code, userId, undefined, cardNumberInput.value) .then(response => { setOrderInfo(response.data.orderInfo); setStep(1); }) .catch(err => { if (err.response.data.message === NOT_UKRAINIAN_CARD_ERROR_MESSAGE) { - cardNumberInput.setCustomError(t('onlyForUkrainianCards')); + cardNumberInput.setCustomError(t('onlyForCountryBankingCards', 'Ukrainian')); } else { setIsApiError(true); } @@ -87,26 +92,26 @@ export const InitialStep: FC> = ({ isApiError, setO const handleInputAmountChange = (amount?: number) => setInputAmount(amount); - const isLoading = orderIsProcessing || estimationIsLoading || isMinMaxLoading; + const isLoading = orderIsProcessing || estimationIsLoading || isCurrenciesLoading; return ( <>

- +

- +

} currency={{ code: 'TEZ' }} - currenciesList={[]} - minAmount={minExchangeAmount.toString()} - maxAmount={maxExchangeAmount.toString()} + currenciesList={[{ code: 'TEZ' }]} + minAmount={String(outputCurrency?.minAmount ?? '0')} + maxAmount={String(outputCurrency?.maxAmount ?? '0')} isMinAmountError={isMinAmountError} isMaxAmountError={isMaxAmountError} isInsufficientTezBalanceError={isInsufficientTezBalanceError} @@ -121,17 +126,21 @@ export const InitialStep: FC> = ({ isApiError, setO readOnly amountInputDisabled label={} - currency={{ code: 'UAH', icon: FIAT_ICONS_SRC.UAH }} - currenciesList={[]} + currency={outputCurrency} + currenciesList={currencies} + isCurrenciesLoading={isCurrenciesLoading} amount={outputAmount} emptyListPlaceholder={t('noAssetsFound')} + onCurrencySelect={currency => setOutputCurrency(currency)} />

:

-

1 TEZ ≈ {exchangeRate} UAH

+

+ {exchangeRate ? `1 TEZ ≈ ${exchangeRate} ${outputCurrency?.code}` : '-'} +

@@ -140,7 +149,7 @@ export const InitialStep: FC> = ({ isApiError, setO - +
diff --git a/src/app/store/buy-with-credit-card/epics.ts b/src/app/store/buy-with-credit-card/epics.ts index 0a868d493..5cca0b265 100644 --- a/src/app/store/buy-with-credit-card/epics.ts +++ b/src/app/store/buy-with-credit-card/epics.ts @@ -6,7 +6,7 @@ import { ofType } from 'ts-action-operators'; import type { RootState } from 'app/store/root-state.type'; import { getMoonPayCurrencies } from 'lib/apis/moonpay'; -import { getAliceBobPairInfo } from 'lib/apis/temple'; +import { getAliceBobPairsInfo } from 'lib/apis/temple'; import { getCurrenciesInfo as getUtorgCurrenciesInfo } from 'lib/apis/utorg'; import { PAIR_NOT_FOUND_MESSAGE } from 'lib/buy-with-credit-card/constants'; import { getUpdatedFiatLimits } from 'lib/buy-with-credit-card/get-updated-fiat-limits'; @@ -36,7 +36,7 @@ const loadAllCurrenciesEpic: Epic = (action$: Observable) => forkJoin([ getCurrencies$(getMoonPayCurrencies, mapMoonPayProviderCurrencies), getCurrencies$(getUtorgCurrenciesInfo, mapUtorgProviderCurrencies), - getCurrencies$(() => getAliceBobPairInfo(false), mapAliceBobProviderCurrencies) + getCurrencies$(() => getAliceBobPairsInfo(false), mapAliceBobProviderCurrencies) ]).pipe( map(([moonpayCurrencies, utorgCurrencies, tezUahPairInfo]) => loadAllCurrenciesActions.success({ diff --git a/src/app/store/buy-with-credit-card/utils.ts b/src/app/store/buy-with-credit-card/utils.ts index bf95d40bb..1774a400d 100644 --- a/src/app/store/buy-with-credit-card/utils.ts +++ b/src/app/store/buy-with-credit-card/utils.ts @@ -1,5 +1,6 @@ import { isDefined } from '@rnw-community/shared'; import { AxiosResponse } from 'axios'; +import FiatCurrencyInfo from 'currency-codes'; import { Currency, @@ -10,20 +11,52 @@ import { import { AliceBobPairInfo } from 'lib/apis/temple'; import { CurrencyInfoType as UtorgCurrencyInfoType, UtorgCurrencyInfo } from 'lib/apis/utorg'; import { toTokenSlug } from 'lib/assets'; +import { FIAT_ICONS_SRC } from 'lib/icons'; + +interface AliceBobFiatCurrency { + name: string; + code: string; + icon: string; + precision: number; +} const UTORG_FIAT_ICONS_BASE_URL = 'https://utorg.pro/img/flags2/icon-'; const UTORG_CRYPTO_ICONS_BASE_URL = 'https://utorg.pro/img/cryptoIcons'; -const knownUtorgFiatCurrenciesNames: Record = { - PHP: 'Philippine Peso', - INR: 'Indian Rupee' +export const getCurrencyNameByCode = (code: string) => { + const customCurrencyNames: Record = { + UAH: 'Ukrainian Hryvnia', + KZT: 'Kazakhstani Tenge' + }; + + if (isDefined(customCurrencyNames[code])) { + return customCurrencyNames[code]; + } + + const currencyInfo = FiatCurrencyInfo.code(code); + + return isDefined(currencyInfo) ? currencyInfo.currency : '???'; }; -const aliceBobHryvnia = { - name: 'Ukrainian Hryvnia', - code: 'UAH', - icon: '', - precision: 2 +export const knownAliceBobFiatCurrencies: Record = { + UAH: { + name: getCurrencyNameByCode('UAH'), + code: 'UAH', + icon: FIAT_ICONS_SRC.UAH, + precision: 2 + }, + MYR: { + name: getCurrencyNameByCode('MYR'), + code: 'MYR', + icon: `${UTORG_FIAT_ICONS_BASE_URL}MY.svg`, + precision: 2 + }, + KZT: { + name: getCurrencyNameByCode('KZT'), + code: 'KZT', + icon: FIAT_ICONS_SRC.KZT, + precision: 2 + } }; const aliceBobTezos = { @@ -68,11 +101,11 @@ export const mapMoonPayProviderCurrencies = (currencies: Currency[]) => ({ export const mapUtorgProviderCurrencies = (currencies: UtorgCurrencyInfo[]) => ({ fiat: currencies .filter(({ type, depositMax }) => type === UtorgCurrencyInfoType.FIAT && depositMax > 0) - .map(({ display, symbol, depositMin, depositMax, precision }) => ({ - name: knownUtorgFiatCurrenciesNames[symbol] ?? '', - code: symbol, + .map(({ display, symbol: code, depositMin, depositMax, precision }) => ({ + name: getCurrencyNameByCode(code), + code, codeToDisplay: display, - icon: `${UTORG_FIAT_ICONS_BASE_URL}${symbol.slice(0, -1)}.svg`, + icon: `${UTORG_FIAT_ICONS_BASE_URL}${code.slice(0, -1)}.svg`, precision, minAmount: depositMin, maxAmount: depositMax @@ -91,13 +124,28 @@ export const mapUtorgProviderCurrencies = (currencies: UtorgCurrencyInfo[]) => ( })) }); -export const mapAliceBobProviderCurrencies = (response: AxiosResponse<{ pairInfo: AliceBobPairInfo }>) => ({ - fiat: [ - { - ...aliceBobHryvnia, - minAmount: response.data.pairInfo.minAmount, - maxAmount: response.data.pairInfo.maxAmount +export const mapAliceBobProviderCurrencies = (response: AxiosResponse<{ pairsInfo: AliceBobPairInfo[] }>) => ({ + fiat: response.data.pairsInfo.map(pair => { + const [minAmountString, code] = pair.minamount.split(' '); + const minAmount = Number(minAmountString); + const maxAmount = Number(pair.maxamount.split(' ')[0]); + + if (knownAliceBobFiatCurrencies[code]) { + return { + ...knownAliceBobFiatCurrencies[code], + minAmount, + maxAmount + }; } - ], + + return { + name: getCurrencyNameByCode(code), + code, + icon: `https://static.moonpay.com/widget/currencies/${code.toLowerCase()}.svg`, + precision: 2, + minAmount, + maxAmount + }; + }), crypto: [aliceBobTezos] }); diff --git a/src/lib/apis/temple/endpoints/alice-bob.ts b/src/lib/apis/temple/endpoints/alice-bob.ts index 95e626f26..e0ecf6fb8 100644 --- a/src/lib/apis/temple/endpoints/alice-bob.ts +++ b/src/lib/apis/temple/endpoints/alice-bob.ts @@ -47,21 +47,33 @@ export interface AliceBobOrderInfo { } export interface AliceBobPairInfo { - minAmount: number; - maxAmount: number; + from: string; + to: string; + fromnetwork: string | null; + tonetwork: string | null; + in: string; + out: string; + ratetype: string; + amount: string; + tofee: string; + fromfee: string; + minamount: string; + maxamount: string; } export const createAliceBobOrder = ( - isWithdraw: boolean, amount: string, + inputAssetCode: string, + outputAssetCode: string, userId: string, walletAddress?: string, cardNumber?: string ) => templeWalletApi.post<{ orderInfo: AliceBobOrderInfo }>('/alice-bob/create-order', null, { params: { - isWithdraw, amount, + from: getFromToParam(inputAssetCode), + to: getFromToParam(outputAssetCode), userId, walletAddress, cardNumber @@ -71,16 +83,19 @@ export const createAliceBobOrder = ( export const cancelAliceBobOrder = (orderId: string) => templeWalletApi.post('/alice-bob/cancel-order', null, { params: { orderId } }); -export const getAliceBobPairInfo = (isWithdraw: boolean) => - templeWalletApi.get<{ pairInfo: AliceBobPairInfo }>('/alice-bob/get-pair-info', { params: { isWithdraw } }); +export const getAliceBobPairsInfo = (isWithdraw: boolean) => + templeWalletApi.get<{ pairsInfo: AliceBobPairInfo[] }>('/alice-bob/get-pairs-info', { params: { isWithdraw } }); export const getAliceBobOrderInfo = (orderId: string) => templeWalletApi.get<{ orderInfo: AliceBobOrderInfo }>('/alice-bob/check-order', { params: { orderId } }); -export const estimateAliceBobOutput = (isWithdraw: boolean, amount: string) => +export const estimateAliceBobOutput = (amount: string, inputAssetCode: string, outputAssetCode: string) => templeWalletApi.post<{ outputAmount: number }>('/alice-bob/estimate-amount', null, { params: { - isWithdraw, - amount + amount, + from: getFromToParam(inputAssetCode), + to: getFromToParam(outputAssetCode) } }); + +const getFromToParam = (code: string) => (code === 'XTZ' ? 'TEZ' : `CARD${code}`); diff --git a/src/lib/buy-with-credit-card/get-payment-providers-to-display.ts b/src/lib/buy-with-credit-card/get-payment-providers-to-display.ts index f6e3bd89a..9c10fd105 100644 --- a/src/lib/buy-with-credit-card/get-payment-providers-to-display.ts +++ b/src/lib/buy-with-credit-card/get-payment-providers-to-display.ts @@ -17,10 +17,6 @@ const fiatPurchaseProvidersSortPredicate = ( providerA: PaymentProviderInterface, providerB: PaymentProviderInterface ) => { - if (providerA.kycRequired !== providerB.kycRequired) { - return providerA.kycRequired ? -1 : 1; - } - const { outputAmount: providerAOutputAmount = 0 } = providerA; const { outputAmount: providerBOutputAmount = 0 } = providerB; diff --git a/src/lib/icons/fiat.ts b/src/lib/icons/fiat.ts index 69dfe3253..9782fa6f7 100644 --- a/src/lib/icons/fiat.ts +++ b/src/lib/icons/fiat.ts @@ -1,8 +1,10 @@ import FallbackSrc from './assets/token-fallback.png'; +import SrcKZT from './fiat/kzt.png'; import SrcUAH from './fiat/uah.svg'; export const FIAT_FALLBACK_ICON_SRC = FallbackSrc; export namespace FIAT_ICONS_SRC { export const UAH = SrcUAH; + export const KZT = SrcKZT; } diff --git a/src/lib/icons/fiat/kzt.png b/src/lib/icons/fiat/kzt.png new file mode 100644 index 000000000..57962c950 Binary files /dev/null and b/src/lib/icons/fiat/kzt.png differ