From fdd52744508762643fa38cfe830d8a9390c72cd4 Mon Sep 17 00:00:00 2001 From: Martin Minkov Date: Sun, 14 Jul 2024 18:38:35 -0700 Subject: [PATCH] feat(transaction-leaves): add type checking for MayUseToken fields - Check if parentsOwnToken and inheritFromParent are instances of Bool - Throw an error if the fields are not of type Bool - This ensures that the correct types are passed to the MayUseToken object, preventing potential runtime errors due to incorrect types being used in the check function --- mina-transaction/transaction-leaves.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mina-transaction/transaction-leaves.ts b/mina-transaction/transaction-leaves.ts index 3dc7fe23..0d218c3d 100644 --- a/mina-transaction/transaction-leaves.ts +++ b/mina-transaction/transaction-leaves.ts @@ -82,6 +82,15 @@ const MayUseToken = { inheritFromParent: Bool, }), check: ({ parentsOwnToken, inheritFromParent }: MayUseToken) => { + if ( + !(parentsOwnToken instanceof Bool) || + !(inheritFromParent instanceof Bool) + ) { + throw Error( + 'MayUseToken: parentsOwnToken and inheritFromParent must be Bool' + ); + } + parentsOwnToken .and(inheritFromParent) .assertFalse(