diff --git a/react/change.log b/react/change.log index fd505ef..b78afb8 100644 --- a/react/change.log +++ b/react/change.log @@ -12,6 +12,10 @@ front: - sort http stack history desc - swapped gettotalbalance interest with getinfo interest - extended settings / export keys ui +- added error message if coin is already running in another mode +- added explicit "new address generated" message +- added cli / rpc passphru back: -- added cli route \ No newline at end of file +- added cli route +- rpc passphru \ No newline at end of file diff --git a/react/src/actions/actions/addressBalance.js b/react/src/actions/actions/addressBalance.js index 6efd174..af2c2fe 100644 --- a/react/src/actions/actions/addressBalance.js +++ b/react/src/actions/actions/addressBalance.js @@ -106,20 +106,46 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { } }) } else { + if (Config.cli.default && + mode === 'native') { + payload = { + mode: null, + chain: coin, + cmd: payload.function, + params: [""] + }; + } + const _timestamp = Date.now(); dispatch(logGuiHttp({ 'timestamp': _timestamp, 'function': 'getKMDAddressesNative', 'type': 'post', - 'url': `http://127.0.0.1:${Config.iguanaCorePort}`, + 'url': Config.cli.default ? `http://127.0.0.1:${Config.agamaPort}/shepherd/cli` : `http://127.0.0.1:${Config.iguanaCorePort}`, 'payload': payload, 'status': 'pending', })); - fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { + let _fetchConfig = { method: 'POST', body: JSON.stringify(payload), - }) + }; + + if (Config.cli.default && + mode === 'native') { + _fetchConfig = { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ 'payload': payload }), + }; + } + + fetch( + Config.cli.default && mode === 'native' ? `http://127.0.0.1:${Config.agamaPort}/shepherd/cli` : `http://127.0.0.1:${Config.iguanaCorePort}`, + _fetchConfig + ) .catch(function(error) { console.log(error); dispatch(logGuiHttp({ @@ -142,7 +168,7 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { 'status': 'success', 'response': json, })); - resolve(json); + resolve(Config.cli.default && mode === 'native' ? json.result : json); }) } }); @@ -227,8 +253,19 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { } } - let newAddressArray = []; + // remove addr duplicates + if (result[0]) { + result[0] = result[0].filter(function(elem, pos) { + return result[0].indexOf(elem) === pos; + }); + } + if (result[1]) { + result[1] = result[1].filter(function(elem, pos) { + return result[1].indexOf(elem) === pos; + }); + } + let newAddressArray = []; for (let a = 0; a < result.length; a++) { newAddressArray[a] = []; @@ -260,7 +297,7 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { Promise.all(result[1].map((_address, index) => { return new Promise((resolve, reject) => { const _timestamp = Date.now(); - let ajaxDataToHex = `["${_address}"]`; + let ajaxDataToHex = `[\"${_address}\"]`; iguanaHashHex(ajaxDataToHex, dispatch) .then((hashHexJson) => { @@ -286,16 +323,40 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { 'timestamp': _timestamp, 'function': 'getKMDAddressesNative+ZBalance', 'type': 'post', - 'url': `http://127.0.0.1:${Config.iguanaCorePort}`, + 'url': Config.cli.default ? `http://127.0.0.1:${Config.agamaPort}/shepherd/cli` : `http://127.0.0.1:${Config.iguanaCorePort}`, 'payload': payload, 'status': 'pending', })); - fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, - { + let _fetchConfig = { method: 'POST', body: JSON.stringify(payload), - }) + }; + + if (Config.cli.default && + mode === 'native') { + payload = { + mode: null, + chain: coin, + cmd: 'z_getbalance', + params: [ + _address + ] + }; + + _fetchConfig = { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ 'payload': payload }), + }; + } + + fetch( + Config.cli.default && mode === 'native' ? `http://127.0.0.1:${Config.agamaPort}/shepherd/cli` : `http://127.0.0.1:${Config.iguanaCorePort}`, + _fetchConfig + ) .catch(function(error) { console.log(error); dispatch(logGuiHttp({ @@ -329,6 +390,10 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { ) ); } else { + if (Config.cli.default && + mode === 'native') { + json = json.result; + } resolve(json); newAddressArray[1][index] = { address: _address, @@ -449,10 +514,33 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { 'status': 'pending', })); - fetch(`http://127.0.0.1:${(Config.useBasiliskInstance && mode === 'basilisk' ? Config.iguanaCorePort + 1 : Config.iguanaCorePort)}`, { + let _fetchConfig = { method: 'POST', body: JSON.stringify(payload), - }) + }; + + if (Config.cli.default && + mode === 'native') { + payload = { + mode: null, + chain: coin, + cmd: payload.function, + params: payload.params + }; + + _fetchConfig = { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ 'payload': payload }), + }; + } + + fetch( + Config.cli.default && mode === 'native' ? `http://127.0.0.1:${Config.agamaPort}/shepherd/cli` : `http://127.0.0.1:${(Config.useBasiliskInstance && mode === 'basilisk' ? Config.iguanaCorePort + 1 : Config.iguanaCorePort)}`, + _fetchConfig + ) .catch(function(error) { console.log(error); dispatch(logGuiHttp({ @@ -470,6 +558,10 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { }) .then(response => response.json()) .then(function(json) { + if (Config.cli.default && + mode === 'native') { + json = json.result; + } dispatch(logGuiHttp({ 'timestamp': _timestamp, 'status': 'success', diff --git a/react/src/actions/actions/iguanaHelpers.js b/react/src/actions/actions/iguanaHelpers.js index f989c3b..8c5abf2 100644 --- a/react/src/actions/actions/iguanaHelpers.js +++ b/react/src/actions/actions/iguanaHelpers.js @@ -28,44 +28,49 @@ export function iguanaHashHex(data, dispatch) { }; return new Promise((resolve, reject) => { - const _timestamp = Date.now(); - dispatch(logGuiHttp({ - 'timestamp': _timestamp, - 'function': 'iguanaHashHex', - 'type': 'post', - 'url': `http://127.0.0.1:${Config.iguanaCorePort}`, - 'payload': payload, - 'status': 'pending', - })); - - fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { - method: 'POST', - body: JSON.stringify(payload), - }) - .catch(function(error) { - console.log(error); + // skip iguana hashing in cli mode + if (Config.cli.default) { + resolve(true); + } else { + const _timestamp = Date.now(); dispatch(logGuiHttp({ 'timestamp': _timestamp, - 'status': 'error', - 'response': error, + 'function': 'iguanaHashHex', + 'type': 'post', + 'url': `http://127.0.0.1:${Config.iguanaCorePort}`, + 'payload': payload, + 'status': 'pending', })); - dispatch( - triggerToaster( - 'iguanaHashHex', - 'Error', - 'error' - ) - ); - }) - .then(response => response.json()) - .then(json => { - dispatch(logGuiHttp({ - 'timestamp': _timestamp, - 'status': 'success', - 'response': json, - })); - resolve(json.hex); - }) + + fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { + method: 'POST', + body: JSON.stringify(payload), + }) + .catch(function(error) { + console.log(error); + dispatch(logGuiHttp({ + 'timestamp': _timestamp, + 'status': 'error', + 'response': error, + })); + dispatch( + triggerToaster( + 'iguanaHashHex', + 'Error', + 'error' + ) + ); + }) + .then(response => response.json()) + .then(json => { + dispatch(logGuiHttp({ + 'timestamp': _timestamp, + 'status': 'success', + 'response': json, + })); + resolve(json.hex); + }) + } }) } diff --git a/react/src/actions/actions/nativeBalance.js b/react/src/actions/actions/nativeBalance.js index 05dfe32..fc2612c 100644 --- a/react/src/actions/actions/nativeBalance.js +++ b/react/src/actions/actions/nativeBalance.js @@ -32,21 +32,44 @@ export function getKMDBalanceTotal(coin) { }; } + if (Config.cli.default) { + payload = { + mode: null, + chain: coin, + cmd: 'z_gettotalbalance' + }; + } + return dispatch => { const _timestamp = Date.now(); dispatch(logGuiHttp({ 'timestamp': _timestamp, 'function': 'getKMDBalanceTotal', 'type': 'post', - 'url': `http://127.0.0.1:${Config.iguanaCorePort}`, + 'url': Config.cli.default ? `http://127.0.0.1:${Config.agamaPort}/shepherd/cli` : `http://127.0.0.1:${Config.iguanaCorePort}`, 'payload': payload, 'status': 'pending', })); - return fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { + let _fetchConfig = { method: 'POST', body: JSON.stringify(payload), - }) + }; + + if (Config.cli.default) { + _fetchConfig = { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ 'payload': payload }), + }; + } + + return fetch( + Config.cli.default ? `http://127.0.0.1:${Config.agamaPort}/shepherd/cli` : `http://127.0.0.1:${Config.iguanaCorePort}`, + _fetchConfig + ) .catch(function(error) { console.log(error); dispatch(logGuiHttp({ @@ -80,6 +103,6 @@ export function getKMDBalanceTotal(coin) { export function getNativeBalancesState(json) { return { type: DASHBOARD_ACTIVE_COIN_NATIVE_BALANCE, - balance: json && !json.error ? json : 0, + balance: json && !json.error ? (Config.cli.default ? json.result : json) : 0, } } \ No newline at end of file diff --git a/react/src/actions/actions/nativeNewAddress.js b/react/src/actions/actions/nativeNewAddress.js index c6ff35a..7bac1a8 100644 --- a/react/src/actions/actions/nativeNewAddress.js +++ b/react/src/actions/actions/nativeNewAddress.js @@ -10,13 +10,21 @@ import { guiLogState } from './log'; -function handleGetNewKMDAddresses(pubpriv, coin, dispatch) { - dispatch( +function handleGetNewKMDAddresses(pubpriv, coin, dispatch, json) { + /*dispatch( triggerToaster( translate('KMD_NATIVE.NEW_ADDR_GENERATED'), translate('TOASTR.WALLET_NOTIFICATION'), 'success' ) + );*/ + dispatch( + triggerToaster( + json.result ? json.result : json, + translate('KMD_NATIVE.NEW_ADDR_GENERATED'), + 'info', + false + ) ); dispatch(getKMDAddressesNative(coin)); @@ -45,7 +53,7 @@ export function getNewKMDAddresses(coin, pubpriv) { }; } else { payload = { - 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + 'userpass': `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`, 'agent': coin, 'method': 'passthru', 'function': ajaxFunctionInput, @@ -59,15 +67,36 @@ export function getNewKMDAddresses(coin, pubpriv) { 'timestamp': _timestamp, 'function': 'getNewKMDAddresses', 'type': 'post', - 'url': `http://127.0.0.1:${Config.iguanaCorePort}`, + 'url': Config.cli.default ? `http://127.0.0.1:${Config.agamaPort}/shepherd/cli` : `http://127.0.0.1:${Config.iguanaCorePort}`, 'payload': payload, 'status': 'pending', })); - return fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { + let _fetchConfig = { method: 'POST', body: JSON.stringify(payload), - }) + }; + + if (Config.cli.default) { + payload = { + mode: null, + chain: coin, + cmd: payload.function + }; + + _fetchConfig = { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ 'payload': payload }), + }; + } + + return fetch( + Config.cli.default ? `http://127.0.0.1:${Config.agamaPort}/shepherd/cli` : `http://127.0.0.1:${Config.iguanaCorePort}`, + _fetchConfig + ) .catch(function(error) { console.log(error); dispatch(logGuiHttp({ @@ -85,6 +114,9 @@ export function getNewKMDAddresses(coin, pubpriv) { }) .then(response => response.json()) .then(json => { + if (Config.cli.default) { + json = json.result; + } dispatch(logGuiHttp({ 'timestamp': _timestamp, 'status': 'success', @@ -94,7 +126,8 @@ export function getNewKMDAddresses(coin, pubpriv) { handleGetNewKMDAddresses( pubpriv, coin, - dispatch + dispatch, + json ) ); }) diff --git a/react/src/actions/actions/nativeSend.js b/react/src/actions/actions/nativeSend.js index 898b15e..4e78805 100644 --- a/react/src/actions/actions/nativeSend.js +++ b/react/src/actions/actions/nativeSend.js @@ -51,15 +51,50 @@ export function sendNativeTx(coin, _payload) { 'timestamp': _timestamp, 'function': 'sendNativeTx', 'type': 'post', - 'url': `http://127.0.0.1:${Config.iguanaCorePort}`, + 'url': Config.cli.default ? `http://127.0.0.1:${Config.agamaPort}/shepherd/cli` : `http://127.0.0.1:${Config.iguanaCorePort}`, 'payload': payload, 'status': 'pending', })); - fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { + let _fetchConfig = { method: 'POST', body: JSON.stringify(payload), - }) + }; + + if (Config.cli.default) { + payload = { + mode: null, + chain: coin, + cmd: payload.function, + params: + _payload.addressType === 'public' && _payload.sendTo.length !== 95 ? + [ + _payload.sendTo, + _payload.amount + ] + : + [ + _payload.sendFrom, + [{ + address: _payload.sendTo, + amount: _payload.amount + }] + ] + }; + + _fetchConfig = { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ 'payload': payload }), + }; + } + + fetch( + Config.cli.default ? `http://127.0.0.1:${Config.agamaPort}/shepherd/cli` : `http://127.0.0.1:${Config.iguanaCorePort}`, + _fetchConfig + ) .catch(function(error) { console.log(error); dispatch(logGuiHttp({ @@ -77,7 +112,7 @@ export function sendNativeTx(coin, _payload) { }) .then(function(response) { const _response = response.text().then(function(text) { return text; }); - return response.json(); + return _response; }) .then(function(json) { dispatch(logGuiHttp({ @@ -86,15 +121,29 @@ export function sendNativeTx(coin, _payload) { 'response': json, })); - if (json.error && - json.error.toString().indexOf('code:') > -1) { + if (json.indexOf('"code":') > -1) { + const _message = json.substring(json.indexOf('"message":"') + 11, json.indexOf('"},"id":"jl777"')); + dispatch( triggerToaster( - 'Send failed', + true, + _message, translate('TOASTR.WALLET_NOTIFICATION'), 'error' ) ); + + if (json.indexOf('"code":-4') > -1) { + dispatch( + triggerToaster( + true, + translate('TOASTR.WALLET_NOTIFICATION'), + 'Your wallet.dat is not matching the blockchain. Please resync from the scratch.', + 'info', + false + ) + ); + } } else { dispatch( triggerToaster( @@ -160,15 +209,36 @@ export function getKMDOPID(opid, coin) { 'timestamp': _timestamp, 'function': 'getKMDOPID', 'type': 'post', - 'url': `http://127.0.0.1:${Config.iguanaCorePort}`, + 'url': Config.cli.default ? `http://127.0.0.1:${Config.agamaPort}/shepherd/cli` : `http://127.0.0.1:${Config.iguanaCorePort}`, 'payload': payload, 'status': 'pending', })); - fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { + let _fetchConfig = { method: 'POST', body: JSON.stringify(payload), - }) + }; + + if (Config.cli.default) { + payload = { + mode: null, + chain: coin, + cmd: 'z_getoperationstatus' + }; + + _fetchConfig = { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ 'payload': payload }), + }; + } + + fetch( + Config.cli.default ? `http://127.0.0.1:${Config.agamaPort}/shepherd/cli` : `http://127.0.0.1:${Config.iguanaCorePort}`, + _fetchConfig + ) .catch(function(error) { console.log(error); dispatch(logGuiHttp({ @@ -186,6 +256,9 @@ export function getKMDOPID(opid, coin) { }) .then(response => response.json()) .then(json => { + if (Config.cli.default) { + json = json.result; + } dispatch(logGuiHttp({ 'timestamp': _timestamp, 'status': 'success', diff --git a/react/src/actions/actions/nativeSyncInfo.js b/react/src/actions/actions/nativeSyncInfo.js index 5459798..dd37de7 100644 --- a/react/src/actions/actions/nativeSyncInfo.js +++ b/react/src/actions/actions/nativeSyncInfo.js @@ -60,20 +60,31 @@ export function getSyncInfoNativeKMD(skipDebug) { } function getSyncInfoNativeState(json, coin, skipDebug) { + console.log('getSyncInfoNativeState', json); if (coin === 'KMD' && json && json.error) { return getSyncInfoNativeKMD(skipDebug); } else { - return { - type: SYNCING_NATIVE_MODE, - progress: json, + if (json && + json.error && + Config.cli.default) { + console.log('getSyncInfoNativeState', 'error'); + return { + type: SYNCING_NATIVE_MODE, + progress: Config.cli.default ? json.error : json, + } + } else { + return { + type: SYNCING_NATIVE_MODE, + progress: Config.cli.default ? json.result : json, + } } } } export function getSyncInfoNative(coin, skipDebug) { - const payload = { + let payload = { 'userpass': `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`, 'agent': getPassthruAgent(coin), 'method': 'passthru', @@ -82,21 +93,43 @@ export function getSyncInfoNative(coin, skipDebug) { 'hex': '', }; + if (Config.cli.default) { + payload = { + mode: null, + chain: coin, + cmd: 'getinfo' + }; + } + return dispatch => { const _timestamp = Date.now(); dispatch(logGuiHttp({ 'timestamp': _timestamp, 'function': 'getSyncInfo', 'type': 'post', - 'url': `http://127.0.0.1:${Config.iguanaCorePort}`, + 'url': Config.cli.default ? `http://127.0.0.1:${Config.agamaPort}/shepherd/cli` : `http://127.0.0.1:${Config.iguanaCorePort}`, 'payload': payload, 'status': 'pending', })); - - return fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { + let _fetchConfig = { method: 'POST', body: JSON.stringify(payload), - }) + }; + + if (Config.cli.default) { + _fetchConfig = { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ 'payload': payload }), + }; + } + + return fetch( + Config.cli.default ? `http://127.0.0.1:${Config.agamaPort}/shepherd/cli` : `http://127.0.0.1:${Config.iguanaCorePort}`, + _fetchConfig + ) .catch(function(error) { console.log(error); dispatch(logGuiHttp({ @@ -112,8 +145,26 @@ export function getSyncInfoNative(coin, skipDebug) { ) ); }) - .then(response => response.json()) + .then(function(response) { + const _response = response.text().then(function(text) { return text; }); + return _response; + }) + //.then(response => response.json()) .then(json => { + if (!json && + Config.cli.default) { + dispatch( + triggerToaster( + 'Komodod is down', + 'Critical Error', + 'error', + false + ) + ); + } else { + json = JSON.parse(json); + } + dispatch(logGuiHttp({ 'timestamp': _timestamp, 'status': 'success', diff --git a/react/src/actions/actions/nativeTxHistory.js b/react/src/actions/actions/nativeTxHistory.js index 61896b0..c35c447 100644 --- a/react/src/actions/actions/nativeTxHistory.js +++ b/react/src/actions/actions/nativeTxHistory.js @@ -37,15 +37,36 @@ export function getNativeTxHistory(coin) { 'timestamp': _timestamp, 'function': 'getNativeTxHistory', 'type': 'post', - 'url': `http://127.0.0.1:${Config.iguanaCorePort}`, + 'url': Config.cli.default ? `http://127.0.0.1:${Config.agamaPort}/shepherd/cli` : `http://127.0.0.1:${Config.iguanaCorePort}`, 'payload': payload, 'status': 'pending', })); - return fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { + let _fetchConfig = { method: 'POST', body: JSON.stringify(payload), - }) + }; + + if (Config.cli.default) { + payload = { + mode: null, + chain: coin, + cmd: 'listtransactions' + }; + + _fetchConfig = { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ 'payload': payload }), + }; + } + + return fetch( + Config.cli.default ? `http://127.0.0.1:${Config.agamaPort}/shepherd/cli` : `http://127.0.0.1:${Config.iguanaCorePort}`, + _fetchConfig + ) .catch(function(error) { console.log(error); dispatch(logGuiHttp({ diff --git a/react/src/components/dashboard/main/dashboard.js b/react/src/components/dashboard/main/dashboard.js index 3edd13b..8f9bdba 100755 --- a/react/src/components/dashboard/main/dashboard.js +++ b/react/src/components/dashboard/main/dashboard.js @@ -26,6 +26,10 @@ class Dashboard extends React.Component { this.props.Main.isLoggedIn; } + isNativeMode() { + return this.props.ActiveCoin.mode === 'native'; + } + render() { if (this.isLoggedIn()) { return this.renderDashboard(); diff --git a/react/src/components/dashboard/receiveCoin/receiveCoin.js b/react/src/components/dashboard/receiveCoin/receiveCoin.js index a69455f..564fa69 100644 --- a/react/src/components/dashboard/receiveCoin/receiveCoin.js +++ b/react/src/components/dashboard/receiveCoin/receiveCoin.js @@ -2,10 +2,10 @@ import React from 'react'; import { copyCoinAddress, checkAddressBasilisk, - validateAddressBasilisk + validateAddressBasilisk, + getNewKMDAddresses } from '../../../actions/actionCreators'; import Store from '../../../store'; - import { AddressActionsBasiliskModeRender, AddressActionsNonBasiliskModeRender, @@ -19,6 +19,43 @@ import { class ReceiveCoin extends React.Component { constructor(props) { super(props); + + this.state = { + openDropMenu: false, + }; + this.openDropMenu = this.openDropMenu.bind(this); + this.handleClickOutside = this.handleClickOutside.bind(this); + } + + componentWillMount() { + document.addEventListener( + 'click', + this.handleClickOutside, + false + ); + } + + componentWillUnmount() { + document.removeEventListener( + 'click', + this.handleClickOutside, + false + ); + } + + handleClickOutside(e) { + if (e.srcElement.className.indexOf('dropdown') === -1 && + (e.srcElement.offsetParent && e.srcElement.offsetParent.className.indexOf('dropdown') === -1)) { + this.setState({ + openDropMenu: false, + }); + } + } + + openDropMenu() { + this.setState(Object.assign({}, this.state, { + openDropMenu: !this.state.openDropMenu, + })); } _checkAddressBasilisk(address) { @@ -47,12 +84,16 @@ class ReceiveCoin extends React.Component { return this.props.mode === 'basilisk'; } - renderAddressActions(address) { + isNativeMode() { + return this.props.mode == 'native'; + } + + renderAddressActions(address, type) { if (this.isBasiliskMode()) { return AddressActionsBasiliskModeRender.call(this, address); } - return AddressActionsNonBasiliskModeRender.call(this, address); + return AddressActionsNonBasiliskModeRender.call(this, address, type); } hasNoAmount(address) { @@ -63,26 +104,34 @@ class ReceiveCoin extends React.Component { return address.interest === 'N/A' || address.interest === 0 || !address.interest; } - renderAddressList() { + getNewAddress(type) { + Store.dispatch(getNewKMDAddresses(this.props.coin, type)); + } + + renderAddressList(type) { if (this.props.addresses && - this.props.addresses.public && - this.props.addresses.public.length) { + this.props.addresses[type] && + this.props.addresses[type].length) { let items = []; - for (let i = 0; i < this.props.addresses.public.length; i++) { - let address = this.props.addresses.public[i]; + for (let i = 0; i < this.props.addresses[type].length; i++) { + let address = this.props.addresses[type][i]; if (this.isBasiliskMode() && - this.hasNoAmount(address)) { - address.amount = this.props.cache && this.props.cache[this.props.coin][address.address] && this.props.cache[this.props.coin][address.address].getbalance.data && this.props.cache[this.props.coin][address.address].getbalance.data.balance ? this.props.cache[this.props.coin][address.address].getbalance.data.balance : 'N/A'; + this.hasNoAmount(address)) { + address.amount = this.props.cache && this.props.cache[this.props.coin][address.address] + && this.props.cache[this.props.coin][address.address].getbalance.data + && this.props.cache[this.props.coin][address.address].getbalance.data.balance ? this.props.cache[this.props.coin][address.address].getbalance.data.balance : 'N/A'; } if (this.isBasiliskMode() && - this.hasNoInterest(address)) { - address.interest = this.props.cache && this.props.cache[this.props.coin][address.address] && this.props.cache[this.props.coin][address.address].getbalance.data && this.props.cache[this.props.coin][address.address].getbalance.data.interest ? this.props.cache[this.props.coin][address.address].getbalance.data.interest : 'N/A'; + this.hasNoInterest(address)) { + address.interest = this.props.cache && this.props.cache[this.props.coin][address.address] + && this.props.cache[this.props.coin][address.address].getbalance.data + && this.props.cache[this.props.coin][address.address].getbalance.data.interest ? this.props.cache[this.props.coin][address.address].getbalance.data.interest : 'N/A'; } items.push( - AddressItemRender.call(this, address) + AddressItemRender.call(this, address, type) ); } @@ -93,9 +142,10 @@ class ReceiveCoin extends React.Component { } render() { + // TODO nativeActiveSection === 'receive' should be removed when native mode is fully merged + // into the rest of the components if (this.props && - this.props.receive && - this.props.mode !== 'native') { + (this.props.receive || (this.isNativeMode() && this.props.nativeActiveSection === 'receive'))) { return ReceiveCoinRender.call(this); } diff --git a/react/src/components/dashboard/receiveCoin/receiveCoin.render.js b/react/src/components/dashboard/receiveCoin/receiveCoin.render.js index abc865d..8d3db07 100644 --- a/react/src/components/dashboard/receiveCoin/receiveCoin.render.js +++ b/react/src/components/dashboard/receiveCoin/receiveCoin.render.js @@ -29,11 +29,12 @@ export const AddressActionsBasiliskModeRender = function(address) { ); }; -export const AddressActionsNonBasiliskModeRender = function(address) { +export const AddressActionsNonBasiliskModeRender = function(address, type) { return (