Skip to content

feat: standardize bill event schema and compatibility checks#419

Open
Arowolokehinde wants to merge 3 commits intoRemitwise-Org:mainfrom
Arowolokehinde:feature/bills-event-schema-parity
Open

feat: standardize bill event schema and compatibility checks#419
Arowolokehinde wants to merge 3 commits intoRemitwise-Org:mainfrom
Arowolokehinde:feature/bills-event-schema-parity

Conversation

@Arowolokehinde
Copy link
Copy Markdown

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

  1. Schema Standardization & Typing
    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.
  2. Backward Compatibility & Regression Prevention
    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.
  3. Test Suite Repair & Stabilization
    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.
  4. Compilation Fixes
    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.

@Arowolokehinde Arowolokehinde force-pushed the feature/bills-event-schema-parity branch from 855531f to 8569e21 Compare March 27, 2026 18:25
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.

Implement bill event schema parity and backward compatibility checks

1 participant