diff options
author | Marek Kotewicz <marek.kotewicz@gmail.com> | 2015-01-07 04:50:09 +0800 |
---|---|---|
committer | Marek Kotewicz <marek.kotewicz@gmail.com> | 2015-01-07 04:50:09 +0800 |
commit | 210682b73454a13e82c9c04bb1b0ea94bcb65ca1 (patch) | |
tree | 1b78d4f25900ce25bf740f12707292de7d68cdfe | |
parent | 1d139f7a0b54cd3344e32245a06ed29d92f0ae0b (diff) | |
download | dexon-210682b73454a13e82c9c04bb1b0ea94bcb65ca1.tar.gz dexon-210682b73454a13e82c9c04bb1b0ea94bcb65ca1.tar.zst dexon-210682b73454a13e82c9c04bb1b0ea94bcb65ca1.zip |
real, ureal paddings and implicit paddings for uint, int and hash
-rw-r--r-- | dist/ethereum.js | 2 | ||||
-rw-r--r-- | dist/ethereum.js.map | 2 | ||||
-rw-r--r-- | dist/ethereum.min.js | 2 | ||||
-rw-r--r-- | lib/abi.js | 61 |
4 files changed, 48 insertions, 19 deletions
diff --git a/dist/ethereum.js b/dist/ethereum.js index 710a61883..8abe6ad53 100644 --- a/dist/ethereum.js +++ b/dist/ethereum.js @@ -1,5 +1,5 @@ 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 hexToDec,decToHex,findIndex,findMethodIndex,padLeft,setupInputTypes,inputTypes,toAbiInput,setupOutputTypes,outputTypes,fromAbiOutput,inputParser,outputParser;hexToDec=function(hex){return parseInt(hex,16).toString()},decToHex=function(dec){return parseInt(dec).toString(16)},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(string,chars){return new Array(chars-string.length+1).join("0")+string},setupInputTypes=function(){var prefixedType=function(prefix,bitsInNumber){return function(type,value){var padding,expected=prefix;return 0!==type.indexOf(expected)?!1:(padding=parseInt(type.slice(expected.length))/8*bitsInNumber,value="number"==typeof value?value.toString(16):"string"==typeof value?web3.toHex(value):0===value.indexOf("0x")?value.substr(2):(+value).toString(16),padLeft(value,2*padding))}},namedType=function(name,padding,formatter){return function(type,value){return type!==name?!1:padLeft(formatter?formatter(value):value,2*padding)}},formatBool=function(value){return value?"0x1":"0x0"};return[prefixedType("uint",1),prefixedType("int",1),prefixedType("hash",1),prefixedType("string",8),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="0x"+padLeft(index.toString(16),2),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,bitsInNumber){return function(type){var padding,expected=prefix;return 0!==type.indexOf(expected)?-1:(padding=parseInt(type.slice(expected.length))/8*bitsInNumber,2*padding)}},namedType=function(name,padding){return function(type){return name===type?2*padding:-1}},formatInt=function(value){return value.length<=8?+parseInt(value,16):hexToDec(value)},formatHash=function(value){return"0x"+value},formatBool=function(value){return"1"===value?!0:!1},formatString=function(value){return web3.toAscii(value)};return[{padding:prefixedType("uint",1),format:formatInt},{padding:prefixedType("int",1),format:formatInt},{padding:prefixedType("hash",1),format:formatHash},{padding:prefixedType("string",8),format:formatString},{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):"0x"+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 hexToDec,decToHex,findIndex,findMethodIndex,padLeft,calcBitPadding,calcBytePadding,calcRealPadding,setupInputTypes,inputTypes,toAbiInput,setupOutputTypes,outputTypes,fromAbiOutput,inputParser,outputParser;hexToDec=function(hex){return parseInt(hex,16).toString()},decToHex=function(dec){return parseInt(dec).toString(16)},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(string,chars){return new Array(chars-string.length+1).join("0")+string},calcBitPadding=function(type,expected){var value=type.slice(expected.length);return""===value?32:parseInt(value)/8},calcBytePadding=function(type,expected){var value=type.slice(expected.length);return""===value?32:parseInt(value)},calcRealPadding=function(type,expected){var sizes,padding,i,value=type.slice(expected.length);if(""===value)return 32;for(sizes=value.split("x"),padding=0,i=0;sizes>i;i++)padding+=sizes[i]/8;return padding},setupInputTypes=function(){var prefixedType=function(prefix,calcPadding){return function(type,value){var padding,expected=prefix;return 0!==type.indexOf(expected)?!1:(padding=calcPadding(type,expected),value="number"==typeof value?value.toString(16):"string"==typeof value?web3.toHex(value):0===value.indexOf("0x")?value.substr(2):(+value).toString(16),padLeft(value,2*padding))}},namedType=function(name,padding,formatter){return function(type,value){return type!==name?!1:padLeft(formatter?formatter(value):value,2*padding)}},formatBool=function(value){return value?"0x1":"0x0"};return[prefixedType("uint",calcBitPadding),prefixedType("int",calcBitPadding),prefixedType("hash",calcBitPadding),prefixedType("string",calcBytePadding),prefixedType("real",calcRealPadding),prefixedType("ureal",calcRealPadding),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="0x"+padLeft(index.toString(16),2),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,calcPadding){return function(type){var padding,expected=prefix;return 0!==type.indexOf(expected)?-1:(padding=calcPadding(type,expected),2*padding)}},namedType=function(name,padding){return function(type){return name===type?2*padding:-1}},formatInt=function(value){return value.length<=8?+parseInt(value,16):hexToDec(value)},formatHash=function(value){return"0x"+value},formatBool=function(value){return"1"===value?!0:!1},formatString=function(value){return web3.toAscii(value)};return[{padding:prefixedType("uint",calcBitPadding),format:formatInt},{padding:prefixedType("int",calcBitPadding),format:formatInt},{padding:prefixedType("hash",calcBitPadding),format:formatHash},{padding:prefixedType("string",calcBytePadding),format:formatString},{padding:prefixedType("real",calcRealPadding),format:formatInt},{padding:prefixedType("ureal",calcRealPadding),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):"0x"+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){ diff --git a/dist/ethereum.js.map b/dist/ethereum.js.map index bd70fa0ca..f15143fac 100644 --- a/dist/ethereum.js.map +++ b/dist/ethereum.js.map @@ -17,7 +17,7 @@ "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 hexToDec,decToHex,findIndex,findMethodIndex,padLeft,setupInputTypes,inputTypes,toAbiInput,setupOutputTypes,outputTypes,fromAbiOutput,inputParser,outputParser;hexToDec=function(hex){return parseInt(hex,16).toString()},decToHex=function(dec){return parseInt(dec).toString(16)},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(string,chars){return new Array(chars-string.length+1).join(\"0\")+string},setupInputTypes=function(){var prefixedType=function(prefix,bitsInNumber){return function(type,value){var padding,expected=prefix;return 0!==type.indexOf(expected)?!1:(padding=parseInt(type.slice(expected.length))/8*bitsInNumber,value=\"number\"==typeof value?value.toString(16):\"string\"==typeof value?web3.toHex(value):0===value.indexOf(\"0x\")?value.substr(2):(+value).toString(16),padLeft(value,2*padding))}},namedType=function(name,padding,formatter){return function(type,value){return type!==name?!1:padLeft(formatter?formatter(value):value,2*padding)}},formatBool=function(value){return value?\"0x1\":\"0x0\"};return[prefixedType(\"uint\",1),prefixedType(\"int\",1),prefixedType(\"hash\",1),prefixedType(\"string\",8),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=\"0x\"+padLeft(index.toString(16),2),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,bitsInNumber){return function(type){var padding,expected=prefix;return 0!==type.indexOf(expected)?-1:(padding=parseInt(type.slice(expected.length))/8*bitsInNumber,2*padding)}},namedType=function(name,padding){return function(type){return name===type?2*padding:-1}},formatInt=function(value){return value.length<=8?+parseInt(value,16):hexToDec(value)},formatHash=function(value){return\"0x\"+value},formatBool=function(value){return\"1\"===value?!0:!1},formatString=function(value){return web3.toAscii(value)};return[{padding:prefixedType(\"uint\",1),format:formatInt},{padding:prefixedType(\"int\",1),format:formatInt},{padding:prefixedType(\"hash\",1),format:formatHash},{padding:prefixedType(\"string\",8),format:formatString},{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):\"0x\"+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 hexToDec,decToHex,findIndex,findMethodIndex,padLeft,calcBitPadding,calcBytePadding,calcRealPadding,setupInputTypes,inputTypes,toAbiInput,setupOutputTypes,outputTypes,fromAbiOutput,inputParser,outputParser;hexToDec=function(hex){return parseInt(hex,16).toString()},decToHex=function(dec){return parseInt(dec).toString(16)},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(string,chars){return new Array(chars-string.length+1).join(\"0\")+string},calcBitPadding=function(type,expected){var value=type.slice(expected.length);return\"\"===value?32:parseInt(value)/8},calcBytePadding=function(type,expected){var value=type.slice(expected.length);return\"\"===value?32:parseInt(value)},calcRealPadding=function(type,expected){var sizes,padding,i,value=type.slice(expected.length);if(\"\"===value)return 32;for(sizes=value.split(\"x\"),padding=0,i=0;sizes>i;i++)padding+=sizes[i]/8;return padding},setupInputTypes=function(){var prefixedType=function(prefix,calcPadding){return function(type,value){var padding,expected=prefix;return 0!==type.indexOf(expected)?!1:(padding=calcPadding(type,expected),value=\"number\"==typeof value?value.toString(16):\"string\"==typeof value?web3.toHex(value):0===value.indexOf(\"0x\")?value.substr(2):(+value).toString(16),padLeft(value,2*padding))}},namedType=function(name,padding,formatter){return function(type,value){return type!==name?!1:padLeft(formatter?formatter(value):value,2*padding)}},formatBool=function(value){return value?\"0x1\":\"0x0\"};return[prefixedType(\"uint\",calcBitPadding),prefixedType(\"int\",calcBitPadding),prefixedType(\"hash\",calcBitPadding),prefixedType(\"string\",calcBytePadding),prefixedType(\"real\",calcRealPadding),prefixedType(\"ureal\",calcRealPadding),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=\"0x\"+padLeft(index.toString(16),2),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,calcPadding){return function(type){var padding,expected=prefix;return 0!==type.indexOf(expected)?-1:(padding=calcPadding(type,expected),2*padding)}},namedType=function(name,padding){return function(type){return name===type?2*padding:-1}},formatInt=function(value){return value.length<=8?+parseInt(value,16):hexToDec(value)},formatHash=function(value){return\"0x\"+value},formatBool=function(value){return\"1\"===value?!0:!1},formatString=function(value){return web3.toAscii(value)};return[{padding:prefixedType(\"uint\",calcBitPadding),format:formatInt},{padding:prefixedType(\"int\",calcBitPadding),format:formatInt},{padding:prefixedType(\"hash\",calcBitPadding),format:formatHash},{padding:prefixedType(\"string\",calcBytePadding),format:formatString},{padding:prefixedType(\"real\",calcRealPadding),format:formatInt},{padding:prefixedType(\"ureal\",calcRealPadding),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):\"0x\"+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;", diff --git a/dist/ethereum.min.js b/dist/ethereum.min.js index 0cc764e92..b1ecdfb83 100644 --- a/dist/ethereum.min.js +++ b/dist/ethereum.min.js @@ -1 +1 @@ -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,r,o,i,s,a,u,c,l,h,p,f,d;n=function(t){return parseInt(t,16).toString()},r=function(t){return parseInt(t).toString(16)},o=function(t,e){for(var n=!1,r=0;r<t.length&&!n;r++)n=e(t[r]);return n?r-1:-1},i=function(t,e){return o(t,function(t){return t.name===e})},s=function(t,e){return new Array(e-t.length+1).join("0")+t},a=function(){var t=function(t,e){return function(n,r){var o,i=t;return 0!==n.indexOf(i)?!1:(o=parseInt(n.slice(i.length))/8*e,r="number"==typeof r?r.toString(16):"string"==typeof r?web3.toHex(r):0===r.indexOf("0x")?r.substr(2):(+r).toString(16),s(r,2*o))}},e=function(t,e,n){return function(r,o){return r!==t?!1:s(n?n(o):o,2*e)}},n=function(t){return t?"0x1":"0x0"};return[t("uint",1),t("int",1),t("hash",1),t("string",8),e("address",20),e("bool",1,n)]},u=a(),c=function(t,e,n){var r,o,a,c,l="",h=i(t,e);if(-1!==h){for(l="0x"+s(h.toString(16),2),r=t[h],o=0;o<r.inputs.length;o++){for(a=!1,c=0;c<u.length&&!a;c++)a=u[c](r.inputs[o].type,n[o]);a||console.error("unsupported json type: "+r.inputs[o].type),l+=a}return l}},l=function(){var t=function(t,e){return function(n){var r,o=t;return 0!==n.indexOf(o)?-1:(r=parseInt(n.slice(o.length))/8*e,2*r)}},e=function(t,e){return function(n){return t===n?2*e:-1}},r=function(t){return t.length<=8?+parseInt(t,16):n(t)},o=function(t){return"0x"+t},i=function(t){return"1"===t?!0:!1},s=function(t){return web3.toAscii(t)};return[{padding:t("uint",1),format:r},{padding:t("int",1),format:r},{padding:t("hash",1),format:o},{padding:t("string",8),format:s},{padding:e("address",20)},{padding:e("bool",1),format:i}]},h=l(),p=function(t,e,n){var r,o,s,a,u,c,l,p=i(t,e);if(-1!==p){for(n=n.slice(2),r=[],o=t[p],s=0;s<o.outputs.length;s++){for(a=-1,u=0;u<h.length&&-1===a;u++)a=h[u].padding(o.outputs[s].type);-1!==a&&(c=n.slice(0,a),l=h[u-1].format,r.push(l?l(c):"0x"+c),n=n.slice(a))}return r}},f=function(t){var e={};return t.forEach(function(n){e[n.name]=function(){var e=Array.prototype.slice.call(arguments);return c(t,n.name,e)}}),e},d=function(t){var e={};return t.forEach(function(n){e[n.name]=function(e){return p(t,n.name,e)}}),e},e.exports={inputParser:f,outputParser:d}},{}],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 y.trigger(t._event,t._id,t.data);if(t._id){var e=y._callbacks[t._id];e&&(e.call(this,t.error,t.data),delete y._callbacks[t._id])}}var o,i,s,a,u=function(){return[{name:"sha3",call:"web3_sha3"}]},c=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"},{name:"logs",call:"eth_logs"}];return r},l=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"}]},h=function(){return[{name:"put",call:"db_put"},{name:"get",call:"db_get"},{name:"putString",call:"db_putString"},{name:"getString",call:"db_getString"}]},p=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"}]},f=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_filterLogs"}]},d=function(){return[{name:"newFilter",call:"shh_newFilter"},{name:"uninstallFilter",call:"shh_uninstallFilter"},{name:"getMessage",call:"shh_getMessages"}]},v=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){y.provider.send(t,function(t,r){return t?void n(t):void e(r)})})})["catch"](function(t){console.error(t)})}})},g=function(t,e){e.forEach(function(e){var r={};r.get=function(){return new Promise(function(t,n){y.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){y.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)})},m=function(t){return parseInt(t,16).toString()},b=function(t){return parseInt(t).toString(16)},y={_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},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},toDecimal:function(t){return m(t.substring(2))},fromDecimal:function(t){return"0x"+b(t)},toEth:function(t){for(var e,n,r,o="string"==typeof t?0===t.indexOf("0x")?parseInt(t.substr(2),16):parseInt(t):t,i=0,s=["wei","Kwei","Mwei","Gwei","szabo","finney","ether","grand","Mether","Gether","Tether","Pether","Eether","Zether","Yether","Nether","Dether","Vether","Uether"];o>3e3&&i<s.length-1;)o/=1e3,i++;for(e=o.toString().length<o.toFixed(2).length?o.toString():o.toFixed(2),n=function(t,e,n){return e+","+n};r=e,e=e.replace(/(\d)(\d\d\d[\.\,])/,n),r!==e;);return e+" "+s[i]},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===y._events[t]&&(y._events[t]={}),y._events[t][e]=n,this},off:function(t,e){return void 0!==y._events[t]&&delete y._events[t][e],this},trigger:function(t,e,n){var r,o=y._events[t];o&&o[e]&&(r=o[e])(n)}};v(y,u()),v(y.eth,c()),g(y.eth,l()),v(y.db,h()),v(y.shh,p()),o={changed:"eth_changed"},v(o,f()),i={changed:"shh_changed"},v(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&&(y._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)},y.provider=new s,y.setProvider=function(t){t.onmessage=r,y.provider.set(t),y.provider.sendQueued()},y.haveProvider=function(){return!!y.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,y.on(e.changed,t,n.trigger.bind(n)),y.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),y.provider.stopPolling(e),y.off(impl.changed,e)})},a.prototype.messages=function(){var t=this;return this.promise.then(function(e){return t.impl.getMessages(e)})},a.prototype.logs=function(){return this.messages()},e.exports=y},{}],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}]},{},["web3"]);
\ 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,r,o,i,s,a,u,c,l,h,p,f,d,v,g,m;n=function(t){return parseInt(t,16).toString()},r=function(t){return parseInt(t).toString(16)},o=function(t,e){for(var n=!1,r=0;r<t.length&&!n;r++)n=e(t[r]);return n?r-1:-1},i=function(t,e){return o(t,function(t){return t.name===e})},s=function(t,e){return new Array(e-t.length+1).join("0")+t},a=function(t,e){var n=t.slice(e.length);return""===n?32:parseInt(n)/8},u=function(t,e){var n=t.slice(e.length);return""===n?32:parseInt(n)},c=function(t,e){var n,r,o,i=t.slice(e.length);if(""===i)return 32;for(n=i.split("x"),r=0,o=0;n>o;o++)r+=n[o]/8;return r},l=function(){var t=function(t,e){return function(n,r){var o,i=t;return 0!==n.indexOf(i)?!1:(o=e(n,i),r="number"==typeof r?r.toString(16):"string"==typeof r?web3.toHex(r):0===r.indexOf("0x")?r.substr(2):(+r).toString(16),s(r,2*o))}},e=function(t,e,n){return function(r,o){return r!==t?!1:s(n?n(o):o,2*e)}},n=function(t){return t?"0x1":"0x0"};return[t("uint",a),t("int",a),t("hash",a),t("string",u),t("real",c),t("ureal",c),e("address",20),e("bool",1,n)]},h=l(),p=function(t,e,n){var r,o,a,u,c="",l=i(t,e);if(-1!==l){for(c="0x"+s(l.toString(16),2),r=t[l],o=0;o<r.inputs.length;o++){for(a=!1,u=0;u<h.length&&!a;u++)a=h[u](r.inputs[o].type,n[o]);a||console.error("unsupported json type: "+r.inputs[o].type),c+=a}return c}},f=function(){var t=function(t,e){return function(n){var r,o=t;return 0!==n.indexOf(o)?-1:(r=e(n,o),2*r)}},e=function(t,e){return function(n){return t===n?2*e:-1}},r=function(t){return t.length<=8?+parseInt(t,16):n(t)},o=function(t){return"0x"+t},i=function(t){return"1"===t?!0:!1},s=function(t){return web3.toAscii(t)};return[{padding:t("uint",a),format:r},{padding:t("int",a),format:r},{padding:t("hash",a),format:o},{padding:t("string",u),format:s},{padding:t("real",c),format:r},{padding:t("ureal",c),format:r},{padding:e("address",20)},{padding:e("bool",1),format:i}]},d=f(),v=function(t,e,n){var r,o,s,a,u,c,l,h=i(t,e);if(-1!==h){for(n=n.slice(2),r=[],o=t[h],s=0;s<o.outputs.length;s++){for(a=-1,u=0;u<d.length&&-1===a;u++)a=d[u].padding(o.outputs[s].type);-1!==a&&(c=n.slice(0,a),l=d[u-1].format,r.push(l?l(c):"0x"+c),n=n.slice(a))}return r}},g=function(t){var e={};return t.forEach(function(n){e[n.name]=function(){var e=Array.prototype.slice.call(arguments);return p(t,n.name,e)}}),e},m=function(t){var e={};return t.forEach(function(n){e[n.name]=function(e){return v(t,n.name,e)}}),e},e.exports={inputParser:g,outputParser:m}},{}],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 y.trigger(t._event,t._id,t.data);if(t._id){var e=y._callbacks[t._id];e&&(e.call(this,t.error,t.data),delete y._callbacks[t._id])}}var o,i,s,a,u=function(){return[{name:"sha3",call:"web3_sha3"}]},c=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"},{name:"logs",call:"eth_logs"}];return r},l=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"}]},h=function(){return[{name:"put",call:"db_put"},{name:"get",call:"db_get"},{name:"putString",call:"db_putString"},{name:"getString",call:"db_getString"}]},p=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"}]},f=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_filterLogs"}]},d=function(){return[{name:"newFilter",call:"shh_newFilter"},{name:"uninstallFilter",call:"shh_uninstallFilter"},{name:"getMessage",call:"shh_getMessages"}]},v=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){y.provider.send(t,function(t,r){return t?void n(t):void e(r)})})})["catch"](function(t){console.error(t)})}})},g=function(t,e){e.forEach(function(e){var r={};r.get=function(){return new Promise(function(t,n){y.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){y.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)})},m=function(t){return parseInt(t,16).toString()},b=function(t){return parseInt(t).toString(16)},y={_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},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},toDecimal:function(t){return m(t.substring(2))},fromDecimal:function(t){return"0x"+b(t)},toEth:function(t){for(var e,n,r,o="string"==typeof t?0===t.indexOf("0x")?parseInt(t.substr(2),16):parseInt(t):t,i=0,s=["wei","Kwei","Mwei","Gwei","szabo","finney","ether","grand","Mether","Gether","Tether","Pether","Eether","Zether","Yether","Nether","Dether","Vether","Uether"];o>3e3&&i<s.length-1;)o/=1e3,i++;for(e=o.toString().length<o.toFixed(2).length?o.toString():o.toFixed(2),n=function(t,e,n){return e+","+n};r=e,e=e.replace(/(\d)(\d\d\d[\.\,])/,n),r!==e;);return e+" "+s[i]},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===y._events[t]&&(y._events[t]={}),y._events[t][e]=n,this},off:function(t,e){return void 0!==y._events[t]&&delete y._events[t][e],this},trigger:function(t,e,n){var r,o=y._events[t];o&&o[e]&&(r=o[e])(n)}};v(y,u()),v(y.eth,c()),g(y.eth,l()),v(y.db,h()),v(y.shh,p()),o={changed:"eth_changed"},v(o,f()),i={changed:"shh_changed"},v(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&&(y._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)},y.provider=new s,y.setProvider=function(t){t.onmessage=r,y.provider.set(t),y.provider.sendQueued()},y.haveProvider=function(){return!!y.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,y.on(e.changed,t,n.trigger.bind(n)),y.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),y.provider.stopPolling(e),y.off(impl.changed,e)})},a.prototype.messages=function(){var t=this;return this.promise.then(function(e){return t.impl.getMessages(e)})},a.prototype.logs=function(){return this.messages()},e.exports=y},{}],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}]},{},["web3"]);
\ No newline at end of file diff --git a/lib/abi.js b/lib/abi.js index e80406ef9..5a4d64515 100644 --- a/lib/abi.js +++ b/lib/abi.js @@ -54,17 +54,44 @@ var padLeft = function (string, chars) { return new Array(chars - string.length + 1).join("0") + string; }; +var calcBitPadding = function (type, expected) { + var value = type.slice(expected.length); + if (value === "") { + return 32; + } + return parseInt(value) / 8; +}; + +var calcBytePadding = function (type, expected) { + var value = type.slice(expected.length); + if (value === "") { + return 32; + } + return parseInt(value); +}; + +var calcRealPadding = function (type, expected) { + var value = type.slice(expected.length); + if (value === "") { + return 32; + } + var sizes = value.split('x'); + for (var padding = 0, i = 0; i < sizes; i++) { + padding += (sizes[i] / 8); + } + return padding; +}; + var setupInputTypes = function () { - // @param prefix is the string prefix of the type - // @param bitsInNumber is number of bits per number in type - var prefixedType = function (prefix, bitsInNumber) { + + var prefixedType = function (prefix, calcPadding) { return function (type, value) { var expected = prefix; if (type.indexOf(expected) !== 0) { return false; } - var padding = parseInt(type.slice(expected.length)) / 8 * bitsInNumber; + var padding = calcPadding(type, expected); if (typeof value === "number") value = value.toString(16); else if (typeof value === "string") @@ -92,10 +119,12 @@ var setupInputTypes = function () { }; return [ - prefixedType('uint', 1), - prefixedType('int', 1), - prefixedType('hash', 1), - prefixedType('string', 8), + prefixedType('uint', calcBitPadding), + prefixedType('int', calcBitPadding), + prefixedType('hash', calcBitPadding), + prefixedType('string', calcBytePadding), + prefixedType('real', calcRealPadding), + prefixedType('ureal', calcRealPadding), namedType('address', 20), namedType('bool', 1, formatBool), ]; @@ -129,16 +158,14 @@ var toAbiInput = function (json, methodName, params) { var setupOutputTypes = function () { - // @param prefix is the string prefix of the type - // @param bitsInNumber is number of bits per number in type - var prefixedType = function (prefix, bitsInNumber) { + var prefixedType = function (prefix, calcPadding) { return function (type) { var expected = prefix; if (type.indexOf(expected) !== 0) { return -1; } - var padding = parseInt(type.slice(expected.length)) / 8 * bitsInNumber; + var padding = calcPadding(type, expected); return padding * 2; }; }; @@ -166,10 +193,12 @@ var setupOutputTypes = function () { }; return [ - { padding: prefixedType('uint', 1), format: formatInt }, - { padding: prefixedType('int', 1), format: formatInt }, - { padding: prefixedType('hash', 1), format: formatHash }, - { padding: prefixedType('string', 8), format: formatString }, + { padding: prefixedType('uint', calcBitPadding), format: formatInt }, + { padding: prefixedType('int', calcBitPadding), format: formatInt }, + { padding: prefixedType('hash', calcBitPadding), format: formatHash }, + { padding: prefixedType('string', calcBytePadding), format: formatString }, + { padding: prefixedType('real', calcRealPadding), format: formatInt }, + { padding: prefixedType('ureal', calcRealPadding), format: formatInt }, { padding: namedType('address', 20) }, { padding: namedType('bool', 1), format: formatBool } ]; |