Skip to content

Add .operations() and .changes() method to TransactionResultMeta#542

Open
hakymulla wants to merge 5 commits into
stellar:mainfrom
hakymulla:internal_operations
Open

Add .operations() and .changes() method to TransactionResultMeta#542
hakymulla wants to merge 5 commits into
stellar:mainfrom
hakymulla:internal_operations

Conversation

@hakymulla

Copy link
Copy Markdown

What

Add .operations() and .changes() to TransactionResultMeta that returns ref to internal operations

Why

Closes #460

Known limitations

[TODO or N/A]

Copilot AI review requested due to automatic review settings June 10, 2026 06:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a public transaction_meta module with helpers to access operations and iterate ledger entry changes from TransactionResultMeta, along with new tests covering several transaction meta versions.

Changes:

  • Introduce TransactionResultMeta::operations() returning an enum ref over V0–V3 vs V4 operation meta.
  • Introduce TransactionResultMeta::changes() to iterate ledger entry changes derived from tx apply processing operations.
  • Add Rust tests validating operations() and changes() behavior across meta versions.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

File Description
tests/transaction_meta.rs Adds unit tests for TransactionResultMeta::operations() and changes() across V0/V1/V4.
src/transaction_meta.rs Introduces OperationsMetaRef and implements operations() + changes() on TransactionResultMeta.
src/lib.rs Exposes the new transaction_meta module publicly.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/transaction_meta.rs Outdated
Comment on lines +20 to +34
pub fn changes(&self) -> impl Iterator<Item = &LedgerEntryChange> {
let tx_apply_processing_ledgers: Box<dyn Iterator<Item = &LedgerEntryChange>> =
match &self.tx_apply_processing {
TransactionMeta::V0(operation_meta) => {
let res = operation_meta.iter().flat_map(|op| op.changes.0.iter());
Box::new(res)
}

TransactionMeta::V1(operation_meta) => {
let iter = operation_meta
.operations
.iter()
.flat_map(|op| op.changes.0.iter());
Box::new(iter)
}
Comment thread src/lib.rs
Comment on lines 160 to +163
#[cfg(feature = "alloc")]
pub(crate) mod num128;

pub mod transaction_meta;
Comment thread src/transaction_meta.rs Outdated
Comment on lines +20 to +22
pub fn changes(&self) -> impl Iterator<Item = &LedgerEntryChange> {
let tx_apply_processing_ledgers: Box<dyn Iterator<Item = &LedgerEntryChange>> =
match &self.tx_apply_processing {
Comment thread src/transaction_meta.rs Outdated
Comment on lines +9 to +10
impl<'a> TransactionResultMeta {
pub fn operations(&'a self) -> OperationsMetaRef<'a> {
Comment thread tests/transaction_meta.rs Outdated
@@ -0,0 +1,256 @@
#![cfg(feature = "alloc")]

use std::vec;
Comment thread tests/transaction_meta.rs Outdated
Comment on lines +200 to +201
let thrid_ledger_name = &ops.get(2).unwrap().changes.get(0).unwrap().name();
assert_eq!(*thrid_ledger_name, "Updated");

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ee6fd47b16

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/transaction_meta.rs
}

pub fn changes(&self) -> impl Iterator<Item = &LedgerEntryChange> {
let tx_apply_processing_ledgers: Box<dyn Iterator<Item = &LedgerEntryChange>> =

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Avoid std-prelude Box in no_std builds

In non-std feature sets this module is still compiled, but Box is only available from the std prelude here; the crate advertises supported no_std profiles with alloc or even without alloc, so cargo check --no-default-features --features alloc / --no-default-features will fail to resolve this Box (and the no-alloc profile cannot allocate a boxed iterator at all). Please either gate this API on alloc and import alloc::boxed::Box, or return a non-allocating concrete iterator/enumeration so the supported no_std configurations keep compiling.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2f51dfe5fe

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/transaction_meta.rs Outdated
Comment on lines +43 to +47
let iter = operation_meta
.operations
.iter()
.flat_map(|op| op.changes.0.iter())
.chain(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve txChangesBefore ordering

For V2/V3/V4 metadata, tx_changes_before is explicitly the transaction-level changes before operations are applied, but this iterator starts with operation changes and only then appends tx_changes_before. When a transaction has both before-level and operation-level ledger changes, changes() returns them as fee, operation, before, after instead of fee, before, operation, after, so consumers replaying this helper see a non-chronological ledger-change stream.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1e7ed3b0b2

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/transaction_meta.rs Outdated
Comment on lines +34 to +38
let iter = operation_meta
.operations
.iter()
.flat_map(|op| op.changes.0.iter())
.chain(operation_meta.tx_changes.0.iter());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Yield V1 transaction changes before operation changes

When V1 metadata has both tx_changes and per-operation changes, this iterator emits the operation changes first and the transaction-level changes last, even though the V1 metadata stores tx_changes before operations (matching the older transaction-level-before-operation layout that V2 later made explicit with tx_changes_before). Consumers using changes() to replay or inspect the metadata stream in order will see V1 changes in a different order from the metadata for those transactions.

Useful? React with 👍 / 👎.

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.

Add .operations() and .changes() to TransactionResultMeta that returns ref to internal operations

2 participants