Skip to content

Commit

Permalink
feat(ui): Add Node Number display to staking details
Browse files Browse the repository at this point in the history
Show the node number of the selected pool in staking details
  • Loading branch information
pbennett committed Oct 23, 2024
1 parent 7bebc0b commit e6bc705
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion ui/src/components/ValidatorDetails/StakingDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import { ellipseAddressJsx } from '@/utils/ellipseAddress'
import { ExplorerLink } from '@/utils/explorer'
import { convertFromBaseUnits, roundToFirstNonZeroDecimal } from '@/utils/format'
import { cn } from '@/utils/ui'
import { Constraints } from '@/contracts/ValidatorRegistryClient'
import { Constraints, NodePoolAssignmentConfig } from '@/contracts/ValidatorRegistryClient'

interface StakingDetailsProps {
validator: Validator
Expand Down Expand Up @@ -233,6 +233,17 @@ export function StakingDetails({ validator, constraints, stakesByValidator }: St
)
}

function nodeNumForPoolId(poolAppId: bigint, poolAssignments: NodePoolAssignmentConfig) {
for (let nodeIndex = 0; nodeIndex < poolAssignments.nodes.length; nodeIndex++) {
for (let poolIndex = 0; poolIndex < poolAssignments.nodes[nodeIndex][0].length; poolIndex++) {
if (poolAssignments.nodes[nodeIndex][0][poolIndex] === poolAppId) {
return nodeIndex + 1
}
}
}
return undefined
}

const renderPoolInfo = () => {
if (!selectedPoolInfo) {
return (
Expand Down Expand Up @@ -345,6 +356,15 @@ export function StakingDetails({ validator, constraints, stakesByValidator }: St
</dd>
</div>

<div className="py-4 grid grid-cols-2 gap-4">
<dt className="text-sm font-medium leading-6 text-muted-foreground">Node Number</dt>
<dd className="flex items-center gap-x-2 text-sm">
<span className="font-mono">
{nodeNumForPoolId(selectedPoolInfo.poolAppId, validator.nodePoolAssignment)}
</span>
</dd>
</div>

<div className="py-4 grid grid-cols-2 gap-4">
<dt className="text-sm font-medium leading-6 text-muted-foreground">Algod version</dt>
<dd className="flex items-center gap-x-2 text-sm">
Expand Down

0 comments on commit e6bc705

Please sign in to comment.