diff --git a/common/containers/Tabs/SendTransaction/components/Donate.jsx b/common/containers/Tabs/SendTransaction/components/Donate.jsx
index 281e1879..15e0b77a 100644
--- a/common/containers/Tabs/SendTransaction/components/Donate.jsx
+++ b/common/containers/Tabs/SendTransaction/components/Donate.jsx
@@ -2,37 +2,38 @@
import React from 'react';
import translate from 'translations';
+import { donationAddressMap } from 'config/data';
export default class Donate extends React.Component {
- props: {
- onDonate: (address: string, amount: string, unit: string) => void
- };
- state: {
- clicked: boolean
- } = {
- clicked: false
- };
- render() {
- return (
-
- );
- }
+ props: {
+ onDonate: (address: string, amount: string, unit: string) => void
+ };
+ state: {
+ clicked: boolean
+ } = {
+ clicked: false
+ };
+ render() {
+ return (
+
+ );
+ }
- onClick = () => {
- // FIXME move to config
- this.props.onDonate('0x7cB57B5A97eAbe94205C07890BE4c1aD31E486A8', '1', 'ETH');
+ onClick = () => {
+ // FIXME move to config
+ this.props.onDonate(donationAddressMap.ETH, '1', 'ETH');
- this.setState({ clicked: true });
- };
+ this.setState({ clicked: true });
+ };
}
diff --git a/common/containers/Tabs/SendTransaction/index.jsx b/common/containers/Tabs/SendTransaction/index.jsx
index bc00b7ef..86026039 100644
--- a/common/containers/Tabs/SendTransaction/index.jsx
+++ b/common/containers/Tabs/SendTransaction/index.jsx
@@ -5,266 +5,275 @@ import PropTypes from 'prop-types';
import translate from 'translations';
import { UnlockHeader } from 'components/ui';
import {
- Donate,
- DataField,
- CustomMessage,
- GasField,
- AmountField,
- AddressField
+ Donate,
+ DataField,
+ CustomMessage,
+ GasField,
+ AmountField,
+ AddressField
} from './components';
import pickBy from 'lodash/pickBy';
// import type { Transaction } from './types';
import customMessages from './messages';
+import { donationAddressMap } from 'config/data';
type State = {
- hasQueryString: boolean,
- readOnly: boolean,
- to: string,
- value: string,
- unit: string,
- gasLimit: string,
- data: string,
- gasChanged: boolean
+ hasQueryString: boolean,
+ readOnly: boolean,
+ to: string,
+ value: string,
+ unit: string,
+ gasLimit: string,
+ data: string,
+ gasChanged: boolean
};
function getParam(query: { [string]: string }, key: string) {
- const keys = Object.keys(query);
- const index = keys.findIndex(k => k.toLowerCase() === key.toLowerCase());
- if (index === -1) {
- return null;
- }
+ const keys = Object.keys(query);
+ const index = keys.findIndex(k => k.toLowerCase() === key.toLowerCase());
+ if (index === -1) {
+ return null;
+ }
- return query[keys[index]];
+ return query[keys[index]];
}
// TODO query string
// TODO how to handle DATA?
export class SendTransaction extends React.Component {
- static propTypes = {
- location: PropTypes.object.isRequired
- };
- props: {
- location: {
- query: {
- [string]: string
- }
- }
- };
- state: State = {
- hasQueryString: false,
- readOnly: false,
- // FIXME use correct defaults
- to: '',
- value: '999.11',
- unit: 'ether',
- gasLimit: '21000',
- data: '',
- gasChanged: false
- };
+ static propTypes = {
+ location: PropTypes.object.isRequired
+ };
+ props: {
+ location: {
+ query: {
+ [string]: string
+ }
+ }
+ };
+ state: State = {
+ hasQueryString: false,
+ readOnly: false,
+ // FIXME use correct defaults
+ to: '',
+ value: '999.11',
+ unit: 'ether',
+ gasLimit: '21000',
+ data: '',
+ gasChanged: false
+ };
- componentDidMount() {
- const queryPresets = pickBy(this.parseQuery());
- if (Object.keys(queryPresets).length) {
- this.setState({ ...queryPresets, hasQueryString: true });
- }
-
- this.setState(pickBy(queryPresets));
+ componentDidMount() {
+ const queryPresets = pickBy(this.parseQuery());
+ if (Object.keys(queryPresets).length) {
+ this.setState({ ...queryPresets, hasQueryString: true });
}
- render() {
- const unlocked = true; //wallet != null
- const unitReadable = 'UNITREADABLE';
- const nodeUnit = 'NODEUNIT';
- const hasEnoughBalance = false;
- const { to, value, unit, gasLimit, data, readOnly, hasQueryString } = this.state;
- const customMessage = customMessages.find(m => m.to === to);
+ this.setState(pickBy(queryPresets));
+ }
- // tokens
- // ng-show="token.balance!=0 && token.balance!='loading' || token.type!=='default' || tokenVisibility=='shown'"
+ render() {
+ const unlocked = true; //wallet != null
+ const unitReadable = 'UNITREADABLE';
+ const nodeUnit = 'NODEUNIT';
+ const hasEnoughBalance = false;
+ const {
+ to,
+ value,
+ unit,
+ gasLimit,
+ data,
+ readOnly,
+ hasQueryString
+ } = this.state;
+ const customMessage = customMessages.find(m => m.to === to);
- return (
-
-
-
+ // tokens
+ // ng-show="token.balance!=0 && token.balance!='loading' || token.type!=='default' || tokenVisibility=='shown'"
- {hasQueryString &&
-
-
- {translate('WARN_Send_Link')}
-
-
}
+ return (
+
+
+
-
+ {hasQueryString &&
+
+
+ {translate('WARN_Send_Link')}
+
+
}
- {unlocked &&
-
- {'' /* */}
-
+
-
- {readOnly &&
- !hasEnoughBalance &&
-
-
-
- Warning! You do not have enough funds to
- complete this swap.
-
- {' '}
-
- Please add more funds or access a different wallet.
-
-
}
+ {unlocked &&
+
+ {'' /* */}
+
-
-
- {translate('SEND_trans')}
-
-
-
-
-
- {unit === 'ether' &&
- }
-
+
+ {readOnly &&
+ !hasEnoughBalance &&
+
+
+
+ Warning! You do not have enough funds to
+ complete this swap.
+
+ {' '}
+
+ Please add more funds or access a different wallet.
+
+
}
-
+
+
+ {translate('SEND_trans')}
+
+
+
+
+
+ {unit === 'ether' &&
+ }
+
-
-
-
-
-
-
-
-
-
-
+
-
+
+
+
+
+
+
+
+
+
+
-
- {'' /* */}
- {
- '' /* @@if (site === 'mew' ) { @@include( './sendTx-content.tpl', { "site": "mew" } ) }
+
+
+
+ {'' /* */}
+ {
+ '' /* @@if (site === 'mew' ) { @@include( './sendTx-content.tpl', { "site": "mew" } ) }
@@if (site === 'cx' ) { @@include( './sendTx-content.tpl', { "site": "cx" } ) }
@@if (site === 'mew' ) { @@include( './sendTx-modal.tpl', { "site": "mew" } ) }
@@if (site === 'cx' ) { @@include( './sendTx-modal.tpl', { "site": "cx" } ) } */
- }
- }
-
-
-
- );
+ }
+ }
+
+
+
+ );
+ }
+
+ parseQuery() {
+ const query = this.props.location.query;
+ const to = getParam(query, 'to');
+ const data = getParam(query, 'data');
+ // FIXME validate token against presets
+ const unit = getParam(query, 'tokenSymbol');
+ const value = getParam(query, 'value');
+ let gasLimit = getParam(query, 'gas');
+ if (gasLimit === null) {
+ gasLimit = getParam(query, 'limit');
}
+ const readOnly = getParam(query, 'readOnly') == null ? false : true;
- parseQuery() {
- const query = this.props.location.query;
- const to = getParam(query, 'to');
- const data = getParam(query, 'data');
- // FIXME validate token against presets
- const unit = getParam(query, 'tokenSymbol');
- const value = getParam(query, 'value');
- let gasLimit = getParam(query, 'gas');
- if (gasLimit === null) {
- gasLimit = getParam(query, 'limit');
- }
- const readOnly = getParam(query, 'readOnly') == null ? false : true;
+ return { to, data, value, unit, gasLimit, readOnly };
+ }
- return { to, data, value, unit, gasLimit, readOnly };
+ // FIXME use mkTx instead or something that could take care of default gas/data and whatnot,
+ // FIXME also should it reset gasChanged?
+ onNewTx = (
+ address: string,
+ amount: string,
+ unit: string,
+ data: string = '',
+ gasLimit: string = '21000'
+ ) => {
+ this.setState({
+ to: address,
+ value: amount,
+ unit,
+ data,
+ gasLimit,
+ gasChanged: false
+ });
+ };
+
+ onAddressChange = (value: string) => {
+ this.setState({
+ to: value
+ });
+ };
+
+ onDataChange = (value: string) => {
+ if (this.state.unit !== 'ether') {
+ return;
}
+ this.setState({
+ ...this.state,
+ data: value
+ });
+ };
- // FIXME use mkTx instead or something that could take care of default gas/data and whatnot,
- // FIXME also should it reset gasChanged?
- onNewTx = (
- address: string,
- amount: string,
- unit: string,
- data: string = '',
- gasLimit: string = '21000'
- ) => {
- this.setState({
- to: address,
- value: amount,
- unit,
- data,
- gasLimit,
- gasChanged: false
- });
- };
+ onGasChange = (value: string) => {
+ this.setState({ gasLimit: value, gasChanged: true });
+ };
- onAddressChange = (value: string) => {
- this.setState({
- to: value
- });
- };
-
- onDataChange = (value: string) => {
- if (this.state.unit !== 'ether') {
- return;
- }
- this.setState({
- ...this.state,
- data: value
- });
- };
-
- onGasChange = (value: string) => {
- this.setState({ gasLimit: value, gasChanged: true });
- };
-
- onAmountChange = (value: string, unit: string) => {
- this.setState({
- value,
- unit
- });
- };
+ onAmountChange = (value: string, unit: string) => {
+ this.setState({
+ value,
+ unit
+ });
+ };
}
// export connected version
export default SendTransaction;
diff --git a/common/containers/Tabs/SendTransaction/messages.js b/common/containers/Tabs/SendTransaction/messages.js
index 22808052..927242a6 100644
--- a/common/containers/Tabs/SendTransaction/messages.js
+++ b/common/containers/Tabs/SendTransaction/messages.js
@@ -1,32 +1,33 @@
// @flow
+import { donationAddressMap } from 'config/data';
export default [
- {
- // donation address example
- to: '0x7cB57B5A97eAbe94205C07890BE4c1aD31E486A8',
- gasLimit: 21000,
- data: '',
- msg: 'Thank you for donating to MyEtherWallet. TO THE MOON!'
- },
- {
- // BAT
- to: '0x0D8775F648430679A709E98d2b0Cb6250d2887EF',
- gasLimit: 200000,
- data: '0xb4427263',
- msg: 'BAT. THE SALE IS OVER. STOP CLOGGING THE BLOCKCHAIN PLEASE'
- },
- {
- // BANCOR
- to: '0x00000',
- gasLimit: 200000,
- data: '',
- msg: 'Bancor. Starts June XX, 2017.'
- },
- {
- // Moeda
- to: '0x4870E705a3def9DDa6da7A953D1cd3CCEDD08573',
- gasLimit: 200000,
- data: '',
- msg: 'Moeda. Ends at block 4,111,557.'
- }
+ {
+ // donation address example
+ to: donationAddressMap.ETH,
+ gasLimit: 21000,
+ data: '',
+ msg: 'Thank you for donating to MyEtherWallet. TO THE MOON!'
+ },
+ {
+ // BAT
+ to: '0x0D8775F648430679A709E98d2b0Cb6250d2887EF',
+ gasLimit: 200000,
+ data: '0xb4427263',
+ msg: 'BAT. THE SALE IS OVER. STOP CLOGGING THE BLOCKCHAIN PLEASE'
+ },
+ {
+ // BANCOR
+ to: '0x00000',
+ gasLimit: 200000,
+ data: '',
+ msg: 'Bancor. Starts June XX, 2017.'
+ },
+ {
+ // Moeda
+ to: '0x4870E705a3def9DDa6da7A953D1cd3CCEDD08573',
+ gasLimit: 200000,
+ data: '',
+ msg: 'Moeda. Ends at block 4,111,557.'
+ }
];
diff --git a/common/sagas/ens.js b/common/sagas/ens.js
index 6c9fd571..ee4eefae 100644
--- a/common/sagas/ens.js
+++ b/common/sagas/ens.js
@@ -4,30 +4,31 @@ import { delay } from 'redux-saga';
import { cacheEnsAddress } from 'actions/ens';
import type { ResolveEnsNameAction } from 'actions/ens';
import { getEnsAddress } from 'selectors/ens';
+import { donationAddressMap } from 'config/data';
function* resolveEns(action: ResolveEnsNameAction) {
- const ensName = action.payload;
- // FIXME Add resolve logic
- //// _ens.getAddress(scope.addressDrtv.ensAddressField, function(data) {
- // if (data.error) uiFuncs.notifier.danger(data.msg);
- // else if (data.data == '0x0000000000000000000000000000000000000000' || data.data == '0x') {
- // setValue('0x0000000000000000000000000000000000000000');
- // scope.addressDrtv.derivedAddress = '0x0000000000000000000000000000000000000000';
- // scope.addressDrtv.showDerivedAddress = true;
- // } else {
- // setValue(data.data);
- // scope.addressDrtv.derivedAddress = ethUtil.toChecksumAddress(data.data);
- // scope.addressDrtv.showDerivedAddress = true;
+ const ensName = action.payload;
+ // FIXME Add resolve logic
+ //// _ens.getAddress(scope.addressDrtv.ensAddressField, function(data) {
+ // if (data.error) uiFuncs.notifier.danger(data.msg);
+ // else if (data.data == '0x0000000000000000000000000000000000000000' || data.data == '0x') {
+ // setValue('0x0000000000000000000000000000000000000000');
+ // scope.addressDrtv.derivedAddress = '0x0000000000000000000000000000000000000000';
+ // scope.addressDrtv.showDerivedAddress = true;
+ // } else {
+ // setValue(data.data);
+ // scope.addressDrtv.derivedAddress = ethUtil.toChecksumAddress(data.data);
+ // scope.addressDrtv.showDerivedAddress = true;
- const cachedEnsAddress = yield select(getEnsAddress, ensName);
+ const cachedEnsAddress = yield select(getEnsAddress, ensName);
- if (cachedEnsAddress) {
- return;
- }
- yield call(delay, 1000);
- yield put(cacheEnsAddress(ensName, '0x7cB57B5A97eAbe94205C07890BE4c1aD31E486A8'));
+ if (cachedEnsAddress) {
+ return;
+ }
+ yield call(delay, 1000);
+ yield put(cacheEnsAddress(ensName, donationAddressMap.ETH));
}
export default function* notificationsSaga() {
- yield takeEvery('ENS_RESOLVE', resolveEns);
+ yield takeEvery('ENS_RESOLVE', resolveEns);
}