Browse Source

AGP-299, Combine functions

v0.25
Miika Turunen 7 years ago
parent
commit
d8c82d4791
  1. 52
      react/src/actions/actions/getTxDetails.js
  2. 3
      react/src/components/dashboard/walletsTxInfo/walletsTxInfo.js

52
react/src/actions/actions/getTxDetails.js

@ -5,7 +5,7 @@ import Config from '../../config';
export function getTxDetails(coin, txid, type) {
return new Promise((resolve, reject) => {
const payload = {
let payload = {
mode: null,
chain: coin,
cmd: 'gettransaction',
@ -13,44 +13,18 @@ export function getTxDetails(coin, txid, type) {
txid
],
};
fetch(
`http://127.0.0.1:${Config.agamaPort}/shepherd/cli`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ payload: payload })
},
)
.catch(function(error) {
console.log(error);
dispatch(
triggerToaster(
'getTransaction',
'Error',
'error'
)
);
})
.then(response => response.json())
.then(json => {
resolve(json.result ? json.result : json);
})
});
}
export function getRawTxDetails(coin, txid) {
return new Promise((resolve, reject) => {
const payload = {
mode: null,
chain: coin,
cmd: 'getrawtransaction',
params: [
txid,
1
],
};
if(type==='raw') {
payload = {
mode: null,
chain: coin,
cmd: 'getrawtransaction',
params: [
txid,
1
],
};
}
fetch(
`http://127.0.0.1:${Config.agamaPort}/shepherd/cli`, {

3
react/src/components/dashboard/walletsTxInfo/walletsTxInfo.js

@ -5,7 +5,6 @@ import { sortByDate } from '../../../util/sort';
import {
toggleDashboardTxInfoModal,
getTxDetails,
getRawTxDetails,
} from '../../../actions/actionCreators';
import Store from '../../../store';
import WalletsTxInfoRender from './walletsTxInfo.render';
@ -52,7 +51,7 @@ class WalletsTxInfo extends React.Component {
}
loadRawTxDetails(coin, txid) {
getRawTxDetails(coin, txid)
getTxDetails(coin, txid, 'raw')
.then((json) => {
this.setState(Object.assign({}, this.state, {
rawTxDetails: json,

Loading…
Cancel
Save