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
7595a5df
Commit
7595a5df
authored
Jan 13, 2015
by
Marek Kotewicz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removed padding calculation from ethereum.js, padding is always 32
parent
9a9987ae
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
121 deletions
+51
-121
ethereum.js
dist/ethereum.js
+24
-59
ethereum.js.map
dist/ethereum.js.map
+2
-2
ethereum.min.js
dist/ethereum.min.js
+1
-1
abi.js
lib/abi.js
+24
-59
No files found.
dist/ethereum.js
View file @
7595a5df
...
...
@@ -55,47 +55,16 @@ var padLeft = function (string, chars) {
return
new
Array
(
chars
-
string
.
length
+
1
).
join
(
"0"
)
+
string
;
};
var
calcBitPadding
=
function
(
type
,
expected
)
{
var
value
=
type
.
slice
(
expected
.
length
);
if
(
value
===
""
)
{
return
32
;
}
return
parseInt
(
value
)
/
8
;
};
var
calcBytePadding
=
function
(
type
,
expected
)
{
var
value
=
type
.
slice
(
expected
.
length
);
if
(
value
===
""
)
{
return
32
;
}
return
parseInt
(
value
);
};
var
calcRealPadding
=
function
(
type
,
expected
)
{
var
value
=
type
.
slice
(
expected
.
length
);
if
(
value
===
""
)
{
return
32
;
}
var
sizes
=
value
.
split
(
'x'
);
for
(
var
padding
=
0
,
i
=
0
;
i
<
sizes
;
i
++
)
{
padding
+=
(
sizes
[
i
]
/
8
);
}
return
padding
;
};
var
setupInputTypes
=
function
()
{
var
prefixedType
=
function
(
prefix
,
calcPadding
)
{
var
prefixedType
=
function
(
prefix
)
{
return
function
(
type
,
value
)
{
var
expected
=
prefix
;
if
(
type
.
indexOf
(
expected
)
!==
0
)
{
return
false
;
}
var
padding
=
calcPadding
(
type
,
expected
);
if
(
padding
>
32
)
return
false
;
// not allowed to be so big.
padding
=
32
;
// override as per the new ABI.
var
padding
=
32
;
// override as per the new ABI.
if
(
prefix
===
"string"
)
return
web3
.
fromAscii
(
value
,
padding
).
substr
(
2
);
...
...
@@ -111,13 +80,13 @@ var setupInputTypes = function () {
};
};
var
namedType
=
function
(
name
,
padding
,
formatter
)
{
var
namedType
=
function
(
name
,
formatter
)
{
return
function
(
type
,
value
)
{
if
(
type
!==
name
)
{
return
false
;
}
padding
=
32
;
//override as per the new ABI.
var
padding
=
32
;
//override as per the new ABI.
return
padLeft
(
formatter
?
formatter
(
value
)
:
value
,
padding
*
2
);
};
...
...
@@ -128,14 +97,14 @@ var setupInputTypes = function () {
};
return
[
prefixedType
(
'uint'
,
calcBitPadding
),
prefixedType
(
'int'
,
calcBitPadding
),
prefixedType
(
'hash'
,
calcBitPadding
),
prefixedType
(
'string'
,
calcBytePadding
),
prefixedType
(
'real'
,
calcRealPadding
),
prefixedType
(
'ureal'
,
calcRealPadding
),
namedType
(
'address'
,
20
),
namedType
(
'bool'
,
1
,
formatBool
),
prefixedType
(
'uint'
),
prefixedType
(
'int'
),
prefixedType
(
'hash'
),
prefixedType
(
'string'
),
prefixedType
(
'real'
),
prefixedType
(
'ureal'
),
namedType
(
'address'
),
namedType
(
'bool'
,
formatBool
),
];
};
...
...
@@ -166,24 +135,20 @@ var toAbiInput = function (json, methodName, params) {
var
setupOutputTypes
=
function
()
{
var
prefixedType
=
function
(
prefix
,
calcPadding
)
{
var
prefixedType
=
function
(
prefix
)
{
return
function
(
type
)
{
var
expected
=
prefix
;
if
(
type
.
indexOf
(
expected
)
!==
0
)
{
return
-
1
;
}
var
padding
=
calcPadding
(
type
,
expected
);
if
(
padding
>
32
)
return
-
1
;
// not allowed to be so big.
padding
=
32
;
// override as per the new ABI.
var
padding
=
32
;
// override as per the new ABI.
return
padding
*
2
;
};
};
var
namedType
=
function
(
name
,
padding
)
{
var
namedType
=
function
(
name
)
{
return
function
(
type
)
{
padding
=
32
;
// override as per the new ABI.
var
padding
=
32
;
// override as per the new ABI.
return
name
===
type
?
padding
*
2
:
-
1
;
};
};
...
...
@@ -205,14 +170,14 @@ var setupOutputTypes = function () {
};
return
[
{
padding
:
prefixedType
(
'uint'
,
calcBitPadding
),
format
:
formatInt
},
{
padding
:
prefixedType
(
'int'
,
calcBitPadding
),
format
:
formatInt
},
{
padding
:
prefixedType
(
'hash'
,
calcBitPadding
),
format
:
formatHash
},
{
padding
:
prefixedType
(
'string'
,
calcBytePadding
),
format
:
formatString
},
{
padding
:
prefixedType
(
'real'
,
calcRealPadding
),
format
:
formatInt
},
{
padding
:
prefixedType
(
'ureal'
,
calcRealPadding
),
format
:
formatInt
},
{
padding
:
namedType
(
'address'
,
20
)
},
{
padding
:
namedType
(
'bool'
,
1
),
format
:
formatBool
}
{
padding
:
prefixedType
(
'uint'
),
format
:
formatInt
},
{
padding
:
prefixedType
(
'int'
),
format
:
formatInt
},
{
padding
:
prefixedType
(
'hash'
),
format
:
formatHash
},
{
padding
:
prefixedType
(
'string'
),
format
:
formatString
},
{
padding
:
prefixedType
(
'real'
),
format
:
formatInt
},
{
padding
:
prefixedType
(
'ureal'
),
format
:
formatInt
},
{
padding
:
namedType
(
'address'
)
},
{
padding
:
namedType
(
'bool'
),
format
:
formatBool
}
];
};
...
...
dist/ethereum.js.map
View file @
7595a5df
This diff is collapsed.
Click to expand it.
dist/ethereum.min.js
View file @
7595a5df
This diff is collapsed.
Click to expand it.
lib/abi.js
View file @
7595a5df
...
...
@@ -54,47 +54,16 @@ var padLeft = function (string, chars) {
return
new
Array
(
chars
-
string
.
length
+
1
).
join
(
"0"
)
+
string
;
};
var
calcBitPadding
=
function
(
type
,
expected
)
{
var
value
=
type
.
slice
(
expected
.
length
);
if
(
value
===
""
)
{
return
32
;
}
return
parseInt
(
value
)
/
8
;
};
var
calcBytePadding
=
function
(
type
,
expected
)
{
var
value
=
type
.
slice
(
expected
.
length
);
if
(
value
===
""
)
{
return
32
;
}
return
parseInt
(
value
);
};
var
calcRealPadding
=
function
(
type
,
expected
)
{
var
value
=
type
.
slice
(
expected
.
length
);
if
(
value
===
""
)
{
return
32
;
}
var
sizes
=
value
.
split
(
'x'
);
for
(
var
padding
=
0
,
i
=
0
;
i
<
sizes
;
i
++
)
{
padding
+=
(
sizes
[
i
]
/
8
);
}
return
padding
;
};
var
setupInputTypes
=
function
()
{
var
prefixedType
=
function
(
prefix
,
calcPadding
)
{
var
prefixedType
=
function
(
prefix
)
{
return
function
(
type
,
value
)
{
var
expected
=
prefix
;
if
(
type
.
indexOf
(
expected
)
!==
0
)
{
return
false
;
}
var
padding
=
calcPadding
(
type
,
expected
);
if
(
padding
>
32
)
return
false
;
// not allowed to be so big.
padding
=
32
;
// override as per the new ABI.
var
padding
=
32
;
// override as per the new ABI.
if
(
prefix
===
"string"
)
return
web3
.
fromAscii
(
value
,
padding
).
substr
(
2
);
...
...
@@ -110,13 +79,13 @@ var setupInputTypes = function () {
};
};
var
namedType
=
function
(
name
,
padding
,
formatter
)
{
var
namedType
=
function
(
name
,
formatter
)
{
return
function
(
type
,
value
)
{
if
(
type
!==
name
)
{
return
false
;
}
padding
=
32
;
//override as per the new ABI.
var
padding
=
32
;
//override as per the new ABI.
return
padLeft
(
formatter
?
formatter
(
value
)
:
value
,
padding
*
2
);
};
...
...
@@ -127,14 +96,14 @@ var setupInputTypes = function () {
};
return
[
prefixedType
(
'uint'
,
calcBitPadding
),
prefixedType
(
'int'
,
calcBitPadding
),
prefixedType
(
'hash'
,
calcBitPadding
),
prefixedType
(
'string'
,
calcBytePadding
),
prefixedType
(
'real'
,
calcRealPadding
),
prefixedType
(
'ureal'
,
calcRealPadding
),
namedType
(
'address'
,
20
),
namedType
(
'bool'
,
1
,
formatBool
),
prefixedType
(
'uint'
),
prefixedType
(
'int'
),
prefixedType
(
'hash'
),
prefixedType
(
'string'
),
prefixedType
(
'real'
),
prefixedType
(
'ureal'
),
namedType
(
'address'
),
namedType
(
'bool'
,
formatBool
),
];
};
...
...
@@ -165,24 +134,20 @@ var toAbiInput = function (json, methodName, params) {
var
setupOutputTypes
=
function
()
{
var
prefixedType
=
function
(
prefix
,
calcPadding
)
{
var
prefixedType
=
function
(
prefix
)
{
return
function
(
type
)
{
var
expected
=
prefix
;
if
(
type
.
indexOf
(
expected
)
!==
0
)
{
return
-
1
;
}
var
padding
=
calcPadding
(
type
,
expected
);
if
(
padding
>
32
)
return
-
1
;
// not allowed to be so big.
padding
=
32
;
// override as per the new ABI.
var
padding
=
32
;
// override as per the new ABI.
return
padding
*
2
;
};
};
var
namedType
=
function
(
name
,
padding
)
{
var
namedType
=
function
(
name
)
{
return
function
(
type
)
{
padding
=
32
;
// override as per the new ABI.
var
padding
=
32
;
// override as per the new ABI.
return
name
===
type
?
padding
*
2
:
-
1
;
};
};
...
...
@@ -204,14 +169,14 @@ var setupOutputTypes = function () {
};
return
[
{
padding
:
prefixedType
(
'uint'
,
calcBitPadding
),
format
:
formatInt
},
{
padding
:
prefixedType
(
'int'
,
calcBitPadding
),
format
:
formatInt
},
{
padding
:
prefixedType
(
'hash'
,
calcBitPadding
),
format
:
formatHash
},
{
padding
:
prefixedType
(
'string'
,
calcBytePadding
),
format
:
formatString
},
{
padding
:
prefixedType
(
'real'
,
calcRealPadding
),
format
:
formatInt
},
{
padding
:
prefixedType
(
'ureal'
,
calcRealPadding
),
format
:
formatInt
},
{
padding
:
namedType
(
'address'
,
20
)
},
{
padding
:
namedType
(
'bool'
,
1
),
format
:
formatBool
}
{
padding
:
prefixedType
(
'uint'
),
format
:
formatInt
},
{
padding
:
prefixedType
(
'int'
),
format
:
formatInt
},
{
padding
:
prefixedType
(
'hash'
),
format
:
formatHash
},
{
padding
:
prefixedType
(
'string'
),
format
:
formatString
},
{
padding
:
prefixedType
(
'real'
),
format
:
formatInt
},
{
padding
:
prefixedType
(
'ureal'
),
format
:
formatInt
},
{
padding
:
namedType
(
'address'
)
},
{
padding
:
namedType
(
'bool'
),
format
:
formatBool
}
];
};
...
...
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