From 8b9210c3e297e33e5a00aedc0cc43db89549e19f Mon Sep 17 00:00:00 2001 From: Tal Derei <70081547+TalDerei@users.noreply.github.com> Date: Thu, 18 Jul 2024 08:17:58 -0700 Subject: [PATCH] support multi-fees for auction intents (#1507) --- packages/services/src/view-service/fees.ts | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/packages/services/src/view-service/fees.ts b/packages/services/src/view-service/fees.ts index 98470a7c02..3326aabe49 100644 --- a/packages/services/src/view-service/fees.ts +++ b/packages/services/src/view-service/fees.ts @@ -39,5 +39,30 @@ export const extractAltFee = async ( return swaps?.swap?.claimFee?.assetId ?? indexedDb.stakingTokenAssetId; } + const auctionScheduleAsset = request.dutchAuctionScheduleActions + .map(a => a.description?.input) + .find(Boolean); + if (auctionScheduleAsset?.assetId) { + return auctionScheduleAsset.assetId; + } + + const auctionEndAsset = request.dutchAuctionEndActions.map(a => a.auctionId).find(Boolean); + if (auctionEndAsset) { + const endAuction = await indexedDb.getAuction(auctionEndAsset); + if (endAuction.auction?.input?.assetId) { + return endAuction.auction.input.assetId; + } + } + + const auctionWithdrawAsset = request.dutchAuctionWithdrawActions + .map(a => a.auctionId) + .find(Boolean); + if (auctionWithdrawAsset) { + const withdrawAuction = await indexedDb.getAuction(auctionWithdrawAsset); + if (withdrawAuction.auction?.input?.assetId) { + return withdrawAuction.auction.input.assetId; + } + } + throw new Error('Could not extract alternative fee assetId from TransactionPlannerRequest'); };