@@ -43,7 +43,7 @@ export type UseTransactionProps<T> = {
43
43
params : T [ ] ;
44
44
createTxAtom : AtomType < T > ;
45
45
useDisposableSigner ?: boolean ;
46
- eventType : TransactionEventsClasses ;
46
+ eventType : TransactionEventsClasses | TransactionEventsClasses [ ] ;
47
47
parsePendingTxNotification ?: ( tx : TransactionPair < T > ) => PartialNotification ;
48
48
parseErrorTxNotification ?: ( ) => PartialNotification ;
49
49
} & UseTransactionPropsEvents < T > ;
@@ -80,12 +80,22 @@ export const useTransaction = <T,>({
80
80
const dispatchNotification = useSetAtom ( dispatchToastNotificationAtom ) ;
81
81
const { mutateAsync : performBuildTx } = useAtomValue ( createTxAtom ) ;
82
82
83
- // We don't want to display zeroed value when params are not set yet.
84
- const txKinds = new Array ( Math . max ( 1 , params . length ) ) . fill ( eventType ) ;
83
+ // Claim & Stake is the only array of tx kinds. The rest are single tx kinds.
84
+ const arr = new Array ( Math . max ( 1 , params . length ) ) ;
85
+ const kinds =
86
+ Array . isArray ( eventType ) ?
87
+ // **IMPORTANT**
88
+ // If eventType is an array, we set kinds by multiplying each kind by params length
89
+ // i.e. (["ClaimRewards", "Bond"] AND params.length == 2) => ["ClaimRewards", "Bond", "ClaimRewards", "Bond"]
90
+ arr . fill ( eventType ) . flat ( )
91
+ : arr . fill ( eventType ) ; // Don't display zeroed value when params are not set yet.
92
+
85
93
const feeProps = useTransactionFee (
86
- txKinds ,
87
- [ "ShieldedTransfer" , "UnshieldingTransfer" ] . includes ( eventType )
94
+ kinds ,
95
+ kinds . some ( ( k ) => [ "ShieldedTransfer" , "UnshieldingTransfer" ] . includes ( k ) )
88
96
) ;
97
+ const broadcastEventType =
98
+ ! Array . isArray ( eventType ) ? eventType : "ClaimRewards" ;
89
99
90
100
const dispatchPendingTxNotification = (
91
101
tx : TransactionPair < T > ,
@@ -192,7 +202,7 @@ export const useTransaction = <T,>({
192
202
transactionPair . encodedTxData ,
193
203
transactionPair . signedTxs ,
194
204
transactionPair . encodedTxData . meta ?. props ,
195
- eventType
205
+ broadcastEventType
196
206
) ;
197
207
onBroadcasted ?.( transactionPair ) ;
198
208
} catch ( error ) {
0 commit comments