mirror of https://github.com/status-im/web3.js.git
Merge branch 'strings' of https://github.com/ethereum/ethereum.js into strings
Conflicts: dist/web3-light.js dist/web3-light.js.map dist/web3-light.min.js dist/web3.js dist/web3.js.map dist/web3.min.js
This commit is contained in:
commit
7dd44e7d60
|
@ -354,9 +354,9 @@ var formatInputBytes = function (value) {
|
||||||
* @returns {SolidityParam}
|
* @returns {SolidityParam}
|
||||||
*/
|
*/
|
||||||
var formatInputDynamicBytes = function (value) {
|
var formatInputDynamicBytes = function (value) {
|
||||||
var value = utils.toHex(value);
|
value = utils.toHex(value);
|
||||||
var result = utils.padRight((value).substr(2), 64);
|
var result = utils.padRight((value).substr(2), 64);
|
||||||
var length = (value.length / 2 - 1) | 0;
|
var length = Math.floor(value.length / 2 - 1);
|
||||||
return new SolidityParam(formatInputInt(length).value + result, 32);
|
return new SolidityParam(formatInputInt(length).value + result, 32);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1085,7 +1085,7 @@ var fromDecimal = function (value) {
|
||||||
* @return {String}
|
* @return {String}
|
||||||
*/
|
*/
|
||||||
var toHex = function (val) {
|
var toHex = function (val) {
|
||||||
/*jshint maxcomplexity:7 */
|
/*jshint maxcomplexity: 8 */
|
||||||
|
|
||||||
if (isBoolean(val))
|
if (isBoolean(val))
|
||||||
return fromDecimal(+val);
|
return fromDecimal(+val);
|
||||||
|
@ -1102,6 +1102,8 @@ var toHex = function (val) {
|
||||||
return fromDecimal(val);
|
return fromDecimal(val);
|
||||||
else if (!isFinite(val))
|
else if (!isFinite(val))
|
||||||
return fromAscii(val);
|
return fromAscii(val);
|
||||||
|
else if(val.indexOf('0x') === 0)
|
||||||
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
return fromDecimal(val);
|
return fromDecimal(val);
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -354,9 +354,9 @@ var formatInputBytes = function (value) {
|
||||||
* @returns {SolidityParam}
|
* @returns {SolidityParam}
|
||||||
*/
|
*/
|
||||||
var formatInputDynamicBytes = function (value) {
|
var formatInputDynamicBytes = function (value) {
|
||||||
var value = utils.toHex(value);
|
value = utils.toHex(value);
|
||||||
var result = utils.padRight((value).substr(2), 64);
|
var result = utils.padRight((value).substr(2), 64);
|
||||||
var length = (value.length / 2 - 1) | 0;
|
var length = Math.floor(value.length / 2 - 1);
|
||||||
return new SolidityParam(formatInputInt(length).value + result, 32);
|
return new SolidityParam(formatInputInt(length).value + result, 32);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1085,7 +1085,7 @@ var fromDecimal = function (value) {
|
||||||
* @return {String}
|
* @return {String}
|
||||||
*/
|
*/
|
||||||
var toHex = function (val) {
|
var toHex = function (val) {
|
||||||
/*jshint maxcomplexity:7 */
|
/*jshint maxcomplexity: 8 */
|
||||||
|
|
||||||
if (isBoolean(val))
|
if (isBoolean(val))
|
||||||
return fromDecimal(+val);
|
return fromDecimal(+val);
|
||||||
|
@ -1102,6 +1102,8 @@ var toHex = function (val) {
|
||||||
return fromDecimal(val);
|
return fromDecimal(val);
|
||||||
else if (!isFinite(val))
|
else if (!isFinite(val))
|
||||||
return fromAscii(val);
|
return fromAscii(val);
|
||||||
|
else if(val.indexOf('0x') === 0)
|
||||||
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
return fromDecimal(val);
|
return fromDecimal(val);
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -62,9 +62,9 @@ var formatInputBytes = function (value) {
|
||||||
* @returns {SolidityParam}
|
* @returns {SolidityParam}
|
||||||
*/
|
*/
|
||||||
var formatInputDynamicBytes = function (value) {
|
var formatInputDynamicBytes = function (value) {
|
||||||
var value = utils.toHex(value);
|
value = utils.toHex(value);
|
||||||
var result = utils.padRight((value).substr(2), 64);
|
var result = utils.padRight((value).substr(2), 64);
|
||||||
var length = (value.length / 2 - 1) | 0;
|
var length = Math.floor(value.length / 2 - 1);
|
||||||
return new SolidityParam(formatInputInt(length).value + result, 32);
|
return new SolidityParam(formatInputInt(length).value + result, 32);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -213,7 +213,7 @@ var fromDecimal = function (value) {
|
||||||
* @return {String}
|
* @return {String}
|
||||||
*/
|
*/
|
||||||
var toHex = function (val) {
|
var toHex = function (val) {
|
||||||
/*jshint maxcomplexity:7 */
|
/*jshint maxcomplexity: 8 */
|
||||||
|
|
||||||
if (isBoolean(val))
|
if (isBoolean(val))
|
||||||
return fromDecimal(+val);
|
return fromDecimal(+val);
|
||||||
|
@ -230,6 +230,8 @@ var toHex = function (val) {
|
||||||
return fromDecimal(val);
|
return fromDecimal(val);
|
||||||
else if (!isFinite(val))
|
else if (!isFinite(val))
|
||||||
return fromAscii(val);
|
return fromAscii(val);
|
||||||
|
else if(val.indexOf('0x') === 0)
|
||||||
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
return fromDecimal(val);
|
return fromDecimal(val);
|
||||||
|
|
|
@ -20,6 +20,10 @@ describe('lib/solidity/coder', function () {
|
||||||
test({ type: 'int256', expected: new bn(1), value: '0000000000000000000000000000000000000000000000000000000000000001'});
|
test({ type: 'int256', expected: new bn(1), value: '0000000000000000000000000000000000000000000000000000000000000001'});
|
||||||
test({ type: 'int256', expected: new bn(16), value: '0000000000000000000000000000000000000000000000000000000000000010'});
|
test({ type: 'int256', expected: new bn(16), value: '0000000000000000000000000000000000000000000000000000000000000010'});
|
||||||
test({ type: 'int256', expected: new bn(-1), value: 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'});
|
test({ type: 'int256', expected: new bn(-1), value: 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'});
|
||||||
|
test({ type: 'int8', expected: new bn(16), value: '0000000000000000000000000000000000000000000000000000000000000010'});
|
||||||
|
test({ type: 'int32', expected: new bn(16), value: '0000000000000000000000000000000000000000000000000000000000000010'});
|
||||||
|
test({ type: 'int64', expected: new bn(16), value: '0000000000000000000000000000000000000000000000000000000000000010'});
|
||||||
|
test({ type: 'int128', expected: new bn(16), value: '0000000000000000000000000000000000000000000000000000000000000010'});
|
||||||
test({ type: 'bytes32', expected: '0x6761766f66796f726b0000000000000000000000000000000000000000000000',
|
test({ type: 'bytes32', expected: '0x6761766f66796f726b0000000000000000000000000000000000000000000000',
|
||||||
value: '6761766f66796f726b0000000000000000000000000000000000000000000000'});
|
value: '6761766f66796f726b0000000000000000000000000000000000000000000000'});
|
||||||
test({ type: 'bytes', expected: '0x6761766f66796f726b',
|
test({ type: 'bytes', expected: '0x6761766f66796f726b',
|
||||||
|
|
|
@ -24,6 +24,8 @@ describe('lib/solidity/coder', function () {
|
||||||
expected: '6761766f66796f726b0000000000000000000000000000000000000000000000'});
|
expected: '6761766f66796f726b0000000000000000000000000000000000000000000000'});
|
||||||
test({ type: 'bytes32', value: '0x731a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b',
|
test({ type: 'bytes32', value: '0x731a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b',
|
||||||
expected: '731a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b'});
|
expected: '731a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b'});
|
||||||
|
test({ type: 'bytes32', value: '0x02838654a83c213dae3698391eabbd54a5b6e1fb3452bc7fa4ea0dd5c8ce7e29',
|
||||||
|
expected: '02838654a83c213dae3698391eabbd54a5b6e1fb3452bc7fa4ea0dd5c8ce7e29'});
|
||||||
test({ type: 'bytes', value: '0x6761766f66796f726b',
|
test({ type: 'bytes', value: '0x6761766f66796f726b',
|
||||||
expected: '0000000000000000000000000000000000000000000000000000000000000020' +
|
expected: '0000000000000000000000000000000000000000000000000000000000000020' +
|
||||||
'0000000000000000000000000000000000000000000000000000000000000009' +
|
'0000000000000000000000000000000000000000000000000000000000000009' +
|
||||||
|
|
|
@ -14,6 +14,7 @@ var tests = [
|
||||||
{ value: '-0x1', expected: '-0x1'},
|
{ value: '-0x1', expected: '-0x1'},
|
||||||
{ value: '-15', expected: '-0xf'},
|
{ value: '-15', expected: '-0xf'},
|
||||||
{ value: '-0xf', expected: '-0xf'},
|
{ value: '-0xf', expected: '-0xf'},
|
||||||
|
{ value: '0x657468657265756d', expected: '0x657468657265756d'},
|
||||||
{ value: '0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd', expected: '0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd'},
|
{ value: '0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd', expected: '0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd'},
|
||||||
{ value: '-0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', expected: '-0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'},
|
{ value: '-0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', expected: '-0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'},
|
||||||
{ value: '-0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd', expected: '-0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd'},
|
{ value: '-0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd', expected: '-0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd'},
|
||||||
|
|
Loading…
Reference in New Issue