Skip to content

fix(#382): assign unique contract error discriminants - #471

Open
iyanumajekodunmi756 wants to merge 2 commits into
TevaLabs:mainfrom
iyanumajekodunmi756:fix/382-unique-contract-error-discriminants
Open

fix(#382): assign unique contract error discriminants#471
iyanumajekodunmi756 wants to merge 2 commits into
TevaLabs:mainfrom
iyanumajekodunmi756:fix/382-unique-contract-error-discriminants

Conversation

@iyanumajekodunmi756

@iyanumajekodunmi756 iyanumajekodunmi756 commented Aug 28, 2026

Copy link
Copy Markdown

Summary

Closes #382.

This PR removes the ContractError discriminant collision between oracle timestamp validation and pending-winnings expiry handling. It also synchronizes the wallet-facing TypeScript error map and documentation with the authoritative Rust enum, and adds a regression test so future duplicate discriminants are caught automatically.

Changes

  • Assign PendingWinningsNotExpired the unique stable code 83.
  • Preserve OracleTimestampOutsideWindow at code 66.
  • Add the missing RotationDelayNotElapsed (55) mapping to TypeScript bindings.
  • Move the pending-winnings expiry mapping in the TypeScript decoder from 61 to 83.
  • Synchronize docs/WALLET_ERROR_GUIDE.md with every error code currently defined by contracts/src/errors.rs.
  • Add a parity regression test asserting that all Rust error discriminants are unique.

Compatibility / migration notes

Contract error codes are part of the client-facing ABI. Existing clients that decode code 61 as PendingWinningsNotExpired must update to code 83. Code 66 now unambiguously identifies OracleTimestampOutsideWindow; clients should not use code 66 for pending-winnings expiry handling.

No contract storage layout, event schema, method signature, or settlement behavior was changed.

Validation

Passed locally:

  • node scripts/check-doc-drift.js
  • npm --prefix bindings run test:errors
  • npm --prefix bindings run build
  • npm --prefix bindings run lint
  • git diff --check

Rust validation could not be run in the execution environment because cargo is not installed. The existing broader ABI parity command also reports pre-existing contract-method drift unrelated to this issue; the error enum parity portion passes.

Review checklist

  • Every ContractError variant has a unique u32 discriminant.
  • TypeScript error mapping matches Rust error names and codes.
  • Wallet error guide covers the authoritative error map.
  • Regression coverage prevents future discriminant collisions.
  • No generated build artifacts included.

closes #382

iyanumajekodunmi756 and others added 2 commits August 28, 2026 10:32
Keep pending-winnings expiry errors distinct from oracle timestamp errors and synchronize wallet-facing mappings and regression checks.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
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.

Quality: fix colliding ContractError discriminant (code 66)

1 participant