mirror of
https://github.com/embarklabs/embark.git
synced 2025-02-18 08:36:51 +00:00
fix(@embark/code-generator): use plugins for contract generation
`contractGeneration` plugins were only used in the Embark console Now they are used to generate the Dapp artifacts too
This commit is contained in:
parent
536a4029ba
commit
c87d7da4cc
@ -56,7 +56,7 @@ class CodeGenerator {
|
|||||||
|
|
||||||
this.events.setCommandHandler('code-generator:contract', (contractName, cb) => {
|
this.events.setCommandHandler('code-generator:contract', (contractName, cb) => {
|
||||||
this.events.request('contracts:contract', contractName, (contract) => {
|
this.events.request('contracts:contract', contractName, (contract) => {
|
||||||
this.buildContractJS(contractName, this.generateContractJSON(contract, contract), cb);
|
this.buildContractJS(contract, cb);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -457,7 +457,23 @@ class CodeGenerator {
|
|||||||
}, "");
|
}, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
buildContractJS(contractName, contractJSON, cb) {
|
buildContractJS(contract, cb) {
|
||||||
|
const contractName = contract.className;
|
||||||
|
|
||||||
|
if (this.plugins) {
|
||||||
|
const contractsPlugins = this.plugins.getPluginsFor('contractGeneration');
|
||||||
|
if (contractsPlugins.length > 0) {
|
||||||
|
let result = '';
|
||||||
|
contractsPlugins.forEach(function (plugin) {
|
||||||
|
result += plugin.generateContracts({contracts: {[contractName]: contract}});
|
||||||
|
});
|
||||||
|
return this.generateArtifact(result, contractName + '.js', constants.dappArtifacts.contractsJs, (err, path, _updated) => {
|
||||||
|
cb(err, path);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const contractJSON = this.generateContractJSON(contractName, contract);
|
||||||
const contractCode = `
|
const contractCode = `
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user