From dc6d915ecfebf95176cc8b24ed4dbcd73fbcd5aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren?= Date: Fri, 26 Jan 2024 09:27:37 +0100 Subject: [PATCH] Update @nimiq/utils to support CRC as reference fiat currency --- package.json | 2 +- src/lib/Constants.ts | 13 +++++++++---- src/lib/swap/utils/CommonUtils.ts | 4 ++-- yarn.lock | 5 ++--- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 2de471354..7b634b154 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "@nimiq/rpc": "^0.4.1", "@nimiq/style": "^0.8.2", "@nimiq/ten31-pass-api": "^1.1.0", - "@nimiq/utils": "^0.9.3", + "@nimiq/utils": "https://github.com/nimiq/nimiq-utils#soeren/dist/crc", "@nimiq/vue-components": "https://github.com/nimiq/vue-components#build/wallet", "@opengsn/common": "^2.2.5", "@sentry/vue": "^6.0.0", diff --git a/src/lib/Constants.ts b/src/lib/Constants.ts index ec8625de2..84b687f8a 100644 --- a/src/lib/Constants.ts +++ b/src/lib/Constants.ts @@ -1,7 +1,12 @@ -export { - FiatApiSupportedFiatCurrency as FiatCurrency, - FiatApiSupportedCryptoCurrency as CryptoCurrency, -} from '@nimiq/utils'; +import { FiatApiSupportedFiatCurrency, FiatApiBridgedFiatCurrency } from '@nimiq/utils'; + +export { FiatApiSupportedCryptoCurrency as CryptoCurrency } from '@nimiq/utils'; + +export const FiatCurrency = { + ...FiatApiSupportedFiatCurrency, + ...FiatApiBridgedFiatCurrency, +}; +export type FiatCurrency = FiatApiSupportedFiatCurrency | FiatApiBridgedFiatCurrency; export const FIAT_PRICE_UNAVAILABLE = null; export const CASHLINK_ADDRESS = 'cashlink'; diff --git a/src/lib/swap/utils/CommonUtils.ts b/src/lib/swap/utils/CommonUtils.ts index fce7e2132..e0eb00ccb 100644 --- a/src/lib/swap/utils/CommonUtils.ts +++ b/src/lib/swap/utils/CommonUtils.ts @@ -136,8 +136,8 @@ export function capDecimals(amount: number, asset: SwapAsset) { } export function calculateFees( - { to, from }: { to: FiatCurrency.EUR, from?: CryptoCurrency } - | { to?: CryptoCurrency, from: FiatCurrency.EUR }, + { to, from }: { to: 'eur', from?: CryptoCurrency } + | { to?: CryptoCurrency, from: 'eur' }, amount?: number, feesPerUnit = { eur: 0, nim: 0, btc: 0 }, ) { diff --git a/yarn.lock b/yarn.lock index 191ab7423..4dec677f2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1673,10 +1673,9 @@ dependencies: big-integer "^1.6.44" -"@nimiq/utils@^0.9.3": +"@nimiq/utils@https://github.com/nimiq/nimiq-utils#soeren/dist/crc": version "0.9.3" - resolved "https://registry.yarnpkg.com/@nimiq/utils/-/utils-0.9.3.tgz#db402c8f42bb16dee8e5500c617cff18e1497960" - integrity sha512-g/9FpoNcJmU737TRQsNdU5/OGoXnc1UwunJBF/TGw4bx4cQ/pbYO7k0nsZ4RGUFn0jiy9xlxYH+yH1mvSY7+nQ== + resolved "https://github.com/nimiq/nimiq-utils#b97dedd796fd232852dffd1845c6eb3f00d88681" dependencies: big-integer "^1.6.44"