-
Notifications
You must be signed in to change notification settings - Fork 6
Add BigInt field type for safe handling of large integers #199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Add new BigIntField component with integer-only validation - Map 64-bit+ integers to bigint field type (EVM: uint64/128/256, Stellar: U64/128/256) - Add createBigIntTransform() for string-based value handling - Update field type dropdown to include bigint in numeric category - Simplify adapter field generation by removing redundant validation - Update all tests for new bigint mappings Fixes #194
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new BigInt field type to safely handle large integers beyond JavaScript's Number.MAX_SAFE_INTEGER (2^53-1), preventing precision loss for blockchain integer types like uint256.
- Adds dedicated
BigIntFieldcomponent with built-in validation for large integer inputs - Updates EVM and Stellar adapters to map 64-bit+ integers to
bigintfield type - Implements string-based storage to avoid JavaScript Number precision limitations
Reviewed Changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
packages/types/src/forms/fields.ts |
Adds bigint to FieldType union and value mapping |
packages/ui/src/components/fields/BigIntField.tsx |
New component for large integer input with validation |
packages/ui/src/components/fields/index.ts |
Exports BigIntField component |
packages/renderer/src/utils/formUtils.ts |
Adds createBigIntTransform for string-based transforms |
packages/renderer/src/components/fieldRegistry.ts |
Registers BigIntField in component registry |
packages/utils/src/fieldDefaults.ts |
Adds bigint case to getDefaultValueForType |
packages/adapter-evm/src/mapping/constants.ts |
Maps 64-bit+ integer types to bigint |
packages/adapter-stellar/src/mapping/constants.ts |
Maps 64-bit+ integer types to bigint |
| Multiple test files | Updates tests to reflect bigint mapping changes |
packages/builder/src/components/UIBuilder/StepFormCustomization/utils/fieldTypeUtils.ts |
Adds bigint to field type labels and groups |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
- Replace fragile pattern string comparison with direct value testing in validation.ts - Remove duplicated integer validation logic in BigIntField by using pattern property instead - Introduce consistent regex constants (INTEGER_PATTERN for validation, INTEGER_INPUT_PATTERN for input) - Simplify validation flow by delegating pattern validation to validateField utility All tests passing ✅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 20 out of 20 changed files in this pull request and generated 2 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
- Create integerValidation.ts with shared pattern constants (INTEGER_PATTERN, INTEGER_INPUT_PATTERN, INTEGER_HTML_PATTERN) - Update validation.ts to use shared INTEGER_PATTERN constant - Update BigIntField.tsx to use all shared constants - Ensures consistency across validation logic and HTML attributes Addresses Copilot review feedback about pattern duplication and inconsistency between JavaScript patterns and HTML pattern attribute. All tests passing ✅
Summary
Fixes #194
This PR introduces a new BigInt field type to safely handle large integers beyond JavaScript's
Number.MAX_SAFE_INTEGER(2^53-1), preventing precision loss for values likeuint256.Changes
🆕 New Components
BigIntField.tsx(250 lines): Dedicated component for large integer handling with built-in validationcreateBigIntTransform(): Transform function that keeps values as strings to avoid precision loss🔧 Core Updates
'bigint'toFieldTypeuniongetDefaultValueForType()to support bigint fields🌐 Adapter Changes (EVM & Stellar)
uint64,uint128,uint256,int64,int128,int256)U64,U128,U256,I64,I128,I256)🧪 Testing
Architecture Benefits
✅ Chain-Agnostic Core - No blockchain-specific logic in core components
✅ DRY Principle - Validation defined once in component
✅ Type Safety - Proper TypeScript typing throughout
✅ Separation of Concerns - Adapters map types, components handle UI/validation
Breaking Changes
'bigint'field type instead of'number'Changeset Included
✅ Comprehensive changeset documenting all package changes and version bumps