mirror of
https://github.com/status-im/MyCrypto.git
synced 2025-02-26 01:35:16 +00:00
* create config reducer tests * create generateWallet reducer tests * create wallet reducer tests * create swap reducer tests; use empty string as destination amount when origin amount is an empty string instead of 0 * add additional swap reducer tests * refactor swap; additional tests * create separate dir for swap reducer
37 lines
904 B
JavaScript
37 lines
904 B
JavaScript
import { combineAndUpper } from 'utils/formatters';
|
|
import without from 'lodash/without';
|
|
import { ALL_CRYPTO_KIND_OPTIONS } from '.';
|
|
|
|
export const buildDestinationAmount = (
|
|
originAmount,
|
|
originKind,
|
|
destinationKind,
|
|
bityRates
|
|
) => {
|
|
let pairName = combineAndUpper(originKind, destinationKind);
|
|
let bityRate = bityRates[pairName];
|
|
return originAmount !== null ? originAmount * bityRate : null;
|
|
};
|
|
|
|
export const buildDestinationKind = (
|
|
originKind: string,
|
|
destinationKind: string
|
|
): string => {
|
|
if (originKind === destinationKind) {
|
|
return without(ALL_CRYPTO_KIND_OPTIONS, originKind)[0];
|
|
} else {
|
|
return destinationKind;
|
|
}
|
|
};
|
|
|
|
export const buildOriginKind = (
|
|
originKind: string,
|
|
destinationKind: string
|
|
): string => {
|
|
if (originKind === destinationKind) {
|
|
return without(ALL_CRYPTO_KIND_OPTIONS, destinationKind)[0];
|
|
} else {
|
|
return originKind;
|
|
}
|
|
};
|