mirror of https://github.com/status-im/web3.js.git
changed topic to topics
This commit is contained in:
parent
8d7d00ded9
commit
1c9f50feb9
|
@ -136,7 +136,7 @@ var addEventRelatedPropertiesToContract = function (contract, desc, address) {
|
|||
return parser(data);
|
||||
};
|
||||
|
||||
Object.defineProperty(contract, 'topic', {
|
||||
Object.defineProperty(contract, 'topics', {
|
||||
get: function() {
|
||||
return utils.filterEvents(desc).map(function (e) {
|
||||
return signature.eventSignatureFromAscii(e.name);
|
||||
|
|
|
@ -67,10 +67,10 @@ var inputParser = function (address, sign, event) {
|
|||
return function (indexed, options) {
|
||||
var o = options || {};
|
||||
o.address = address;
|
||||
o.topic = [];
|
||||
o.topic.push(sign);
|
||||
o.topics = [];
|
||||
o.topics.push(sign);
|
||||
if (indexed) {
|
||||
o.topic = o.topic.concat(indexedParamsToTopics(event, indexed));
|
||||
o.topics = o.topics.concat(indexedParamsToTopics(event, indexed));
|
||||
}
|
||||
return o;
|
||||
};
|
||||
|
@ -102,12 +102,12 @@ var outputParser = function (event) {
|
|||
};
|
||||
|
||||
output.topics = output.topic; // fallback for go-ethereum
|
||||
if (!output.topic) {
|
||||
if (!output.topics) {
|
||||
return result;
|
||||
}
|
||||
|
||||
var indexedOutputs = filterInputs(event.inputs, true);
|
||||
var indexedData = "0x" + output.topic.slice(1, output.topic.length).map(function (topic) { return topic.slice(2); }).join("");
|
||||
var indexedData = "0x" + output.topics.slice(1, output.topics.length).map(function (topics) { return topics.slice(2); }).join("");
|
||||
var indexedRes = abi.formatOutput(indexedOutputs, indexedData);
|
||||
|
||||
var notIndexedOutputs = filterInputs(event.inputs, false);
|
||||
|
@ -122,7 +122,7 @@ var outputParser = function (event) {
|
|||
var getMatchingEvent = function (events, payload) {
|
||||
for (var i = 0; i < events.length; i++) {
|
||||
var sign = signature.eventSignatureFromAscii(events[i].name);
|
||||
if (sign === payload.topic[0]) {
|
||||
if (sign === payload.topics[0]) {
|
||||
return events[i];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -145,12 +145,12 @@ var inputPostFormatter = function(post){
|
|||
post.ttl = utils.fromDecimal(post.ttl);
|
||||
post.workToProve = utils.fromDecimal(post.workToProve);
|
||||
|
||||
if(!(post.topic instanceof Array))
|
||||
post.topic = [post.topic];
|
||||
if(!(post.topics instanceof Array))
|
||||
post.topics = [post.topics];
|
||||
|
||||
|
||||
// format the following options
|
||||
post.topic = post.topic.map(function(topic){
|
||||
post.topics = post.topics.map(function(topic){
|
||||
return utils.fromAscii(topic);
|
||||
});
|
||||
|
||||
|
@ -179,7 +179,7 @@ var outputPostFormatter = function(post){
|
|||
}
|
||||
|
||||
// format the following options
|
||||
post.topic = post.topic.map(function(topic){
|
||||
post.topics = post.topics.map(function(topic){
|
||||
return utils.toAscii(topic);
|
||||
});
|
||||
|
||||
|
|
|
@ -20,8 +20,8 @@ describe('event', function () {
|
|||
|
||||
// then
|
||||
assert.equal(result.address, address);
|
||||
assert.equal(result.topic.length, 1);
|
||||
assert.equal(result.topic[0], signature);
|
||||
assert.equal(result.topics.length, 1);
|
||||
assert.equal(result.topics[0], signature);
|
||||
|
||||
});
|
||||
|
||||
|
@ -47,8 +47,8 @@ describe('event', function () {
|
|||
|
||||
// then
|
||||
assert.equal(result.address, address);
|
||||
assert.equal(result.topic.length, 1);
|
||||
assert.equal(result.topic[0], signature);
|
||||
assert.equal(result.topics.length, 1);
|
||||
assert.equal(result.topics[0], signature);
|
||||
assert.equal(result.fromBlock, options.fromBlock);
|
||||
assert.equal(result.toBlock, options.toBlock);
|
||||
assert.equal(result.offset, options.offset);
|
||||
|
@ -78,9 +78,9 @@ describe('event', function () {
|
|||
|
||||
// then
|
||||
assert.equal(result.address, address);
|
||||
assert.equal(result.topic.length, 2);
|
||||
assert.equal(result.topic[0], signature);
|
||||
assert.equal(result.topic[1], f.formatInputInt(4));
|
||||
assert.equal(result.topics.length, 2);
|
||||
assert.equal(result.topics[0], signature);
|
||||
assert.equal(result.topics[1], f.formatInputInt(4));
|
||||
assert.equal(result.fromBlock, options.fromBlock);
|
||||
assert.equal(result.toBlock, options.toBlock);
|
||||
assert.equal(result.offset, options.offset);
|
||||
|
@ -110,10 +110,10 @@ describe('event', function () {
|
|||
|
||||
// then
|
||||
assert.equal(result.address, address);
|
||||
assert.equal(result.topic.length, 2);
|
||||
assert.equal(result.topic[0], signature);
|
||||
assert.equal(result.topic[1][0], f.formatInputInt(4));
|
||||
assert.equal(result.topic[1][1], f.formatInputInt(69));
|
||||
assert.equal(result.topics.length, 2);
|
||||
assert.equal(result.topics[0], signature);
|
||||
assert.equal(result.topics[1][0], f.formatInputInt(4));
|
||||
assert.equal(result.topics[1][1], f.formatInputInt(69));
|
||||
assert.equal(result.earliest, options.earliest);
|
||||
assert.equal(result.latest, options.latest);
|
||||
assert.equal(result.offset, options.offset);
|
||||
|
|
|
@ -13,14 +13,14 @@ describe('formatters', function () {
|
|||
payload: {test: 'test'},
|
||||
ttl: 200,
|
||||
workToProve: 1000,
|
||||
topic: ['hello','mytopics']
|
||||
topics: ['hello','mytopics']
|
||||
}), {
|
||||
from: '0x00000',
|
||||
to: '0x00000',
|
||||
payload: '0x7b2274657374223a2274657374227d',
|
||||
ttl: '0xc8',
|
||||
workToProve: '0x3e8',
|
||||
topic: ['0x68656c6c6f','0x6d79746f70696373']
|
||||
topics: ['0x68656c6c6f','0x6d79746f70696373']
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -10,14 +10,14 @@ describe('formatters', function () {
|
|||
sent: '0x3e8',
|
||||
ttl: '0x3e8',
|
||||
payload: '0x7b2274657374223a2274657374227d',
|
||||
topic: ['0x68656c6c6f','0x6d79746f70696373']
|
||||
topics: ['0x68656c6c6f','0x6d79746f70696373']
|
||||
}), {
|
||||
expiry: 1000,
|
||||
sent: 1000,
|
||||
ttl: 1000,
|
||||
payload: {test: 'test'},
|
||||
payloadRaw: '0x7b2274657374223a2274657374227d',
|
||||
topic: ['hello','mytopics']
|
||||
topics: ['hello','mytopics']
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue