5
5
SolanaError ,
6
6
} from '@solana/errors' ;
7
7
import { 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' ;
9
9
import { DataPublisher } from '@solana/subscribable' ;
10
10
import { demultiplexDataPublisher } from '@solana/subscribable' ;
11
11
@@ -14,7 +14,7 @@ import { RpcSubscriptionsChannel } from './rpc-subscriptions-channel';
14
14
15
15
type Config < TNotification > = Readonly < {
16
16
channel : RpcSubscriptionsChannel < unknown , RpcNotification < TNotification > | RpcResponseData < RpcSubscriptionId > > ;
17
- responseTransformer ?: < T > ( response : unknown , notificationName : string ) => T ;
17
+ responseTransformer ?: RpcResponseTransformer ;
18
18
signal : AbortSignal ;
19
19
subscribeRequest : RpcRequest ;
20
20
unsubscribeMethodName : string ;
@@ -65,7 +65,8 @@ function augmentSubscriberCountAndReturnNewCount(
65
65
const cache = new WeakMap ( ) ;
66
66
function getMemoizedDemultiplexedNotificationPublisherFromChannelAndResponseTransformer < TNotification > (
67
67
channel : RpcSubscriptionsChannel < unknown , RpcNotification < TNotification > > ,
68
- responseTransformer ?: < T > ( response : unknown , notificationName : string ) => T ,
68
+ subscribeRequest : RpcRequest ,
69
+ responseTransformer ?: RpcResponseTransformer ,
69
70
) : DataPublisher < {
70
71
[ channelName : `notification:${number } `] : TNotification ;
71
72
} > {
@@ -84,7 +85,7 @@ function getMemoizedDemultiplexedNotificationPublisherFromChannelAndResponseTran
84
85
return ;
85
86
}
86
87
const transformedNotification = responseTransformer
87
- ? responseTransformer ( message . params . result , message . method )
88
+ ? responseTransformer ( message . params . result , subscribeRequest )
88
89
: message . params . result ;
89
90
return [ `notification:${ message . params . subscription } ` , transformedNotification ] ;
90
91
} ) ) ,
@@ -189,6 +190,7 @@ export async function executeRpcPubSubSubscriptionPlan<TNotification>({
189
190
*/
190
191
const notificationPublisher = getMemoizedDemultiplexedNotificationPublisherFromChannelAndResponseTransformer (
191
192
channel ,
193
+ subscribeRequest ,
192
194
responseTransformer ,
193
195
) ;
194
196
const notificationKey = `notification:${ subscriptionId } ` as const ;
0 commit comments