1use crate::abi::U256;
4use crate::{
5 AccessControlRegistry, AccessControlRegistryAdminnedWithManager, Bytes32, Error, Whitelist,
6 WhitelistRoles, WhitelistRolesWithManager, WhitelistWithManager, Zero,
7};
8
9pub struct DummyWhitelist<Address: AsRef<[u8]> + Zero + Default + PartialEq> {
10 manager: Address,
11}
12
13impl<Address: AsRef<[u8]> + Zero + Default + PartialEq> Default for DummyWhitelist<Address> {
14 fn default() -> Self {
15 Self {
16 manager: Address::default(),
17 }
18 }
19}
20
21impl<Address> Whitelist for DummyWhitelist<Address>
22where
23 Address: AsRef<[u8]> + Zero + Default + PartialEq,
24{
25 type Address = Address;
26 fn user_is_whitelisted(&self, _service_id: &Bytes32, _user: &Self::Address) -> bool {
27 false
28 }
29 fn extend_whitelist_expiration(
30 &mut self,
31 _service_id: &Bytes32,
32 _user: &Self::Address,
33 _expiration_timestamp: u64,
34 ) {
35 }
36
37 fn set_whitelist_expiration(
38 &mut self,
39 _service_id: &Bytes32,
40 _user: &Self::Address,
41 _expiration_timestamp: u64,
42 ) {
43 }
44
45 fn set_indefinite_whitelist_status(
46 &mut self,
47 _service_id: &Bytes32,
48 _user: &Self::Address,
49 _status: bool,
50 ) -> U256 {
51 U256::from(0u8)
52 }
53
54 fn revoke_indefinite_whitelist_status(
55 &mut self,
56 _service_id: &Bytes32,
57 _user: &Self::Address,
58 _setter: &Self::Address,
59 ) -> (bool, U256) {
60 (true, U256::from(0u8))
61 }
62}
63
64impl<Address> WhitelistRoles for DummyWhitelist<Address> where
65 Address: AsRef<[u8]> + Default + PartialEq + Zero
66{
67}
68
69impl<Address> WhitelistRolesWithManager for DummyWhitelist<Address>
70where
71 Address: AsRef<[u8]> + Default + PartialEq + Zero,
72{
73 fn has_whitelist_expiration_extender_role_or_is_manager(
74 &self,
75 _account: &Self::Address,
76 ) -> bool {
77 true
78 }
79
80 fn has_indefinite_whitelister_role_or_is_manager(&self, _account: &Self::Address) -> bool {
81 true
82 }
83
84 fn has_whitelist_expiration_setter_role_or_is_manager(&self, _account: &Self::Address) -> bool {
85 true
86 }
87}
88
89impl<Address> AccessControlRegistryAdminnedWithManager for DummyWhitelist<Address>
90where
91 Address: AsRef<[u8]> + Default + PartialEq + Zero,
92{
93 type Address = Address;
94
95 fn manager(&self) -> &Self::Address {
96 &self.manager
97 }
98
99 fn admin_role_description(&self) -> String {
100 String::from("")
101 }
102
103 fn admin_role_description_hash(&self) -> Bytes32 {
104 Bytes32::default()
105 }
106
107 fn admin_role(&self) -> Bytes32 {
108 Bytes32::default()
109 }
110}
111
112impl<Address> WhitelistWithManager for DummyWhitelist<Address>
113where
114 Address: AsRef<[u8]> + Zero + Default + PartialEq,
115{
116 fn extend_whitelist_expiration(
117 &mut self,
118 _service_id: &Bytes32,
119 _user: &<Self as Whitelist>::Address,
120 _expiration_timestamp: u64,
121 ) {
122 }
123
124 fn set_whitelist_expiration(&mut self, _service_id: &Bytes32, _user: &<Self as Whitelist>::Address, _expiration_timestamp: u64) {
125 }
126
127 fn set_indefinite_whitelist_status(&mut self, _service_id: &Bytes32, _user: &<Self as Whitelist>::Address, _status: bool) -> U256 {
128 U256::from(0u8)
129 }
130
131 fn revoke_indefinite_whitelist_status(&mut self, _service_id: &Bytes32, _user: &<Self as Whitelist>::Address, _setter: &<Self as Whitelist>::Address) -> (bool, U256) {
132 (false, U256::from(0u8))
133 }
134}
135
136pub struct DummyAccess<Address: AsRef<[u8]> + Zero + Default + PartialEq> {
137 manager: Address,
138}
139
140impl<Address: AsRef<[u8]> + Zero + Default + PartialEq> Default for DummyAccess<Address> {
141 fn default() -> Self {
142 Self {
143 manager: Address::default(),
144 }
145 }
146}
147
148impl<Address> AccessControlRegistryAdminnedWithManager for DummyAccess<Address>
149where
150 Address: AsRef<[u8]> + Zero + Default + PartialEq,
151{
152 type Address = Address;
153 fn manager(&self) -> &Self::Address {
154 &self.manager
155 }
156 fn admin_role_description(&self) -> String {
157 String::from("")
158 }
159 fn admin_role_description_hash(&self) -> Bytes32 {
160 Bytes32::default()
161 }
162 fn admin_role(&self) -> Bytes32 {
163 Bytes32::default()
164 }
165}
166
167impl<Address> AccessControlRegistry for DummyAccess<Address>
168where
169 Address: AsRef<[u8]> + Zero + Default + PartialEq,
170{
171 fn has_role(&self, _role: &Bytes32, _who: &Self::Address) -> bool {
172 true
173 }
174 fn grant_role(&mut self, _role: &Bytes32, _who: &Self::Address) -> Result<(), Error> {
175 Ok(())
176 }
177 fn get_role_admin(&self, _role: &Bytes32) -> Option<Bytes32> {
178 Some(Bytes32::default())
179 }
180 fn set_role_admin(&mut self, _role: &Bytes32, _role_admin: Bytes32) -> Result<(), Error> {
181 Ok(())
182 }
183 fn renounce_role(&mut self, _role: &Bytes32, _account: &Self::Address) -> Result<(), Error> {
184 Ok(())
185 }
186
187 fn revoke_role(&mut self, _role: &Bytes32, _account: &Self::Address) -> Result<(), Error> {
188 Ok(())
189 }
190}