diff --git a/packages/apps/rwa-demo/src/app/(app)/page.tsx b/packages/apps/rwa-demo/src/app/(app)/page.tsx index 6d7f219040..e2c6a6d7c1 100644 --- a/packages/apps/rwa-demo/src/app/(app)/page.tsx +++ b/packages/apps/rwa-demo/src/app/(app)/page.tsx @@ -113,15 +113,15 @@ const Home = () => { {asset && ( <> diff --git a/packages/apps/rwa-demo/src/components/DistributionForm/DistributionForm.tsx b/packages/apps/rwa-demo/src/components/DistributionForm/DistributionForm.tsx index 538d87cb02..7287bfaa2d 100644 --- a/packages/apps/rwa-demo/src/components/DistributionForm/DistributionForm.tsx +++ b/packages/apps/rwa-demo/src/components/DistributionForm/DistributionForm.tsx @@ -15,6 +15,7 @@ import { cloneElement, useEffect, useRef, useState } from 'react'; import { Controller, useForm } from 'react-hook-form'; import { AssetPausedMessage } from '../AssetPausedMessage/AssetPausedMessage'; import { InvestorFrozenMessage } from '../InvestorFrozenMessage/InvestorFrozenMessage'; +import { NoComplianceMessage } from '../NoComplianceMessage/NoComplianceMessage'; import { SendTransactionAnimation } from '../SendTransactionAnimation/SendTransactionAnimation'; import type { ITransaction } from '../TransactionsProvider/TransactionsProvider'; @@ -106,7 +107,7 @@ export const DistributionForm: FC = ({ label="Amount" {...field} errorMessage={errors.amount?.message} - description={`max amount: ${maxAmount} `} + description={`max amount: ${maxAmount < 0 ? 0 : maxAmount} `} /> )} /> @@ -116,6 +117,7 @@ export const DistributionForm: FC = ({ <> + } > diff --git a/packages/apps/rwa-demo/src/components/InvestorBalance/InvestorBalance.tsx b/packages/apps/rwa-demo/src/components/InvestorBalance/InvestorBalance.tsx index 6592352054..8384153598 100644 --- a/packages/apps/rwa-demo/src/components/InvestorBalance/InvestorBalance.tsx +++ b/packages/apps/rwa-demo/src/components/InvestorBalance/InvestorBalance.tsx @@ -22,6 +22,7 @@ export const InvestorBalance: FC = ({ }); const { data: frozenData } = useGetFrozenTokens({ investorAccount }); + const cleanedBalance = balance < 0 ? 0 : balance; if (short) { return ( @@ -33,15 +34,15 @@ export const InvestorBalance: FC = ({ ]} account={investorAccount} /> - - {balance} ( {frozenData}) + + {cleanedBalance} ( {frozenData}) ); } return ( - + investorBalance:{' '} = ({ ]} account={investorAccount} /> - {balance} ( {frozenData}) + {cleanedBalance} ( {frozenData}) ); }; diff --git a/packages/apps/rwa-demo/src/components/NoComplianceMessage/NoComplianceMessage.tsx b/packages/apps/rwa-demo/src/components/NoComplianceMessage/NoComplianceMessage.tsx new file mode 100644 index 0000000000..0d4eae6f05 --- /dev/null +++ b/packages/apps/rwa-demo/src/components/NoComplianceMessage/NoComplianceMessage.tsx @@ -0,0 +1,19 @@ +import { useAsset } from '@/hooks/asset'; +import { Notification } from '@kadena/kode-ui'; +import type { FC } from 'react'; + +export const NoComplianceMessage: FC = () => { + const { asset } = useAsset(); + + if ( + (asset?.maxSupply ?? -1) >= 0 && + (asset?.maxBalance ?? -1) >= 0 && + (asset?.maxInvestors ?? -1) >= 0 + ) + return; + return ( + + There are no compliance rules set + + ); +}; diff --git a/packages/apps/rwa-demo/src/components/SetComplianceForm/SetComplianceForm.tsx b/packages/apps/rwa-demo/src/components/SetComplianceForm/SetComplianceForm.tsx index 12535cd2b8..d934e4ef60 100644 --- a/packages/apps/rwa-demo/src/components/SetComplianceForm/SetComplianceForm.tsx +++ b/packages/apps/rwa-demo/src/components/SetComplianceForm/SetComplianceForm.tsx @@ -23,7 +23,12 @@ export const SetComplianceForm: FC = ({ onClose, trigger }) => { const { asset } = useAsset(); const { setIsRightAsideExpanded, isRightAsideExpanded } = useLayout(); const [isOpen, setIsOpen] = useState(false); - const { handleSubmit, reset, control } = useForm({ + const { + handleSubmit, + reset, + control, + formState: { isValid }, + } = useForm({ defaultValues: { maxBalance: `${asset?.maxBalance ?? 0}`, maxSupply: `${asset?.maxSupply ?? 0}`, @@ -67,7 +72,7 @@ export const SetComplianceForm: FC = ({ onClose, trigger }) => { ( )} @@ -76,7 +81,7 @@ export const SetComplianceForm: FC = ({ onClose, trigger }) => { ( )} @@ -84,7 +89,7 @@ export const SetComplianceForm: FC = ({ onClose, trigger }) => { ( = ({ onClose, trigger }) => { - diff --git a/packages/apps/rwa-demo/src/components/TransactionsProvider/TransactionsProvider.tsx b/packages/apps/rwa-demo/src/components/TransactionsProvider/TransactionsProvider.tsx index 752b4f2ec5..d53beb3d56 100644 --- a/packages/apps/rwa-demo/src/components/TransactionsProvider/TransactionsProvider.tsx +++ b/packages/apps/rwa-demo/src/components/TransactionsProvider/TransactionsProvider.tsx @@ -148,7 +148,7 @@ export const TransactionsProvider: FC = ({ children }) => { }, ); - return true; + return 2222; }, [], ); diff --git a/packages/apps/rwa-demo/src/hooks/getAgents.ts b/packages/apps/rwa-demo/src/hooks/getAgents.ts index 4f4659a424..fbf014fdcd 100644 --- a/packages/apps/rwa-demo/src/hooks/getAgents.ts +++ b/packages/apps/rwa-demo/src/hooks/getAgents.ts @@ -39,12 +39,14 @@ export const useGetAgents = () => { variables: { qualifiedName: `${getAsset()}.AGENT-ADDED`, }, + fetchPolicy: 'no-cache', }); const { data: removedData, loading: removedLoading } = useEventsQuery({ variables: { qualifiedName: `${getAsset()}.AGENT-REMOVED`, }, + fetchPolicy: 'no-cache', }); const { data: subscriptionAddData } = useEventSubscriptionSubscription({ diff --git a/packages/apps/rwa-demo/src/hooks/getInvestors.ts b/packages/apps/rwa-demo/src/hooks/getInvestors.ts index 1b2a83b752..2c8a02955c 100644 --- a/packages/apps/rwa-demo/src/hooks/getInvestors.ts +++ b/packages/apps/rwa-demo/src/hooks/getInvestors.ts @@ -25,12 +25,14 @@ export const useGetInvestors = () => { variables: { qualifiedName: `${getAsset()}.IDENTITY-REGISTERED`, }, + fetchPolicy: 'no-cache', }); const { data: removedData, loading: removedLoading } = useEventsQuery({ variables: { qualifiedName: `${getAsset()}.IDENTITY-REMOVED`, }, + fetchPolicy: 'no-cache', }); const { data: addedSubscriptionData } = useEventSubscriptionSubscription({ diff --git a/packages/apps/rwa-demo/src/utils/store/index.ts b/packages/apps/rwa-demo/src/utils/store/index.ts index 41c9b6ff3f..b7db3a7fc5 100644 --- a/packages/apps/rwa-demo/src/utils/store/index.ts +++ b/packages/apps/rwa-demo/src/utils/store/index.ts @@ -10,7 +10,10 @@ const RWAStore = () => { const addTransaction = async (data: ITransaction) => { const asset = getAssetFolder(); - await set(ref(database, `${asset}/transactions/${data.uuid}`), data); + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const { listener, ...newData } = data; + + await set(ref(database, `${asset}/transactions/${data.uuid}`), newData); }; const removeTransaction = async (data: ITransaction) => {