fix: replace generic Unauthorized() with specific error types#427
Open
Aboudjem wants to merge 1 commit intoithacaxyz:mainfrom
Open
fix: replace generic Unauthorized() with specific error types#427Aboudjem wants to merge 1 commit intoithacaxyz:mainfrom
Aboudjem wants to merge 1 commit intoithacaxyz:mainfrom
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces the generic
Unauthorized()error with five specific error types to help offchain integrators diagnose issues more precisely (closes #399).New Errors
UnauthorizedNonSelf()GuardedExecutor.onlyThismodifier,IthacaAccount._execute(simple workflow)address(this)UnauthorizedNonOrchestrator()IthacaAccount.checkAndIncrementNonceUnauthorizedPayment()IthacaAccount.payUnauthorizedPaymasterSignature()IthacaAccount.pay(paymaster path)UnauthorizedSignature()IthacaAccount._execute(signed workflow)Changes
src/GuardedExecutor.sol: Defined five new custom errors replacing the genericUnauthorized(). UpdatedonlyThismodifier.src/IthacaAccount.sol: Replaced all 5revert Unauthorized()call sites with the appropriate specific error.test/Account.t.sol: Updated test expectingUnauthorizedSignature()(wasUnauthorized()).test/GuardedExecutor.t.sol: Updated 2 tests expectingUnauthorizedNonSelf()(wasUnauthorized()).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 buildcompiles successfullyforge test --match-contract "AccountTest|GuardedExecutorTest|OrchestratorTest"— 47/47 tests passforge test— 206/209 pass (3 pre-existing failures unrelated to this change)forge fmtapplied🤖 Generated with Claude Code