-
Notifications
You must be signed in to change notification settings - Fork 0
feat: implement MLXDR operations bundle handling #21
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
- Added support for operations bundles in MLXDR by introducing new methods: - `fromOperationsBundle`: Converts an array of Moonlight operations to an MLXDR operations bundle. - `toOperationsBundle`: Converts an MLXDR operations bundle back to an array of Moonlight operations. - Added validation for operations bundles in `isOperationsBundle`. - Updated `MLXDRTypeByte` enum to include `OperationsBundle` and adjusted `TransactionBundle` value. - Created unit tests for operations bundle functionality in `index.unit.test.ts` to ensure correct conversion and validation of operations bundles. - Refactored imports in `index.unit.test.ts` and `signing.unit.test.ts` for consistency and clarity.
- Updated imports in src/custom-xdr/index.unit.test.ts to use type imports for operation types. - Removed unused imports and variables in src/transaction-builder/signing.unit.test.ts to enhance code clarity and maintainability.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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 implements operations bundle handling in MLXDR (Moonlight XDR) format, allowing multiple Moonlight operations to be serialized and deserialized as a single bundle. The changes include new conversion methods, validation functions, comprehensive unit tests, and a breaking change to the MLXDRTypeByte enum to accommodate the new OperationsBundle type.
Key Changes:
- Added
fromOperationsBundleandtoOperationsBundlemethods to convert between operation arrays and MLXDR format - Introduced
OperationsBundletype byte (0x08) and shiftedTransactionBundleto 0x09 - Created comprehensive test suite covering single operations, multiple operations, mixed operation types, and signed operations
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/custom-xdr/types.ts | Added OperationsBundle enum value (0x08) and shifted TransactionBundle to 0x09 |
| src/custom-xdr/index.ts | Implemented operationsBundleToMLXDR, MLXDRtoOperationsBundle, and isOperationsBundle functions; exported new methods in MLXDR module |
| src/custom-xdr/index.unit.test.ts | Added comprehensive test suite for operations bundle functionality covering various scenarios including signed operations |
| src/transaction-builder/signing.unit.test.ts | New test file verifying signature consistency between individual operations and bundle operations |
| src/operation/index.unit.test.ts | Fixed import path from external package to local module and corrected describe block name from "Condition" to "Operation" |
| deno.json | Bumped version from 0.5.0 to 0.6.0 |
Comments suppressed due to low confidence (1)
src/custom-xdr/index.ts:385
- The module documentation (JSDoc comment) should be updated to mention operations bundles. The comment currently only mentions "Condition/Operation objects" but now also supports operations bundles.
Consider updating the documentation to:
/**
* * MLXDR Module
*
* This module provides functions to work with Moonlight's custom XDR format (MLXDR).
* It includes utilities to check if data is in MLXDR format, identify the type of MLXDR data,
* and convert between standard Condition/Operation objects, operations bundles, and their MLXDR representations.
*
* All MLXDR data is encoded as a BASE64 string prefixed with 'ML' to distinguish it from standard Stellar XDR.
* The first byte after the prefix indicates the object type (e.g., Create Condition, Deposit Operation, Operations Bundle, etc.).
*
* Example MLXDR encoding for a Spend Operation:
* - Decoded Bytes:
* - 0x30 0xb0: 'ML' Prefix
* - 0x05: Type Byte for Spend Operation
* - 0x...: Actual XDR Data
*//**
* * MLXDR Module
*
* This module provides functions to work with Moonlight's custom XDR format (MLXDR).
* It includes utilities to check if data is in MLXDR format, identify the type of MLXDR data,
* and convert between standard Condition/Operation objects and their MLXDR representations.
*
* All MLXDR data is encoded as a BASE64 string prefixed with 'ML' to distinguish it from standard Stellar XDR.
* The first byte after the prefix indicates the object type (e.g., Create Condition, Deposit Operation, etc.).
*
* Example MLXDR encoding for a Spend Operation:
* - Decoded Bytes:
* - 0x30 0xb0: 'ML' Prefix
* - 0x05: Type Byte for Spend Operation
* - 0x...: Actual XDR Data
*/
…on and update test imports
Added support for operations bundles in MLXDR by introducing new methods:
fromOperationsBundle: Converts an array of Moonlight operations to an MLXDR operations bundle.toOperationsBundle: Converts an MLXDR operations bundle back to an array of Moonlight operations.isOperationsBundle.Updated
MLXDRTypeByteenum to includeOperationsBundleand adjustedTransactionBundlevalue.Created unit tests for operations bundle functionality in
index.unit.test.tsto ensure correct conversion and validation of operations bundles.Refactored imports in
index.unit.test.tsandsigning.unit.test.tsfor consistency and clarity.