From fe424cb37137bcc02df341bbefe47d636959665f Mon Sep 17 00:00:00 2001 From: pbca26 Date: Fri, 28 Apr 2017 10:08:15 +0300 Subject: [PATCH 01/16] send to openalias handle --- react/src/actions/actionCreators.js | 34 +++++++++- react/src/components/dashboard/sendCoin.js | 67 +++++++++++++++++-- react/src/components/dashboard/walletsData.js | 19 ++---- .../components/dashboard/walletsNativeSend.js | 66 ++++++++++++++++-- react/src/config.js | 1 + 5 files changed, 164 insertions(+), 23 deletions(-) diff --git a/react/src/actions/actionCreators.js b/react/src/actions/actionCreators.js index 266050d..1b3529c 100644 --- a/react/src/actions/actionCreators.js +++ b/react/src/actions/actionCreators.js @@ -157,7 +157,7 @@ function toggleSendReceiveCoinFormsState() { } } -function triggerToaster(display, message, title, _type) { +export function triggerToaster(display, message, title, _type) { return { type: TOASTER_MESSAGE, display, @@ -2063,6 +2063,38 @@ export function restartIguanaInstance(pmid) { }); } +export function restartBasiliskInstance() { + return dispatch => { + getIguanaInstancesList() + .then(function(json) { + for (let port in json.result) { + if (json.result[port].mode === 'basilisk') { + restartIguanaInstance(json.result[port].pmid) + .then(function(json) { + console.log('restartBasiliskInstance', json); + }); + } + } + }); + } +} + +export function resolveOpenAliasAddress(email) { + const url = email.replace('@', '.'); + + return new Promise((resolve, reject) => { + fetch('https://dns.google.com/resolve?name=' + url + '&type=txt', { + method: 'GET', + }) + .catch(function(error) { + console.log(error); + dispatch(triggerToaster(true, 'resolveOpenAliasAddress', 'Error', 'error')); + }) + .then(response => response.json()) + .then(json => resolve(json)) + }); +} + export function connectNotaries() { const payload = { 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), diff --git a/react/src/components/dashboard/sendCoin.js b/react/src/components/dashboard/sendCoin.js index 2e2202c..86d42c0 100644 --- a/react/src/components/dashboard/sendCoin.js +++ b/react/src/components/dashboard/sendCoin.js @@ -1,6 +1,13 @@ import React from 'react'; +import Config from '../../config'; import { translate } from '../../translate/translate'; -import { sendToAddress } from '../../actions/actionCreators'; +import { + sendToAddress, + sendNativeTx, + getKMDOPID, + resolveOpenAliasAddress, + triggerToaster +} from '../../actions/actionCreators'; import Store from '../../store'; // TODO: implement logic @@ -12,7 +19,8 @@ class SendCoin extends React.Component { currentStep: 0, sendFrom: this.props.Dashboard && this.props.Dashboard.activeHandle ? this.props.Dashboard.activeHandle[this.props.ActiveCoin.coin] : null, sendFromAmount: 0, - sendTo: null, + sendTo: '', + sendToOA: null, amount: 0, fee: 0.0001, sendSig: false, @@ -20,6 +28,7 @@ class SendCoin extends React.Component { this.updateInput = this.updateInput.bind(this); this.handleSubmit = this.handleSubmit.bind(this); this.toggleSendSig = this.toggleSendSig.bind(this); + this.getOAdress = this.getOAdress.bind(this); } changeSendCoinStep(step) { @@ -97,7 +106,7 @@ class SendCoin extends React.Component { false ); } - } + } } renderSendCoinResponse() { @@ -113,6 +122,53 @@ class SendCoin extends React.Component { } } + getOAdress() { + resolveOpenAliasAddress(this.state.sendToOA) + .then(function(json) { + const reply = json.Answer; + + if (reply && reply.length) { + for (let i = 0; i < reply.length; i++) { + const _address = reply[i].data.split(' '); + const coin = _address[0].replace('"oa1:', ''); + const coinAddress = _address[1].replace('recipient_address=', '').replace(';', ''); + + if (coin.toUpperCase() === this.props.ActiveCoin.coin) { + this.setState(Object.assign({}, this.state, { + sendTo: coinAddress, + })); + } + } + + if (this.state.sendTo === '') { + Store.dispatch(triggerToaster(true, 'Couldn\'t find any ' + this.props.ActiveCoin.coin +' addresses', 'OpenAlias', 'error')); + } + } else { + Store.dispatch(triggerToaster(true, 'Couldn\'t find any addresses', 'OpenAlias', 'error')); + } + }.bind(this)); + } + + renderOASendUI() { + if (Config.openAlias) { + return ( +
+
+ + +
+
+ +
+
+ ); + } else { + return null; + } + } + render() { if (this.props.ActiveCoin && this.props.ActiveCoin.send && this.props.ActiveCoin.mode !== 'native') { return ( @@ -155,9 +211,12 @@ class SendCoin extends React.Component { + + {this.renderOASendUI()} +
- +
+
+ {this.renderOASendUI()} +
- +
diff --git a/react/src/config.js b/react/src/config.js index 700a203..0eb154b 100644 --- a/react/src/config.js +++ b/react/src/config.js @@ -4,4 +4,5 @@ module.exports = { agamaPort: 17777, enableCacheApi: true, useBasiliskInstance: true, + openAlias: true, }; From 18370431711a29f2fde17ea09bf9245cca79c9d0 Mon Sep 17 00:00:00 2001 From: pbca26 Date: Fri, 28 Apr 2017 10:22:28 +0300 Subject: [PATCH 02/16] basilisk / full send (wip) --- react/src/components/dashboard/sendCoin.js | 64 +++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) diff --git a/react/src/components/dashboard/sendCoin.js b/react/src/components/dashboard/sendCoin.js index 86d42c0..7851702 100644 --- a/react/src/components/dashboard/sendCoin.js +++ b/react/src/components/dashboard/sendCoin.js @@ -15,6 +15,7 @@ import Store from '../../store'; class SendCoin extends React.Component { constructor(props) { super(props); + this.state = { currentStep: 0, sendFrom: this.props.Dashboard && this.props.Dashboard.activeHandle ? this.props.Dashboard.activeHandle[this.props.ActiveCoin.coin] : null, @@ -24,13 +25,74 @@ class SendCoin extends React.Component { amount: 0, fee: 0.0001, sendSig: false, + addressSelectorOpen: false, }; this.updateInput = this.updateInput.bind(this); this.handleSubmit = this.handleSubmit.bind(this); + this.openDropMenu = this.openDropMenu.bind(this); this.toggleSendSig = this.toggleSendSig.bind(this); this.getOAdress = this.getOAdress.bind(this); } + renderAddressByType(type) { + if (this.props.ActiveCoin.addresses && this.props.ActiveCoin.addresses[type] && this.props.ActiveCoin.addresses[type].length) { + return this.props.ActiveCoin.addresses[type].map((address) => +
  • + this.updateAddressSelection(address.address, type, address.amount)}> [ {address.amount} {this.props.ActiveCoin.coin} ]  {address.address} +
  • + ); + } else { + return null; + } + } + + renderSelectorCurrentLabel() { + if (this.state.sendFrom) { + return ( + + [ {this.state.sendFromAmount} {this.props.ActiveCoin.coin} ]  {this.state.sendFrom} + + ); + } else { + return ( + - Select Transparent or Private Address - + ); + } + } + + renderAddressList() { + return ( +
    + +
    + +
    +
    + ); + } + + openDropMenu() { + this.setState(Object.assign({}, this.state, { + addressSelectorOpen: !this.state.addressSelectorOpen, + })); + } + + updateAddressSelection(address, type, amount) { + this.setState(Object.assign({}, this.state, { + sendFrom: address, + addressType: type, + sendFromAmount: amount, + addressSelectorOpen: !this.state.addressSelectorOpen, + })); + } + changeSendCoinStep(step) { this.setState(Object.assign({}, this.state, { currentStep: step, @@ -209,7 +271,7 @@ class SendCoin extends React.Component {
    - + {this.renderAddressList()}
    {this.renderOASendUI()} From d2095ef3cc4bc23651ca06c832a15d06cdf1816a Mon Sep 17 00:00:00 2001 From: pbca26 Date: Fri, 28 Apr 2017 13:29:42 +0300 Subject: [PATCH 03/16] utxo raw --- .../src/components/dashboard/coinTileItem.js | 1 - react/src/components/dashboard/sendCoin.js | 23 +++++++++++++++---- react/src/config.js | 1 + 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/react/src/components/dashboard/coinTileItem.js b/react/src/components/dashboard/coinTileItem.js index 3b6d051..0d1cc26 100644 --- a/react/src/components/dashboard/coinTileItem.js +++ b/react/src/components/dashboard/coinTileItem.js @@ -49,7 +49,6 @@ class CoinTileItem extends React.Component { Store.dispatch(getFullTransactionsList(coin)); } if (mode === 'basilisk') { - console.log('dispatchCoinActions', mode); const useAddress = this.props.ActiveCoin.mainBasiliskAddress ? this.props.ActiveCoin.mainBasiliskAddress : this.props.Dashboard.activeHandle[coin]; Store.dispatch(iguanaActiveHandle(true)); diff --git a/react/src/components/dashboard/sendCoin.js b/react/src/components/dashboard/sendCoin.js index 7851702..b698e60 100644 --- a/react/src/components/dashboard/sendCoin.js +++ b/react/src/components/dashboard/sendCoin.js @@ -6,7 +6,8 @@ import { sendNativeTx, getKMDOPID, resolveOpenAliasAddress, - triggerToaster + triggerToaster, + iguanaUTXORawTX } from '../../actions/actionCreators'; import Store from '../../store'; @@ -117,10 +118,24 @@ class SendCoin extends React.Component { } handleSubmit() { - Store.dispatch(sendNativeTx(this.props.ActiveCoin.coin, this.state)); - setTimeout(function() { + const utxoSet = this.props.ActiveCoin.cache[this.props.ActiveCoin.coin][this.state.sendFrom].refresh; + const sendData = { + 'coin': this.props.ActiveCoin.coin, + 'sendfrom': this.state.sendFrom, + 'sendtoaddr': this.state.sendTo, + 'amount': this.state.amount, + 'txfee': this.state.fee, + 'sendsig': this.state.sendSig === true ? 0 : 1, + 'utxos': utxoSet + }; + iguanaUTXORawTX(sendData) + .then(function(json) { + console.log(json); + }); + //Store.dispatch(sendNativeTx(this.props.ActiveCoin.coin, this.state)); + /*setTimeout(function() { Store.dispatch(getKMDOPID(null, this.props.ActiveCoin.coin)); - }, 1000); + }, 1000);*/ } renderSignedTx(signedtx) { diff --git a/react/src/config.js b/react/src/config.js index 0eb154b..ec47c42 100644 --- a/react/src/config.js +++ b/react/src/config.js @@ -5,4 +5,5 @@ module.exports = { enableCacheApi: true, useBasiliskInstance: true, openAlias: true, + debug: true, }; From 04c4fcd564c9c14fb776e2e4b30f5db9eae856f1 Mon Sep 17 00:00:00 2001 From: pbca26 Date: Sat, 29 Apr 2017 12:04:13 +0300 Subject: [PATCH 04/16] addr amount render fix; toggle send api type --- react/src/actions/actionCreators.js | 72 +++++++++++-- react/src/components/dashboard/sendCoin.js | 101 +++++++++++++++--- react/src/components/dashboard/walletsData.js | 15 ++- 3 files changed, 169 insertions(+), 19 deletions(-) diff --git a/react/src/actions/actionCreators.js b/react/src/actions/actionCreators.js index 1b3529c..7f99a85 100644 --- a/react/src/actions/actionCreators.js +++ b/react/src/actions/actionCreators.js @@ -978,7 +978,7 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { 'account': '*' }; } - console.log('pl', payload); + //console.log('pl', payload); if (sessionStorage.getItem('useCache') && mode === 'basilisk') { const pubkey = JSON.parse(sessionStorage.getItem('IguanaActiveAccount')).pubkey; @@ -1063,7 +1063,7 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { } function calcBalance(result, json, dispatch, mode) { - console.log('result', result); + //console.log('result', result); if (mode === 'full' || mode === 'basilisk') { result[0] = result[0].result; } else { @@ -1071,8 +1071,8 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { result[1] = result[1].result; } - console.log('calc result', result); - console.log('calc json', json); + //console.log('calc result', result); + //console.log('calc json', json); if (mode !== 'basilisk') { const allAddrArray = json.map(res => res.address).filter((x, i, a) => a.indexOf(x) == i); @@ -1112,8 +1112,8 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { } else { filteredArray = json.filter(res => res.address === result[a][b]).map(res => res.amount); } - console.log('filteredArray', filteredArray); - console.log('addr', result[a][b]); + //console.log('filteredArray', filteredArray); + //console.log('addr', result[a][b]); let sum = 0; @@ -1752,6 +1752,34 @@ export function sendToAddress(coin, _payload) { } } +export function sendFromAddress(coin, _payload) { + const payload = { + 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + 'coin': coin, + 'method': 'sendfrom', + 'params': [ + _payload.sendFrom, + _payload.sendTo, + _payload.amount, + 'EasyDEX', + 'EasyDEXTransaction' + ] + }; + + return dispatch => { + return fetch('http://127.0.0.1:' + Config.iguanaCorePort, { + method: 'POST', + body: JSON.stringify(payload), + }) + .catch(function(error) { + console.log(error); + dispatch(triggerToaster(true, 'sendFromAddress', 'Error', 'error')); + }) + .then(response => response.json()) + .then(json => dispatch(sendToAddressState(json, dispatch))) + } +} + function checkAddressBasiliskHandle(json) { if (json && json.error) { return dispatch => { @@ -2116,6 +2144,38 @@ export function connectNotaries() { } } +export function iguanaUTXORawTX(data) { + const payload = { + 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + 'symbol': data.coin, + 'agent': 'basilisk', + 'method': 'utxorawtx', + 'vals': { + 'timelock': 0, + 'changeaddr': data.sendfrom, + 'destaddr': data.sendtoaddr, + 'txfee': data.txfee, + 'amount': data.amount, + 'sendflag': data.sendsig + }, + 'utxos': data.utxos + }; + console.log('iguanaUTXORawTXExport', payload); + + return new Promise((resolve, reject) => { + fetch('http://127.0.0.1:' + Config.iguanaCorePort, { + method: 'POST', + body: JSON.stringify(payload), + }) + .catch(function(error) { + console.log(error); + dispatch(triggerToaster(true, 'iguanaUTXORawTX', 'Error', 'error')); + }) + .then(response => response.json()) + .then(json => resolve(json)) + }); +} + /*function Shepherd_SendPendValue() { Shepherd_SysInfo().then(function(result){ var ram_data = formatBytes(result.totalmem_bytes) diff --git a/react/src/components/dashboard/sendCoin.js b/react/src/components/dashboard/sendCoin.js index b698e60..555c90d 100644 --- a/react/src/components/dashboard/sendCoin.js +++ b/react/src/components/dashboard/sendCoin.js @@ -3,6 +3,7 @@ import Config from '../../config'; import { translate } from '../../translate/translate'; import { sendToAddress, + sendFromAddress, sendNativeTx, getKMDOPID, resolveOpenAliasAddress, @@ -26,22 +27,47 @@ class SendCoin extends React.Component { amount: 0, fee: 0.0001, sendSig: false, + sendApiType: false, addressSelectorOpen: false, }; this.updateInput = this.updateInput.bind(this); - this.handleSubmit = this.handleSubmit.bind(this); + this.handleBasiliskSend = this.handleBasiliskSend.bind(this); this.openDropMenu = this.openDropMenu.bind(this); this.toggleSendSig = this.toggleSendSig.bind(this); this.getOAdress = this.getOAdress.bind(this); + this.toggleSendAPIType = this.toggleSendAPIType.bind(this); + } + + renderAddressAmount(address) { + if (this.props.ActiveCoin.addresses && this.props.ActiveCoin.addresses['public'] && this.props.ActiveCoin.addresses['public'].length) { + for (let i = 0; i < this.props.ActiveCoin.addresses['public'].length; i++) { + if (this.props.ActiveCoin.addresses['public'][i].address === address) { + return this.props.ActiveCoin.addresses['public'][i].amount; + } + } + } else { + return 0; + } } renderAddressByType(type) { if (this.props.ActiveCoin.addresses && this.props.ActiveCoin.addresses[type] && this.props.ActiveCoin.addresses[type].length) { - return this.props.ActiveCoin.addresses[type].map((address) => -
  • - this.updateAddressSelection(address.address, type, address.amount)}> [ {address.amount} {this.props.ActiveCoin.coin} ]  {address.address} -
  • - ); + if (this.state.sendApiType) { + const mainAddress = this.props.Dashboard.activeHandle[this.props.ActiveCoin.coin]; + const mainAddressAmount = this.renderAddressAmount(mainAddress); + + return( +
  • + this.updateAddressSelection(mainAddress, type, mainAddressAmount)}> [ {mainAddressAmount} {this.props.ActiveCoin.coin} ]  {mainAddress} +
  • + ); + } else { + return this.props.ActiveCoin.addresses[type].map((address) => +
  • + this.updateAddressSelection(address.address, type, address.amount)}> [ {address.amount} {this.props.ActiveCoin.coin} ]  {address.address} +
  • + ); + } } else { return null; } @@ -54,6 +80,16 @@ class SendCoin extends React.Component { [ {this.state.sendFromAmount} {this.props.ActiveCoin.coin} ]  {this.state.sendFrom} ); + } else if (this.state.sendApiType) { + const mainAddress = this.props.Dashboard.activeHandle[this.props.ActiveCoin.coin]; + const mainAddressAmount = this.renderAddressAmount(mainAddress); + + console.log('sendApiType', this.state.sendApiType); + return ( + + [ {mainAddressAmount} {this.props.ActiveCoin.coin} ]  {mainAddress} + + ); } else { return ( - Select Transparent or Private Address - @@ -89,7 +125,7 @@ class SendCoin extends React.Component { this.setState(Object.assign({}, this.state, { sendFrom: address, addressType: type, - sendFromAmount: amount, + sendFromAmount: amount ? amount : this.props.ActiveCoin.addresses[type][address].amount, addressSelectorOpen: !this.state.addressSelectorOpen, })); } @@ -100,7 +136,12 @@ class SendCoin extends React.Component { })); if (step === 2) { - Store.dispatch(sendToAddress(this.props.ActiveCoin.coin, this.state)); + if (!this.state.sendApiType) { + handleBasiliskSend(); + } else { + Store.dispatch(sendToAddress(this.props.ActiveCoin.coin, this.state)); + } + //Store.dispatch(sendFromAddress(this.props.ActiveCoin.coin, this.state)); } } @@ -110,14 +151,19 @@ class SendCoin extends React.Component { })); } + toggleSendAPIType() { + this.setState(Object.assign({}, this.state, { + sendApiType: !this.state.sendApiType, + })); + } + updateInput(e) { this.setState({ [e.target.name]: e.target.value, }); - console.log(this.state); } - handleSubmit() { + handleBasiliskSend() { const utxoSet = this.props.ActiveCoin.cache[this.props.ActiveCoin.coin][this.state.sendFrom].refresh; const sendData = { 'coin': this.props.ActiveCoin.coin, @@ -130,6 +176,19 @@ class SendCoin extends React.Component { }; iguanaUTXORawTX(sendData) .then(function(json) { + console.log('sendData', sendData); + console.log('iguanaUTXORawTXJSON', json); + if (json.result === 'success' && json.completed === true) { + Store.dispatch(triggerToaster(true, translate('TOASTR.SIGNED_TX_GENERATED') + '.', translate('TOASTR.WALLET_NOTIFICATION'))); + + if (sendData.sendsig === 1) { + Store.dispatch(triggerToaster(true, translate('TOASTR.SENDING_TX') + '.', translate('TOASTR.WALLET_NOTIFICATION'))); + ajax_data_dexrawtx = { + 'signedtx': json.signedtx, + 'coin': sendData.coin + }; + } + } console.log(json); }); //Store.dispatch(sendNativeTx(this.props.ActiveCoin.coin, this.state)); @@ -218,7 +277,7 @@ class SendCoin extends React.Component { } if (this.state.sendTo === '') { - Store.dispatch(triggerToaster(true, 'Couldn\'t find any ' + this.props.ActiveCoin.coin +' addresses', 'OpenAlias', 'error')); + Store.dispatch(triggerToaster(true, 'Couldn\'t find any ' + this.props.ActiveCoin.coin + ' addresses', 'OpenAlias', 'error')); } } else { Store.dispatch(triggerToaster(true, 'Couldn\'t find any addresses', 'OpenAlias', 'error')); @@ -231,7 +290,7 @@ class SendCoin extends React.Component { return (
    - +
    @@ -246,6 +305,23 @@ class SendCoin extends React.Component { } } + renderSendApiTypeSelector() { + if (this.props.ActiveCoin.mode === 'basilisk') { + return ( +
    +
    +
    + +
    + +
    +
    + ); + } else { + return null; + } + } + render() { if (this.props.ActiveCoin && this.props.ActiveCoin.send && this.props.ActiveCoin.mode !== 'native') { return ( @@ -283,6 +359,7 @@ class SendCoin extends React.Component {
    + {this.renderSendApiTypeSelector()}
    diff --git a/react/src/components/dashboard/walletsData.js b/react/src/components/dashboard/walletsData.js index fb623f5..1748f50 100644 --- a/react/src/components/dashboard/walletsData.js +++ b/react/src/components/dashboard/walletsData.js @@ -64,6 +64,7 @@ class WalletsData extends React.Component { toggleCacheApi() { const _useCache = !this.state.useCache; + console.log('useCache is set to', _useCache); sessionStorage.setItem('useCache', _useCache); this.setState(Object.assign({}, this.state, { @@ -353,11 +354,23 @@ class WalletsData extends React.Component { } } + renderAddressAmount() { + if (this.props.ActiveCoin.addresses['public'] && this.props.ActiveCoin.addresses['public'].length) { + for (let i = 0; i < this.props.ActiveCoin.addresses['public'].length; i++) { + if (this.props.ActiveCoin.addresses['public'][i].address === this.state.currentAddress) { + return this.props.ActiveCoin.addresses['public'][i].amount; + } + } + } else { + return 0; + } + } + renderSelectorCurrentLabel() { if (this.state.currentAddress) { return ( - [ {this.state.sendFromAmount} {this.props.ActiveCoin.coin} ]  {this.state.currentAddress} + [ {this.renderAddressAmount()} {this.props.ActiveCoin.coin} ]  {this.state.currentAddress} ); } else { From 2aa119596628a9ecf75534630ce2057158e84c8a Mon Sep 17 00:00:00 2001 From: pbca26 Date: Sat, 29 Apr 2017 13:05:27 +0300 Subject: [PATCH 05/16] save listunspent to cache file --- react/src/actions/actionCreators.js | 33 +++++++++++++++++-- .../src/components/dashboard/coinTileItem.js | 2 +- react/src/components/dashboard/sendCoin.js | 1 - 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/react/src/actions/actionCreators.js b/react/src/actions/actionCreators.js index 7f99a85..a0d17b7 100644 --- a/react/src/actions/actionCreators.js +++ b/react/src/actions/actionCreators.js @@ -1020,7 +1020,7 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'); var payload; - if (passthru_agent == 'iguana') { + if (passthru_agent === 'iguana') { payload = { 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), 'agent': passthru_agent, @@ -1149,12 +1149,12 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { }) .then(response => response.json()) .then(function(json) { + var updatedCache = Object.assign({}, json.result); json = json.result.basilisk; // if listunspent is not in cache file retrieve new copy // otherwise read from cache data - // TODO: save listunspent to cache file(?) if (json[coin][currentAddress].listunspent) { - calcBalance(result, json[coin][currentAddress].listunspent, dispatch, mode); + calcBalance(result, json[coin][currentAddress].listunspent.data, dispatch, mode); } else { fetch('http://127.0.0.1:' + (Config.useBasiliskInstance && mode === 'basilisk' ? Config.basiliskPort : Config.iguanaCorePort), { method: 'POST', @@ -1166,6 +1166,12 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { }) .then(response => response.json()) .then(function(json) { + updatedCache.basilisk[coin][currentAddress].listunspent = { + 'data': json, + 'status': 'done', + 'timestamp': Date.now(), + }; + dispatch(shepherdGroomPost(pubkey, updatedCache)); calcBalance(result, json, dispatch, mode); }) } @@ -1188,6 +1194,27 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { } } +export function shepherdGroomPost(_filename, _payload) { + return dispatch => { + return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/groom/', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + 'filename': _filename, + 'payload': JSON.stringify(_payload), + }), + }) + .catch(function(error) { + console.log(error); + dispatch(triggerToaster(true, 'shepherdGroomPost', 'Error', 'error')); + }) + .then(response => response.json()) + .then(json => console.log(json)) + } +} + export function fetchUtxoCache(_payload) { const _userpass = '?userpass=tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), _pubkey = '&pubkey=' + _payload.pubkey, diff --git a/react/src/components/dashboard/coinTileItem.js b/react/src/components/dashboard/coinTileItem.js index 0d1cc26..9b440ec 100644 --- a/react/src/components/dashboard/coinTileItem.js +++ b/react/src/components/dashboard/coinTileItem.js @@ -56,7 +56,7 @@ class CoinTileItem extends React.Component { Store.dispatch(getShepherdCache(this.props.Dashboard.activeHandle.pubkey)); Store.dispatch(getBasiliskTransactionsList(coin, useAddress)); Store.dispatch(getKMDAddressesNative(coin, mode, useAddress)); - Store.dispatch(iguanaEdexBalance(coin, mode)); + //Store.dispatch(iguanaEdexBalance(coin, mode)); } } } diff --git a/react/src/components/dashboard/sendCoin.js b/react/src/components/dashboard/sendCoin.js index 555c90d..70deabf 100644 --- a/react/src/components/dashboard/sendCoin.js +++ b/react/src/components/dashboard/sendCoin.js @@ -84,7 +84,6 @@ class SendCoin extends React.Component { const mainAddress = this.props.Dashboard.activeHandle[this.props.ActiveCoin.coin]; const mainAddressAmount = this.renderAddressAmount(mainAddress); - console.log('sendApiType', this.state.sendApiType); return ( [ {mainAddressAmount} {this.props.ActiveCoin.coin} ]  {mainAddress} From 42ed745a7b7d750c4327e8058b704195752c2d94 Mon Sep 17 00:00:00 2001 From: pbca26 Date: Sat, 29 Apr 2017 14:03:04 +0300 Subject: [PATCH 06/16] navigate to pg 1 on addr change --- react/src/components/dashboard/walletsData.js | 1 + 1 file changed, 1 insertion(+) diff --git a/react/src/components/dashboard/walletsData.js b/react/src/components/dashboard/walletsData.js index 1748f50..915d1b2 100644 --- a/react/src/components/dashboard/walletsData.js +++ b/react/src/components/dashboard/walletsData.js @@ -324,6 +324,7 @@ class WalletsData extends React.Component { this.setState(Object.assign({}, this.state, { currentAddress: address, addressSelectorOpen: false, + activePage: 1, })); setTimeout(function() { From a9a9a27a126dce1c8fe9f0e54a00b7882ba24444 Mon Sep 17 00:00:00 2001 From: pbca26 Date: Sat, 29 Apr 2017 18:09:43 +0300 Subject: [PATCH 07/16] fixed typo in walletsdata comp --- react/src/components/dashboard/walletsData.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/react/src/components/dashboard/walletsData.js b/react/src/components/dashboard/walletsData.js index 915d1b2..473c252 100644 --- a/react/src/components/dashboard/walletsData.js +++ b/react/src/components/dashboard/walletsData.js @@ -445,7 +445,7 @@ class WalletsData extends React.Component {
  • - + {translate('INDEX.FETCH_WALLET_DATA')}
  • @@ -459,6 +459,11 @@ class WalletsData extends React.Component { Update UTXO +
  • + + Fetch all + +
  • Restart Basilisk Instance From 09f024175ea64e3d790a284ebdb2f33c9a911d8a Mon Sep 17 00:00:00 2001 From: pbca26 Date: Sat, 29 Apr 2017 18:10:07 +0300 Subject: [PATCH 08/16] added immediate and timeout to iguana calls --- react/src/actions/actionCreators.js | 170 +++++++++++++++++++++------- 1 file changed, 129 insertions(+), 41 deletions(-) diff --git a/react/src/actions/actionCreators.js b/react/src/actions/actionCreators.js index a0d17b7..2f0caf8 100644 --- a/react/src/actions/actionCreators.js +++ b/react/src/actions/actionCreators.js @@ -504,6 +504,8 @@ export function getDexCoins() { 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), 'agent': 'InstantDEX', 'method': 'allcoins', + 'immediate': 60000, + 'timeout': 60000 }) }) .catch(function(error) { @@ -534,7 +536,8 @@ export function iguanaWalletPassphrase(_passphrase) { 'password': _passphrase, 'timeout': '2592000', 'agent': 'bitcoinrpc', - 'method': 'walletpassphrase' + 'method': 'walletpassphrase', + 'immediate': 60000, }), }) .catch(function(error) { @@ -553,7 +556,9 @@ export function iguanaActiveHandle(getMainAddress) { body: JSON.stringify({ 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), 'agent': 'SuperNET', - 'method': 'activehandle' + 'method': 'activehandle', + 'immediate': 60000, + 'timeout': 60000 }), }) .catch(function(error) { @@ -573,7 +578,9 @@ export function iguanaEdexBalance(coin) { 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), 'agent': 'bitcoinrpc', 'method': 'getbalance', - 'coin': coin + 'coin': coin, + 'immediate': 60000, + 'timeout': 60000 }), }) .catch(function(error) { @@ -613,7 +620,9 @@ export function encryptWallet(_passphrase, cb, coin) { 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), 'agent': 'bitcoinrpc', 'method': 'encryptwallet', - 'passphrase': _passphrase + 'passphrase': _passphrase, + 'immediate': 60000, + 'timeout': 60000 }; return dispatch => { @@ -637,7 +646,8 @@ export function walletPassphrase(_passphrase) { 'agent': 'bitcoinrpc', 'method': 'walletpassphrase', 'password': _passphrase, - 'timeout': '2592000' + 'timeout': '2592000', + 'immediate': 60000, }; return dispatch => { @@ -685,7 +695,9 @@ export function getFullTransactionsList(coin) { 0, 9999999, [] - ] + ], + 'immediate': 60000, + 'timeout': 60000 }; return dispatch => { @@ -710,7 +722,9 @@ export function getBasiliskTransactionsList(coin, address) { 'address': address, 'count': 100, 'skip': 0, - 'symbol': coin + 'symbol': coin, + 'immediate': 60000, + 'timeout': 60000 }; if (sessionStorage.getItem('useCache')) { @@ -757,6 +771,8 @@ export function getPeersList(coin) { 'agent': 'SuperNET', 'method': 'getpeers', 'activecoin': coin, + 'immediate': 60000, + 'timeout': 60000 }; return dispatch => { @@ -802,7 +818,9 @@ export function addPeerNode(coin, ip) { 'agent': 'iguana', 'method': 'addnode', 'activecoin': coin, - 'ipaddr': ip + 'ipaddr': ip, + 'immediate': 60000, + 'timeout': 60000 }; return dispatch => { @@ -836,7 +854,9 @@ export function getAddressesByAccount(coin, mode) { 'coin': coin, 'agent': 'bitcoinrpc', 'method': 'getaddressesbyaccount', - 'account': '*' + 'account': '*', + 'immediate': 60000, + 'timeout': 60000 }; return dispatch => { @@ -891,8 +911,8 @@ export function getSyncInfo(coin) { 'coin': coin, 'agent': 'bitcoinrpc', 'method': 'getinfo', - 'immediate': 100, - 'timeout': 4000 + 'immediate': 60000, + 'timeout': 60000 }; return dispatch => { @@ -957,7 +977,9 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { 'method': 'passthru', 'asset': coin, 'function': ajax_function_input, - 'hex': tmplistaddr_hex_input + 'hex': tmplistaddr_hex_input, + 'immediate': 60000, + 'timeout': 60000 }; } else { payload = { @@ -965,7 +987,9 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { 'agent': passthru_agent, 'method': 'passthru', 'function': ajax_function_input, - 'hex': tmplistaddr_hex_input + 'hex': tmplistaddr_hex_input, + 'immediate': 60000, + 'timeout': 60000 }; } @@ -975,7 +999,9 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { 'coin': coin, 'agent': 'bitcoinrpc', 'method': 'getaddressesbyaccount', - 'account': '*' + 'account': '*', + 'immediate': 60000, + 'timeout': 60000 }; } //console.log('pl', payload); @@ -1027,7 +1053,9 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { 'method': 'passthru', 'asset': coin, 'function': 'listunspent', - 'hex': '' + 'hex': '', + 'immediate': 60000, + 'timeout': 60000 }; } else { payload = { @@ -1035,7 +1063,9 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { 'agent': passthru_agent, 'method': 'passthru', 'function': 'listunspent', - 'hex': '' + 'hex': '', + 'immediate': 60000, + 'timeout': 60000 }; } @@ -1047,7 +1077,9 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { 'params': [ 1, 9999999, - ] + ], + 'immediate': 60000, + 'timeout': 60000 }; } @@ -1058,7 +1090,9 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { 'agent': 'dex', 'method': 'listunspent', 'address': currentAddress, - 'symbol': coin + 'symbol': coin, + 'immediate': 60000, + 'timeout': 60000 }; } @@ -1321,7 +1355,9 @@ export function importPrivKey(wifKey) { 'params': [ wifKey, 'imported' - ] + ], + 'immediate': 60000, + 'timeout': 60000 }; return dispatch => { @@ -1407,7 +1443,9 @@ export function getSyncInfoNative(coin) { 'method': 'passthru', 'asset': coin, 'function': 'getinfo', - 'hex': '' + 'hex': '', + 'immediate': 60000, + 'timeout': 60000 }; return dispatch => { @@ -1431,7 +1469,9 @@ export function getDexBalance(coin, addr) { 'agent': 'dex', 'method': 'listunspent', 'address': _addr, - 'symbol': coin + 'symbol': coin, + 'immediate': 60000, + 'timeout': 60000 }; console.log('addr', _addr); return new Promise((resolve, reject) => { @@ -1465,7 +1505,9 @@ export function getKMDBalanceTotal(coin) { 'method': 'passthru', 'asset': coin, 'function': 'z_gettotalbalance', - 'hex': '3000' + 'hex': '3000', + 'immediate': 60000, + 'timeout': 60000 }; } else { payload = { @@ -1473,7 +1515,9 @@ export function getKMDBalanceTotal(coin) { 'agent': getPassthruAgent(coin), 'method': 'passthru', 'function': 'z_gettotalbalance', - 'hex': '3000' + 'hex': '3000', + 'immediate': 60000, + 'timeout': 60000 }; } @@ -1512,7 +1556,9 @@ export function getNativeTxHistory(coin) { 'method': 'passthru', 'asset': coin, 'function': 'listtransactions', - 'hex': '' + 'hex': '', + 'immediate': 60000, + 'timeout': 60000 }; } else { payload = { @@ -1520,7 +1566,9 @@ export function getNativeTxHistory(coin) { 'agent': getPassthruAgent(coin), 'method': 'passthru', 'function': 'listtransactions', - 'hex': '' + 'hex': '', + 'immediate': 60000, + 'timeout': 60000 }; } @@ -1578,7 +1626,9 @@ export function getNewKMDAddresses(coin, pubpriv) { 'method': 'passthru', 'asset': coin, 'function': ajax_function_input, - 'hex': '' + 'hex': '', + 'immediate': 60000, + 'timeout': 60000 }; } else { payload = { @@ -1586,7 +1636,9 @@ export function getNewKMDAddresses(coin, pubpriv) { 'agent': coin, 'method': 'passthru', 'function': ajax_function_input, - 'hex': '' + 'hex': '', + 'immediate': 60000, + 'timeout': 60000 }; } @@ -1612,7 +1664,9 @@ export function iguanaHashHex(data) { 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), 'agent': 'hash', 'method': 'hex', - 'message': data + 'message': data, + 'immediate': 60000, + 'timeout': 60000 }; return new Promise((resolve, reject) => { @@ -1644,7 +1698,9 @@ export function sendNativeTx(coin, _payload) { 'method': 'passthru', 'asset': coin, 'function': 'z_sendmany', - 'hex': hashHexJson + 'hex': hashHexJson, + 'immediate': 60000, + 'timeout': 60000 }; } else { payload = { @@ -1652,7 +1708,9 @@ export function sendNativeTx(coin, _payload) { 'agent': getPassthruAgent(coin), 'method': 'passthru', 'function': 'z_sendmany', - 'hex': hashHexJson + 'hex': hashHexJson, + 'immediate': 60000, + 'timeout': 60000 }; } @@ -1708,7 +1766,9 @@ export function getKMDOPID(opid, coin) { 'method': 'passthru', 'asset': coin, 'function': 'z_getoperationstatus', - 'hex': hashHexJson + 'hex': hashHexJson, + 'immediate': 60000, + 'timeout': 60000 }; } else { payload = { @@ -1716,7 +1776,9 @@ export function getKMDOPID(opid, coin) { 'agent': passthru_agent, 'method': 'passthru', 'function': 'z_getoperationstatus', - 'hex': hashHexJson + 'hex': hashHexJson, + 'immediate': 60000, + 'timeout': 60000 }; } @@ -1752,6 +1814,13 @@ function sendToAddressState(json, dispatch) { } } +export function clearLastSendToResponseState() { + return { + type: DASHBOARD_ACTIVE_COIN_SENDTO, + lastSendToResponse: null, + } +} + export function sendToAddress(coin, _payload) { const payload = { 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), @@ -1762,7 +1831,9 @@ export function sendToAddress(coin, _payload) { _payload.amount, 'EasyDEX', 'EasyDEXTransaction' - ] + ], + 'immediate': 60000, + 'timeout': 60000 }; return dispatch => { @@ -1790,7 +1861,9 @@ export function sendFromAddress(coin, _payload) { _payload.amount, 'EasyDEX', 'EasyDEXTransaction' - ] + ], + 'immediate': 60000, + 'timeout': 60000 }; return dispatch => { @@ -1827,7 +1900,9 @@ export function checkAddressBasilisk(coin, address) { 'agent': 'dex', 'method': 'checkaddress', 'address': address, - 'symbol': coin + 'symbol': coin, + 'immediate': 60000, + 'timeout': 60000 }; return dispatch => { @@ -1867,7 +1942,9 @@ export function validateAddressBasilisk(coin, address) { 'agent': 'dex', 'method': 'validateaddress', 'address': address, - 'symbol': coin + 'symbol': coin, + 'immediate': 60000, + 'timeout': 60000 }; return dispatch => { @@ -1902,7 +1979,9 @@ export function getDexNotaries(coin) { 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), 'agent': 'dex', 'method': 'getnotaries', - 'symbol': coin + 'symbol': coin, + 'immediate': 60000, + 'timeout': 60000 }; return dispatch => { @@ -1936,7 +2015,9 @@ export function createNewWallet(_passphrase) { 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), 'agent': 'bitcoinrpc', 'method': 'encryptwallet', - 'passphrase': _passphrase + 'passphrase': _passphrase, + 'immediate': 60000, + 'timeout': 60000 }; return dispatch => { @@ -1972,6 +2053,7 @@ export function deleteCacheFile(_payload) { } export function fetchNewCacheData(_payload) { + console.log('fetchNewCacheData', true); const _userpass = '?userpass=tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), _pubkey = '&pubkey=' + _payload.pubkey, _route = _payload.allcoins ? 'cache-all' : 'cache-one', @@ -2002,7 +2084,9 @@ function initNotaryNodesConSequence(nodes) { 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), 'agent': 'dex', 'method': 'getinfo', - 'symbol': node + 'symbol': node, + 'immediate': 60000, + 'timeout': 60000 }; return new Promise((resolve, reject) => { @@ -2154,7 +2238,9 @@ export function connectNotaries() { const payload = { 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), 'agent': 'dpow', - 'method': 'notarychains' + 'method': 'notarychains,', + 'immediate': 60000, + 'timeout': 60000 }; return dispatch => { @@ -2185,7 +2271,9 @@ export function iguanaUTXORawTX(data) { 'amount': data.amount, 'sendflag': data.sendsig }, - 'utxos': data.utxos + 'utxos': data.utxos, + 'immediate': 60000, + 'timeout': 60000 }; console.log('iguanaUTXORawTXExport', payload); From d71f956c5e0b00bdc9ee476ec293f7c48ef0f258 Mon Sep 17 00:00:00 2001 From: pbca26 Date: Sun, 30 Apr 2017 10:54:08 +0300 Subject: [PATCH 09/16] minor basilisk update --- react/src/actions/actionCreators.js | 4 +++- .../src/components/dashboard/coinTileItem.js | 3 ++- react/src/components/dashboard/sendCoin.js | 9 ++++++-- react/src/components/dashboard/walletsData.js | 22 ++++++++++++++----- 4 files changed, 28 insertions(+), 10 deletions(-) diff --git a/react/src/actions/actionCreators.js b/react/src/actions/actionCreators.js index 2f0caf8..81c7ef9 100644 --- a/react/src/actions/actionCreators.js +++ b/react/src/actions/actionCreators.js @@ -838,13 +838,15 @@ export function addPeerNode(coin, ip) { } export function getAddressesByAccountState(json, coin, mode) { + json = json.result.map(res => Object.assign({}, res, { 'address': res })); + console.log('getAddressesByAccountState', json); if (mode === 'basilisk') { getDexBalance(coin, mode, json.result); } return { type: ACTIVE_COIN_GET_ADDRESSES, - addresses: json.result, + addresses: { 'public': json.result }, } } diff --git a/react/src/components/dashboard/coinTileItem.js b/react/src/components/dashboard/coinTileItem.js index 9b440ec..a4ceea9 100644 --- a/react/src/components/dashboard/coinTileItem.js +++ b/react/src/components/dashboard/coinTileItem.js @@ -45,7 +45,7 @@ class CoinTileItem extends React.Component { Store.dispatch(iguanaActiveHandle(true)); Store.dispatch(getSyncInfo(coin)); Store.dispatch(iguanaEdexBalance(coin, mode)); - Store.dispatch(getKMDAddressesNative(coin, mode)); //getAddressesByAccount(coin)); + Store.dispatch(getAddressesByAccount(coin, mode)); Store.dispatch(getFullTransactionsList(coin)); } if (mode === 'basilisk') { @@ -68,6 +68,7 @@ class CoinTileItem extends React.Component { Store.dispatch(dashboardChangeActiveCoin(coin, mode)); this.dispatchCoinActions(coin, mode); + if (mode === 'full') { var _iguanaActiveHandle = setInterval(function() { this.dispatchCoinActions(coin, mode); diff --git a/react/src/components/dashboard/sendCoin.js b/react/src/components/dashboard/sendCoin.js index 70deabf..ef4d56a 100644 --- a/react/src/components/dashboard/sendCoin.js +++ b/react/src/components/dashboard/sendCoin.js @@ -8,7 +8,8 @@ import { getKMDOPID, resolveOpenAliasAddress, triggerToaster, - iguanaUTXORawTX + iguanaUTXORawTX, + clearLastSendToResponseState } from '../../actions/actionCreators'; import Store from '../../store'; @@ -130,6 +131,8 @@ class SendCoin extends React.Component { } changeSendCoinStep(step) { + Store.dispatch(clearLastSendToResponseState()); + this.setState(Object.assign({}, this.state, { currentStep: step, })); @@ -253,7 +256,9 @@ class SendCoin extends React.Component { ); } else { - return null; + return ( + Processing transaction... + ); } } diff --git a/react/src/components/dashboard/walletsData.js b/react/src/components/dashboard/walletsData.js index 473c252..463201b 100644 --- a/react/src/components/dashboard/walletsData.js +++ b/react/src/components/dashboard/walletsData.js @@ -343,6 +343,21 @@ class WalletsData extends React.Component { })); } + renderUseCacheToggle() { + if (this.props.ActiveCoin.mode === 'basilisk') { + return ( +
    +
    + +
    + +
    + ); + } else { + return null; + } + } + renderAddressByType(type) { if (this.props.ActiveCoin.addresses && this.props.ActiveCoin.addresses[type] && this.props.ActiveCoin.addresses[type].length) { return this.props.ActiveCoin.addresses[type].map((address) => @@ -484,12 +499,7 @@ class WalletsData extends React.Component {
    {this.renderAddressList()}
    -
    -
    - -
    - -
    + {this.renderUseCacheToggle}
  • From cee45689441e03d9331336b78224cb591ed2ee71 Mon Sep 17 00:00:00 2001 From: pbca26 Date: Sun, 30 Apr 2017 12:07:14 +0300 Subject: [PATCH 10/16] full mode get addr fix --- react/src/actions/actionCreators.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/react/src/actions/actionCreators.js b/react/src/actions/actionCreators.js index 81c7ef9..859fb50 100644 --- a/react/src/actions/actionCreators.js +++ b/react/src/actions/actionCreators.js @@ -305,6 +305,10 @@ export function dismissToasterMessage() { export function addCoin(coin, mode) { console.log('coin, mode', coin + ' ' + mode); + startIguanaInstance(mode, coin) + .then(function(json) { + console.log('addCoin+startIguanaInstance', json); + }); if (mode === '-1') { return dispatch => { dispatch(shepherdGetConfig(coin, mode)); @@ -838,8 +842,19 @@ export function addPeerNode(coin, ip) { } export function getAddressesByAccountState(json, coin, mode) { - json = json.result.map(res => Object.assign({}, res, { 'address': res })); - console.log('getAddressesByAccountState', json); + if (mode === 'full') { + let publicAddressArray = []; + + for (let i = 0; i < json.result.length; i++) { + publicAddressArray.push({ + 'address': json.result[i], + 'amount': 'N/A' + }); + } + + json.result = publicAddressArray; + } + if (mode === 'basilisk') { getDexBalance(coin, mode, json.result); } From 167572feb8a8b19f929d3452388a8282b3a3e4d3 Mon Sep 17 00:00:00 2001 From: pbca26 Date: Sun, 30 Apr 2017 12:43:51 +0300 Subject: [PATCH 11/16] sort desc tx history --- react/src/components/dashboard/walletsData.js | 7 ++++--- react/src/components/dashboard/walletsNativeTxHistory.js | 7 ++++--- react/src/util/sort.js | 5 +++++ 3 files changed, 13 insertions(+), 6 deletions(-) create mode 100644 react/src/util/sort.js diff --git a/react/src/components/dashboard/walletsData.js b/react/src/components/dashboard/walletsData.js index 463201b..e8f51cf 100644 --- a/react/src/components/dashboard/walletsData.js +++ b/react/src/components/dashboard/walletsData.js @@ -2,6 +2,7 @@ import React from 'react'; import Config from '../../config'; import { translate } from '../../translate/translate'; import { secondsToString } from '../../util/time'; +import { sortByDate } from '../../util/sort'; import { basiliskRefresh, basiliskConnection, @@ -156,7 +157,7 @@ class WalletsData extends React.Component { this.setState({ [e.target.name]: e.target.value, activePage: 1, - itemsList: historyToSplit, + itemsList: sortByDate(historyToSplit), }); } @@ -171,7 +172,7 @@ class WalletsData extends React.Component { historyToSplit = historyToSplit.slice((this.state.activePage - 1) * this.state.itemsPerPage, this.state.activePage * this.state.itemsPerPage); this.setState(Object.assign({}, this.state, { - itemsList: historyToSplit, + itemsList: sortByDate(historyToSplit), })); } } @@ -189,7 +190,7 @@ class WalletsData extends React.Component { this.setState(Object.assign({}, this.state, { activePage: page, - itemsList: historyToSplit, + itemsList: sortByDate(historyToSplit), })); } diff --git a/react/src/components/dashboard/walletsNativeTxHistory.js b/react/src/components/dashboard/walletsNativeTxHistory.js index f90e2a6..b867dd8 100644 --- a/react/src/components/dashboard/walletsNativeTxHistory.js +++ b/react/src/components/dashboard/walletsNativeTxHistory.js @@ -1,6 +1,7 @@ import React from 'react'; import { translate } from '../../translate/translate'; import { secondsToString } from '../../util/time'; +import { sortByDate } from '../../util/sort'; import { toggleDashboardTxInfoModal } from '../../actions/actionCreators'; import Store from '../../store'; @@ -31,7 +32,7 @@ class WalletsNativeTxHistory extends React.Component { this.setState({ [e.target.name]: e.target.value, activePage: 1, - itemsList: historyToSplit, + itemsList: sortByDate(historyToSplit), }); } @@ -85,7 +86,7 @@ class WalletsNativeTxHistory extends React.Component { historyToSplit = historyToSplit.slice((this.state.activePage - 1) * this.state.itemsPerPage, this.state.activePage * this.state.itemsPerPage); this.setState(Object.assign({}, this.state, { - itemsList: historyToSplit, + itemsList: sortByDate(historyToSplit), })); } } @@ -97,7 +98,7 @@ class WalletsNativeTxHistory extends React.Component { this.setState(Object.assign({}, this.state, { activePage: page, - itemsList: historyToSplit, + itemsList: sortByDate(historyToSplit), })); } diff --git a/react/src/util/sort.js b/react/src/util/sort.js new file mode 100644 index 0000000..dd0fff5 --- /dev/null +++ b/react/src/util/sort.js @@ -0,0 +1,5 @@ +export function sortByDate(data) { + return data.sort(function(a, b){ + return new Date(b.blocktime || b.timestamp) - new Date(a.blocktime || a.timestamp); + }); +} \ No newline at end of file From fcde5b528c515858dbc6d8c3f8ed9f63a37eee40 Mon Sep 17 00:00:00 2001 From: pbca26 Date: Sun, 30 Apr 2017 12:50:43 +0300 Subject: [PATCH 12/16] sort desc tx history fix --- react/src/components/dashboard/walletsData.js | 12 ++++++------ .../components/dashboard/walletsNativeTxHistory.js | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/react/src/components/dashboard/walletsData.js b/react/src/components/dashboard/walletsData.js index e8f51cf..171f87b 100644 --- a/react/src/components/dashboard/walletsData.js +++ b/react/src/components/dashboard/walletsData.js @@ -151,13 +151,13 @@ class WalletsData extends React.Component { } updateInput(e) { - let historyToSplit = this.props.ActiveCoin.txhistory; + let historyToSplit = sortByDate(this.props.ActiveCoin.txhistory); historyToSplit = historyToSplit.slice(0, e.target.value); this.setState({ [e.target.name]: e.target.value, activePage: 1, - itemsList: sortByDate(historyToSplit), + itemsList: historyToSplit, }); } @@ -168,11 +168,11 @@ class WalletsData extends React.Component { componentWillReceiveProps(props) { if (this.props.ActiveCoin.txhistory && this.props.ActiveCoin.txhistory.length) { if (!this.state.itemsList || (this.state.itemsList && !this.state.itemsList.length) || (props.ActiveCoin.txhistory !== this.props.ActiveCoin.txhistory)) { - let historyToSplit = this.props.ActiveCoin.txhistory; + let historyToSplit = sortByDate(this.props.ActiveCoin.txhistory); historyToSplit = historyToSplit.slice((this.state.activePage - 1) * this.state.itemsPerPage, this.state.activePage * this.state.itemsPerPage); this.setState(Object.assign({}, this.state, { - itemsList: sortByDate(historyToSplit), + itemsList: historyToSplit, })); } } @@ -185,12 +185,12 @@ class WalletsData extends React.Component { } updateCurrentPage(page) { - let historyToSplit = this.props.ActiveCoin.txhistory; + let historyToSplit = sortByDate(this.props.ActiveCoin.txhistory); historyToSplit = historyToSplit.slice((page - 1) * this.state.itemsPerPage, page * this.state.itemsPerPage); this.setState(Object.assign({}, this.state, { activePage: page, - itemsList: sortByDate(historyToSplit), + itemsList: historyToSplit, })); } diff --git a/react/src/components/dashboard/walletsNativeTxHistory.js b/react/src/components/dashboard/walletsNativeTxHistory.js index b867dd8..9efd521 100644 --- a/react/src/components/dashboard/walletsNativeTxHistory.js +++ b/react/src/components/dashboard/walletsNativeTxHistory.js @@ -26,13 +26,13 @@ class WalletsNativeTxHistory extends React.Component { } updateInput(e) { - let historyToSplit = this.props.ActiveCoin.txhistory; + let historyToSplit = sortByDate(this.props.ActiveCoin.txhistory); historyToSplit = historyToSplit.slice(0, e.target.value); this.setState({ [e.target.name]: e.target.value, activePage: 1, - itemsList: sortByDate(historyToSplit), + itemsList: historyToSplit, }); } @@ -82,23 +82,23 @@ class WalletsNativeTxHistory extends React.Component { componentWillReceiveProps(props) { if (!this.state.itemsList || (this.state.itemsList && !this.state.itemsList.length) || (props.ActiveCoin.txhistory !== this.props.ActiveCoin.txhistory)) { if (this.props.ActiveCoin.txhistory) { - let historyToSplit = this.props.ActiveCoin.txhistory; + let historyToSplit = sortByDate(this.props.ActiveCoin.txhistory); historyToSplit = historyToSplit.slice((this.state.activePage - 1) * this.state.itemsPerPage, this.state.activePage * this.state.itemsPerPage); this.setState(Object.assign({}, this.state, { - itemsList: sortByDate(historyToSplit), + itemsList: historyToSplit, })); } } } updateCurrentPage(page) { - let historyToSplit = this.props.ActiveCoin.txhistory; + let historyToSplit = sortByDate(this.props.ActiveCoin.txhistory); historyToSplit = historyToSplit.slice((page - 1) * this.state.itemsPerPage, page * this.state.itemsPerPage); this.setState(Object.assign({}, this.state, { activePage: page, - itemsList: sortByDate(historyToSplit), + itemsList: historyToSplit, })); } From 5f1bb0c6c02da940a0f525b7506707279dcce81b Mon Sep 17 00:00:00 2001 From: pbca26 Date: Sun, 30 Apr 2017 14:41:05 +0300 Subject: [PATCH 13/16] pagination btn next fix --- react/src/components/dashboard/walletsData.js | 2 +- react/src/components/dashboard/walletsNativeTxHistory.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/react/src/components/dashboard/walletsData.js b/react/src/components/dashboard/walletsData.js index 171f87b..20e3a31 100644 --- a/react/src/components/dashboard/walletsData.js +++ b/react/src/components/dashboard/walletsData.js @@ -243,7 +243,7 @@ class WalletsData extends React.Component { this.updateCurrentPage(this.state.activePage - 1)}>Previous {this.renderPaginationItems()} -
  • +
  • Math.floor(this.props.ActiveCoin.txhistory.length / this.state.itemsPerPage) ? 'paginate_button next disabled' : 'paginate_button next'} id="kmd-tx-history-tbl_next"> this.updateCurrentPage(this.state.activePage + 1)}>Next
  • diff --git a/react/src/components/dashboard/walletsNativeTxHistory.js b/react/src/components/dashboard/walletsNativeTxHistory.js index 9efd521..e58bffc 100644 --- a/react/src/components/dashboard/walletsNativeTxHistory.js +++ b/react/src/components/dashboard/walletsNativeTxHistory.js @@ -151,7 +151,7 @@ class WalletsNativeTxHistory extends React.Component { this.updateCurrentPage(this.state.activePage - 1)}>Previous {this.renderPaginationItems()} -
  • +
  • Math.floor(this.props.ActiveCoin.txhistory.length / this.state.itemsPerPage) ? 'paginate_button next disabled' : 'paginate_button next'} id="kmd-tx-history-tbl_next"> this.updateCurrentPage(this.state.activePage + 1)}>Next
  • From 4cadf0d363bc8e3a91d63486c8d21e3e5843a51b Mon Sep 17 00:00:00 2001 From: pbca26 Date: Sun, 30 Apr 2017 15:55:16 +0300 Subject: [PATCH 14/16] native addr list fix --- react/src/actions/actionCreators.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/react/src/actions/actionCreators.js b/react/src/actions/actionCreators.js index 859fb50..4d062f3 100644 --- a/react/src/actions/actionCreators.js +++ b/react/src/actions/actionCreators.js @@ -48,6 +48,8 @@ export const DASHBOARD_DISPLAY_NOTARIES_MODAL = 'DASHBOARD_DISPLAY_NOTARIES_MODA export const DASHBOARD_CONNECT_NOTARIES = 'DASHBOARD_CONNECT_NOTARIES'; export const VIEW_CACHE_DATA = 'VIEW_CACHE_DATA'; +var iguanaForks = {}; // forks in mem array + export function toggleViewCacheModal(display) { return { type: VIEW_CACHE_DATA, @@ -305,10 +307,10 @@ export function dismissToasterMessage() { export function addCoin(coin, mode) { console.log('coin, mode', coin + ' ' + mode); - startIguanaInstance(mode, coin) + /*startIguanaInstance(mode, coin) .then(function(json) { console.log('addCoin+startIguanaInstance', json); - }); + });*/ if (mode === '-1') { return dispatch => { dispatch(shepherdGetConfig(coin, mode)); @@ -1010,7 +1012,7 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { }; } - if (mode === 'native' || mode === 'basilisk') { + if (mode === 'full' || mode === 'basilisk') { payload = { 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), 'coin': coin, @@ -1021,7 +1023,6 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { 'timeout': 60000 }; } - //console.log('pl', payload); if (sessionStorage.getItem('useCache') && mode === 'basilisk') { const pubkey = JSON.parse(sessionStorage.getItem('IguanaActiveAccount')).pubkey; @@ -1117,9 +1118,6 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { //console.log('result', result); if (mode === 'full' || mode === 'basilisk') { result[0] = result[0].result; - } else { - result[0] = result[0].result; - result[1] = result[1].result; } //console.log('calc result', result); From 3dd67513bd82acf7029d0a4234fefd23c5f33ca4 Mon Sep 17 00:00:00 2001 From: pbca26 Date: Sun, 30 Apr 2017 16:01:14 +0300 Subject: [PATCH 15/16] native addr list balances fix --- react/src/actions/actionCreators.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react/src/actions/actionCreators.js b/react/src/actions/actionCreators.js index 4d062f3..4e9f40b 100644 --- a/react/src/actions/actionCreators.js +++ b/react/src/actions/actionCreators.js @@ -1172,7 +1172,7 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { newAddressArray[a][b] = { address: result[a][b], - amount: currentAddress === result[a][b] ? sum : 'N/A', + amount: currentAddress === result[a][b] || mode === 'native' ? sum : 'N/A', }; } } From 035baeff3749cb9fb8f8c7c05937a2fa59bb9216 Mon Sep 17 00:00:00 2001 From: pbca26 Date: Sun, 30 Apr 2017 16:07:46 +0300 Subject: [PATCH 16/16] missing send basilisk condition --- react/src/components/dashboard/sendCoin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react/src/components/dashboard/sendCoin.js b/react/src/components/dashboard/sendCoin.js index ef4d56a..4ac7138 100644 --- a/react/src/components/dashboard/sendCoin.js +++ b/react/src/components/dashboard/sendCoin.js @@ -138,7 +138,7 @@ class SendCoin extends React.Component { })); if (step === 2) { - if (!this.state.sendApiType) { + if (!this.state.sendApiType && this.props.ActiveCoin.mode === 'basilisk') { handleBasiliskSend(); } else { Store.dispatch(sendToAddress(this.props.ActiveCoin.coin, this.state));