Skip to content

Commit

Permalink
fix(ui): handle constraints being undefined pre-fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
drichar committed Apr 4, 2024
1 parent fa07fc2 commit d5bde80
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ui/src/components/ValidatorTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export function ValidatorTable({ validators, stakesByValidator }: ValidatorTable
notation: 'compact',
}).format(currentStake)

const maxStake = calculateMaxStake(validator, constraints!, true)
const maxStake = calculateMaxStake(validator, constraints, true)
const maxStakeCompact = new Intl.NumberFormat(undefined, {
notation: 'compact',
}).format(maxStake)
Expand Down
4 changes: 2 additions & 2 deletions ui/src/utils/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,11 +380,11 @@ export function getAddValidatorFormSchema(constraints: Constraints) {

export function calculateMaxStake(
validator: Validator,
constraints: Constraints,
constraints?: Constraints,
algos = false,
): number {
const { numPools } = validator.state
if (numPools === 0) {
if (numPools === 0 || !constraints) {
return 0
}
const hardMaxDividedBetweenPools = constraints.maxAlgoPerValidator / BigInt(numPools)
Expand Down

0 comments on commit d5bde80

Please sign in to comment.