Browse Source

native rpc addr balance

all-modes
pbca26 8 years ago
parent
commit
5eb58cd90e
  1. 101
      react/src/actions/actions/addressBalance.js
  2. 74
      react/src/actions/actions/iguanaHelpers.js
  3. 4
      react/src/actions/actions/nativeBalance.js
  4. 2
      react/src/actions/actions/nativeSyncInfo.js
  5. 2
      react/src/actions/actions/nativeTxHistory.js

101
react/src/actions/actions/addressBalance.js

@ -106,20 +106,46 @@ export function getKMDAddressesNative(coin, mode, currentAddress) {
}
})
} else {
if (Config.cli.default &&
mode === 'native') {
payload = {
mode: null,
chain: coin,
cmd: payload.function,
params: [""]
};
}
const _timestamp = Date.now();
dispatch(logGuiHttp({
'timestamp': _timestamp,
'function': 'getKMDAddressesNative',
'type': 'post',
'url': `http://127.0.0.1:${Config.iguanaCorePort}`,
'url': Config.cli.default ? `http://127.0.0.1:${Config.agamaPort}/shepherd/cli` : `http://127.0.0.1:${Config.iguanaCorePort}`,
'payload': payload,
'status': 'pending',
}));
fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, {
let _fetchConfig = {
method: 'POST',
body: JSON.stringify(payload),
})
};
if (Config.cli.default === true &&
mode === 'native') {
_fetchConfig = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ 'payload': payload }),
};
}
fetch(
Config.cli.default && mode === 'native' ? `http://127.0.0.1:${Config.agamaPort}/shepherd/cli` : `http://127.0.0.1:${Config.iguanaCorePort}`,
_fetchConfig
)
.catch(function(error) {
console.log(error);
dispatch(logGuiHttp({
@ -142,7 +168,7 @@ export function getKMDAddressesNative(coin, mode, currentAddress) {
'status': 'success',
'response': json,
}));
resolve(json);
resolve(Config.cli.default && mode === 'native' ? json.result : json);
})
}
});
@ -286,16 +312,40 @@ export function getKMDAddressesNative(coin, mode, currentAddress) {
'timestamp': _timestamp,
'function': 'getKMDAddressesNative+ZBalance',
'type': 'post',
'url': `http://127.0.0.1:${Config.iguanaCorePort}`,
'url': Config.cli.default ? `http://127.0.0.1:${Config.agamaPort}/shepherd/cli` : `http://127.0.0.1:${Config.iguanaCorePort}`,
'payload': payload,
'status': 'pending',
}));
fetch(`http://127.0.0.1:${Config.iguanaCorePort}`,
{
let _fetchConfig = {
method: 'POST',
body: JSON.stringify(payload),
})
};
if (Config.cli.default === true &&
mode === 'native') {
payload = {
mode: null,
chain: coin,
cmd: 'z_getbalance',
params: [
_address
]
};
_fetchConfig = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ 'payload': payload }),
};
}
fetch(
Config.cli.default && mode === 'native' ? `http://127.0.0.1:${Config.agamaPort}/shepherd/cli` : `http://127.0.0.1:${Config.iguanaCorePort}`,
_fetchConfig
)
.catch(function(error) {
console.log(error);
dispatch(logGuiHttp({
@ -329,6 +379,10 @@ export function getKMDAddressesNative(coin, mode, currentAddress) {
)
);
} else {
if (Config.cli.default &&
mode === 'native') {
json = json.result;
}
resolve(json);
newAddressArray[1][index] = {
address: _address,
@ -449,10 +503,33 @@ export function getKMDAddressesNative(coin, mode, currentAddress) {
'status': 'pending',
}));
fetch(`http://127.0.0.1:${(Config.useBasiliskInstance && mode === 'basilisk' ? Config.iguanaCorePort + 1 : Config.iguanaCorePort)}`, {
let _fetchConfig = {
method: 'POST',
body: JSON.stringify(payload),
})
};
if (Config.cli.default === true &&
mode === 'native') {
payload = {
mode: null,
chain: coin,
cmd: payload.function,
params: payload.params
};
_fetchConfig = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ 'payload': payload }),
};
}
fetch(
Config.cli.default && mode === 'native' ? `http://127.0.0.1:${Config.agamaPort}/shepherd/cli` : `http://127.0.0.1:${(Config.useBasiliskInstance && mode === 'basilisk' ? Config.iguanaCorePort + 1 : Config.iguanaCorePort)}`,
_fetchConfig
)
.catch(function(error) {
console.log(error);
dispatch(logGuiHttp({
@ -470,6 +547,10 @@ export function getKMDAddressesNative(coin, mode, currentAddress) {
})
.then(response => response.json())
.then(function(json) {
if (Config.cli.default &&
mode === 'native') {
json = json.result;
}
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'success',

74
react/src/actions/actions/iguanaHelpers.js

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

4
react/src/actions/actions/nativeBalance.js

@ -35,7 +35,7 @@ export function getKMDBalanceTotal(coin) {
if (Config.cli.default === true) {
payload = {
mode: null,
coin,
chain: coin,
cmd: 'z_gettotalbalance'
};
}
@ -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 ? json.result : json) : 0,
balance: json && !json.error ? (Config.cli.default === true ? json.result : json) : 0,
}
}

2
react/src/actions/actions/nativeSyncInfo.js

@ -85,7 +85,7 @@ export function getSyncInfoNative(coin, skipDebug) {
if (Config.cli.default === true) {
payload = {
mode: null,
coin,
chain: coin,
cmd: 'getinfo'
};
}

2
react/src/actions/actions/nativeTxHistory.js

@ -34,7 +34,7 @@ export function getNativeTxHistory(coin) {
if (Config.cli.default === true) {
payload = {
mode: null,
coin,
chain: coin,
cmd: 'listtransactions'
};
}

Loading…
Cancel
Save