decoding of empty array, fixed #210, fixed #211

This commit is contained in:
Marek Kotewicz 2015-05-21 11:38:19 +02:00
parent 9abf38a349
commit d03bec658e
8 changed files with 15 additions and 13 deletions

6
dist/web3-light.js vendored
View File

@ -577,7 +577,7 @@ SolidityParam.prototype.combine = function (param) {
* @returns {Boolean}
*/
SolidityParam.prototype.isDynamic = function () {
return this.value.length > 64 || this.offset;
return this.value.length > 64 || this.offset !== undefined;
};
/**
@ -693,7 +693,7 @@ SolidityParam.decodeBytes = function (bytes, index) {
var offset = getOffset(bytes, index);
// 2 * , cause we also parse length
return new SolidityParam(bytes.substr(offset * 2, 2 * 64));
return new SolidityParam(bytes.substr(offset * 2, 2 * 64), 0);
};
/**
@ -708,7 +708,7 @@ SolidityParam.decodeArray = function (bytes, index) {
index = index || 0;
var offset = getOffset(bytes, index);
var length = parseInt('0x' + bytes.substr(offset * 2, 64));
return new SolidityParam(bytes.substr(offset * 2, (length + 1) * 64));
return new SolidityParam(bytes.substr(offset * 2, (length + 1) * 64), 0);
};
module.exports = SolidityParam;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

6
dist/web3.js vendored
View File

@ -577,7 +577,7 @@ SolidityParam.prototype.combine = function (param) {
* @returns {Boolean}
*/
SolidityParam.prototype.isDynamic = function () {
return this.value.length > 64 || this.offset;
return this.value.length > 64 || this.offset !== undefined;
};
/**
@ -693,7 +693,7 @@ SolidityParam.decodeBytes = function (bytes, index) {
var offset = getOffset(bytes, index);
// 2 * , cause we also parse length
return new SolidityParam(bytes.substr(offset * 2, 2 * 64));
return new SolidityParam(bytes.substr(offset * 2, 2 * 64), 0);
};
/**
@ -708,7 +708,7 @@ SolidityParam.decodeArray = function (bytes, index) {
index = index || 0;
var offset = getOffset(bytes, index);
var length = parseInt('0x' + bytes.substr(offset * 2, 64));
return new SolidityParam(bytes.substr(offset * 2, (length + 1) * 64));
return new SolidityParam(bytes.substr(offset * 2, (length + 1) * 64), 0);
};
module.exports = SolidityParam;

2
dist/web3.js.map vendored

File diff suppressed because one or more lines are too long

2
dist/web3.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -72,7 +72,7 @@ SolidityParam.prototype.combine = function (param) {
* @returns {Boolean}
*/
SolidityParam.prototype.isDynamic = function () {
return this.value.length > 64 || this.offset;
return this.value.length > 64 || this.offset !== undefined;
};
/**
@ -188,7 +188,7 @@ SolidityParam.decodeBytes = function (bytes, index) {
var offset = getOffset(bytes, index);
// 2 * , cause we also parse length
return new SolidityParam(bytes.substr(offset * 2, 2 * 64));
return new SolidityParam(bytes.substr(offset * 2, 2 * 64), 0);
};
/**
@ -203,7 +203,7 @@ SolidityParam.decodeArray = function (bytes, index) {
index = index || 0;
var offset = getOffset(bytes, index);
var length = parseInt('0x' + bytes.substr(offset * 2, 64));
return new SolidityParam(bytes.substr(offset * 2, (length + 1) * 64));
return new SolidityParam(bytes.substr(offset * 2, (length + 1) * 64), 0);
};
module.exports = SolidityParam;

View File

@ -24,6 +24,8 @@ describe('lib/solidity/coder', function () {
test({ type: 'bytes', expected: 'gavofyork', value: '0000000000000000000000000000000000000000000000000000000000000020' +
'0000000000000000000000000000000000000000000000000000000000000009' +
'6761766f66796f726b0000000000000000000000000000000000000000000000'});
test({ type: 'int[]', expected: [], value: '0000000000000000000000000000000000000000000000000000000000000020' +
'0000000000000000000000000000000000000000000000000000000000000000'});
test({ type: 'int[]', expected: [new bn(3)], value: '0000000000000000000000000000000000000000000000000000000000000020' +
'0000000000000000000000000000000000000000000000000000000000000001' +
'0000000000000000000000000000000000000000000000000000000000000003'});