Skip to content

Commit

Permalink
small recfactors for wallet smoosh
Browse files Browse the repository at this point in the history
  • Loading branch information
fmtabbara committed Sep 12, 2024
1 parent d15f25e commit a9beb4a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 20 deletions.
2 changes: 1 addition & 1 deletion nym-wallet/src/components/Bonding/NodeStats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const NodeStats = ({ mixnode }: { mixnode: TBondedMixnode }) => {
const navigate = useNavigate();

// clamp routing score to [0-100]
const score = Math.min(Math.max(routingScore, 0), 100);
const score = Math.min(Math.max(routingScore || 0, 0), 100);

const data = [
{ key: 'routingScore', value: score },
Expand Down
4 changes: 2 additions & 2 deletions nym-wallet/src/context/bonding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ export type TBondedMixnode = {
operatorRewards?: DecCoin;
delegators: number;
status: MixnodeStatus;
proxy?: string;
proxy?: string | null;
operatorCost: DecCoin;
host: string;
estimatedRewards?: DecCoin;
activeSetProbability?: SelectionChance;
standbySetProbability?: SelectionChance;
routingScore: number;
routingScore?: number;
httpApiPort: number;
mixPort: number;
verlocPort: number;
Expand Down
20 changes: 3 additions & 17 deletions nym-wallet/src/pages/Admin/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,15 @@ const AdminForm: FCWithChildren<{
<Grid container spacing={3}>
<Grid item xs={12}>
<TextField
{...register('minimum_mixnode_pledge')}
{...register('minimum_pledge')}
required
variant="outlined"
id="minimum_mixnode_bond"
name="minimum_mixnode_bond"
label="Minumum mixnode bond"
fullWidth
error={!!errors.minimum_mixnode_pledge}
helperText={`${errors?.minimum_mixnode_pledge?.amount?.message} ${errors?.minimum_mixnode_pledge?.denom?.message}`}
InputLabelProps={{ shrink: true }}
/>
</Grid>
<Grid item xs={12}>
<TextField
{...register('minimum_gateway_pledge')}
required
variant="outlined"
id="minimum_gateway_bond"
name="minimum_gateway_bond"
label="Minumum gateway bond"
fullWidth
error={!!errors.minimum_gateway_pledge}
helperText={`${errors?.minimum_gateway_pledge?.amount?.message} ${errors?.minimum_gateway_pledge?.denom?.message}`}
error={!!errors.minimum_pledge}
helperText={`${errors?.minimum_pledge?.amount?.message} ${errors?.minimum_pledge?.denom?.message}`}
InputLabelProps={{ shrink: true }}
/>
</Grid>
Expand Down
10 changes: 10 additions & 0 deletions nym-wallet/src/utils/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,3 +251,13 @@ export const getIntervalAsDate = async () => {

return { nextEpoch, nextInterval };
};

export const calculateStake = (pledge: string, delegations: string) => {
let stake;
try {
stake = unymToNym(Big(pledge).plus(delegations));
} catch (e: any) {
Console.warn(`not a valid decimal number: ${e}`);
}
return stake;
};

0 comments on commit a9beb4a

Please sign in to comment.