diff --git a/lib/contracts/code_generator.js b/lib/contracts/code_generator.js index e7e8064d5..7fba4b5be 100644 --- a/lib/contracts/code_generator.js +++ b/lib/contracts/code_generator.js @@ -26,6 +26,7 @@ class CodeGenerator { this.contractsConfig = options.contractsConfig || {}; this.storageConfig = options.storageConfig || {}; this.communicationConfig = options.communicationConfig || {}; + this.namesystemConfig = options.namesystemConfig || {}; // TODO: this should also be removed and use events instead this.contractsManager = options.contractsManager; this.plugins = options.plugins; @@ -224,6 +225,17 @@ class CodeGenerator { return block; } + generateNamesInitialization(useEmbarkJS) { + if (!useEmbarkJS || this.namesystemConfig === {}) return ""; + + let result = "\n"; + result += Templates.define_when_env_loaded(); + result += this._getInitCode('names', this.namesystemConfig); + + return result; + } + + generateStorageInitialization(useEmbarkJS) { if (!useEmbarkJS || this.storageConfig === {}) return ""; @@ -266,6 +278,7 @@ class CodeGenerator { result += this.generateContracts(options.useEmbarkJS, options.deployment, true); result += this.generateStorageInitialization(options.useEmbarkJS); result += this.generateCommunicationInitialization(options.useEmbarkJS); + result += this.generateNamesInitialization(options.useEmbarkJS); return result; } @@ -331,6 +344,7 @@ class CodeGenerator { code += self.generateCommunicationInitialization(true); code += self.generateStorageInitialization(true); + code += self.generateNamesInitialization(true); next(); }, function writeFile(next) { diff --git a/lib/core/engine.js b/lib/core/engine.js index 041dcc109..4a84b234d 100644 --- a/lib/core/engine.js +++ b/lib/core/engine.js @@ -173,6 +173,7 @@ class Engine { contractsManager: this.contractsManager, plugins: self.plugins, storageConfig: self.config.storageConfig, + namesystemConfig: self.config.namesystemConfig, communicationConfig: self.config.communicationConfig, events: self.events });