mirror of https://github.com/embarklabs/embark.git
fix on deploy
This commit is contained in:
parent
7e4429b342
commit
d005d3f668
|
@ -194,6 +194,14 @@ class CodeGenerator {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
generateContractCode(contract) {
|
||||||
|
let abi = JSON.stringify(contract.abiDefinition);
|
||||||
|
|
||||||
|
let block = "";
|
||||||
|
block += Templates.vanilla_contract({className: contract.className, abi: abi, contract: contract});
|
||||||
|
return block;
|
||||||
|
}
|
||||||
|
|
||||||
generateStorageInitialization(useEmbarkJS) {
|
generateStorageInitialization(useEmbarkJS) {
|
||||||
let self = this;
|
let self = this;
|
||||||
let result = "\n";
|
let result = "\n";
|
||||||
|
|
|
@ -77,16 +77,11 @@ class Deploy {
|
||||||
if (contract.onDeploy !== undefined) {
|
if (contract.onDeploy !== undefined) {
|
||||||
self.logger.info('executing onDeploy commands');
|
self.logger.info('executing onDeploy commands');
|
||||||
let codeGenerator = new CodeGenerator({contractsManager: self.contractsManager});
|
let codeGenerator = new CodeGenerator({contractsManager: self.contractsManager});
|
||||||
let context = codeGenerator.generateContext();
|
|
||||||
let code = codeGenerator.generateContracts(false, true, true);
|
|
||||||
let cmds = contract.onDeploy.join(';\n');
|
|
||||||
|
|
||||||
let _cmds = "";
|
let cmds = "";
|
||||||
_cmds += "__mainContext.__loadManagerInstance.execWhenReady(function() {";
|
cmds += codeGenerator.generateContractCode(contract);
|
||||||
_cmds += cmds;
|
cmds += contract.onDeploy.join(';\n');
|
||||||
_cmds += "});";
|
RunCode.doEval(cmds, self.web3);
|
||||||
|
|
||||||
RunCode.doEval(context + "\n" + code + "\n" + _cmds, self.web3);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
callback();
|
callback();
|
||||||
|
|
|
@ -7,9 +7,11 @@ import 'bootstrap/dist/css/bootstrap.min.css';
|
||||||
//import 'bootstrap/dist/js/bootstrap.min.js';
|
//import 'bootstrap/dist/js/bootstrap.min.js';
|
||||||
import EmbarkJS from 'Embark/EmbarkJS';
|
import EmbarkJS from 'Embark/EmbarkJS';
|
||||||
import SimpleStorage from 'Embark/contracts/SimpleStorage';
|
import SimpleStorage from 'Embark/contracts/SimpleStorage';
|
||||||
|
import Test from 'Embark/contracts/Test';
|
||||||
|
|
||||||
window.EmbarkJS = EmbarkJS;
|
window.EmbarkJS = EmbarkJS;
|
||||||
window.SimpleStorage = SimpleStorage;
|
window.SimpleStorage = SimpleStorage;
|
||||||
|
window.Test = Test;
|
||||||
|
|
||||||
import './foo.css';
|
import './foo.css';
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue