1
1
import type { Commitment } from '@solana/rpc-core' ;
2
+ import type { GetAccountInfoApi } from '@solana/rpc-core/dist/types/rpc-methods/getAccountInfo' ;
3
+ import type { GetSignatureStatusesApi } from '@solana/rpc-core/dist/types/rpc-methods/getSignatureStatuses' ;
4
+ import type { AccountNotificationsApi } from '@solana/rpc-core/dist/types/rpc-subscriptions/account-notifications' ;
5
+ import type { SignatureNotificationsApi } from '@solana/rpc-core/dist/types/rpc-subscriptions/signature-notifications' ;
6
+ import type { SlotNotificationsApi } from '@solana/rpc-core/dist/types/rpc-subscriptions/slot-notifications' ;
7
+ import type { Rpc , RpcSubscriptions } from '@solana/rpc-transport/dist/types/json-rpc-types' ;
2
8
import {
3
9
getSignatureFromTransaction ,
4
10
IDurableNonceTransaction ,
@@ -18,6 +24,16 @@ interface BaseConfig {
18
24
transaction : ITransactionWithFeePayer & ITransactionWithSignatures ;
19
25
}
20
26
27
+ interface DefaultDurableNonceTransactionConfirmerConfig {
28
+ rpc : Rpc < GetSignatureStatusesApi & GetAccountInfoApi > ;
29
+ rpcSubscriptions : RpcSubscriptions < AccountNotificationsApi & SignatureNotificationsApi > ;
30
+ }
31
+
32
+ interface DefaultTransactionConfirmerConfig {
33
+ rpc : Rpc < GetSignatureStatusesApi > ;
34
+ rpcSubscriptions : RpcSubscriptions < SignatureNotificationsApi & SlotNotificationsApi > ;
35
+ }
36
+
21
37
interface WaitForTransactionWithBlockhashLifetimeConfirmationConfig extends BaseConfig {
22
38
getBlockHeightExceedencePromise : ReturnType < typeof createBlockHeightExceedencePromiseFactory > ;
23
39
transaction : ITransactionWithFeePayer & ITransactionWithSignatures & ITransactionWithBlockhashLifetime ;
@@ -58,6 +74,43 @@ async function raceStrategies<TConfig extends BaseConfig>(
58
74
}
59
75
}
60
76
77
+ export function createDefaultDurableNonceTransactionConfirmer ( {
78
+ rpc,
79
+ rpcSubscriptions,
80
+ } : DefaultDurableNonceTransactionConfirmerConfig ) {
81
+ const getNonceInvalidationPromise = createNonceInvalidationPromiseFactory ( rpc , rpcSubscriptions ) ;
82
+ const getSignatureConfirmationPromise = createSignatureConfirmationPromiseFactory ( rpc , rpcSubscriptions ) ;
83
+ return async function confirmTransaction (
84
+ config : Omit <
85
+ Parameters < typeof waitForDurableNonceTransactionConfirmation > [ 0 ] ,
86
+ 'getNonceInvalidationPromise' | 'getSignatureConfirmationPromise'
87
+ >
88
+ ) {
89
+ await waitForDurableNonceTransactionConfirmation ( {
90
+ ...config ,
91
+ getNonceInvalidationPromise,
92
+ getSignatureConfirmationPromise,
93
+ } ) ;
94
+ } ;
95
+ }
96
+
97
+ export function createDefaultTransactionConfirmer ( { rpc, rpcSubscriptions } : DefaultTransactionConfirmerConfig ) {
98
+ const getBlockHeightExceedencePromise = createBlockHeightExceedencePromiseFactory ( rpcSubscriptions ) ;
99
+ const getSignatureConfirmationPromise = createSignatureConfirmationPromiseFactory ( rpc , rpcSubscriptions ) ;
100
+ return async function confirmTransaction (
101
+ config : Omit <
102
+ Parameters < typeof waitForTransactionConfirmation > [ 0 ] ,
103
+ 'getBlockHeightExceedencePromise' | 'getSignatureConfirmationPromise'
104
+ >
105
+ ) {
106
+ await waitForTransactionConfirmation ( {
107
+ ...config ,
108
+ getBlockHeightExceedencePromise,
109
+ getSignatureConfirmationPromise,
110
+ } ) ;
111
+ } ;
112
+ }
113
+
61
114
export async function waitForDurableNonceTransactionConfirmation (
62
115
config : WaitForDurableNonceTransactionConfirmationConfig
63
116
) : Promise < void > {
0 commit comments