-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* reenable spend max in frontend * max send invariants * reenable spend max in planner * lintingg * refactor assertion checks * fix swaps and state updates * modify privacy warning * Refactoring spend max (#1760) * refactor to use zustand and remove extraneous state * more refactor and linting * fix bug with non max amounts * forgot to add unit tests * error message * linting * changeset * bump wasm deps to v0.80.5 * extra safety checks in wasm planner * update lockfile * split wasm code * refactoring assertions * assertion cleanup * fix import * gabe's suggestion's * revert * linting galore * extra extra extra validation for sanity checking * Suggestions (#1867) * changeset for updates packages * delete outdated changeset --------- Co-authored-by: Gabe Rodriguez <[email protected]>
- Loading branch information
Showing
15 changed files
with
780 additions
and
71 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
'@penumbra-zone/services': minor | ||
'@penumbra-zone/storage': minor | ||
'minifront': minor | ||
'@penumbra-zone/types': minor | ||
--- | ||
|
||
send max feature |
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,38 @@ | ||
import { ViewService } from '@penumbra-zone/protobuf'; | ||
import { GasPrices } from '@penumbra-zone/protobuf/penumbra/core/component/fee/v1/fee_pb'; | ||
import { BalancesResponse } from '@penumbra-zone/protobuf/penumbra/view/v1/view_pb'; | ||
import { getAssetIdFromValueView } from '@penumbra-zone/getters/value-view'; | ||
import { Metadata } from '@penumbra-zone/protobuf/penumbra/core/asset/v1/asset_pb'; | ||
import { getAddressIndex } from '@penumbra-zone/getters/balances-response'; | ||
import { getAssetId } from '@penumbra-zone/getters/metadata'; | ||
import { penumbra } from '../penumbra'; | ||
|
||
// Fetches gas prices | ||
export const getGasPrices = async (): Promise<GasPrices[]> => { | ||
const res = await penumbra.service(ViewService).gasPrices({}); | ||
return res.altGasPrices; | ||
}; | ||
|
||
// Determines if the user has UM token in their account balances | ||
export const hasStakingToken = ( | ||
balancesResponses: BalancesResponse[] | undefined, | ||
stakingAssetMetadata: Metadata | undefined, | ||
source: BalancesResponse | undefined, | ||
): boolean => { | ||
if (!balancesResponses || !stakingAssetMetadata || !source) { | ||
return false; | ||
} | ||
|
||
const account = getAddressIndex.optional(source)?.account; | ||
if (typeof account === 'undefined') { | ||
return false; | ||
} | ||
|
||
return balancesResponses.some( | ||
asset => | ||
getAssetIdFromValueView | ||
.optional(asset.balanceView) | ||
?.equals(getAssetId.optional(stakingAssetMetadata)) && | ||
getAddressIndex.optional(asset)?.account === account, | ||
); | ||
}; |
Oops, something went wrong.