From 9c274fca4a6ee6fb1823305ca5d562cba11f6126 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Tue, 12 Apr 2016 15:18:20 +0100 Subject: [PATCH] Support Ethereum units for setting the value on a transaction --- assets/js/app.js | 5 ++++- assets/js/universal-dapp.js | 10 +++++++++- index.html | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/assets/js/app.js b/assets/js/app.js index 7fde21b504..7b7eb75598 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -672,7 +672,10 @@ vm: executionContext === 'vm', removable: false, getAddress: function(){ return $('#txorigin').val(); }, - getValue: function(){ return $('#value').val(); }, + getValue: function(){ + var comp = $('#value').val().split(' '); + return web3.toWei(comp[0], comp.slice(1).join(' ')); + }, removable_instances: true, renderOutputModifier: function(contractName, $contractOutput) { var contract = data.contracts[contractName]; diff --git a/assets/js/universal-dapp.js b/assets/js/universal-dapp.js index 63af85b9a7..beba5064a3 100644 --- a/assets/js/universal-dapp.js +++ b/assets/js/universal-dapp.js @@ -431,7 +431,15 @@ UniversalDApp.prototype.runTx = function( data, args, cb) { data = '0x' + data; var gas = self.options.getGas ? self.options.getGas : 1000000; - var value = self.options.getValue ? self.options.getValue() : 0; + + var value = 0; + if (self.options.getValue) { + try { + value = self.options.getValue(); + } catch (e) { + return cb(e); + } + } if (!this.vm) { var tx = { diff --git a/index.html b/index.html index 72d4a4ccfe..195755a852 100644 --- a/index.html +++ b/index.html @@ -81,7 +81,7 @@
- +