diff --git a/common/actions/swap.js b/common/actions/swap.js index 15f2a4d0..79c37555 100644 --- a/common/actions/swap.js +++ b/common/actions/swap.js @@ -3,7 +3,9 @@ import { SWAP_DESTINATION_KIND, SWAP_ORIGIN_AMOUNT, SWAP_ORIGIN_KIND, - SWAP_UPDATE_BITY_RATES + SWAP_UPDATE_BITY_RATES, + SWAP_PART_ONE_COMPLETE, + SWAP_RECEIVING_ADDRESS } from './swapConstants'; export const originKindSwap = value => { @@ -40,3 +42,17 @@ export const updateBityRatesSwap = value => { value }; }; + +export const partOneCompleteSwap = (value: boolean) => { + return { + type: SWAP_PART_ONE_COMPLETE, + value + }; +}; + +export const receivingAddressSwap = value => { + return { + type: SWAP_RECEIVING_ADDRESS, + value + }; +}; diff --git a/common/actions/swapConstants.js b/common/actions/swapConstants.js index ca72fc2c..ecf0fb4a 100644 --- a/common/actions/swapConstants.js +++ b/common/actions/swapConstants.js @@ -3,3 +3,5 @@ export const SWAP_DESTINATION_KIND = 'SWAP_DESTINATION_KIND'; export const SWAP_ORIGIN_AMOUNT = 'SWAP_ORIGIN_AMOUNT'; export const SWAP_DESTINATION_AMOUNT = 'SWAP_DESTINATION_AMOUNT'; export const SWAP_UPDATE_BITY_RATES = 'SWAP_UPDATE_BITY_RATES'; +export const SWAP_PART_ONE_COMPLETE = 'SWAP_PART_ONE_COMPLETE'; +export const SWAP_RECEIVING_ADDRESS = 'SWAP_RECEIVING_ADDRESS'; diff --git a/common/components/Footer/index.jsx b/common/components/Footer/index.jsx index 1c7bdd82..39da157a 100644 --- a/common/components/Footer/index.jsx +++ b/common/components/Footer/index.jsx @@ -1,100 +1,202 @@ -import React, {Component} from 'react'; -import translate, {getTranslators} from 'translations'; - +import React, { Component } from 'react'; +import translate, { getTranslators } from 'translations'; +import { DONATION_ADDRESSES_MAP } from 'config/data'; export default class Footer extends Component { - render() { - const translators = getTranslators() - return ( - + ); + } } diff --git a/common/config/data.js b/common/config/data.js index 0094ba20..dac459b5 100644 --- a/common/config/data.js +++ b/common/config/data.js @@ -1,162 +1,168 @@ +export const DONATION_ADDRESSES_MAP = { + BTC: '1MEWT2SGbqtz6mPCgFcnea8XmWV5Z4Wc6', + ETH: '0x7cB57B5A97eAbe94205C07890BE4c1aD31E486A8', + REP: '0x7cB57B5A97eAbe94205C07890BE4c1aD31E486A8' +}; + export const languages = [ - { - sign: 'en', - name: 'English' - }, - { - sign: 'de', - name: 'Deutsch' - }, - { - sign: 'el', - name: 'Ελληνικά' - }, - { - sign: 'es', - name: 'Español' - }, - { - sign: 'fi', - name: 'Suomi' - }, - { - sign: 'fr', - name: 'Français' - }, - { - sign: 'hu', - name: 'Magyar' - }, - { - sign: 'id', - name: 'Indonesian' - }, - { - sign: 'it', - name: 'Italiano' - }, - { - sign: 'ja', - name: '日本語' - }, - { - sign: 'nl', - name: 'Nederlands' - }, - { - sign: 'no', - name: 'Norsk Bokmål' - }, - { - sign: 'pl', - name: 'Polski' - }, - { - sign: 'pt', - name: 'Português' - }, - { - sign: 'ru', - name: 'Русский' - }, - { - sign: 'ko', - name: 'Korean' - }, - // { - // 'sign': 'sk', - // 'name': 'Slovenčina' - // }, - // { - // 'sign': 'sl', - // 'name': 'Slovenščina' - // }, - // { - // 'sign': 'sv', - // 'name': 'Svenska' - // }, - { - sign: 'tr', - name: 'Türkçe' - }, - { - sign: 'vi', - name: 'Tiếng Việt' - }, - { - sign: 'zhcn', - name: '简体中文' - }, - { - sign: 'zhtw', - name: '繁體中文' - } + { + sign: 'en', + name: 'English' + }, + { + sign: 'de', + name: 'Deutsch' + }, + { + sign: 'el', + name: 'Ελληνικά' + }, + { + sign: 'es', + name: 'Español' + }, + { + sign: 'fi', + name: 'Suomi' + }, + { + sign: 'fr', + name: 'Français' + }, + { + sign: 'hu', + name: 'Magyar' + }, + { + sign: 'id', + name: 'Indonesian' + }, + { + sign: 'it', + name: 'Italiano' + }, + { + sign: 'ja', + name: '日本語' + }, + { + sign: 'nl', + name: 'Nederlands' + }, + { + sign: 'no', + name: 'Norsk Bokmål' + }, + { + sign: 'pl', + name: 'Polski' + }, + { + sign: 'pt', + name: 'Português' + }, + { + sign: 'ru', + name: 'Русский' + }, + { + sign: 'ko', + name: 'Korean' + }, + // { + // 'sign': 'sk', + // 'name': 'Slovenčina' + // }, + // { + // 'sign': 'sl', + // 'name': 'Slovenščina' + // }, + // { + // 'sign': 'sv', + // 'name': 'Svenska' + // }, + { + sign: 'tr', + name: 'Türkçe' + }, + { + sign: 'vi', + name: 'Tiếng Việt' + }, + { + sign: 'zhcn', + name: '简体中文' + }, + { + sign: 'zhtw', + name: '繁體中文' + } ]; export const nodeList = [ - { - name: 'ETH', - blockExplorerTX: 'https://etherscan.io/tx/[[txHash]]', - blockExplorerAddr: 'https://etherscan.io/address/[[address]]', - // 'type': nodes.nodeTypes.ETH, - eip155: true, - chainId: 1, - // 'tokenList': require('./tokens/ethTokens.json'), - // 'abiList': require('./abiDefinitions/ethAbi.json'), - estimateGas: true, - service: 'MyEtherWallet' - // 'lib': new nodes.customNode('https://api.myetherapi.com/eth', '') - }, - { - name: 'ETH', - blockExplorerTX: 'https://etherscan.io/tx/[[txHash]]', - blockExplorerAddr: 'https://etherscan.io/address/[[address]]', - // 'type': nodes.nodeTypes.ETH, - eip155: true, - chainId: 1, - // 'tokenList': require('./tokens/ethTokens.json'), - // 'abiList': require('./abiDefinitions/ethAbi.json'), - estimateGas: false, - service: 'Etherscan.io' - // 'lib': require('./nodeHelpers/etherscan') - }, - { - name: 'Ropsten', - // 'type': nodes.nodeTypes.Ropsten, - blockExplorerTX: 'https://ropsten.etherscan.io/tx/[[txHash]]', - blockExplorerAddr: 'https://ropsten.etherscan.io/address/[[address]]', - eip155: true, - chainId: 3, - // 'tokenList': require('./tokens/ropstenTokens.json'), - // 'abiList': require('./abiDefinitions/ropstenAbi.json'), - estimateGas: false, - service: 'MyEtherWallet' - // 'lib': new nodes.customNode('https://api.myetherapi.com/rop', '') - }, - { - name: 'Kovan', - // 'type': nodes.nodeTypes.Kovan, - blockExplorerTX: 'https://kovan.etherscan.io/tx/[[txHash]]', - blockExplorerAddr: 'https://kovan.etherscan.io/address/[[address]]', - eip155: true, - chainId: 42, - // 'tokenList': require('./tokens/kovanTokens.json'), - // 'abiList': require('./abiDefinitions/kovanAbi.json'), - estimateGas: false, - service: 'Etherscan.io' - // 'lib': require('./nodeHelpers/etherscanKov') - }, - { - name: 'ETC', - blockExplorerTX: 'https://gastracker.io/tx/[[txHash]]', - blockExplorerAddr: 'https://gastracker.io/addr/[[address]]', - // 'type': nodes.nodeTypes.ETC, - eip155: true, - chainId: 61, - // 'tokenList': require('./tokens/etcTokens.json'), - // 'abiList': require('./abiDefinitions/etcAbi.json'), - estimateGas: false, - service: 'Epool.io' - // 'lib': new nodes.customNode('https://mewapi.epool.io', '') - } + { + name: 'ETH', + blockExplorerTX: 'https://etherscan.io/tx/[[txHash]]', + blockExplorerAddr: 'https://etherscan.io/address/[[address]]', + // 'type': nodes.nodeTypes.ETH, + eip155: true, + chainId: 1, + // 'tokenList': require('./tokens/ethTokens.json'), + // 'abiList': require('./abiDefinitions/ethAbi.json'), + estimateGas: true, + service: 'MyEtherWallet' + // 'lib': new nodes.customNode('https://api.myetherapi.com/eth', '') + }, + { + name: 'ETH', + blockExplorerTX: 'https://etherscan.io/tx/[[txHash]]', + blockExplorerAddr: 'https://etherscan.io/address/[[address]]', + // 'type': nodes.nodeTypes.ETH, + eip155: true, + chainId: 1, + // 'tokenList': require('./tokens/ethTokens.json'), + // 'abiList': require('./abiDefinitions/ethAbi.json'), + estimateGas: false, + service: 'Etherscan.io' + // 'lib': require('./nodeHelpers/etherscan') + }, + { + name: 'Ropsten', + // 'type': nodes.nodeTypes.Ropsten, + blockExplorerTX: 'https://ropsten.etherscan.io/tx/[[txHash]]', + blockExplorerAddr: 'https://ropsten.etherscan.io/address/[[address]]', + eip155: true, + chainId: 3, + // 'tokenList': require('./tokens/ropstenTokens.json'), + // 'abiList': require('./abiDefinitions/ropstenAbi.json'), + estimateGas: false, + service: 'MyEtherWallet' + // 'lib': new nodes.customNode('https://api.myetherapi.com/rop', '') + }, + { + name: 'Kovan', + // 'type': nodes.nodeTypes.Kovan, + blockExplorerTX: 'https://kovan.etherscan.io/tx/[[txHash]]', + blockExplorerAddr: 'https://kovan.etherscan.io/address/[[address]]', + eip155: true, + chainId: 42, + // 'tokenList': require('./tokens/kovanTokens.json'), + // 'abiList': require('./abiDefinitions/kovanAbi.json'), + estimateGas: false, + service: 'Etherscan.io' + // 'lib': require('./nodeHelpers/etherscanKov') + }, + { + name: 'ETC', + blockExplorerTX: 'https://gastracker.io/tx/[[txHash]]', + blockExplorerAddr: 'https://gastracker.io/addr/[[address]]', + // 'type': nodes.nodeTypes.ETC, + eip155: true, + chainId: 61, + // 'tokenList': require('./tokens/etcTokens.json'), + // 'abiList': require('./abiDefinitions/etcAbi.json'), + estimateGas: false, + service: 'Epool.io' + // 'lib': new nodes.customNode('https://mewapi.epool.io', '') + } ]; diff --git a/common/containers/Tabs/Swap/components/wantToSwapMy.js b/common/containers/Tabs/Swap/components/currencySwap.js similarity index 94% rename from common/containers/Tabs/Swap/components/wantToSwapMy.js rename to common/containers/Tabs/Swap/components/currencySwap.js index f82da9f0..be58f129 100644 --- a/common/containers/Tabs/Swap/components/wantToSwapMy.js +++ b/common/containers/Tabs/Swap/components/currencySwap.js @@ -31,9 +31,9 @@ class CoinTypeDropDown extends Component { } } -export default class WantToSwapMy extends Component { - constructor(props, context) { - super(props, context); +export default class CurrencySwap extends Component { + constructor(props) { + super(props); } static propTypes = { @@ -47,10 +47,13 @@ export default class WantToSwapMy extends Component { originKindSwap: PropTypes.func, destinationKindSwap: PropTypes.func, originAmountSwap: PropTypes.func, - destinationAmountSwap: PropTypes.func + destinationAmountSwap: PropTypes.func, + partOneCompleteSwap: PropTypes.func }; - onClickStartSwap() {} + onClickStartSwap = () => { + this.props.partOneCompleteSwap(true); + }; onChangeOriginAmount = amount => { let originAmountAsNumber = parseFloat(amount); diff --git a/common/containers/Tabs/Swap/components/currentRates.js b/common/containers/Tabs/Swap/components/currentRates.js index 577df5a4..1016bec4 100644 --- a/common/containers/Tabs/Swap/components/currentRates.js +++ b/common/containers/Tabs/Swap/components/currentRates.js @@ -1,6 +1,7 @@ import React, { Component } from 'react'; import translate from 'translations'; import PropTypes from 'prop-types'; +import { toFixedIfLarger } from 'utils/formatters'; export default class CurrentRates extends Component { constructor(props) { @@ -48,10 +49,10 @@ export default class CurrentRates extends Component { name="ETHBTCAmount" /> - ETH = {(this.state.ETHBTCAmount * this.props.ETHBTC).toFixed( + {` ETH = ${toFixedIfLarger( + this.state.ETHBTCAmount * this.props.ETHBTC, 6 - )}{' '} - BTC + )} BTC`}
@@ -62,10 +63,10 @@ export default class CurrentRates extends Component { name="ETHREPAmount" /> - ETH = {(this.state.ETHREPAmount * this.props.ETHREP).toFixed( + {` ETH = ${toFixedIfLarger( + this.state.ETHREPAmount * this.props.ETHREP, 6 - )}{' '} - REP + )} REP`}
@@ -78,10 +79,10 @@ export default class CurrentRates extends Component { name="BTCETHAmount" /> - BTC = {(this.state.BTCETHAmount * this.props.BTCETH).toFixed( + {` BTC = ${toFixedIfLarger( + this.state.BTCETHAmount * this.props.BTCETH, 6 - )}{' '} - ETH + )} ETH`}@@ -92,10 +93,10 @@ export default class CurrentRates extends Component { name="BTCREPAmount" /> - BTC = {(this.state.BTCREPAmount * this.props.BTCREP).toFixed( + {` BTC = ${toFixedIfLarger( + this.state.BTCREPAmount * this.props.BTCREP, 6 - )}{' '} - REP + )} REP`}
diff --git a/common/containers/Tabs/Swap/components/receivingAddress.js b/common/containers/Tabs/Swap/components/receivingAddress.js new file mode 100644 index 00000000..c2bc37a8 --- /dev/null +++ b/common/containers/Tabs/Swap/components/receivingAddress.js @@ -0,0 +1,67 @@ +import React, { Component } from 'react'; +import PropTypes from 'prop-types'; +import { DONATION_ADDRESSES_MAP } from 'config/data'; +import Validator from 'libs/validator'; +import translate from 'translations'; + +export default class ReceivingAddress extends Component { + constructor(props) { + super(props); + this.validator = new Validator(); + this.state = { + validAddress: false + }; + } + + static propTypes = { + destinationKind: PropTypes.string.isRequired, + receivingAddressSwap: PropTypes.func.isRequired, + receivingAddress: PropTypes.string + }; + + onChangeReceivingAddress = event => { + const value = event.target.value; + this.props.receivingAddressSwap(value); + let validAddress; + // TODO - find better pattern here once currencies move beyond BTC, ETH, REP + if (this.props.destinationKind === 'BTC') { + validAddress = this.validator.isValidBTCAddress(value); + } else { + validAddress = this.validator.isValidETHAddress(value); + } + this.setState({ validAddress }); + }; + + render() { + const { destinationKind, receivingAddress } = this.props; + const { validAddress } = this.state; + return ( +{translate('SEND_amount')}
+{translate('SWAP_rec_amt')}
+{translate('SWAP_your_rate')}
+