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
46b932cc
Commit
46b932cc
authored
Jan 15, 2015
by
Marek Kotewicz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
negative integers support
parent
f85f77f6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
4 deletions
+23
-4
abi.js
lib/abi.js
+13
-3
abi.parsers.js
test/abi.parsers.js
+10
-1
No files found.
lib/abi.js
View file @
46b932cc
...
...
@@ -57,9 +57,10 @@ var findMethodIndex = function (json, methodName) {
/// @param string string to be padded
/// @param number of characters that result string should have
/// @param sign, by default 0
/// @returns right aligned string
var
padLeft
=
function
(
string
,
chars
)
{
return
new
Array
(
chars
-
string
.
length
+
1
).
join
(
"0"
)
+
string
;
var
padLeft
=
function
(
string
,
chars
,
sign
)
{
return
new
Array
(
chars
-
string
.
length
+
1
).
join
(
sign
?
sign
:
"0"
)
+
string
;
};
/// @param expected type prefix (string)
...
...
@@ -86,8 +87,17 @@ var setupInputTypes = function () {
/// @returns right-aligned byte representation of int
var
formatInt
=
function
(
value
)
{
var
padding
=
32
*
2
;
if
(
typeof
value
===
'number'
)
if
(
typeof
value
===
'number'
)
{
if
(
value
<
0
)
{
// two's complement
// TODO: fix big numbers support
value
=
((
value
)
>>>
0
).
toString
(
16
)
return
padLeft
(
value
,
padding
,
'f'
);
}
value
=
value
.
toString
(
16
);
}
else
if
(
value
.
indexOf
(
'0x'
)
===
0
)
value
=
value
.
substr
(
2
);
else
if
(
typeof
value
===
'string'
)
...
...
test/abi.parsers.js
View file @
46b932cc
...
...
@@ -55,7 +55,7 @@ describe('abi', function() {
});
it
(
'should parse input uint'
,
function
()
{
it
(
'should parse input uint
256
'
,
function
()
{
// given
var
d
=
clone
(
description
);
...
...
@@ -88,6 +88,9 @@ describe('abi', function() {
// then
assert
.
equal
(
parser
.
test
(
1
),
"0000000000000000000000000000000000000000000000000000000000000001"
);
assert
.
equal
(
parser
.
test
(
10
),
"000000000000000000000000000000000000000000000000000000000000000a"
);
assert
.
equal
(
parser
.
test
(
-
1
),
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
);
assert
.
equal
(
parser
.
test
(
-
2
),
"fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe"
);
assert
.
equal
(
parser
.
test
(
-
16
),
"fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0"
);
});
...
...
@@ -106,6 +109,9 @@ describe('abi', function() {
// then
assert
.
equal
(
parser
.
test
(
1
),
"0000000000000000000000000000000000000000000000000000000000000001"
);
assert
.
equal
(
parser
.
test
(
10
),
"000000000000000000000000000000000000000000000000000000000000000a"
);
assert
.
equal
(
parser
.
test
(
-
1
),
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
);
assert
.
equal
(
parser
.
test
(
-
2
),
"fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe"
);
assert
.
equal
(
parser
.
test
(
-
16
),
"fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0"
);
});
...
...
@@ -124,6 +130,9 @@ describe('abi', function() {
// then
assert
.
equal
(
parser
.
test
(
1
),
"0000000000000000000000000000000000000000000000000000000000000001"
);
assert
.
equal
(
parser
.
test
(
10
),
"000000000000000000000000000000000000000000000000000000000000000a"
);
assert
.
equal
(
parser
.
test
(
-
1
),
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
);
assert
.
equal
(
parser
.
test
(
-
2
),
"fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe"
);
assert
.
equal
(
parser
.
test
(
-
16
),
"fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0"
);
});
...
...
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