Skip to content

Commit

Permalink
chore(trading): move regional to suite-common
Browse files Browse the repository at this point in the history
  • Loading branch information
adderpositive authored and tomasklim committed Jan 24, 2025
1 parent b01275c commit 45c0a0d
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { Locator, Page, expect } from '@playwright/test';

import { TrezorUserEnvLink } from '@trezor/trezor-user-env-link';
import { FiatCurrencyCode } from '@suite-common/suite-config';
import regional from '@trezor/suite/src/constants/wallet/coinmarket/regional';
import { NetworkSymbol } from '@suite-common/wallet-config';
import { regional } from '@suite-common/invity';

import { step } from '../common';
import { invityResponses } from '../../fixtures/invity/index';
Expand Down
5 changes: 2 additions & 3 deletions packages/suite/src/actions/wallet/coinmarketBuyActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ import {
FiatCurrencyCode,
} from 'invity-api';

import { invityAPI } from '@suite-common/invity';
import { invityAPI, regional } from '@suite-common/invity';

import { Account } from 'src/types/wallet';
import { Dispatch } from 'src/types/suite';
import regional from 'src/constants/wallet/coinmarket/regional';
import * as modalActions from 'src/actions/suite/modalActions';
import { verifyAddress as verifyBuyAddress } from 'src/actions/wallet/coinmarket/coinmarketCommonActions';
import { CoinmarketFiatCurrenciesProps } from 'src/types/coinmarket/coinmarket';
Expand Down Expand Up @@ -68,7 +67,7 @@ export const loadBuyInfo = async (): Promise<BuyInfo> => {
if (!buyInfo || !buyInfo.providers) {
return {
buyInfo: {
country: regional.unknownCountry,
country: regional.UNKNOWN_COUNTRY,
providers: [],
defaultAmountsOfFiatCurrencies,
},
Expand Down
8 changes: 4 additions & 4 deletions packages/suite/src/utils/wallet/coinmarket/coinmarketUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import {
sortByCoin,
} from '@suite-common/wallet-utils';
import { BigNumber } from '@trezor/utils';
import { regional } from '@suite-common/invity';

import { Account } from 'src/types/wallet';
import regional from 'src/constants/wallet/coinmarket/regional';
import { ExtendedMessageDescriptor, TrezorDevice } from 'src/types/suite';
import {
CoinmarketAccountOptionsGroupOptionProps,
Expand Down Expand Up @@ -253,13 +253,13 @@ export const coinmarketGetSuccessQuotes = <T extends CoinmarketTradeType>(
quotes: CoinmarketTradeDetailMapProps[T][] | undefined,
) => (quotes ? quotes.filter(quote => quote.error === undefined) : undefined);

export const getDefaultCountry = (country: string = regional.unknownCountry) => {
export const getDefaultCountry = (country: string = regional.UNKNOWN_COUNTRY) => {
const label = regional.countriesMap.get(country);

if (!label)
return {
label: regional.countriesMap.get(regional.unknownCountry)!,
value: regional.unknownCountry,
label: regional.countriesMap.get(regional.UNKNOWN_COUNTRY)!,
value: regional.UNKNOWN_COUNTRY,
};

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { Control, Controller } from 'react-hook-form';

import { Flag, Select, Row } from '@trezor/components';
import { spacings } from '@trezor/theme';
import { regional } from '@suite-common/invity';

import regional from 'src/constants/wallet/coinmarket/regional';
import { CountryOption } from 'src/types/wallet/coinmarketCommonTypes';
import { getCountryLabelParts } from 'src/utils/wallet/coinmarket/coinmarketUtils';
import { useCoinmarketFormContext } from 'src/hooks/wallet/coinmarket/form/useCoinmarketCommonForm';
Expand Down
3 changes: 2 additions & 1 deletion suite-common/invity/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"type-check": "yarn g:tsc --build"
},
"dependencies": {
"@trezor/env-utils": "workspace:*"
"@trezor/env-utils": "workspace:*",
"@trezor/utils": "workspace:*"
},
"devDependencies": {
"@types/invity-api": "^1.1.2"
Expand Down
1 change: 1 addition & 0 deletions suite-common/invity/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './types';
export * from './invityAPI';
export * from './regional';
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { isArrayMember } from '@trezor/utils';

class Regional {
unknownCountry = 'unknown';
readonly UNKNOWN_COUNTRY = 'unknown';

countries: [string, string][] = [
[this.unknownCountry, `🌍 Worldwide`],
[this.UNKNOWN_COUNTRY, `🌍 Worldwide`],
['AD', '🇦🇩 Andorra'],
['AE', '🇦🇪 United Arab Emirates'],
['AF', '🇦🇫 Afghanistan'],
Expand Down Expand Up @@ -311,6 +311,4 @@ class Regional {

type EEACountryCodes = (typeof regional.EEACountryCodes)[number];

const regional = new Regional();

export default regional;
export const regional = new Regional();
3 changes: 2 additions & 1 deletion suite-common/invity/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"extends": "../../tsconfig.base.json",
"compilerOptions": { "outDir": "libDev" },
"references": [
{ "path": "../../packages/env-utils" }
{ "path": "../../packages/env-utils" },
{ "path": "../../packages/utils" }
]
}
1 change: 1 addition & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9587,6 +9587,7 @@ __metadata:
resolution: "@suite-common/invity@workspace:suite-common/invity"
dependencies:
"@trezor/env-utils": "workspace:*"
"@trezor/utils": "workspace:*"
"@types/invity-api": "npm:^1.1.2"
languageName: unknown
linkType: soft
Expand Down

0 comments on commit 45c0a0d

Please sign in to comment.