Skip to content

Commit efaafb2

Browse files
committed
Keep extra filter topics when using Frgment filters in Contracts.
1 parent d88ee45 commit efaafb2

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

packages/contracts/src.ts/index.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -346,10 +346,17 @@ class FragmentRunningEvent extends RunningEvent {
346346
readonly interface: Interface;
347347
readonly fragment: EventFragment;
348348

349-
constructor(address: string, contractInterface: Interface, fragment: EventFragment) {
350-
let filter = {
351-
address: address,
352-
topics: [ contractInterface.getEventTopic(fragment) ]
349+
constructor(address: string, contractInterface: Interface, fragment: EventFragment, topics?: Array<string>) {
350+
let filter: EventFilter = {
351+
address: address
352+
}
353+
354+
let topic = contractInterface.getEventTopic(fragment);
355+
if (topics) {
356+
if (topic !== topics[0]) { errors.throwArgumentError("topic mismatch", "topics", topics); }
357+
filter.topics = topics.slice();
358+
} else {
359+
filter.topics = [ topic ];
353360
}
354361

355362
super(getEventTag(filter), filter);
@@ -646,7 +653,7 @@ export class Contract {
646653
if (eventName.topics[0]) {
647654
let fragment = this.interface.getEvent(eventName.topics[0]);
648655
if (fragment) {
649-
return this._normalizeRunningEvent(new FragmentRunningEvent(this.address, this.interface, fragment));
656+
return this._normalizeRunningEvent(new FragmentRunningEvent(this.address, this.interface, fragment, eventName.topics));
650657
}
651658
}
652659

0 commit comments

Comments
 (0)