Skip to content

Fix non-compiling callora-vault — duplicate DuplicateRequestId variant and duplicate SettlementClient client #400

@greatest0fallt1me

Description

@greatest0fallt1me

Description

callora-vault currently does not compile. cargo check -p callora-vault fails with 11 errors that all trace back to two copy-paste regressions in contracts/vault/src/lib.rs. Because the crate is broken, the entire cargo test --workspace, WASM size, and coverage gates cannot run, so CI is effectively red across the board. This issue restores a clean build.

The two root causes are: (1) the VaultError enum declares DuplicateRequestId = 29 twice (contracts/vault/src/lib.rs:91 and :105), and (2) two traits — Settlement (:159) and SettlementTrait (:188) — are both annotated with #[contractclient(name = "SettlementClient")], generating the SettlementClient type twice.

Requirements and context

Functional

  • Remove the duplicate DuplicateRequestId = 29 enum arm. Keep exactly one variant. Resolves error[E0428] (name defined multiple times) and error[E0081] (discriminant 29 assigned more than once).
  • Fix the misleading doc comment on the surviving variant: line 90 currently reads /// Duplicate request ID detected (code 23). but the discriminant is 29. The comment must state code 29.
  • Remove the redundant second settlement client. The file defines #[contractclient(name = "SettlementClient")] trait Settlement at contracts/vault/src/lib.rs:159 and #[soroban_sdk::contractclient(name = "SettlementClient")] trait SettlementTrait at :188. Keep one; deleting the duplicate resolves error[E0428], the error[E0592] duplicate new / receive_payment / try_receive_payment definitions, and the error[E0034] ambiguity at the SettlementClient::new(...) call sites (:676, :781).
  • After the fixes, error[E0004] (non-exhaustive match generated by the #[contracterror] macro) must also clear, since it is a downstream symptom of the duplicate discriminant.

Non-functional / repo conventions

  • No behavioral change: deduct / batch_deduct must continue to call settlement_client.receive_payment(..., to_pool=true, developer=None) exactly as today (contracts/vault/src/lib.rs:677 and :782).
  • Keep the DuplicateRequestId error code stable at 29 so existing integrators and the idempotency tests in contracts/vault/src/test_idempotency.rs keep passing.
  • Do not renumber any other VaultError codes; docs/interfaces/vault.json enumerates codes 1–28 and must be extended (not reshuffled) to add code 29.

Acceptance criteria

  • cargo check -p callora-vault and cargo build --workspace succeed with zero errors.
  • VaultError contains exactly one DuplicateRequestId = 29 arm with a correct /// ... (code 29) doc comment.
  • Only one SettlementClient is generated; SettlementClient::new(...) compiles without E0034 ambiguity.
  • cargo test --workspace passes, including contracts/vault/src/test_idempotency.rs.
  • cargo clippy --all-targets --all-features -- -D warnings is clean (the two pre-existing unreachable pattern warnings are gone).
  • docs/interfaces/vault.json adds { "code": 29, "name": "DuplicateRequestId", ... } to the errors.codes array.

Suggested execution

1. Fork the repo and create a branch

git checkout -b fix/vault-duplicate-symbols

2. Implement changes

  • contracts/vault/src/lib.rs — delete the duplicate DuplicateRequestId = 29 arm (:105) and fix the doc comment on the remaining one; delete one of the two duplicate settlement client trait declarations (Settlement at :159 or SettlementTrait at :188) so a single SettlementClient is generated.
  • docs/interfaces/vault.json — append error code 29.

3. Write/extend tests

  • Confirm contracts/vault/src/test_idempotency.rs still exercises the duplicate-request_id path returning VaultError::DuplicateRequestId; add an assertion that pins the numeric code to 29 (e.g. assert_eq!(VaultError::DuplicateRequestId as u32, 29)) so a future renumber regression is caught.

4. Test and commit

cargo fmt --all -- --check
cargo clippy --all-targets --all-features -- -D warnings
cargo test --workspace
./scripts/check-wasm-size.sh
./scripts/coverage.sh

Example commit message

fix(vault): remove duplicate DuplicateRequestId variant and SettlementClient

The VaultError enum declared DuplicateRequestId = 29 twice and two traits
both generated a SettlementClient, breaking compilation (E0428/E0081/E0592/
E0034/E0004). Collapse to a single definition each; error code stays 29.

Guidelines

  • Coverage must stay >= 95% (scripts/coverage.sh), CI-enforced via .github/workflows/coverage.yml.
  • Keep NatSpec-style /// docs accurate; update docs/interfaces/vault.json to reflect error code 29.
  • Verify EVENT_SCHEMA.md still matches the unchanged deduct event shape.
  • Timeframe: 96 hours.

Metadata

Metadata

Assignees

No one assigned

    Labels

    GRANTFOX OSSGrantFox OSS programMAYBE REWARDEDGrantFox — potentially rewardedOFFICIAL CAMPAIGNGrantFox official campaignciCI / build pipelineimprovementRefactor, performance, or tech-debtintermediateModerate complexitysmart-contractSoroban / Rust contract work

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions