diff --git a/components/factory/components/metaBox.tsx b/components/factory/components/metaBox.tsx
index bc067f4c..4042a122 100644
--- a/components/factory/components/metaBox.tsx
+++ b/components/factory/components/metaBox.tsx
@@ -2,7 +2,7 @@ import React, { useState, useEffect, useCallback } from 'react';
import { MetadataSDKType } from '@chalabi/manifestjs/dist/codegen/cosmos/bank/v1beta1/bank';
import MintForm from '@/components/factory/forms/MintForm';
import BurnForm from '@/components/factory/forms/BurnForm';
-import TransferForm from '@/components/factory/forms/TransferForm';
+
import { useGroupsByAdmin, usePoaParams } from '@/hooks';
export default function MetaBox({
@@ -16,7 +16,7 @@ export default function MetaBox({
refetch: () => void;
balance: string;
}>) {
- const [activeTab, setActiveTab] = useState<'transfer' | 'burn' | 'mint'>('mint');
+ const [activeTab, setActiveTab] = useState<'burn' | 'mint'>('mint');
const { poaParams, isPoaParamsLoading, refetchPoaParams, isPoaParamsError } = usePoaParams();
const admin = poaParams?.admins[0];
@@ -51,7 +51,7 @@ export default function MetaBox({
{`${activeTab.charAt(0).toUpperCase() + activeTab.slice(1)} ${denom.display}`}
- {[...(denom.base.includes('mfx') ? [] : ['transfer']), 'burn', 'mint'].map(tab => (
+ {['burn', 'mint'].map(tab => (
@@ -78,9 +78,6 @@ export default function MetaBox({
)}
{denom && (
<>
- {!denom.base.includes('mfx') && activeTab === 'transfer' && (
-
- )}
{activeTab === 'burn' && (
unit.denom === denom.display)?.exponent || 0;
const isMFX = denom.base.includes('mfx');
+ const { balance: recipientBalance } = useTokenFactoryBalance(recipient ?? '', denom.base);
+ const balanceNumber = parseFloat(
+ shiftDigits(isMFX ? recipientBalance?.amount || '0' : balance, -exponent)
+ );
+
+ const BurnSchema = Yup.object().shape({
+ amount: Yup.number()
+ .positive('Amount must be positive')
+ .required('Amount is required')
+ .max(1e12, 'Amount is too large')
+ .test('max-balance', 'Amount exceeds balance', function (value) {
+ return value <= balanceNumber;
+ }),
+ });
+
const handleBurn = async () => {
if (!amount || isNaN(Number(amount))) {
return;
@@ -187,58 +205,80 @@ export default function BurnForm({
{denom.display}
-
-
-
-
setAmount(e.target.value)}
- />
-
-
-
-
-
setRecipient(e.target.value)}
- />
-
-
-
-
-
-
- {isMFX && (
-
+
{
+ setAmount(values.amount);
+ handleBurn();
+ }}
+ validateOnChange={true}
+ validateOnBlur={true}
+ validateOnMount={true}
+ >
+ {({ isValid, dirty, setFieldValue }) => (
+
)}
-
+
{isMFX && (
unit.denom === denom.display)?.exponent || 0;
const isMFX = denom.base.includes('mfx');
+ const MintSchema = Yup.object().shape({
+ amount: Yup.number()
+ .positive('Amount must be positive')
+ .required('Amount is required')
+ .max(1e12, 'Amount is too large'),
+ recipient: Yup.string()
+ .required('Recipient address is required')
+ .manifestAddress('Invalid address format'),
+ });
+
const handleMint = async () => {
if (!amount || isNaN(Number(amount))) {
return;
@@ -173,86 +186,107 @@ export default function MintForm({
) : (
<>
- <>
-
-
-
-
YOUR BALANCE
-
{shiftDigits(balance, -exponent)}
-
-
-
EXPONENT
-
{denom?.denom_units[1]?.exponent}
-
-
-
CIRCULATING SUPPLY
-
{denom.display}
-
+
+
+
+
YOUR BALANCE
+
{shiftDigits(balance, -exponent)}
+
+
+
EXPONENT
+
{denom?.denom_units[1]?.exponent}
+
+
+
CIRCULATING SUPPLY
+
{denom.display}
-
-
-
-
setAmount(e.target.value)}
- />
-
-
-
-
- setRecipient(e.target.value)}
- />
+
+
{
+ setAmount(values.amount);
+ setRecipient(values.recipient);
+ handleMint();
+ }}
+ validateOnChange={true}
+ validateOnBlur={true}
+ >
+ {({ isValid, dirty, setFieldValue, errors, touched }) => (
+
-
- >
-
-
- {isMFX && (
-
+
)}
- setIsModalOpen(false)}
- payoutPairs={payoutPairs}
- updatePayoutPair={updatePayoutPair}
- addPayoutPair={addPayoutPair}
- removePayoutPair={removePayoutPair}
- handleMultiMint={handleMultiMint}
- isSigning={isSigning}
- />
-
+
+
setIsModalOpen(false)}
+ payoutPairs={payoutPairs}
+ updatePayoutPair={updatePayoutPair}
+ addPayoutPair={addPayoutPair}
+ removePayoutPair={removePayoutPair}
+ handleMultiMint={handleMultiMint}
+ isSigning={isSigning}
+ />
>
)}
diff --git a/components/react/inputs/BaseInput.tsx b/components/react/inputs/BaseInput.tsx
index 3e61e19c..0b89840d 100644
--- a/components/react/inputs/BaseInput.tsx
+++ b/components/react/inputs/BaseInput.tsx
@@ -22,7 +22,7 @@ export const BaseInput: React.FC
{meta.touched && meta.error ? (