diff --git a/web3.js/src/connection.ts b/web3.js/src/connection.ts index 7499f80879..5e0577378d 100644 --- a/web3.js/src/connection.ts +++ b/web3.js/src/connection.ts @@ -1725,6 +1725,7 @@ type ProgramAccountSubscriptionInfo = { callback: ProgramAccountChangeCallback; commitment?: Commitment; subscriptionId: SubscriptionId | null; // null when there's no current server subscription id + filters?: GetProgramAccountsFilter[]; }; /** @@ -3708,7 +3709,9 @@ export class Connection { this._subscribe( sub, 'programSubscribe', - this._buildArgs([sub.programId], sub.commitment, 'base64'), + this._buildArgs([sub.programId], sub.commitment, 'base64', { + filters: sub.filters, + }), ); } @@ -3830,12 +3833,14 @@ export class Connection { * @param programId Public key of the program to monitor * @param callback Function to invoke whenever the account is changed * @param commitment Specify the commitment level account changes must reach before notification + * @param filters The program account filters to pass into the RPC method * @return subscription id */ onProgramAccountChange( programId: PublicKey, callback: ProgramAccountChangeCallback, commitment?: Commitment, + filters?: GetProgramAccountsFilter[], ): number { const id = ++this._programAccountChangeSubscriptionCounter; this._programAccountChangeSubscriptions[id] = { @@ -3843,6 +3848,7 @@ export class Connection { callback, commitment, subscriptionId: null, + filters, }; this._updateSubscriptions(); return id;