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;
|
callback: ProgramAccountChangeCallback;
|
||||||
commitment?: Commitment;
|
commitment?: Commitment;
|
||||||
subscriptionId: SubscriptionId | null; // null when there's no current server subscription id
|
subscriptionId: SubscriptionId | null; // null when there's no current server subscription id
|
||||||
|
filters?: GetProgramAccountsFilter[];
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -3708,7 +3709,9 @@ export class Connection {
|
|||||||
this._subscribe(
|
this._subscribe(
|
||||||
sub,
|
sub,
|
||||||
'programSubscribe',
|
'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 programId Public key of the program to monitor
|
||||||
* @param callback Function to invoke whenever the account is changed
|
* @param callback Function to invoke whenever the account is changed
|
||||||
* @param commitment Specify the commitment level account changes must reach before notification
|
* @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
|
* @return subscription id
|
||||||
*/
|
*/
|
||||||
onProgramAccountChange(
|
onProgramAccountChange(
|
||||||
programId: PublicKey,
|
programId: PublicKey,
|
||||||
callback: ProgramAccountChangeCallback,
|
callback: ProgramAccountChangeCallback,
|
||||||
commitment?: Commitment,
|
commitment?: Commitment,
|
||||||
|
filters?: GetProgramAccountsFilter[],
|
||||||
): number {
|
): number {
|
||||||
const id = ++this._programAccountChangeSubscriptionCounter;
|
const id = ++this._programAccountChangeSubscriptionCounter;
|
||||||
this._programAccountChangeSubscriptions[id] = {
|
this._programAccountChangeSubscriptions[id] = {
|
||||||
@ -3843,6 +3848,7 @@ export class Connection {
|
|||||||
callback,
|
callback,
|
||||||
commitment,
|
commitment,
|
||||||
subscriptionId: null,
|
subscriptionId: null,
|
||||||
|
filters,
|
||||||
};
|
};
|
||||||
this._updateSubscriptions();
|
this._updateSubscriptions();
|
||||||
return id;
|
return id;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user