aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/redux/reducer.ts
diff options
context:
space:
mode:
authorBrandon Millman <brandon@0xproject.com>2018-11-14 06:35:09 +0800
committerGitHub <noreply@github.com>2018-11-14 06:35:09 +0800
commite02dc13805349a770506350c69e9061f596b48b2 (patch)
tree7e0b7165ba370af5088a51183d39a7fba9c535a0 /packages/instant/src/redux/reducer.ts
parent7b4f63a39ca4b4e05123d2b6871c6e01f8a132a2 (diff)
parent820ab062a6b24f246770f3700ecd6fbb5e3dcfa4 (diff)
downloaddexon-sol-tools-e02dc13805349a770506350c69e9061f596b48b2.tar
dexon-sol-tools-e02dc13805349a770506350c69e9061f596b48b2.tar.gz
dexon-sol-tools-e02dc13805349a770506350c69e9061f596b48b2.tar.bz2
dexon-sol-tools-e02dc13805349a770506350c69e9061f596b48b2.tar.lz
dexon-sol-tools-e02dc13805349a770506350c69e9061f596b48b2.tar.xz
dexon-sol-tools-e02dc13805349a770506350c69e9061f596b48b2.tar.zst
dexon-sol-tools-e02dc13805349a770506350c69e9061f596b48b2.zip
Merge pull request #1252 from 0xProject/fix/asset-buyer/price-per-token
[asset-buyer][instant] Fix incorrect token prices for non 18-decimal tokens
Diffstat (limited to 'packages/instant/src/redux/reducer.ts')
-rw-r--r--packages/instant/src/redux/reducer.ts14
1 files changed, 7 insertions, 7 deletions
diff --git a/packages/instant/src/redux/reducer.ts b/packages/instant/src/redux/reducer.ts
index ef46fdd9d..77c99627a 100644
--- a/packages/instant/src/redux/reducer.ts
+++ b/packages/instant/src/redux/reducer.ts
@@ -41,7 +41,7 @@ interface PropsDerivedState {
interface OptionalState {
selectedAsset: Asset;
availableAssets: Asset[];
- selectedAssetAmount: BigNumber;
+ selectedAssetUnitAmount: BigNumber;
ethUsdPrice: BigNumber;
latestBuyQuote: BuyQuote;
latestErrorMessage: string;
@@ -90,10 +90,10 @@ export const createReducer = (initialState: State) => {
...state,
ethUsdPrice: action.data,
};
- case ActionTypes.UPDATE_SELECTED_ASSET_AMOUNT:
+ case ActionTypes.UPDATE_SELECTED_ASSET_UNIT_AMOUNT:
return {
...state,
- selectedAssetAmount: action.data,
+ selectedAssetUnitAmount: action.data,
};
case ActionTypes.UPDATE_LATEST_BUY_QUOTE:
const newBuyQuoteIfExists = action.data;
@@ -204,7 +204,7 @@ export const createReducer = (initialState: State) => {
latestBuyQuote: undefined,
quoteRequestState: AsyncProcessState.None,
buyOrderState: { processState: OrderProcessState.None },
- selectedAssetAmount: undefined,
+ selectedAssetUnitAmount: undefined,
};
case ActionTypes.SET_AVAILABLE_ASSETS:
return {
@@ -232,9 +232,9 @@ const reduceStateWithAccount = (state: State, account: Account) => {
const doesBuyQuoteMatchState = (buyQuote: BuyQuote, state: State): boolean => {
const selectedAssetIfExists = state.selectedAsset;
- const selectedAssetAmountIfExists = state.selectedAssetAmount;
+ const selectedAssetUnitAmountIfExists = state.selectedAssetUnitAmount;
// if no selectedAsset or selectedAssetAmount exists on the current state, return false
- if (_.isUndefined(selectedAssetIfExists) || _.isUndefined(selectedAssetAmountIfExists)) {
+ if (_.isUndefined(selectedAssetIfExists) || _.isUndefined(selectedAssetUnitAmountIfExists)) {
return false;
}
// if buyQuote's assetData does not match that of the current selected asset, return false
@@ -246,7 +246,7 @@ const doesBuyQuoteMatchState = (buyQuote: BuyQuote, state: State): boolean => {
const selectedAssetMetaData = selectedAssetIfExists.metaData;
if (selectedAssetMetaData.assetProxyId === AssetProxyId.ERC20) {
const selectedAssetAmountBaseUnits = Web3Wrapper.toBaseUnitAmount(
- selectedAssetAmountIfExists,
+ selectedAssetUnitAmountIfExists,
selectedAssetMetaData.decimals,
);
const doesAssetAmountMatch = selectedAssetAmountBaseUnits.eq(buyQuote.assetBuyAmount);