Skip to content

Commit

Permalink
Additional tx classifications
Browse files Browse the repository at this point in the history
  • Loading branch information
grod220 committed Jul 29, 2024
1 parent ba19606 commit 7d8f740
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 14 deletions.
34 changes: 21 additions & 13 deletions packages/ui/components/ui/tx/action-view.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SpendViewComponent } from './actions-views/spend';
import { OutputViewComponent } from './actions-views/output';
import { ActionView } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/transaction/v1/transaction_pb';
import { ActionView } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/transaction/v1/transaction_pb.js';
import { SwapClaimViewComponent } from './actions-views/swap/swap-claim';
import { DelegateComponent } from './actions-views/delegate';
import { UndelegateComponent } from './actions-views/undelegate';
Expand All @@ -11,13 +11,15 @@ import { SwapViewComponent } from './actions-views/swap';
import { ActionDutchAuctionScheduleViewComponent } from './actions-views/action-dutch-auction-schedule-view';
import { ActionDutchAuctionEndComponent } from './actions-views/action-dutch-auction-end';
import { ActionDutchAuctionWithdrawViewComponent } from './actions-views/action-dutch-auction-withdraw-view';
import { ValueView } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/asset/v1/asset_pb';
import { ValueView } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/asset/v1/asset_pb.js';
import { DelegatorVoteComponent } from './actions-views/delegator-vote';
import { ValidatorVoteComponent } from './actions-views/validator-vote';

const CASE_TO_LABEL: Record<string, string> = {
daoDeposit: 'DAO Deposit',
daoOutput: 'DAO Output',
daoSpend: 'DAO Spend',
type Case = Exclude<ActionView['actionView']['case'], undefined>;

const CASE_TO_LABEL: Record<Case, string> = {
output: 'Output',
spend: 'Spend',
delegate: 'Delegate',
delegatorVote: 'Delegator Vote',
ibcRelayAction: 'IBC Relay Action',
Expand All @@ -35,9 +37,15 @@ const CASE_TO_LABEL: Record<string, string> = {
undelegateClaim: 'Undelegate Claim',
validatorDefinition: 'Validator Definition',
validatorVote: 'Validator Vote',
actionDutchAuctionEnd: 'Dutch Auction End',
actionDutchAuctionSchedule: 'Dutch Auction Schedule',
actionDutchAuctionWithdraw: 'Dutch Auction Withdraw',
communityPoolDeposit: 'Community Pool Deposit',
communityPoolOutput: 'Community Pool Output',
communityPoolSpend: 'Community Pool Spend',
};

const getLabelForActionCase = (actionCase: string | undefined): string => {
const getLabelForActionCase = (actionCase: ActionView['actionView']['case']): string => {
if (!actionCase) {
return '';
}
Expand Down Expand Up @@ -91,6 +99,12 @@ export const ActionViewComponent = ({
case 'actionDutchAuctionWithdraw':
return <ActionDutchAuctionWithdrawViewComponent value={actionView.value} />;

case 'delegatorVote':
return <DelegatorVoteComponent value={actionView.value} />;

case 'validatorVote':
return <ValidatorVoteComponent value={actionView.value} />;

case 'validatorDefinition':
return <UnimplementedView label='Validator Definition' />;

Expand All @@ -103,12 +117,6 @@ export const ActionViewComponent = ({
case 'proposalWithdraw':
return <UnimplementedView label='Proposal Withdraw' />;

case 'validatorVote':
return <UnimplementedView label='Validator Vote' />;

case 'delegatorVote':
return <DelegatorVoteComponent value={actionView.value} />;

case 'proposalDepositClaim':
return <UnimplementedView label='Proposal Deposit Claim' />;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export const DelegatorVoteComponent = ({ value }: { value: DelegatorVoteView })
return <div>Invalid DelegatorVoteView</div>;
};

const VoteToString = (vote: Vote): string => {
export const VoteToString = (vote: Vote): string => {
switch (vote.vote) {
case Vote_Vote.UNSPECIFIED:
return 'UNSPECIFIED';
Expand Down
41 changes: 41 additions & 0 deletions packages/ui/components/ui/tx/actions-views/validator-vote.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { ViewBox } from '../viewbox';
import { ActionDetails } from './action-details';
import { ValidatorVote } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/component/governance/v1/governance_pb';
import { VoteToString } from './delegator-vote';
import { bech32mIdentityKey } from '@penumbra-zone/bech32m/penumbravalid';
import { bech32mGovernanceId } from '@penumbra-zone/bech32m/penumbragovern';

export const ValidatorVoteComponent = ({ value }: { value: ValidatorVote }) => {
return (
<ViewBox
label='Validator Vote'
visibleContent={
<ActionDetails>
{!!value.body?.proposal && (
<ActionDetails.Row label='Proposal'>{Number(value.body.proposal)}</ActionDetails.Row>
)}

{!!value.body?.vote && (
<ActionDetails.Row label='Vote'>{VoteToString(value.body.vote)}</ActionDetails.Row>
)}

{!!value.body?.reason?.reason && (
<ActionDetails.Row label='Reason'>{value.body.reason.reason}</ActionDetails.Row>
)}

{!!value.body?.identityKey && (
<ActionDetails.Row label='Identity key'>
{bech32mIdentityKey(value.body.identityKey)}
</ActionDetails.Row>
)}

{!!value.body?.governanceKey && (
<ActionDetails.Row label='Governance key'>
{bech32mGovernanceId(value.body.governanceKey)}
</ActionDetails.Row>
)}
</ActionDetails>
}
/>
);
};

0 comments on commit 7d8f740

Please sign in to comment.