Skip to content

Commit

Permalink
Keep extra filter topics when using Frgment filters in Contracts.
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmoo committed Jul 21, 2019
1 parent d88ee45 commit efaafb2
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions packages/contracts/src.ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,10 +346,17 @@ class FragmentRunningEvent extends RunningEvent {
readonly interface: Interface;
readonly fragment: EventFragment;

constructor(address: string, contractInterface: Interface, fragment: EventFragment) {
let filter = {
address: address,
topics: [ contractInterface.getEventTopic(fragment) ]
constructor(address: string, contractInterface: Interface, fragment: EventFragment, topics?: Array<string>) {
let filter: EventFilter = {
address: address
}

let topic = contractInterface.getEventTopic(fragment);
if (topics) {
if (topic !== topics[0]) { errors.throwArgumentError("topic mismatch", "topics", topics); }
filter.topics = topics.slice();
} else {
filter.topics = [ topic ];
}

super(getEventTag(filter), filter);
Expand Down Expand Up @@ -646,7 +653,7 @@ export class Contract {
if (eventName.topics[0]) {
let fragment = this.interface.getEvent(eventName.topics[0]);
if (fragment) {
return this._normalizeRunningEvent(new FragmentRunningEvent(this.address, this.interface, fragment));
return this._normalizeRunningEvent(new FragmentRunningEvent(this.address, this.interface, fragment, eventName.topics));
}
}

Expand Down

0 comments on commit efaafb2

Please sign in to comment.