Skip to content

Commit

Permalink
fix: correctly handle max sqd value on delegation
Browse files Browse the repository at this point in the history
  • Loading branch information
belopash committed May 23, 2024
1 parent 78e29a1 commit 360c702
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/pages/WorkersPage/WorkerDelegate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useFormik } from 'formik';
import * as yup from 'yup';

import { useWorkerDelegate } from '@api/contracts/staking';
import { formatSqd, fromSqd, toSqd } from '@api/contracts/utils';
import { formatSqd, fromSqd, humanReadableSqd, toSqd } from '@api/contracts/utils';
import { BlockchainApiWorker } from '@api/subsquid-network-squid';
import { BlockchainContractError } from '@components/BlockchainContractError';
import { ContractCallDialog } from '@components/ContractCallDialog';
Expand Down Expand Up @@ -59,8 +59,8 @@ export function WorkerDelegate({
const formik = useFormik({
initialValues: {
source: '',
amount: 0,
max: 0,
amount: '0',
max: '0',
},
validationSchema: delegateSchema(SQD_TOKEN),
validateOnChange: true,
Expand Down Expand Up @@ -94,7 +94,7 @@ export function WorkerDelegate({
formik.setValues({
...formik.values,
source: source.id,
max: fromSqd(source.balance).toNumber(),
max: humanReadableSqd(source.balance),
});
}, [formik, isSourceLoading, sources]);

Expand Down Expand Up @@ -133,7 +133,7 @@ export function WorkerDelegate({
if (!wallet) return;

formik.setFieldValue('source', wallet.id);
formik.setFieldValue('max', fromSqd(wallet.balance).toNumber());
formik.setFieldValue('max', fromSqd(wallet.balance).toFixed(18));
}}
/>
</FormRow>
Expand Down

0 comments on commit 360c702

Please sign in to comment.