Skip to content

Commit

Permalink
ts: Add tx signature to EventCallback (coral-xyz#1851)
Browse files Browse the repository at this point in the history
  • Loading branch information
dboures committed May 18, 2022
1 parent 1490d5f commit ac37fda
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ com/project-serum/anchor/pull/1841)).

ts: Change `BROWSER` env variable to `ANCHOR_BROWSER` ([#1233](https://github.com/project-serum/anchor/pull/1233)).

### Breaking

* ts: Add transaction signature to `EventCallback` parameters ([#1851](https://github.com/project-serum/anchor/pull/1851)).

## [0.24.2] - 2022-04-13

### Fixes
Expand Down
6 changes: 3 additions & 3 deletions ts/src/program/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export type EventData<T extends IdlEventField, Defined> = {
[N in T["name"]]: DecodeType<(T & { name: N })["type"], Defined>;
};

type EventCallback = (event: any, slot: number) => void;
type EventCallback = (event: any, slot: number, signature: string) => void;

export class EventManager {
/**
Expand Down Expand Up @@ -72,7 +72,7 @@ export class EventManager {

public addEventListener(
eventName: string,
callback: (event: any, slot: number) => void
callback: (event: any, slot: number, signature: string) => void
): number {
let listener = this._listenerIdCount;
this._listenerIdCount += 1;
Expand Down Expand Up @@ -107,7 +107,7 @@ export class EventManager {
const listenerCb = this._eventCallbacks.get(listener);
if (listenerCb) {
const [, callback] = listenerCb;
callback(event.data, ctx.slot);
callback(event.data, ctx.slot, logs.signature);
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion ts/src/program/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ export class Program<IDL extends Idl = Idl> {
*/
public addEventListener(
eventName: string,
callback: (event: any, slot: number) => void
callback: (event: any, slot: number, signature: string) => void
): number {
return this._events.addEventListener(eventName, callback);
}
Expand Down

0 comments on commit ac37fda

Please sign in to comment.