1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-24 11:01:41 +01:00
metamask-extension/ui/app/components/send/send-v2-container.js
Dan J Miller 803eaaf968 [NewUI] SendV2-#8: Send container handles tokens; gas info dynamic from state (#2364)
* Adds memo field to send-v2.

* Vertical align transaction with flexbox.

* Customize Gas UI

* Remove internal state from InputNumber and fix use in gastooltip.

* Move customize-gas-modal to its own folder and minor cleanup

* Create send container, get account info from state, and make currency display more reusable

* Adjusts send-v2 and container for send-token. Dynamically getting suggested gas prices.
2017-10-13 13:19:22 -07:00

63 lines
1.8 KiB
JavaScript

const connect = require('react-redux').connect
const actions = require('../../actions')
const abi = require('ethereumjs-abi')
const SendEther = require('../../send-v2')
const { multiplyCurrencies } = require('../../conversion-util')
const {
accountsWithSendEtherInfoSelector,
getCurrentAccountWithSendEtherInfo,
conversionRateSelector,
getSelectedToken,
getSelectedTokenExchangeRate,
getSelectedAddress,
} = require('../../selectors')
module.exports = connect(mapStateToProps, mapDispatchToProps)(SendEther)
function mapStateToProps (state) {
const selectedAddress = getSelectedAddress(state);
const selectedToken = getSelectedToken(state);
const tokenExchangeRates = state.metamask.tokenExchangeRates
const selectedTokenExchangeRate = getSelectedTokenExchangeRate(state)
const conversionRate = conversionRateSelector(state)
let data;
let primaryCurrency;
let tokenToUSDRate;
if (selectedToken) {
data = Array.prototype.map.call(
abi.rawEncode(['address', 'uint256'], [selectedAddress, '0x0']),
x => ('00' + x.toString(16)).slice(-2)
).join('')
primaryCurrency = selectedToken.symbol
tokenToUSDRate = multiplyCurrencies(
conversionRate,
selectedTokenExchangeRate,
{ toNumericBase: 'dec' }
)
}
return {
selectedAccount: getCurrentAccountWithSendEtherInfo(state),
accounts: accountsWithSendEtherInfoSelector(state),
conversionRate,
selectedToken,
primaryCurrency,
data,
tokenToUSDRate,
}
}
function mapDispatchToProps (dispatch) {
return {
showCustomizeGasModal: () => dispatch(actions.showModal({ name: 'CUSTOMIZE_GAS' })),
estimateGas: params => dispatch(actions.estimateGas(params)),
getGasPrice: () => dispatch(actions.getGasPrice()),
updateTokenExchangeRate: token => dispatch(actions.updateTokenExchangeRate(token)),
}
}