0

Using Drizzle ran into a problem. Can anyone help? There are several get functions

1-st works fine both in the truffle console and at the frontend, function without arguments

truffle console:

input: this.Ethnote.deployed().then(instance => { return instance.getNotebooksCount();}).then(result => {console.log(result);}).catch(e => {console.log(e);});

output: BigNumber { s: 1, e: 0, c: [ 1 ] }

react:

input: <ContractData contract="Ethnote" method="getNotebooksCount "/>

output: 1

2-nd works only in the truffle console, on the front it falls with an error, function with argument 0 (Notebook index) and returns several outputs

truffle console:

input: this.Ethnote.deployed().then(instance => { return instance.getNotebook(0);}).then(result => {console.log(result);}).catch(e => {console.log(e);});

output: [ '0x627306090abab3a6e1400e9345bc60c78a8bef57', 'inbox', BigNumber { s: 1, e: 9, c: [ 1521898678 ] }, BigNumber { s: 1, e: 9, c: [ 1521898678 ] }, BigNumber { s: 1, e: 0, c: [ 0 ] } ]

react:

input: <ContractData contract="Ethnote" method="getNotebook" methodArgs={[0]} />

output: TypeError: str.slice is not a function at Object.keccak256 (http://localhost:3100/static/js/bundle.js:60919:14) at Object.sha3 (http://localhost:3100/static/js/bundle.js:60556:29) at DrizzleContract.generateArgsHash (http://localhost:3100/static/js/bundle.js:69698:39) at Function.cacheCall (http://localhost:3100/static/js/bundle.js:69637:32) at new ContractData (http://localhost:3100/static/js/bundle.js:146699:130) at http://localhost:3100/static/js/bundle.js:27170:19 at measureLifeCyclePerf (http://localhost:3100/static/js/bundle.js:26951:13) at ReactCompositeComponentWrapper._constructComponentWithoutOwner (http://localhost:3100/static/js/bundle.js:27169:17) at ReactCompositeComponentWrapper._constructComponent (http://localhost:3100/static/js/bundle.js:27160:20) at ReactCompositeComponentWrapper.mountComponent (http://localhost:3100/static/js/bundle.js:27063:22) at Object.mountComponent (http://localhost:3100/static/js/bundle.js:19468:36) at ReactCompositeComponentWrapper.performInitialMount (http://localhost:3100/static/js/bundle.js:27246:35) at ReactCompositeComponentWrapper.mountComponent (http://localhost:3100/static/js/bundle.js:27133:22) at Object.mountComponent (http://localhost:3100/static/js/bundle.js:19468:36) at ReactCompositeComponentWrapper.performInitialMount (http://localhost:3100/static/js/bundle.js:27246:35) at ReactCompositeComponentWrapper.mountComponent (http://localhost:3100/static/js/bundle.js:27133:22) at Object.mountComponent (http://localhost:3100/static/js/bundle.js:19468:36) at ReactDOMComponent.mountChildren (http://localhost:3100/static/js/bundle.js:26268:45) at ReactDOMComponent._createInitialChildren (http://localhost:3100/static/js/bundle.js:23295:33) at ReactDOMComponent.mountComponent (http://localhost:3100/static/js/bundle.js:23114:13) at Object.mountComponent (http://localhost:3100/static/js/bundle.js:19468:36) at ReactDOMComponent.mountChildren (http://localhost:3100/static/js/bundle.js:26268:45) From previous event: at new DrizzleContract (http://localhost:3100/static/js/bundle.js:69583:27) at Drizzle.getContracts (http://localhost:3100/static/js/bundle.js:69469:58) at http://localhost:3100/static/js/bundle.js:69450:17

1

I am struggling with this very thing, when I step though with the debugger it appears that drizzle(?) is going through the whole contract until it hits an undefined str.

At the moment I am not using contractData, still figuring it out, instead I use (modified to your code):

getThePrayers(accounts) {
this.contracts.Ethnote.methods. getNotebooksCount().call({from: accounts[0]})
.then(function(_number){
  self.setState({
    notebookCount: _number.toNumber()
 });
});

}

in the App constructor I have:

this.state = {
  notebookCount: 0
}

and use the following in the html

{notebookCount}

A bit annoying that a simple call to a view function returns a promise.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.