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