diff --git a/.changeset/lovely-pots-sleep.md b/.changeset/lovely-pots-sleep.md new file mode 100644 index 0000000000..a845151cc8 --- /dev/null +++ b/.changeset/lovely-pots-sleep.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/packages/apps/rwa-demo/src/components/TableFormatters/FormatDeleteInvestor.tsx b/packages/apps/rwa-demo/src/components/TableFormatters/FormatDeleteInvestor.tsx index cc393ed546..59a59e1fb1 100644 --- a/packages/apps/rwa-demo/src/components/TableFormatters/FormatDeleteInvestor.tsx +++ b/packages/apps/rwa-demo/src/components/TableFormatters/FormatDeleteInvestor.tsx @@ -18,8 +18,6 @@ export const FormatDeleteInvestor = () => { investorAccount, }); - console.log(notAllowedReason); - const handleDelete = async () => { await submit({ investor: investorAccount }); }; diff --git a/packages/apps/rwa-demo/src/components/TransactionsProvider/TransactionsProvider.tsx b/packages/apps/rwa-demo/src/components/TransactionsProvider/TransactionsProvider.tsx index d53beb3d56..f848121757 100644 --- a/packages/apps/rwa-demo/src/components/TransactionsProvider/TransactionsProvider.tsx +++ b/packages/apps/rwa-demo/src/components/TransactionsProvider/TransactionsProvider.tsx @@ -88,6 +88,9 @@ const interpretMessage = (str: string, data?: ITransaction): string => { if (str?.includes('buy gas failed')) { return `This account does not have enough balance to pay for Gas`; } + if (str?.includes('exceeds max investor')) { + return `The maximum amount of investors has been reached`; + } return `${data?.type}: ${str}`; }; @@ -124,11 +127,20 @@ export const TransactionsProvider: FC = ({ children }) => { r.subscribe( (nextData: any) => { - if (nextData?.errors?.length !== undefined) { + if ( + nextData?.errors?.length !== undefined || + nextData?.data?.transaction?.result.badResult + ) { addNotification({ intent: 'negative', label: 'there was an error', - message: JSON.stringify(nextData?.errors), + message: interpretErrorMessage( + nextData?.errors + ? JSON.stringify(nextData?.errors) + : JSON.parse( + nextData?.data.transaction?.result.badResult ?? '{}', + ).message, + ), url: `https://explorer.kadena.io/${activeNetwork.networkId}/transaction/${data.requestKey}`, }); return; diff --git a/packages/apps/rwa-demo/src/hooks/distributeTokens.ts b/packages/apps/rwa-demo/src/hooks/distributeTokens.ts index 3edbdab269..96cb2c245c 100644 --- a/packages/apps/rwa-demo/src/hooks/distributeTokens.ts +++ b/packages/apps/rwa-demo/src/hooks/distributeTokens.ts @@ -2,6 +2,7 @@ import { interpretErrorMessage, TXTYPES, } from '@/components/TransactionsProvider/TransactionsProvider'; +import { INFINITE_COMPLIANCE } from '@/constants'; import type { IDistributeTokensProps } from '@/services/distributeTokens'; import { distributeTokens } from '@/services/distributeTokens'; import { getClient } from '@/utils/client'; @@ -56,8 +57,12 @@ export const useDistributeTokens = ({ !paused && accountRoles.isSupplyModifier() && !isActiveAccountChangeTx && - ((asset.maxSupply >= 0 && asset.supply < asset.maxSupply) || - asset.maxSupply < 0), + ((asset.maxSupply > INFINITE_COMPLIANCE && + asset.supply < asset.maxSupply) || + asset.maxSupply === INFINITE_COMPLIANCE) && + ((asset.maxInvestors > INFINITE_COMPLIANCE && + asset.maxInvestors > asset.investorCount) || + asset.maxInvestors === INFINITE_COMPLIANCE), ); }, [ frozen, diff --git a/packages/apps/rwa-demo/src/services/pact/modelcontract.ts b/packages/apps/rwa-demo/src/services/pact/modelcontract.ts index b6ca9110df..e4e9b86a9f 100644 --- a/packages/apps/rwa-demo/src/services/pact/modelcontract.ts +++ b/packages/apps/rwa-demo/src/services/pact/modelcontract.ts @@ -1369,5 +1369,5 @@ export const getContract = ({ contractName, namespace }: IAddContractProps) => ` (RWA.token-mapper.add-token-ref TOKEN-ID ${namespace}.${contractName}) -(${namespace}.${contractName}.init "${contractName}" "MVP" 0 "kadenaID" "0.0" [RWA.max-balance-compliance RWA.supply-limit-compliance] false (keyset-ref-guard "${namespace}.admin-keyset")) +(${namespace}.${contractName}.init "${contractName}" "MVP" 0 "kadenaID" "0.0" [RWA.max-balance-compliance RWA.supply-limit-compliance RWA.max-investors-compliance] false (keyset-ref-guard "${namespace}.admin-keyset")) `;