55 SolanaError ,
66} from '@solana/errors' ;
77import { safeRace } from '@solana/promises' ;
8- import { createRpcMessage , RpcRequest , RpcResponseData } from '@solana/rpc-spec-types' ;
8+ import { createRpcMessage , RpcRequest , RpcResponseData , RpcResponseTransformer } from '@solana/rpc-spec-types' ;
99import { DataPublisher } from '@solana/subscribable' ;
1010import { demultiplexDataPublisher } from '@solana/subscribable' ;
1111
@@ -14,7 +14,7 @@ import { RpcSubscriptionsChannel } from './rpc-subscriptions-channel';
1414
1515type Config < TNotification > = Readonly < {
1616 channel : RpcSubscriptionsChannel < unknown , RpcNotification < TNotification > | RpcResponseData < RpcSubscriptionId > > ;
17- responseTransformer ?: < T > ( response : unknown , notificationName : string ) => T ;
17+ responseTransformer ?: RpcResponseTransformer ;
1818 signal : AbortSignal ;
1919 subscribeRequest : RpcRequest ;
2020 unsubscribeMethodName : string ;
@@ -65,7 +65,8 @@ function augmentSubscriberCountAndReturnNewCount(
6565const cache = new WeakMap ( ) ;
6666function getMemoizedDemultiplexedNotificationPublisherFromChannelAndResponseTransformer < TNotification > (
6767 channel : RpcSubscriptionsChannel < unknown , RpcNotification < TNotification > > ,
68- responseTransformer ?: < T > ( response : unknown , notificationName : string ) => T ,
68+ subscribeRequest : RpcRequest ,
69+ responseTransformer ?: RpcResponseTransformer ,
6970) : DataPublisher < {
7071 [ channelName : `notification:${number } `] : TNotification ;
7172} > {
@@ -84,7 +85,7 @@ function getMemoizedDemultiplexedNotificationPublisherFromChannelAndResponseTran
8485 return ;
8586 }
8687 const transformedNotification = responseTransformer
87- ? responseTransformer ( message . params . result , message . method )
88+ ? responseTransformer ( message . params . result , subscribeRequest )
8889 : message . params . result ;
8990 return [ `notification:${ message . params . subscription } ` , transformedNotification ] ;
9091 } ) ) ,
@@ -189,6 +190,7 @@ export async function executeRpcPubSubSubscriptionPlan<TNotification>({
189190 */
190191 const notificationPublisher = getMemoizedDemultiplexedNotificationPublisherFromChannelAndResponseTransformer (
191192 channel ,
193+ subscribeRequest ,
192194 responseTransformer ,
193195 ) ;
194196 const notificationKey = `notification:${ subscriptionId } ` as const ;
0 commit comments