refactor: Extract shared require_admin pattern into router-common crate (#128)#172
Merged
Maki-Zeninn merged 2 commits intoMaki-Zeninn:mainfrom Mar 30, 2026
Merged
refactor: Extract shared require_admin pattern into router-common crate (#128)#172Maki-Zeninn merged 2 commits intoMaki-Zeninn:mainfrom
Maki-Zeninn merged 2 commits intoMaki-Zeninn:mainfrom
Conversation
…mmon crate - Created new workspace crate `contracts/router-common` - Added `require_admin!` and `require_admin_simple!` macros to eliminate code duplication - Updated all contracts to depend on `router-common` - Replaced repetitive admin check boilerplate with the shared macro - Improves maintainability and reduces risk of inconsistent admin logic Closes Maki-Zeninn#128
|
@onahiOMOTI 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! 🚀 |
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.
Closes #128
Description
This PR implements Issue #128 - Refactor: extract shared require_admin pattern into a shared module or macro.
Problem
All six contracts had nearly identical
require_adminfunctions with only minor differences in error types. This caused significant code duplication (DRY violation), making maintenance error-prone.Solution
contracts/router-commonrequire_admin!— flexible version with custom error typesrequire_admin_simple!— simpler version when error variants are standardizedrouter-commonas a dependency to all contractsChanges
contracts/router-commonsrc/lib.rswith admin guard macrosCargo.tomlCargo.tomlin all contract cratesBenefits