Browse Source

dex send raw tx

all-modes
Petr Balashov 8 years ago
parent
commit
6a9fdae00b
  1. 55
      react/src/actions/actionCreators.js
  2. 13
      react/src/components/addcoin/addcoin.js
  3. 42
      react/src/components/dashboard/sendCoin.js
  4. 15
      react/src/components/dashboard/walletsBalance.js

55
react/src/actions/actionCreators.js

@ -306,7 +306,7 @@ export function dismissToasterMessage() {
}
export function addCoin(coin, mode, syncOnly) {
console.log('coin, mode', coin + ' ' + mode);
console.log('coin, mode, syncOnly', coin + ' ' + mode + ' ' + syncOnly);
/*startIguanaInstance(mode, coin)
.then(function(json) {
console.log('addCoin+startIguanaInstance', json);
@ -317,27 +317,36 @@ export function addCoin(coin, mode, syncOnly) {
}
} else {
if (checkCoinType(coin) === 'currency_ac') {
var _acData = startCurrencyAssetChain('', coin, mode);
const _acData = startCurrencyAssetChain('', coin, mode);
return dispatch => {
dispatch(iguanaAddCoin(coin, mode, _acData));
}
}
if (checkCoinType(coin) === 'ac') {
var _acData = startAssetChain('', coin, mode);
const _acData = startAssetChain('', coin, mode);
return dispatch => {
dispatch(iguanaAddCoin(coin, mode, _acData));
}
}
if (checkCoinType(coin) === 'crypto') {
var _acData = startCrypto('', coin, mode);
const _acData = startCrypto('', coin, mode);
if (syncOnly) {
startIguanaInstance(mode + '/sync', coin)
.then(function(json) {
console.log('started ' + coin + ' / ' mode + ' fork', json);
return dispatch => {
const modeToValue = {
'1': 'full',
'0': 'basilisk',
'-1': 'native'
};
return dispatch => {
startIguanaInstance(modeToValue[mode] + '/sync', coin)
.then(function(json) {
console.log('started ' + coin + ' / ' + modeToValue[mode] + ' fork', json);
dispatch(iguanaAddCoin(coin, mode, _acData));
}
});
});
}
} else {
return dispatch => {
dispatch(iguanaAddCoin(coin, mode, _acData));
@ -1133,8 +1142,9 @@ export function getKMDAddressesNative(coin, mode, currentAddress) {
//console.log('calc result', result);
//console.log('calc json', json);
if (mode !== 'basilisk') {
if (mode !== 'basilisk' && json && json.length) {
const allAddrArray = json.map(res => res.address).filter((x, i, a) => a.indexOf(x) == i);
for (let a=0; a < allAddrArray.length; a++) {
const filteredArray = json.filter(res => res.address === allAddrArray[a]).map(res => res.amount);
@ -2323,6 +2333,29 @@ export function iguanaUTXORawTX(data) {
});
}
export function dexSendRawTX(data) {
const payload = {
'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
'agent': 'dex',
'method': 'sendrawtransaction',
'signedtx': data.signedtx,
'symbol': data.coin
};
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, 'dexSendRawTX', '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)

13
react/src/components/addcoin/addcoin.js

@ -39,7 +39,7 @@ class AddCoin extends React.Component {
toggleSyncOnlyMode() {
this.setState(Object.assign({}, this.state, {
syncOnly: this.state.syncOnly,
syncOnly: !this.state.syncOnly,
}));
}
@ -108,17 +108,8 @@ class AddCoin extends React.Component {
this.updateSelectedMode('1');
}
/*handleForm(e) {
e.preventDefault();
e.target.reset();
this.setState({
mode: '',
selectedCoin: null,
});
}*/
activateCoin() {
Store.dispatch(addCoin(this.state.selectedCoin.split('|')[0], this.state.mode, syncOnly));
Store.dispatch(addCoin(this.state.selectedCoin.split('|')[0], this.state.mode, this.state.syncOnly));
}
dismiss() {

42
react/src/components/dashboard/sendCoin.js

@ -10,7 +10,8 @@ import {
triggerToaster,
iguanaUTXORawTX,
clearLastSendToResponseState,
sendToAddressStateAlt
sendToAddressStateAlt,
dexSendRawTX
} from '../../actions/actionCreators';
import Store from '../../store';
@ -41,7 +42,9 @@ class SendCoin extends React.Component {
}
renderAddressAmount(address) {
if (this.props.ActiveCoin.addresses && this.props.ActiveCoin.addresses['public'] && this.props.ActiveCoin.addresses['public'].length) {
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;
@ -53,7 +56,9 @@ class SendCoin extends React.Component {
}
renderAddressByType(type) {
if (this.props.ActiveCoin.addresses && this.props.ActiveCoin.addresses[type] && this.props.ActiveCoin.addresses[type].length) {
if (this.props.ActiveCoin.addresses &&
this.props.ActiveCoin.addresses[type] &&
this.props.ActiveCoin.addresses[type].length) {
if (this.state.sendApiType) {
const mainAddress = this.props.Dashboard.activeHandle[this.props.ActiveCoin.coin];
const mainAddressAmount = this.renderAddressAmount(mainAddress);
@ -179,20 +184,32 @@ class SendCoin extends React.Component {
'sendsig': this.state.sendSig === true ? 0 : 1,
'utxos': utxoSet
};
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'), 'success'));
Store.dispatch(sendToAddressStateAlt(json));
if (sendData.sendsig === 1) {
//Store.dispatch(triggerToaster(true, translate('TOASTR.SENDING_TX') + '.', translate('TOASTR.WALLET_NOTIFICATION'), 'success'));
/*ajax_data_dexrawtx = {
const dexrawtxData = {
'signedtx': json.signedtx,
'coin': sendData.coin
};*/
};
dexSendRawTX(dexrawtxData)
.then(function(dexRawTxJson) {
if (dexRawTxJson.error === undefined) {
Store.dispatch(sendToAddressStateAlt(dexRawTxJson));
Store.dispatch(triggerToaster(true, translate('TOASTR.SIGNED_TX_SENT'), translate('TOASTR.WALLET_NOTIFICATION')));
console.log('utxo remove', true);
} else {
console.log('utxo alt');
Store.dispatch(triggerToaster(true, translate('TOASTR.SIGNED_TX_SENT'), translate('TOASTR.WALLET_NOTIFICATION')));
Store.dispatch(sendToAddressStateAlt(dexRawTxJson));
}
});
} else {
Store.dispatch(sendToAddressStateAlt(json));
}
@ -241,9 +258,15 @@ class SendCoin extends React.Component {
<span className="label label-success">{this.props.ActiveCoin.lastSendToResponse[key] === true ? 'true' : 'success'}</span>
);
} else {
return (
<span className="label label-danger">false</span>
);
if (this.props.ActiveCoin.lastSendToResponse[key].length > 20 && key === 'result') {
return (
<span>{this.props.ActiveCoin.lastSendToResponse[key]}</span>
);
} else {
return (
<span className="label label-danger">false</span>
);
}
}
} else if (key === 'error') {
return (
@ -270,7 +293,6 @@ class SendCoin extends React.Component {
renderSendCoinResponse() {
if (this.props.ActiveCoin.lastSendToResponse) {
console.log('renderSendCoinResponse', this.props.ActiveCoin.lastSendToResponse);
return Object.keys(this.props.ActiveCoin.lastSendToResponse).map((key, index) =>
<tr key={key}>
<td>{key}</td>

15
react/src/components/dashboard/walletsBalance.js

@ -3,11 +3,16 @@ import { translate } from '../../translate/translate';
class WalletsBalance extends React.Component {
render() {
if (this.props && this.props.coin && this.props.mode !== 'native' && this.props.balance && !this.props.send && !this.props.receive) {
if (this.props &&
this.props.ActiveCoin &&
this.props.ActiveCoin.coin &&
this.props.ActiveCoin.mode !== 'native' &&
!this.props.ActiveCoin.send &&
!this.props.ActiveCoin.receive) {
return (
<div id="wallet-widgets" data-plugin="masonry" data-edexcoin="COIN">
<div className="col-xs-12">
<div className={this.props.coin.mode === 'native' || this.props.coin.mode === 'full' ? 'col-xs-12' : 'col-xs-12 hide'}>
<div className={this.props.ActiveCoin.mode === 'native' || this.props.ActiveCoin.mode === 'full' ? 'col-xs-12' : 'col-xs-12 hide'}>
<div role="alert" className="alert alert-info alert-dismissible" data-edexcoin="COIN" id="edexcoin-wallet-waitingrt-alert">
<button aria-label="Close" data-dismiss="alert" className="close" type="button">
<span aria-hidden="true">×</span>
@ -37,7 +42,7 @@ class WalletsBalance extends React.Component {
<i className="icon fa-eye font-size-24 vertical-align-bottom margin-right-5"></i>{translate('INDEX.BALANCE')}
</div>
<span className="pull-right padding-top-10" data-edexcoin="COIN" style={{fontSize: '22px'}}>
<span data-edexcoin="COIN" id="edex_total_balance"></span> <span data-edexcoin="COIN" id="edex_total_balance_coincode">{this.props && this.props.balance ? this.props.balance : 0}</span>
<span data-edexcoin="COIN" id="edex_total_balance"></span> <span data-edexcoin="COIN" id="edex_total_balance_coincode">{this.props.ActiveCoin && this.props.ActiveCoin.balance ? this.props.ActiveCoin.balance : 0}</span>
</span>
</div>
</div>
@ -45,7 +50,7 @@ class WalletsBalance extends React.Component {
</div>
</div>
<div className={this.props.coin.mode === 'native' ? 'col-lg-4 col-xs-12' : 'col-lg-4 col-xs-12 hide'} data-edexcoin="COIN" id="edexcoin_getbalance_interest">
<div className={this.props.ActiveCoin.mode === 'native'|| (this.props.ActiveCoin.mode === 'basilisk' && this.props.ActiveCoin.coin === 'KMD') ? 'col-lg-4 col-xs-12' : 'col-lg-4 col-xs-12 hide'} data-edexcoin="COIN" id="edexcoin_getbalance_interest">
<div className="widget widget-shadow" id="widgetLineareaOne">
<div className="widget-content">
<div className="padding-20 padding-top-10">
@ -62,7 +67,7 @@ class WalletsBalance extends React.Component {
</div>
</div>
<div className={this.props.coin.mode === 'native' ? 'col-lg-4 col-xs-12' : 'col-lg-4 col-xs-12 hide'} data-edexcoin="COIN" id="edexcoin_getbalance_total_interest">
<div className={this.props.ActiveCoin.mode === 'native' || (this.props.ActiveCoin.mode === 'basilisk' && this.props.ActiveCoin.coin === 'KMD') ? 'col-lg-4 col-xs-12' : 'col-lg-4 col-xs-12 hide'} data-edexcoin="COIN" id="edexcoin_getbalance_total_interest">
<div className="widget widget-shadow" id="widgetLineareaOne">
<div className="widget-content">
<div className="padding-20 padding-top-10">

Loading…
Cancel
Save