mirror of
https://github.com/embarklabs/embark.git
synced 2025-02-17 08:07:51 +00:00
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());
|
cb(self.compileError, self.listContracts());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
self.events.setCommandHandler('contracts:all', (cb) => {
|
||||||
|
cb(self.compileError, self.contracts);
|
||||||
|
});
|
||||||
|
|
||||||
self.events.setCommandHandler('contracts:dependencies', (cb) => {
|
self.events.setCommandHandler('contracts:dependencies', (cb) => {
|
||||||
cb(self.compileError, self.contractDependencies);
|
cb(self.compileError, self.contractDependencies);
|
||||||
});
|
});
|
||||||
|
@ -240,7 +240,7 @@ class Test {
|
|||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
console.info('Compiling contracts'.cyan);
|
console.info('Compiling contracts'.cyan);
|
||||||
self.engine.contractsManager.build(() => {
|
self.engine.events.request("contracts:build", false, (err) => {
|
||||||
self.builtContracts = cloneDeep(self.engine.contractsManager.contracts);
|
self.builtContracts = cloneDeep(self.engine.contractsManager.contracts);
|
||||||
let className;
|
let className;
|
||||||
for (className in self.builtContracts) {
|
for (className in self.builtContracts) {
|
||||||
@ -311,32 +311,35 @@ class Test {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
function createContractObject(accounts, next) {
|
function createContractObject(accounts, next) {
|
||||||
async.each(Object.keys(self.engine.contractsManager.contracts), (contractName, eachCb) => {
|
self.engine.events.request('contracts:all', (err, contracts) => {
|
||||||
const contract = self.engine.contractsManager.contracts[contractName];
|
|
||||||
if (!self.contracts[contractName]) {
|
|
||||||
self.contracts[contractName] = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
let newContract = new EmbarkJS.Contract({
|
async.each(contracts, (contract, eachCb) => {
|
||||||
abi: contract.abiDefinition,
|
if (!self.contracts[contract.className]) {
|
||||||
address: contract.deployedAddress,
|
self.contracts[contract.className] = {};
|
||||||
from: self.web3.eth.defaultAccount,
|
}
|
||||||
gas: 6000000,
|
|
||||||
web3: self.web3
|
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) {
|
], function (err, accounts) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user