mirror of
https://github.com/embarklabs/embark.git
synced 2025-02-20 01:18:52 +00:00
make contract gas calculation automatic
This commit is contained in:
parent
7b3fefd039
commit
89c0001dcb
@ -1,7 +1,6 @@
|
|||||||
{
|
{
|
||||||
"development": {
|
"development": {
|
||||||
"gasLimit": 500000,
|
"gas": "auto",
|
||||||
"gasPrice": 10000000000000,
|
|
||||||
"contracts": {
|
"contracts": {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
{
|
{
|
||||||
"default": {
|
"default": {
|
||||||
"gasLimit": 500000,
|
"gas": "auto",
|
||||||
"gasPrice": 10000000000000,
|
|
||||||
"contracts": {
|
"contracts": {
|
||||||
"SimpleStorage": {
|
"SimpleStorage": {
|
||||||
"args": [
|
"args": [
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
{
|
{
|
||||||
"development": {
|
"development": {
|
||||||
"gasLimit": 500000,
|
"gas": "auto",
|
||||||
"gasPrice": 10000000000000,
|
|
||||||
"contracts": {
|
"contracts": {
|
||||||
"SimpleStorage": {
|
"SimpleStorage": {
|
||||||
"args": [
|
"args": [
|
||||||
|
@ -26,9 +26,10 @@ ABIGenerator.prototype.generateContracts = function(useEmbarkJS) {
|
|||||||
var contract = this.contractsManager.contracts[className];
|
var contract = this.contractsManager.contracts[className];
|
||||||
|
|
||||||
var abi = JSON.stringify(contract.abiDefinition);
|
var abi = JSON.stringify(contract.abiDefinition);
|
||||||
|
var gasEstimates = JSON.stringify(contract.gasEstimates);
|
||||||
|
|
||||||
if (useEmbarkJS) {
|
if (useEmbarkJS) {
|
||||||
result += "\n" + className + " = new EmbarkJS.Contract({abi: " + abi + ", address: '" + contract.deployedAddress + "', code: '" + contract.code + "'});";
|
result += "\n" + className + " = new EmbarkJS.Contract({abi: " + abi + ", address: '" + contract.deployedAddress + "', code: '" + contract.code + "', gasEstimates: " + gasEstimates + "});";
|
||||||
} else {
|
} else {
|
||||||
result += "\n" + className + "Abi = " + abi + ";";
|
result += "\n" + className + "Abi = " + abi + ";";
|
||||||
result += "\n" + className + "Contract = web3.eth.contract(" + className + "Abi);";
|
result += "\n" + className + "Contract = web3.eth.contract(" + className + "Abi);";
|
||||||
|
@ -21,7 +21,13 @@ ContractsManager.prototype.build = function() {
|
|||||||
var contract = this.compiledContracts[className];
|
var contract = this.compiledContracts[className];
|
||||||
var contractConfig = this.contractsConfig[className];
|
var contractConfig = this.contractsConfig[className];
|
||||||
|
|
||||||
contract.gasLimit = this.contractsConfig.gasLimit;
|
if (this.contractsConfig.gas === 'auto') {
|
||||||
|
var maxGas = Math.max(contract.gasEstimates.creation[0], contract.gasEstimates.creation[1], 500000);
|
||||||
|
var adjustedGas = Math.round(maxGas * 1.01);
|
||||||
|
contract.gas = adjustedGas;
|
||||||
|
} else {
|
||||||
|
contract.gas = this.contractsConfig.gas;
|
||||||
|
}
|
||||||
contract.gasPrice = this.contractsConfig.gasPrice;
|
contract.gasPrice = this.contractsConfig.gasPrice;
|
||||||
|
|
||||||
if (contractConfig === undefined) {
|
if (contractConfig === undefined) {
|
||||||
|
@ -16,7 +16,7 @@ Deploy.prototype.deployContract = function(contract, params, callback) {
|
|||||||
contractParams.push({
|
contractParams.push({
|
||||||
from: this.web3.eth.coinbase,
|
from: this.web3.eth.coinbase,
|
||||||
data: contract.code,
|
data: contract.code,
|
||||||
gas: contract.gasLimit,
|
gas: contract.gas,
|
||||||
gasPrice: contract.gasPrice
|
gasPrice: contract.gasPrice
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user