Repository navigation
feat: add public getter for current ledger sequence (#15) - #320
Open
Rodrigoue9 wants to merge 1 commit into
Open
Rodrigoue9 wants to merge 1 commit into
Rodrigoue9 wants to merge 1 commit into
Conversation
Rodrigoue9
force-pushed
the
feat/issue-15-get-ledger-sequence
branch
from
October 3, 2026 16:05
41f3311 to
ff8c252
Compare
This was referenced Oct 7, 2026
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
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.
Summary
What was wrong
External services and integrating contracts need an authentic on-chain reference to the current chain-time (ledger sequence number). Previously,
VeroContractdid not expose a public getter for the ledger sequence, forcing external integrations to query the Stellar RPC directly or duplicate chain-state queries.What was done & Alternatives Considered
This pull request introduces a lightweight, public read-only getter
pub fn get_ledger(env: Env) -> u32on the core contract interface that returnsenv.ledger().sequence().env.ledger().timestamp()) instead of or alongside sequence. Rejected because Issue feat: add public getter for current ledger sequence #15 specifically requests sequence number, which is discrete and monotonic across Stellar consensus ledgers.src/lib.rs. Rejected because external smart contracts and off-chain RPC clients invoke Soroban contracts through the#[contractimpl]interface; placing the method insrc/contracts/proxy_entry/entry_config.rsmakes it an exposed entrypoint onVeroContractandVeroContractClient.What to look at
get_ledgerintentionally does NOT gate oncircuit_breaker::require_not_paused(&env)or require contract initialization. This ensures external observers and oracle monitors can query chain sequence even during emergency pauses or prior to initialization.How verified
tests/init.rsverifying default sequence, mocked advances, post-initialization consistency, and availability during emergency pause.cargo fmt --all -- --check,cargo clippy --workspace --all-targets -- -D clippy::all).Related Issue
Closes #15
Changes Made
src/contracts/proxy_entry/entry_config.rs):pub fn get_ledger(env: Env) -> u32returningenv.ledger().sequence().tests/init.rs):test_get_ledger_sequenceto verify sequence reflection against default environment, mocked sequence advances (100, 500, 1000, 10000), across contract initialization, and confirmed readability remains unblocked even when the contract is paused.Testing Performed
cargo test --test init: 8/8 tests passed.cargo fmt --all -- --check: formatting 100% compliant.cargo clippy --workspace --all-targets -- -D clippy::all: 0 warnings, 0 errors.Checklist
Closes #15.cargo fmt --check.cargo clippy -- -D warningswhere applicable.