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

Allow configuring custom web3 instance #38

Merged
merged 25 commits into from May 10, 2019

Conversation

frangio
Copy link
Contributor

@frangio frangio commented May 9, 2019

Fixes #35

Removes the assumption that there is a global web3 (as in a Truffle environment) by adding a mechanism to manually configure the web3 instance. Also allows using in Truffle migrations (OpenZeppelin/openzeppelin-contracts#1743).

require('openzeppelin-test-helpers/configure')({ web3: ... });

Also where possible replaces web3.utils by the web3-utils package.

Copy link
Contributor

@nventuro nventuro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to add the new integration test to the .travis.yaml file for it to actually run.

package.json Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
inject-web3.js Outdated Show resolved Hide resolved
@frangio frangio requested a review from nventuro May 9, 2019 21:52
@frangio
Copy link
Contributor Author

frangio commented May 9, 2019

Sorry, let me add some documentation and a changelog entry.

@frangio frangio changed the title Remove assumption of global web3 Allow configuring custom web3 instance May 10, 2019
@frangio
Copy link
Contributor Author

frangio commented May 10, 2019

@nventuro Done.

I also changed the API slightly. It is now called configure and receives an object. Additionally, it no longer returns the helpers, forcing you to get them as another step. This makes it clear that you are first expected to configure, and only afterwards use the library.

require('openzeppelin-test-helpers/configure')({ web3 });
const { expectEvent } = require('openzeppelin-test-helpers');

Copy link
Contributor

@nventuro nventuro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fantastic @frangio, thanks a lot!

configure.js Show resolved Hide resolved
@frangio frangio merged commit 401e0bd into OpenZeppelin:master May 10, 2019
@frangio frangio deleted the reduce-dependencies branch May 10, 2019 23:50
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.

Using the helpers outside of Truffle (i.e. remove assumption of global web3)
2 participants