Auto-generated commits, too.
This commit is contained in:
parent
e95bb34ea0
commit
b6c0e53d69
|
@ -85,6 +85,18 @@ var calcRealPadding = function (type, expected) {
|
||||||
|
|
||||||
var setupInputTypes = function () {
|
var setupInputTypes = function () {
|
||||||
|
|
||||||
|
// convert from int, decimal-string, prefixed hex string whatever into a bare hex string.
|
||||||
|
var formatStandard = function (value) {
|
||||||
|
if (typeof value === "number")
|
||||||
|
return value.toString(16);
|
||||||
|
else if (typeof value === "string" && value.indexOf('0x') === 0)
|
||||||
|
return value.substr(2);
|
||||||
|
else if (typeof value === "string")
|
||||||
|
return web3.toHex(value);
|
||||||
|
else
|
||||||
|
return (+value).toString(16);
|
||||||
|
};
|
||||||
|
|
||||||
var prefixedType = function (prefix, calcPadding) {
|
var prefixedType = function (prefix, calcPadding) {
|
||||||
return function (type, value) {
|
return function (type, value) {
|
||||||
var expected = prefix;
|
var expected = prefix;
|
||||||
|
@ -99,15 +111,7 @@ var setupInputTypes = function () {
|
||||||
|
|
||||||
if (prefix === "string")
|
if (prefix === "string")
|
||||||
return web3.fromAscii(value, padding).substr(2);
|
return web3.fromAscii(value, padding).substr(2);
|
||||||
if (typeof value === "number")
|
return padLeft(formatStandard(value), padding * 2);
|
||||||
value = value.toString(16);
|
|
||||||
else if (typeof value === "string")
|
|
||||||
value = web3.toHex(value);
|
|
||||||
else if (value.indexOf('0x') === 0)
|
|
||||||
value = value.substr(2);
|
|
||||||
else
|
|
||||||
value = (+value).toString(16);
|
|
||||||
return padLeft(value, padding * 2);
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -124,7 +128,7 @@ var setupInputTypes = function () {
|
||||||
};
|
};
|
||||||
|
|
||||||
var formatBool = function (value) {
|
var formatBool = function (value) {
|
||||||
return value ? '0x1' : '0x0';
|
return value ? '01' : '00';
|
||||||
};
|
};
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
@ -134,7 +138,7 @@ var setupInputTypes = function () {
|
||||||
prefixedType('string', calcBytePadding),
|
prefixedType('string', calcBytePadding),
|
||||||
prefixedType('real', calcRealPadding),
|
prefixedType('real', calcRealPadding),
|
||||||
prefixedType('ureal', calcRealPadding),
|
prefixedType('ureal', calcRealPadding),
|
||||||
namedType('address', 20),
|
namedType('address', 20, formatStandard),
|
||||||
namedType('bool', 1, formatBool),
|
namedType('bool', 1, formatBool),
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue