From dc166a2bee346871b5b05462980f8004baa69588 Mon Sep 17 00:00:00 2001 From: chriseth Date: Tue, 21 Jul 2015 00:44:25 +0200 Subject: [PATCH] Parameter en- and decoding. --- index.html | 104 ++++++++++++++++++++++++++++++++++------------------ web3.min.js | 4 ++ 2 files changed, 73 insertions(+), 35 deletions(-) create mode 100644 web3.min.js diff --git a/index.html b/index.html index 364027b7b0..1143000d6e 100644 --- a/index.html +++ b/index.html @@ -56,6 +56,7 @@ body { +

Solidity realtime compiler and runtime

@@ -292,49 +293,82 @@ var runTx = function(data, to, cb) { vm.runTx({tx: tx}, cb); }; +var getConstructorInterface = function(abi) { + var funABI = {'name':'','inputs':[],'type':'constructor','outputs':[]}; + for (var i = 0; i < abi.length; i++) + if (abi[i].type == 'constructor') { + funABI.inputs = abi[i].inputs || []; + break; + } + return funABI; +}; + +var getCallButton = function(args) { + // args.abi, args.bytecode [constr only], args.address [fun only] + // args.appendFunctions [constr only] + var isConstructor = args.bytecode !== undefined; + var fun = new web3.eth.function(args.abi); + var inputs = ''; + $.each(args.abi.inputs, function(i, inp) { + if (inputs != '') inputs += ', '; + inputs += inp.type + ' ' + inp.name; + }); + var inputField = $('').attr('placeholder', inputs); + var outputSpan = $('
'); + var button = $(''); - var createResult = $(''); - execInter - .append(createButton) - .append(createResult); - var bytecode = contract.bytecode; - var funHashes = contract.functionHashes; var abi = $.parseJSON(contract.interface); - createButton.click(function() { - createResult.text(' ...'); - //@todo constructor arguments - runTx(bytecode, undefined, function(err, result) { - if (err) - createResult.text(err); - else - { - createResult.text(' Creation used ' + result.vm.gasUsed.toString(10) + ' gas.'); - appendFunctions(result.createdAddress); - } - }); - }); + var execInter = $('
'); + var funABI = getConstructorInterface(abi); + var appendFunctions = function(address) { var instance = $('
'); instance.append($('').text('Contract at address ' + address.toString('hex'))); - $.each(funHashes, function(signature, hash) { - var runButton = $('