Skip to content

Commit 5e43b65

Browse files
fix approval revocation reserved-bit messaging
Co-authored-by: jeffsmale90 <jeffsmale90@users.noreply.github.com>
1 parent 89622a8 commit 5e43b65

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

packages/delegation-core/src/caveats/approvalRevocationEnforcer.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,16 +107,16 @@ function termsToMask(terms: ApprovalRevocationTerms): number {
107107
}
108108

109109
/**
110-
* Parses a validated 1..7 bitmask into {@link ApprovalRevocationTerms}.
110+
* Parses a validated 1..63 bitmask into {@link ApprovalRevocationTerms}.
111111
*
112-
* @param mask - Integer byte value; only bits 0-2 may be set, and at least one must be set.
112+
* @param mask - Integer byte value; only bits 0-5 may be set, and at least one must be set.
113113
* @returns Flag object for encoding/decoding.
114114
* @throws Error if reserved bits are set or the mask is zero.
115115
*/
116116
function maskToTerms(mask: number): ApprovalRevocationTerms {
117117
if (mask > ALLOWED_APPROVAL_REVOCATION_MAX_MASK) {
118118
throw new Error(
119-
'Invalid ApprovalRevocation terms: reserved bits must be zero (only bits 0-2 are defined)',
119+
'Invalid ApprovalRevocation terms: reserved bits must be zero (only bits 0-5 are defined)',
120120
);
121121
}
122122

packages/delegation-core/test/caveats/approvalRevocationEnforcer.test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ const ALL_VALID_TERM_SETS: ApprovalRevocationTerms[] = Array.from(
3232
},
3333
);
3434

35+
const RESERVED_BITS_ERROR =
36+
'Invalid ApprovalRevocation terms: reserved bits must be zero (only bits 0-5 are defined)';
37+
3538
describe('ApprovalRevocationEnforcer', () => {
3639
describe('createApprovalRevocationTerms', () => {
3740
const BYTE_LEN = 1;
@@ -184,13 +187,13 @@ describe('ApprovalRevocationEnforcer', () => {
184187

185188
it('throws when reserved bits are set on-chain', () => {
186189
expect(() => decodeApprovalRevocationTerms('0x40')).toThrow(
187-
'reserved bits must be zero',
190+
RESERVED_BITS_ERROR,
188191
);
189192
expect(() => decodeApprovalRevocationTerms('0x80')).toThrow(
190-
'reserved bits must be zero',
193+
RESERVED_BITS_ERROR,
191194
);
192195
expect(() => decodeApprovalRevocationTerms('0xff')).toThrow(
193-
'reserved bits must be zero',
196+
RESERVED_BITS_ERROR,
194197
);
195198
});
196199

0 commit comments

Comments
 (0)