Skip to content

fix: replace generic Unauthorized() with specific error types#427

Open
Aboudjem wants to merge 1 commit intoithacaxyz:mainfrom
Aboudjem:fix/specific-unauthorized-errors
Open

fix: replace generic Unauthorized() with specific error types#427
Aboudjem wants to merge 1 commit intoithacaxyz:mainfrom
Aboudjem:fix/specific-unauthorized-errors

Conversation

@Aboudjem
Copy link
Copy Markdown

Summary

Replaces the generic Unauthorized() error with five specific error types to help offchain integrators diagnose issues more precisely (closes #399).

New Errors

Error Location Context
UnauthorizedNonSelf() GuardedExecutor.onlyThis modifier, IthacaAccount._execute (simple workflow) Caller is not address(this)
UnauthorizedNonOrchestrator() IthacaAccount.checkAndIncrementNonce Caller is not the Orchestrator
UnauthorizedPayment() IthacaAccount.pay Caller is not the Orchestrator or account is not the EOA/payer
UnauthorizedPaymasterSignature() IthacaAccount.pay (paymaster path) Paymaster signature validation failed
UnauthorizedSignature() IthacaAccount._execute (signed workflow) Intent signature validation failed

Changes

  • src/GuardedExecutor.sol: Defined five new custom errors replacing the generic Unauthorized(). Updated onlyThis modifier.
  • src/IthacaAccount.sol: Replaced all 5 revert Unauthorized() call sites with the appropriate specific error.
  • test/Account.t.sol: Updated test expecting UnauthorizedSignature() (was Unauthorized()).
  • test/GuardedExecutor.t.sol: Updated 2 tests expecting UnauthorizedNonSelf() (was Unauthorized()).

Gas Optimization

No measurable gas impact — custom errors without arguments compile to the same 4-byte selector revert pattern. The only difference is the selector value itself.

Test plan

  • forge build compiles successfully
  • forge test --match-contract "AccountTest|GuardedExecutorTest|OrchestratorTest" — 47/47 tests pass
  • Full forge test — 206/209 pass (3 pre-existing failures unrelated to this change)
  • forge fmt applied

🤖 Generated with Claude Code

Replace the single generic `Unauthorized()` error with five specific errors
to help offchain integrators diagnose issues more precisely:

- `UnauthorizedNonSelf()` — caller is not `address(this)`
- `UnauthorizedNonOrchestrator()` — caller is not the Orchestrator
- `UnauthorizedPayment()` — payment auth failed (wrong caller or account mismatch)
- `UnauthorizedPaymasterSignature()` — paymaster signature validation failed
- `UnauthorizedSignature()` — intent signature validation failed

Closes ithacaxyz#399

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.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.

Add more specific errors in the Account and Orchestrator

1 participant