Skip to content

Commit

Permalink
fix ics20 ibc withdrawals (#1422)
Browse files Browse the repository at this point in the history
* fix ics20 withdrawls

* extract asset id from denom
  • Loading branch information
TalDerei authored Jul 5, 2024
1 parent a650bce commit 6c2bfdc
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/services/src/view-service/fees.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { AssetId } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/asset/v1/asset_pb';
import { TransactionPlannerRequest } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/view/v1/view_pb';
import { assetIdFromBaseDenom } from '@penumbra-zone/wasm/asset';

// Attempts to extract a fee token, with priority in descending order, from the assets used
// in the actions of the planner request.
Expand All @@ -14,5 +15,8 @@ export const extractAltFee = (request: TransactionPlannerRequest): AssetId => {
const swapAsset = request.swaps.map(assetIn => assetIn.value?.assetId).find(Boolean);
if (swapAsset) return swapAsset;

const ics20WithdrawAsset = request.ics20Withdrawals.map(w => w.denom).find(Boolean);
if (ics20WithdrawAsset) return assetIdFromBaseDenom(ics20WithdrawAsset.denom);

throw new Error('Could not extract alternative fee assetId from TransactionPlannerRequest');
};

0 comments on commit 6c2bfdc

Please sign in to comment.