diff --git a/src/hooks/utils/useCreateRoles.ts b/src/hooks/utils/useCreateRoles.ts index db6e8ad62..be978509b 100644 --- a/src/hooks/utils/useCreateRoles.ts +++ b/src/hooks/utils/useCreateRoles.ts @@ -915,6 +915,9 @@ export default function useCreateRoles() { throw new Error('Cannot prepare transactions for edited role without smart address'); } const newPredictedHatSmartAccount = await predictSmartAccount(BigInt(formHat.id)); + if (!newPredictedHatSmartAccount) { + throw new Error('Cannot predict smart account'); + } const newStreamTxData = createBatchLinearStreamCreationTx( newStreamsOnHat.map(stream => ({ ...stream, recipient: newPredictedHatSmartAccount })), ); diff --git a/src/store/roles/rolesStoreUtils.ts b/src/store/roles/rolesStoreUtils.ts index 5db97f48a..166bec4b6 100644 --- a/src/store/roles/rolesStoreUtils.ts +++ b/src/store/roles/rolesStoreUtils.ts @@ -134,7 +134,7 @@ export const predictAccountAddress = async (params: { tokenId, ]); if (!(await publicClient.getBytecode({ address: predictedAddress }))) { - throw new DecentHatsError('Predicted address is not a contract'); + return; } return predictedAddress; }; @@ -288,6 +288,10 @@ export const sanitize = async ( publicClient, }); + if (!topHatSmartAddress) { + throw new DecentHatsError('Top Hat smart address is not valid'); + } + const whitelistingVotingContract = whitelistingVotingStrategy ? getContract({ abi: abis.LinearERC20VotingWithHatsProposalCreation, @@ -320,6 +324,9 @@ export const sanitize = async ( tokenId: BigInt(rawAdminHat.id), publicClient, }); + if (!adminHatSmartAddress) { + throw new DecentHatsError('Admin Hat smart address is not valid'); + } const adminHat: DecentAdminHat = { id: rawAdminHat.id,