-
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.
fees: ux for multi-asset fees (#1268)
* add index for spendable notes table in idb * scaffolding planner support for multi-asset fees * filter for alt fee asset id * fix fee rendering * full multi-asset fee support ~ * attempt to pass CI * partially address comments * valentine + jesse feedback * fix broken lockfile, update deps, update db version * remove dangling minifront_url * co-locate idb version with storage package * remove idb version from extension .env * support actions for alt fees * linting and organization cleanup * update lockfile * remove extension dir trace * fix lockfile? * address valentine comments * fix test suite * try fixing rust tests * rust lint * rust lint * add TODOs for #1310 * fix lint --------- Co-authored-by: valentine <valentyn1789@gmail.com>
- Loading branch information
1 parent
1ee18e0
commit 29fc9f7
Showing
24 changed files
with
750 additions
and
540 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { BalancesResponse } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/view/v1/view_pb'; | ||
import { Metadata } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/asset/v1/asset_pb'; | ||
import { getAssetIdFromValueView } from '@penumbra-zone/getters/value-view'; | ||
import { getAssetId } from '@penumbra-zone/getters/metadata'; | ||
|
||
export const hasStakingToken = ( | ||
assetBalances: BalancesResponse[], | ||
stakingAssetMetadata: Metadata, | ||
): boolean => { | ||
return assetBalances.some(asset => | ||
getAssetIdFromValueView(asset.balanceView).equals(getAssetId(stakingAssetMetadata)), | ||
); | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { AssetId } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/asset/v1/asset_pb'; | ||
import { | ||
TransactionPlannerRequest, | ||
TransactionPlannerRequest_ActionDutchAuctionEnd, | ||
TransactionPlannerRequest_ActionDutchAuctionSchedule, | ||
TransactionPlannerRequest_ActionDutchAuctionWithdraw, | ||
TransactionPlannerRequest_Output, | ||
TransactionPlannerRequest_Swap, | ||
} from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/view/v1/view_pb'; | ||
import { Code, ConnectError } from '@connectrpc/connect'; | ||
|
||
export const extractAltFee = (request: TransactionPlannerRequest): AssetId | undefined => { | ||
// Note: expand the possible types as we expand our support to more actions in the future. | ||
const fields = [ | ||
{ name: 'outputs', value: request.outputs }, | ||
{ name: 'swaps', value: request.swaps }, | ||
{ name: 'dutchAuctionScheduleActions', value: request.dutchAuctionScheduleActions }, | ||
{ name: 'dutchAuctionEndActions', value: request.dutchAuctionEndActions }, | ||
{ name: 'dutchAuctionWithdrawActions', value: request.dutchAuctionWithdrawActions }, | ||
]; | ||
|
||
const nonEmptyField = fields.find(field => field.value.length > 0); | ||
|
||
if (!nonEmptyField) { | ||
throw new ConnectError('No non-empty field found in the request.', Code.InvalidArgument); | ||
} | ||
|
||
const action = nonEmptyField.value[0]!; | ||
|
||
switch (nonEmptyField.name) { | ||
case 'outputs': | ||
return (action as TransactionPlannerRequest_Output).value?.assetId; | ||
case 'swaps': | ||
return (action as TransactionPlannerRequest_Swap).value?.assetId; | ||
case 'dutchAuctionScheduleActions': | ||
return (action as TransactionPlannerRequest_ActionDutchAuctionSchedule).description?.outputId; | ||
case 'dutchAuctionEndActions': | ||
return new AssetId({ | ||
inner: (action as TransactionPlannerRequest_ActionDutchAuctionEnd).auctionId?.inner, | ||
}); | ||
case 'dutchAuctionWithdrawActions': | ||
return new AssetId({ | ||
inner: (action as TransactionPlannerRequest_ActionDutchAuctionWithdraw).auctionId?.inner, | ||
}); | ||
default: | ||
console.warn('Unsupported action type.'); | ||
throw new ConnectError('Unsupported action type.', Code.InvalidArgument); | ||
} | ||
}; |
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
Oops, something went wrong.