-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Transaction stores: remove code duplication for detecting fiat swaps
- Loading branch information
Showing
5 changed files
with
69 additions
and
202 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,15 @@ | ||
import { SwapAsset } from '@nimiq/fastspot-api'; | ||
import { CryptoCurrency, FiatCurrency } from '../../Constants'; | ||
|
||
export function assetToCurrency(asset: SwapAsset): string { // eslint-disable-line consistent-return | ||
switch (asset) { // eslint-disable-line default-case | ||
case SwapAsset.NIM: | ||
return CryptoCurrency.NIM; | ||
case SwapAsset.BTC: | ||
return CryptoCurrency.BTC; | ||
case SwapAsset.USDC: | ||
case SwapAsset.USDC_MATIC: | ||
return CryptoCurrency.USDC; | ||
case SwapAsset.EUR: | ||
return FiatCurrency.EUR; | ||
// The default case is unnecessary as TypeScript throws a compiler error if a case is missing | ||
} | ||
export function assetToCurrency(asset: Exclude<SwapAsset, SwapAsset.EUR>): CryptoCurrency; | ||
export function assetToCurrency(asset: SwapAsset.EUR): FiatCurrency; | ||
export function assetToCurrency(asset: SwapAsset): CryptoCurrency | FiatCurrency; | ||
export function assetToCurrency(asset: SwapAsset): CryptoCurrency | FiatCurrency { | ||
return { | ||
[SwapAsset.NIM]: CryptoCurrency.NIM, | ||
[SwapAsset.BTC]: CryptoCurrency.BTC, | ||
[SwapAsset.USDC]: CryptoCurrency.USDC, | ||
[SwapAsset.USDC_MATIC]: CryptoCurrency.USDC, | ||
[SwapAsset.EUR]: FiatCurrency.EUR, | ||
}[asset]; | ||
} |
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