Skip to content

Commit

Permalink
feat(transaction-leaves): add MayUseToken type and object to represen…
Browse files Browse the repository at this point in the history
…t token usage permissions

The MayUseToken type and object were added to represent the permissions for token usage in a transaction. It includes two boolean fields: parentsOwnToken to indicate if the parent owns the token, and inheritFromParent to specify if the token usage should be inherited from the parent.

The check method was also added to enforce the constraint that a transaction cannot both have the parent own the token and inherit the token usage from the parent at the same time.

This addition provides a structured way to handle token usage permissions within the transaction leaves.
  • Loading branch information
MartinMinkov committed Jul 11, 2024
1 parent df8c87e commit d293a68
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions mina-transaction/transaction-leaves.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export {
ReceiptChainHash,
StateHash,
TransactionVersion,
MayUseToken,
};

type AuthRequired = {
Expand Down Expand Up @@ -70,3 +71,21 @@ const TransactionVersion = {
...provable(UInt32),
empty: () => UInt32.from(protocolVersions.txnVersion),
};

type MayUseToken = {
parentsOwnToken: Bool;
inheritFromParent: Bool;
};
const MayUseToken = {
...provable({
parentsOwnToken: Bool,
inheritFromParent: Bool,
}),
check: ({ parentsOwnToken, inheritFromParent }: MayUseToken) => {
parentsOwnToken
.and(inheritFromParent)
.assertFalse(
'MayUseToken: parentsOwnToken and inheritFromParent cannot both be true'
);
},
};

0 comments on commit d293a68

Please sign in to comment.