embarklabs / embark

Framework for serverless Decentralized Applications using Ethereum, IPFS and other platforms
https://framework.embarklabs.io/
MIT License
3.79k stars 495 forks source link

Contract function calls don't pass options to send & doesn't correctly read struct values #1729

Open ewingrj opened 5 years ago

ewingrj commented 5 years ago

Bug Report

Summary

Current behavior

When accessing a contract method directly on the generated js Contract instance instead of the Contract.methods object, the following bugs are present:

  1. When making a call that returns a struct ex:Contract.records(1), the error TypeError: CreateListFromArrayLike called on non-object is thrown

  2. When making a send, the provided options are ignored ex: Contract.logSender({from: 0x...}), the default account will always be used for the send.

How to reproduce

Run the tests in the repo https://github.com/ewingrj/embark_bug.

First test is for the first issue, Second for the second issue.

Expected behavior

Any contract functions accessed directly via Contract.func_name should behave the same as if they were accessed via Contract.methods.func_name.

If you encounter an error, please create a logfile using the following command and post the output here

$ embark run --nodashboard --logfile log.txt --loglevel trace

Please provide additional information about your system

OS: Embark Version: 4.1.0-beta.5 Node Version: NPM Version:

Sometimes issues are related to Embark's installation. Can you provide information on how Embark was installed?

ewingrj commented 5 years ago

A followup on the issue of opts not being passed...

This appears to be a bug in web3@1.0.0-beta.37. If cb is undefined or null, the opts are ignored. If I set cb to an empty function, then it works correctly.

1737 may fix this issue (or at least part of it). Hopefully web3 1.2 and up will be less buggy going forward 🙏

ewingrj commented 5 years ago

This is still an issue even after updating to web3 1.2.1 :(

jrainville commented 5 years ago

Yeah, it's not that surprising since Web3 1.2 is really beta.37 😉