feat: standardize bill event schema and compatibility checks#419
Open
Arowolokehinde wants to merge 3 commits intoRemitwise-Org:mainfrom
Open
feat: standardize bill event schema and compatibility checks#419Arowolokehinde wants to merge 3 commits intoRemitwise-Org:mainfrom
Arowolokehinde wants to merge 3 commits intoRemitwise-Org:mainfrom
Conversation
855531f to
8569e21
Compare
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.
Bills Event Schema Parity
Closes #275
Objective
Standardize the bill_payments contract event schema and implement robust backward-compatibility checks to preserve downstream contract-event decoding reliability after upgrades, as requested in issue #275.
Diagnosis & Findings
The bill_payments contract previously relied on weakly typed tuples for event emission, which posed a high risk of schema drift and downstream indexer breakage during future contract upgrades. In addition, several areas of the test suite and contract logic were suffering from compilation failures, logic gaps (e.g., time paradoxes in property tests), and mismatched validation layers under Soroban's evolving mock_all_auths() environment.
Prescribed Interventions
Canonical Structs: Replaced raw tuple emissions with strongly-typed structs (e.g.,
BillCreatedEvent
,
BillPaidEvent
,
BillCancelledEvent
).
Schema Versioning: Embedded a schema_version: u32 inside each event struct, starting at v1, to guarantee that downstream clients can predictably detect and decode future payload shape changes.
Topic Parity: Enforced a strict 4-topic signature
(Namespace, Category, Priority, Action)
utilizing the remitwise-common library, guaranteeing that current indexers will not lose track of the events.
Compile-Time Assertions: Implemented the assert_min_fields! compile-time macro. This ensures the compiler will immediately catch any accidental field-count regressions (deletions) from the standardized structs.
Function Signature Alignment: Executed a systematic AST-aware script to safely inject the newly required external_ref: Option and currency: String arguments across all ~40
create_bill
inline tests to fix Arity compilation mismatch errors (error[E0061]).
Property Test Time-Paradox Resolution: Corrected buggy proptest! logic in prop_overdue_bills_all_have_due_before_now and prop_recurring_next_bill_due_date_follows_original where the ledger time was incorrectly advanced before bill creation, triggering spurious Error(Auth, InvalidAction) SDK panics.
Strict Auth Validation: Refactored
test_pay_bill_no_auth_fails
to drop mock_all_auths() so that it accurately trips and tests the authorization boundary.
Resolved alloc vs std boundaries in
normalize_currency
and
validate_currency
so no_std environments compile without throwing dependency errors on .trim().
Silenced MAX_PAGE_LIMIT import and
bill_id
variable lifetime IDE warnings across
lib.rs
and
test_notifications.rs
.
Marked API examples in rustdoc with
ignore
to fix cargo test --doc build errors.