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
b0a9bbf3
Commit
b0a9bbf3
authored
Jan 14, 2015
by
Marek Kotewicz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
next part of abi.js docs
parent
6b2ec231
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
71 additions
and
61 deletions
+71
-61
ethereum.js
dist/ethereum.js
+34
-29
ethereum.js.map
dist/ethereum.js.map
+2
-2
ethereum.min.js
dist/ethereum.min.js
+1
-1
abi.js
lib/abi.js
+34
-29
No files found.
dist/ethereum.js
View file @
b0a9bbf3
...
@@ -36,6 +36,10 @@ var decToHex = function (dec) {
...
@@ -36,6 +36,10 @@ var decToHex = function (dec) {
return
parseInt
(
dec
).
toString
(
16
);
return
parseInt
(
dec
).
toString
(
16
);
};
};
/// Finds first index of array element matching pattern
/// @param array
/// @param callback pattern
/// @returns index of element
var
findIndex
=
function
(
array
,
callback
)
{
var
findIndex
=
function
(
array
,
callback
)
{
var
end
=
false
;
var
end
=
false
;
var
i
=
0
;
var
i
=
0
;
...
@@ -45,31 +49,39 @@ var findIndex = function (array, callback) {
...
@@ -45,31 +49,39 @@ var findIndex = function (array, callback) {
return
end
?
i
-
1
:
-
1
;
return
end
?
i
-
1
:
-
1
;
};
};
/// @returns a function that is used as a pattern for 'findIndex'
var
findMethodIndex
=
function
(
json
,
methodName
)
{
var
findMethodIndex
=
function
(
json
,
methodName
)
{
return
findIndex
(
json
,
function
(
method
)
{
return
findIndex
(
json
,
function
(
method
)
{
return
method
.
name
===
methodName
;
return
method
.
name
===
methodName
;
});
});
};
};
/// @param string string to be padded
/// @param number of characters that result string should have
/// @returns right aligned string
var
padLeft
=
function
(
string
,
chars
)
{
var
padLeft
=
function
(
string
,
chars
)
{
return
new
Array
(
chars
-
string
.
length
+
1
).
join
(
"0"
)
+
string
;
return
new
Array
(
chars
-
string
.
length
+
1
).
join
(
"0"
)
+
string
;
};
};
/// Setups input formatters for solidity types
/// @param expected type prefix (string)
/// @returns an array of input formatters
/// @returns function which checks if type has matching prefix. if yes, returns true, otherwise false
var
setupInputTypes
=
function
()
{
var
prefixedType
=
function
(
prefix
)
{
return
function
(
type
)
{
var
prefixedType
=
function
(
prefix
)
{
return
function
(
type
,
value
)
{
return
type
.
indexOf
(
prefix
)
===
0
;
return
type
.
indexOf
(
prefix
)
===
0
;
};
};
};
};
var
namedType
=
function
(
name
,
formatter
)
{
/// @param expected type name (string)
return
function
(
type
,
value
)
{
/// @returns function which checks if type is matching expected one. if yes, returns true, otherwise false
return
type
===
name
;
var
namedType
=
function
(
name
)
{
};
return
function
(
type
)
{
return
name
===
type
;
};
};
};
/// Setups input formatters for solidity types
/// @returns an array of input formatters
var
setupInputTypes
=
function
()
{
var
formatInt
=
function
(
value
)
{
var
formatInt
=
function
(
value
)
{
var
padding
=
32
*
2
;
var
padding
=
32
*
2
;
...
@@ -106,6 +118,11 @@ var setupInputTypes = function () {
...
@@ -106,6 +118,11 @@ var setupInputTypes = function () {
var
inputTypes
=
setupInputTypes
();
var
inputTypes
=
setupInputTypes
();
/// Formats input params to bytes
/// @param contract json abi
/// @param name of the method that we want to use
/// @param array of params that will be formatted to bytes
/// @returns bytes representation of input params
var
toAbiInput
=
function
(
json
,
methodName
,
params
)
{
var
toAbiInput
=
function
(
json
,
methodName
,
params
)
{
var
bytes
=
""
;
var
bytes
=
""
;
var
index
=
findMethodIndex
(
json
,
methodName
);
var
index
=
findMethodIndex
(
json
,
methodName
);
...
@@ -136,23 +153,6 @@ var toAbiInput = function (json, methodName, params) {
...
@@ -136,23 +153,6 @@ var toAbiInput = function (json, methodName, params) {
/// @returns an array of output formatters
/// @returns an array of output formatters
var
setupOutputTypes
=
function
()
{
var
setupOutputTypes
=
function
()
{
/// @param expected type prefix (string)
/// @returns function which checks if type has matching prefix. if yes, returns true, otherwise false
var
prefixedType
=
function
(
prefix
)
{
return
function
(
type
)
{
var
expected
=
prefix
;
return
type
.
indexOf
(
expected
)
===
0
;
};
};
/// @param expected type name (string)
/// @returns function which checks if type is matching expected one. if yes, returns true, otherwise false
var
namedType
=
function
(
name
)
{
return
function
(
type
)
{
return
name
===
type
;
};
};
/// @returns input bytes formatted to int
/// @returns input bytes formatted to int
var
formatInt
=
function
(
value
)
{
var
formatInt
=
function
(
value
)
{
return
value
.
length
<=
8
?
+
parseInt
(
value
,
16
)
:
hexToDec
(
value
);
return
value
.
length
<=
8
?
+
parseInt
(
value
,
16
)
:
hexToDec
(
value
);
...
@@ -187,6 +187,11 @@ var setupOutputTypes = function () {
...
@@ -187,6 +187,11 @@ var setupOutputTypes = function () {
var
outputTypes
=
setupOutputTypes
();
var
outputTypes
=
setupOutputTypes
();
/// Formats output bytes back to param list
/// @param contract json abi
/// @param name of the method that we want to use
/// @param bytes representtion of output
/// @returns array of output params
var
fromAbiOutput
=
function
(
json
,
methodName
,
output
)
{
var
fromAbiOutput
=
function
(
json
,
methodName
,
output
)
{
var
index
=
findMethodIndex
(
json
,
methodName
);
var
index
=
findMethodIndex
(
json
,
methodName
);
...
...
dist/ethereum.js.map
View file @
b0a9bbf3
This diff is collapsed.
Click to expand it.
dist/ethereum.min.js
View file @
b0a9bbf3
This diff is collapsed.
Click to expand it.
lib/abi.js
View file @
b0a9bbf3
...
@@ -35,6 +35,10 @@ var decToHex = function (dec) {
...
@@ -35,6 +35,10 @@ var decToHex = function (dec) {
return
parseInt
(
dec
).
toString
(
16
);
return
parseInt
(
dec
).
toString
(
16
);
};
};
/// Finds first index of array element matching pattern
/// @param array
/// @param callback pattern
/// @returns index of element
var
findIndex
=
function
(
array
,
callback
)
{
var
findIndex
=
function
(
array
,
callback
)
{
var
end
=
false
;
var
end
=
false
;
var
i
=
0
;
var
i
=
0
;
...
@@ -44,31 +48,39 @@ var findIndex = function (array, callback) {
...
@@ -44,31 +48,39 @@ var findIndex = function (array, callback) {
return
end
?
i
-
1
:
-
1
;
return
end
?
i
-
1
:
-
1
;
};
};
/// @returns a function that is used as a pattern for 'findIndex'
var
findMethodIndex
=
function
(
json
,
methodName
)
{
var
findMethodIndex
=
function
(
json
,
methodName
)
{
return
findIndex
(
json
,
function
(
method
)
{
return
findIndex
(
json
,
function
(
method
)
{
return
method
.
name
===
methodName
;
return
method
.
name
===
methodName
;
});
});
};
};
/// @param string string to be padded
/// @param number of characters that result string should have
/// @returns right aligned string
var
padLeft
=
function
(
string
,
chars
)
{
var
padLeft
=
function
(
string
,
chars
)
{
return
new
Array
(
chars
-
string
.
length
+
1
).
join
(
"0"
)
+
string
;
return
new
Array
(
chars
-
string
.
length
+
1
).
join
(
"0"
)
+
string
;
};
};
/// Setups input formatters for solidity types
/// @param expected type prefix (string)
/// @returns an array of input formatters
/// @returns function which checks if type has matching prefix. if yes, returns true, otherwise false
var
setupInputTypes
=
function
()
{
var
prefixedType
=
function
(
prefix
)
{
return
function
(
type
)
{
var
prefixedType
=
function
(
prefix
)
{
return
function
(
type
,
value
)
{
return
type
.
indexOf
(
prefix
)
===
0
;
return
type
.
indexOf
(
prefix
)
===
0
;
};
};
};
};
var
namedType
=
function
(
name
,
formatter
)
{
/// @param expected type name (string)
return
function
(
type
,
value
)
{
/// @returns function which checks if type is matching expected one. if yes, returns true, otherwise false
return
type
===
name
;
var
namedType
=
function
(
name
)
{
};
return
function
(
type
)
{
return
name
===
type
;
};
};
};
/// Setups input formatters for solidity types
/// @returns an array of input formatters
var
setupInputTypes
=
function
()
{
var
formatInt
=
function
(
value
)
{
var
formatInt
=
function
(
value
)
{
var
padding
=
32
*
2
;
var
padding
=
32
*
2
;
...
@@ -105,6 +117,11 @@ var setupInputTypes = function () {
...
@@ -105,6 +117,11 @@ var setupInputTypes = function () {
var
inputTypes
=
setupInputTypes
();
var
inputTypes
=
setupInputTypes
();
/// Formats input params to bytes
/// @param contract json abi
/// @param name of the method that we want to use
/// @param array of params that will be formatted to bytes
/// @returns bytes representation of input params
var
toAbiInput
=
function
(
json
,
methodName
,
params
)
{
var
toAbiInput
=
function
(
json
,
methodName
,
params
)
{
var
bytes
=
""
;
var
bytes
=
""
;
var
index
=
findMethodIndex
(
json
,
methodName
);
var
index
=
findMethodIndex
(
json
,
methodName
);
...
@@ -135,23 +152,6 @@ var toAbiInput = function (json, methodName, params) {
...
@@ -135,23 +152,6 @@ var toAbiInput = function (json, methodName, params) {
/// @returns an array of output formatters
/// @returns an array of output formatters
var
setupOutputTypes
=
function
()
{
var
setupOutputTypes
=
function
()
{
/// @param expected type prefix (string)
/// @returns function which checks if type has matching prefix. if yes, returns true, otherwise false
var
prefixedType
=
function
(
prefix
)
{
return
function
(
type
)
{
var
expected
=
prefix
;
return
type
.
indexOf
(
expected
)
===
0
;
};
};
/// @param expected type name (string)
/// @returns function which checks if type is matching expected one. if yes, returns true, otherwise false
var
namedType
=
function
(
name
)
{
return
function
(
type
)
{
return
name
===
type
;
};
};
/// @returns input bytes formatted to int
/// @returns input bytes formatted to int
var
formatInt
=
function
(
value
)
{
var
formatInt
=
function
(
value
)
{
return
value
.
length
<=
8
?
+
parseInt
(
value
,
16
)
:
hexToDec
(
value
);
return
value
.
length
<=
8
?
+
parseInt
(
value
,
16
)
:
hexToDec
(
value
);
...
@@ -186,6 +186,11 @@ var setupOutputTypes = function () {
...
@@ -186,6 +186,11 @@ var setupOutputTypes = function () {
var
outputTypes
=
setupOutputTypes
();
var
outputTypes
=
setupOutputTypes
();
/// Formats output bytes back to param list
/// @param contract json abi
/// @param name of the method that we want to use
/// @param bytes representtion of output
/// @returns array of output params
var
fromAbiOutput
=
function
(
json
,
methodName
,
output
)
{
var
fromAbiOutput
=
function
(
json
,
methodName
,
output
)
{
var
index
=
findMethodIndex
(
json
,
methodName
);
var
index
=
findMethodIndex
(
json
,
methodName
);
...
...
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