Browse Source

send, get new addr rpc

all-modes
pbca26 8 years ago
parent
commit
e9b967882c
  1. 5
      react/change.log
  2. 21
      react/src/actions/actions/addressBalance.js
  3. 1
      react/src/actions/actions/iguanaHelpers.js
  4. 6
      react/src/actions/actions/nativeBalance.js
  5. 47
      react/src/actions/actions/nativeNewAddress.js
  6. 76
      react/src/actions/actions/nativeSend.js
  7. 6
      react/src/actions/actions/nativeSyncInfo.js
  8. 16
      react/src/actions/actions/nativeTxHistory.js
  9. 4
      react/src/components/dashboard/walletsNativeSend/walletsNativeSend.js
  10. 44
      react/src/components/dashboard/walletsNativeSend/walletsNativeSend.render.js

5
react/change.log

@ -13,6 +13,9 @@ front:
- 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
- added cli route
- rpc passphru

21
react/src/actions/actions/addressBalance.js

@ -131,7 +131,7 @@ export function getKMDAddressesNative(coin, mode, currentAddress) {
body: JSON.stringify(payload),
};
if (Config.cli.default === true &&
if (Config.cli.default &&
mode === 'native') {
_fetchConfig = {
method: 'POST',
@ -253,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] = [];
@ -286,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) => {
@ -322,7 +333,7 @@ export function getKMDAddressesNative(coin, mode, currentAddress) {
body: JSON.stringify(payload),
};
if (Config.cli.default === true &&
if (Config.cli.default &&
mode === 'native') {
payload = {
mode: null,
@ -508,7 +519,7 @@ export function getKMDAddressesNative(coin, mode, currentAddress) {
body: JSON.stringify(payload),
};
if (Config.cli.default === true &&
if (Config.cli.default &&
mode === 'native') {
payload = {
mode: null,

1
react/src/actions/actions/iguanaHelpers.js

@ -28,6 +28,7 @@ export function iguanaHashHex(data, dispatch) {
};
return new Promise((resolve, reject) => {
// skip iguana hashing in cli mode
if (Config.cli.default) {
resolve(true);
} else {

6
react/src/actions/actions/nativeBalance.js

@ -32,7 +32,7 @@ export function getKMDBalanceTotal(coin) {
};
}
if (Config.cli.default === true) {
if (Config.cli.default) {
payload = {
mode: null,
chain: coin,
@ -56,7 +56,7 @@ export function getKMDBalanceTotal(coin) {
body: JSON.stringify(payload),
};
if (Config.cli.default === true) {
if (Config.cli.default) {
_fetchConfig = {
method: 'POST',
headers: {
@ -103,6 +103,6 @@ export function getKMDBalanceTotal(coin) {
export function getNativeBalancesState(json) {
return {
type: DASHBOARD_ACTIVE_COIN_NATIVE_BALANCE,
balance: json && !json.error ? (Config.cli.default === true ? json.result : json) : 0,
balance: json && !json.error ? (Config.cli.default ? json.result : json) : 0,
}
}

47
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
)
);
})

76
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({
@ -102,9 +137,10 @@ export function sendNativeTx(coin, _payload) {
dispatch(
triggerToaster(
true,
'Your wallet.dat is not matching the blockchain. Please resync from the scratch.',
translate('TOASTR.WALLET_NOTIFICATION'),
'info'
'Your wallet.dat is not matching the blockchain. Please resync from the scratch.',
'info',
false
)
);
}
@ -173,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({
@ -199,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',

6
react/src/actions/actions/nativeSyncInfo.js

@ -67,7 +67,7 @@ function getSyncInfoNativeState(json, coin, skipDebug) {
} else {
return {
type: SYNCING_NATIVE_MODE,
progress: Config.cli.default === true ? json.result : json,
progress: Config.cli.default ? json.result : json,
}
}
}
@ -82,7 +82,7 @@ export function getSyncInfoNative(coin, skipDebug) {
'hex': '',
};
if (Config.cli.default === true) {
if (Config.cli.default) {
payload = {
mode: null,
chain: coin,
@ -105,7 +105,7 @@ export function getSyncInfoNative(coin, skipDebug) {
body: JSON.stringify(payload),
};
if (Config.cli.default === true) {
if (Config.cli.default) {
_fetchConfig = {
method: 'POST',
headers: {

16
react/src/actions/actions/nativeTxHistory.js

@ -31,14 +31,6 @@ export function getNativeTxHistory(coin) {
};
}
if (Config.cli.default === true) {
payload = {
mode: null,
chain: coin,
cmd: 'listtransactions'
};
}
return dispatch => {
const _timestamp = Date.now();
dispatch(logGuiHttp({
@ -55,7 +47,13 @@ export function getNativeTxHistory(coin) {
body: JSON.stringify(payload),
};
if (Config.cli.default === true) {
if (Config.cli.default) {
payload = {
mode: null,
chain: coin,
cmd: 'listtransactions'
};
_fetchConfig = {
method: 'POST',
headers: {

4
react/src/components/dashboard/walletsNativeSend/walletsNativeSend.js

@ -79,7 +79,7 @@ class WalletsNativeSend extends React.Component {
if (this.state.sendFrom) {
return (
<span>
<i className={ this.state.addressType === 'public' ? 'icon fa-eye' : 'icon fa-eye-slash' }></i>
<i className={ this.state.addressType === 'public' ? 'icon fa-eye' : 'icon fa-eye-slash' }></i>
<span className="text">
[ { this.state.sendFromAmount } { this.props.ActiveCoin.coin } ]
{ this.state.sendFrom }
@ -119,7 +119,7 @@ class WalletsNativeSend extends React.Component {
return (
<span className={ `label label-${_satatusDef[opid.status].icon}` }>
<i className="icon fa-eye"></i>
<i className="icon fa-eye"></i>&nbsp;
<span>{ translate(`KMD_NATIVE.${_satatusDef[opid.status].label}`) }</span>
</span>
);

44
react/src/components/dashboard/walletsNativeSend/walletsNativeSend.render.js

@ -11,8 +11,8 @@ export const AddressListRender = function() {
onClick={ this.openDropMenu }>
<span className="filter-option pull-left">{ this.renderSelectorCurrentLabel() } </span>
<span className="bs-caret">
<span className="caret"></span>
</span>
<span className="caret"></span>
</span>
</button>
<div className="dropdown-menu open">
<ul className="dropdown-menu inner">
@ -115,7 +115,9 @@ export const WalletsNativeSendRender = function() {
<div className="col-lg-6 form-group form-material">
<label
className="control-label"
htmlFor="kmdWalletFee">{ translate('INDEX.FEE') }</label>
htmlFor="kmdWalletFee">
{ translate('INDEX.FEE') }
</label>
<input
type="text"
className="form-control"
@ -128,8 +130,8 @@ export const WalletsNativeSendRender = function() {
</div>
<div className="col-lg-12">
<span>
<strong>{ translate('INDEX.TOTAL') }:</strong>
{ this.state.amount } - { this.state.fee }/kb = { Number(this.state.amount) - Number(this.state.fee) }
<strong>{ translate('INDEX.TOTAL') }:</strong>
{ this.state.amount } - { this.state.fee }/kb = { Number(this.state.amount) - Number(this.state.fee) }
{ this.props.ActiveCoin.coin }
</span>
</div>
@ -155,30 +157,32 @@ export const WalletsNativeSendRender = function() {
<div className="col-xlg-12 col-lg-12 col-sm-12 col-xs-12">
<div className="panel">
<header className="panel-heading">
<h3 className="panel-title">{ translate('INDEX.OPERATIONS_STATUSES') }</h3>
<h3 className="panel-title">
{ translate('INDEX.OPERATIONS_STATUSES') }
</h3>
</header>
<div className="panel-body">
<table
className="table table-hover dataTable table-striped"
width="100%">
<thead>
<tr>
<th>{ translate('INDEX.STATUS') }</th>
<th>ID</th>
<th>{ translate('INDEX.TIME') }</th>
<th>{ translate('INDEX.RESULT') }</th>
</tr>
</thead>
<tr>
<th>{ translate('INDEX.STATUS') }</th>
<th>ID</th>
<th>{ translate('INDEX.TIME') }</th>
<th>{ translate('INDEX.RESULT') }</th>
</tr>
</thead>
<tbody>
{ this.renderOPIDList() }
{ this.renderOPIDList() }
</tbody>
<tfoot>
<tr>
<th>{ translate('INDEX.STATUS') }</th>
<th>ID</th>
<th>{ translate('INDEX.TIME') }</th>
<th>{ translate('INDEX.RESULT') }</th>
</tr>
<tr>
<th>{ translate('INDEX.STATUS') }</th>
<th>ID</th>
<th>{ translate('INDEX.TIME') }</th>
<th>{ translate('INDEX.RESULT') }</th>
</tr>
</tfoot>
</table>
</div>

Loading…
Cancel
Save