aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarian OANCΞA <contact@siteshop.ro>2014-11-18 15:21:06 +0800
committerMarian OANCΞA <contact@siteshop.ro>2014-11-18 15:21:06 +0800
commit8fe16df6c911f8262ae0eb839a3f036467ee0da7 (patch)
tree2370b76a7effe4fdae042d814be8250204268ab7
parent1a9624af5146a790f6bc8c5167bf5a6c006a6644 (diff)
parent27a8799e4809325bb2d7dbc7480a3de0f9d684d6 (diff)
downloadgo-tangerine-8fe16df6c911f8262ae0eb839a3f036467ee0da7.tar
go-tangerine-8fe16df6c911f8262ae0eb839a3f036467ee0da7.tar.gz
go-tangerine-8fe16df6c911f8262ae0eb839a3f036467ee0da7.tar.bz2
go-tangerine-8fe16df6c911f8262ae0eb839a3f036467ee0da7.tar.lz
go-tangerine-8fe16df6c911f8262ae0eb839a3f036467ee0da7.tar.xz
go-tangerine-8fe16df6c911f8262ae0eb839a3f036467ee0da7.tar.zst
go-tangerine-8fe16df6c911f8262ae0eb839a3f036467ee0da7.zip
Merge pull request #11 from debris/master
Update
-rw-r--r--.travis.yml5
-rw-r--r--dist/ethereum.js14
-rw-r--r--dist/ethereum.js.map10
-rw-r--r--dist/ethereum.min.js2
-rw-r--r--example/contract.html75
-rw-r--r--example/index.html2
-rw-r--r--index.js2
-rw-r--r--index_qt.js2
-rw-r--r--lib/abi.js48
-rw-r--r--lib/contract.js63
-rw-r--r--lib/main.js8
11 files changed, 206 insertions, 25 deletions
diff --git a/.travis.yml b/.travis.yml
index 148e4e797..fafacbd5a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -4,5 +4,8 @@ node_js:
- "0.10"
before_script:
- npm install
+ - npm install jshint
+script:
+ - "jshint *.js lib"
after_script:
- - npm run-script gulp \ No newline at end of file
+ - npm run-script gulp
diff --git a/dist/ethereum.js b/dist/ethereum.js
index 32dfb596a..f98e67ea3 100644
--- a/dist/ethereum.js
+++ b/dist/ethereum.js
@@ -1,18 +1,20 @@
require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
-var findIndex=function(array,callback){for(var end=!1,i=0;i<array.length&&!end;i++)end=callback(array[i]);return end?i-1:-1},findMethodIndex=function(json,methodName){return findIndex(json,function(method){return method.name===methodName})},padLeft=function(number,n){return new Array(2*n-number.toString().length+1).join("0")+number},setupInputTypes=function(){var prefixedType=function(prefix){return function(type,value){var padding,expected=prefix;return 0!==type.indexOf(expected)?!1:(padding=parseInt(type.slice(expected.length))/8,padLeft(value,padding))}},namedType=function(name,padding,formatter){return function(type,value){return type!==name?!1:padLeft(formatter?value:formatter(value),padding)}},formatBool=function(value){return value?"1":"0"};return[prefixedType("uint"),prefixedType("int"),namedType("address",20),namedType("bool",1,formatBool)]},inputTypes=setupInputTypes(),toAbiInput=function(json,methodName,params){var method,i,found,j,bytes="",index=findMethodIndex(json,methodName);if(-1!==index){for(bytes=bytes+index+"x0",method=json[index],i=0;i<method.inputs.length;i++){for(found=!1,j=0;j<inputTypes.length&&!found;j++)found=inputTypes[j](method.inputs[i].type,params[i]);found||console.error("unsupported json type: "+method.inputs[i].type),bytes+=found}return bytes}},setupOutputTypes=function(){var prefixedType=function(prefix){return function(type){var padding,expected=prefix;return 0!==type.indexOf(expected)?-1:(padding=parseInt(type.slice(expected.length))/8,2*padding)}},namedType=function(name,padding){return function(type){return name===type?2*padding:-1}},formatInt=function(value){return parseInt(value,16)},formatBool=function(value){return"1"===value?!0:!1};return[{padding:prefixedType("uint"),format:formatInt},{padding:prefixedType("int"),format:formatInt},{padding:namedType("address",20)},{padding:namedType("bool",1),format:formatBool}]},outputTypes=setupOutputTypes(),fromAbiOutput=function(json,methodName,output){var result,method,i,padding,j,res,formatter,index=findMethodIndex(json,methodName);if(-1!==index){for(output=output.slice(2),result=[],method=json[index],i=0;i<method.outputs.length;i++){for(padding=-1,j=0;j<outputTypes.length&&-1===padding;j++)padding=outputTypes[j].padding(method.outputs[i].type);-1!==padding&&(res=output.slice(0,padding),formatter=outputTypes[j-1].format,result.push(formatter?formatter(res):res),output=output.slice(padding))}return result}},load=function(json){var contract={};return json.forEach(function(method){contract[method.name]=function(){var params=Array.prototype.slice.call(arguments);return toAbiInput(json,method.name,params)}}),contract};module.exports=load;
+var findIndex=function(array,callback){for(var end=!1,i=0;i<array.length&&!end;i++)end=callback(array[i]);return end?i-1:-1},findMethodIndex=function(json,methodName){return findIndex(json,function(method){return method.name===methodName})},padLeft=function(number,n){return new Array(2*n-number.toString().length+1).join("0")+number},setupInputTypes=function(){var prefixedType=function(prefix){return function(type,value){var padding,expected=prefix;return 0!==type.indexOf(expected)?!1:(padding=parseInt(type.slice(expected.length))/8,padLeft(value,padding))}},namedType=function(name,padding,formatter){return function(type,value){return type!==name?!1:padLeft(formatter?value:formatter(value),padding)}},formatBool=function(value){return value?"1":"0"};return[prefixedType("uint"),prefixedType("int"),namedType("address",20),namedType("bool",1,formatBool)]},inputTypes=setupInputTypes(),toAbiInput=function(json,methodName,params){var method,i,found,j,val,bytes="",index=findMethodIndex(json,methodName);if(-1!==index){for(bytes=bytes+index+"x0",method=json[index],i=0;i<method.inputs.length;i++){for(found=!1,j=0;j<inputTypes.length&&!found;j++)val=parseInt(params[i]).toString(16),found=inputTypes[j](method.inputs[i].type,val);found||console.error("unsupported json type: "+method.inputs[i].type),bytes+=found}return bytes}},setupOutputTypes=function(){var prefixedType=function(prefix){return function(type){var padding,expected=prefix;return 0!==type.indexOf(expected)?-1:(padding=parseInt(type.slice(expected.length))/8,2*padding)}},namedType=function(name,padding){return function(type){return name===type?2*padding:-1}},formatInt=function(value){return parseInt(value,16)},formatBool=function(value){return"1"===value?!0:!1};return[{padding:prefixedType("uint"),format:formatInt},{padding:prefixedType("int"),format:formatInt},{padding:namedType("address",20)},{padding:namedType("bool",1),format:formatBool}]},outputTypes=setupOutputTypes(),fromAbiOutput=function(json,methodName,output){var result,method,i,padding,j,res,formatter,index=findMethodIndex(json,methodName);if(-1!==index){for(output=output.slice(2),result=[],method=json[index],i=0;i<method.outputs.length;i++){for(padding=-1,j=0;j<outputTypes.length&&-1===padding;j++)padding=outputTypes[j].padding(method.outputs[i].type);-1!==padding&&(res=output.slice(0,padding),formatter=outputTypes[j-1].format,result.push(formatter?formatter(res):res),output=output.slice(padding))}return result}},inputParser=function(json){var parser={};return json.forEach(function(method){parser[method.name]=function(){var params=Array.prototype.slice.call(arguments);return toAbiInput(json,method.name,params)}}),parser},outputParser=function(json){var parser={};return json.forEach(function(method){parser[method.name]=function(output){return fromAbiOutput(json,method.name,output)}}),parser};module.exports={inputParser:inputParser,outputParser:outputParser};
},{}],2:[function(require,module,exports){
var AutoProvider=function(userOptions){var options,self,closeWithSuccess,ws;if(!web3.haveProvider()){if(this.sendQueue=[],this.onmessageQueue=[],navigator.qt)return void(this.provider=new web3.providers.QtProvider);userOptions=userOptions||{},options={httprpc:userOptions.httprpc||"http://localhost:8080",websockets:userOptions.websockets||"ws://localhost:40404/eth"},self=this,closeWithSuccess=function(success){ws.close(),success?self.provider=new web3.providers.WebSocketProvider(options.websockets):(self.provider=new web3.providers.HttpRpcProvider(options.httprpc),self.poll=self.provider.poll.bind(self.provider)),self.sendQueue.forEach(function(payload){self.provider(payload)}),self.onmessageQueue.forEach(function(handler){self.provider.onmessage=handler})},ws=new WebSocket(options.websockets),ws.onopen=function(){closeWithSuccess(!0)},ws.onerror=function(){closeWithSuccess(!1)}}};AutoProvider.prototype.send=function(payload){return this.provider?void this.provider.send(payload):void this.sendQueue.push(payload)},Object.defineProperty(AutoProvider.prototype,"onmessage",{set:function(handler){return this.provider?void(this.provider.onmessage=handler):void this.onmessageQueue.push(handler)}}),module.exports=AutoProvider;
},{}],3:[function(require,module,exports){
+var abi,contract;abi=require("./abi"),contract=function(address,desc){var inputParser=abi.inputParser(desc),outputParser=abi.outputParser(desc),contract={};return desc.forEach(function(method){contract[method.name]=function(){var params=Array.prototype.slice.call(arguments),parsed=inputParser[method.name].apply(null,params),onSuccess=function(result){return outputParser[method.name](result)};return{call:function(extra){return extra=extra||{},extra.to=address,extra.data=parsed,web3.eth.call(extra).then(onSuccess)},transact:function(extra){return extra=extra||{},extra.to=address,extra.data=parsed,web3.eth.transact(extra).then(onSuccess)}}}}),contract},module.exports=contract;
+},{"./abi":1}],4:[function(require,module,exports){
function formatJsonRpcObject(object){return{jsonrpc:"2.0",method:object.call,params:object.args,id:object._id}}function formatJsonRpcMessage(message){var object=JSON.parse(message);return{_id:object.id,data:object.result,error:object.error}}var HttpRpcProvider=function(host){this.handlers=[],this.host=host};HttpRpcProvider.prototype.sendRequest=function(payload,cb){var data=formatJsonRpcObject(payload),request=new XMLHttpRequest;request.open("POST",this.host,!0),request.send(JSON.stringify(data)),request.onreadystatechange=function(){4===request.readyState&&cb&&cb(request)}},HttpRpcProvider.prototype.send=function(payload){var self=this;this.sendRequest(payload,function(request){self.handlers.forEach(function(handler){handler.call(self,formatJsonRpcMessage(request.responseText))})})},HttpRpcProvider.prototype.poll=function(payload,id){var self=this;this.sendRequest(payload,function(request){var parsed=JSON.parse(request.responseText);!parsed.error&&(parsed.result instanceof Array?0!==parsed.result.length:parsed.result)&&self.handlers.forEach(function(handler){handler.call(self,{_event:payload.call,_id:id,data:parsed.result})})})},Object.defineProperty(HttpRpcProvider.prototype,"onmessage",{set:function(handler){this.handlers.push(handler)}}),module.exports=HttpRpcProvider;
-},{}],4:[function(require,module,exports){
-function flattenPromise(obj){return obj instanceof Promise?Promise.resolve(obj):obj instanceof Array?new Promise(function(resolve){var promises=obj.map(function(o){return flattenPromise(o)});return Promise.all(promises).then(function(res){for(var i=0;i<obj.length;i++)obj[i]=res[i];resolve(obj)})}):obj instanceof Object?new Promise(function(resolve){var keys=Object.keys(obj),promises=keys.map(function(key){return flattenPromise(obj[key])});return Promise.all(promises).then(function(res){for(var i=0;i<keys.length;i++)obj[keys[i]]=res[i];resolve(obj)})}):Promise.resolve(obj)}function messageHandler(data){if(void 0!==data._event)return void web3.trigger(data._event,data._id,data.data);if(data._id){var cb=web3._callbacks[data._id];cb&&(cb.call(this,data.error,data.data),delete web3._callbacks[data._id])}}var ethWatch,shhWatch,ProviderManager,Filter,ethMethods=function(){var blockCall=function(args){return"string"==typeof args[0]?"eth_blockByHash":"eth_blockByNumber"},transactionCall=function(args){return"string"==typeof args[0]?"eth_transactionByHash":"eth_transactionByNumber"},uncleCall=function(args){return"string"==typeof args[0]?"eth_uncleByHash":"eth_uncleByNumber"},methods=[{name:"balanceAt",call:"eth_balanceAt"},{name:"stateAt",call:"eth_stateAt"},{name:"storageAt",call:"eth_storageAt"},{name:"countAt",call:"eth_countAt"},{name:"codeAt",call:"eth_codeAt"},{name:"transact",call:"eth_transact"},{name:"call",call:"eth_call"},{name:"block",call:blockCall},{name:"transaction",call:transactionCall},{name:"uncle",call:uncleCall},{name:"compilers",call:"eth_compilers"},{name:"lll",call:"eth_lll"},{name:"solidity",call:"eth_solidity"}];return methods},ethProperties=function(){return[{name:"coinbase",getter:"eth_coinbase",setter:"eth_setCoinbase"},{name:"listening",getter:"eth_listening",setter:"eth_setListening"},{name:"mining",getter:"eth_mining",setter:"eth_setMining"},{name:"gasPrice",getter:"eth_gasPrice"},{name:"account",getter:"eth_account"},{name:"accounts",getter:"eth_accounts"},{name:"peerCount",getter:"eth_peerCount"},{name:"defaultBlock",getter:"eth_defaultBlock",setter:"eth_setDefaultBlock"},{name:"number",getter:"eth_number"}]},dbMethods=function(){return[{name:"put",call:"db_put"},{name:"get",call:"db_get"},{name:"putString",call:"db_putString"},{name:"getString",call:"db_getString"}]},shhMethods=function(){return[{name:"post",call:"shh_post"},{name:"newIdentity",call:"shh_newIdentity"},{name:"haveIdentity",call:"shh_haveIdentity"},{name:"newGroup",call:"shh_newGroup"},{name:"addToGroup",call:"shh_addToGroup"}]},ethWatchMethods=function(){var newFilter=function(args){return"string"==typeof args[0]?"eth_newFilterString":"eth_newFilter"};return[{name:"newFilter",call:newFilter},{name:"uninstallFilter",call:"eth_uninstallFilter"},{name:"getMessages",call:"eth_getMessages"}]},shhWatchMethods=function(){return[{name:"newFilter",call:"shh_newFilter"},{name:"uninstallFilter",call:"shh_uninstallFilter"},{name:"getMessage",call:"shh_getMessages"}]},setupMethods=function(obj,methods){methods.forEach(function(method){obj[method.name]=function(){return flattenPromise(Array.prototype.slice.call(arguments)).then(function(args){var call="function"==typeof method.call?method.call(args):method.call;return{call:call,args:args}}).then(function(request){return new Promise(function(resolve,reject){web3.provider.send(request,function(err,result){return err?void reject(err):void resolve(result)})})}).catch(function(err){console.error(err)})}})},setupProperties=function(obj,properties){properties.forEach(function(property){var proto={};proto.get=function(){return new Promise(function(resolve,reject){web3.provider.send({call:property.getter},function(err,result){return err?void reject(err):void resolve(result)})})},property.setter&&(proto.set=function(val){return flattenPromise([val]).then(function(args){return new Promise(function(resolve){web3.provider.send({call:property.setter,args:args},function(err,result){return err?void reject(err):void resolve(result)})})}).catch(function(err){console.error(err)})}),Object.defineProperty(obj,property.name,proto)})},web3={_callbacks:{},_events:{},providers:{},toHex:function(str){var i,n,hex="";for(i=0;i<str.length;i++)n=str.charCodeAt(i).toString(16),hex+=n.length<2?"0"+n:n;return hex},toAscii:function(hex){var code,str="",i=0,l=hex.length;for("0x"===hex.substring(0,2)&&(i=2);l>i&&(code=hex.charCodeAt(i),0!==code);i+=2)str+=String.fromCharCode(parseInt(hex.substr(i,2),16));return str},toDecimal:function(val){return parseInt(val,16)},fromAscii:function(str,pad){pad=void 0===pad?32:pad;for(var hex=this.toHex(str);hex.length<2*pad;)hex+="00";return"0x"+hex},eth:{prototype:Object(),watch:function(params){return new Filter(params,ethWatch)}},db:{prototype:Object()},shh:{prototype:Object(),watch:function(params){return new Filter(params,shhWatch)}},on:function(event,id,cb){return void 0===web3._events[event]&&(web3._events[event]={}),web3._events[event][id]=cb,this},off:function(event,id){return void 0!==web3._events[event]&&delete web3._events[event][id],this},trigger:function(event,id,data){var cb,callbacks=web3._events[event];callbacks&&callbacks[id]&&(cb=callbacks[id])(data)}},eth=web3.eth;setupMethods(eth,ethMethods()),setupProperties(eth,ethProperties()),setupMethods(web3.db,dbMethods()),setupMethods(web3.shh,shhMethods()),ethWatch={changed:"eth_changed"},setupMethods(ethWatch,ethWatchMethods()),shhWatch={changed:"shh_changed"},setupMethods(shhWatch,shhWatchMethods()),ProviderManager=function(){var self,poll;this.queued=[],this.polls=[],this.ready=!1,this.provider=void 0,this.id=1,self=this,(poll=function(){self.provider&&self.provider.poll&&self.polls.forEach(function(data){data.data._id=self.id,self.id++,self.provider.poll(data.data,data.id)}),setTimeout(poll,12e3)})()},ProviderManager.prototype.send=function(data,cb){data._id=this.id,cb&&(web3._callbacks[data._id]=cb),data.args=data.args||[],this.id++,void 0!==this.provider?this.provider.send(data):(console.warn("provider is not set"),this.queued.push(data))},ProviderManager.prototype.set=function(provider){void 0!==this.provider&&void 0!==this.provider.unload&&this.provider.unload(),this.provider=provider,this.ready=!0},ProviderManager.prototype.sendQueued=function(){for(var i=0;this.queued.length;i++)this.send(this.queued[i])},ProviderManager.prototype.installed=function(){return void 0!==this.provider},ProviderManager.prototype.startPolling=function(data,pollId){this.provider&&this.provider.poll&&this.polls.push({data:data,id:pollId})},ProviderManager.prototype.stopPolling=function(pollId){var i,poll;for(i=this.polls.length;i--;)poll=this.polls[i],poll.id===pollId&&this.polls.splice(i,1)},web3.provider=new ProviderManager,web3.setProvider=function(provider){provider.onmessage=messageHandler,web3.provider.set(provider),web3.provider.sendQueued()},web3.haveProvider=function(){return!!web3.provider.provider},Filter=function(options,impl){this.impl=impl,this.callbacks=[];var self=this;this.promise=impl.newFilter(options),this.promise.then(function(id){self.id=id,web3.on(impl.changed,id,self.trigger.bind(self)),web3.provider.startPolling({call:impl.changed,args:[id]},id)})},Filter.prototype.arrived=function(callback){this.changed(callback)},Filter.prototype.changed=function(callback){var self=this;this.promise.then(function(id){self.callbacks.push(callback)})},Filter.prototype.trigger=function(messages){for(var i=0;i<this.callbacks.length;i++)this.callbacks[i].call(this,messages)},Filter.prototype.uninstall=function(){var self=this;this.promise.then(function(id){self.impl.uninstallFilter(id),web3.provider.stopPolling(id),web3.off(impl.changed,id)})},Filter.prototype.messages=function(){var self=this;return this.promise.then(function(id){return self.impl.getMessages(id)})},module.exports=web3;
},{}],5:[function(require,module,exports){
-var QtProvider=function(){this.handlers=[];var self=this;navigator.qt.onmessage=function(message){self.handlers.forEach(function(handler){handler.call(self,JSON.parse(message.data))})}};QtProvider.prototype.send=function(payload){navigator.qt.postMessage(JSON.stringify(payload))},Object.defineProperty(QtProvider.prototype,"onmessage",{set:function(handler){this.handlers.push(handler)}}),module.exports=QtProvider;
+function flattenPromise(obj){return obj instanceof Promise?Promise.resolve(obj):obj instanceof Array?new Promise(function(resolve){var promises=obj.map(function(o){return flattenPromise(o)});return Promise.all(promises).then(function(res){for(var i=0;i<obj.length;i++)obj[i]=res[i];resolve(obj)})}):obj instanceof Object?new Promise(function(resolve){var keys=Object.keys(obj),promises=keys.map(function(key){return flattenPromise(obj[key])});return Promise.all(promises).then(function(res){for(var i=0;i<keys.length;i++)obj[keys[i]]=res[i];resolve(obj)})}):Promise.resolve(obj)}function messageHandler(data){if(void 0!==data._event)return void web3.trigger(data._event,data._id,data.data);if(data._id){var cb=web3._callbacks[data._id];cb&&(cb.call(this,data.error,data.data),delete web3._callbacks[data._id])}}var ethWatch,shhWatch,ProviderManager,Filter,ethMethods=function(){var blockCall=function(args){return"string"==typeof args[0]?"eth_blockByHash":"eth_blockByNumber"},transactionCall=function(args){return"string"==typeof args[0]?"eth_transactionByHash":"eth_transactionByNumber"},uncleCall=function(args){return"string"==typeof args[0]?"eth_uncleByHash":"eth_uncleByNumber"},methods=[{name:"balanceAt",call:"eth_balanceAt"},{name:"stateAt",call:"eth_stateAt"},{name:"storageAt",call:"eth_storageAt"},{name:"countAt",call:"eth_countAt"},{name:"codeAt",call:"eth_codeAt"},{name:"transact",call:"eth_transact"},{name:"call",call:"eth_call"},{name:"block",call:blockCall},{name:"transaction",call:transactionCall},{name:"uncle",call:uncleCall},{name:"compilers",call:"eth_compilers"},{name:"lll",call:"eth_lll"},{name:"solidity",call:"eth_solidity"},{name:"serpent",call:"eth_serpent"}];return methods},ethProperties=function(){return[{name:"coinbase",getter:"eth_coinbase",setter:"eth_setCoinbase"},{name:"listening",getter:"eth_listening",setter:"eth_setListening"},{name:"mining",getter:"eth_mining",setter:"eth_setMining"},{name:"gasPrice",getter:"eth_gasPrice"},{name:"account",getter:"eth_account"},{name:"accounts",getter:"eth_accounts"},{name:"peerCount",getter:"eth_peerCount"},{name:"defaultBlock",getter:"eth_defaultBlock",setter:"eth_setDefaultBlock"},{name:"number",getter:"eth_number"}]},dbMethods=function(){return[{name:"put",call:"db_put"},{name:"get",call:"db_get"},{name:"putString",call:"db_putString"},{name:"getString",call:"db_getString"}]},shhMethods=function(){return[{name:"post",call:"shh_post"},{name:"newIdentity",call:"shh_newIdentity"},{name:"haveIdentity",call:"shh_haveIdentity"},{name:"newGroup",call:"shh_newGroup"},{name:"addToGroup",call:"shh_addToGroup"}]},ethWatchMethods=function(){var newFilter=function(args){return"string"==typeof args[0]?"eth_newFilterString":"eth_newFilter"};return[{name:"newFilter",call:newFilter},{name:"uninstallFilter",call:"eth_uninstallFilter"},{name:"getMessages",call:"eth_getMessages"}]},shhWatchMethods=function(){return[{name:"newFilter",call:"shh_newFilter"},{name:"uninstallFilter",call:"shh_uninstallFilter"},{name:"getMessage",call:"shh_getMessages"}]},setupMethods=function(obj,methods){methods.forEach(function(method){obj[method.name]=function(){return flattenPromise(Array.prototype.slice.call(arguments)).then(function(args){var call="function"==typeof method.call?method.call(args):method.call;return{call:call,args:args}}).then(function(request){return new Promise(function(resolve,reject){web3.provider.send(request,function(err,result){return err?void reject(err):void resolve(result)})})}).catch(function(err){console.error(err)})}})},setupProperties=function(obj,properties){properties.forEach(function(property){var proto={};proto.get=function(){return new Promise(function(resolve,reject){web3.provider.send({call:property.getter},function(err,result){return err?void reject(err):void resolve(result)})})},property.setter&&(proto.set=function(val){return flattenPromise([val]).then(function(args){return new Promise(function(resolve){web3.provider.send({call:property.setter,args:args},function(err,result){return err?void reject(err):void resolve(result)})})}).catch(function(err){console.error(err)})}),Object.defineProperty(obj,property.name,proto)})},web3={_callbacks:{},_events:{},providers:{},toHex:function(str){var i,n,hex="";for(i=0;i<str.length;i++)n=str.charCodeAt(i).toString(16),hex+=n.length<2?"0"+n:n;return hex},toAscii:function(hex){var code,str="",i=0,l=hex.length;for("0x"===hex.substring(0,2)&&(i=2);l>i&&(code=hex.charCodeAt(i),0!==code);i+=2)str+=String.fromCharCode(parseInt(hex.substr(i,2),16));return str},toDecimal:function(val){return parseInt(val,16)},fromAscii:function(str,pad){pad=void 0===pad?32:pad;for(var hex=this.toHex(str);hex.length<2*pad;)hex+="00";return"0x"+hex},eth:{prototype:Object(),watch:function(params){return new Filter(params,ethWatch)}},db:{prototype:Object()},shh:{prototype:Object(),watch:function(params){return new Filter(params,shhWatch)}},on:function(event,id,cb){return void 0===web3._events[event]&&(web3._events[event]={}),web3._events[event][id]=cb,this},off:function(event,id){return void 0!==web3._events[event]&&delete web3._events[event][id],this},trigger:function(event,id,data){var cb,callbacks=web3._events[event];callbacks&&callbacks[id]&&(cb=callbacks[id])(data)}};setupMethods(web3.eth,ethMethods()),setupProperties(web3.eth,ethProperties()),setupMethods(web3.db,dbMethods()),setupMethods(web3.shh,shhMethods()),ethWatch={changed:"eth_changed"},setupMethods(ethWatch,ethWatchMethods()),shhWatch={changed:"shh_changed"},setupMethods(shhWatch,shhWatchMethods()),ProviderManager=function(){var self,poll;this.queued=[],this.polls=[],this.ready=!1,this.provider=void 0,this.id=1,self=this,(poll=function(){self.provider&&self.provider.poll&&self.polls.forEach(function(data){data.data._id=self.id,self.id++,self.provider.poll(data.data,data.id)}),setTimeout(poll,12e3)})()},ProviderManager.prototype.send=function(data,cb){data._id=this.id,cb&&(web3._callbacks[data._id]=cb),data.args=data.args||[],this.id++,void 0!==this.provider?this.provider.send(data):(console.warn("provider is not set"),this.queued.push(data))},ProviderManager.prototype.set=function(provider){void 0!==this.provider&&void 0!==this.provider.unload&&this.provider.unload(),this.provider=provider,this.ready=!0},ProviderManager.prototype.sendQueued=function(){for(var i=0;this.queued.length;i++)this.send(this.queued[i])},ProviderManager.prototype.installed=function(){return void 0!==this.provider},ProviderManager.prototype.startPolling=function(data,pollId){this.provider&&this.provider.poll&&this.polls.push({data:data,id:pollId})},ProviderManager.prototype.stopPolling=function(pollId){var i,poll;for(i=this.polls.length;i--;)poll=this.polls[i],poll.id===pollId&&this.polls.splice(i,1)},web3.provider=new ProviderManager,web3.setProvider=function(provider){provider.onmessage=messageHandler,web3.provider.set(provider),web3.provider.sendQueued()},web3.haveProvider=function(){return!!web3.provider.provider},Filter=function(options,impl){this.impl=impl,this.callbacks=[];var self=this;this.promise=impl.newFilter(options),this.promise.then(function(id){self.id=id,web3.on(impl.changed,id,self.trigger.bind(self)),web3.provider.startPolling({call:impl.changed,args:[id]},id)})},Filter.prototype.arrived=function(callback){this.changed(callback)},Filter.prototype.changed=function(callback){var self=this;this.promise.then(function(id){self.callbacks.push(callback)})},Filter.prototype.trigger=function(messages){for(var i=0;i<this.callbacks.length;i++)this.callbacks[i].call(this,messages)},Filter.prototype.uninstall=function(){var self=this;this.promise.then(function(id){self.impl.uninstallFilter(id),web3.provider.stopPolling(id),web3.off(impl.changed,id)})},Filter.prototype.messages=function(){var self=this;return this.promise.then(function(id){return self.impl.getMessages(id)})},module.exports=web3;
},{}],6:[function(require,module,exports){
+var QtProvider=function(){this.handlers=[];var self=this;navigator.qt.onmessage=function(message){self.handlers.forEach(function(handler){handler.call(self,JSON.parse(message.data))})}};QtProvider.prototype.send=function(payload){navigator.qt.postMessage(JSON.stringify(payload))},Object.defineProperty(QtProvider.prototype,"onmessage",{set:function(handler){this.handlers.push(handler)}}),module.exports=QtProvider;
+},{}],7:[function(require,module,exports){
var WebSocketProvider=function(host){this.handlers=[],this.queued=[],this.ready=!1,this.ws=new WebSocket(host);var self=this;this.ws.onmessage=function(event){for(var i=0;i<self.handlers.length;i++)self.handlers[i].call(self,JSON.parse(event.data),event)},this.ws.onopen=function(){self.ready=!0;for(var i=0;i<self.queued.length;i++)self.send(self.queued[i])}};WebSocketProvider.prototype.send=function(payload){if(this.ready){var data=JSON.stringify(payload);this.ws.send(data)}else this.queued.push(payload)},WebSocketProvider.prototype.onMessage=function(handler){this.handlers.push(handler)},WebSocketProvider.prototype.unload=function(){this.ws.close()},Object.defineProperty(WebSocketProvider.prototype,"onmessage",{set:function(provider){this.onMessage(provider)}}),module.exports=WebSocketProvider;
},{}],"web3":[function(require,module,exports){
-var web3=require("./lib/main");web3.providers.WebSocketProvider=require("./lib/websocket"),web3.providers.HttpRpcProvider=require("./lib/httprpc"),web3.providers.QtProvider=require("./lib/qt"),web3.providers.AutoProvider=require("./lib/autoprovider"),web3.contract=require("./lib/abi"),module.exports=web3;
-},{"./lib/abi":1,"./lib/autoprovider":2,"./lib/httprpc":3,"./lib/main":4,"./lib/qt":5,"./lib/websocket":6}]},{},[])
+var web3=require("./lib/main");web3.providers.WebSocketProvider=require("./lib/websocket"),web3.providers.HttpRpcProvider=require("./lib/httprpc"),web3.providers.QtProvider=require("./lib/qt"),web3.providers.AutoProvider=require("./lib/autoprovider"),web3.contract=require("./lib/contract"),module.exports=web3;
+},{"./lib/autoprovider":2,"./lib/contract":3,"./lib/httprpc":4,"./lib/main":5,"./lib/qt":6,"./lib/websocket":7}]},{},[])
//# sourceMappingURL=ethereum.js.map \ No newline at end of file
diff --git a/dist/ethereum.js.map b/dist/ethereum.js.map
index f5dcfd0ba..72d4eb684 100644
--- a/dist/ethereum.js.map
+++ b/dist/ethereum.js.map
@@ -4,6 +4,7 @@
"node_modules/browserify/node_modules/browser-pack/_prelude.js",
"lib/abi.js",
"lib/autoprovider.js",
+ "lib/contract.js",
"lib/httprpc.js",
"lib/main.js",
"lib/qt.js",
@@ -11,17 +12,18 @@
"index.js"
],
"names": [],
- "mappings": "AAAA;ACAA;;ACAA;;ACAA;;ACAA;;ACAA;;ACAA;;ACAA",
+ "mappings": "AAAA;ACAA;;ACAA;;ACAA;;ACAA;;ACAA;;ACAA;;ACAA;;ACAA",
"file": "generated.js",
"sourceRoot": "",
"sourcesContent": [
"(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require==\"function\"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error(\"Cannot find module '\"+o+\"'\");throw f.code=\"MODULE_NOT_FOUND\",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require==\"function\"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})",
- "var findIndex=function(array,callback){for(var end=!1,i=0;i<array.length&&!end;i++)end=callback(array[i]);return end?i-1:-1},findMethodIndex=function(json,methodName){return findIndex(json,function(method){return method.name===methodName})},padLeft=function(number,n){return new Array(2*n-number.toString().length+1).join(\"0\")+number},setupInputTypes=function(){var prefixedType=function(prefix){return function(type,value){var padding,expected=prefix;return 0!==type.indexOf(expected)?!1:(padding=parseInt(type.slice(expected.length))/8,padLeft(value,padding))}},namedType=function(name,padding,formatter){return function(type,value){return type!==name?!1:padLeft(formatter?value:formatter(value),padding)}},formatBool=function(value){return value?\"1\":\"0\"};return[prefixedType(\"uint\"),prefixedType(\"int\"),namedType(\"address\",20),namedType(\"bool\",1,formatBool)]},inputTypes=setupInputTypes(),toAbiInput=function(json,methodName,params){var method,i,found,j,bytes=\"\",index=findMethodIndex(json,methodName);if(-1!==index){for(bytes=bytes+index+\"x0\",method=json[index],i=0;i<method.inputs.length;i++){for(found=!1,j=0;j<inputTypes.length&&!found;j++)found=inputTypes[j](method.inputs[i].type,params[i]);found||console.error(\"unsupported json type: \"+method.inputs[i].type),bytes+=found}return bytes}},setupOutputTypes=function(){var prefixedType=function(prefix){return function(type){var padding,expected=prefix;return 0!==type.indexOf(expected)?-1:(padding=parseInt(type.slice(expected.length))/8,2*padding)}},namedType=function(name,padding){return function(type){return name===type?2*padding:-1}},formatInt=function(value){return parseInt(value,16)},formatBool=function(value){return\"1\"===value?!0:!1};return[{padding:prefixedType(\"uint\"),format:formatInt},{padding:prefixedType(\"int\"),format:formatInt},{padding:namedType(\"address\",20)},{padding:namedType(\"bool\",1),format:formatBool}]},outputTypes=setupOutputTypes(),fromAbiOutput=function(json,methodName,output){var result,method,i,padding,j,res,formatter,index=findMethodIndex(json,methodName);if(-1!==index){for(output=output.slice(2),result=[],method=json[index],i=0;i<method.outputs.length;i++){for(padding=-1,j=0;j<outputTypes.length&&-1===padding;j++)padding=outputTypes[j].padding(method.outputs[i].type);-1!==padding&&(res=output.slice(0,padding),formatter=outputTypes[j-1].format,result.push(formatter?formatter(res):res),output=output.slice(padding))}return result}},load=function(json){var contract={};return json.forEach(function(method){contract[method.name]=function(){var params=Array.prototype.slice.call(arguments);return toAbiInput(json,method.name,params)}}),contract};module.exports=load;",
+ "var findIndex=function(array,callback){for(var end=!1,i=0;i<array.length&&!end;i++)end=callback(array[i]);return end?i-1:-1},findMethodIndex=function(json,methodName){return findIndex(json,function(method){return method.name===methodName})},padLeft=function(number,n){return new Array(2*n-number.toString().length+1).join(\"0\")+number},setupInputTypes=function(){var prefixedType=function(prefix){return function(type,value){var padding,expected=prefix;return 0!==type.indexOf(expected)?!1:(padding=parseInt(type.slice(expected.length))/8,padLeft(value,padding))}},namedType=function(name,padding,formatter){return function(type,value){return type!==name?!1:padLeft(formatter?value:formatter(value),padding)}},formatBool=function(value){return value?\"1\":\"0\"};return[prefixedType(\"uint\"),prefixedType(\"int\"),namedType(\"address\",20),namedType(\"bool\",1,formatBool)]},inputTypes=setupInputTypes(),toAbiInput=function(json,methodName,params){var method,i,found,j,val,bytes=\"\",index=findMethodIndex(json,methodName);if(-1!==index){for(bytes=bytes+index+\"x0\",method=json[index],i=0;i<method.inputs.length;i++){for(found=!1,j=0;j<inputTypes.length&&!found;j++)val=parseInt(params[i]).toString(16),found=inputTypes[j](method.inputs[i].type,val);found||console.error(\"unsupported json type: \"+method.inputs[i].type),bytes+=found}return bytes}},setupOutputTypes=function(){var prefixedType=function(prefix){return function(type){var padding,expected=prefix;return 0!==type.indexOf(expected)?-1:(padding=parseInt(type.slice(expected.length))/8,2*padding)}},namedType=function(name,padding){return function(type){return name===type?2*padding:-1}},formatInt=function(value){return parseInt(value,16)},formatBool=function(value){return\"1\"===value?!0:!1};return[{padding:prefixedType(\"uint\"),format:formatInt},{padding:prefixedType(\"int\"),format:formatInt},{padding:namedType(\"address\",20)},{padding:namedType(\"bool\",1),format:formatBool}]},outputTypes=setupOutputTypes(),fromAbiOutput=function(json,methodName,output){var result,method,i,padding,j,res,formatter,index=findMethodIndex(json,methodName);if(-1!==index){for(output=output.slice(2),result=[],method=json[index],i=0;i<method.outputs.length;i++){for(padding=-1,j=0;j<outputTypes.length&&-1===padding;j++)padding=outputTypes[j].padding(method.outputs[i].type);-1!==padding&&(res=output.slice(0,padding),formatter=outputTypes[j-1].format,result.push(formatter?formatter(res):res),output=output.slice(padding))}return result}},inputParser=function(json){var parser={};return json.forEach(function(method){parser[method.name]=function(){var params=Array.prototype.slice.call(arguments);return toAbiInput(json,method.name,params)}}),parser},outputParser=function(json){var parser={};return json.forEach(function(method){parser[method.name]=function(output){return fromAbiOutput(json,method.name,output)}}),parser};module.exports={inputParser:inputParser,outputParser:outputParser};",
"var AutoProvider=function(userOptions){var options,self,closeWithSuccess,ws;if(!web3.haveProvider()){if(this.sendQueue=[],this.onmessageQueue=[],navigator.qt)return void(this.provider=new web3.providers.QtProvider);userOptions=userOptions||{},options={httprpc:userOptions.httprpc||\"http://localhost:8080\",websockets:userOptions.websockets||\"ws://localhost:40404/eth\"},self=this,closeWithSuccess=function(success){ws.close(),success?self.provider=new web3.providers.WebSocketProvider(options.websockets):(self.provider=new web3.providers.HttpRpcProvider(options.httprpc),self.poll=self.provider.poll.bind(self.provider)),self.sendQueue.forEach(function(payload){self.provider(payload)}),self.onmessageQueue.forEach(function(handler){self.provider.onmessage=handler})},ws=new WebSocket(options.websockets),ws.onopen=function(){closeWithSuccess(!0)},ws.onerror=function(){closeWithSuccess(!1)}}};AutoProvider.prototype.send=function(payload){return this.provider?void this.provider.send(payload):void this.sendQueue.push(payload)},Object.defineProperty(AutoProvider.prototype,\"onmessage\",{set:function(handler){return this.provider?void(this.provider.onmessage=handler):void this.onmessageQueue.push(handler)}}),module.exports=AutoProvider;",
+ "var abi,contract;abi=require(\"./abi\"),contract=function(address,desc){var inputParser=abi.inputParser(desc),outputParser=abi.outputParser(desc),contract={};return desc.forEach(function(method){contract[method.name]=function(){var params=Array.prototype.slice.call(arguments),parsed=inputParser[method.name].apply(null,params),onSuccess=function(result){return outputParser[method.name](result)};return{call:function(extra){return extra=extra||{},extra.to=address,extra.data=parsed,web3.eth.call(extra).then(onSuccess)},transact:function(extra){return extra=extra||{},extra.to=address,extra.data=parsed,web3.eth.transact(extra).then(onSuccess)}}}}),contract},module.exports=contract;",
"function formatJsonRpcObject(object){return{jsonrpc:\"2.0\",method:object.call,params:object.args,id:object._id}}function formatJsonRpcMessage(message){var object=JSON.parse(message);return{_id:object.id,data:object.result,error:object.error}}var HttpRpcProvider=function(host){this.handlers=[],this.host=host};HttpRpcProvider.prototype.sendRequest=function(payload,cb){var data=formatJsonRpcObject(payload),request=new XMLHttpRequest;request.open(\"POST\",this.host,!0),request.send(JSON.stringify(data)),request.onreadystatechange=function(){4===request.readyState&&cb&&cb(request)}},HttpRpcProvider.prototype.send=function(payload){var self=this;this.sendRequest(payload,function(request){self.handlers.forEach(function(handler){handler.call(self,formatJsonRpcMessage(request.responseText))})})},HttpRpcProvider.prototype.poll=function(payload,id){var self=this;this.sendRequest(payload,function(request){var parsed=JSON.parse(request.responseText);!parsed.error&&(parsed.result instanceof Array?0!==parsed.result.length:parsed.result)&&self.handlers.forEach(function(handler){handler.call(self,{_event:payload.call,_id:id,data:parsed.result})})})},Object.defineProperty(HttpRpcProvider.prototype,\"onmessage\",{set:function(handler){this.handlers.push(handler)}}),module.exports=HttpRpcProvider;",
- "function flattenPromise(obj){return obj instanceof Promise?Promise.resolve(obj):obj instanceof Array?new Promise(function(resolve){var promises=obj.map(function(o){return flattenPromise(o)});return Promise.all(promises).then(function(res){for(var i=0;i<obj.length;i++)obj[i]=res[i];resolve(obj)})}):obj instanceof Object?new Promise(function(resolve){var keys=Object.keys(obj),promises=keys.map(function(key){return flattenPromise(obj[key])});return Promise.all(promises).then(function(res){for(var i=0;i<keys.length;i++)obj[keys[i]]=res[i];resolve(obj)})}):Promise.resolve(obj)}function messageHandler(data){if(void 0!==data._event)return void web3.trigger(data._event,data._id,data.data);if(data._id){var cb=web3._callbacks[data._id];cb&&(cb.call(this,data.error,data.data),delete web3._callbacks[data._id])}}var ethWatch,shhWatch,ProviderManager,Filter,ethMethods=function(){var blockCall=function(args){return\"string\"==typeof args[0]?\"eth_blockByHash\":\"eth_blockByNumber\"},transactionCall=function(args){return\"string\"==typeof args[0]?\"eth_transactionByHash\":\"eth_transactionByNumber\"},uncleCall=function(args){return\"string\"==typeof args[0]?\"eth_uncleByHash\":\"eth_uncleByNumber\"},methods=[{name:\"balanceAt\",call:\"eth_balanceAt\"},{name:\"stateAt\",call:\"eth_stateAt\"},{name:\"storageAt\",call:\"eth_storageAt\"},{name:\"countAt\",call:\"eth_countAt\"},{name:\"codeAt\",call:\"eth_codeAt\"},{name:\"transact\",call:\"eth_transact\"},{name:\"call\",call:\"eth_call\"},{name:\"block\",call:blockCall},{name:\"transaction\",call:transactionCall},{name:\"uncle\",call:uncleCall},{name:\"compilers\",call:\"eth_compilers\"},{name:\"lll\",call:\"eth_lll\"},{name:\"solidity\",call:\"eth_solidity\"}];return methods},ethProperties=function(){return[{name:\"coinbase\",getter:\"eth_coinbase\",setter:\"eth_setCoinbase\"},{name:\"listening\",getter:\"eth_listening\",setter:\"eth_setListening\"},{name:\"mining\",getter:\"eth_mining\",setter:\"eth_setMining\"},{name:\"gasPrice\",getter:\"eth_gasPrice\"},{name:\"account\",getter:\"eth_account\"},{name:\"accounts\",getter:\"eth_accounts\"},{name:\"peerCount\",getter:\"eth_peerCount\"},{name:\"defaultBlock\",getter:\"eth_defaultBlock\",setter:\"eth_setDefaultBlock\"},{name:\"number\",getter:\"eth_number\"}]},dbMethods=function(){return[{name:\"put\",call:\"db_put\"},{name:\"get\",call:\"db_get\"},{name:\"putString\",call:\"db_putString\"},{name:\"getString\",call:\"db_getString\"}]},shhMethods=function(){return[{name:\"post\",call:\"shh_post\"},{name:\"newIdentity\",call:\"shh_newIdentity\"},{name:\"haveIdentity\",call:\"shh_haveIdentity\"},{name:\"newGroup\",call:\"shh_newGroup\"},{name:\"addToGroup\",call:\"shh_addToGroup\"}]},ethWatchMethods=function(){var newFilter=function(args){return\"string\"==typeof args[0]?\"eth_newFilterString\":\"eth_newFilter\"};return[{name:\"newFilter\",call:newFilter},{name:\"uninstallFilter\",call:\"eth_uninstallFilter\"},{name:\"getMessages\",call:\"eth_getMessages\"}]},shhWatchMethods=function(){return[{name:\"newFilter\",call:\"shh_newFilter\"},{name:\"uninstallFilter\",call:\"shh_uninstallFilter\"},{name:\"getMessage\",call:\"shh_getMessages\"}]},setupMethods=function(obj,methods){methods.forEach(function(method){obj[method.name]=function(){return flattenPromise(Array.prototype.slice.call(arguments)).then(function(args){var call=\"function\"==typeof method.call?method.call(args):method.call;return{call:call,args:args}}).then(function(request){return new Promise(function(resolve,reject){web3.provider.send(request,function(err,result){return err?void reject(err):void resolve(result)})})}).catch(function(err){console.error(err)})}})},setupProperties=function(obj,properties){properties.forEach(function(property){var proto={};proto.get=function(){return new Promise(function(resolve,reject){web3.provider.send({call:property.getter},function(err,result){return err?void reject(err):void resolve(result)})})},property.setter&&(proto.set=function(val){return flattenPromise([val]).then(function(args){return new Promise(function(resolve){web3.provider.send({call:property.setter,args:args},function(err,result){return err?void reject(err):void resolve(result)})})}).catch(function(err){console.error(err)})}),Object.defineProperty(obj,property.name,proto)})},web3={_callbacks:{},_events:{},providers:{},toHex:function(str){var i,n,hex=\"\";for(i=0;i<str.length;i++)n=str.charCodeAt(i).toString(16),hex+=n.length<2?\"0\"+n:n;return hex},toAscii:function(hex){var code,str=\"\",i=0,l=hex.length;for(\"0x\"===hex.substring(0,2)&&(i=2);l>i&&(code=hex.charCodeAt(i),0!==code);i+=2)str+=String.fromCharCode(parseInt(hex.substr(i,2),16));return str},toDecimal:function(val){return parseInt(val,16)},fromAscii:function(str,pad){pad=void 0===pad?32:pad;for(var hex=this.toHex(str);hex.length<2*pad;)hex+=\"00\";return\"0x\"+hex},eth:{prototype:Object(),watch:function(params){return new Filter(params,ethWatch)}},db:{prototype:Object()},shh:{prototype:Object(),watch:function(params){return new Filter(params,shhWatch)}},on:function(event,id,cb){return void 0===web3._events[event]&&(web3._events[event]={}),web3._events[event][id]=cb,this},off:function(event,id){return void 0!==web3._events[event]&&delete web3._events[event][id],this},trigger:function(event,id,data){var cb,callbacks=web3._events[event];callbacks&&callbacks[id]&&(cb=callbacks[id])(data)}},eth=web3.eth;setupMethods(eth,ethMethods()),setupProperties(eth,ethProperties()),setupMethods(web3.db,dbMethods()),setupMethods(web3.shh,shhMethods()),ethWatch={changed:\"eth_changed\"},setupMethods(ethWatch,ethWatchMethods()),shhWatch={changed:\"shh_changed\"},setupMethods(shhWatch,shhWatchMethods()),ProviderManager=function(){var self,poll;this.queued=[],this.polls=[],this.ready=!1,this.provider=void 0,this.id=1,self=this,(poll=function(){self.provider&&self.provider.poll&&self.polls.forEach(function(data){data.data._id=self.id,self.id++,self.provider.poll(data.data,data.id)}),setTimeout(poll,12e3)})()},ProviderManager.prototype.send=function(data,cb){data._id=this.id,cb&&(web3._callbacks[data._id]=cb),data.args=data.args||[],this.id++,void 0!==this.provider?this.provider.send(data):(console.warn(\"provider is not set\"),this.queued.push(data))},ProviderManager.prototype.set=function(provider){void 0!==this.provider&&void 0!==this.provider.unload&&this.provider.unload(),this.provider=provider,this.ready=!0},ProviderManager.prototype.sendQueued=function(){for(var i=0;this.queued.length;i++)this.send(this.queued[i])},ProviderManager.prototype.installed=function(){return void 0!==this.provider},ProviderManager.prototype.startPolling=function(data,pollId){this.provider&&this.provider.poll&&this.polls.push({data:data,id:pollId})},ProviderManager.prototype.stopPolling=function(pollId){var i,poll;for(i=this.polls.length;i--;)poll=this.polls[i],poll.id===pollId&&this.polls.splice(i,1)},web3.provider=new ProviderManager,web3.setProvider=function(provider){provider.onmessage=messageHandler,web3.provider.set(provider),web3.provider.sendQueued()},web3.haveProvider=function(){return!!web3.provider.provider},Filter=function(options,impl){this.impl=impl,this.callbacks=[];var self=this;this.promise=impl.newFilter(options),this.promise.then(function(id){self.id=id,web3.on(impl.changed,id,self.trigger.bind(self)),web3.provider.startPolling({call:impl.changed,args:[id]},id)})},Filter.prototype.arrived=function(callback){this.changed(callback)},Filter.prototype.changed=function(callback){var self=this;this.promise.then(function(id){self.callbacks.push(callback)})},Filter.prototype.trigger=function(messages){for(var i=0;i<this.callbacks.length;i++)this.callbacks[i].call(this,messages)},Filter.prototype.uninstall=function(){var self=this;this.promise.then(function(id){self.impl.uninstallFilter(id),web3.provider.stopPolling(id),web3.off(impl.changed,id)})},Filter.prototype.messages=function(){var self=this;return this.promise.then(function(id){return self.impl.getMessages(id)})},module.exports=web3;",
+ "function flattenPromise(obj){return obj instanceof Promise?Promise.resolve(obj):obj instanceof Array?new Promise(function(resolve){var promises=obj.map(function(o){return flattenPromise(o)});return Promise.all(promises).then(function(res){for(var i=0;i<obj.length;i++)obj[i]=res[i];resolve(obj)})}):obj instanceof Object?new Promise(function(resolve){var keys=Object.keys(obj),promises=keys.map(function(key){return flattenPromise(obj[key])});return Promise.all(promises).then(function(res){for(var i=0;i<keys.length;i++)obj[keys[i]]=res[i];resolve(obj)})}):Promise.resolve(obj)}function messageHandler(data){if(void 0!==data._event)return void web3.trigger(data._event,data._id,data.data);if(data._id){var cb=web3._callbacks[data._id];cb&&(cb.call(this,data.error,data.data),delete web3._callbacks[data._id])}}var ethWatch,shhWatch,ProviderManager,Filter,ethMethods=function(){var blockCall=function(args){return\"string\"==typeof args[0]?\"eth_blockByHash\":\"eth_blockByNumber\"},transactionCall=function(args){return\"string\"==typeof args[0]?\"eth_transactionByHash\":\"eth_transactionByNumber\"},uncleCall=function(args){return\"string\"==typeof args[0]?\"eth_uncleByHash\":\"eth_uncleByNumber\"},methods=[{name:\"balanceAt\",call:\"eth_balanceAt\"},{name:\"stateAt\",call:\"eth_stateAt\"},{name:\"storageAt\",call:\"eth_storageAt\"},{name:\"countAt\",call:\"eth_countAt\"},{name:\"codeAt\",call:\"eth_codeAt\"},{name:\"transact\",call:\"eth_transact\"},{name:\"call\",call:\"eth_call\"},{name:\"block\",call:blockCall},{name:\"transaction\",call:transactionCall},{name:\"uncle\",call:uncleCall},{name:\"compilers\",call:\"eth_compilers\"},{name:\"lll\",call:\"eth_lll\"},{name:\"solidity\",call:\"eth_solidity\"},{name:\"serpent\",call:\"eth_serpent\"}];return methods},ethProperties=function(){return[{name:\"coinbase\",getter:\"eth_coinbase\",setter:\"eth_setCoinbase\"},{name:\"listening\",getter:\"eth_listening\",setter:\"eth_setListening\"},{name:\"mining\",getter:\"eth_mining\",setter:\"eth_setMining\"},{name:\"gasPrice\",getter:\"eth_gasPrice\"},{name:\"account\",getter:\"eth_account\"},{name:\"accounts\",getter:\"eth_accounts\"},{name:\"peerCount\",getter:\"eth_peerCount\"},{name:\"defaultBlock\",getter:\"eth_defaultBlock\",setter:\"eth_setDefaultBlock\"},{name:\"number\",getter:\"eth_number\"}]},dbMethods=function(){return[{name:\"put\",call:\"db_put\"},{name:\"get\",call:\"db_get\"},{name:\"putString\",call:\"db_putString\"},{name:\"getString\",call:\"db_getString\"}]},shhMethods=function(){return[{name:\"post\",call:\"shh_post\"},{name:\"newIdentity\",call:\"shh_newIdentity\"},{name:\"haveIdentity\",call:\"shh_haveIdentity\"},{name:\"newGroup\",call:\"shh_newGroup\"},{name:\"addToGroup\",call:\"shh_addToGroup\"}]},ethWatchMethods=function(){var newFilter=function(args){return\"string\"==typeof args[0]?\"eth_newFilterString\":\"eth_newFilter\"};return[{name:\"newFilter\",call:newFilter},{name:\"uninstallFilter\",call:\"eth_uninstallFilter\"},{name:\"getMessages\",call:\"eth_getMessages\"}]},shhWatchMethods=function(){return[{name:\"newFilter\",call:\"shh_newFilter\"},{name:\"uninstallFilter\",call:\"shh_uninstallFilter\"},{name:\"getMessage\",call:\"shh_getMessages\"}]},setupMethods=function(obj,methods){methods.forEach(function(method){obj[method.name]=function(){return flattenPromise(Array.prototype.slice.call(arguments)).then(function(args){var call=\"function\"==typeof method.call?method.call(args):method.call;return{call:call,args:args}}).then(function(request){return new Promise(function(resolve,reject){web3.provider.send(request,function(err,result){return err?void reject(err):void resolve(result)})})}).catch(function(err){console.error(err)})}})},setupProperties=function(obj,properties){properties.forEach(function(property){var proto={};proto.get=function(){return new Promise(function(resolve,reject){web3.provider.send({call:property.getter},function(err,result){return err?void reject(err):void resolve(result)})})},property.setter&&(proto.set=function(val){return flattenPromise([val]).then(function(args){return new Promise(function(resolve){web3.provider.send({call:property.setter,args:args},function(err,result){return err?void reject(err):void resolve(result)})})}).catch(function(err){console.error(err)})}),Object.defineProperty(obj,property.name,proto)})},web3={_callbacks:{},_events:{},providers:{},toHex:function(str){var i,n,hex=\"\";for(i=0;i<str.length;i++)n=str.charCodeAt(i).toString(16),hex+=n.length<2?\"0\"+n:n;return hex},toAscii:function(hex){var code,str=\"\",i=0,l=hex.length;for(\"0x\"===hex.substring(0,2)&&(i=2);l>i&&(code=hex.charCodeAt(i),0!==code);i+=2)str+=String.fromCharCode(parseInt(hex.substr(i,2),16));return str},toDecimal:function(val){return parseInt(val,16)},fromAscii:function(str,pad){pad=void 0===pad?32:pad;for(var hex=this.toHex(str);hex.length<2*pad;)hex+=\"00\";return\"0x\"+hex},eth:{prototype:Object(),watch:function(params){return new Filter(params,ethWatch)}},db:{prototype:Object()},shh:{prototype:Object(),watch:function(params){return new Filter(params,shhWatch)}},on:function(event,id,cb){return void 0===web3._events[event]&&(web3._events[event]={}),web3._events[event][id]=cb,this},off:function(event,id){return void 0!==web3._events[event]&&delete web3._events[event][id],this},trigger:function(event,id,data){var cb,callbacks=web3._events[event];callbacks&&callbacks[id]&&(cb=callbacks[id])(data)}};setupMethods(web3.eth,ethMethods()),setupProperties(web3.eth,ethProperties()),setupMethods(web3.db,dbMethods()),setupMethods(web3.shh,shhMethods()),ethWatch={changed:\"eth_changed\"},setupMethods(ethWatch,ethWatchMethods()),shhWatch={changed:\"shh_changed\"},setupMethods(shhWatch,shhWatchMethods()),ProviderManager=function(){var self,poll;this.queued=[],this.polls=[],this.ready=!1,this.provider=void 0,this.id=1,self=this,(poll=function(){self.provider&&self.provider.poll&&self.polls.forEach(function(data){data.data._id=self.id,self.id++,self.provider.poll(data.data,data.id)}),setTimeout(poll,12e3)})()},ProviderManager.prototype.send=function(data,cb){data._id=this.id,cb&&(web3._callbacks[data._id]=cb),data.args=data.args||[],this.id++,void 0!==this.provider?this.provider.send(data):(console.warn(\"provider is not set\"),this.queued.push(data))},ProviderManager.prototype.set=function(provider){void 0!==this.provider&&void 0!==this.provider.unload&&this.provider.unload(),this.provider=provider,this.ready=!0},ProviderManager.prototype.sendQueued=function(){for(var i=0;this.queued.length;i++)this.send(this.queued[i])},ProviderManager.prototype.installed=function(){return void 0!==this.provider},ProviderManager.prototype.startPolling=function(data,pollId){this.provider&&this.provider.poll&&this.polls.push({data:data,id:pollId})},ProviderManager.prototype.stopPolling=function(pollId){var i,poll;for(i=this.polls.length;i--;)poll=this.polls[i],poll.id===pollId&&this.polls.splice(i,1)},web3.provider=new ProviderManager,web3.setProvider=function(provider){provider.onmessage=messageHandler,web3.provider.set(provider),web3.provider.sendQueued()},web3.haveProvider=function(){return!!web3.provider.provider},Filter=function(options,impl){this.impl=impl,this.callbacks=[];var self=this;this.promise=impl.newFilter(options),this.promise.then(function(id){self.id=id,web3.on(impl.changed,id,self.trigger.bind(self)),web3.provider.startPolling({call:impl.changed,args:[id]},id)})},Filter.prototype.arrived=function(callback){this.changed(callback)},Filter.prototype.changed=function(callback){var self=this;this.promise.then(function(id){self.callbacks.push(callback)})},Filter.prototype.trigger=function(messages){for(var i=0;i<this.callbacks.length;i++)this.callbacks[i].call(this,messages)},Filter.prototype.uninstall=function(){var self=this;this.promise.then(function(id){self.impl.uninstallFilter(id),web3.provider.stopPolling(id),web3.off(impl.changed,id)})},Filter.prototype.messages=function(){var self=this;return this.promise.then(function(id){return self.impl.getMessages(id)})},module.exports=web3;",
"var QtProvider=function(){this.handlers=[];var self=this;navigator.qt.onmessage=function(message){self.handlers.forEach(function(handler){handler.call(self,JSON.parse(message.data))})}};QtProvider.prototype.send=function(payload){navigator.qt.postMessage(JSON.stringify(payload))},Object.defineProperty(QtProvider.prototype,\"onmessage\",{set:function(handler){this.handlers.push(handler)}}),module.exports=QtProvider;",
"var WebSocketProvider=function(host){this.handlers=[],this.queued=[],this.ready=!1,this.ws=new WebSocket(host);var self=this;this.ws.onmessage=function(event){for(var i=0;i<self.handlers.length;i++)self.handlers[i].call(self,JSON.parse(event.data),event)},this.ws.onopen=function(){self.ready=!0;for(var i=0;i<self.queued.length;i++)self.send(self.queued[i])}};WebSocketProvider.prototype.send=function(payload){if(this.ready){var data=JSON.stringify(payload);this.ws.send(data)}else this.queued.push(payload)},WebSocketProvider.prototype.onMessage=function(handler){this.handlers.push(handler)},WebSocketProvider.prototype.unload=function(){this.ws.close()},Object.defineProperty(WebSocketProvider.prototype,\"onmessage\",{set:function(provider){this.onMessage(provider)}}),module.exports=WebSocketProvider;",
- "var web3=require(\"./lib/main\");web3.providers.WebSocketProvider=require(\"./lib/websocket\"),web3.providers.HttpRpcProvider=require(\"./lib/httprpc\"),web3.providers.QtProvider=require(\"./lib/qt\"),web3.providers.AutoProvider=require(\"./lib/autoprovider\"),web3.contract=require(\"./lib/abi\"),module.exports=web3;"
+ "var web3=require(\"./lib/main\");web3.providers.WebSocketProvider=require(\"./lib/websocket\"),web3.providers.HttpRpcProvider=require(\"./lib/httprpc\"),web3.providers.QtProvider=require(\"./lib/qt\"),web3.providers.AutoProvider=require(\"./lib/autoprovider\"),web3.contract=require(\"./lib/contract\"),module.exports=web3;"
]
} \ No newline at end of file
diff --git a/dist/ethereum.min.js b/dist/ethereum.min.js
index 125523290..60a267d99 100644
--- a/dist/ethereum.min.js
+++ b/dist/ethereum.min.js
@@ -1 +1 @@
-require=function e(t,n,r){function o(s,a){if(!n[s]){if(!t[s]){var c="function"==typeof require&&require;if(!a&&c)return c(s,!0);if(i)return i(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var l=n[s]={exports:{}};t[s][0].call(l.exports,function(e){var n=t[s][1][e];return o(n?n:e)},l,l.exports,e,t,n,r)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s<r.length;s++)o(r[s]);return o}({1:[function(e,t){var n=function(e,t){for(var n=!1,r=0;r<e.length&&!n;r++)n=t(e[r]);return n?r-1:-1},r=function(e,t){return n(e,function(e){return e.name===t})},o=function(e,t){return new Array(2*t-e.toString().length+1).join("0")+e},i=function(){var e=function(e){return function(t,n){var r,i=e;return 0!==t.indexOf(i)?!1:(r=parseInt(t.slice(i.length))/8,o(n,r))}},t=function(e,t,n){return function(r,i){return r!==e?!1:o(n?i:n(i),t)}},n=function(e){return e?"1":"0"};return[e("uint"),e("int"),t("address",20),t("bool",1,n)]},s=i(),a=function(e,t,n){var o,i,a,c,u="",l=r(e,t);if(-1!==l){for(u=u+l+"x0",o=e[l],i=0;i<o.inputs.length;i++){for(a=!1,c=0;c<s.length&&!a;c++)a=s[c](o.inputs[i].type,n[i]);a||console.error("unsupported json type: "+o.inputs[i].type),u+=a}return u}},c=function(){var e=function(e){return function(t){var n,r=e;return 0!==t.indexOf(r)?-1:(n=parseInt(t.slice(r.length))/8,2*n)}},t=function(e,t){return function(n){return e===n?2*t:-1}},n=function(e){return parseInt(e,16)},r=function(e){return"1"===e?!0:!1};return[{padding:e("uint"),format:n},{padding:e("int"),format:n},{padding:t("address",20)},{padding:t("bool",1),format:r}]},u=(c(),function(e){var t={};return e.forEach(function(n){t[n.name]=function(){var t=Array.prototype.slice.call(arguments);return a(e,n.name,t)}}),t});t.exports=u},{}],2:[function(e,t){var n=function(e){var t,n,r,o;if(!web3.haveProvider()){if(this.sendQueue=[],this.onmessageQueue=[],navigator.qt)return void(this.provider=new web3.providers.QtProvider);e=e||{},t={httprpc:e.httprpc||"http://localhost:8080",websockets:e.websockets||"ws://localhost:40404/eth"},n=this,r=function(e){o.close(),e?n.provider=new web3.providers.WebSocketProvider(t.websockets):(n.provider=new web3.providers.HttpRpcProvider(t.httprpc),n.poll=n.provider.poll.bind(n.provider)),n.sendQueue.forEach(function(e){n.provider(e)}),n.onmessageQueue.forEach(function(e){n.provider.onmessage=e})},o=new WebSocket(t.websockets),o.onopen=function(){r(!0)},o.onerror=function(){r(!1)}}};n.prototype.send=function(e){return this.provider?void this.provider.send(e):void this.sendQueue.push(e)},Object.defineProperty(n.prototype,"onmessage",{set:function(e){return this.provider?void(this.provider.onmessage=e):void this.onmessageQueue.push(e)}}),t.exports=n},{}],3:[function(e,t){function n(e){return{jsonrpc:"2.0",method:e.call,params:e.args,id:e._id}}function r(e){var t=JSON.parse(e);return{_id:t.id,data:t.result,error:t.error}}var o=function(e){this.handlers=[],this.host=e};o.prototype.sendRequest=function(e,t){var r=n(e),o=new XMLHttpRequest;o.open("POST",this.host,!0),o.send(JSON.stringify(r)),o.onreadystatechange=function(){4===o.readyState&&t&&t(o)}},o.prototype.send=function(e){var t=this;this.sendRequest(e,function(e){t.handlers.forEach(function(n){n.call(t,r(e.responseText))})})},o.prototype.poll=function(e,t){var n=this;this.sendRequest(e,function(r){var o=JSON.parse(r.responseText);!o.error&&(o.result instanceof Array?0!==o.result.length:o.result)&&n.handlers.forEach(function(r){r.call(n,{_event:e.call,_id:t,data:o.result})})})},Object.defineProperty(o.prototype,"onmessage",{set:function(e){this.handlers.push(e)}}),t.exports=o},{}],4:[function(e,t){function n(e){return e instanceof Promise?Promise.resolve(e):e instanceof Array?new Promise(function(t){var r=e.map(function(e){return n(e)});return Promise.all(r).then(function(n){for(var r=0;r<e.length;r++)e[r]=n[r];t(e)})}):e instanceof Object?new Promise(function(t){var r=Object.keys(e),o=r.map(function(t){return n(e[t])});return Promise.all(o).then(function(n){for(var o=0;o<r.length;o++)e[r[o]]=n[o];t(e)})}):Promise.resolve(e)}function r(e){if(void 0!==e._event)return void g.trigger(e._event,e._id,e.data);if(e._id){var t=g._callbacks[e._id];t&&(t.call(this,e.error,e.data),delete g._callbacks[e._id])}}var o,i,s,a,c=function(){var e=function(e){return"string"==typeof e[0]?"eth_blockByHash":"eth_blockByNumber"},t=function(e){return"string"==typeof e[0]?"eth_transactionByHash":"eth_transactionByNumber"},n=function(e){return"string"==typeof e[0]?"eth_uncleByHash":"eth_uncleByNumber"},r=[{name:"balanceAt",call:"eth_balanceAt"},{name:"stateAt",call:"eth_stateAt"},{name:"storageAt",call:"eth_storageAt"},{name:"countAt",call:"eth_countAt"},{name:"codeAt",call:"eth_codeAt"},{name:"transact",call:"eth_transact"},{name:"call",call:"eth_call"},{name:"block",call:e},{name:"transaction",call:t},{name:"uncle",call:n},{name:"compilers",call:"eth_compilers"},{name:"lll",call:"eth_lll"},{name:"solidity",call:"eth_solidity"}];return r},u=function(){return[{name:"coinbase",getter:"eth_coinbase",setter:"eth_setCoinbase"},{name:"listening",getter:"eth_listening",setter:"eth_setListening"},{name:"mining",getter:"eth_mining",setter:"eth_setMining"},{name:"gasPrice",getter:"eth_gasPrice"},{name:"account",getter:"eth_account"},{name:"accounts",getter:"eth_accounts"},{name:"peerCount",getter:"eth_peerCount"},{name:"defaultBlock",getter:"eth_defaultBlock",setter:"eth_setDefaultBlock"},{name:"number",getter:"eth_number"}]},l=function(){return[{name:"put",call:"db_put"},{name:"get",call:"db_get"},{name:"putString",call:"db_putString"},{name:"getString",call:"db_getString"}]},h=function(){return[{name:"post",call:"shh_post"},{name:"newIdentity",call:"shh_newIdentity"},{name:"haveIdentity",call:"shh_haveIdentity"},{name:"newGroup",call:"shh_newGroup"},{name:"addToGroup",call:"shh_addToGroup"}]},d=function(){var e=function(e){return"string"==typeof e[0]?"eth_newFilterString":"eth_newFilter"};return[{name:"newFilter",call:e},{name:"uninstallFilter",call:"eth_uninstallFilter"},{name:"getMessages",call:"eth_getMessages"}]},p=function(){return[{name:"newFilter",call:"shh_newFilter"},{name:"uninstallFilter",call:"shh_uninstallFilter"},{name:"getMessage",call:"shh_getMessages"}]},f=function(e,t){t.forEach(function(t){e[t.name]=function(){return n(Array.prototype.slice.call(arguments)).then(function(e){var n="function"==typeof t.call?t.call(e):t.call;return{call:n,args:e}}).then(function(e){return new Promise(function(t,n){g.provider.send(e,function(e,r){return e?void n(e):void t(r)})})}).catch(function(e){console.error(e)})}})},v=function(e,t){t.forEach(function(t){var r={};r.get=function(){return new Promise(function(e,n){g.provider.send({call:t.getter},function(t,r){return t?void n(t):void e(r)})})},t.setter&&(r.set=function(e){return n([e]).then(function(e){return new Promise(function(n){g.provider.send({call:t.setter,args:e},function(e,t){return e?void reject(e):void n(t)})})}).catch(function(e){console.error(e)})}),Object.defineProperty(e,t.name,r)})},g={_callbacks:{},_events:{},providers:{},toHex:function(e){var t,n,r="";for(t=0;t<e.length;t++)n=e.charCodeAt(t).toString(16),r+=n.length<2?"0"+n:n;return r},toAscii:function(e){var t,n="",r=0,o=e.length;for("0x"===e.substring(0,2)&&(r=2);o>r&&(t=e.charCodeAt(r),0!==t);r+=2)n+=String.fromCharCode(parseInt(e.substr(r,2),16));return n},toDecimal:function(e){return parseInt(e,16)},fromAscii:function(e,t){t=void 0===t?32:t;for(var n=this.toHex(e);n.length<2*t;)n+="00";return"0x"+n},eth:{prototype:Object(),watch:function(e){return new a(e,o)}},db:{prototype:Object()},shh:{prototype:Object(),watch:function(e){return new a(e,i)}},on:function(e,t,n){return void 0===g._events[e]&&(g._events[e]={}),g._events[e][t]=n,this},off:function(e,t){return void 0!==g._events[e]&&delete g._events[e][t],this},trigger:function(e,t,n){var r,o=g._events[e];o&&o[t]&&(r=o[t])(n)}},m=g.eth;f(m,c()),v(m,u()),f(g.db,l()),f(g.shh,h()),o={changed:"eth_changed"},f(o,d()),i={changed:"shh_changed"},f(i,p()),s=function(){var e,t;this.queued=[],this.polls=[],this.ready=!1,this.provider=void 0,this.id=1,e=this,(t=function(){e.provider&&e.provider.poll&&e.polls.forEach(function(t){t.data._id=e.id,e.id++,e.provider.poll(t.data,t.id)}),setTimeout(t,12e3)})()},s.prototype.send=function(e,t){e._id=this.id,t&&(g._callbacks[e._id]=t),e.args=e.args||[],this.id++,void 0!==this.provider?this.provider.send(e):(console.warn("provider is not set"),this.queued.push(e))},s.prototype.set=function(e){void 0!==this.provider&&void 0!==this.provider.unload&&this.provider.unload(),this.provider=e,this.ready=!0},s.prototype.sendQueued=function(){for(var e=0;this.queued.length;e++)this.send(this.queued[e])},s.prototype.installed=function(){return void 0!==this.provider},s.prototype.startPolling=function(e,t){this.provider&&this.provider.poll&&this.polls.push({data:e,id:t})},s.prototype.stopPolling=function(e){var t,n;for(t=this.polls.length;t--;)n=this.polls[t],n.id===e&&this.polls.splice(t,1)},g.provider=new s,g.setProvider=function(e){e.onmessage=r,g.provider.set(e),g.provider.sendQueued()},g.haveProvider=function(){return!!g.provider.provider},a=function(e,t){this.impl=t,this.callbacks=[];var n=this;this.promise=t.newFilter(e),this.promise.then(function(e){n.id=e,g.on(t.changed,e,n.trigger.bind(n)),g.provider.startPolling({call:t.changed,args:[e]},e)})},a.prototype.arrived=function(e){this.changed(e)},a.prototype.changed=function(e){var t=this;this.promise.then(function(){t.callbacks.push(e)})},a.prototype.trigger=function(e){for(var t=0;t<this.callbacks.length;t++)this.callbacks[t].call(this,e)},a.prototype.uninstall=function(){var e=this;this.promise.then(function(t){e.impl.uninstallFilter(t),g.provider.stopPolling(t),g.off(impl.changed,t)})},a.prototype.messages=function(){var e=this;return this.promise.then(function(t){return e.impl.getMessages(t)})},t.exports=g},{}],5:[function(e,t){var n=function(){this.handlers=[];var e=this;navigator.qt.onmessage=function(t){e.handlers.forEach(function(n){n.call(e,JSON.parse(t.data))})}};n.prototype.send=function(e){navigator.qt.postMessage(JSON.stringify(e))},Object.defineProperty(n.prototype,"onmessage",{set:function(e){this.handlers.push(e)}}),t.exports=n},{}],6:[function(e,t){var n=function(e){this.handlers=[],this.queued=[],this.ready=!1,this.ws=new WebSocket(e);var t=this;this.ws.onmessage=function(e){for(var n=0;n<t.handlers.length;n++)t.handlers[n].call(t,JSON.parse(e.data),e)},this.ws.onopen=function(){t.ready=!0;for(var e=0;e<t.queued.length;e++)t.send(t.queued[e])}};n.prototype.send=function(e){if(this.ready){var t=JSON.stringify(e);this.ws.send(t)}else this.queued.push(e)},n.prototype.onMessage=function(e){this.handlers.push(e)},n.prototype.unload=function(){this.ws.close()},Object.defineProperty(n.prototype,"onmessage",{set:function(e){this.onMessage(e)}}),t.exports=n},{}],web3:[function(e,t){var n=e("./lib/main");n.providers.WebSocketProvider=e("./lib/websocket"),n.providers.HttpRpcProvider=e("./lib/httprpc"),n.providers.QtProvider=e("./lib/qt"),n.providers.AutoProvider=e("./lib/autoprovider"),n.contract=e("./lib/abi"),t.exports=n},{"./lib/abi":1,"./lib/autoprovider":2,"./lib/httprpc":3,"./lib/main":4,"./lib/qt":5,"./lib/websocket":6}]},{},[]); \ No newline at end of file
+require=function t(e,n,r){function o(s,a){if(!n[s]){if(!e[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(i)return i(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var l=n[s]={exports:{}};e[s][0].call(l.exports,function(t){var n=e[s][1][t];return o(n?n:t)},l,l.exports,t,e,n,r)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s<r.length;s++)o(r[s]);return o}({1:[function(t,e){var n=function(t,e){for(var n=!1,r=0;r<t.length&&!n;r++)n=e(t[r]);return n?r-1:-1},r=function(t,e){return n(t,function(t){return t.name===e})},o=function(t,e){return new Array(2*e-t.toString().length+1).join("0")+t},i=function(){var t=function(t){return function(e,n){var r,i=t;return 0!==e.indexOf(i)?!1:(r=parseInt(e.slice(i.length))/8,o(n,r))}},e=function(t,e,n){return function(r,i){return r!==t?!1:o(n?i:n(i),e)}},n=function(t){return t?"1":"0"};return[t("uint"),t("int"),e("address",20),e("bool",1,n)]},s=i(),a=function(t,e,n){var o,i,a,u,c,l="",h=r(t,e);if(-1!==h){for(l=l+h+"x0",o=t[h],i=0;i<o.inputs.length;i++){for(a=!1,u=0;u<s.length&&!a;u++)c=parseInt(n[i]).toString(16),a=s[u](o.inputs[i].type,c);a||console.error("unsupported json type: "+o.inputs[i].type),l+=a}return l}},u=function(){var t=function(t){return function(e){var n,r=t;return 0!==e.indexOf(r)?-1:(n=parseInt(e.slice(r.length))/8,2*n)}},e=function(t,e){return function(n){return t===n?2*e:-1}},n=function(t){return parseInt(t,16)},r=function(t){return"1"===t?!0:!1};return[{padding:t("uint"),format:n},{padding:t("int"),format:n},{padding:e("address",20)},{padding:e("bool",1),format:r}]},c=u(),l=function(t,e,n){var o,i,s,a,u,l,h,p=r(t,e);if(-1!==p){for(n=n.slice(2),o=[],i=t[p],s=0;s<i.outputs.length;s++){for(a=-1,u=0;u<c.length&&-1===a;u++)a=c[u].padding(i.outputs[s].type);-1!==a&&(l=n.slice(0,a),h=c[u-1].format,o.push(h?h(l):l),n=n.slice(a))}return o}},h=function(t){var e={};return t.forEach(function(n){e[n.name]=function(){var e=Array.prototype.slice.call(arguments);return a(t,n.name,e)}}),e},p=function(t){var e={};return t.forEach(function(n){e[n.name]=function(e){return l(t,n.name,e)}}),e};e.exports={inputParser:h,outputParser:p}},{}],2:[function(t,e){var n=function(t){var e,n,r,o;if(!web3.haveProvider()){if(this.sendQueue=[],this.onmessageQueue=[],navigator.qt)return void(this.provider=new web3.providers.QtProvider);t=t||{},e={httprpc:t.httprpc||"http://localhost:8080",websockets:t.websockets||"ws://localhost:40404/eth"},n=this,r=function(t){o.close(),t?n.provider=new web3.providers.WebSocketProvider(e.websockets):(n.provider=new web3.providers.HttpRpcProvider(e.httprpc),n.poll=n.provider.poll.bind(n.provider)),n.sendQueue.forEach(function(t){n.provider(t)}),n.onmessageQueue.forEach(function(t){n.provider.onmessage=t})},o=new WebSocket(e.websockets),o.onopen=function(){r(!0)},o.onerror=function(){r(!1)}}};n.prototype.send=function(t){return this.provider?void this.provider.send(t):void this.sendQueue.push(t)},Object.defineProperty(n.prototype,"onmessage",{set:function(t){return this.provider?void(this.provider.onmessage=t):void this.onmessageQueue.push(t)}}),e.exports=n},{}],3:[function(t,e){var n,r;n=t("./abi"),r=function(t,e){var r=n.inputParser(e),o=n.outputParser(e),i={};return e.forEach(function(e){i[e.name]=function(){var n=Array.prototype.slice.call(arguments),i=r[e.name].apply(null,n),s=function(t){return o[e.name](t)};return{call:function(e){return e=e||{},e.to=t,e.data=i,web3.eth.call(e).then(s)},transact:function(e){return e=e||{},e.to=t,e.data=i,web3.eth.transact(e).then(s)}}}}),i},e.exports=r},{"./abi":1}],4:[function(t,e){function n(t){return{jsonrpc:"2.0",method:t.call,params:t.args,id:t._id}}function r(t){var e=JSON.parse(t);return{_id:e.id,data:e.result,error:e.error}}var o=function(t){this.handlers=[],this.host=t};o.prototype.sendRequest=function(t,e){var r=n(t),o=new XMLHttpRequest;o.open("POST",this.host,!0),o.send(JSON.stringify(r)),o.onreadystatechange=function(){4===o.readyState&&e&&e(o)}},o.prototype.send=function(t){var e=this;this.sendRequest(t,function(t){e.handlers.forEach(function(n){n.call(e,r(t.responseText))})})},o.prototype.poll=function(t,e){var n=this;this.sendRequest(t,function(r){var o=JSON.parse(r.responseText);!o.error&&(o.result instanceof Array?0!==o.result.length:o.result)&&n.handlers.forEach(function(r){r.call(n,{_event:t.call,_id:e,data:o.result})})})},Object.defineProperty(o.prototype,"onmessage",{set:function(t){this.handlers.push(t)}}),e.exports=o},{}],5:[function(t,e){function n(t){return t instanceof Promise?Promise.resolve(t):t instanceof Array?new Promise(function(e){var r=t.map(function(t){return n(t)});return Promise.all(r).then(function(n){for(var r=0;r<t.length;r++)t[r]=n[r];e(t)})}):t instanceof Object?new Promise(function(e){var r=Object.keys(t),o=r.map(function(e){return n(t[e])});return Promise.all(o).then(function(n){for(var o=0;o<r.length;o++)t[r[o]]=n[o];e(t)})}):Promise.resolve(t)}function r(t){if(void 0!==t._event)return void g.trigger(t._event,t._id,t.data);if(t._id){var e=g._callbacks[t._id];e&&(e.call(this,t.error,t.data),delete g._callbacks[t._id])}}var o,i,s,a,u=function(){var t=function(t){return"string"==typeof t[0]?"eth_blockByHash":"eth_blockByNumber"},e=function(t){return"string"==typeof t[0]?"eth_transactionByHash":"eth_transactionByNumber"},n=function(t){return"string"==typeof t[0]?"eth_uncleByHash":"eth_uncleByNumber"},r=[{name:"balanceAt",call:"eth_balanceAt"},{name:"stateAt",call:"eth_stateAt"},{name:"storageAt",call:"eth_storageAt"},{name:"countAt",call:"eth_countAt"},{name:"codeAt",call:"eth_codeAt"},{name:"transact",call:"eth_transact"},{name:"call",call:"eth_call"},{name:"block",call:t},{name:"transaction",call:e},{name:"uncle",call:n},{name:"compilers",call:"eth_compilers"},{name:"lll",call:"eth_lll"},{name:"solidity",call:"eth_solidity"},{name:"serpent",call:"eth_serpent"}];return r},c=function(){return[{name:"coinbase",getter:"eth_coinbase",setter:"eth_setCoinbase"},{name:"listening",getter:"eth_listening",setter:"eth_setListening"},{name:"mining",getter:"eth_mining",setter:"eth_setMining"},{name:"gasPrice",getter:"eth_gasPrice"},{name:"account",getter:"eth_account"},{name:"accounts",getter:"eth_accounts"},{name:"peerCount",getter:"eth_peerCount"},{name:"defaultBlock",getter:"eth_defaultBlock",setter:"eth_setDefaultBlock"},{name:"number",getter:"eth_number"}]},l=function(){return[{name:"put",call:"db_put"},{name:"get",call:"db_get"},{name:"putString",call:"db_putString"},{name:"getString",call:"db_getString"}]},h=function(){return[{name:"post",call:"shh_post"},{name:"newIdentity",call:"shh_newIdentity"},{name:"haveIdentity",call:"shh_haveIdentity"},{name:"newGroup",call:"shh_newGroup"},{name:"addToGroup",call:"shh_addToGroup"}]},p=function(){var t=function(t){return"string"==typeof t[0]?"eth_newFilterString":"eth_newFilter"};return[{name:"newFilter",call:t},{name:"uninstallFilter",call:"eth_uninstallFilter"},{name:"getMessages",call:"eth_getMessages"}]},d=function(){return[{name:"newFilter",call:"shh_newFilter"},{name:"uninstallFilter",call:"shh_uninstallFilter"},{name:"getMessage",call:"shh_getMessages"}]},f=function(t,e){e.forEach(function(e){t[e.name]=function(){return n(Array.prototype.slice.call(arguments)).then(function(t){var n="function"==typeof e.call?e.call(t):e.call;return{call:n,args:t}}).then(function(t){return new Promise(function(e,n){g.provider.send(t,function(t,r){return t?void n(t):void e(r)})})}).catch(function(t){console.error(t)})}})},v=function(t,e){e.forEach(function(e){var r={};r.get=function(){return new Promise(function(t,n){g.provider.send({call:e.getter},function(e,r){return e?void n(e):void t(r)})})},e.setter&&(r.set=function(t){return n([t]).then(function(t){return new Promise(function(n){g.provider.send({call:e.setter,args:t},function(t,e){return t?void reject(t):void n(e)})})}).catch(function(t){console.error(t)})}),Object.defineProperty(t,e.name,r)})},g={_callbacks:{},_events:{},providers:{},toHex:function(t){var e,n,r="";for(e=0;e<t.length;e++)n=t.charCodeAt(e).toString(16),r+=n.length<2?"0"+n:n;return r},toAscii:function(t){var e,n="",r=0,o=t.length;for("0x"===t.substring(0,2)&&(r=2);o>r&&(e=t.charCodeAt(r),0!==e);r+=2)n+=String.fromCharCode(parseInt(t.substr(r,2),16));return n},toDecimal:function(t){return parseInt(t,16)},fromAscii:function(t,e){e=void 0===e?32:e;for(var n=this.toHex(t);n.length<2*e;)n+="00";return"0x"+n},eth:{prototype:Object(),watch:function(t){return new a(t,o)}},db:{prototype:Object()},shh:{prototype:Object(),watch:function(t){return new a(t,i)}},on:function(t,e,n){return void 0===g._events[t]&&(g._events[t]={}),g._events[t][e]=n,this},off:function(t,e){return void 0!==g._events[t]&&delete g._events[t][e],this},trigger:function(t,e,n){var r,o=g._events[t];o&&o[e]&&(r=o[e])(n)}};f(g.eth,u()),v(g.eth,c()),f(g.db,l()),f(g.shh,h()),o={changed:"eth_changed"},f(o,p()),i={changed:"shh_changed"},f(i,d()),s=function(){var t,e;this.queued=[],this.polls=[],this.ready=!1,this.provider=void 0,this.id=1,t=this,(e=function(){t.provider&&t.provider.poll&&t.polls.forEach(function(e){e.data._id=t.id,t.id++,t.provider.poll(e.data,e.id)}),setTimeout(e,12e3)})()},s.prototype.send=function(t,e){t._id=this.id,e&&(g._callbacks[t._id]=e),t.args=t.args||[],this.id++,void 0!==this.provider?this.provider.send(t):(console.warn("provider is not set"),this.queued.push(t))},s.prototype.set=function(t){void 0!==this.provider&&void 0!==this.provider.unload&&this.provider.unload(),this.provider=t,this.ready=!0},s.prototype.sendQueued=function(){for(var t=0;this.queued.length;t++)this.send(this.queued[t])},s.prototype.installed=function(){return void 0!==this.provider},s.prototype.startPolling=function(t,e){this.provider&&this.provider.poll&&this.polls.push({data:t,id:e})},s.prototype.stopPolling=function(t){var e,n;for(e=this.polls.length;e--;)n=this.polls[e],n.id===t&&this.polls.splice(e,1)},g.provider=new s,g.setProvider=function(t){t.onmessage=r,g.provider.set(t),g.provider.sendQueued()},g.haveProvider=function(){return!!g.provider.provider},a=function(t,e){this.impl=e,this.callbacks=[];var n=this;this.promise=e.newFilter(t),this.promise.then(function(t){n.id=t,g.on(e.changed,t,n.trigger.bind(n)),g.provider.startPolling({call:e.changed,args:[t]},t)})},a.prototype.arrived=function(t){this.changed(t)},a.prototype.changed=function(t){var e=this;this.promise.then(function(){e.callbacks.push(t)})},a.prototype.trigger=function(t){for(var e=0;e<this.callbacks.length;e++)this.callbacks[e].call(this,t)},a.prototype.uninstall=function(){var t=this;this.promise.then(function(e){t.impl.uninstallFilter(e),g.provider.stopPolling(e),g.off(impl.changed,e)})},a.prototype.messages=function(){var t=this;return this.promise.then(function(e){return t.impl.getMessages(e)})},e.exports=g},{}],6:[function(t,e){var n=function(){this.handlers=[];var t=this;navigator.qt.onmessage=function(e){t.handlers.forEach(function(n){n.call(t,JSON.parse(e.data))})}};n.prototype.send=function(t){navigator.qt.postMessage(JSON.stringify(t))},Object.defineProperty(n.prototype,"onmessage",{set:function(t){this.handlers.push(t)}}),e.exports=n},{}],7:[function(t,e){var n=function(t){this.handlers=[],this.queued=[],this.ready=!1,this.ws=new WebSocket(t);var e=this;this.ws.onmessage=function(t){for(var n=0;n<e.handlers.length;n++)e.handlers[n].call(e,JSON.parse(t.data),t)},this.ws.onopen=function(){e.ready=!0;for(var t=0;t<e.queued.length;t++)e.send(e.queued[t])}};n.prototype.send=function(t){if(this.ready){var e=JSON.stringify(t);this.ws.send(e)}else this.queued.push(t)},n.prototype.onMessage=function(t){this.handlers.push(t)},n.prototype.unload=function(){this.ws.close()},Object.defineProperty(n.prototype,"onmessage",{set:function(t){this.onMessage(t)}}),e.exports=n},{}],web3:[function(t,e){var n=t("./lib/main");n.providers.WebSocketProvider=t("./lib/websocket"),n.providers.HttpRpcProvider=t("./lib/httprpc"),n.providers.QtProvider=t("./lib/qt"),n.providers.AutoProvider=t("./lib/autoprovider"),n.contract=t("./lib/contract"),e.exports=n},{"./lib/autoprovider":2,"./lib/contract":3,"./lib/httprpc":4,"./lib/main":5,"./lib/qt":6,"./lib/websocket":7}]},{},[]); \ No newline at end of file
diff --git a/example/contract.html b/example/contract.html
new file mode 100644
index 000000000..44f0b03a1
--- /dev/null
+++ b/example/contract.html
@@ -0,0 +1,75 @@
+<!doctype>
+<html>
+
+<head>
+<script type="text/javascript" src="js/es6-promise/promise.min.js"></script>
+<script type="text/javascript" src="../dist/ethereum.js"></script>
+<script type="text/javascript">
+
+ var web3 = require('web3');
+ web3.setProvider(new web3.providers.AutoProvider());
+
+ // solidity source code
+ var source = "" +
+ "contract test {\n" +
+ " function multiply(uint a) returns(uint d) {\n" +
+ " return a * 7;\n" +
+ " }\n" +
+ "}\n";
+
+ // contract description, this will be autogenerated somehow
+ var desc = [{
+ "name": "multiply",
+ "inputs": [
+ {
+ "name": "a",
+ "type": "uint256"
+ }
+ ],
+ "outputs": [
+ {
+ "name": "d",
+ "type": "uint256"
+ }
+ ]
+ }];
+
+ var contract;
+
+ function createExampleContract() {
+ // hide create button
+ document.getElementById('create').style.visibility = 'hidden';
+ document.getElementById('source').innerText = source;
+
+ // create contract
+ web3.eth.transact({code: web3.eth.solidity(source)}).then(function (address) {
+ contract = web3.contract(address, desc);
+ document.getElementById('call').style.visibility = 'visible';
+ });
+ }
+
+ function callExampleContract() {
+ // this should be generated by ethereum
+ var param = document.getElementById('value').value;
+
+ // call the contract
+ contract.multiply(param).call().then(function(res) {
+ document.getElementById('result').innerText = res[0];
+ });
+ }
+
+</script>
+</head>
+<body>
+ <h1>contract</h1>
+ <div id="source"></div>
+ <div id='create'>
+ <button type="button" onClick="createExampleContract();">create example contract</button>
+ </div>
+ <div id='call' style='visibility: hidden;'>
+ <input type="number" id="value" onkeyup='callExampleContract()'></input>
+ </div>
+ <div id="result"></div>
+</body>
+</html>
+
diff --git a/example/index.html b/example/index.html
index 4847f68c0..d0bf094ef 100644
--- a/example/index.html
+++ b/example/index.html
@@ -30,7 +30,7 @@
</script>
</head>
<body>
- <h1>balance</h1>
+ <h1>coinbase balance</h1>
<button type="button" onClick="watchBalance();">watch balance</button>
<div></div>
<div id="original"></div>
diff --git a/index.js b/index.js
index 3197d0de6..c2de7e735 100644
--- a/index.js
+++ b/index.js
@@ -3,6 +3,6 @@ web3.providers.WebSocketProvider = require('./lib/websocket');
web3.providers.HttpRpcProvider = require('./lib/httprpc');
web3.providers.QtProvider = require('./lib/qt');
web3.providers.AutoProvider = require('./lib/autoprovider');
-web3.contract = require('./lib/abi');
+web3.contract = require('./lib/contract');
module.exports = web3;
diff --git a/index_qt.js b/index_qt.js
index 596695374..d5e47597e 100644
--- a/index_qt.js
+++ b/index_qt.js
@@ -1,5 +1,5 @@
var web3 = require('./lib/main');
web3.providers.QtProvider = require('./lib/qt');
-web3.abi = require('./lib/abi');
+web3.contract = require('./lib/contract');
module.exports = web3;
diff --git a/lib/abi.js b/lib/abi.js
index 1e3759918..3df0fe684 100644
--- a/lib/abi.js
+++ b/lib/abi.js
@@ -1,3 +1,24 @@
+/*
+ This file is part of ethereum.js.
+
+ ethereum.js is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ ethereum.js is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
+*/
+/** @file abi.js
+ * @authors:
+ * Marek Kotewicz <marek@ethdev.com>
+ * @date 2014
+ */
var findIndex = function (array, callback) {
var end = false;
@@ -71,7 +92,8 @@ var toAbiInput = function (json, methodName, params) {
for (var i = 0; i < method.inputs.length; i++) {
var found = false;
for (var j = 0; j < inputTypes.length && !found; j++) {
- found = inputTypes[j](method.inputs[i].type, params[i]);
+ var val = parseInt(params[i]).toString(16);
+ found = inputTypes[j](method.inputs[i].type, val);
}
if (!found) {
console.error('unsupported json type: ' + method.inputs[i].type);
@@ -148,17 +170,31 @@ var fromAbiOutput = function (json, methodName, output) {
return result;
};
-var load = function (json) {
- var contract = {};
+var inputParser = function (json) {
+ var parser = {};
json.forEach(function (method) {
- contract[method.name] = function () {
+ parser[method.name] = function () {
var params = Array.prototype.slice.call(arguments);
return toAbiInput(json, method.name, params);
};
});
- return contract;
+ return parser;
};
-module.exports = load;
+var outputParser = function (json) {
+ var parser = {};
+ json.forEach(function (method) {
+ parser[method.name] = function (output) {
+ return fromAbiOutput(json, method.name, output);
+ };
+ });
+
+ return parser;
+};
+
+module.exports = {
+ inputParser: inputParser,
+ outputParser: outputParser
+};
diff --git a/lib/contract.js b/lib/contract.js
new file mode 100644
index 000000000..10ceaf869
--- /dev/null
+++ b/lib/contract.js
@@ -0,0 +1,63 @@
+/*
+ This file is part of ethereum.js.
+
+ ethereum.js is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ ethereum.js is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
+*/
+/** @file contract.js
+ * @authors:
+ * Marek Kotewicz <marek@ethdev.com>
+ * @date 2014
+ */
+
+if (process.env.NODE_ENV !== 'build') {
+ var web3 = require('./web3'); // jshint ignore:line
+}
+var abi = require('./abi');
+
+var contract = function (address, desc) {
+ var inputParser = abi.inputParser(desc);
+ var outputParser = abi.outputParser(desc);
+
+ var contract = {};
+
+ desc.forEach(function (method) {
+ contract[method.name] = function () {
+ var params = Array.prototype.slice.call(arguments);
+ var parsed = inputParser[method.name].apply(null, params);
+
+ var onSuccess = function (result) {
+ return outputParser[method.name](result);
+ };
+
+ return {
+ call: function (extra) {
+ extra = extra || {};
+ extra.to = address;
+ extra.data = parsed;
+ return web3.eth.call(extra).then(onSuccess);
+ },
+ transact: function (extra) {
+ extra = extra || {};
+ extra.to = address;
+ extra.data = parsed;
+ return web3.eth.transact(extra).then(onSuccess);
+ }
+ };
+ };
+ });
+
+ return contract;
+};
+
+module.exports = contract;
diff --git a/lib/main.js b/lib/main.js
index e2caf6bc3..a8848674b 100644
--- a/lib/main.js
+++ b/lib/main.js
@@ -87,7 +87,8 @@ var ethMethods = function () {
{ name: 'uncle', call: uncleCall },
{ name: 'compilers', call: 'eth_compilers' },
{ name: 'lll', call: 'eth_lll' },
- { name: 'solidity', call: 'eth_solidity' }
+ { name: 'solidity', call: 'eth_solidity' },
+ { name: 'serpent', call: 'eth_serpent' }
];
return methods;
};
@@ -292,9 +293,8 @@ var web3 = {
}
};
-var eth = web3.eth;
-setupMethods(eth, ethMethods());
-setupProperties(eth, ethProperties());
+setupMethods(web3.eth, ethMethods());
+setupProperties(web3.eth, ethProperties());
setupMethods(web3.db, dbMethods());
setupMethods(web3.shh, shhMethods());