idBuilder now accepts either number or bigint#14
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
Adds support for passing both number and bigint to idBuilder, with corresponding validation and test updates.
- Extend
idBuilderto acceptbigint | numberand normalize numbers tobigint - Update unit tests to import
maxUint256, remove obsolete cases, and add a large-bigintscenario - Adjust
createCaveatBuildertest to useBigIntfor theidcaveat
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/delegation-toolkit/src/caveatBuilder/idBuilder.ts | Expanded parameter type, added type checks/validation |
| packages/delegation-toolkit/test/caveatBuilder/idBuilder.test.ts | Updated tests for bigint support and new edge cases |
| packages/delegation-toolkit/test/caveatBuilder/createCaveatBuilder.test.ts | Switched id test value to BigInt |
Comments suppressed due to low confidence (3)
packages/delegation-toolkit/test/caveatBuilder/idBuilder.test.ts:27
- We cover the negative
bigintcase, but not a negativenumber. Add a test likeexpect(() => buildWithId(-1)).to.throw('Invalid id: must be positive')to ensure number inputs are also validated.
const invalidId = -1n;
packages/delegation-toolkit/test/caveatBuilder/createCaveatBuilder.test.ts:241
- The test now only uses a
bigintforid. Consider adding a parallel case with anumberinput to verifycreateCaveatBuilderhandles both types.
const id = BigInt(Math.floor(Math.random() * 2 ** 32));
packages/delegation-toolkit/src/caveatBuilder/idBuilder.ts:27
- This runtime check is redundant since
idValueis already narrowed tobigintin prior branches. Consider removing to simplify the logic.
if (typeof idValue !== 'bigint') {
3a637d5 to
0f7e334
Compare
V00D00-child
approved these changes
Jun 30, 2025
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
Previous
idBuilderrequired the id to be passed as anumbertype, which restricted the id up toNumber.MAX_SAFE_INTEGER.With this change, the
idBuildernow accepts either abigintornumber:🧪 How to Test?
This is sufficiently covered in unit tests, validating both number and bigint. The above code snippets can be used to manually validate the behaviour.
List any breaking changes:
📋 Checklist
Check off completed items: