diff --git a/components/SelectValidator.tsx b/components/SelectValidator.tsx index 35e68bd3..acfef138 100644 --- a/components/SelectValidator.tsx +++ b/components/SelectValidator.tsx @@ -12,16 +12,17 @@ import { import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"; import { useChains } from "@/context/ChainsContext"; import { cn } from "@/lib/utils"; +import { Validator } from "cosmjs-types/cosmos/staking/v1beta1/staking"; import { Check, ChevronsUpDown } from "lucide-react"; import { useState } from "react"; interface SelectValidatorProps { - readonly validatorAddress: string; + readonly selectedValidatorAddress: string; readonly setValidatorAddress: (validatorAddress: string) => void; } export default function SelectValidator({ - validatorAddress, + selectedValidatorAddress, setValidatorAddress, }: SelectValidatorProps) { const { @@ -38,6 +39,12 @@ export default function SelectValidator({ // reasonable filtering here. const validators = [...bonded, ...unbonding, ...unbonded]; + function displayValidator(val: Validator): string { + return val.description.moniker + (val.jailed ? " (jailed)" : "") + } + + const selectedValidator = validators.find((validatorItem) => selectedValidatorAddress === validatorItem.operatorAddress); + return ( @@ -47,9 +54,8 @@ export default function SelectValidator({ aria-expanded={open} className="mb-4 w-full max-w-[300px] justify-between border-white bg-fuchsia-900 hover:bg-fuchsia-900" > - {validatorAddress - ? validators.find((validatorItem) => validatorAddress === validatorItem.operatorAddress) - ?.description.moniker || "Unknown validator" + {selectedValidatorAddress + ? selectedValidator ? displayValidator(selectedValidator): "Unknown validator" : "Select validator…"} @@ -76,7 +82,7 @@ export default function SelectValidator({ MsgBeginRedelegate
MsgDelegate
MsgUndelegate
MsgWithdrawDelegatorReward