This is my contract:
enum State { Active, Refunding, Pending, Releasing}
function state(uint orderid) public view returns (State) {
return State.Releasing;
}
In one Javascript to interact with contract:
async getState(order_id) {
const contractInstance = await this.contract.deployed()
//const status = ['Active', 'Refunding', 'Pending', 'Releasing']
return contractInstance.state.call(order_id);
}
In another javascript to call that function:
case RELEASE_PAYMENT:
console.log("order_id in orderReducer:",action.id);
(new PaypalContract())
.releasePayment(action.id)
.then(() => (new PaypalContract()).getState(action.id))
.then((e)=> {
console.log("status in orderReducer:",e)
return{
...state,
orderStatus:e
}
})
return{
...state,
orderStatus:'Releasing'
}
From web dev tool, I can see the returned 'e' is always a object, not a string value I expected. Any ideas?
Another question is about react, it looks the react just render once with the first returned state, after I got 'e' from contract, it won't render with the updated state.
Thanks.
e
is a promise object which you need to resolve in order to get the actual value that you seek to get.