@ -58,7 +58,7 @@ var isArrayType = function (type) {
* /
* /
var dynamicTypeBytes = function ( type , value ) {
var dynamicTypeBytes = function ( type , value ) {
// TODO: decide what to do with array of strings
// TODO: decide what to do with array of strings
if ( isArrayType ( type ) || type === 'string ' ) // only string itself that is dynamic; stringX is static length.
if ( isArrayType ( type ) || type === 'byte s' )
return f . formatInputInt ( value . length ) ;
return f . formatInputInt ( value . length ) ;
return "" ;
return "" ;
} ;
} ;
@ -99,7 +99,7 @@ var formatInput = function (inputs, params) {
toAppendArrayContent += params [ i ] . reduce ( function ( acc , curr ) {
toAppendArrayContent += params [ i ] . reduce ( function ( acc , curr ) {
return acc + formatter ( curr ) ;
return acc + formatter ( curr ) ;
} , "" ) ;
} , "" ) ;
else if ( inputs [ i ] . type === 'string ' )
else if ( inputs [ i ] . type === 'byte s' )
toAppendArrayContent += formatter ( params [ i ] ) ;
toAppendArrayContent += formatter ( params [ i ] ) ;
else
else
toAppendConstant += formatter ( params [ i ] ) ;
toAppendConstant += formatter ( params [ i ] ) ;
@ -118,7 +118,7 @@ var formatInput = function (inputs, params) {
* @ returns { Number } length of dynamic type , 0 or multiplication of ETH_PADDING ( 32 )
* @ returns { Number } length of dynamic type , 0 or multiplication of ETH_PADDING ( 32 )
* /
* /
var dynamicBytesLength = function ( type ) {
var dynamicBytesLength = function ( type ) {
if ( isArrayType ( type ) || type === 'string ' ) // only string itself that is dynamic; stringX is static length.
if ( isArrayType ( type ) || type === 'byte s' )
return c . ETH_PADDING * 2 ;
return c . ETH_PADDING * 2 ;
return 0 ;
return 0 ;
} ;
} ;
@ -168,7 +168,7 @@ var formatOutput = function (outs, output) {
}
}
result . push ( array ) ;
result . push ( array ) ;
}
}
else if ( types . prefixedType ( 'string ' ) ( outs [ i ] . type ) ) {
else if ( types . prefixedType ( 'byte s' ) ( outs [ i ] . type ) ) {
dynamicPart = dynamicPart . slice ( padding ) ;
dynamicPart = dynamicPart . slice ( padding ) ;
result . push ( formatter ( output . slice ( 0 , padding ) ) ) ;
result . push ( formatter ( output . slice ( 0 , padding ) ) ) ;
output = output . slice ( padding ) ;
output = output . slice ( padding ) ;
@ -509,8 +509,7 @@ var inputTypes = function () {
return [
return [
{ type : prefixedType ( 'uint' ) , format : f . formatInputInt } ,
{ type : prefixedType ( 'uint' ) , format : f . formatInputInt } ,
{ type : prefixedType ( 'int' ) , format : f . formatInputInt } ,
{ type : prefixedType ( 'int' ) , format : f . formatInputInt } ,
{ type : prefixedType ( 'hash' ) , format : f . formatInputInt } ,
{ type : prefixedType ( 'bytes' ) , format : f . formatInputString } ,
{ type : prefixedType ( 'string' ) , format : f . formatInputString } ,
{ type : prefixedType ( 'real' ) , format : f . formatInputReal } ,
{ type : prefixedType ( 'real' ) , format : f . formatInputReal } ,
{ type : prefixedType ( 'ureal' ) , format : f . formatInputReal } ,
{ type : prefixedType ( 'ureal' ) , format : f . formatInputReal } ,
{ type : namedType ( 'address' ) , format : f . formatInputInt } ,
{ type : namedType ( 'address' ) , format : f . formatInputInt } ,
@ -525,8 +524,7 @@ var outputTypes = function () {
return [
return [
{ type : prefixedType ( 'uint' ) , format : f . formatOutputUInt } ,
{ type : prefixedType ( 'uint' ) , format : f . formatOutputUInt } ,
{ type : prefixedType ( 'int' ) , format : f . formatOutputInt } ,
{ type : prefixedType ( 'int' ) , format : f . formatOutputInt } ,
{ type : prefixedType ( 'hash' ) , format : f . formatOutputHash } ,
{ type : prefixedType ( 'bytes' ) , format : f . formatOutputString } ,
{ type : prefixedType ( 'string' ) , format : f . formatOutputString } ,
{ type : prefixedType ( 'real' ) , format : f . formatOutputReal } ,
{ type : prefixedType ( 'real' ) , format : f . formatOutputReal } ,
{ type : prefixedType ( 'ureal' ) , format : f . formatOutputUReal } ,
{ type : prefixedType ( 'ureal' ) , format : f . formatOutputUReal } ,
{ type : namedType ( 'address' ) , format : f . formatOutputAddress } ,
{ type : namedType ( 'address' ) , format : f . formatOutputAddress } ,
@ -1087,10 +1085,12 @@ module.exports = {
* Jeffrey Wilcke < jeff @ ethdev . com >
* Jeffrey Wilcke < jeff @ ethdev . com >
* Marek Kotewicz < marek @ ethdev . com >
* Marek Kotewicz < marek @ ethdev . com >
* Marian Oancea < marian @ ethdev . com >
* Marian Oancea < marian @ ethdev . com >
* Fabian Vogelsteller < fabian @ ethdev . com >
* Gav Wood < g @ ethdev . com >
* Gav Wood < g @ ethdev . com >
* @ date 2014
* @ date 2014
* /
* /
var version = require ( '../version.json' ) ;
var net = require ( './web3/net' ) ;
var net = require ( './web3/net' ) ;
var eth = require ( './web3/eth' ) ;
var eth = require ( './web3/eth' ) ;
var db = require ( './web3/db' ) ;
var db = require ( './web3/db' ) ;
@ -1103,11 +1103,14 @@ var requestManager = require('./web3/requestmanager');
var c = require ( './utils/config' ) ;
var c = require ( './utils/config' ) ;
/// @returns an array of objects describing web3 api methods
/// @returns an array of objects describing web3 api methods
var web3Methods = function ( ) {
var web3Methods = [
return [
{ name : 'sha3' , call : 'web3_sha3' , inputFormatter : utils . toHex } ,
{ name : 'sha3' , call : 'web3_sha3' }
] ;
] ;
} ;
var web3Properties = [
{ name : 'version.client' , getter : 'web3_clientVersion' } ,
{ name : 'version.network' , getter : 'net_version' }
] ;
/// creates methods in a given object based on method description on input
/// creates methods in a given object based on method description on input
/// setups api calls for these methods
/// setups api calls for these methods
@ -1167,7 +1170,9 @@ var setupMethods = function (obj, methods) {
/// setups api calls for these properties
/// setups api calls for these properties
var setupProperties = function ( obj , properties ) {
var setupProperties = function ( obj , properties ) {
properties . forEach ( function ( property ) {
properties . forEach ( function ( property ) {
var proto = { } ;
var objectProperties = property . name . split ( '.' ) ,
proto = { } ;
proto . get = function ( ) {
proto . get = function ( ) {
// show deprecated warning
// show deprecated warning
@ -1197,6 +1202,13 @@ var setupProperties = function (obj, properties) {
}
}
proto . enumerable = ! property . newProperty ;
proto . enumerable = ! property . newProperty ;
if ( objectProperties . length > 1 ) {
if ( ! obj [ objectProperties [ 0 ] ] )
obj [ objectProperties [ 0 ] ] = { } ;
Object . defineProperty ( obj [ objectProperties [ 0 ] ] , objectProperties [ 1 ] , proto ) ;
} else
Object . defineProperty ( obj , property . name , proto ) ;
Object . defineProperty ( obj , property . name , proto ) ;
} ) ;
} ) ;
@ -1227,6 +1239,11 @@ var shhWatch = {
/// setups web3 object, and it's in-browser executed methods
/// setups web3 object, and it's in-browser executed methods
var web3 = {
var web3 = {
version : {
api : version . version
} ,
manager : requestManager ( ) ,
manager : requestManager ( ) ,
providers : { } ,
providers : { } ,
@ -1334,7 +1351,8 @@ Object.defineProperty(web3.eth, 'defaultBlock', {
/// setups all api methods
/// setups all api methods
setupMethods ( web3 , web3Methods ( ) ) ;
setupMethods ( web3 , web3Methods ) ;
setupProperties ( web3 , web3Properties ) ;
setupMethods ( web3 . net , net . methods ) ;
setupMethods ( web3 . net , net . methods ) ;
setupProperties ( web3 . net , net . properties ) ;
setupProperties ( web3 . net , net . properties ) ;
setupMethods ( web3 . eth , eth . methods ) ;
setupMethods ( web3 . eth , eth . methods ) ;
@ -1347,7 +1365,7 @@ setupMethods(shhWatch, watches.shh());
module . exports = web3 ;
module . exports = web3 ;
} , { "./solidity/formatters" : 2 , "./utils/config" : 4 , "./utils/utils" : 5 , "./web3/db" : 8 , "./web3/eth" : 9 , "./web3/filter" : 11 , "./web3/net" : 15 , "./web3/requestmanager" : 17 , "./web3/shh" : 18 , "./web3/watches" : 20 } ] , 7 : [ function ( require , module , exports ) {
} , { "../version.json" : 21 , ". /solidity/formatters" : 2 , "./utils/config" : 4 , "./utils/utils" : 5 , "./web3/db" : 8 , "./web3/eth" : 9 , "./web3/filter" : 11 , "./web3/net" : 15 , "./web3/requestmanager" : 17 , "./web3/shh" : 18 , "./web3/watches" : 20 } ] , 7 : [ function ( require , module , exports ) {
/ *
/ *
This file is part of ethereum . js .
This file is part of ethereum . js .
@ -1615,13 +1633,14 @@ module.exports = contract;
* @ date 2015
* @ date 2015
* /
* /
/// @returns an array of objects describing web3.db api methods
/// @returns an array of objects describing web3.db api methods
var methods = function ( ) {
var methods = function ( ) {
return [
return [
{ name : 'put' , call : 'db_put' } ,
{ name : 'get' , call : 'db_get' } ,
{ name : 'putString' , call : 'db_putString' } ,
{ name : 'putString' , call : 'db_putString' } ,
{ name : 'getString' , call : 'db_getString' }
{ name : 'getString' , call : 'db_getString' } ,
{ name : 'putHex' , call : 'db_putHex' } ,
{ name : 'getHex' , call : 'db_getHex' }
] ;
] ;
} ;
} ;
@ -1649,6 +1668,7 @@ module.exports = {
/ * * @ f i l e e t h . j s
/ * * @ f i l e e t h . j s
* @ authors :
* @ authors :
* Marek Kotewicz < marek @ ethdev . com >
* Marek Kotewicz < marek @ ethdev . com >
* Fabian Vogelsteller < fabian @ ethdev . com >
* @ date 2015
* @ date 2015
* /
* /
@ -1734,7 +1754,7 @@ var methods = [
inputFormatter : formatters . inputTransactionFormatter } ,
inputFormatter : formatters . inputTransactionFormatter } ,
{ name : 'call' , call : 'eth_call' , addDefaultblock : 2 ,
{ name : 'call' , call : 'eth_call' , addDefaultblock : 2 ,
inputFormatter : formatters . inputCallFormatter } ,
inputFormatter : formatters . inputCallFormatter } ,
{ name : 'compile.solidity' , call : 'eth_compileSolidity' , inputFormatter : utils . toHex } ,
{ name : 'compile.solidity' , call : 'eth_compileSolidity' } ,
{ name : 'compile.lll' , call : 'eth_compileLLL' , inputFormatter : utils . toHex } ,
{ name : 'compile.lll' , call : 'eth_compileLLL' , inputFormatter : utils . toHex } ,
{ name : 'compile.serpent' , call : 'eth_compileSerpent' , inputFormatter : utils . toHex } ,
{ name : 'compile.serpent' , call : 'eth_compileSerpent' , inputFormatter : utils . toHex } ,
{ name : 'flush' , call : 'eth_flush' } ,
{ name : 'flush' , call : 'eth_flush' } ,
@ -1941,6 +1961,7 @@ module.exports = {
* Jeffrey Wilcke < jeff @ ethdev . com >
* Jeffrey Wilcke < jeff @ ethdev . com >
* Marek Kotewicz < marek @ ethdev . com >
* Marek Kotewicz < marek @ ethdev . com >
* Marian Oancea < marian @ ethdev . com >
* Marian Oancea < marian @ ethdev . com >
* Fabian Vogelsteller < fabian @ ethdev . com >
* Gav Wood < g @ ethdev . com >
* Gav Wood < g @ ethdev . com >
* @ date 2014
* @ date 2014
* /
* /
@ -2322,6 +2343,7 @@ module.exports = {
* @ authors :
* @ authors :
* Marek Kotewicz < marek @ ethdev . com >
* Marek Kotewicz < marek @ ethdev . com >
* Marian Oancea < marian @ ethdev . com >
* Marian Oancea < marian @ ethdev . com >
* Fabian Vogelsteller < fabian @ ethdev . com >
* @ date 2014
* @ date 2014
* /
* /
@ -2337,7 +2359,6 @@ var HttpProvider = function (host) {
HttpProvider . prototype . send = function ( payload , callback ) {
HttpProvider . prototype . send = function ( payload , callback ) {
var request = new XMLHttpRequest ( ) ;
var request = new XMLHttpRequest ( ) ;
request . open ( 'POST' , this . host , false ) ;
// ASYNC
// ASYNC
if ( typeof callback === 'function' ) {
if ( typeof callback === 'function' ) {
@ -2539,6 +2560,7 @@ module.exports = QtSyncProvider;
* Jeffrey Wilcke < jeff @ ethdev . com >
* Jeffrey Wilcke < jeff @ ethdev . com >
* Marek Kotewicz < marek @ ethdev . com >
* Marek Kotewicz < marek @ ethdev . com >
* Marian Oancea < marian @ ethdev . com >
* Marian Oancea < marian @ ethdev . com >
* Fabian Vogelsteller < fabian @ ethdev . com >
* Gav Wood < g @ ethdev . com >
* Gav Wood < g @ ethdev . com >
* @ date 2014
* @ date 2014
* /
* /
@ -2609,7 +2631,6 @@ var requestManager = function() {
var result = provider . send ( payload ) ;
var result = provider . send ( payload ) ;
if ( ! jsonrpc . isValidResponse ( result ) ) {
if ( ! jsonrpc . isValidResponse ( result ) ) {
console . log ( result ) ;
if ( typeof result === 'object' && result . error && result . error . message )
if ( typeof result === 'object' && result . error && result . error . message )
console . error ( result . error . message ) ;
console . error ( result . error . message ) ;
return null ;
return null ;
@ -2819,6 +2840,10 @@ module.exports = {
} ;
} ;
} , { } ] , 21 : [ function ( require , module , exports ) {
module . exports = {
"version" : "0.1.3"
}
} , { } ] , "web3" : [ function ( require , module , exports ) {
} , { } ] , "web3" : [ function ( require , module , exports ) {
var web3 = require ( './lib/web3' ) ;
var web3 = require ( './lib/web3' ) ;
web3 . providers . HttpProvider = require ( './lib/web3/httpprovider' ) ;
web3 . providers . HttpProvider = require ( './lib/web3/httpprovider' ) ;