feat(transfer-restrictions): enforce whitelist in validate_transfer#505
Merged
truthixify merged 3 commits intoDistinctCodes:mainfrom Feb 23, 2026
Conversation
validate_transfer was a stub that always returned Ok(true), ignoring any whitelist or accreditation config. Now: - If the whitelist for an asset is non-empty, the recipient (`to`) must be present in it; otherwise returns Error::TransferRestrictionFailed. - If `require_accredited = true`, the whitelist is used as the MVP proxy for accredited-investor status; returns Error::AccreditedInvestorRequired when `to` is absent. - No restrictions set and empty whitelist → transfer is still allowed (zero-friction default). Closes DistinctCodes#472
Covers all three acceptance criteria from issue DistinctCodes#472: transfer_restrictions.rs (client-level integration): - test_transfer_to_non_whitelisted_fails: transfer_tokens panics when recipient is not in an active whitelist - test_empty_whitelist_allows_transfer: no whitelist → transfer succeeds transfer_restrictions_new.rs (unit-level, direct module calls): - test_validate_transfer_blocked_when_not_whitelisted: validate_transfer returns Ok for whitelisted address, Err for non-whitelisted - test_validate_transfer_empty_whitelist_allows_all: empty whitelist imposes no restriction - test_validate_transfer_accredited_required_uses_whitelist: whitelist acts as accredited-investor registry for require_accredited flag
|
@KevinMB0220 is attempting to deploy a commit to the naijabuz's projects Team on Vercel. A member of the Team first needs to authorize it. |
Fixes clippy::bool_assert_comparison lint triggered by -D warnings in CI.
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 #472
Summary
validate_transferwas a no-op stub that always returnedOk(true), making the whitelist and accreditation config completely ignored. This PR implements the actual enforcement logic.to) must be present; otherwise returnsError::TransferRestrictionFailed.require_accredited = true, the whitelist is used as the MVP proxy registry; returnsError::AccreditedInvestorRequiredwhentois absent.Changes
src/transfer_restrictions.rsvalidate_transfer.require_accreditedcheck using the same whitelist as MVP proxy (as specified).src/tests/transfer_restrictions.rs(client integration tests)test_transfer_to_non_whitelisted_fails—transfer_tokenspanics when recipient is not whitelisted (acceptance criterion 1).test_empty_whitelist_allows_transfer— transfer succeeds when no whitelist is set (acceptance criterion 2).src/tests/transfer_restrictions_new.rs(unit tests, direct module calls)test_validate_transfer_blocked_when_not_whitelisted—validate_transferallows whitelisted address, blocks non-whitelisted.test_validate_transfer_empty_whitelist_allows_all— empty whitelist imposes no restriction.test_validate_transfer_accredited_required_uses_whitelist—require_accreditedflag gates via whitelist.Test plan
cargo fmt— no changes neededcargo clippy— clean, no warningscargo test— 193/193 tests passAcceptance criteria
validate_transferintegrated intotransfer_tokens(was already wired inlib.rs; enforcement now actually runs)