Enhancement/admin auth helper#365
Merged
mikewheeleer merged 2 commits intoMay 28, 2026
Merged
Conversation
|
@Mrwicks00 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! 🚀 |
Contributor
Author
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.
Pull Request: Refactor Repeated Admin-Load Boilerplate into Single Helper (#337)
Description
Closes #337
This pull request refactors the repetitive admin authorization and validation logic in the TalentTrust Escrow contract (
contracts/escrow) into a single, clean helper function.Key Changes
Extracted
load_and_auth_adminHelper:fn load_and_auth_admin(env: &Env) -> Addressinsidecontracts/escrow/src/lib.rs.NotInitializedif missing) and callsrequire_auth()on it.Replaced Boilerplate:
load_and_auth_admin:pauseunpauseactivate_emergency_pauseresolve_emergencyDead Code Elimination:
require_admin(env, caller)helper which was never called in the contract.Added Comprehensive Unit Tests:
contracts/escrow/src/test/admin_auth_helper.rswith extensive test coverage forload_and_auth_admin.contracts/escrow/src/test/mod.rs.Updated Documentation:
docs/escrow/access-control.mdto reflect the newload_and_auth_adminpattern, documented the security invariants, and described the dead-code cleanup.Verification Status
All checks, linters, and verification steps are fully passing:
Unit and Integration Tests:
cargo testoncontracts/escrow.Linting (Clippy):
cargo clippy --testssuccessfully with zero errors or warnings.Formatting (rustfmt):
Pre-existing Codebase Fixes
In order to successfully run
cargo testand verify our refactoring, we also resolved a few pre-existing compiler errors that were blocking the build onmain:EscrowErrorenum intypes.rsand added missing variants referenced by thedisputemodule.release_milestoneinstead of 2) in tests.symbol_short!topics (>9 characters) withSymbol::newingovernance.rsandlib.rs.