mirror of https://github.com/status-im/web3.js.git
encoding fixed size variables > 32 bytes"
This commit is contained in:
parent
e3a8734914
commit
3e66cca699
|
@ -36,9 +36,8 @@ var SolidityParam = require('./param');
|
|||
* @returns {SolidityParam}
|
||||
*/
|
||||
var formatInputInt = function (value) {
|
||||
var padding = c.ETH_PADDING * 2;
|
||||
BigNumber.config(c.ETH_BIGNUMBER_ROUNDING_MODE);
|
||||
var result = utils.padLeft(utils.toTwosComplement(value).round().toString(16), padding);
|
||||
var result = utils.padLeft(utils.toTwosComplement(value).round().toString(16), 64);
|
||||
return new SolidityParam(result);
|
||||
};
|
||||
|
||||
|
@ -50,7 +49,9 @@ var formatInputInt = function (value) {
|
|||
* @returns {SolidityParam}
|
||||
*/
|
||||
var formatInputBytes = function (value) {
|
||||
var result = utils.padRight(utils.toHex(value).substr(2), 64);
|
||||
var result = utils.toHex(value).substr(2);
|
||||
var l = Math.floor((result.length + 63) / 64);
|
||||
result = utils.padRight(result, l * 64);
|
||||
return new SolidityParam(result);
|
||||
};
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ SolidityParam.prototype.combine = function (param) {
|
|||
* @returns {Boolean}
|
||||
*/
|
||||
SolidityParam.prototype.isDynamic = function () {
|
||||
return this.value.length > 64 || this.offset !== undefined;
|
||||
return this.offset !== undefined;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -43,6 +43,10 @@ describe('lib/solidity/coder', function () {
|
|||
'c3a40000c3a40000000000000000000000000000000000000000000000000000'});
|
||||
test({ type: 'bytes32', value: '0xc3a40000c3a4',
|
||||
expected: 'c3a40000c3a40000000000000000000000000000000000000000000000000000'});
|
||||
test({ type: 'bytes64', value: '0xc3a40000c3a40000000000000000000000000000000000000000000000000000' +
|
||||
'c3a40000c3a40000000000000000000000000000000000000000000000000000',
|
||||
expected: 'c3a40000c3a40000000000000000000000000000000000000000000000000000' +
|
||||
'c3a40000c3a40000000000000000000000000000000000000000000000000000'});
|
||||
test({ type: 'string', value: 'ää',
|
||||
expected: '0000000000000000000000000000000000000000000000000000000000000020' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000008' +
|
||||
|
|
Loading…
Reference in New Issue