Skip to content

Conversation

@fazzatti
Copy link
Contributor

  • 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.

- 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
Copy link

codecov bot commented Nov 14, 2025

Codecov Report

❌ Patch coverage is 76.00000% with 12 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/custom-xdr/index.ts 76.00% 12 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copilot finished reviewing on behalf of fazzatti November 14, 2025 17:42
Copy link
Contributor

Copilot AI left a 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 fromOperationsBundle and toOperationsBundle methods to convert between operation arrays and MLXDR format
  • Introduced OperationsBundle type byte (0x08) and shifted TransactionBundle to 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
 */

@fazzatti fazzatti requested a review from toruguera November 14, 2025 18:03
@fazzatti fazzatti merged commit e290dae into dev Nov 14, 2025
2 checks passed
@fazzatti fazzatti deleted the feat/add-mlxdr-encoding-for-operations-bundle branch November 14, 2025 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants