OSDN Git Service

update page with list-transaction to get-transactions
authorZhiting Lin <zlin035@uottawa.ca>
Fri, 5 Jul 2019 06:42:15 +0000 (14:42 +0800)
committerZhiting Lin <zlin035@uottawa.ca>
Fri, 5 Jul 2019 06:42:15 +0000 (14:42 +0800)
src/features/transactions/actions.js
src/features/transactions/components/Show.jsx
src/sdk/api/transactions.js

index 0679ac0..4add742 100644 (file)
@@ -278,11 +278,40 @@ const buildTransaction = (builderBlock) =>{
   return chainClient().transactions.build(builderFunction)
 }
 
+const getTransaction = (params) => {
+
+  return (dispatch) => {
+    const promise = chainClient().transactions.getTransaction(params)
+
+    promise.then(
+      (resp) => {
+        if(resp.status == 'fail'){
+          dispatch({type: 'ERROR', payload: { 'message': resp.msg}})
+        }else{
+          resp.data = [resp.data]
+          dispatch({
+            type: `RECEIVED_${type.toUpperCase()}_ITEMS`,
+            param: resp
+          })
+        }
+      }
+    ).catch(error=>{
+      if(error.body){
+        dispatch({type: 'ERROR', payload: { 'message': error.body.msg}})
+      }
+      else throw error
+    })
+
+    return promise
+  }
+}
+
 export default {
   ...list,
   ...form,
   decode,
   getAddresses,
   estimateGas,
-  buildTransaction
+  buildTransaction,
+  getTransaction
 }
index 472e3da..56d166a 100644 (file)
@@ -162,7 +162,7 @@ const mapStateToProps = (state, ownProps) => ({
 })
 
 const mapDispatchToProps = ( dispatch ) => ({
-  fetchItem: (id) => dispatch(actions.fetchItems({id: `${id}`}))
+  fetchItem: (id) => dispatch(actions.getTransaction({tx_id: `${id}`}))
 })
 
 export default connect(
index df9f128..47c09bf 100644 (file)
@@ -71,6 +71,9 @@ const transactionsAPI = (client) => {
       Object.assign({}, params, {detail: true}),
       {cb}),
 
+    getTransaction: (params, cb) => shared.query(client, 'transactions', '/get-transaction',
+      params, {cb}),
+
     queryAll: (params, processor, cb) => shared.queryAll(client, 'transactions', params, processor, cb),
 
     build: (builderBlock, cb) => {