Skip to content

fix(contracts): add shared ABI fixture, sync error tables, and validate client signatures - #2072

Open
DeepDev69x3 wants to merge 1 commit into
DistinctCodes:mainfrom
DeepDev69x3:fix/shared-abi-interface-fixture-2025
Open

DeepDev69x3 wants to merge 1 commit into
DistinctCodes:mainfrom
DeepDev69x3:fix/shared-abi-interface-fixture-2025

Conversation

@DeepDev69x3

Copy link
Copy Markdown

Summary

This PR resolves #2025 by introducing a canonical, committed JSON ABI fixture (contracts/shared/payment_escrow.abi.json), synchronizing the TypeScript ContractError table with all contract error codes, adding automated ABI conformance tests in both Rust and the backend client, and validating parameter signatures.

Closes #2025

Key Changes

  1. Canonical Interface & ABI Fixture (contracts/shared/payment_escrow.abi.json & backend fixture):

    • Defines the canonical Soroban contract specification for payment_escrow (version 1).
    • Specifies all public functions (create, release, refund, release_partial, refund_remaining, get_status, get_escrow, initialize, version, upgrade, propose_admin, accept_admin, pause, unpause, is_paused) along with their input parameter names, types, and return types.
    • Formally enumerates all contract errors and lifecycle states.
  2. TypeScript Error Enum & Table Synchronization (contracts/shared/error-codes.ts & escrow-contract.client.ts):

    • Extended ContractError enum to cover all 14 contract error codes (including AlreadyReleased = 6, AlreadyRefunded = 7, AlreadyInitialized = 10, NotInitialized = 11, Unauthorized = 12, Paused = 13, NoPendingAdmin = 14, AmountExceedsEscrow = 20, NothingToRefund = 21).
    • Aligned CONTRACT_ERROR_NAMES table for reliable client-side and backend mapping.
    • Updated buildCreateTx to optionally accept the 5th tokenAddress argument while retaining backward compatibility.
  3. Backend Client ABI Conformance Suite (backend/src/payments/soroban/abi-fixture.spec.ts):

    • Added comprehensive unit tests verifying that EscrowContractClient transaction builders (buildCreateTx, buildReleaseTx, buildRefundTx) generate invocations matching the fixture functions and argument counts.
    • Asserts 100% synchronization between the TypeScript ContractError enum and the contract ABI fixture.
  4. Rust Contract ABI Synchronization Test (contracts/payment_escrow/tests/abi_fixture_test.rs):

    • Added integration tests in Rust asserting that the contract's VERSION, Error enum variant codes, and EscrowState values match the shared fixture.

Verification & CI Proof

  • cargo test --workspace: 32/32 tests passing (100% green).
  • cargo clippy --workspace --all-targets -- -D warnings: 0 warnings / 0 errors.
  • cargo fmt --all -- --check: Passed.
  • bash scripts/audit_require_auth.sh: All entrypoints passed auth check.
  • npm test -- src/payments/soroban/: 10 test suites passed (86 tests passing, 0 errors).
  • npm run lint & npm run build: 0 lint errors, build succeeded cleanly.

@vercel

vercel Bot commented Nov 8, 2026

Copy link
Copy Markdown

@DeepDev69x3 is attempting to deploy a commit to the naijabuz's projects Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
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.

Contracts have no shared ABI/interface fixture used by both the Rust tests and the backend client

1 participant