Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unreliable array test in Contract package #1013

Merged
merged 2 commits into from
Sep 15, 2017
Merged

Fix unreliable array test in Contract package #1013

merged 2 commits into from
Sep 15, 2017

Conversation

microraptor
Copy link
Contributor

@microraptor microraptor commented Sep 3, 2017

Using node.js 6.11.2 I get the following error when trying to instantiate contracts:

> jsonInterface instanceof Array
true
> new web3.eth.Contract(jsonInterface)
Error: You must provide the json interface of the contract when instatiating a contract object.

Although jsonInterface instanceof Array evaluates to true, the exact same test condition evaluates to false within the Contract constructor with the passed down json interface. Using either Array.isArray(jsonInterface) or toString.call(jsonInterface) === '[object Array]' as a test condition instead fixes the issue.

Also the typo in the error message got corrected.

microraptor and others added 2 commits September 3, 2017 04:29
Using node.js 6.11.2 I get the following error when trying to instantiate contracts:
> jsonInterface instanceof Array
true
> new web3.eth.Contract(jsonInterface)
Error: You must provide the json interface of the contract when instatiating a contract object.

Although jsonInterface instanceof Array evaluates to true, the exact same test condition evaluates to false within the Contract constructor with the passed down json interface. Using either "Array.isArray(jsonInterface)" or "toString.call(jsonInterface) === '[object Array]'" as a test condition instead fixes the issue.

Also the typo in the error message got corrected.
@frozeman frozeman merged commit 18dffea into web3:1.0 Sep 15, 2017
@frozeman
Copy link
Contributor

Thanks for the find!

nachomazzara pushed a commit to nachomazzara/web3.js that referenced this pull request Jun 4, 2020
Using node.js 6.11.2 I get the following error when trying to instantiate contracts:
> jsonInterface instanceof Array
true
> new web3.eth.Contract(jsonInterface)
Error: You must provide the json interface of the contract when instatiating a contract object.

Although jsonInterface instanceof Array evaluates to true, the exact same test condition evaluates to false within the Contract constructor with the passed down json interface. Using either "Array.isArray(jsonInterface)" or "toString.call(jsonInterface) === '[object Array]'" as a test condition instead fixes the issue.

Also the typo in the error message got corrected.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants