-
Notifications
You must be signed in to change notification settings - Fork 495
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(@embark/plugins): introduce API to register a contract factory
This commit introduces two new plugin APIs `registerTestContractFactory()` and `registerCustomContractGenerator()`, which can be used to register a factory function for the creation of web3 contract instances within tests, and custom code generation for `embark console` respectively. Example: ``` // some.plugin.js module.exports = function (embark) { embark.registerTestContractFactory(function (contractRecipe, web3) { // do something with web3 and contractRecipe and return contract instance here }); }; ``` **Notice that**: - This factory function is used for contract instance creation within tests. A `contractRecipe` and a `web3` instance is accessible within the factory. Example: ``` // some.plugin.js module.exports = function (embark) { embark.registerCustomContractGenerator(function (contractRecipe) { // returns code string that will be eval'ed }); }; ``` **Notice that**: - Once registered, this generator will be used for **all** contract instances that will be created for `embark console`, including built-in once like ENSRegistry. - While this does affect contract creation in client-side code, it doesn't actually affect the instances created for deployment hooks **if** deployment hooks are written as functions. Closes #1066
- Loading branch information
Showing
4 changed files
with
58 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters