trufflesuite / drizzle-legacy

Reactive Ethereum datastore for dapp UIs.
http://truffleframework.com/docs/drizzle/getting-started
MIT License
503 stars 128 forks source link

Calling function with multiple return values #207

Closed JYisus closed 5 years ago

JYisus commented 5 years ago

When I call a function that returns multiple values, the value that the object object of Drizzle takes is Null instead of the vector with the elements that I need. This is the Solidity code of that function: function getRequest(uint _id) public view returns (address, uint) { return (userRequest[msg.sender][_id].user, userRequest[msg.sender][_id].resource); }

And this is how I call it: // In the componentDidMount() //... const dataKey = contract.methods['getRequest'].cacheCall(this.props.idReq); this.setState({ dataKey}); //... // In the render() const { ControlAcceso } = this.props.drizzleState.contracts; const request = ControlAcceso.getRequest[this.state.dataKey]; console.log(request && request)

The result of this console.log is: 2019-04-04 13 53 25 localhost 1da9db05cf75

cds-amal commented 5 years ago

Hello @JYisus,

Thanks for raising this issue. Does the render function check that the contract is initialized, and its data is fetched? See this example for how to check the preconditions: drizzle-react-components

If the render function is guarded by checks for initialization and data fetched and the issue remains, could you share a sample repo so we could reproduce the issue?

Thanks in advance!

JYisus commented 5 years ago

Hi @cds-amal , I solved it restarting the server, i don't know what was wrong, but now it's working. Thank you for the help!