ts: Add `commitment` param to `addEventListener` (#3052)

This commit is contained in:
Tomáš Livora 2024-06-26 23:00:17 +02:00 committed by GitHub
parent 70d4f488c1
commit 18cc94be94
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 29 additions and 24 deletions

View File

@ -14,6 +14,8 @@ The minor version will be incremented upon a breaking change and the patch versi
### Fixes
- ts: add optional `commitment` parameter to `Program.addEventListener` ([#3052](https://github.com/coral-xyz/anchor/pull/3052))
### Breaking
## [0.30.1] - 2024-06-20

View File

@ -1,8 +1,8 @@
import { PublicKey } from "@solana/web3.js";
import { IdlEvent, IdlField } from "../idl.js";
import { Commitment, PublicKey } from "@solana/web3.js";
import { Coder } from "../coder/index.js";
import { DecodeType } from "./namespace/types.js";
import { IdlEvent, IdlField } from "../idl.js";
import Provider from "../provider.js";
import { DecodeType } from "./namespace/types.js";
const PROGRAM_LOG = "Program log: ";
const PROGRAM_DATA = "Program data: ";
@ -73,7 +73,8 @@ export class EventManager {
public addEventListener(
eventName: string,
callback: (event: any, slot: number, signature: string) => void
callback: (event: any, slot: number, signature: string) => void,
commitment?: Commitment
): number {
let listener = this._listenerIdCount;
this._listenerIdCount += 1;
@ -116,7 +117,8 @@ export class EventManager {
});
}
}
}
},
commitment
);
return listener;

View File

@ -1,28 +1,28 @@
import { Commitment, PublicKey } from "@solana/web3.js";
import { inflate } from "pako";
import { PublicKey } from "@solana/web3.js";
import Provider, { getProvider } from "../provider.js";
import { BorshCoder, Coder } from "../coder/index.js";
import {
Idl,
idlAddress,
decodeIdlAccount,
IdlInstruction,
convertIdlToCamelCase,
decodeIdlAccount,
idlAddress,
} from "../idl.js";
import { Coder, BorshCoder } from "../coder/index.js";
import NamespaceFactory, {
RpcNamespace,
InstructionNamespace,
TransactionNamespace,
AccountNamespace,
SimulateNamespace,
MethodsNamespace,
ViewNamespace,
IdlEvents,
} from "./namespace/index.js";
import Provider, { getProvider } from "../provider.js";
import { utf8 } from "../utils/bytes/index.js";
import { EventManager } from "./event.js";
import { Address, translateAddress } from "./common.js";
import { CustomAccountResolver } from "./accounts-resolver.js";
import { Address, translateAddress } from "./common.js";
import { EventManager } from "./event.js";
import NamespaceFactory, {
AccountNamespace,
IdlEvents,
InstructionNamespace,
MethodsNamespace,
RpcNamespace,
SimulateNamespace,
TransactionNamespace,
ViewNamespace,
} from "./namespace/index.js";
export * from "./common.js";
export * from "./context.js";
@ -377,9 +377,10 @@ export class Program<IDL extends Idl = Idl> {
event: IdlEvents<IDL>[E],
slot: number,
signature: string
) => void
) => void,
commitment?: Commitment
): number {
return this._events.addEventListener(eventName, callback);
return this._events.addEventListener(eventName, callback, commitment);
}
/**