-
Notifications
You must be signed in to change notification settings - Fork 45
Non-breaking reafactoring changes, with one bug fixed #675
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
Open
ReneDuris
wants to merge
8
commits into
multiversx:main
Choose a base branch
from
ReneDuris:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
Replace generic error message with descriptive ErrInvalidTuple that explains the issue and provides context for debugging. - Created ErrInvalidTuple error class - Updated Tuple.fromItems to use new error - Added test coverage for error cases Fixed TODO: Define a better error for tuple validation.
Replace hardcoded array2-array256 factory entries with dynamic parsing that can handle arbitrary array sizes automatically. - Created parseArrayType helper function in typeExpressionParser - Updated TypeMapper to use dynamic array parsing - Removed 11 hardcoded array factory entries - Added test coverage for arbitrary array sizes (array999, array1000, array5) Fixed TODO: Array types are hardcoded (array2, array6, array8, etc.). Need dynamic parsing.
Move conversion logic from NativeSerializer to respective type classes for better separation of concerns and encapsulation. - Added BytesValue.fromNative() for bytes conversion - Added StringValue.fromNative() for string conversion - Added AddressValue.fromNative() for address conversion - Added NumericalValue.fromNative() for numerical conversion - Updated NativeSerializer to use new static methods Fixed TODO: move logic to typesystem/bytes.ts Fixed TODO: move logic to typesystem/string.ts Fixed TODO: move logic to typesystem/address.ts Fixed TODO: move logic to typesystem/numerical.ts
Consolidate guardValueIsSet and guardValueIsSetWithMessage into a single function that handles both use cases automatically. - Updated guardValueIsSet to accept either variable name or custom message - Deprecated guardValueIsSetWithMessage (kept for backward compatibility) - Added JSDoc documentation Fixed TODO: merge with guardValueIsSetWithMessage Fixed TODO: merge with guardValueIsSet
Add type validation in OptionalValue, CompositeValue, VariadicValue, OptionValue, and List constructors to catch type mismatches early. - Added type assertions in OptionalValue constructor - Added type assertions in CompositeValue constructor - Added type assertions in VariadicValue constructor - Added type assertions in OptionValue constructor - Added type assertions in List constructor - Updated test to verify type validation correctly catches bugs Fixed TODO: assert value is of type type.getFirstTypeParameter() Fixed TODO: assert type of each item (wrt. type.getTypeParameters()) Fixed TODO: assert items are of type type.getFirstTypeParameter()
Split generic types into dedicated files for better code organization and maintainability while preserving backward compatibility. - Moved OptionType and OptionValue to genericOption.ts - Moved ListType and List to genericList.ts - Updated generic.ts to re-export from new files - All tests pass, full backward compatibility maintained Fixed TODO: Move to a new file, genericOption.ts Fixed TODO: Move to a new file, genericList.ts
The OptionValueBinaryCodec.decodeTopLevel() was incorrectly passing the inner type parameter (e.g., U32Type) directly to OptionValue constructor instead of wrapping it in an OptionType. This bug was hidden until type assertions were added in commit 71e165c. The assertions exposed that OptionValue was being constructed with wrong type, causing runtime errors when accessing type parameters. - Wrap inner type with OptionType before creating OptionValue - Import OptionType in option codec - Ensures type consistency and proper type parameter access Bug discovered by type assertions added in previous refactoring.
Extract complex recursive logic from ArgSerializer into dedicated helper classes for better maintainability and testability. This is a non-breaking refactor that keeps all public APIs unchanged. Created helper classes: - BufferReader: Sequential buffer reading with position tracking - BufferWriter: Buffer accumulation for serialization - TypeValueReader: Recursive reading logic for complex types - TypeValueWriter: Recursive writing logic for complex types Simplified ArgSerializer methods: - buffersToValues(): Now uses BufferReader + TypeValueReader - valuesToBuffers(): Now uses BufferWriter + TypeValueWriter Benefits: - Eliminated nested functions and complex closures - Better separation of concerns - Easier to test each component independently - More maintainable code structure - No breaking changes to public API Fixed TODO: Refactor, split (function is quite complex) in buffersToValues Fixed TODO: Refactor, split (function is quite complex) in valuesToBuffers
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.
This PR includes several improvements with no breaking changes:
Refactorings:
Merged duplicate guard utility functions
Added runtime type assertions in type system constructors for better error detection
Split generic types into separate files (genericOption.ts, genericList.ts)
Refactored ArgSerializer by extracting complex recursive logic into dedicated helper classes (BufferReader, BufferWriter, TypeValueReader, TypeValueWriter)
Bug Fix:
Fixed OptionValue type construction in option codec - was passing inner type instead of wrapped OptionType (bug exposed by new type assertions)
All changes maintain full backward compatibility. All tests passing.