feat: @metamask/delegation-core encoders and decoders now accept periodDuration as bigint#227
Merged
Merged
Conversation
… as either number of bigint - erc20tokenPeriodTransfer - nativeTokenPeriodTransfer - multiTokenPeriod - also adds missing tests for erc20TokenPeriodTransfer
cc55536 to
5be332a
Compare
periodDuration as bigintperiodDuration as bigint
5a3a6da to
3a7f12b
Compare
mj-kiwi
approved these changes
May 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📝 Description
MultiTokenPeriod,NativeTokenPeriodTransferandErc20TokenPeriodTransferenforcers encodeperiodDurationas UINT256. Becausenumberis the natural type for duration represented as seconds, it was chosen as theperiodDurationtype for the typescript interface.There's a case where the enforcer is used to encode a single allowance, where the period duration is simply set as
UINT256_MAX- meaning there's no real possibility of a second duration (unless you wait ~3.6 times 10^69 years).By making the config type generic with default value, the return type of
decodeXXXis unchanged, and a caller can specifyperiodDurationasbigint.🧪 How to Test?
This is a typing only change, as the encoders already work with
periodDurationvalues specified asbigint. New unit tests invoke theencodeXXXfunctions withperiodDurationasbigint.Non breaking.
List any breaking changes:
📋 Checklist
Check off completed items:
🔗 Related Issues
Link to related issues:
Closes #
Related to #
📚 Additional Notes
Any additional information, concerns, or context:
Note
Low Risk
Low risk typing/API-surface tweak: encoding already uses uint256 and runtime behavior is unchanged; primary impact is TypeScript types and added test coverage.
Overview
Adds
bigintsupport forperiodDurationinputs in theMultiTokenPeriod,ERC20TokenPeriodTransfer, andNativeTokenPeriodTransferterms/encoder APIs by making the term types generic and widening the encoder overloads tonumber | bigint.Keeps decode output unchanged (still decoding
periodDurationto anumber), and adds unit tests to ensure encoding accepts bigint durations and decoding normalizes them back to numbers. TheCHANGELOG.mdis updated to document the behavior change.Reviewed by Cursor Bugbot for commit 3a7f12b. Bugbot is set up for automated code reviews on this repo. Configure here.