Skip to content

Expose the ledger entry key as an XdrLedgerKey - #203

Merged
christian-rogobete merged 1 commit into
mainfrom
hardening-ledger-key
Nov 5, 2026
Merged

christian-rogobete merged 1 commit into
mainfrom
hardening-ledger-key

Conversation

@christian-rogobete

Copy link
Copy Markdown
Member

Fixes a defect in LedgerEntry. Before this change, getKeyXdr() decoded the base64 key of a getLedgerEntries entry, a LedgerKey, as an XdrSCVal, so it returned a value of an unrelated type for every entry. The key of an account entry read as SCV_BOOL false, the key of a contract data entry as an SCV_I64. The docblock presented the result as the key of the ledger entry.

This change:

  • Adds getLedgerKeyXdr(), which decodes the key as an XdrLedgerKey.
  • Deprecates getKeyXdr() in its docblock with a message that names the new getter, and keeps its result as it was.
  • Asserts the decoded keys of an account entry and a contract data entry and their round trip to the response key.

The unit suite passes.

Closes #202

Fixes a defect in `LedgerEntry`. Before this change, `getKeyXdr()`
decoded the base64 `key` of a `getLedgerEntries` entry, a `LedgerKey`,
as an `XdrSCVal`, so it returned a value of an unrelated type for every
entry. The key of an account entry read as `SCV_BOOL` false, the key of
a contract data entry as an `SCV_I64`. The docblock presented the result
as the key of the ledger entry.

This change:

- Adds `getLedgerKeyXdr()`, which decodes the key as an `XdrLedgerKey`.
- Deprecates `getKeyXdr()` in its docblock with a message that names the
  new getter, and keeps its result as it was.
- Asserts the decoded keys of an account entry and a contract data entry
  and their round trip to the response key.

The unit suite passes.

Closes #202
@codecov

codecov Bot commented Nov 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.47%. Comparing base (90b0041) to head (0c876fa).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##               main     #203   +/-   ##
=========================================
  Coverage     93.47%   93.47%           
- Complexity    21621    21622    +1     
=========================================
  Files          1006     1006           
  Lines         52422    52424    +2     
=========================================
+ Hits          49001    49003    +2     
  Misses         3421     3421           
Files with missing lines Coverage Δ
...oneso/StellarSDK/Soroban/Responses/LedgerEntry.php 94.73% <100.00%> (+0.29%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@christian-rogobete
christian-rogobete merged commit fb1224d into main Nov 5, 2026
10 checks passed
@christian-rogobete
christian-rogobete deleted the hardening-ledger-key branch November 5, 2026 03:29
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.

LedgerEntry::getKeyXdr() decodes the ledger key as an SCVal

1 participant