Skip to content

Commit

Permalink
feat(transaction-leaves): add type checking for MayUseToken fields
Browse files Browse the repository at this point in the history
  - 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
  • Loading branch information
MartinMinkov committed Jul 15, 2024
1 parent d293a68 commit fdd5274
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions mina-transaction/transaction-leaves.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit fdd5274

Please sign in to comment.