@@ -20,6 +20,7 @@ interface IContext {
2020 counterCurrency : CurrencyDefinition ;
2121 /** the request's expected amount in counter currency */
2222 counterValue ?: string ;
23+ setOnConfirmation : ( onConfirmation : ( ) => void ) => void ;
2324 /**
2425 * set the pending status for UX purposes
2526 * Pending means the payment is being processed and takes a long time.
@@ -72,6 +73,7 @@ export const RequestProvider: React.FC<{ chainId?: string | number }> = ({
7273 const counterCurrency = currencyManager . from ( "USD" ) ! ;
7374 const [ counterValue , setCounterValue ] = useState < string > ( "" ) ;
7475 const [ pending , setPending ] = useState ( false ) ;
76+ const [ onConfirmation , setOnConfirmation ] = useState < ( ) => void > ( ) ;
7577
7678 // gets counter currency rate
7779 const rate = useRate ( parsedRequest ?. currency , counterCurrency ) ;
@@ -100,6 +102,9 @@ export const RequestProvider: React.FC<{ chainId?: string | number }> = ({
100102 } ) ;
101103 parseResult . loaded = true ;
102104 setParsedRequest ( parseResult ) ;
105+ if ( onConfirmation ) {
106+ result . request . waitForConfirmation ( ) . then ( onConfirmation ) ;
107+ }
103108 }
104109 } ;
105110
@@ -125,6 +130,7 @@ export const RequestProvider: React.FC<{ chainId?: string | number }> = ({
125130 counterCurrency,
126131 counterValue,
127132 setPending,
133+ setOnConfirmation,
128134 update : useCallback (
129135 ( ) => fetchRequest ( id , chainId , pending ) ,
130136 [ id , chainId , pending ]
0 commit comments