Make gasLimit fully configurable from UI

pull/1/head
Alex Beregszaszi 9 years ago
parent 628221286d
commit 3f4cb564d0
  1. 2
      index.html
  2. 1
      src/app/renderer.js
  3. 13
      src/universal-dapp.js

@ -73,7 +73,7 @@
<div class="crow">
<label for="txorigin"><select name="txorigin" id="txorigin"></select> Transaction origin</label>
</div>
<div class="crow hide">
<div class="crow">
<label for="gasLimit"><input type="number" id="gasLimit" value="3000000"> Gas limit</label>
</div>
<div class="crow hide">

@ -67,6 +67,7 @@ function Renderer (editor, executionContext, updateFiles) {
var comp = $('#value').val().split(' ');
return executionContext.web3().toWei(comp[0], comp.slice(1).join(' '));
},
getGasLimit: function () { return $('#gasLimit').val(); },
removable_instances: true,
renderOutputModifier: function (contractName, $contractOutput) {
var contract = data.contracts[contractName];

@ -618,7 +618,14 @@ UniversalDApp.prototype.runTx = function (data, args, cb) {
data = '0x' + data;
}
var gas = self.options.getGas ? self.options.getGas : 3000000;
var gasLimit = 3000000;
if (self.options.getGasLimit) {
try {
gasLimit = self.options.getGasLimit();
} catch (e) {
return cb(e);
}
}
var value = 0;
if (self.options.getValue) {
@ -645,7 +652,7 @@ UniversalDApp.prototype.runTx = function (data, args, cb) {
return cb(err, resp);
}
if (resp > gas) {
if (resp > gasLimit) {
return cb('Gas required exceeds limit: ' + resp);
}
@ -667,7 +674,7 @@ UniversalDApp.prototype.runTx = function (data, args, cb) {
tx = new EthJSTX({
nonce: new Buffer([account.nonce++]), // @todo count beyond 255
gasPrice: 1,
gasLimit: gas,
gasLimit: gasLimit,
to: to,
value: new BN(value, 10),
data: new Buffer(data.slice(2), 'hex')

Loading…
Cancel
Save