mirror of
https://github.com/status-im/web3.js.git
synced 2025-02-23 11:38:12 +00:00
proper formatting event options
This commit is contained in:
parent
93b323f176
commit
b5eabd875f
18
dist/web3-light.js
vendored
18
dist/web3-light.js
vendored
@ -1334,7 +1334,6 @@ var isJson = function (str) {
|
||||
|
||||
module.exports = {
|
||||
padLeft: padLeft,
|
||||
findIndex: findIndex,
|
||||
toHex: toHex,
|
||||
toDecimal: toDecimal,
|
||||
fromDecimal: fromDecimal,
|
||||
@ -2079,10 +2078,17 @@ SolidityEvent.prototype.signature = function () {
|
||||
SolidityEvent.prototype.encode = function (indexed, options) {
|
||||
indexed = indexed || {};
|
||||
options = options || {};
|
||||
var result = {};
|
||||
|
||||
options.address = this._address;
|
||||
options.topics = options.topics || [];
|
||||
options.topics.push('0x' + this.signature());
|
||||
['fromBlock', 'toBlock'].filter(function (f) {
|
||||
return options[f] !== undefined;
|
||||
}).forEach(function (f) {
|
||||
result[f] = utils.toHex(options[f]);
|
||||
});
|
||||
|
||||
result.address = this._address;
|
||||
result.topics = [];
|
||||
result.topics.push('0x' + this.signature());
|
||||
|
||||
var indexedTopics = this._params.filter(function (i) {
|
||||
return i.indexed === true;
|
||||
@ -2100,9 +2106,9 @@ SolidityEvent.prototype.encode = function (indexed, options) {
|
||||
return '0x' + coder.encodeParam(i.type, value);
|
||||
});
|
||||
|
||||
options.topics = options.topics.concat(indexedTopics);
|
||||
result.topics = result.topics.concat(indexedTopics);
|
||||
|
||||
return options;
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
|
6
dist/web3-light.js.map
vendored
6
dist/web3-light.js.map
vendored
File diff suppressed because one or more lines are too long
4
dist/web3-light.min.js
vendored
4
dist/web3-light.min.js
vendored
File diff suppressed because one or more lines are too long
18
dist/web3.js
vendored
18
dist/web3.js
vendored
@ -1334,7 +1334,6 @@ var isJson = function (str) {
|
||||
|
||||
module.exports = {
|
||||
padLeft: padLeft,
|
||||
findIndex: findIndex,
|
||||
toHex: toHex,
|
||||
toDecimal: toDecimal,
|
||||
fromDecimal: fromDecimal,
|
||||
@ -2079,10 +2078,17 @@ SolidityEvent.prototype.signature = function () {
|
||||
SolidityEvent.prototype.encode = function (indexed, options) {
|
||||
indexed = indexed || {};
|
||||
options = options || {};
|
||||
var result = {};
|
||||
|
||||
options.address = this._address;
|
||||
options.topics = options.topics || [];
|
||||
options.topics.push('0x' + this.signature());
|
||||
['fromBlock', 'toBlock'].filter(function (f) {
|
||||
return options[f] !== undefined;
|
||||
}).forEach(function (f) {
|
||||
result[f] = utils.toHex(options[f]);
|
||||
});
|
||||
|
||||
result.address = this._address;
|
||||
result.topics = [];
|
||||
result.topics.push('0x' + this.signature());
|
||||
|
||||
var indexedTopics = this._params.filter(function (i) {
|
||||
return i.indexed === true;
|
||||
@ -2100,9 +2106,9 @@ SolidityEvent.prototype.encode = function (indexed, options) {
|
||||
return '0x' + coder.encodeParam(i.type, value);
|
||||
});
|
||||
|
||||
options.topics = options.topics.concat(indexedTopics);
|
||||
result.topics = result.topics.concat(indexedTopics);
|
||||
|
||||
return options;
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
|
6
dist/web3.js.map
vendored
6
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
@ -89,10 +89,17 @@ SolidityEvent.prototype.signature = function () {
|
||||
SolidityEvent.prototype.encode = function (indexed, options) {
|
||||
indexed = indexed || {};
|
||||
options = options || {};
|
||||
var result = {};
|
||||
|
||||
options.address = this._address;
|
||||
options.topics = options.topics || [];
|
||||
options.topics.push('0x' + this.signature());
|
||||
['fromBlock', 'toBlock'].filter(function (f) {
|
||||
return options[f] !== undefined;
|
||||
}).forEach(function (f) {
|
||||
result[f] = utils.toHex(options[f]);
|
||||
});
|
||||
|
||||
result.address = this._address;
|
||||
result.topics = [];
|
||||
result.topics.push('0x' + this.signature());
|
||||
|
||||
var indexedTopics = this._params.filter(function (i) {
|
||||
return i.indexed === true;
|
||||
@ -110,9 +117,9 @@ SolidityEvent.prototype.encode = function (indexed, options) {
|
||||
return '0x' + coder.encodeParam(i.type, value);
|
||||
});
|
||||
|
||||
options.topics = options.topics.concat(indexedTopics);
|
||||
result.topics = result.topics.concat(indexedTopics);
|
||||
|
||||
return options;
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -118,6 +118,31 @@ var tests = [{
|
||||
null
|
||||
]
|
||||
}
|
||||
}, {
|
||||
abi: {
|
||||
name: 'event1',
|
||||
inputs: [{
|
||||
type: 'int',
|
||||
name: 'a',
|
||||
indexed: true
|
||||
}]
|
||||
},
|
||||
indexed: {
|
||||
a: 1
|
||||
},
|
||||
options: {
|
||||
fromBlock: 4,
|
||||
toBlock: 10
|
||||
},
|
||||
expected: {
|
||||
address: address,
|
||||
fromBlock: '0x4',
|
||||
toBlock: '0xa',
|
||||
topics: [
|
||||
signature,
|
||||
'0x0000000000000000000000000000000000000000000000000000000000000001'
|
||||
]
|
||||
}
|
||||
}];
|
||||
|
||||
describe('lib/web3/event', function () {
|
||||
|
Loading…
x
Reference in New Issue
Block a user