-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
34 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,18 @@ | ||
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'; | ||
|
||
// Attempts to extract a fee token from the assets used in the actions of the planner request | ||
// Priority in descending order | ||
// Attempts to extract a fee token, with priority in descending order, from the assets used | ||
// in the actions of the planner request. | ||
// TODO: expand functionality for other action types like auctions, IBC, governance, etc. | ||
export const extractAltFee = (request: TransactionPlannerRequest): AssetId => { | ||
const outputAsset = request.outputs.map(o => o.value?.assetId).find(Boolean); | ||
if (outputAsset) return outputAsset; | ||
|
||
const spendAsset = request.spends.map(o => o.value?.assetId).find(Boolean); | ||
if (spendAsset) return spendAsset; | ||
|
||
const swapAsset = request.swaps.map(assetIn => assetIn.value?.assetId).find(Boolean); | ||
if (swapAsset) return swapAsset; | ||
|
||
const auctionScheduleAsset = request.dutchAuctionScheduleActions | ||
.map(a => a.description?.outputId) | ||
.find(Boolean); | ||
if (auctionScheduleAsset) return auctionScheduleAsset; | ||
|
||
const auctionEndAsset = request.dutchAuctionEndActions.map(a => a.auctionId?.inner).find(Boolean); | ||
if (auctionEndAsset) { | ||
return new AssetId({ inner: auctionEndAsset }); | ||
} | ||
|
||
const auctionWithdrawAsset = request.dutchAuctionWithdrawActions | ||
.map(a => a.auctionId?.inner) | ||
.find(Boolean); | ||
if (auctionWithdrawAsset) { | ||
return new AssetId({ inner: auctionWithdrawAsset }); | ||
} | ||
|
||
throw new Error('Could not extract alternative fee assetId from TransactionPlannerRequest'); | ||
Check failure on line 17 in packages/services/src/view-service/fees.ts GitHub Actions / testsrc/view-service/fees.test.ts > extractAltFee > extracts the fee from dutchAuctionScheduleActions
Check failure on line 17 in packages/services/src/view-service/fees.ts GitHub Actions / testsrc/view-service/fees.test.ts > extractAltFee > extracts the fee from dutchAuctionEndActions
Check failure on line 17 in packages/services/src/view-service/fees.ts GitHub Actions / testsrc/view-service/fees.test.ts > extractAltFee > extracts the fee from dutchAuctionWithdrawActions
|
||
}; |
34 changes: 0 additions & 34 deletions
34
packages/services/src/view-service/transaction-planner/fees.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters