Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
83505e61
Commit
83505e61
authored
Jan 19, 2015
by
Marek Kotewicz
Browse files
Options
Browse Files
Download
Plain Diff
Merge commit '2b4d38b9bf059014596e1ab00c99dc2ad4ab3761' into ethereumjs
parents
2ce109eb
6a58db66
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
149 additions
and
28 deletions
+149
-28
ethereum.js
dist/ethereum.js
+32
-11
ethereum.js.map
dist/ethereum.js.map
+4
-4
ethereum.min.js
dist/ethereum.min.js
+1
-1
abi.js
lib/abi.js
+29
-6
autoprovider.js
lib/autoprovider.js
+2
-3
providermanager.js
lib/providermanager.js
+0
-1
abi.parsers.js
test/abi.parsers.js
+81
-2
No files found.
dist/ethereum.js
View file @
83505e61
...
...
@@ -117,6 +117,13 @@ var formatInputBool = function (value) {
return
'000000000000000000000000000000000000000000000000000000000000000'
+
(
value
?
'1'
:
'0'
);
};
/// Formats input value to byte representation of real
/// Values are multiplied by 2^m and encoded as integers
/// @returns byte representation of real
var
formatInputReal
=
function
(
value
)
{
return
formatInputInt
(
new
BigNumber
(
value
).
times
(
new
BigNumber
(
2
).
pow
(
128
)));
};
var
dynamicTypeBytes
=
function
(
type
,
value
)
{
// TODO: decide what to do with array of strings
if
(
arrayType
(
type
)
||
prefixedType
(
'string'
)(
type
))
...
...
@@ -133,8 +140,8 @@ var setupInputTypes = function () {
{
type
:
prefixedType
(
'int'
),
format
:
formatInputInt
},
{
type
:
prefixedType
(
'hash'
),
format
:
formatInputInt
},
{
type
:
prefixedType
(
'string'
),
format
:
formatInputString
},
{
type
:
prefixedType
(
'real'
),
format
:
formatInput
Int
},
{
type
:
prefixedType
(
'ureal'
),
format
:
formatInput
Int
},
{
type
:
prefixedType
(
'real'
),
format
:
formatInput
Real
},
{
type
:
prefixedType
(
'ureal'
),
format
:
formatInput
Real
},
{
type
:
namedType
(
'address'
),
format
:
formatInputInt
},
{
type
:
namedType
(
'bool'
),
format
:
formatInputBool
}
];
...
...
@@ -187,13 +194,19 @@ var toAbiInput = function (json, methodName, params) {
return
bytes
;
};
/// Check if input value is negative
/// @param value is hex format
/// @returns true if it is negative, otherwise false
var
signedIsNegative
=
function
(
value
)
{
return
(
new
BigNumber
(
value
.
substr
(
0
,
1
),
16
).
toString
(
2
).
substr
(
0
,
1
))
===
'1'
;
};
/// Formats input right-aligned input bytes to int
/// @returns right-aligned input bytes formatted to int
var
formatOutputInt
=
function
(
value
)
{
// check if it's negative number
// it it is, return two's complement
var
firstBit
=
new
BigNumber
(
value
.
substr
(
0
,
1
),
16
).
toString
(
2
).
substr
(
0
,
1
);
if
(
firstBit
===
'1'
)
{
if
(
signedIsNegative
(
value
))
{
return
new
BigNumber
(
value
,
16
).
minus
(
new
BigNumber
(
'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'
,
16
)).
minus
(
1
);
}
return
new
BigNumber
(
value
,
16
);
...
...
@@ -205,6 +218,16 @@ var formatOutputUInt = function (value) {
return
new
BigNumber
(
value
,
16
);
};
/// @returns input bytes formatted to real
var
formatOutputReal
=
function
(
value
)
{
return
formatOutputInt
(
value
).
dividedBy
(
new
BigNumber
(
2
).
pow
(
128
));
};
/// @returns input bytes formatted to ureal
var
formatOutputUReal
=
function
(
value
)
{
return
formatOutputUInt
(
value
).
dividedBy
(
new
BigNumber
(
2
).
pow
(
128
));
};
/// @returns right-aligned input bytes formatted to hex
var
formatOutputHash
=
function
(
value
)
{
return
"0x"
+
value
;
...
...
@@ -240,8 +263,8 @@ var setupOutputTypes = function () {
{
type
:
prefixedType
(
'int'
),
format
:
formatOutputInt
},
{
type
:
prefixedType
(
'hash'
),
format
:
formatOutputHash
},
{
type
:
prefixedType
(
'string'
),
format
:
formatOutputString
},
{
type
:
prefixedType
(
'real'
),
format
:
formatOutput
Int
},
{
type
:
prefixedType
(
'ureal'
),
format
:
formatOutput
Int
},
{
type
:
prefixedType
(
'real'
),
format
:
formatOutput
Real
},
{
type
:
prefixedType
(
'ureal'
),
format
:
formatOutput
UReal
},
{
type
:
namedType
(
'address'
),
format
:
formatOutputAddress
},
{
type
:
namedType
(
'bool'
),
format
:
formatOutputBool
}
];
...
...
@@ -387,10 +410,9 @@ module.exports = {
* if it fails, it uses HttpRpcProvider
*/
// TODO: is these line is supposed to be here?
var
web3
=
require
(
'./web3'
);
// jshint ignore:line
if
(
"build"
!==
'build'
)
{
/*
var WebSocket = require('ws'); // jshint ignore:line
var web3 = require('./web3'); // jshint ignore:line
*/
}
/**
...
...
@@ -433,7 +455,7 @@ var AutoProvider = function (userOptions) {
self
.
poll
=
self
.
provider
.
poll
.
bind
(
self
.
provider
);
}
self
.
sendQueue
.
forEach
(
function
(
payload
)
{
self
.
provider
(
payload
);
self
.
provider
.
send
(
payload
);
});
self
.
onmessageQueue
.
forEach
(
function
(
handler
)
{
self
.
provider
.
onmessage
=
handler
;
...
...
@@ -474,7 +496,7 @@ Object.defineProperty(AutoProvider.prototype, 'onmessage', {
module
.
exports
=
AutoProvider
;
},{}],
3
:[
function
(
require
,
module
,
exports
){
},{
"./web3"
:
8
}],
3
:[
function
(
require
,
module
,
exports
){
/*
This file is part of ethereum.js.
...
...
@@ -807,7 +829,6 @@ module.exports = HttpRpcProvider;
* @date 2014
*/
// TODO: is these line is supposed to be here?
var
web3
=
require
(
'./web3'
);
// jshint ignore:line
/**
...
...
dist/ethereum.js.map
View file @
83505e61
This diff is collapsed.
Click to expand it.
dist/ethereum.min.js
View file @
83505e61
This diff is collapsed.
Click to expand it.
lib/abi.js
View file @
83505e61
...
...
@@ -116,6 +116,13 @@ var formatInputBool = function (value) {
return
'000000000000000000000000000000000000000000000000000000000000000'
+
(
value
?
'1'
:
'0'
);
};
/// Formats input value to byte representation of real
/// Values are multiplied by 2^m and encoded as integers
/// @returns byte representation of real
var
formatInputReal
=
function
(
value
)
{
return
formatInputInt
(
new
BigNumber
(
value
).
times
(
new
BigNumber
(
2
).
pow
(
128
)));
};
var
dynamicTypeBytes
=
function
(
type
,
value
)
{
// TODO: decide what to do with array of strings
if
(
arrayType
(
type
)
||
prefixedType
(
'string'
)(
type
))
...
...
@@ -132,8 +139,8 @@ var setupInputTypes = function () {
{
type
:
prefixedType
(
'int'
),
format
:
formatInputInt
},
{
type
:
prefixedType
(
'hash'
),
format
:
formatInputInt
},
{
type
:
prefixedType
(
'string'
),
format
:
formatInputString
},
{
type
:
prefixedType
(
'real'
),
format
:
formatInput
Int
},
{
type
:
prefixedType
(
'ureal'
),
format
:
formatInput
Int
},
{
type
:
prefixedType
(
'real'
),
format
:
formatInput
Real
},
{
type
:
prefixedType
(
'ureal'
),
format
:
formatInput
Real
},
{
type
:
namedType
(
'address'
),
format
:
formatInputInt
},
{
type
:
namedType
(
'bool'
),
format
:
formatInputBool
}
];
...
...
@@ -186,13 +193,19 @@ var toAbiInput = function (json, methodName, params) {
return
bytes
;
};
/// Check if input value is negative
/// @param value is hex format
/// @returns true if it is negative, otherwise false
var
signedIsNegative
=
function
(
value
)
{
return
(
new
BigNumber
(
value
.
substr
(
0
,
1
),
16
).
toString
(
2
).
substr
(
0
,
1
))
===
'1'
;
};
/// Formats input right-aligned input bytes to int
/// @returns right-aligned input bytes formatted to int
var
formatOutputInt
=
function
(
value
)
{
// check if it's negative number
// it it is, return two's complement
var
firstBit
=
new
BigNumber
(
value
.
substr
(
0
,
1
),
16
).
toString
(
2
).
substr
(
0
,
1
);
if
(
firstBit
===
'1'
)
{
if
(
signedIsNegative
(
value
))
{
return
new
BigNumber
(
value
,
16
).
minus
(
new
BigNumber
(
'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'
,
16
)).
minus
(
1
);
}
return
new
BigNumber
(
value
,
16
);
...
...
@@ -204,6 +217,16 @@ var formatOutputUInt = function (value) {
return
new
BigNumber
(
value
,
16
);
};
/// @returns input bytes formatted to real
var
formatOutputReal
=
function
(
value
)
{
return
formatOutputInt
(
value
).
dividedBy
(
new
BigNumber
(
2
).
pow
(
128
));
};
/// @returns input bytes formatted to ureal
var
formatOutputUReal
=
function
(
value
)
{
return
formatOutputUInt
(
value
).
dividedBy
(
new
BigNumber
(
2
).
pow
(
128
));
};
/// @returns right-aligned input bytes formatted to hex
var
formatOutputHash
=
function
(
value
)
{
return
"0x"
+
value
;
...
...
@@ -239,8 +262,8 @@ var setupOutputTypes = function () {
{
type
:
prefixedType
(
'int'
),
format
:
formatOutputInt
},
{
type
:
prefixedType
(
'hash'
),
format
:
formatOutputHash
},
{
type
:
prefixedType
(
'string'
),
format
:
formatOutputString
},
{
type
:
prefixedType
(
'real'
),
format
:
formatOutput
Int
},
{
type
:
prefixedType
(
'ureal'
),
format
:
formatOutput
Int
},
{
type
:
prefixedType
(
'real'
),
format
:
formatOutput
Real
},
{
type
:
prefixedType
(
'ureal'
),
format
:
formatOutput
UReal
},
{
type
:
namedType
(
'address'
),
format
:
formatOutputAddress
},
{
type
:
namedType
(
'bool'
),
format
:
formatOutputBool
}
];
...
...
lib/autoprovider.js
View file @
83505e61
...
...
@@ -27,10 +27,9 @@
* if it fails, it uses HttpRpcProvider
*/
// TODO: is these line is supposed to be here?
var
web3
=
require
(
'./web3'
);
// jshint ignore:line
if
(
process
.
env
.
NODE_ENV
!==
'build'
)
{
var
WebSocket
=
require
(
'ws'
);
// jshint ignore:line
var
web3
=
require
(
'./web3'
);
// jshint ignore:line
}
/**
...
...
@@ -73,7 +72,7 @@ var AutoProvider = function (userOptions) {
self
.
poll
=
self
.
provider
.
poll
.
bind
(
self
.
provider
);
}
self
.
sendQueue
.
forEach
(
function
(
payload
)
{
self
.
provider
(
payload
);
self
.
provider
.
send
(
payload
);
});
self
.
onmessageQueue
.
forEach
(
function
(
handler
)
{
self
.
provider
.
onmessage
=
handler
;
...
...
lib/providermanager.js
View file @
83505e61
...
...
@@ -23,7 +23,6 @@
* @date 2014
*/
// TODO: is these line is supposed to be here?
var
web3
=
require
(
'./web3'
);
// jshint ignore:line
/**
...
...
test/abi.parsers.js
View file @
83505e61
...
...
@@ -380,6 +380,45 @@ describe('abi', function() {
);
});
it
(
'should parse input real'
,
function
()
{
// given
var
d
=
clone
(
description
);
d
[
0
].
inputs
=
[
{
type
:
'real'
}
];
// when
var
parser
=
abi
.
inputParser
(
d
);
// then
assert
.
equal
(
parser
.
test
([
1
]),
"0000000000000000000000000000000100000000000000000000000000000000"
);
assert
.
equal
(
parser
.
test
([
2.125
]),
"0000000000000000000000000000000220000000000000000000000000000000"
);
assert
.
equal
(
parser
.
test
([
8.5
]),
"0000000000000000000000000000000880000000000000000000000000000000"
);
assert
.
equal
(
parser
.
test
([
-
1
]),
"ffffffffffffffffffffffffffffffff00000000000000000000000000000000"
);
});
it
(
'should parse input ureal'
,
function
()
{
// given
var
d
=
clone
(
description
);
d
[
0
].
inputs
=
[
{
type
:
'ureal'
}
];
// when
var
parser
=
abi
.
inputParser
(
d
);
// then
assert
.
equal
(
parser
.
test
([
1
]),
"0000000000000000000000000000000100000000000000000000000000000000"
);
assert
.
equal
(
parser
.
test
([
2.125
]),
"0000000000000000000000000000000220000000000000000000000000000000"
);
assert
.
equal
(
parser
.
test
([
8.5
]),
"0000000000000000000000000000000880000000000000000000000000000000"
);
});
});
describe
(
'outputParser'
,
function
()
{
...
...
@@ -633,12 +672,52 @@ describe('abi', function() {
var
parser
=
abi
.
outputParser
(
d
);
// then
assert
.
equal
(
parser
.
test
(
"0
0
0000000000000000000000000000000000000000000000000000000000000001"
)[
0
],
true
);
assert
.
equal
(
parser
.
test
(
"0
0
0000000000000000000000000000000000000000000000000000000000000000"
)[
0
],
false
);
assert
.
equal
(
parser
.
test
(
"0
x
0000000000000000000000000000000000000000000000000000000000000001"
)[
0
],
true
);
assert
.
equal
(
parser
.
test
(
"0
x
0000000000000000000000000000000000000000000000000000000000000000"
)[
0
],
false
);
});
it
(
'should parse output real'
,
function
()
{
// given
var
d
=
clone
(
description
);
d
[
0
].
outputs
=
[
{
type
:
'real'
}
];
// when
var
parser
=
abi
.
outputParser
(
d
);
// then
assert
.
equal
(
parser
.
test
(
"0x0000000000000000000000000000000100000000000000000000000000000000"
)[
0
],
1
);
assert
.
equal
(
parser
.
test
(
"0x0000000000000000000000000000000220000000000000000000000000000000"
)[
0
],
2.125
);
assert
.
equal
(
parser
.
test
(
"0x0000000000000000000000000000000880000000000000000000000000000000"
)[
0
],
8.5
);
assert
.
equal
(
parser
.
test
(
"0xffffffffffffffffffffffffffffffff00000000000000000000000000000000"
)[
0
],
-
1
);
});
it
(
'should parse output ureal'
,
function
()
{
// given
var
d
=
clone
(
description
);
d
[
0
].
outputs
=
[
{
type
:
'ureal'
}
];
// when
var
parser
=
abi
.
outputParser
(
d
);
// then
assert
.
equal
(
parser
.
test
(
"0x0000000000000000000000000000000100000000000000000000000000000000"
)[
0
],
1
);
assert
.
equal
(
parser
.
test
(
"0x0000000000000000000000000000000220000000000000000000000000000000"
)[
0
],
2.125
);
assert
.
equal
(
parser
.
test
(
"0x0000000000000000000000000000000880000000000000000000000000000000"
)[
0
],
8.5
);
});
it
(
'should parse multiple output strings'
,
function
()
{
// given
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment