mirror of
https://github.com/status-im/web3.js.git
synced 2025-02-23 19:48: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) {
|
||||
/*jshint maxcomplexity:7 */
|
||||
|
||||
if(val === null || typeof val === 'undefined')
|
||||
return val;
|
||||
|
||||
if (isBoolean(val))
|
||||
return fromDecimal(+val);
|
||||
|
||||
@ -2117,15 +2114,16 @@ SolidityEvent.prototype.encode = function (indexed, options) {
|
||||
return i.indexed === true;
|
||||
}).map(function (i) {
|
||||
var value = indexed[i.name];
|
||||
if (value !== undefined) {
|
||||
if (utils.isArray(value)) {
|
||||
return value.map(function (v) {
|
||||
return '0x' + coder.encodeParam(i.type, v);
|
||||
});
|
||||
}
|
||||
return '0x' + coder.encodeParam(i.type, value);
|
||||
if (value === undefined || value === null) {
|
||||
return null;
|
||||
}
|
||||
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);
|
||||
@ -2245,9 +2243,9 @@ var getOptions = function (options) {
|
||||
// make sure topics, get converted to hex
|
||||
options.topics = options.topics || [];
|
||||
options.topics = options.topics.map(function(topic) {
|
||||
if (topic === null) {
|
||||
if (topic === null || topic === undefined) {
|
||||
return null;
|
||||
} else if (utils.isArray) {
|
||||
} else if (utils.isArray(topic)) {
|
||||
topic = topic.map(utils.toHex);
|
||||
}
|
||||
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) {
|
||||
/*jshint maxcomplexity:7 */
|
||||
|
||||
if(val === null || typeof val === 'undefined')
|
||||
return val;
|
||||
|
||||
if (isBoolean(val))
|
||||
return fromDecimal(+val);
|
||||
|
||||
@ -2117,15 +2114,16 @@ SolidityEvent.prototype.encode = function (indexed, options) {
|
||||
return i.indexed === true;
|
||||
}).map(function (i) {
|
||||
var value = indexed[i.name];
|
||||
if (value !== undefined) {
|
||||
if (utils.isArray(value)) {
|
||||
return value.map(function (v) {
|
||||
return '0x' + coder.encodeParam(i.type, v);
|
||||
});
|
||||
}
|
||||
return '0x' + coder.encodeParam(i.type, value);
|
||||
if (value === undefined || value === null) {
|
||||
return null;
|
||||
}
|
||||
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);
|
||||
@ -2245,9 +2243,9 @@ var getOptions = function (options) {
|
||||
// make sure topics, get converted to hex
|
||||
options.topics = options.topics || [];
|
||||
options.topics = options.topics.map(function(topic) {
|
||||
if (topic === null) {
|
||||
if (topic === null || topic === undefined) {
|
||||
return null;
|
||||
} else if (utils.isArray) {
|
||||
} else if (utils.isArray(topic)) {
|
||||
topic = topic.map(utils.toHex);
|
||||
}
|
||||
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) {
|
||||
/*jshint maxcomplexity:7 */
|
||||
|
||||
if(val === null || typeof val === 'undefined')
|
||||
return val;
|
||||
|
||||
if (isBoolean(val))
|
||||
return fromDecimal(+val);
|
||||
|
||||
|
@ -98,15 +98,16 @@ SolidityEvent.prototype.encode = function (indexed, options) {
|
||||
return i.indexed === true;
|
||||
}).map(function (i) {
|
||||
var value = indexed[i.name];
|
||||
if (value !== undefined) {
|
||||
if (utils.isArray(value)) {
|
||||
return value.map(function (v) {
|
||||
return '0x' + coder.encodeParam(i.type, v);
|
||||
});
|
||||
}
|
||||
return '0x' + coder.encodeParam(i.type, value);
|
||||
if (value === undefined || value === null) {
|
||||
return null;
|
||||
}
|
||||
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);
|
||||
|
@ -42,7 +42,7 @@ var getOptions = function (options) {
|
||||
// make sure topics, get converted to hex
|
||||
options.topics = options.topics || [];
|
||||
options.topics = options.topics.map(function(topic) {
|
||||
if (topic === null) {
|
||||
if (topic === null || topic === undefined) {
|
||||
return null;
|
||||
} else if (utils.isArray(topic)) {
|
||||
topic = topic.map(utils.toHex);
|
||||
|
@ -75,7 +75,56 @@ var tests = [{
|
||||
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 () {
|
||||
|
@ -4,7 +4,6 @@ var BigNumber = require('bignumber.js');
|
||||
var assert = chai.assert;
|
||||
|
||||
var tests = [
|
||||
{ value: null, expected: null },
|
||||
{ value: 1, expected: '0x1' },
|
||||
{ value: '1', expected: '0x1' },
|
||||
{ value: '0x1', expected: '0x1'},
|
||||
|
Loading…
x
Reference in New Issue
Block a user