Skip to content

Commit

Permalink
refactor(suite): renamed currency to cryptoId
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasBoda committed Dec 19, 2024
1 parent 3dbdc10 commit d49bf6d
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ const getTranslationIds = (
};

const getSuiteReceiveAccounts = ({
currency,
cryptoId,
device,
symbol,
isDebug,
accounts,
}: CoinmarketGetSuiteReceiveAccountsProps): Account[] | undefined => {
if (currency) {
if (cryptoId) {
const unavailableCapabilities = device?.unavailableCapabilities ?? {};

// Is the symbol supported by the suite and the device natively?
Expand All @@ -98,7 +98,7 @@ const getSuiteReceiveAccounts = ({
};

const useCoinmarketVerifyAccount = ({
currency,
cryptoId,
}: CoinmarketVerifyAccountProps): CoinmarketVerifyAccountReturnProps => {
const selectedAccount = useSelector(state => state.wallet.selectedAccount);
const accounts = useSelector(state => state.wallet.accounts);
Expand All @@ -115,22 +115,22 @@ const useCoinmarketVerifyAccount = ({
CoinmarketVerifyFormAccountOptionProps | undefined
>();

const networkId = currency && parseCryptoId(currency).networkId;
const symbol = currency && cryptoIdToSymbol(currency);
const networkId = cryptoId && parseCryptoId(cryptoId).networkId;
const symbol = cryptoId && cryptoIdToSymbol(cryptoId);
const suiteReceiveAccounts = useMemo(
() =>
getSuiteReceiveAccounts({
currency,
cryptoId,
device,
symbol,
isDebug,
accounts,
}),
[accounts, currency, device, isDebug, symbol],
[accounts, cryptoId, device, isDebug, symbol],
);

const { supportedMainnets, supportedTestnets } = useNetworkSupport();
const currencyNetwork = currency === undefined ? undefined : cryptoIdToNetwork(currency);
const currencyNetwork = cryptoId && cryptoIdToNetwork(cryptoId);
const findNetworkByType = (network: Network) =>
network.networkType === currencyNetwork?.networkType;
const isNetworkSupported =
Expand Down
4 changes: 2 additions & 2 deletions packages/suite/src/types/coinmarket/coinmarketVerify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export interface CoinmarketVerifyFormAccountOptionProps {
}

export interface CoinmarketVerifyAccountProps {
currency: CryptoId | undefined;
cryptoId: CryptoId | undefined;
}

export interface CoinmarketGetTranslationIdsProps {
Expand Down Expand Up @@ -53,7 +53,7 @@ export interface CoinmarketVerifyOptionsItemProps {
}

export interface CoinmarketGetSuiteReceiveAccountsProps {
currency: CryptoId | undefined;
cryptoId: CryptoId | undefined;
device: TrezorDevice | undefined;
symbol: NetworkSymbol | undefined;
isDebug: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ export const CoinmarketOfferBuy = ({
paymentMethod,
paymentMethodName,
}: CoinmarketOfferBuyProps) => {
const currency = selectedQuote?.receiveCurrency;
const coinmarketVerifyAccount = useCoinmarketVerifyAccount({ currency });
const cryptoId = selectedQuote?.receiveCurrency;
const coinmarketVerifyAccount = useCoinmarketVerifyAccount({ cryptoId });

return (
<>
<Card>
{currency && (
{cryptoId && (
<CoinmarketVerify
coinmarketVerifyAccount={coinmarketVerifyAccount}
currency={currency}
cryptoId={cryptoId}
/>
)}
</Card>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ export const CoinmarketOfferExchange = ({
quoteAmounts,
}: CoinmarketOfferExchangeProps) => {
const { exchangeStep } = useCoinmarketFormContext<CoinmarketTradeExchangeType>();
const currency = selectedQuote?.receive;
const coinmarketVerifyAccount = useCoinmarketVerifyAccount({ currency });
const cryptoId = selectedQuote?.receive;
const coinmarketVerifyAccount = useCoinmarketVerifyAccount({ cryptoId });

const steps: CoinmarketSelectedOfferStepperItemProps[] = [
{
step: 'RECEIVING_ADDRESS',
translationId: 'TR_EXCHANGE_VERIFY_ADDRESS_STEP',
isActive: exchangeStep === 'RECEIVING_ADDRESS',
component: currency ? (
component: cryptoId ? (
<CoinmarketVerify
coinmarketVerifyAccount={coinmarketVerifyAccount}
currency={currency}
cryptoId={cryptoId}
/>
) : null,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ import {

interface CoinmarketVerifyProps {
coinmarketVerifyAccount: CoinmarketVerifyAccountReturnProps;
currency: CryptoId;
cryptoId: CryptoId;
}

export const CoinmarketVerify = ({ coinmarketVerifyAccount, currency }: CoinmarketVerifyProps) => {
export const CoinmarketVerify = ({ coinmarketVerifyAccount, cryptoId }: CoinmarketVerifyProps) => {
const dispatch = useDispatch();
const { translationString } = useTranslation();
const { cryptoIdToCoinSymbol, cryptoIdToNativeCoinSymbol } = useCoinmarketInfo();
Expand Down Expand Up @@ -63,8 +63,8 @@ export const CoinmarketVerify = ({ coinmarketVerifyAccount, currency }: Coinmark
const { ref: networkRef, ...networkField } = form.register('address', {
required: translationString('TR_EXCHANGE_RECEIVING_ADDRESS_REQUIRED'),
validate: value => {
if (selectedAccountOption?.type === 'NON_SUITE' && currency) {
const symbol = cryptoIdToNativeCoinSymbol(currency);
if (selectedAccountOption?.type === 'NON_SUITE' && cryptoId) {
const symbol = cryptoIdToNativeCoinSymbol(cryptoId);
if (value && !addressValidator.validate(value, symbol)) {
return translationString('TR_EXCHANGE_RECEIVING_ADDRESS_INVALID');
}
Expand Down Expand Up @@ -105,11 +105,11 @@ export const CoinmarketVerify = ({ coinmarketVerifyAccount, currency }: Coinmark
<Paragraph typographyStyle="hint" variant="tertiary">
<Translation
id="TR_EXCHANGE_RECEIVING_ADDRESS_INFO"
values={{ symbol: cryptoIdToCoinSymbol(currency) }}
values={{ symbol: cryptoIdToCoinSymbol(cryptoId) }}
/>
</Paragraph>
<CoinmarketVerifyOptions
receiveNetwork={currency}
receiveNetwork={cryptoId}
selectedAccountOption={selectedAccountOption}
selectAccountOptions={selectAccountOptions}
isMenuOpen={isMenuOpen}
Expand All @@ -127,7 +127,7 @@ export const CoinmarketVerify = ({ coinmarketVerifyAccount, currency }: Coinmark
account={selectedAccountOption?.account}
address={address}
control={form.control}
receiveSymbol={currency}
receiveSymbol={cryptoId}
setValue={form.setValue}
label={
<Tooltip
Expand Down

1 comment on commit d49bf6d

@adderpositive
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙏 thank you so much

Please sign in to comment.