-
Notifications
You must be signed in to change notification settings - Fork 495
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
Feature Request: allow plugins to generate contract classes to be used in test,console, & dapps #1066
Comments
@perissology Hey man, I was just looking into this and having a bit of a hard time following what exactly you're looking for as there's a bit information lacking. After having a call with @jrainville as well on this, to sync up on both of our interpretations of this issue, we thought it'd be better to reach out to you to ask what your intention is. Here's our understanding (consider that this involved a lot of self interpretation):
Correct, this API enables you to write a plugin which controls what the code looks like that'll be used later in the dapp to create (web3) instances of your contracts.
So this sounds like, you'd like to write a plugin, which controls the same thing, just for tests, as the contract instances for tests are currently completely controlled by Embark (we actually create those instances in memory and monkey-patch Is that correct, or are we on a wrong path here? Looking forward to hearing back from you! |
Quick update: had another chat meanwhile with @iurimatias and he could clarify and confirm that assumption above. |
exactly. Would also be nice if these were loaded when you use |
This commit introduces a new API `registerTestContractFactory()` which can be used to register a factory function for the creation of web3 contract instances in the testing environment. Example: ``` // some.plugin.js module.exports = function (embark) { embark.registerTestContractFactory((contractRecipe, web3) => { // do something with web3 and contractRecipe and return contract instance here }); }; ``` Closes #1066
This commit introduces a new API `registerContractFactory()` which can be used to register a factory function for the creation of web3 contract instances. Example: ``` // some.plugin.js module.exports = function (embark) { embark.registerContractFactory(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. - It's also used for `EmbarkJS.Blockchain.Contract` within `embark console`. In that scenario, this function has to be a constructor function and therefore cannot be registered using fat arrow functions. Also, we don't control what gets passed to that function in that scenario. Closes #1066
This commit introduces a new API `registerContractFactory()` which can be used to register a factory function for the creation of web3 contract instances. Example: ``` // some.plugin.js module.exports = function (embark) { embark.registerContractFactory(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. - It's also used for `EmbarkJS.Blockchain.Contract` within `embark console`. In that scenario, this function has to be a constructor function and therefore cannot be registered using fat arrow functions. Also, we don't control what gets passed to that function in that scenario. Closes #1066
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
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
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 Always use custom generator and fallback to vanilla
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 Always use custom generator and fallback to vanilla
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 Always use custom generator and fallback to vanilla
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 Always use custom generator and fallback to vanilla
Feature Request
Summary
Currently there is the method
registerContractsGeneration
that plugins can use. However, apparently this only affects the code loaded by the dapp.It would be great if there was a hook that was called to generate the class instances for tests and console use.
This would greatly simplify the adoption process of converting an existing codebases over to using embark. Conversion would be as simple as minimal embark configuration and writing a simple plugin for the js instances their code is already using (or use an existing plugin). Then they are using embark and get cool features like code coverage, etc fairly painlessly.
A
truffle
compatible plugin would be a great 2nd plugin after moving the existing embark code to a plugin.The text was updated successfully, but these errors were encountered: