mirror of https://github.com/embarklabs/embark.git
re-add gas estimates; get accounts through await instead of a callback
This commit is contained in:
parent
a14bebabf6
commit
7093844566
|
@ -23,13 +23,21 @@ class EthereumBlockchainClient {
|
||||||
let provider = await this.events.request2("blockchain:client:provider", "ethereum");
|
let provider = await this.events.request2("blockchain:client:provider", "ethereum");
|
||||||
var web3 = new Web3(provider)
|
var web3 = new Web3(provider)
|
||||||
// var web3 = new Web3("ws://localhost:8556")
|
// var web3 = new Web3("ws://localhost:8556")
|
||||||
web3.eth.getAccounts().then((accounts) => {
|
// web3.eth.getAccounts().then((accounts) => {
|
||||||
|
let accounts = await web3.eth.getAccounts();
|
||||||
let account = accounts[0];
|
let account = accounts[0];
|
||||||
// let contractObject = this.blockchain.ContractObject({abi: contract.abiDefinition});
|
// let contractObject = this.blockchain.ContractObject({abi: contract.abiDefinition});
|
||||||
console.dir("== ethereum contract deployer")
|
console.dir("== ethereum contract deployer")
|
||||||
let contractObj = new web3.eth.Contract(contract.abiDefinition, contract.address);
|
let contractObj = new web3.eth.Contract(contract.abiDefinition, contract.address);
|
||||||
// let deployObject = this.blockchain.deployContractObject(contractObject, {arguments: contractParams, data: dataCode});
|
// let deployObject = this.blockchain.deployContractObject(contractObject, {arguments: contractParams, data: dataCode});
|
||||||
let contractObject = contractObj.deploy({ arguments: (contract.args || []), data: ("0x" + contract.code) });
|
let contractObject = contractObj.deploy({ arguments: (contract.args || []), data: ("0x" + contract.code) });
|
||||||
|
|
||||||
|
if (contract.gas === 'auto' || !contract.gas) {
|
||||||
|
let gasValue = await contractObject.estimateGas();
|
||||||
|
let increase_per = 1 + (Math.random() / 10.0);
|
||||||
|
contract.gas = Math.floor(gasValue * increase_per);
|
||||||
|
}
|
||||||
|
|
||||||
// this.blockchain.deployContractFromObject(deployObject,
|
// this.blockchain.deployContractFromObject(deployObject,
|
||||||
console.dir({ arguments: contract.args, data: ("0x" + contract.code) });
|
console.dir({ arguments: contract.args, data: ("0x" + contract.code) });
|
||||||
console.dir("------- send")
|
console.dir("------- send")
|
||||||
|
@ -43,7 +51,7 @@ class EthereumBlockchainClient {
|
||||||
}, (hash) => {
|
}, (hash) => {
|
||||||
console.dir('hash is ' + hash);
|
console.dir('hash is ' + hash);
|
||||||
});
|
});
|
||||||
})
|
// })
|
||||||
}
|
}
|
||||||
|
|
||||||
async doLinking(params, callback) {
|
async doLinking(params, callback) {
|
||||||
|
|
Loading…
Reference in New Issue