mirror of
https://github.com/embarklabs/embark.git
synced 2025-01-10 13:55:45 +00:00
feat(dapp-config): add dapp connection to dapp config (artifact)
This commit is contained in:
parent
1543f6ad41
commit
52aebebf9e
@ -83,5 +83,9 @@
|
||||
"eth",
|
||||
"xyz"
|
||||
]
|
||||
},
|
||||
"dappConfig": {
|
||||
"dir": "config",
|
||||
"blockchain": "blockchain.json"
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,9 @@ const Templates = {
|
||||
class CodeGenerator {
|
||||
constructor(embark, options) {
|
||||
this.blockchainConfig = embark.config.blockchainConfig || {};
|
||||
this.embarkConfig = embark.config.embarkConfig;
|
||||
this.dappConfigs = {};
|
||||
this.logger = embark.logger;
|
||||
this.rpcHost = this.blockchainConfig.rpcHost || '';
|
||||
this.rpcPort = this.blockchainConfig.rpcPort || '';
|
||||
this.contractsConfig = embark.config.contractsConfig || {};
|
||||
@ -42,6 +45,10 @@ class CodeGenerator {
|
||||
listenToCommands() {
|
||||
let self = this;
|
||||
|
||||
this.events.on('config:load:contracts', (contractConfig) => {
|
||||
this.generateConfigs(contractConfig);
|
||||
});
|
||||
|
||||
this.events.setCommandHandler('provider-code', function(cb) {
|
||||
let providerCode = self.generateProvider(false);
|
||||
|
||||
@ -186,6 +193,23 @@ class CodeGenerator {
|
||||
return result;
|
||||
}
|
||||
|
||||
generateConfigs(contractConfig) {
|
||||
this.dappConfigs.blockchain = {dappConnection: contractConfig.dappConnection};
|
||||
async.waterfall([
|
||||
(next) => {
|
||||
fs.mkdirp(utils.joinPath(this.embarkConfig.buildDir, constants.dappConfig.dir), next);
|
||||
},
|
||||
(_dir, next) => {
|
||||
fs.writeFile(utils.joinPath(this.embarkConfig.buildDir, constants.dappConfig.dir, constants.dappConfig.blockchain),
|
||||
JSON.stringify(this.dappConfigs.blockchain, null, 2), next);
|
||||
}
|
||||
], (err) => {
|
||||
if (err) {
|
||||
this.logger.error(err.message || err);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
generateContractCode(contract, gasLimit) {
|
||||
let abi = JSON.stringify(contract.abiDefinition);
|
||||
|
||||
|
@ -27,14 +27,15 @@ describe('embark.CodeGenerator', function() {
|
||||
deployedAddress: "0x124",
|
||||
code: '123456'
|
||||
}
|
||||
]
|
||||
];
|
||||
|
||||
const TestEvents = {
|
||||
request: (cmd, cb) => {
|
||||
cb(currentSolcVersion);
|
||||
},
|
||||
setCommandHandler: () => {
|
||||
}
|
||||
},
|
||||
on: () => {}
|
||||
};
|
||||
let generator = new CodeGenerator({config: {blockchainConfig: {}}, events: TestEvents}, {});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user