Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
changeCurrentlySelectedDevice: deviceId =>
dispatch(change("registrationsTabListing", "selectedDevice", deviceId))
});
const setWrapMax = () => (dispatch, getState) => {
const activeUnwrappedToken = wrapUnwrap.activeUnwrappedToken(getState());
const maxWrapValueInEther =
activeUnwrappedToken === TOKEN_ETHER
? web3.fromWei(balances.ethBalance(getState()))
: balances.tokenBalance(getState(), { tokenName: activeUnwrappedToken });
if (maxWrapValueInEther) {
dispatch(
change(
activeUnwrappedToken === TOKEN_ETHER ? "wrapEther" : "wrapTokenWrapper",
"amount",
maxWrapValueInEther.toString()
)
);
}
};
) => (dispatch, getState) => {
const { price } = formValueSelector("takeOffer")(
getState(),
"volume",
"total",
"price"
);
if (isNaN(value)) {
dispatch(form.change("takeOffer", "total", "0"));
} else {
dispatch(
form.change(
"takeOffer",
"total",
web3
.toBigNumber(value)
.mul(price)
.toFixed()
.toString()
)
);
}
dispatch(defer(getTransactionGasCostEstimateEpic));
};
const setUnwrapMax = () => (dispatch, getState) => {
const activeWrappedToken = wrapUnwrap.activeWrappedToken(getState());
const maxUnwrapValueInEther = balances.tokenBalance(getState(), {
tokenName: activeWrappedToken
});
if (maxUnwrapValueInEther) {
dispatch(
change(
activeWrappedToken === TOKEN_WRAPPED_ETH
? "unwrapEther"
: "unwrapTokenWrapper",
"amount",
maxUnwrapValueInEther.toString()
)
);
}
};
) => (dispatch, getState) => {
const { price } = formValueSelector("takeOffer")(
getState(),
"volume",
"total",
"price"
);
if (isNaN(value)) {
dispatch(form.change("takeOffer", "total", "0"));
} else {
dispatch(
form.change(
"takeOffer",
"total",
web3
.toBigNumber(value)
.mul(price)
.toFixed()
.toString()
)
);
}
dispatch(defer(getTransactionGasCostEstimateEpic));
};
changeSaltVal: val => dispatch(change("newSecret", "salt", val))
})
) => (dispatch, getState) => {
const usersQuoteTokenBalanceBN = web3.toBigNumber(
quoteTokenBalance(getState())
);
const activeOfferTakeData = offerTakeOfferData(getState());
const volume = activeOfferTakeData.get("buyHowMuch");
const priceBN = web3.toBigNumber(activeOfferTakeData.get("ask_price"));
const total = usersQuoteTokenBalanceBN.gte(priceBN.mul(volume))
? web3.fromWei(priceBN.mul(volume), ETH_UNIT_ETHER)
: web3.fromWei(usersQuoteTokenBalanceBN, ETH_UNIT_ETHER);
const totalSerialized = total.toString();
dispatch(form.change("takeOffer", "total", totalSerialized));
dispatch(defer(totalFieldValueChangedEpic, totalSerialized));
};
);
dispatch(
form.change(
"takeOffer",
"volume",
web3
.toBigNumber(value)
.div(price)
.toFixed()
.toString()
)
);
if (isNaN(value)) {
dispatch(form.change("takeOffer", "volume", "0"));
} else {
dispatch(
form.change(
"takeOffer",
"volume",
web3
.toBigNumber(value)
.div(price)
.toFixed()
.toString()
)
);
}
dispatch(defer(getTransactionGasCostEstimateEpic));
};
const setTransferMax = () => (dispatch, getState) => {
const maxTransferValueInEther = balances.tokenBalance(getState(), {
tokenName: transfers.selectedToken(getState())
});
if (maxTransferValueInEther) {
dispatch(
change("tokenTransfer", "tokenAmount", maxTransferValueInEther.toString())
);
}
};
) => (dispatch, getState) => {
const balance = activeBaseTokenBalance(getState());
const formName = offerMakeToFormName(offerMakeType);
const { price } = currentFormValues(getState())(formName);
const usersBaseTokenBalanceBN = web3.toBigNumber(web3.fromWei(balance));
const priceBN = web3.toBigNumber(price.toString());
const totalSerialized = usersBaseTokenBalanceBN
.mul(priceBN)
.toFixed()
.toString();
dispatch(change(formName, "total", totalSerialized));
dispatch(defer(totalFieldValueChangedEpic, offerMakeType, totalSerialized));
};