Repository navigation
chore: return the crate's semver from version() in all three contracts - #67
Merged
codemagician1949 merged 1 commit intoAug 25, 2026
Merged
Conversation
All three contracts already exposed version(), but as a hand-maintained u32
ABI marker — invoice-registry returned 2, pool-manager 1, repayment-waterfall
2. Those numbers were not tied to anything: nothing stopped a release from
bumping Cargo.toml while the on-chain value stayed where it was, and an
integrator reading version() off a deployed contract could not map the answer
back to a published crate.
version() now returns the crate's semver as a soroban_sdk::String, read from
CARGO_PKG_VERSION at compile time so the manifest and the on-chain value
cannot drift by construction.
soroban_sdk::String is written fully qualified rather than imported. Each of
the three crates would otherwise need String added to its `use
soroban_sdk::{...}` block, and the codebase already uses the qualified form
elsewhere (invoice_transfer_history returns soroban_sdk::Vec<TransferRecord>),
so this follows existing practice rather than introducing a style.
Tests, one per crate, assert version() equals CARGO_PKG_VERSION rather than a
literal, so a version bump cannot leave a stale assertion passing:
- invoice-registry: replaces test_version_returns_two, whose name and its
assertion both had to change anyway
- pool-manager and repayment-waterfall: new tests alongside the existing suites
tests/integration.rs asserted the three old integers and now asserts "0.1.0"
as a literal. Deliberately not written against that test crate's own
CARGO_PKG_VERSION — the root crate happens to share the version today, so
doing so would look like a coupling that does not exist. Binding each contract
to its own manifest is what the per-crate unit tests do.
Interface change for integrators: version() returns String, not u32.
cargo test --workspace passes (141 tests), cargo check --workspace is clean,
and the release wasm build stays inside the 64KB per-contract CI limit.
Contributor
|
Nice job @Alheriii |
3 tasks
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.
Closes #1
Summary
All three contracts already exposed
version(), but as a hand-maintainedu32ABI marker — invoice-registry returned2, pool-manager1, repayment-waterfall2.Those numbers were not tied to anything. Nothing stopped a release from bumping
Cargo.tomlwhile the on-chain value stayed put, and an integrator readingversion()off a deployed contract could not map the answer back to a published crate. That is the gap the issue is closing.version()now returns the crate's semver as asoroban_sdk::String, read fromCARGO_PKG_VERSIONat compile time — so the manifest and the on-chain value cannot drift by construction, rather than by discipline.soroban_sdk::Stringis written fully qualified rather than imported. Each of the three crates would otherwise needStringadded to itsuse soroban_sdk::{...}block, and the codebase already uses the qualified form elsewhere (invoice_transfer_historyreturnssoroban_sdk::Vec<TransferRecord>) — so this follows existing practice rather than introducing a style.Tests
One per crate, asserting against
CARGO_PKG_VERSIONrather than a literal, so a future version bump cannot leave a stale assertion passing:test_version_returns_two, whose name and assertion both had to change anywaytests/integration.rsasserted the three old integers and now asserts"0.1.0"as a literal. Deliberately not written against that test crate's ownCARGO_PKG_VERSION: the root crate happens to share the version today, so doing so would look like a coupling that does not exist. Binding each contract to its own manifest is what the per-crate unit tests do.Acceptance criteria
version()in invoice-registry, pool-manager, repayment-waterfallCARGO_PKG_VERSION, so it cannot stop matchingMigration note
Interface change for integrators:
version()returnsString, notu32. Any caller comparing against1or2needs updating.governanceis left alone — it is outside this issue's scope and still returnsu32, so it is worth a follow-up if the intent is workspace-wide consistency.Wasm size — worth a look before merging
pool_manager.wasmis the constraint here, and it was already tight:mainThe
Stringreturn costs 677 bytes in that crate. It still passes the 64KB job, but pool-manager is now at 99.1% of the limit, and the next addition to it is likely to break the build. Flagging rather than burying it — #66 recovers 22 of those bytes via a Clippy fix, and if more headroom is wanted, splitting pool-manager is the real answer.Verification
cargo test --workspacepassing (141 tests),cargo check --workspaceclean, release Wasm build within the size limit.Conflicts
This and #66 both touch
pool-manager/src/lib.rs,repayment-waterfall/src/lib.rsandinvoice-registry/src/lib.rs— unavoidable, since #66 reformats the same files this one edits.They were written to not collide: the
version()bodies and the new tests were deliberately placed in the gaps between #66's reformatting hunks, not at the ends of the files where the nearest hunk would have been ~5 lines away. Every hunk here is at least 22 lines from every hunk there.Both merge orders were tested locally against
main. Clean either way, and on the combined result the fmt and clippy gates #66 introduces pass against this PR's code: fmt clean, clippy clean under-D warnings, 141 tests passing, Wasm within limits.