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
af54832d
Commit
af54832d
authored
Jan 19, 2015
by
Marek Kotewicz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
encoding real on input
parent
86b417e8
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
61 additions
and
7 deletions
+61
-7
ethereum.js
dist/ethereum.js
+9
-2
ethereum.js.map
dist/ethereum.js.map
+2
-2
ethereum.min.js
dist/ethereum.min.js
+1
-1
abi.js
lib/abi.js
+9
-2
abi.parsers.js
test/abi.parsers.js
+40
-0
No files found.
dist/ethereum.js
View file @
af54832d
...
...
@@ -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
}
];
...
...
dist/ethereum.js.map
View file @
af54832d
This diff is collapsed.
Click to expand it.
dist/ethereum.min.js
View file @
af54832d
This diff is collapsed.
Click to expand it.
lib/abi.js
View file @
af54832d
...
...
@@ -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
}
];
...
...
test/abi.parsers.js
View file @
af54832d
...
...
@@ -380,6 +380,46 @@ 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
()
{
...
...
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