feat: add filters support to the connection.onProgramAccountChange method (#18257)
* add filters support to the connection.onProgramAccountChange method * add jsdoc comment * chore: lint Co-authored-by: Justin Starry <justin@solana.com>
This commit is contained in:
parent
1793a6eb5d
commit
c2124154a5
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue