File tree Expand file tree Collapse file tree 2 files changed +54
-10
lines changed
Expand file tree Collapse file tree 2 files changed +54
-10
lines changed Original file line number Diff line number Diff line change 22pragma solidity ^ 0.8.20 ;
33
44import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol " ;
5+ import {Strings} from "@openzeppelin/contracts/utils/Strings.sol " ;
56import "./IValidator.sol " ;
67
78/**
@@ -53,13 +54,50 @@ contract Validator is AccessControl, IValidator {
5354 uint256 /* amount */
5455 ) external view override returns (bool valid ) {
5556 if (isV1Frontend (msg .sender )) {
56- valid = ! (isV1Blocked (from) || isV1Blocked (to));
57- if (! valid) {
58- return false ;
57+ if (isV1Blocked (from)) {
58+ revert (
59+ string (
60+ abi.encodePacked (
61+ "Transfer not supported: " ,
62+ Strings.toHexString (from),
63+ " is blocked in V1. Please use V2 instead. See https://monerium.dev/docs/tokens "
64+ )
65+ )
66+ );
5967 }
68+ if (isV1Blocked (to)) {
69+ revert (
70+ string (
71+ abi.encodePacked (
72+ "Transfer not supported: " ,
73+ Strings.toHexString (to),
74+ " is blocked in V1. Please use V2 instead. See https://monerium.dev/docs/tokens "
75+ )
76+ )
77+ );
78+ }
79+ }
80+ if (isBlacklisted (from)) {
81+ revert (
82+ string (
83+ abi.encodePacked (
84+ "Transfer not supported: " ,
85+ Strings.toHexString (from),
86+ " is blacklisted. "
87+ )
88+ )
89+ );
6090 }
61- if (isBlacklisted (from) || isBlacklisted (to)) {
62- return false ;
91+ if (isBlacklisted (to)) {
92+ revert (
93+ string (
94+ abi.encodePacked (
95+ "Transfer not supported: " ,
96+ Strings.toHexString (to),
97+ " is blacklisted. "
98+ )
99+ )
100+ );
63101 }
64102 return true ;
65103 }
Original file line number Diff line number Diff line change @@ -66,15 +66,21 @@ contract ValidatorTest is Test {
6666
6767 // Blocked by frontend
6868 vm.prank (frontend);
69- assertFalse (validator.validate (blocked, admin, 100 ));
69+ vm.expectRevert ("Transfer not supported:0x0000000000000000000000000000000000000004 is blocked in V1. Please use V2 instead. See https://monerium.dev/docs/tokens " );
70+ validator.validate (blocked, admin, 100 );
71+
7072 vm.prank (frontend);
71- assertFalse (validator.validate (admin, blocked, 100 ));
73+ vm.expectRevert ("Transfer not supported:0x0000000000000000000000000000000000000004 is blocked in V1. Please use V2 instead. See https://monerium.dev/docs/tokens " );
74+ validator.validate (admin, blocked, 100 );
7275
73- // Blacklisted always fails
76+ // Blacklisted always reverts
7477 vm.prank (user);
75- assertFalse (validator.validate (blacklisted, admin, 100 ));
78+ vm.expectRevert ("Transfer not supported:0x0000000000000000000000000000000000000005 is blacklisted. " );
79+ validator.validate (blacklisted, admin, 100 );
80+
7681 vm.prank (user);
77- assertFalse (validator.validate (admin, blacklisted, 100 ));
82+ vm.expectRevert ("Transfer not supported:0x0000000000000000000000000000000000000005 is blacklisted. " );
83+ validator.validate (admin, blacklisted, 100 );
7884 }
7985
8086 function testContractId () public {
You can’t perform that action at this time.
0 commit comments