@@ -59,6 +59,7 @@ export type SubmitTxCallbackParams = {
5959
6060// Optional callback
6161export type GetCollateralCallbackParams = {
62+ sender : MessageSender ;
6263 type : Cip30ConfirmationCallbackType . GetCollateral ;
6364 data : {
6465 amount : Cardano . Lovelace ;
@@ -208,13 +209,15 @@ const getFilterAmount = (amount: Cbor): bigint => {
208209/**
209210 * getCollateralCallback
210211 *
212+ * @param sender The sender of the request
211213 * @param amount ADA collateral required in lovelaces
212214 * @param availableUtxos available UTxOs
213215 * @param callback Callback to execute to attempt setting new collateral
214216 * @param logger The logger instance
215217 * @returns Promise<Cbor[]> or null
216218 */
217219const getCollateralCallback = async (
220+ sender : MessageSender ,
218221 amount : Cardano . Lovelace ,
219222 availableUtxos : Cardano . Utxo [ ] ,
220223 callback : GetCollateralCallback ,
@@ -230,6 +233,7 @@ const getCollateralCallback = async (
230233 amount,
231234 utxos : availableUtxosWithoutAssets
232235 } ,
236+ sender,
233237 type : Cip30ConfirmationCallbackType . GetCollateral
234238 } ) ;
235239 return newCollateral . map ( ( core ) => Serialization . TransactionUnspentOutput . fromCore ( core ) . toCbor ( ) ) ;
@@ -285,7 +289,7 @@ const baseCip30WalletApi = (
285289 } ,
286290 // eslint-disable-next-line max-statements, sonarjs/cognitive-complexity,complexity
287291 getCollateral : async (
288- _ : SenderContext ,
292+ { sender } : SenderContext ,
289293 { amount = new Serialization . Value ( MAX_COLLATERAL_AMOUNT ) . toCbor ( ) } : { amount ?: Cbor } = { }
290294 ) : Promise <
291295 Cbor [ ] | null
@@ -300,6 +304,7 @@ const baseCip30WalletApi = (
300304 if ( available . length > 0 && ! ! confirmationCallback . getCollateral ) {
301305 // available UTxOs could be set as collateral based on user preference
302306 return await getCollateralCallback (
307+ sender ,
303308 getFilterAmount ( amount ) ,
304309 available ,
305310 confirmationCallback . getCollateral ,
@@ -328,7 +333,13 @@ const baseCip30WalletApi = (
328333 // if no collateral available by amount in unspendables, return callback if provided to set unspendables and return in the callback
329334
330335 if ( available . length > 0 && ! ! confirmationCallback . getCollateral ) {
331- return await getCollateralCallback ( filterAmount , available , confirmationCallback . getCollateral , logger ) ;
336+ return await getCollateralCallback (
337+ sender ,
338+ filterAmount ,
339+ available ,
340+ confirmationCallback . getCollateral ,
341+ logger
342+ ) ;
332343 }
333344
334345 throw new ApiError ( APIErrorCode . Refused , 'not enough coins in configured collateral UTxOs' ) ;
0 commit comments