@@ -48,7 +48,9 @@ export function useWithdrawIncomingStream(
4848 } ) ;
4949 } ,
5050 onMutate : async ( stream ) => {
51- if ( ! publicKey ) return ;
51+ if ( ! publicKey ) {
52+ return { } ;
53+ }
5254
5355 // Cancel any outgoing refetches (so they don't overwrite our optimistic update)
5456 await queryClient . cancelQueries ( {
@@ -94,7 +96,11 @@ export function useWithdrawIncomingStream(
9496 } ,
9597 onSuccess : async ( result , stream , _variables , context ) => {
9698 if ( publicKey ) {
97- const targetWithdrawn = context ?. expectedWithdrawn ?? stream . withdrawn ;
99+ const ctx = context as {
100+ previousStreams ?: IncomingStreamRecord [ ] ;
101+ expectedWithdrawn ?: number ;
102+ } ;
103+ const targetWithdrawn = ctx . expectedWithdrawn ?? stream . withdrawn ;
98104 // Start polling in the background without blocking the mutation
99105 pollIndexerForWithdraw (
100106 publicKey ,
@@ -108,10 +114,14 @@ export function useWithdrawIncomingStream(
108114 await options ?. onSuccess ?.( result , stream ) ;
109115 } ,
110116 onError : ( error , stream , context ) => {
111- if ( publicKey && context ?. previousStreams ) {
117+ const ctx = context as {
118+ previousStreams ?: IncomingStreamRecord [ ] ;
119+ expectedWithdrawn ?: number ;
120+ } ;
121+ if ( publicKey && ctx ?. previousStreams ) {
112122 queryClient . setQueryData (
113123 incomingStreamsQueryKey ( publicKey ) ,
114- context . previousStreams ,
124+ ctx . previousStreams ,
115125 ) ;
116126 }
117127 options ?. onError ?.( error , stream ) ;
0 commit comments