-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: MarketCurrency to FiatCurrency & CryptoCurrency (#2702)
* refactor: MarketCurrency to FiatCurrency & CryptoCurrency * chore: adds profile migration * fix: mark suggestions
- Loading branch information
1 parent
76017cd
commit ca31adb
Showing
23 changed files
with
126 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
packages/desktop/views/settings/views/profile/Currency.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/shared/src/lib/core/app/interfaces/transak-window-data.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
packages/shared/src/lib/core/market/constants/default-market-currency.constant.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import { MarketCurrency } from '../enums' | ||
import { FiatCurrency } from '../enums' | ||
|
||
export const DEFAULT_MARKET_CURRENCY = MarketCurrency.Usd | ||
export const DEFAULT_MARKET_CURRENCY = FiatCurrency.USD |
16 changes: 16 additions & 0 deletions
16
packages/shared/src/lib/core/market/enums/crypto-currency.enum.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Coingecko supported crypto currencies prices | ||
export enum CryptoCurrency { | ||
BTC = 'btc', | ||
ETH = 'eth', | ||
LTC = 'ltc', | ||
BCH = 'bch', | ||
BNB = 'bnb', | ||
EOS = 'eos', | ||
XRP = 'xrp', | ||
XLM = 'xlm', | ||
LINK = 'link', | ||
DOT = 'dot', | ||
YFI = 'yfi', | ||
BITS = 'bits', | ||
SATS = 'sats', | ||
} |
35 changes: 35 additions & 0 deletions
35
packages/shared/src/lib/core/market/enums/fiat-currency.enum.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Transak and Coingecko supported fiat currencies intersection | ||
export enum FiatCurrency { | ||
USD = 'usd', | ||
EUR = 'eur', | ||
GBP = 'gbp', | ||
AED = 'aed', | ||
ARS = 'ars', | ||
AUD = 'aud', | ||
BHD = 'bhd', | ||
BMD = 'bmd', | ||
BRL = 'brl', | ||
CAD = 'cad', | ||
CHF = 'chf', | ||
CLP = 'clp', | ||
CZK = 'czk', | ||
DKK = 'dkk', | ||
GEL = 'gel', | ||
HKD = 'hkd', | ||
HUF = 'huf', | ||
IDR = 'idr', | ||
ILS = 'ils', | ||
INR = 'inr', | ||
JPY = 'jpy', | ||
KRW = 'krw', | ||
KWD = 'kwd', | ||
MXN = 'mxn', | ||
MYR = 'myr', | ||
NOK = 'nok', | ||
NZD = 'nzd', | ||
PHP = 'php', | ||
PLN = 'pln', | ||
SEK = 'sek', | ||
SGD = 'sgd', | ||
TWD = 'twd', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export * from './coingecko-api-endpoint.enum' | ||
export * from './coingecko-network-id.enum' | ||
export * from './crypto-currency.enum' | ||
export * from './fiat-currency.enum' | ||
export * from './market-coin-id.enum' | ||
export * from './market-currency.enum' |
60 changes: 0 additions & 60 deletions
60
packages/shared/src/lib/core/market/enums/market-currency.enum.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './market-currency.type' | ||
export * from './market-prices.type' | ||
export * from './market-coin-prices.type' |
3 changes: 3 additions & 0 deletions
3
packages/shared/src/lib/core/market/types/market-currency.type.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { CryptoCurrency, FiatCurrency } from '../enums' | ||
|
||
export type MarketCurrency = CryptoCurrency | FiatCurrency |
2 changes: 1 addition & 1 deletion
2
packages/shared/src/lib/core/market/types/market-prices.type.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import { MarketCurrency } from '../enums' | ||
import { MarketCurrency } from './market-currency.type' | ||
|
||
export type MarketPrices = { [key in MarketCurrency]?: number } |
4 changes: 2 additions & 2 deletions
4
packages/shared/src/lib/core/profile/constants/profile-version.constant.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import { AppStage } from '@core/app/enums' | ||
|
||
export const PROFILE_VERSION: Record<AppStage, number> = { | ||
[AppStage.ALPHA]: 22, | ||
[AppStage.ALPHA]: 23, | ||
[AppStage.BETA]: 1, | ||
[AppStage.PROD]: 12, | ||
[AppStage.PROD]: 13, | ||
} |
13 changes: 13 additions & 0 deletions
13
packages/shared/src/lib/core/profile/migrations/alpha/alpha-profile-migration-22-to-23.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { CryptoCurrency, FiatCurrency } from '@core/market' | ||
import { IPersistedProfile } from '@core/profile/interfaces' | ||
|
||
export function alphaProfileMigration22To23(existingProfile: unknown): Promise<void> { | ||
const profile = existingProfile as IPersistedProfile | ||
const marketCurrencies = [...Object.values(FiatCurrency), ...Object.values(CryptoCurrency)] | ||
|
||
if (!marketCurrencies.includes(profile?.settings?.marketCurrency)) { | ||
profile.settings.marketCurrency = FiatCurrency.USD | ||
} | ||
|
||
return Promise.resolve() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
packages/shared/src/lib/core/profile/migrations/prod/prod-profile-migration-12-to-13.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { CryptoCurrency, FiatCurrency } from '@core/market' | ||
import { IPersistedProfile } from '@core/profile/interfaces' | ||
|
||
export function prodProfileMigration12To13(existingProfile: unknown): Promise<void> { | ||
const profile = existingProfile as IPersistedProfile | ||
const marketCurrencies = [...Object.values(FiatCurrency), ...Object.values(CryptoCurrency)] | ||
|
||
if (!marketCurrencies.includes(profile?.settings?.marketCurrency)) { | ||
profile.settings.marketCurrency = FiatCurrency.USD | ||
} | ||
|
||
return Promise.resolve() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters