Skip to content

Commit

Permalink
Repair the type of getProgramAccounts with respect to the memcmp
Browse files Browse the repository at this point in the history
…filter (#2729)
  • Loading branch information
steveluscher committed May 21, 2024
1 parent 26dae19 commit 3496637
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,40 +192,48 @@ rpcSubscriptions
({
filters: [
{
bytes: 'bytes' as Base58EncodedBytes,
encoding: 'base58',
offset: 0n as U64UnsafeBeyond2Pow53Minus1,
memcmp: {
bytes: 'bytes' as Base58EncodedBytes,
encoding: 'base58',
offset: 0n as U64UnsafeBeyond2Pow53Minus1,
},
},
],
}) satisfies Parameters<RpcSubscriptions<ProgramNotificationsApi>['programNotifications']>[1];
// Can't flop them
({
filters: [
{
// @ts-expect-error Can't flop them
bytes: 'bytes' as Base58EncodedBytes,
encoding: 'base64',
offset: 0n as U64UnsafeBeyond2Pow53Minus1,
// @ts-expect-error Can't flop the encodings
memcmp: {
bytes: 'bytes' as Base58EncodedBytes,
encoding: 'base64',
offset: 0n as U64UnsafeBeyond2Pow53Minus1,
},
},
],
}) satisfies Parameters<RpcSubscriptions<ProgramNotificationsApi>['programNotifications']>[1];
({
filters: [
{
bytes: 'bytes' as Base64EncodedBytes,
encoding: 'base64',
offset: 0n as U64UnsafeBeyond2Pow53Minus1,
memcmp: {
bytes: 'bytes' as Base64EncodedBytes,
encoding: 'base64',
offset: 0n as U64UnsafeBeyond2Pow53Minus1,
},
},
],
}) satisfies Parameters<RpcSubscriptions<ProgramNotificationsApi>['programNotifications']>[1];
// Can't flop them
({
filters: [
{
// @ts-expect-error Can't flop them
bytes: 'bytes' as Base64EncodedBytes,
encoding: 'base58',
offset: 0n as U64UnsafeBeyond2Pow53Minus1,
// @ts-expect-error Can't flop the encodings
memcmp: {
bytes: 'bytes' as Base64EncodedBytes,
encoding: 'base58',
offset: 0n as U64UnsafeBeyond2Pow53Minus1,
},
},
],
}) satisfies Parameters<RpcSubscriptions<ProgramNotificationsApi>['programNotifications']>[1];
13 changes: 5 additions & 8 deletions packages/rpc-subscriptions-api/src/program-notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ type ProgramNotificationsMemcmpFilterBase64 = Readonly<{
offset: U64UnsafeBeyond2Pow53Minus1;
}>;

type ProgramNotificationsDatasizeFilter = Readonly<{
dataSize: U64UnsafeBeyond2Pow53Minus1;
}>;
type ProgramNotificationsDatasizeFilter = U64UnsafeBeyond2Pow53Minus1;

type ProgramNotificationsApiNotificationBase<TData> = SolanaRpcResponse<
Readonly<{
Expand All @@ -40,11 +38,10 @@ type ProgramNotificationsApiNotificationBase<TData> = SolanaRpcResponse<
type ProgramNotificationsApiCommonConfig = Readonly<{
commitment?: Commitment;
// The resultant account must meet ALL filter criteria to be included in the returned results
filters?: readonly (
| ProgramNotificationsDatasizeFilter
| ProgramNotificationsMemcmpFilterBase58
| ProgramNotificationsMemcmpFilterBase64
)[];
filters?: readonly Readonly<
| { dataSize: ProgramNotificationsDatasizeFilter }
| { memcmp: ProgramNotificationsMemcmpFilterBase58 | ProgramNotificationsMemcmpFilterBase64 }
>[];
}>;

export interface ProgramNotificationsApi extends RpcSubscriptionsApiMethods {
Expand Down

0 comments on commit 3496637

Please sign in to comment.