Skip to content

chore(contracts): replace panic! with typed errors - #435

Merged
collinsezedike merged 1 commit into
drydocs:mainfrom
Caneryy:feat/issue-433
Jul 30, 2026
Merged

chore(contracts): replace panic! with typed errors#435
collinsezedike merged 1 commit into
drydocs:mainfrom
Caneryy:feat/issue-433

Conversation

@Caneryy

@Caneryy Caneryy commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • router::rebalance() and both adapters' initialize() used raw panic! strings, inconsistent with the vault's typed ContractError pattern ([Contracts] Replace panic strings with a structured ContractError enum #338), and harder for off-chain callers/indexers to handle
  • Added typed error enums (RouterError, adapter-specific ContractError::AlreadyInitialized) and converted all three to return Result instead of panicking
  • Updated existing tests to assert on the new error variants where they previously used #[should_panic]

Test plan

  • cargo test passes across all four contract crates (vault, blend-adapter, defindex-adapter, router)
  • cargo clippy --all-targets -- -D warnings passes
  • cargo fmt --all -- --check passes

Closes #433

@vercel

vercel Bot commented Jul 25, 2026

Copy link
Copy Markdown

@Caneryy is attempting to deploy a commit to the Collins' projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Jul 25, 2026

Copy link
Copy Markdown

@Caneryy 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

@collinsezedike collinsezedike left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI is failing on two things:

  1. Commit Messages: header is 73 characters, over the 72-char limit. Needs shortening, e.g. chore(contracts): replace panic! with typed errors.
  2. Soroban Contract Tests: cargo fmt --all -- --check fails on the import block in blend-adapter/src/lib.rs. Run cargo fmt and push the result.

The PR title (feat(meridian): chore-replace-panic-with-typed-errors-in-router-) also needs fixing to match, since this repo squash-merges using the PR title as the commit message.

The implementation itself is correct, I ran the full test suite and clippy locally and both pass clean. Just these two fixed before merge.

@collinsezedike

collinsezedike commented Jul 26, 2026

Copy link
Copy Markdown
Collaborator

This PR's body doesn't follow CONTRIBUTING.md's PR body format (see "Pull Request Process" > "PR body format").

The Summary section should describe what changed and why, not restate the issue title. The Test plan checkboxes should be checked once you've actually run pnpm lint && pnpm typecheck && pnpm test locally, and the second line should say what you manually verified, not generic placeholder text.

Please update the PR body to reflect what you actually did and verified before this is merged.

@collinsezedike collinsezedike changed the title feat(meridian): chore-replace-panic-with-typed-errors-in-router- chore(contracts): replace panic! with typed errors in router and adapters Jul 30, 2026
@collinsezedike collinsezedike changed the title chore(contracts): replace panic! with typed errors in router and adapters chore(contracts): replace panic! with typed errors Jul 30, 2026

@collinsezedike collinsezedike left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of what was fixed to get this ready:

  • Rebased onto current main (this branch was from before several recent merges landed) and reapplied just the actual contracts changes cleanly.
  • Removed two now-duplicate/obsolete tests: blend-adapter and defindex-adapter each still had their old #[should_panic] reinitialization test from before this PR's own conversion, which either collided with or contradicted the new typed-error test this PR adds for the same thing.
  • Commit header and PR title shortened to fit the 72-character limit (first attempt was 73 characters, 1 over).
  • PR body: filled in Summary and Test plan properly.

The core conversion itself (panic! to typed ContractError/RouterError across router and both adapters) was correct from the start.

Thank you for the contribution. Feel free to grab another open issue.

Merging now.

@collinsezedike
collinsezedike merged commit d697f79 into drydocs:main Jul 30, 2026
7 of 8 checks passed
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.

[Chore] Replace panic! with typed errors in router and adapter contracts

2 participants