mirror of https://github.com/embarklabs/embark.git
requests instead of contract object directly
This commit is contained in:
parent
b9363c54fa
commit
600d686342
|
@ -24,6 +24,10 @@ class ContractsManager {
|
|||
cb(self.compileError, self.listContracts());
|
||||
});
|
||||
|
||||
self.events.setCommandHandler('contracts:all', (cb) => {
|
||||
cb(self.compileError, self.contracts);
|
||||
});
|
||||
|
||||
self.events.setCommandHandler('contracts:dependencies', (cb) => {
|
||||
cb(self.compileError, self.contractDependencies);
|
||||
});
|
||||
|
|
|
@ -240,7 +240,7 @@ class Test {
|
|||
return next();
|
||||
}
|
||||
console.info('Compiling contracts'.cyan);
|
||||
self.engine.contractsManager.build(() => {
|
||||
self.engine.events.request("contracts:build", false, (err) => {
|
||||
self.builtContracts = cloneDeep(self.engine.contractsManager.contracts);
|
||||
let className;
|
||||
for (className in self.builtContracts) {
|
||||
|
@ -311,32 +311,35 @@ class Test {
|
|||
});
|
||||
},
|
||||
function createContractObject(accounts, next) {
|
||||
async.each(Object.keys(self.engine.contractsManager.contracts), (contractName, eachCb) => {
|
||||
const contract = self.engine.contractsManager.contracts[contractName];
|
||||
if (!self.contracts[contractName]) {
|
||||
self.contracts[contractName] = {};
|
||||
}
|
||||
self.engine.events.request('contracts:all', (err, contracts) => {
|
||||
|
||||
let newContract = new EmbarkJS.Contract({
|
||||
abi: contract.abiDefinition,
|
||||
address: contract.deployedAddress,
|
||||
from: self.web3.eth.defaultAccount,
|
||||
gas: 6000000,
|
||||
web3: self.web3
|
||||
async.each(contracts, (contract, eachCb) => {
|
||||
if (!self.contracts[contract.className]) {
|
||||
self.contracts[contract.className] = {};
|
||||
}
|
||||
|
||||
let newContract = new EmbarkJS.Contract({
|
||||
abi: contract.abiDefinition,
|
||||
address: contract.deployedAddress,
|
||||
from: self.web3.eth.defaultAccount,
|
||||
gas: 6000000,
|
||||
web3: self.web3
|
||||
});
|
||||
|
||||
if (newContract.options) {
|
||||
newContract.options.from = self.web3.eth.defaultAccount;
|
||||
newContract.options.data = contract.code;
|
||||
newContract.options.gas = 6000000;
|
||||
}
|
||||
|
||||
Object.setPrototypeOf(self.contracts[contract.className], newContract);
|
||||
Object.assign(self.contracts[contract.className], newContract);
|
||||
|
||||
eachCb();
|
||||
}, (err) => {
|
||||
next(err, accounts);
|
||||
});
|
||||
|
||||
if (newContract.options) {
|
||||
newContract.options.from = self.web3.eth.defaultAccount;
|
||||
newContract.options.data = contract.code;
|
||||
newContract.options.gas = 6000000;
|
||||
}
|
||||
|
||||
Object.setPrototypeOf(self.contracts[contractName], newContract);
|
||||
Object.assign(self.contracts[contractName], newContract);
|
||||
|
||||
eachCb();
|
||||
}, (err) => {
|
||||
next(err, accounts);
|
||||
});
|
||||
}
|
||||
], function (err, accounts) {
|
||||
|
|
Loading…
Reference in New Issue