From 360c70274be88391672b1e287697156179fb4938 Mon Sep 17 00:00:00 2001 From: belopash Date: Thu, 23 May 2024 16:27:55 +0500 Subject: [PATCH] fix: correctly handle max sqd value on delegation --- src/pages/WorkersPage/WorkerDelegate.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pages/WorkersPage/WorkerDelegate.tsx b/src/pages/WorkersPage/WorkerDelegate.tsx index 3e72ea8..205848e 100644 --- a/src/pages/WorkersPage/WorkerDelegate.tsx +++ b/src/pages/WorkersPage/WorkerDelegate.tsx @@ -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'; @@ -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, @@ -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]); @@ -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)); }} />