mirror of
https://github.com/status-im/web3.js.git
synced 2025-02-24 03:58:13 +00:00
fixed filters encoding null
This commit is contained in:
parent
4482d5bf00
commit
5f2eb3308f
24
dist/web3-light.js
vendored
24
dist/web3-light.js
vendored
@ -1110,9 +1110,6 @@ var fromDecimal = function (value) {
|
|||||||
var toHex = function (val) {
|
var toHex = function (val) {
|
||||||
/*jshint maxcomplexity:7 */
|
/*jshint maxcomplexity:7 */
|
||||||
|
|
||||||
if(val === null || typeof val === 'undefined')
|
|
||||||
return val;
|
|
||||||
|
|
||||||
if (isBoolean(val))
|
if (isBoolean(val))
|
||||||
return fromDecimal(+val);
|
return fromDecimal(+val);
|
||||||
|
|
||||||
@ -2117,15 +2114,16 @@ SolidityEvent.prototype.encode = function (indexed, options) {
|
|||||||
return i.indexed === true;
|
return i.indexed === true;
|
||||||
}).map(function (i) {
|
}).map(function (i) {
|
||||||
var value = indexed[i.name];
|
var value = indexed[i.name];
|
||||||
if (value !== undefined) {
|
if (value === undefined || value === null) {
|
||||||
if (utils.isArray(value)) {
|
return null;
|
||||||
return value.map(function (v) {
|
|
||||||
return '0x' + coder.encodeParam(i.type, v);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return '0x' + coder.encodeParam(i.type, value);
|
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
|
if (utils.isArray(value)) {
|
||||||
|
return value.map(function (v) {
|
||||||
|
return '0x' + coder.encodeParam(i.type, v);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return '0x' + coder.encodeParam(i.type, value);
|
||||||
});
|
});
|
||||||
|
|
||||||
options.topics = options.topics.concat(indexedTopics);
|
options.topics = options.topics.concat(indexedTopics);
|
||||||
@ -2245,9 +2243,9 @@ var getOptions = function (options) {
|
|||||||
// make sure topics, get converted to hex
|
// make sure topics, get converted to hex
|
||||||
options.topics = options.topics || [];
|
options.topics = options.topics || [];
|
||||||
options.topics = options.topics.map(function(topic) {
|
options.topics = options.topics.map(function(topic) {
|
||||||
if (topic === null) {
|
if (topic === null || topic === undefined) {
|
||||||
return null;
|
return null;
|
||||||
} else if (utils.isArray) {
|
} else if (utils.isArray(topic)) {
|
||||||
topic = topic.map(utils.toHex);
|
topic = topic.map(utils.toHex);
|
||||||
}
|
}
|
||||||
return utils.toHex(topic);
|
return utils.toHex(topic);
|
||||||
|
8
dist/web3-light.js.map
vendored
8
dist/web3-light.js.map
vendored
File diff suppressed because one or more lines are too long
5
dist/web3-light.min.js
vendored
5
dist/web3-light.min.js
vendored
File diff suppressed because one or more lines are too long
24
dist/web3.js
vendored
24
dist/web3.js
vendored
@ -1110,9 +1110,6 @@ var fromDecimal = function (value) {
|
|||||||
var toHex = function (val) {
|
var toHex = function (val) {
|
||||||
/*jshint maxcomplexity:7 */
|
/*jshint maxcomplexity:7 */
|
||||||
|
|
||||||
if(val === null || typeof val === 'undefined')
|
|
||||||
return val;
|
|
||||||
|
|
||||||
if (isBoolean(val))
|
if (isBoolean(val))
|
||||||
return fromDecimal(+val);
|
return fromDecimal(+val);
|
||||||
|
|
||||||
@ -2117,15 +2114,16 @@ SolidityEvent.prototype.encode = function (indexed, options) {
|
|||||||
return i.indexed === true;
|
return i.indexed === true;
|
||||||
}).map(function (i) {
|
}).map(function (i) {
|
||||||
var value = indexed[i.name];
|
var value = indexed[i.name];
|
||||||
if (value !== undefined) {
|
if (value === undefined || value === null) {
|
||||||
if (utils.isArray(value)) {
|
return null;
|
||||||
return value.map(function (v) {
|
|
||||||
return '0x' + coder.encodeParam(i.type, v);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return '0x' + coder.encodeParam(i.type, value);
|
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
|
if (utils.isArray(value)) {
|
||||||
|
return value.map(function (v) {
|
||||||
|
return '0x' + coder.encodeParam(i.type, v);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return '0x' + coder.encodeParam(i.type, value);
|
||||||
});
|
});
|
||||||
|
|
||||||
options.topics = options.topics.concat(indexedTopics);
|
options.topics = options.topics.concat(indexedTopics);
|
||||||
@ -2245,9 +2243,9 @@ var getOptions = function (options) {
|
|||||||
// make sure topics, get converted to hex
|
// make sure topics, get converted to hex
|
||||||
options.topics = options.topics || [];
|
options.topics = options.topics || [];
|
||||||
options.topics = options.topics.map(function(topic) {
|
options.topics = options.topics.map(function(topic) {
|
||||||
if (topic === null) {
|
if (topic === null || topic === undefined) {
|
||||||
return null;
|
return null;
|
||||||
} else if (utils.isArray) {
|
} else if (utils.isArray(topic)) {
|
||||||
topic = topic.map(utils.toHex);
|
topic = topic.map(utils.toHex);
|
||||||
}
|
}
|
||||||
return utils.toHex(topic);
|
return utils.toHex(topic);
|
||||||
|
8
dist/web3.js.map
vendored
8
dist/web3.js.map
vendored
File diff suppressed because one or more lines are too long
4
dist/web3.min.js
vendored
4
dist/web3.min.js
vendored
File diff suppressed because one or more lines are too long
@ -214,9 +214,6 @@ var fromDecimal = function (value) {
|
|||||||
var toHex = function (val) {
|
var toHex = function (val) {
|
||||||
/*jshint maxcomplexity:7 */
|
/*jshint maxcomplexity:7 */
|
||||||
|
|
||||||
if(val === null || typeof val === 'undefined')
|
|
||||||
return val;
|
|
||||||
|
|
||||||
if (isBoolean(val))
|
if (isBoolean(val))
|
||||||
return fromDecimal(+val);
|
return fromDecimal(+val);
|
||||||
|
|
||||||
|
@ -98,15 +98,16 @@ SolidityEvent.prototype.encode = function (indexed, options) {
|
|||||||
return i.indexed === true;
|
return i.indexed === true;
|
||||||
}).map(function (i) {
|
}).map(function (i) {
|
||||||
var value = indexed[i.name];
|
var value = indexed[i.name];
|
||||||
if (value !== undefined) {
|
if (value === undefined || value === null) {
|
||||||
if (utils.isArray(value)) {
|
return null;
|
||||||
return value.map(function (v) {
|
|
||||||
return '0x' + coder.encodeParam(i.type, v);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return '0x' + coder.encodeParam(i.type, value);
|
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
|
if (utils.isArray(value)) {
|
||||||
|
return value.map(function (v) {
|
||||||
|
return '0x' + coder.encodeParam(i.type, v);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return '0x' + coder.encodeParam(i.type, value);
|
||||||
});
|
});
|
||||||
|
|
||||||
options.topics = options.topics.concat(indexedTopics);
|
options.topics = options.topics.concat(indexedTopics);
|
||||||
|
@ -42,7 +42,7 @@ var getOptions = function (options) {
|
|||||||
// make sure topics, get converted to hex
|
// make sure topics, get converted to hex
|
||||||
options.topics = options.topics || [];
|
options.topics = options.topics || [];
|
||||||
options.topics = options.topics.map(function(topic) {
|
options.topics = options.topics.map(function(topic) {
|
||||||
if (topic === null) {
|
if (topic === null || topic === undefined) {
|
||||||
return null;
|
return null;
|
||||||
} else if (utils.isArray(topic)) {
|
} else if (utils.isArray(topic)) {
|
||||||
topic = topic.map(utils.toHex);
|
topic = topic.map(utils.toHex);
|
||||||
|
@ -75,7 +75,56 @@ var tests = [{
|
|||||||
null // d
|
null // d
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
}, {
|
||||||
|
abi: {
|
||||||
|
name: 'event1',
|
||||||
|
inputs: [{
|
||||||
|
type: 'int',
|
||||||
|
name: 'a',
|
||||||
|
indexed: true
|
||||||
|
}, {
|
||||||
|
type: 'int',
|
||||||
|
name: 'b',
|
||||||
|
indexed: true
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
address: '0x1234567890123456789012345678901234567890',
|
||||||
|
signature: 'ffff',
|
||||||
|
indexed: {
|
||||||
|
a: [16, 1],
|
||||||
|
b: 2
|
||||||
|
},
|
||||||
|
options: {},
|
||||||
|
expected: {
|
||||||
|
address: '0x1234567890123456789012345678901234567890',
|
||||||
|
topics: [
|
||||||
|
'0xffff',
|
||||||
|
['0x0000000000000000000000000000000000000000000000000000000000000010', '0x0000000000000000000000000000000000000000000000000000000000000001'],
|
||||||
|
'0x0000000000000000000000000000000000000000000000000000000000000002'
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
abi: {
|
||||||
|
name: 'event1',
|
||||||
|
inputs: [{
|
||||||
|
type: 'int',
|
||||||
|
name: 'a',
|
||||||
|
indexed: true
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
address: '0x1234567890123456789012345678901234567890',
|
||||||
|
signature: 'ffff',
|
||||||
|
indexed: {
|
||||||
|
a: null
|
||||||
|
},
|
||||||
|
options: {},
|
||||||
|
expected: {
|
||||||
|
address: '0x1234567890123456789012345678901234567890',
|
||||||
|
topics: [
|
||||||
|
'0xffff',
|
||||||
|
null
|
||||||
|
]
|
||||||
|
}
|
||||||
}];
|
}];
|
||||||
|
|
||||||
describe('lib/web3/event', function () {
|
describe('lib/web3/event', function () {
|
||||||
|
@ -4,7 +4,6 @@ var BigNumber = require('bignumber.js');
|
|||||||
var assert = chai.assert;
|
var assert = chai.assert;
|
||||||
|
|
||||||
var tests = [
|
var tests = [
|
||||||
{ value: null, expected: null },
|
|
||||||
{ value: 1, expected: '0x1' },
|
{ value: 1, expected: '0x1' },
|
||||||
{ value: '1', expected: '0x1' },
|
{ value: '1', expected: '0x1' },
|
||||||
{ value: '0x1', expected: '0x1'},
|
{ value: '0x1', expected: '0x1'},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user