Skip to content

Commit 2247473

Browse files
authored
Bugfix multiple event listeners with the same name (otter-sec#2165)
* Bugfix multiple event listeners with the same name * Changelog * changelog
1 parent f2ef418 commit 2247473

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ The minor version will be incremented upon a breaking change and the patch versi
3434
* lang: Fix parsing for bytes literals in the IDL. ([#2261](https://github.com/coral-xyz/anchor/pull/2261))
3535
* lang: Fix IDL `seed` generation for byte string literals. ([#2125](https://github.com/coral-xyz/anchor/pull/2125))
3636
* ts: Update seeds inference to allow nested user defined structs within the seeds ([#2198](https://github.com/coral-xyz/anchor/pull/2198))
37+
* event: Fix multiple event listeners with the same name. ([#2165](https://github.com/coral-xyz/anchor/pull/2165))
3738

3839
## [0.25.0] - 2022-07-05
3940

ts/packages/anchor/src/program/event.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export class EventManager {
7878
this._listenerIdCount += 1;
7979

8080
// Store the listener into the event map.
81-
if (!(eventName in this._eventCallbacks)) {
81+
if (!this._eventListeners.has(eventName)) {
8282
this._eventListeners.set(eventName, []);
8383
}
8484
this._eventListeners.set(
@@ -138,6 +138,7 @@ export class EventManager {
138138
// Update both maps.
139139
this._eventCallbacks.delete(listener);
140140
listeners = listeners.filter((l) => l !== listener);
141+
this._eventListeners.set(eventName, listeners);
141142
if (listeners.length === 0) {
142143
this._eventListeners.delete(eventName);
143144
}

0 commit comments

Comments
 (0)