feat: harden caller authorization and precondition guards in admin_tax_withholding_deductions (closes #335) - #437
Merged
godamongstmen897 merged 2 commits intoSep 1, 2026
Conversation
…x_withholding_deductions (closes Goldii-locks#335)
|
@esthertitilayo-dev 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.
Summary
Hardens �dmin_tax_withholding_deductions (closes #335).
Problem
equire_admin\ was called after the \TaxWithholdingExecutionLock\ was written to instance storage. An unauthorized caller could cause a storage entry to appear on the ledger even though the call was ultimately rejected.
Fix
Moved
equire_admin\ to the first statement — before any storage read. Moved every input/state guard outside the closure and before the lock write. All five rejected paths now return with zero storage entries mutated. Replaced the hard-coded literal with \BPS_SCALE. Added a dedicated test file (\�dmin_tax_withholding_guards_tests.rs) covering: uninitialized contract, non-admin caller, unfunded escrow, out-of-range milestone, rate above scale, zero balance, and the success path with event assertion.
Notes
This PR is orthogonal to #347 and #349 and does not depend on either.
Before merging: verify that CI passes all \cargo test\ and \clippy\ checks on this branch.