Skip to content

fix: resolve settlement crate compile errors and align V2 per-token t…#601

Open
GreatShinro wants to merge 1 commit into
CalloraOrg:mainfrom
GreatShinro:fix/settlement-compile-errors
Open

fix: resolve settlement crate compile errors and align V2 per-token t…#601
GreatShinro wants to merge 1 commit into
CalloraOrg:mainfrom
GreatShinro:fix/settlement-compile-errors

Conversation

@GreatShinro

Copy link
Copy Markdown

Description

Fixes 53 pre-existing compile errors in callora-settlement and 15 in callora-vault by aligning the settlement crate's types with the V2 per-token refactoring defined in types.rs.

Changes

contracts/settlement/src/lib.rs

  • StorageKey enum — Expanded to match types.rs: added DeveloperBalanceV1(Address), DeveloperBalance(Address, Address), DeveloperMinBalance(Address), PendingDeveloperMigration(Address), StorageVersion
  • DeveloperBalance struct — Added token: Address field (per-token accounting)
  • Event structs — Added token: Address to PaymentReceivedEvent, BalanceCreditedEvent, DeveloperWithdrawEvent, DeveloperForceCreditedEvent
  • SettlementError — Added 7 new variants: MigrationSameAddress, InvalidMigrationTarget, NoDeveloperBalance, TimelockOverflow, MigrationNotFound, TimelockNotExpired, MigrationBalanceChanged
  • New typesStorageEntryTtl, Severity, AdminBroadcast, AdminMigrationEvent
  • get_storage_ttl — Removed duplicate first implementation (contained stale injected code from pagination); kept the second complete version with USDC-aware per-token balance key lookup
  • withdraw_developer_balance — Moved USDC token lookup earlier; uses two-arg StorageKey::DeveloperBalance(developer, usdc) for all balance storage operations
  • batch_receive_payment — Removed stale single-arg DeveloperBalance writes; uses balance_key variable consistently
  • force_credit_developer — Uses balance_key (two-arg) for all storage operations
  • Imports — Added String, PendingDeveloperMigration (re-exported from timelock), added module declarations for admin, limits, pagination, timelock

contracts/settlement/src/limits.rs

  • Fixed path references: crate::lib::CalloraSettlementcrate::CalloraSettlement, crate::errors::SettlementError and crate::types::StorageKeycrate::{SettlementError, StorageKey}

contracts/settlement/src/pagination.rs

  • Added token: Address parameter to get_page()
  • Added token field to DeveloperBalance struct construction
  • Uses StorageKey::DeveloperBalance(address, token) for balance lookup

contracts/vault/src/lib.rs

  • Added contracterror to soroban_sdk imports
  • Changed StorageKey::MetaStorageKey::MetaKey (2 occurrences)
  • Changed max_fee_bps type from u16 to u32 (u16 not supported as Soroban contract parameter in SDK 22)
  • Changed u16::MAXu32::MAX references
  • Added missing token argument to two settlement_client.receive_payment() calls
  • Removed duplicate get_max_deduct function
  • Removed duplicate broadcast function (kept the Err() returning version over panic!() version)
  • Added mod validators; declaration

contracts/vault/tests/event_order.rs (new)

  • Draft integration test for stable event emission ordering across runs

Verification

Crate Command Result
callora-settlement cargo check --lib ✅ 0 errors
callora-vault cargo check --lib ✅ 0 errors

Note: Full test suites cannot execute in this environment — dlltool.exe is missing from the MinGW-w64 toolchain. Run on a system with the MinGW toolchain or use rustup default stable-msvc to test.

Breaking Changes

  • max_fee_bps in vault deduct / batch_deduct changed from u16 to u32
  • StorageKey::Meta renamed to StorageKey::MetaKey
  • StorageKey::DeveloperBalance(Address)StorageKey::DeveloperBalance(Address, Address) (requires token parameter)
  • DeveloperBalance struct now requires token: Address field
  • PaymentReceivedEvent, BalanceCreditedEvent, DeveloperWithdrawEvent, DeveloperForceCreditedEvent now include token field

closes #532

…ypes

- Expand StorageKey enum with DeveloperBalanceV1, DeveloperBalance(Address, Address),
  DeveloperMinBalance, PendingDeveloperMigration, StorageVersion
- Add token field to DeveloperBalance, PaymentReceivedEvent, BalanceCreditedEvent,
  DeveloperWithdrawEvent, DeveloperForceCreditedEvent
- Add missing error variants (MigrationSameAddress through MigrationBalanceChanged)
- Add StorageEntryTtl, Severity, AdminBroadcast, AdminMigrationEvent types
- Fix all single-arg StorageKey::DeveloperBalance(addr) calls to two-arg form
- Remove duplicate get_storage_ttl function and stale injected code
- Fix limits.rs path references (crate::lib::, crate::errors::, crate::types::)
- Add token parameter to pagination::get_page
- Add String import and module declarations (admin, limits, pagination, timelock)
- Fix vault crate: add contracterror import, Meta->MetaKey, u16::MAX->u32::MAX,
  add missing token arg to settlement_client calls, remove duplicate functions,
  add validators module declaration
@drips-wave

drips-wave Bot commented Jun 28, 2026

Copy link
Copy Markdown

@GreatShinro Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

Add deterministic event ordering test in vault

1 participant