Browse Source

resolved merge conflicts

all-modes
Petr Balashov 8 years ago
parent
commit
58be931568
  1. 6
      react/change.log
  2. 116
      react/src/actions/actions/addressBalance.js
  3. 75
      react/src/actions/actions/iguanaHelpers.js
  4. 31
      react/src/actions/actions/nativeBalance.js
  5. 47
      react/src/actions/actions/nativeNewAddress.js
  6. 93
      react/src/actions/actions/nativeSend.js
  7. 69
      react/src/actions/actions/nativeSyncInfo.js
  8. 27
      react/src/actions/actions/nativeTxHistory.js
  9. 4
      react/src/components/dashboard/main/dashboard.js
  10. 82
      react/src/components/dashboard/receiveCoin/receiveCoin.js
  11. 68
      react/src/components/dashboard/receiveCoin/receiveCoin.render.js
  12. 2
      react/src/components/dashboard/settings/settings.js
  13. 26
      react/src/components/dashboard/walletsBalance/walletsBalance.js
  14. 58
      react/src/components/dashboard/walletsBalance/walletsBalance.render.js
  15. 2
      react/src/components/dashboard/walletsCacheData/walletsCacheData.render.js
  16. 6
      react/src/components/dashboard/walletsNative/walletsNative.render.js
  17. 15
      react/src/components/dashboard/walletsNativeBalance/walletsNativeBalance.js
  18. 82
      react/src/components/dashboard/walletsNativeBalance/walletsNativeBalance.render.js
  19. 94
      react/src/components/dashboard/walletsNativeReceive/walletsNativeReceive.js
  20. 90
      react/src/components/dashboard/walletsNativeReceive/walletsNativeReceive.render.js
  21. 4
      react/src/components/dashboard/walletsNativeSend/walletsNativeSend.js
  22. 44
      react/src/components/dashboard/walletsNativeSend/walletsNativeSend.render.js
  23. 56
      react/src/components/dashboard/walletsNativeSyncProgress/walletsNativeSyncProgress.js
  24. 26
      react/src/components/dashboard/walletsNotariesList/walletsNotariesList.render.js
  25. 4
      react/src/config.js
  26. 2
      react/www/index.html

6
react/change.log

@ -12,6 +12,10 @@ front:
- sort http stack history desc - sort http stack history desc
- swapped gettotalbalance interest with getinfo interest - swapped gettotalbalance interest with getinfo interest
- extended settings / export keys ui - 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: back:
- added cli route - added cli route
- rpc passphru

116
react/src/actions/actions/addressBalance.js

@ -106,20 +106,46 @@ export function getKMDAddressesNative(coin, mode, currentAddress) {
} }
}) })
} else { } else {
if (Config.cli.default &&
mode === 'native') {
payload = {
mode: null,
chain: coin,
cmd: payload.function,
params: [""]
};
}
const _timestamp = Date.now(); const _timestamp = Date.now();
dispatch(logGuiHttp({ dispatch(logGuiHttp({
'timestamp': _timestamp, 'timestamp': _timestamp,
'function': 'getKMDAddressesNative', 'function': 'getKMDAddressesNative',
'type': 'post', '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, 'payload': payload,
'status': 'pending', 'status': 'pending',
})); }));
fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { let _fetchConfig = {
method: 'POST', method: 'POST',
body: JSON.stringify(payload), 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) { .catch(function(error) {
console.log(error); console.log(error);
dispatch(logGuiHttp({ dispatch(logGuiHttp({
@ -142,7 +168,7 @@ export function getKMDAddressesNative(coin, mode, currentAddress) {
'status': 'success', 'status': 'success',
'response': json, '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++) { for (let a = 0; a < result.length; a++) {
newAddressArray[a] = []; newAddressArray[a] = [];
@ -260,7 +297,7 @@ export function getKMDAddressesNative(coin, mode, currentAddress) {
Promise.all(result[1].map((_address, index) => { Promise.all(result[1].map((_address, index) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const _timestamp = Date.now(); const _timestamp = Date.now();
let ajaxDataToHex = `["${_address}"]`; let ajaxDataToHex = `[\"${_address}\"]`;
iguanaHashHex(ajaxDataToHex, dispatch) iguanaHashHex(ajaxDataToHex, dispatch)
.then((hashHexJson) => { .then((hashHexJson) => {
@ -286,16 +323,40 @@ export function getKMDAddressesNative(coin, mode, currentAddress) {
'timestamp': _timestamp, 'timestamp': _timestamp,
'function': 'getKMDAddressesNative+ZBalance', 'function': 'getKMDAddressesNative+ZBalance',
'type': 'post', '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, 'payload': payload,
'status': 'pending', 'status': 'pending',
})); }));
fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, let _fetchConfig = {
{
method: 'POST', method: 'POST',
body: JSON.stringify(payload), 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) { .catch(function(error) {
console.log(error); console.log(error);
dispatch(logGuiHttp({ dispatch(logGuiHttp({
@ -329,6 +390,10 @@ export function getKMDAddressesNative(coin, mode, currentAddress) {
) )
); );
} else { } else {
if (Config.cli.default &&
mode === 'native') {
json = json.result;
}
resolve(json); resolve(json);
newAddressArray[1][index] = { newAddressArray[1][index] = {
address: _address, address: _address,
@ -449,10 +514,33 @@ export function getKMDAddressesNative(coin, mode, currentAddress) {
'status': 'pending', 'status': 'pending',
})); }));
fetch(`http://127.0.0.1:${(Config.useBasiliskInstance && mode === 'basilisk' ? Config.iguanaCorePort + 1 : Config.iguanaCorePort)}`, { let _fetchConfig = {
method: 'POST', method: 'POST',
body: JSON.stringify(payload), 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) { .catch(function(error) {
console.log(error); console.log(error);
dispatch(logGuiHttp({ dispatch(logGuiHttp({
@ -470,6 +558,10 @@ export function getKMDAddressesNative(coin, mode, currentAddress) {
}) })
.then(response => response.json()) .then(response => response.json())
.then(function(json) { .then(function(json) {
if (Config.cli.default &&
mode === 'native') {
json = json.result;
}
dispatch(logGuiHttp({ dispatch(logGuiHttp({
'timestamp': _timestamp, 'timestamp': _timestamp,
'status': 'success', 'status': 'success',

75
react/src/actions/actions/iguanaHelpers.js

@ -28,44 +28,49 @@ export function iguanaHashHex(data, dispatch) {
}; };
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const _timestamp = Date.now(); // skip iguana hashing in cli mode
dispatch(logGuiHttp({ if (Config.cli.default) {
'timestamp': _timestamp, resolve(true);
'function': 'iguanaHashHex', } else {
'type': 'post', const _timestamp = Date.now();
'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);
dispatch(logGuiHttp({ dispatch(logGuiHttp({
'timestamp': _timestamp, 'timestamp': _timestamp,
'status': 'error', 'function': 'iguanaHashHex',
'response': error, 'type': 'post',
'url': `http://127.0.0.1:${Config.iguanaCorePort}`,
'payload': payload,
'status': 'pending',
})); }));
dispatch(
triggerToaster( fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, {
'iguanaHashHex', method: 'POST',
'Error', body: JSON.stringify(payload),
'error' })
) .catch(function(error) {
); console.log(error);
}) dispatch(logGuiHttp({
.then(response => response.json()) 'timestamp': _timestamp,
.then(json => { 'status': 'error',
dispatch(logGuiHttp({ 'response': error,
'timestamp': _timestamp, }));
'status': 'success', dispatch(
'response': json, triggerToaster(
})); 'iguanaHashHex',
resolve(json.hex); 'Error',
}) 'error'
)
);
})
.then(response => response.json())
.then(json => {
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'success',
'response': json,
}));
resolve(json.hex);
})
}
}) })
} }

31
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 => { return dispatch => {
const _timestamp = Date.now(); const _timestamp = Date.now();
dispatch(logGuiHttp({ dispatch(logGuiHttp({
'timestamp': _timestamp, 'timestamp': _timestamp,
'function': 'getKMDBalanceTotal', 'function': 'getKMDBalanceTotal',
'type': 'post', '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, 'payload': payload,
'status': 'pending', 'status': 'pending',
})); }));
return fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { let _fetchConfig = {
method: 'POST', method: 'POST',
body: JSON.stringify(payload), 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) { .catch(function(error) {
console.log(error); console.log(error);
dispatch(logGuiHttp({ dispatch(logGuiHttp({
@ -80,6 +103,6 @@ export function getKMDBalanceTotal(coin) {
export function getNativeBalancesState(json) { export function getNativeBalancesState(json) {
return { return {
type: DASHBOARD_ACTIVE_COIN_NATIVE_BALANCE, type: DASHBOARD_ACTIVE_COIN_NATIVE_BALANCE,
balance: json && !json.error ? 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 guiLogState
} from './log'; } from './log';
function handleGetNewKMDAddresses(pubpriv, coin, dispatch) { function handleGetNewKMDAddresses(pubpriv, coin, dispatch, json) {
dispatch( /*dispatch(
triggerToaster( triggerToaster(
translate('KMD_NATIVE.NEW_ADDR_GENERATED'), translate('KMD_NATIVE.NEW_ADDR_GENERATED'),
translate('TOASTR.WALLET_NOTIFICATION'), translate('TOASTR.WALLET_NOTIFICATION'),
'success' 'success'
) )
);*/
dispatch(
triggerToaster(
json.result ? json.result : json,
translate('KMD_NATIVE.NEW_ADDR_GENERATED'),
'info',
false
)
); );
dispatch(getKMDAddressesNative(coin)); dispatch(getKMDAddressesNative(coin));
@ -45,7 +53,7 @@ export function getNewKMDAddresses(coin, pubpriv) {
}; };
} else { } else {
payload = { payload = {
'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), 'userpass': `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`,
'agent': coin, 'agent': coin,
'method': 'passthru', 'method': 'passthru',
'function': ajaxFunctionInput, 'function': ajaxFunctionInput,
@ -59,15 +67,36 @@ export function getNewKMDAddresses(coin, pubpriv) {
'timestamp': _timestamp, 'timestamp': _timestamp,
'function': 'getNewKMDAddresses', 'function': 'getNewKMDAddresses',
'type': 'post', '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, 'payload': payload,
'status': 'pending', 'status': 'pending',
})); }));
return fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { let _fetchConfig = {
method: 'POST', method: 'POST',
body: JSON.stringify(payload), 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) { .catch(function(error) {
console.log(error); console.log(error);
dispatch(logGuiHttp({ dispatch(logGuiHttp({
@ -85,6 +114,9 @@ export function getNewKMDAddresses(coin, pubpriv) {
}) })
.then(response => response.json()) .then(response => response.json())
.then(json => { .then(json => {
if (Config.cli.default) {
json = json.result;
}
dispatch(logGuiHttp({ dispatch(logGuiHttp({
'timestamp': _timestamp, 'timestamp': _timestamp,
'status': 'success', 'status': 'success',
@ -94,7 +126,8 @@ export function getNewKMDAddresses(coin, pubpriv) {
handleGetNewKMDAddresses( handleGetNewKMDAddresses(
pubpriv, pubpriv,
coin, coin,
dispatch dispatch,
json
) )
); );
}) })

93
react/src/actions/actions/nativeSend.js

@ -51,15 +51,50 @@ export function sendNativeTx(coin, _payload) {
'timestamp': _timestamp, 'timestamp': _timestamp,
'function': 'sendNativeTx', 'function': 'sendNativeTx',
'type': 'post', '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, 'payload': payload,
'status': 'pending', 'status': 'pending',
})); }));
fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { let _fetchConfig = {
method: 'POST', method: 'POST',
body: JSON.stringify(payload), 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) { .catch(function(error) {
console.log(error); console.log(error);
dispatch(logGuiHttp({ dispatch(logGuiHttp({
@ -77,7 +112,7 @@ export function sendNativeTx(coin, _payload) {
}) })
.then(function(response) { .then(function(response) {
const _response = response.text().then(function(text) { return text; }); const _response = response.text().then(function(text) { return text; });
return response.json(); return _response;
}) })
.then(function(json) { .then(function(json) {
dispatch(logGuiHttp({ dispatch(logGuiHttp({
@ -86,15 +121,29 @@ export function sendNativeTx(coin, _payload) {
'response': json, 'response': json,
})); }));
if (json.error && if (json.indexOf('"code":') > -1) {
json.error.toString().indexOf('code:') > -1) { const _message = json.substring(json.indexOf('"message":"') + 11, json.indexOf('"},"id":"jl777"'));
dispatch( dispatch(
triggerToaster( triggerToaster(
'Send failed', true,
_message,
translate('TOASTR.WALLET_NOTIFICATION'), translate('TOASTR.WALLET_NOTIFICATION'),
'error' '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 { } else {
dispatch( dispatch(
triggerToaster( triggerToaster(
@ -160,15 +209,36 @@ export function getKMDOPID(opid, coin) {
'timestamp': _timestamp, 'timestamp': _timestamp,
'function': 'getKMDOPID', 'function': 'getKMDOPID',
'type': 'post', '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, 'payload': payload,
'status': 'pending', 'status': 'pending',
})); }));
fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { let _fetchConfig = {
method: 'POST', method: 'POST',
body: JSON.stringify(payload), 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) { .catch(function(error) {
console.log(error); console.log(error);
dispatch(logGuiHttp({ dispatch(logGuiHttp({
@ -186,6 +256,9 @@ export function getKMDOPID(opid, coin) {
}) })
.then(response => response.json()) .then(response => response.json())
.then(json => { .then(json => {
if (Config.cli.default) {
json = json.result;
}
dispatch(logGuiHttp({ dispatch(logGuiHttp({
'timestamp': _timestamp, 'timestamp': _timestamp,
'status': 'success', 'status': 'success',

69
react/src/actions/actions/nativeSyncInfo.js

@ -60,20 +60,31 @@ export function getSyncInfoNativeKMD(skipDebug) {
} }
function getSyncInfoNativeState(json, coin, skipDebug) { function getSyncInfoNativeState(json, coin, skipDebug) {
console.log('getSyncInfoNativeState', json);
if (coin === 'KMD' && if (coin === 'KMD' &&
json && json &&
json.error) { json.error) {
return getSyncInfoNativeKMD(skipDebug); return getSyncInfoNativeKMD(skipDebug);
} else { } else {
return { if (json &&
type: SYNCING_NATIVE_MODE, json.error &&
progress: json, 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) { export function getSyncInfoNative(coin, skipDebug) {
const payload = { let payload = {
'userpass': `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`, 'userpass': `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`,
'agent': getPassthruAgent(coin), 'agent': getPassthruAgent(coin),
'method': 'passthru', 'method': 'passthru',
@ -82,21 +93,43 @@ export function getSyncInfoNative(coin, skipDebug) {
'hex': '', 'hex': '',
}; };
if (Config.cli.default) {
payload = {
mode: null,
chain: coin,
cmd: 'getinfo'
};
}
return dispatch => { return dispatch => {
const _timestamp = Date.now(); const _timestamp = Date.now();
dispatch(logGuiHttp({ dispatch(logGuiHttp({
'timestamp': _timestamp, 'timestamp': _timestamp,
'function': 'getSyncInfo', 'function': 'getSyncInfo',
'type': 'post', '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, 'payload': payload,
'status': 'pending', 'status': 'pending',
})); }));
let _fetchConfig = {
return fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, {
method: 'POST', method: 'POST',
body: JSON.stringify(payload), 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) { .catch(function(error) {
console.log(error); console.log(error);
dispatch(logGuiHttp({ 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 => { .then(json => {
if (!json &&
Config.cli.default) {
dispatch(
triggerToaster(
'Komodod is down',
'Critical Error',
'error',
false
)
);
} else {
json = JSON.parse(json);
}
dispatch(logGuiHttp({ dispatch(logGuiHttp({
'timestamp': _timestamp, 'timestamp': _timestamp,
'status': 'success', 'status': 'success',

27
react/src/actions/actions/nativeTxHistory.js

@ -37,15 +37,36 @@ export function getNativeTxHistory(coin) {
'timestamp': _timestamp, 'timestamp': _timestamp,
'function': 'getNativeTxHistory', 'function': 'getNativeTxHistory',
'type': 'post', '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, 'payload': payload,
'status': 'pending', 'status': 'pending',
})); }));
return fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { let _fetchConfig = {
method: 'POST', method: 'POST',
body: JSON.stringify(payload), 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) { .catch(function(error) {
console.log(error); console.log(error);
dispatch(logGuiHttp({ dispatch(logGuiHttp({

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

@ -26,6 +26,10 @@ class Dashboard extends React.Component {
this.props.Main.isLoggedIn; this.props.Main.isLoggedIn;
} }
isNativeMode() {
return this.props.ActiveCoin.mode === 'native';
}
render() { render() {
if (this.isLoggedIn()) { if (this.isLoggedIn()) {
return this.renderDashboard(); return this.renderDashboard();

82
react/src/components/dashboard/receiveCoin/receiveCoin.js

@ -2,10 +2,10 @@ import React from 'react';
import { import {
copyCoinAddress, copyCoinAddress,
checkAddressBasilisk, checkAddressBasilisk,
validateAddressBasilisk validateAddressBasilisk,
getNewKMDAddresses
} from '../../../actions/actionCreators'; } from '../../../actions/actionCreators';
import Store from '../../../store'; import Store from '../../../store';
import { import {
AddressActionsBasiliskModeRender, AddressActionsBasiliskModeRender,
AddressActionsNonBasiliskModeRender, AddressActionsNonBasiliskModeRender,
@ -19,6 +19,43 @@ import {
class ReceiveCoin extends React.Component { class ReceiveCoin extends React.Component {
constructor(props) { constructor(props) {
super(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) { _checkAddressBasilisk(address) {
@ -47,12 +84,16 @@ class ReceiveCoin extends React.Component {
return this.props.mode === 'basilisk'; return this.props.mode === 'basilisk';
} }
renderAddressActions(address) { isNativeMode() {
return this.props.mode == 'native';
}
renderAddressActions(address, type) {
if (this.isBasiliskMode()) { if (this.isBasiliskMode()) {
return AddressActionsBasiliskModeRender.call(this, address); return AddressActionsBasiliskModeRender.call(this, address);
} }
return AddressActionsNonBasiliskModeRender.call(this, address); return AddressActionsNonBasiliskModeRender.call(this, address, type);
} }
hasNoAmount(address) { hasNoAmount(address) {
@ -63,26 +104,34 @@ class ReceiveCoin extends React.Component {
return address.interest === 'N/A' || address.interest === 0 || !address.interest; 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 && if (this.props.addresses &&
this.props.addresses.public && this.props.addresses[type] &&
this.props.addresses.public.length) { this.props.addresses[type].length) {
let items = []; let items = [];
for (let i = 0; i < this.props.addresses.public.length; i++) { for (let i = 0; i < this.props.addresses[type].length; i++) {
let address = this.props.addresses.public[i]; let address = this.props.addresses[type][i];
if (this.isBasiliskMode() && if (this.isBasiliskMode() &&
this.hasNoAmount(address)) { 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'; 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() && if (this.isBasiliskMode() &&
this.hasNoInterest(address)) { 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'; 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( items.push(
AddressItemRender.call(this, address) AddressItemRender.call(this, address, type)
); );
} }
@ -93,9 +142,10 @@ class ReceiveCoin extends React.Component {
} }
render() { render() {
// TODO nativeActiveSection === 'receive' should be removed when native mode is fully merged
// into the rest of the components
if (this.props && if (this.props &&
this.props.receive && (this.props.receive || (this.isNativeMode() && this.props.nativeActiveSection === 'receive'))) {
this.props.mode !== 'native') {
return ReceiveCoinRender.call(this); return ReceiveCoinRender.call(this);
} }

68
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 ( return (
<td> <td>
<span className="label label-default"> <span className={ type === 'public' ? 'label label-default' : 'label label-dark' }>
<i className="icon fa-eye"></i> { translate('IAPI.PUBLIC_SM') } <i className={ type === 'public' ? 'icon fa-eye' : 'icon fa-eye-slash' }></i>
{ type === 'public' ? translate('IAPI.PUBLIC_SM') : translate('KMD_NATIVE.PRIVATE') }
</span> </span>
<button <button
className="btn btn-default btn-xs clipboard-edexaddr margin-left-10" className="btn btn-default btn-xs clipboard-edexaddr margin-left-10"
@ -44,13 +45,15 @@ export const AddressActionsNonBasiliskModeRender = function(address) {
); );
}; };
export const AddressItemRender = function(address) { export const AddressItemRender = function(address, type) {
return ( return (
<tr key={ address.address }> <tr key={ address.address }>
{ this.renderAddressActions(address.address) } { this.renderAddressActions(address.address, type) }
<td>{ address.address }</td> <td>{ type === 'public' ? address.address : address.address.substring(0, 34) + '...' }</td>
<td>{ address.amount }</td> <td>{ address.amount }</td>
<td>{ address.interest ? address.interest : 'N/A' }</td> {!this.isNativeMode() &&
<td>{ address.interest ? address.interest : 'N/A' }</td>
}
</tr> </tr>
); );
}; };
@ -64,31 +67,70 @@ export const ReceiveCoinRender = function() {
<div className="col-xlg-12 col-lg-12 col-sm-12 col-xs-12"> <div className="col-xlg-12 col-lg-12 col-sm-12 col-xs-12">
<div className="panel"> <div className="panel">
<header className="panel-heading"> <header className="panel-heading">
<div className="panel-actions"></div> {this.isNativeMode() &&
<h4 className="panel-title"> <div className="panel-actions">
{ translate('INDEX.RECEIVING_ADDRESS') } <div className={ 'dropdown' + (this.state.openDropMenu ? ' open' : '') }
</h4> onClick={ this.openDropMenu }>
<a className="dropdown-toggle white btn btn-warning">
<i className="icon md-arrows margin-right-10"></i> { translate('INDEX.GET_NEW_ADDRESS') }
<span
className="caret"></span>
</a>
<ul
className="dropdown-menu dropdown-menu-right">
<li>
<a onClick={ () => this.getNewAddress('public') }>
<i className="icon fa-eye"></i> { translate('INDEX.TRANSPARENT_ADDRESS') }
</a>
</li>
<li>
<a onClick={ () => this.getNewAddress('private') }>
<i className="icon fa-eye-slash"></i> { translate('INDEX.PRIVATE_Z_ADDRESS') }
</a>
</li>
</ul>
</div>
</div>
}
<h4 className="panel-title">{ translate('INDEX.RECEIVING_ADDRESS') }</h4>
</header> </header>
<div className="panel-body"> <div className="panel-body">
<table className="table table-hover dataTable table-striped"> <table className="table table-hover dataTable table-striped">
<thead> <thead>
{this.isNativeMode() ?
<tr>
<th>{ translate('INDEX.TYPE') }</th>
<th>{ translate('INDEX.ADDRESS') }</th>
<th>{ translate('INDEX.AMOUNT') }</th>
</tr>
:
<tr> <tr>
<th>{ translate('INDEX.TYPE') }</th> <th>{ translate('INDEX.TYPE') }</th>
<th>{ translate('INDEX.ADDRESS') }</th> <th>{ translate('INDEX.ADDRESS') }</th>
<th>{ translate('INDEX.BALANCE') }</th> <th>{ translate('INDEX.BALANCE') }</th>
<th>{ translate('INDEX.INTEREST') }</th> <th> {translate('INDEX.INTEREST') }</th>
</tr> </tr>
}
</thead> </thead>
<tbody> <tbody>
{ this.renderAddressList() } {this.renderAddressList('public')}
{this.isNativeMode() && this.renderAddressList('private')}
</tbody> </tbody>
<tfoot> <tfoot>
{this.isNativeMode() ?
<tr>
<th>{ translate('INDEX.TYPE') }</th>
<th>{ translate('INDEX.ADDRESS') }</th>
<th>{ translate('INDEX.AMOUNT') }</th>
</tr>
:
<tr> <tr>
<th>{ translate('INDEX.TYPE') }</th> <th>{ translate('INDEX.TYPE') }</th>
<th>{ translate('INDEX.ADDRESS') }</th> <th>{ translate('INDEX.ADDRESS') }</th>
<th>{ translate('INDEX.BALANCE') }</th> <th>{ translate('INDEX.BALANCE') }</th>
<th>{ translate('INDEX.INTEREST') }</th> <th>{ translate('INDEX.INTEREST') }</th>
</tr> </tr>
}
</tfoot> </tfoot>
</table> </table>
</div> </div>

2
react/src/components/dashboard/settings/settings.js

@ -315,7 +315,7 @@ class Settings extends React.Component {
let _cliResponseParsed; let _cliResponseParsed;
try { try {
_cliResponseParsed = JSON.parse(_cliResponse.result) _cliResponseParsed = JSON.parse(_cliResponse.result);
} catch(e) { } catch(e) {
_cliResponseParsed = _cliResponse.result; _cliResponseParsed = _cliResponse.result;
} }

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

@ -74,8 +74,16 @@ class WalletsBalance extends React.Component {
return this.props.ActiveCoin.mode === coinMode; return this.props.ActiveCoin.mode === coinMode;
} }
isNativeOrBasiliskCoinMode() { isBasiliskMode() {
return this.isActiveCoinMode('native') || this.isActiveCoinMode('basilisk'); return this.isActiveCoinMode('basilisk');
}
isNativeMode() {
return this.isActiveCoinMode('native');
}
isFullMode() {
return this.isActiveCoinMode('full');
} }
renderLB(_translationID) { renderLB(_translationID) {
@ -89,13 +97,21 @@ class WalletsBalance extends React.Component {
); );
} }
isNativeBalanceActive() {
return this.isNativeMode() && this.props.ActiveCoin.nativeActiveSection === 'default';
}
isNonNativeBalanceActive() {
return !this.isNativeMode() && !this.props.ActiveCoin.send && !this.props.ActiveCoin.receive;
}
render() { render() {
if (this.props && if (this.props &&
this.props.ActiveCoin && this.props.ActiveCoin &&
this.props.ActiveCoin.coin && this.props.ActiveCoin.coin &&
this.props.ActiveCoin.mode !== 'native' && // TODO the conditions below should be merged when native mode is fully merged into the rest of the components
!this.props.ActiveCoin.send && (this.isNativeBalanceActive() || this.isNonNativeBalanceActive()))
!this.props.ActiveCoin.receive) { {
return WalletsBalanceRender.call(this); return WalletsBalanceRender.call(this);
} }

58
react/src/components/dashboard/walletsBalance/walletsBalance.render.js

@ -5,7 +5,8 @@ const WalletsBalanceRender = function() {
return ( return (
<div id="wallet-widgets"> <div id="wallet-widgets">
<div className="col-xs-12"> <div className="col-xs-12">
<div className={ this.isActiveCoinMode('native') || (this.isActiveCoinMode('full') && !this.isFullySynced()) ? 'col-xs-12' : 'col-xs-12 hide' }> <div className={ this.isNativeMode() || (this.isFullMode()
&& !this.isFullySynced()) ? 'col-xs-12' : 'col-xs-12 hide' }>
<div className="alert alert-info alert-dismissible"> <div className="alert alert-info alert-dismissible">
<button <button
className="close" className="close"
@ -31,17 +32,25 @@ const WalletsBalanceRender = function() {
</div> </div>
</div> </div>
<div className={ this.isNativeOrBasiliskCoinMode() ? 'col-lg-4 col-xs-12' : 'col-lg-12 col-xs-12' }> <div className={ this.isNativeMode() ? 'col-lg-3 col-xs-12' :
this.isBasiliskMode() ? 'col-lg-4 col-xs-12' : 'col-lg-12 col-xs-12'}>
<div className="widget widget-shadow"> <div className="widget widget-shadow">
<div className="widget-content"> <div className="widget-content">
<div className="padding-20 padding-top-10"> <div className="padding-20 padding-top-10">
<div className="clearfix"> <div className="clearfix">
<div className="pull-left padding-vertical-10"> <div className="pull-left padding-vertical-10">
<i className="icon fa-eye font-size-24 vertical-align-bottom margin-right-5"></i> <i className="icon fa-eye font-size-24 vertical-align-bottom margin-right-5"></i>
{ translate('INDEX.BALANCE')} { this.isNativeMode() ? translate('INDEX.TRANSPARENT_BALANCE') : translate('INDEX.BALANCE') }
</div> </div>
<span className="pull-right padding-top-10 font-size-22"> <span className="pull-right padding-top-10 font-size-22">
{ this.renderBalance('main') } { this.props.ActiveCoin.coin } { this.isNativeMode() ?
this.props.ActiveCoin.balance.transparent ? this.props.ActiveCoin.balance.transparent : '-'
:
<span>
{ this.renderBalance('main') } { this.props.ActiveCoin.coin }
</span>
}
</span> </span>
</div> </div>
</div> </div>
@ -49,7 +58,26 @@ const WalletsBalanceRender = function() {
</div> </div>
</div> </div>
<div className={ this.isNativeOrBasiliskCoinMode() ? 'col-lg-4 col-xs-12' : 'col-lg-4 col-xs-12 hide' }> { this.isNativeMode() &&
<div className="col-lg-3 col-xs-12">
<div className="widget widget-shadow">
<div className="padding-20 padding-top-10">
<div className="clearfix">
<div className="pull-left padding-vertical-10">
<i className="icon fa-eye-slash font-size-24 vertical-align-bottom margin-right-5"></i>
{ translate('INDEX.Z_BALANCE') }
</div>
<span className="pull-right padding-top-10 font-size-22">
{ this.props.ActiveCoin.balance.private ? this.props.ActiveCoin.balance.private : '-' }
</span>
</div>
</div>
</div>
</div>
}
<div className={ this.isNativeMode() ? 'col-lg-3 col-xs-12' :
this.isBasiliskMode() ? 'col-lg-4 col-xs-12' : 'col-lg-4 col-xs-12 hide' }>
<div className="widget widget-shadow"> <div className="widget widget-shadow">
<div className="widget-content"> <div className="widget-content">
<div className="padding-20 padding-top-10"> <div className="padding-20 padding-top-10">
@ -59,7 +87,14 @@ const WalletsBalanceRender = function() {
{ translate('INDEX.INTEREST_EARNED') } { translate('INDEX.INTEREST_EARNED') }
</div> </div>
<span className="pull-right padding-top-10 font-size-22"> <span className="pull-right padding-top-10 font-size-22">
{ this.renderBalance('interest') } { this.props.ActiveCoin.coin } { this.isNativeMode() ?
this.props.Dashboard.progress
&& this.props.Dashboard.progress.interest ? this.props.Dashboard.progress.interest : '-'
:
<span>
{this.renderBalance('interest')} {this.props.ActiveCoin.coin}
</span>
}
</span> </span>
</div> </div>
</div> </div>
@ -67,7 +102,8 @@ const WalletsBalanceRender = function() {
</div> </div>
</div> </div>
<div className={ this.isNativeOrBasiliskCoinMode() ? 'col-lg-4 col-xs-12' : 'col-lg-4 col-xs-12 hide' }> <div className={ this.isNativeMode() ? 'col-lg-3 col-xs-12' :
this.isBasiliskMode() ? 'col-lg-4 col-xs-12' : 'col-lg-4 col-xs-12 hide' }>
<div className="widget widget-shadow"> <div className="widget widget-shadow">
<div className="widget-content"> <div className="widget-content">
<div className="padding-20 padding-top-10"> <div className="padding-20 padding-top-10">
@ -77,7 +113,13 @@ const WalletsBalanceRender = function() {
{ translate('INDEX.TOTAL_BALANCE') } { translate('INDEX.TOTAL_BALANCE') }
</div> </div>
<span className="pull-right padding-top-10 font-size-22"> <span className="pull-right padding-top-10 font-size-22">
{ this.renderBalance('total') } { this.props.ActiveCoin.coin } { this.isNativeMode() ?
this.props.ActiveCoin.balance.total ? this.props.ActiveCoin.balance.total : '-'
:
<span>
{ this.renderBalance('total') } { this.props.ActiveCoin.coin }
</span>
}
</span> </span>
</div> </div>
</div> </div>

2
react/src/components/dashboard/walletsCacheData/walletsCacheData.render.js

@ -1,7 +1,7 @@
import React from 'react'; import React from 'react';
import { translate } from '../../../translate/translate'; import { translate } from '../../../translate/translate';
import { animation } from '../../../util/rc-tree-animate'; import { animation } from '../../../util/rc-tree-animate';
import { TreeNode } from 'rc-tree'; import Tree, { TreeNode } from 'rc-tree';
const WalletsCacheDataRender = function() { const WalletsCacheDataRender = function() {
return ( return (

6
react/src/components/dashboard/walletsNative/walletsNative.render.js

@ -1,7 +1,6 @@
import React from 'react'; import React from 'react';
import WalletsNativeBalance from '../walletsNativeBalance/walletsNativeBalance'; import WalletsBalance from '../walletsBalance/walletsBalance';
import WalletsNativeInfo from '../walletsNativeInfo/walletsNativeInfo'; import WalletsNativeInfo from '../walletsNativeInfo/walletsNativeInfo';
import WalletsNativeReceive from '../walletsNativeReceive/walletsNativeReceive';
import WalletsNativeSend from '../walletsNativeSend/walletsNativeSend'; import WalletsNativeSend from '../walletsNativeSend/walletsNativeSend';
import WalletsNativeSyncProgress from '../walletsNativeSyncProgress/walletsNativeSyncProgress'; import WalletsNativeSyncProgress from '../walletsNativeSyncProgress/walletsNativeSyncProgress';
import WalletsNativeTxHistory from '../walletsNativeTxHistory/walletsNativeTxHistory'; import WalletsNativeTxHistory from '../walletsNativeTxHistory/walletsNativeTxHistory';
@ -26,9 +25,8 @@ const WalletsNativeRender = function() {
<div className="page-content"> <div className="page-content">
<WalletsNativeSyncProgress {...this.props} /> <WalletsNativeSyncProgress {...this.props} />
<div className="row"> <div className="row">
<WalletsNativeBalance {...this.props} /> <WalletsBalance {...this.props} />
<WalletsNativeTxHistory {...this.props} /> <WalletsNativeTxHistory {...this.props} />
<WalletsNativeReceive {...this.props} />
<WalletsNativeSend {...this.props} /> <WalletsNativeSend {...this.props} />
<WalletsNativeInfo {...this.props} /> <WalletsNativeInfo {...this.props} />
</div> </div>

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

@ -1,15 +0,0 @@
import React from 'react';
import WalletsNativeBalanceRender from './walletsNativeBalance.render';
class WalletsNativeBalance extends React.Component {
render() {
if (this.props &&
this.props.ActiveCoin.nativeActiveSection === 'default') {
return WalletsNativeBalanceRender.call(this);
}
return null;
}
}
export default WalletsNativeBalance;

82
react/src/components/dashboard/walletsNativeBalance/walletsNativeBalance.render.js

@ -1,82 +0,0 @@
import React from 'react';
import { translate } from '../../../translate/translate';
const WalletsNativeBalanceRender = function() {
return (
<div className="col-xs-12">
<div className="col-lg-3 col-xs-12">
<div className="widget widget-shadow">
<div className="widget-content white bg-yellow-800">
<div className="padding-20 padding-top-10">
<div className="clearfix">
<div className="pull-left padding-vertical-10">
<i className="icon fa-eye font-size-24 vertical-align-bottom margin-right-5"></i>
{ translate('INDEX.TRANSPARENT_BALANCE') }
</div>
<span className="pull-right padding-top-10 font-size-22">
{ this.props.ActiveCoin.balance.transparent ? this.props.ActiveCoin.balance.transparent : '-' }
</span>
</div>
</div>
</div>
</div>
</div>
<div className="col-lg-3 col-xs-12">
<div className="widget widget-shadow">
<div className="widget-content white bg-blue-grey-800">
<div className="padding-20 padding-top-10">
<div className="clearfix">
<div className="pull-left padding-vertical-10">
<i className="icon fa-eye-slash font-size-24 vertical-align-bottom margin-right-5"></i>
{ translate('INDEX.Z_BALANCE') }
</div>
<span className="pull-right padding-top-10 font-size-22">
{ this.props.ActiveCoin.balance.private ? this.props.ActiveCoin.balance.private : '-' }
</span>
</div>
</div>
</div>
</div>
</div>
<div className="col-lg-3 col-xs-12">
<div className="widget widget-shadow">
<div className="widget-content white bg-cyan-700">
<div className="padding-20 padding-top-10">
<div className="clearfix">
<div className="pull-left padding-vertical-10">
<i className="icon fa-money font-size-24 vertical-align-bottom margin-right-5"></i>
{ translate('INDEX.INTEREST_EARNED') }
</div>
<span className="pull-right padding-top-10 font-size-22">
{ this.props.Dashboard.progress && this.props.Dashboard.progress.interest ? this.props.Dashboard.progress.interest : '-' }
</span>
</div>
</div>
</div>
</div>
</div>
<div className="col-lg-3 col-xs-12">
<div className="widget widget-shadow">
<div className="widget-content white bg-green-600">
<div className="padding-20 padding-top-10">
<div className="clearfix">
<div className="pull-left padding-vertical-10">
<i className="icon fa-bullseye font-size-24 vertical-align-bottom margin-right-5"></i>
{ translate('INDEX.ZT_BALANCE') }
</div>
<span className="pull-right padding-top-10 font-size-22">
{ this.props.ActiveCoin.balance.total ? this.props.ActiveCoin.balance.total : '-' }
</span>
</div>
</div>
</div>
</div>
</div>
</div>
);
};
export default WalletsNativeBalanceRender;

94
react/src/components/dashboard/walletsNativeReceive/walletsNativeReceive.js

@ -1,94 +0,0 @@
import React from 'react';
import {
copyCoinAddress,
getNewKMDAddresses
} from '../../../actions/actionCreators';
import Store from '../../../store';
import {
AddressListRender,
WalletsNativeReceiveRender
} from './walletsNativeReceive.render';
class WalletsNativeReceive 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,
}));
}
copyZAddress(address) {
Store.dispatch(copyCoinAddress(address));
}
renderAddressList(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) =>
AddressListRender.call(
this,
address,
type
)
);
}
return null;
}
getNewAddress(type) {
Store.dispatch(
getNewKMDAddresses(
this.props.ActiveCoin.coin,
type
)
);
}
render() {
if (this.props &&
this.props.ActiveCoin &&
this.props.ActiveCoin.nativeActiveSection === 'receive') {
return WalletsNativeReceiveRender.call(this);
}
return null;
}
}
export default WalletsNativeReceive;

90
react/src/components/dashboard/walletsNativeReceive/walletsNativeReceive.render.js

@ -1,90 +0,0 @@
import React from 'react';
import { translate } from '../../../translate/translate';
export const AddressListRender = function(address, type) {
return (
<tr key={ address.address }>
<td>
<span className={ type === 'public' ? 'label label-default' : 'label label-dark' }>
<i className={ type === 'public' ? 'icon fa-eye' : 'icon fa-eye-slash' }></i>
{ type === 'public' ? translate('IAPI.PUBLIC_SM') : translate('KMD_NATIVE.PRIVATE') }
</span>
<button
className="btn btn-default btn-xs clipboard-edexaddr margin-left-10"
onClick={ () => this.copyZAddress(address.address) }>
<i className="icon wb-copy"></i> { translate('INDEX.COPY') }
</button>
</td>
<td>{ type === 'public' ? address.address : address.address.substring(0, 34) + '...' }</td>
<td>{ address.amount }</td>
<td></td>
</tr>
);
};
export const WalletsNativeReceiveRender = function() {
return (
<div>
<div className="col-xs-12 margin-top-20">
<div className="panel nav-tabs-horizontal">
<div>
<div className="col-xlg-12 col-lg-12 col-sm-12 col-xs-12">
<div className="panel">
<header className="panel-heading">
<div className="panel-actions">
<div
className={ 'dropdown' + (this.state.openDropMenu ? ' open' : '') }
onClick={ this.openDropMenu }>
<a className="dropdown-toggle white btn btn-warning">
<i className="icon md-arrows margin-right-10"></i>
{ translate('INDEX.GET_NEW_ADDRESS') }
<span className="caret"></span>
</a>
<ul className="dropdown-menu dropdown-menu-right">
<li>
<a onClick={ () => this.getNewAddress('public') }>
<i className="icon fa-eye"></i>
{ translate('INDEX.TRANSPARENT_ADDRESS') }
</a>
</li>
<li>
<a onClick={ () => this.getNewAddress('private') }>
<i className="icon fa-eye-slash"></i>
{ translate('INDEX.PRIVATE_Z_ADDRESS') }
</a>
</li>
</ul>
</div>
</div>
<h3 className="panel-title">{ translate('INDEX.RECEIVING_ADDRESS') }</h3>
</header>
<div className="panel-body">
<table className="table table-hover dataTable table-striped">
<thead>
<tr>
<th>{ translate('INDEX.TYPE') }</th>
<th>{ translate('INDEX.ADDRESS') }</th>
<th>{ translate('INDEX.AMOUNT') }</th>
</tr>
</thead>
<tbody>
{ this.renderAddressList('public') }
{ this.renderAddressList('private') }
</tbody>
<tfoot>
<tr>
<th>{ translate('INDEX.TYPE') }</th>
<th>{ translate('INDEX.ADDRESS') }</th>
<th>{ translate('INDEX.AMOUNT') }</th>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
);
};

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

@ -79,7 +79,7 @@ class WalletsNativeSend extends React.Component {
if (this.state.sendFrom) { if (this.state.sendFrom) {
return ( return (
<span> <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"> <span className="text">
[ { this.state.sendFromAmount } { this.props.ActiveCoin.coin } ] [ { this.state.sendFromAmount } { this.props.ActiveCoin.coin } ]
{ this.state.sendFrom } { this.state.sendFrom }
@ -119,7 +119,7 @@ class WalletsNativeSend extends React.Component {
return ( return (
<span className={ `label label-${_satatusDef[opid.status].icon}` }> <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>{ translate(`KMD_NATIVE.${_satatusDef[opid.status].label}`) }</span>
</span> </span>
); );

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

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

56
react/src/components/dashboard/walletsNativeSyncProgress/walletsNativeSyncProgress.js

@ -7,29 +7,40 @@ import {
class WalletsNativeSyncProgress extends React.Component { class WalletsNativeSyncProgress extends React.Component {
renderSyncPercentagePlaceholder() { renderSyncPercentagePlaceholder() {
if (this.props.Dashboard.progress.blocks > 0 && if (this.props.Dashboard.progress &&
this.props.Dashboard.progress.blocks > 0 &&
this.props.Dashboard.progress.longestchain === 0) { this.props.Dashboard.progress.longestchain === 0) {
return ( return (
<div className="progress-bar progress-bar-info progress-bar-striped active full-width font-size-80-percent"> <div className="progress-bar progress-bar-info progress-bar-striped active full-width font-size-80-percent">
<span className="full-width">{ translate('INDEX.SYNC_ERR_LONGESTCHAIN') }</span> <span className="full-width">{ translate('INDEX.SYNC_ERR_LONGESTCHAIN') }</span>
</div> </div>
); );
} else if (this.props.Dashboard.progress.blocks === 0) { } else if (this.props.Dashboard.progress && this.props.Dashboard.progress.blocks === 0) {
return ( return (
<div className="progress-bar progress-bar-info progress-bar-striped active full-width font-size-80-percent"> <div className="progress-bar progress-bar-info progress-bar-striped active full-width font-size-80-percent">
<span className="full-width">{ translate('INDEX.SYNC_ERR_BLOCKS') }</span> <span className="full-width">{ translate('INDEX.SYNC_ERR_BLOCKS') }</span>
</div> </div>
); );
} else { } else {
const syncPercentage = (parseFloat(parseInt(this.props.Dashboard.progress.blocks, 10) * 100 / parseInt(this.props.Dashboard.progress.longestchain, 10)).toFixed(2) + '%').replace('NaN', 0); if (this.props.Dashboard.progress && this.props.Dashboard.progress.block) {
const syncPercentage = (parseFloat(parseInt(this.props.Dashboard.progress.blocks, 10) * 100 / parseInt(this.props.Dashboard.progress.longestchain, 10)).toFixed(2) + '%').replace('NaN', 0);
return ( return (
<div <div
className="progress-bar progress-bar-info progress-bar-striped active font-size-80-percent" className="progress-bar progress-bar-info progress-bar-striped active font-size-80-percent"
style={{ width: syncPercentage }}> style={{ width: syncPercentage }}>
<span style={{ width: syncPercentage }}>{ syncPercentage }</span> | { this.props.Dashboard.progress.blocks } / { this.props.Dashboard.progress.longestchain } | { translate('INDEX.CONNECTIONS') }: { this.props.Dashboard.progress.connections } <span style={{ width: syncPercentage }}>{ syncPercentage }</span> | { this.props.Dashboard.progress.blocks } / { this.props.Dashboard.progress.longestchain } | { translate('INDEX.CONNECTIONS') }: { this.props.Dashboard.progress.connections }
</div> </div>
); );
} else {
return (
<div
className="progress-bar progress-bar-info progress-bar-striped active font-size-80-percent"
style={{ width: '100%' }}>
<span style={{ width: '100%' }}>Loading blocks...</span>
</div>
);
}
} }
} }
@ -57,12 +68,16 @@ class WalletsNativeSyncProgress extends React.Component {
`: ${currentProgress}%` `: ${currentProgress}%`
); );
} else { } else {
return( if (this.props.Dashboard.progress.remoteKMDNode &&
`: ${Math.floor(currentBestChain * 100 / this.props.Dashboard.progress.remoteKMDNode.blocks)}% (blocks ${currentBestChain} / ${this.props.Dashboard.progress.remoteKMDNode.blocks})` this.props.Dashboard.progress.remoteKMDNode.blocks) {
); return(
`: ${Math.floor(currentBestChain * 100 / this.props.Dashboard.progress.remoteKMDNode.blocks)}% (blocks ${currentBestChain} / ${this.props.Dashboard.progress.remoteKMDNode.blocks})`
);
}
} }
} else if (this.props.Settings.debugLog.indexOf('Still rescanning') > -1) { } else if (this.props.Settings.debugLog.indexOf('Still rescanning') > -1) {
const temp = this.props.Settings.debugLog.split(' '); const temp = this.props.Settings.debugLog.split(' ');
let currentProgress;
for (let i = 0; i < temp.length; i++) { for (let i = 0; i < temp.length; i++) {
if (temp[i].indexOf('Progress=') > -1) { if (temp[i].indexOf('Progress=') > -1) {
@ -93,18 +108,19 @@ class WalletsNativeSyncProgress extends React.Component {
} }
renderChainActivationNotification() { renderChainActivationNotification() {
if ((!this.props.Dashboard.progress.blocks && !this.props.Dashboard.progress.longestchain) || if (this.props.Dashboard.progress) {
(this.props.Dashboard.progress.blocks < this.props.Dashboard.progress.longestchain)) { if ((!this.props.Dashboard.progress.blocks && !this.props.Dashboard.progress.longestchain) ||
return ChainActivationNotificationRender.call(this); (this.props.Dashboard.progress.blocks < this.props.Dashboard.progress.longestchain)) {
return ChainActivationNotificationRender.call(this);
}
} else {
return null;
} }
return null;
} }
render() { render() {
if (this.props && if (this.props &&
this.props.Dashboard && this.props.Dashboard) {
this.props.Dashboard.progress) {
return WalletsNativeSyncProgressRender.call(this); return WalletsNativeSyncProgressRender.call(this);
} }

26
react/src/components/dashboard/walletsNotariesList/walletsNotariesList.render.js

@ -4,19 +4,21 @@ import Tree, { TreeNode } from 'rc-tree';
import { animation } from '../../../util/rc-tree-animate'; import { animation } from '../../../util/rc-tree-animate';
export const NotariesListRender = function (node, index) { export const NotariesListRender = function (node, index) {
<TreeNode return (
title={ `Node ${index}` }
key={ `node-${index}` }>
<TreeNode
key={ `node-${index}-btc` }
title={ `BTC: ${node.BTCaddress}` } />
<TreeNode
key={ `node-${index}-kmd` }
title={ `KMD: ${node.KMDaddress}` } />
<TreeNode <TreeNode
key={ `node-${index}-pubkey` } title={ `Node ${index}` }
title={ `Pubkey: ${node.pubkey}` } /> key={ `node-${index}` }>
</TreeNode> <TreeNode
key={ `node-${index}-btc` }
title={ `BTC: ${node.BTCaddress}` } />
<TreeNode
key={ `node-${index}-kmd` }
title={ `KMD: ${node.KMDaddress}` } />
<TreeNode
key={ `node-${index}-pubkey` }
title={ `Pubkey: ${node.pubkey}` } />
</TreeNode>
);
}; };
export const WalletsNotariesListRender = function () { export const WalletsNotariesListRender = function () {

4
react/src/config.js

@ -6,4 +6,8 @@ module.exports = {
openAlias: false, openAlias: false,
debug: true, debug: true,
defaultLang: 'EN', defaultLang: 'EN',
cli: {
passthru: true,
default: true
}
}; };

2
react/www/index.html

@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui"> <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
<meta name="description" content="bootstrap admin template"> <meta name="description" content="bootstrap admin template">
<meta name="author" content="SuperNET Team"> <meta name="author" content="SuperNET Team">
<title>Agama (v0.2.0.1a-beta)</title> <title>Agama (v0.2.0.2a-beta)</title>
<link rel="apple-touch-icon" href="assets/images/android-chrome-192x192.png"> <link rel="apple-touch-icon" href="assets/images/android-chrome-192x192.png">
<link rel="icon" type="image/png" href="assets/images/favicon-32x32.png" sizes="32x32"> <link rel="icon" type="image/png" href="assets/images/favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="assets/images/favicon-194x194.png" sizes="194x194"> <link rel="icon" type="image/png" href="assets/images/favicon-194x194.png" sizes="194x194">

Loading…
Cancel
Save