Skip to content

Commit

Permalink
chore(rwa): show the correct balance that can be transferred (#2763)
Browse files Browse the repository at this point in the history
  • Loading branch information
sstraatemans authored Dec 20, 2024
1 parent c322e39 commit c3ca00b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .changeset/seven-chairs-push.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useAccount } from '@/hooks/account';
import { useGetFrozenTokens } from '@/hooks/getFrozenTokens';
import { useGetInvestors } from '@/hooks/getInvestors';
import { useTransferTokens } from '@/hooks/transferTokens';
import type { ITransferTokensProps } from '@/services/transferTokens';
Expand Down Expand Up @@ -26,6 +27,9 @@ export const TransferForm: FC<IProps> = ({ onClose, trigger }) => {
const { account, balance } = useAccount();
const { data: investors } = useGetInvestors();
const { submit, isAllowed } = useTransferTokens();
const { data: frozenAmount } = useGetFrozenTokens({
investorAccount: account?.address!,
});

const {
register,
Expand Down Expand Up @@ -63,6 +67,8 @@ export const TransferForm: FC<IProps> = ({ onClose, trigger }) => {

if (!account) return;

const maxAmount = balance - frozenAmount;

return (
<>
{isRightAsideExpanded && isOpen && (
Expand All @@ -83,12 +89,13 @@ export const TransferForm: FC<IProps> = ({ onClose, trigger }) => {
message: 'The value should be at least 1',
},
max: {
value: balance,
message: 'The value can not be more than your balance',
value: maxAmount,
message:
'The value can not be more than your balance ( - frozen tokens)',
},
})}
variant={errors.amount?.message ? 'negative' : 'default'}
description={`max amount tokens: ${balance}`}
description={`max amount tokens: ${maxAmount}`}
errorMessage={errors.amount?.message}
/>

Expand Down

0 comments on commit c3ca00b

Please sign in to comment.