mirror of https://github.com/embarklabs/embark.git
refactor generateContractsJson
This commit is contained in:
parent
cf999ce997
commit
5f64376c84
|
@ -46,68 +46,78 @@ class CodeGenerator {
|
||||||
// deprecated events; to remove in embark 2.7.0
|
// deprecated events; to remove in embark 2.7.0
|
||||||
this.events.setCommandHandlerOnce('abi-vanila', function(cb) {
|
this.events.setCommandHandlerOnce('abi-vanila', function(cb) {
|
||||||
let vanillaABI = self.generateABI({useEmbarkJS: false});
|
let vanillaABI = self.generateABI({useEmbarkJS: false});
|
||||||
let contractsJSON = self.generateContractsJSON();
|
|
||||||
|
|
||||||
|
this.events.request("contracts:list", (contractsList) => {
|
||||||
|
let contractsJSON = self.generateContractsJSON(contractsList);
|
||||||
cb(vanillaABI, contractsJSON);
|
cb(vanillaABI, contractsJSON);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
this.events.setCommandHandlerOnce('abi', function(cb) {
|
this.events.setCommandHandlerOnce('abi', function(cb) {
|
||||||
let embarkJSABI = self.generateABI({useEmbarkJS: true});
|
let embarkJSABI = self.generateABI({useEmbarkJS: true});
|
||||||
let contractsJSON = self.generateContractsJSON();
|
this.events.request("contracts:list", (contractsList) => {
|
||||||
|
let contractsJSON = self.generateContractsJSON(contractsList);
|
||||||
cb(embarkJSABI, contractsJSON);
|
cb(embarkJSABI, contractsJSON);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
this.events.setCommandHandlerOnce('abi-contracts-vanila', function(cb) {
|
this.events.setCommandHandlerOnce('abi-contracts-vanila', function(cb) {
|
||||||
let vanillaContractsABI = self.generateContracts(false, true, false);
|
let vanillaContractsABI = self.generateContracts(false, true, false);
|
||||||
let contractsJSON = self.generateContractsJSON();
|
self.events.request("contracts:list", (contractsList) => {
|
||||||
|
let contractsJSON = self.generateContractsJSON(contractsList);
|
||||||
cb(vanillaContractsABI, contractsJSON);
|
cb(vanillaContractsABI, contractsJSON);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
this.events.setCommandHandlerOnce('abi-vanila-deployment', function(cb) {
|
this.events.setCommandHandlerOnce('abi-vanila-deployment', function(cb) {
|
||||||
let vanillaABI = self.generateABI({useEmbarkJS: false, deployment: true});
|
let vanillaABI = self.generateABI({useEmbarkJS: false, deployment: true});
|
||||||
let contractsJSON = self.generateContractsJSON();
|
self.events.request("contracts:list", (contractsList) => {
|
||||||
|
let contractsJSON = self.generateContractsJSON(contractsList);
|
||||||
cb(vanillaABI, contractsJSON);
|
cb(vanillaABI, contractsJSON);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// new events
|
// new events
|
||||||
this.events.setCommandHandlerOnce('code-vanila', function(cb) {
|
this.events.setCommandHandlerOnce('code-vanila', function(cb) {
|
||||||
let vanillaABI = self.generateABI({useEmbarkJS: false});
|
let vanillaABI = self.generateABI({useEmbarkJS: false});
|
||||||
let contractsJSON = self.generateContractsJSON();
|
self.events.request("contracts:list", (contractsList) => {
|
||||||
|
let contractsJSON = self.generateContractsJSON(contractsList);
|
||||||
cb(vanillaABI, contractsJSON);
|
cb(vanillaABI, contractsJSON);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
this.events.setCommandHandlerOnce('code', function(cb) {
|
this.events.setCommandHandlerOnce('code', function(cb) {
|
||||||
let embarkJSABI = self.generateABI({useEmbarkJS: true});
|
let embarkJSABI = self.generateABI({useEmbarkJS: true});
|
||||||
let contractsJSON = self.generateContractsJSON();
|
self.events.request("contracts:list", (contractsList) => {
|
||||||
|
let contractsJSON = self.generateContractsJSON(contractsList);
|
||||||
cb(embarkJSABI, contractsJSON);
|
cb(embarkJSABI, contractsJSON);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
this.events.setCommandHandlerOnce('code-contracts-vanila', function(cb) {
|
this.events.setCommandHandlerOnce('code-contracts-vanila', function(cb) {
|
||||||
let vanillaContractsABI = self.generateContracts(false, true, false);
|
let vanillaContractsABI = self.generateContracts(false, true, false);
|
||||||
let contractsJSON = self.generateContractsJSON();
|
self.events.request("contracts:list", (contractsList) => {
|
||||||
|
let contractsJSON = self.generateContractsJSON(contractsList);
|
||||||
cb(vanillaContractsABI, contractsJSON);
|
cb(vanillaContractsABI, contractsJSON);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
this.events.setCommandHandlerOnce('code-vanila-deployment', function(cb) {
|
this.events.setCommandHandlerOnce('code-vanila-deployment', function(cb) {
|
||||||
let vanillaABI = self.generateABI({useEmbarkJS: false, deployment: true});
|
let vanillaABI = self.generateABI({useEmbarkJS: false, deployment: true});
|
||||||
let contractsJSON = self.generateContractsJSON();
|
self.events.request("contracts:list", (contractsList) => {
|
||||||
|
let contractsJSON = self.generateContractsJSON(contractsList);
|
||||||
cb(vanillaABI, contractsJSON);
|
cb(vanillaABI, contractsJSON);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
this.events.setCommandHandlerOnce('code-generator:web3js', function(cb) {
|
this.events.setCommandHandlerOnce('code-generator:web3js', function(cb) {
|
||||||
self.buildWeb3JS(cb);
|
self.buildWeb3JS(cb);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.events.setCommandHandler('code-generator:contract', (contractName, cb) => {
|
self.events.setCommandHandler('code-generator:contract', (contractName, cb) => {
|
||||||
let contract = self.contractsManager.contracts[contractName];
|
self.events.setCommandHandler('contracts:contract', contractName, (contract) => {
|
||||||
self.buildContractJS(contractName, self.generateContractJSON(contractName, contract), cb);
|
self.buildContractJS(contractName, self.generateContractJSON(contract, contract), cb);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
self.events.setCommandHandler('code-generator:contract:vanilla', (contract, gasLimit, cb) => {
|
self.events.setCommandHandler('code-generator:contract:vanilla', (contract, gasLimit, cb) => {
|
||||||
|
@ -304,12 +314,11 @@ class CodeGenerator {
|
||||||
return contractJSON;
|
return contractJSON;
|
||||||
}
|
}
|
||||||
|
|
||||||
generateContractsJSON() {
|
generateContractsJSON(contractsList) {
|
||||||
let contracts = {};
|
let contracts = {};
|
||||||
|
|
||||||
for (let className in this.contractsManager.contracts) {
|
for (let contract of contractsList) {
|
||||||
let contract = this.contractsManager.contracts[className];
|
contracts[contract.className] = this.generateContractJSON(contract.className, contract);
|
||||||
contracts[className] = this.generateContractJSON(className, contract);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return contracts;
|
return contracts;
|
||||||
|
|
Loading…
Reference in New Issue