Miika Turunen
7 years ago
4 changed files with 226 additions and 98 deletions
@ -0,0 +1,79 @@ |
|||
import { |
|||
triggerToaster |
|||
} from '../actionCreators'; |
|||
import Config from '../../config'; |
|||
|
|||
export function getTxDetails(coin, txid, type) { |
|||
return new Promise((resolve, reject) => { |
|||
const payload = { |
|||
mode: null, |
|||
chain: coin, |
|||
cmd: 'gettransaction', |
|||
params: [ |
|||
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 |
|||
], |
|||
}; |
|||
|
|||
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); |
|||
}) |
|||
}); |
|||
} |
Loading…
Reference in new issue