Skip to content

Commit 232a46e

Browse files
committed
style: fix Solidity style violations across src/ — function order, NatSpec coverage, relative imports
(behaviour-preserving)
1 parent 297cffe commit 232a46e

17 files changed

Lines changed: 176 additions & 108 deletions

src/mocks/IAddressListInterfaceIdHelper.sol

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,61 @@ import {AddressListInterfaceId} from "../rules/interfaces/library/AddressListInt
1717
*/
1818
interface IAddressListAllFunctions {
1919
/* ==== From IAddressList ==== */
20+
21+
/**
22+
* @notice Adds several addresses to the set.
23+
* @param targetAddresses The addresses to add.
24+
*/
2025
function addAddresses(address[] calldata targetAddresses) external;
26+
27+
/**
28+
* @notice Removes several addresses from the set.
29+
* @param targetAddresses The addresses to remove.
30+
*/
2131
function removeAddresses(address[] calldata targetAddresses) external;
32+
33+
/**
34+
* @notice Adds a single address to the set.
35+
* @param targetAddress The address to add.
36+
*/
2237
function addAddress(address targetAddress) external;
38+
39+
/**
40+
* @notice Removes a single address from the set.
41+
* @param targetAddress The address to remove.
42+
*/
2343
function removeAddress(address targetAddress) external;
44+
45+
/**
46+
* @notice Returns the number of addresses currently in the set.
47+
* @return count The number of listed addresses.
48+
*/
2449
function listedAddressCount() external view returns (uint256 count);
50+
51+
/**
52+
* @notice Returns whether a single address is in the set.
53+
* @param targetAddress The address to check.
54+
* @return isListed True if the address is listed.
55+
*/
2556
function isAddressListed(address targetAddress) external view returns (bool isListed);
57+
58+
/**
59+
* @notice Returns membership for several addresses in one call.
60+
* @param targetAddresses The addresses to check.
61+
* @return results One boolean per input address, in the same order.
62+
*/
2663
function areAddressesListed(address[] memory targetAddresses) external view returns (bool[] memory results);
64+
2765
/* ==== From IIdentityRegistryContains ==== */
66+
67+
/**
68+
* @notice Returns whether an address is in the set.
69+
* @dev This is the selector that `type(IAddressList).interfaceId` OMITS, because it is
70+
* inherited rather than declared directly. Redeclaring it here is the whole point of
71+
* this flattened interface.
72+
* @param _userAddress The address to check.
73+
* @return True if the address is listed.
74+
*/
2875
function contains(address _userAddress) external view returns (bool);
2976
}
3077

@@ -36,27 +83,31 @@ interface IAddressListAllFunctions {
3683
contract IAddressListInterfaceIdHelper {
3784
/**
3885
* @notice Returns `type(IAddressList).interfaceId` — INCOMPLETE, omits inherited selectors.
86+
* @return The naive interface ID, which does NOT include the inherited `contains(address)`.
3987
*/
4088
function getIAddressListInterfaceId() external pure returns (bytes4) {
4189
return type(IAddressList).interfaceId;
4290
}
4391

4492
/**
4593
* @notice Returns the XOR of ALL selectors in the {IAddressList} hierarchy (flattened).
94+
* @return The complete interface ID, including the inherited `contains(address)` selector.
4695
*/
4796
function getIAddressListAllFunctionsInterfaceId() external pure returns (bytes4) {
4897
return type(IAddressListAllFunctions).interfaceId;
4998
}
5099

51100
/**
52101
* @notice Returns the constant defined in the {AddressListInterfaceId} library.
102+
* @return The pre-computed constant the rules actually advertise via ERC-165.
53103
*/
54104
function getAddressListInterfaceIdConstant() external pure returns (bytes4) {
55105
return AddressListInterfaceId.IADDRESS_LIST_INTERFACE_ID;
56106
}
57107

58108
/**
59109
* @notice Returns the interface ID of the inherited parent interface.
110+
* @return The interface ID of {IIdentityRegistryContains}.
60111
*/
61112
function getIIdentityRegistryContainsInterfaceId() external pure returns (bytes4) {
62113
return type(IIdentityRegistryContains).interfaceId;

src/mocks/IdentityRegistryMock.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: MPL-2.0
22
pragma solidity ^0.8.20;
33

4-
import {IIdentityRegistryVerified} from "src/rules/interfaces/IIdentityRegistry.sol";
4+
import {IIdentityRegistryVerified} from "../rules/interfaces/IIdentityRegistry.sol";
55

66
/**
77
* @title IdentityRegistryMock — test double for an ERC-3643 identity registry

src/mocks/MockERC20WithTransferContext.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
pragma solidity ^0.8.20;
33

44
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
5-
import {ITransferContext} from "src/rules/interfaces/ITransferContext.sol";
5+
import {ITransferContext} from "../rules/interfaces/ITransferContext.sol";
66

77
/**
88
* @title MockERC20WithTransferContext — ERC20 mock that notifies a transfer-context rule

src/mocks/MockERC721WithTransferContext.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
pragma solidity ^0.8.20;
33

44
import {ERC721} from "@openzeppelin/contracts/token/ERC721/ERC721.sol";
5-
import {ITransferContext} from "src/rules/interfaces/ITransferContext.sol";
5+
import {ITransferContext} from "../rules/interfaces/ITransferContext.sol";
66

77
/**
88
* @title MockERC721WithTransferContext — ERC721 mock that notifies a transfer-context rule

src/mocks/SanctionListOracle.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: MPL-2.0
22
pragma solidity ^0.8.20;
33

4-
import {ISanctionsList} from "src/rules/interfaces/ISanctionsList.sol";
4+
import {ISanctionsList} from "../rules/interfaces/ISanctionsList.sol";
55

66
/**
77
* @title SanctionListOracle — test double for a Chainalysis-style sanctions oracle

src/mocks/harness/DeploymentCoverageHarnesses.sol

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
// SPDX-License-Identifier: MPL-2.0
22
pragma solidity ^0.8.20;
33

4-
import {ISanctionsList} from "src/rules/interfaces/ISanctionsList.sol";
5-
import {RuleBlacklist} from "src/rules/validation/deployment/RuleBlacklist.sol";
6-
import {RuleWhitelist} from "src/rules/validation/deployment/RuleWhitelist.sol";
7-
import {RuleWhitelistWrapper} from "src/rules/validation/deployment/RuleWhitelistWrapper.sol";
8-
import {RuleERC2980} from "src/rules/validation/deployment/RuleERC2980.sol";
9-
import {RuleSanctionsList} from "src/rules/validation/deployment/RuleSanctionsList.sol";
10-
import {RuleBlacklistOwnable2Step} from "src/rules/validation/deployment/RuleBlacklistOwnable2Step.sol";
11-
import {RuleWhitelistOwnable2Step} from "src/rules/validation/deployment/RuleWhitelistOwnable2Step.sol";
12-
import {RuleWhitelistWrapperOwnable2Step} from "src/rules/validation/deployment/RuleWhitelistWrapperOwnable2Step.sol";
13-
import {RuleERC2980Ownable2Step} from "src/rules/validation/deployment/RuleERC2980Ownable2Step.sol";
4+
import {ISanctionsList} from "../../rules/interfaces/ISanctionsList.sol";
5+
import {RuleBlacklist} from "../../rules/validation/deployment/RuleBlacklist.sol";
6+
import {RuleWhitelist} from "../../rules/validation/deployment/RuleWhitelist.sol";
7+
import {RuleWhitelistWrapper} from "../../rules/validation/deployment/RuleWhitelistWrapper.sol";
8+
import {RuleERC2980} from "../../rules/validation/deployment/RuleERC2980.sol";
9+
import {RuleSanctionsList} from "../../rules/validation/deployment/RuleSanctionsList.sol";
10+
import {RuleBlacklistOwnable2Step} from "../../rules/validation/deployment/RuleBlacklistOwnable2Step.sol";
11+
import {RuleWhitelistOwnable2Step} from "../../rules/validation/deployment/RuleWhitelistOwnable2Step.sol";
12+
import {RuleWhitelistWrapperOwnable2Step} from "../../rules/validation/deployment/RuleWhitelistWrapperOwnable2Step.sol";
13+
import {RuleERC2980Ownable2Step} from "../../rules/validation/deployment/RuleERC2980Ownable2Step.sol";
1414

1515
/**
1616
* @title RuleBlacklistHarness — test harness exposing RuleBlacklist internals
@@ -85,6 +85,7 @@ contract RuleWhitelistWrapperHarness is RuleWhitelistWrapper {
8585
* @param admin Address granted the admin role
8686
* @param forwarderIrrevocable Trusted ERC-2771 forwarder address
8787
* @param checkSpender_ Whether the spender is also checked against the whitelist
88+
* @param allowMintBurn Whether minting and burning are permitted (sets both flags)
8889
*/
8990
constructor(address admin, address forwarderIrrevocable, bool checkSpender_, bool allowMintBurn)
9091
RuleWhitelistWrapper(admin, forwarderIrrevocable, checkSpender_, allowMintBurn)
@@ -238,6 +239,7 @@ contract RuleWhitelistWrapperOwnable2StepHarness is RuleWhitelistWrapperOwnable2
238239
* @param owner Address set as the contract owner
239240
* @param forwarderIrrevocable Trusted ERC-2771 forwarder address
240241
* @param checkSpender_ Whether the spender is also checked against the whitelist
242+
* @param allowMintBurn Whether minting and burning are permitted (sets both flags)
241243
*/
242244
constructor(address owner, address forwarderIrrevocable, bool checkSpender_, bool allowMintBurn)
243245
RuleWhitelistWrapperOwnable2Step(owner, forwarderIrrevocable, checkSpender_, allowMintBurn)

src/mocks/harness/RuleSanctionsListOwnable2StepHarness.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// SPDX-License-Identifier: MPL-2.0
22
pragma solidity ^0.8.20;
33

4-
import {ISanctionsList} from "src/rules/interfaces/ISanctionsList.sol";
5-
import {RuleSanctionsListOwnable2Step} from "src/rules/validation/deployment/RuleSanctionsListOwnable2Step.sol";
4+
import {ISanctionsList} from "../../rules/interfaces/ISanctionsList.sol";
5+
import {RuleSanctionsListOwnable2Step} from "../../rules/validation/deployment/RuleSanctionsListOwnable2Step.sol";
66

77
/**
88
* @title RuleSanctionsListOwnable2StepHarness — test harness exposing RuleSanctionsListOwnable2Step internals

src/mocks/harness/RuleSpenderWhitelistHarnesses.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// SPDX-License-Identifier: MPL-2.0
22
pragma solidity ^0.8.20;
33

4-
import {RuleSpenderWhitelist} from "src/rules/validation/deployment/RuleSpenderWhitelist.sol";
5-
import {RuleSpenderWhitelistOwnable2Step} from "src/rules/validation/deployment/RuleSpenderWhitelistOwnable2Step.sol";
4+
import {RuleSpenderWhitelist} from "../../rules/validation/deployment/RuleSpenderWhitelist.sol";
5+
import {RuleSpenderWhitelistOwnable2Step} from "../../rules/validation/deployment/RuleSpenderWhitelistOwnable2Step.sol";
66

77
/**
88
* @title RuleSpenderWhitelistHarness — test harness exposing RuleSpenderWhitelist internals

src/mocks/harness/RuleWhitelistWrapperHarnessInternal.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: MPL-2.0
22
pragma solidity ^0.8.20;
33

4-
import {RuleWhitelistWrapper} from "src/rules/validation/deployment/RuleWhitelistWrapper.sol";
4+
import {RuleWhitelistWrapper} from "../../rules/validation/deployment/RuleWhitelistWrapper.sol";
55

66
/**
77
* @title RuleWhitelistWrapperHarnessInternal — test harness exposing RuleWhitelistWrapper internal transfer hook
@@ -16,6 +16,7 @@ contract RuleWhitelistWrapperHarnessInternal is RuleWhitelistWrapper {
1616
* @param admin Address granted the admin role
1717
* @param forwarderIrrevocable Trusted ERC-2771 forwarder address
1818
* @param checkSpender_ Whether the spender is also checked against the whitelist
19+
* @param allowMintBurn Whether minting and burning are permitted (sets both flags)
1920
*/
2021
constructor(address admin, address forwarderIrrevocable, bool checkSpender_, bool allowMintBurn)
2122
RuleWhitelistWrapper(admin, forwarderIrrevocable, checkSpender_, allowMintBurn)

src/rules/operation/abstract/RuleConditionalTransferLightMultiTokenBase.sol

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -313,39 +313,6 @@ abstract contract RuleConditionalTransferLightMultiTokenBase is
313313
== uint8(IERC1404Extend.REJECTED_CODE_BASE.TRANSFER_OK);
314314
}
315315

316-
/**
317-
* @notice Computes the restriction code for a transfer of `token`, independently of the caller.
318-
* @dev Single source of truth for the read path: {detectTransferRestriction} feeds it
319-
* `_msgSender()`, while {detectTransferRestrictionForToken} feeds it an explicit token, so
320-
* the two can never disagree. Mints and burns are exempt; an unbound token has no
321-
* consumable approvals and is therefore always restricted (fail-closed).
322-
* @param token The token the transfer applies to.
323-
* @param from The sender of the transfer.
324-
* @param to The recipient of the transfer.
325-
* @param value The amount of the transfer.
326-
* @return The restriction code, or TRANSFER_OK when an approval exists.
327-
*/
328-
function _detectTransferRestrictionForToken(address token, address from, address to, uint256 value)
329-
internal
330-
view
331-
virtual
332-
returns (uint8)
333-
{
334-
if (from == address(0) || to == address(0)) {
335-
return uint8(IERC1404Extend.REJECTED_CODE_BASE.TRANSFER_OK);
336-
}
337-
338-
if (!isTokenBound(token)) {
339-
return CODE_TRANSFER_REQUEST_NOT_APPROVED;
340-
}
341-
342-
if (approvalCounts[_transferHash(token, from, to, value)] == 0) {
343-
return CODE_TRANSFER_REQUEST_NOT_APPROVED;
344-
}
345-
346-
return uint8(IERC1404Extend.REJECTED_CODE_BASE.TRANSFER_OK);
347-
}
348-
349316
/**
350317
* @notice Authorizes changes to compliance binding: restricted to the compliance manager.
351318
* @dev NOT `view`, unlike every other access-control hook in this codebase. This is structural,
@@ -415,6 +382,39 @@ abstract contract RuleConditionalTransferLightMultiTokenBase is
415382
emit TransferExecuted(token, from, to, value, approvalCounts[transferHash]);
416383
}
417384

385+
/**
386+
* @notice Computes the restriction code for a transfer of `token`, independently of the caller.
387+
* @dev Single source of truth for the read path: {detectTransferRestriction} feeds it
388+
* `_msgSender()`, while {detectTransferRestrictionForToken} feeds it an explicit token, so
389+
* the two can never disagree. Mints and burns are exempt; an unbound token has no
390+
* consumable approvals and is therefore always restricted (fail-closed).
391+
* @param token The token the transfer applies to.
392+
* @param from The sender of the transfer.
393+
* @param to The recipient of the transfer.
394+
* @param value The amount of the transfer.
395+
* @return The restriction code, or TRANSFER_OK when an approval exists.
396+
*/
397+
function _detectTransferRestrictionForToken(address token, address from, address to, uint256 value)
398+
internal
399+
view
400+
virtual
401+
returns (uint8)
402+
{
403+
if (from == address(0) || to == address(0)) {
404+
return uint8(IERC1404Extend.REJECTED_CODE_BASE.TRANSFER_OK);
405+
}
406+
407+
if (!isTokenBound(token)) {
408+
return CODE_TRANSFER_REQUEST_NOT_APPROVED;
409+
}
410+
411+
if (approvalCounts[_transferHash(token, from, to, value)] == 0) {
412+
return CODE_TRANSFER_REQUEST_NOT_APPROVED;
413+
}
414+
415+
return uint8(IERC1404Extend.REJECTED_CODE_BASE.TRANSFER_OK);
416+
}
417+
418418
/**
419419
* @notice Authorizes transfer execution: only a bound token may call the execution hooks.
420420
*/

0 commit comments

Comments
 (0)