Skip to content

Commit

Permalink
update optional getters
Browse files Browse the repository at this point in the history
  • Loading branch information
TalDerei committed Sep 5, 2024
1 parent b14f093 commit 89825c5
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion packages/ui/components/ui/asset-icon/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const AssetIcon = ({
size === 'sm' && 'size-6',
size === 'lg' && 'size-12',
);
const display = getDisplay.optional()(metadata);
const display = getDisplay.optional(metadata);
const isDelegationToken = display ? assetPatterns.delegationToken.matches(display) : false;

Check failure on line 26 in packages/ui/components/ui/asset-icon/index.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unnecessary conditional, value is always truthy
const isUnbondingToken = display ? assetPatterns.unbondingToken.matches(display) : false;

Check failure on line 27 in packages/ui/components/ui/asset-icon/index.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unnecessary conditional, value is always truthy

Expand Down
4 changes: 2 additions & 2 deletions packages/ui/components/ui/tx/actions-views/delegator-vote.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ const umValueView = (amount?: Amount) => {
};

export const DelegatorVoteComponent = ({ value }: { value: DelegatorVoteView }) => {
const body = getDelegatorVoteBody.optional()(value);
const body = getDelegatorVoteBody.optional(value);

if (value.delegatorVote.case === 'visible') {
const note = value.delegatorVote.value.note;
const address = getAddress.optional()(note);
const address = getAddress.optional(note);

return (
<ViewBox
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/components/ui/tx/actions-views/swap/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ export const SwapViewComponent = ({
feeValueView: ValueView;
}) => {
if (value.swapView.case === 'visible') {
const claimTx = getClaimTx.optional()(value);
const addressView = getAddressView.optional()(value);
const claimTx = getClaimTx.optional(value);
const addressView = getAddressView.optional(value);
const oneWaySwap = isOneWaySwap(value) ? getOneWaySwapValues(value) : undefined;

// The 'Fee' protobuf definition does not include assetMetadata.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { getAmount } from '@penumbra-zone/getters/value-view';
* 1.23INPUT -> 4.56OUTPUT
*/
export const OneWaySwap = ({ input, output }: { input: ValueView; output: ValueView }) => {
const outputAmount = getAmount.optional()(output);
const outputAmount = getAmount.optional(output);

return (
<div className='flex items-center gap-2'>
Expand Down
12 changes: 6 additions & 6 deletions packages/ui/components/ui/tx/actions-views/swap/swap-claim.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { SwapClaimView } from '@penumbra-zone/protobuf/penumbra/core/component/d
import { TransactionIdComponent } from './transaction-id';
import { ActionDetails } from '../action-details';
import {
getOutput1ValueOptional,
getOutput2ValueOptional,
getOutput1Value,
getOutput2Value,
getSwapClaimFee,
} from '@penumbra-zone/getters/swap-claim-view';
import { getAmount } from '@penumbra-zone/getters/value-view';
Expand All @@ -30,10 +30,10 @@ const getClaimLabel = (
export const SwapClaimViewComponent = ({ value }: { value: SwapClaimView }) => {
if (value.swapClaimView.case === 'visible') {
const swapTxId = value.swapClaimView.value.swapTx;
const output1Value = getOutput1ValueOptional(value);
const output2Value = getOutput2ValueOptional(value);
const output1Amount = getAmount.optional()(output1Value);
const output2Amount = getAmount.optional()(output2Value);
const output1Value = getOutput1Value(value);

Check failure on line 33 in packages/ui/components/ui/tx/actions-views/swap/swap-claim.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unsafe assignment of an error typed value

Check failure on line 33 in packages/ui/components/ui/tx/actions-views/swap/swap-claim.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unsafe call of an `error` type typed value
const output2Value = getOutput2Value(value);

Check failure on line 34 in packages/ui/components/ui/tx/actions-views/swap/swap-claim.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unsafe assignment of an error typed value

Check failure on line 34 in packages/ui/components/ui/tx/actions-views/swap/swap-claim.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unsafe call of an `error` type typed value
const output1Amount = getAmount.optional(output1Value);
const output2Amount = getAmount.optional(output2Value);
const claimLabel = getClaimLabel(output1Amount, output2Amount);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const getPrice = (
// The input, scaled up by `step_count` to match.
const inputScaled = (stepCount - 1n) * input;

const inputDisplayDenomExponent = getDisplayDenomExponent.optional()(inputMetadata);
const inputDisplayDenomExponent = getDisplayDenomExponent.optional(inputMetadata);
const multiplier = 10 ** (inputDisplayDenomExponent ?? 0);
const price = Math.round((Number(targetOutputScaled) / Number(inputScaled)) * multiplier);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ export const ExpandedDetails = ({
fullSyncHeight >= description.startHeight &&
fullSyncHeight <= description.endHeight;

const inputExponent = getDisplayDenomExponent.optional()(inputMetadata);
const outputExponent = getDisplayDenomExponent.optional()(outputMetadata);
const inputExponent = getDisplayDenomExponent.optional(inputMetadata);
const outputExponent = getDisplayDenomExponent.optional(outputMetadata);

return (
<div className='flex w-full flex-col overflow-hidden'>
Expand Down

0 comments on commit 89825c5

Please sign in to comment.