diff --git a/apps/webapp/src/components/shared/input-token.tsx b/apps/webapp/src/components/shared/input-token.tsx index d0e7004cd2..09ce3f2815 100644 --- a/apps/webapp/src/components/shared/input-token.tsx +++ b/apps/webapp/src/components/shared/input-token.tsx @@ -1,22 +1,18 @@ import { Input, InputProps } from '@penumbra-zone/ui'; import { cn } from '@penumbra-zone/ui/lib/utils'; -import { fromBaseUnitAmount } from '@penumbra-zone/types'; +import { fromBaseUnitAmount, joinLoHiAmount } from '@penumbra-zone/types'; import SelectTokenModal from './select-token-modal'; import { Validation, validationResult } from './validation-result'; import { AccountBalance, AssetBalance } from '../../fetchers/balances'; import { Selection } from '../../state/types'; +import { Fee } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/component/fee/v1alpha1/fee_pb'; -/** - * Each property of the `GasPrices` class has an implicit 1,000 denominator, per - * its docs. - * - * @see `proto/penumbra/penumbra/core/component/fee/v1alpha1/fee.proto` in the - * core repo. - */ -const FEE_DENOMINATOR = 1000; +const PENUMBRA_FEE_DENOMINATOR = 1000; -const getFeeAsString = (fee: bigint | undefined, denomination: string | undefined) => - typeof fee !== 'undefined' ? `${(Number(fee) / FEE_DENOMINATOR).toString()} ${denomination}` : ''; +const getFeeAsString = (fee: Fee | undefined) => { + if (!fee?.amount) return ''; + return `${(Number(joinLoHiAmount(fee.amount)) / PENUMBRA_FEE_DENOMINATOR).toString()} penumbra`; +}; const getCurrentBalance = (assetBalance: AssetBalance | undefined) => assetBalance @@ -33,7 +29,7 @@ interface InputTokenProps extends InputProps { setSelection: (selection: Selection) => void; validations?: Validation[]; balances: AccountBalance[]; - fee: bigint | undefined; + fee: Fee | undefined; } export default function InputToken({ @@ -52,8 +48,7 @@ export default function InputToken({ const vResult = validationResult(value, validations); const currentBalance = getCurrentBalance(selection?.asset); - const denomination = selection?.asset?.denom.display; - const feeAsString = getFeeAsString(fee, denomination); + const feeAsString = getFeeAsString(fee); return (
void; memo: string; setMemo: (txt: string) => void; - fee: bigint | undefined; + fee: Fee | undefined; refreshFee: () => Promise; sendTx: (toastFn: typeof toast) => Promise; txInProgress: boolean; @@ -72,10 +72,9 @@ export const createSendSlice = (): SliceCreator => (set, get) => { const plan = await getPlan({ amount, recipient, selection, memo }); if (!plan?.fee?.amount) return; - const fee = joinLoHiAmount(plan.fee.amount); set(state => { - state.send.fee = fee; + state.send.fee = plan.fee; }); }, sendTx: async toastFn => {