Skip to content

Commit e7fd169

Browse files
committed
update readme and format code
1 parent 152615f commit e7fd169

20 files changed

Lines changed: 918 additions & 198 deletions

README.md

Lines changed: 619 additions & 23 deletions
Large diffs are not rendered by default.

doc/codelist.md

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/modules/AccessControlModuleStandalone.sol

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@ abstract contract AccessControlModuleStandalone is AccessControl {
99
error AccessControlModuleStandalone_AddressZeroNotAllowed();
1010
/* ============ Constructor ============ */
1111
/**
12-
* @notice Assigns the provided address as the default admin.
13-
* @dev
14-
* - Reverts if `admin` is the zero address.
15-
* - Grants `DEFAULT_ADMIN_ROLE` to `admin`.
16-
* The return value of `_grantRole` is intentionally ignored, as it returns `false`
17-
* only when the role was already granted.
18-
*
19-
* @param admin The address that will receive the `DEFAULT_ADMIN_ROLE`.
20-
*/
21-
constructor(address admin)
22-
{
23-
if(admin == address(0)){
12+
* @notice Assigns the provided address as the default admin.
13+
* @dev
14+
* - Reverts if `admin` is the zero address.
15+
* - Grants `DEFAULT_ADMIN_ROLE` to `admin`.
16+
* The return value of `_grantRole` is intentionally ignored, as it returns `false`
17+
* only when the role was already granted.
18+
*
19+
* @param admin The address that will receive the `DEFAULT_ADMIN_ROLE`.
20+
*/
21+
22+
constructor(address admin) {
23+
if (admin == address(0)) {
2424
revert AccessControlModuleStandalone_AddressZeroNotAllowed();
2525
}
2626
// we don't check the return value
@@ -29,17 +29,13 @@ abstract contract AccessControlModuleStandalone is AccessControl {
2929
_grantRole(DEFAULT_ADMIN_ROLE, admin);
3030
}
3131

32-
3332
/*//////////////////////////////////////////////////////////////
3433
PUBLIC/EXTERNAL FUNCTIONS
3534
//////////////////////////////////////////////////////////////*/
36-
/**
35+
/**
3736
* @dev Returns `true` if `account` has been granted `role`.
3837
*/
39-
function hasRole(
40-
bytes32 role,
41-
address account
42-
) public view virtual override(AccessControl) returns (bool) {
38+
function hasRole(bytes32 role, address account) public view virtual override(AccessControl) returns (bool) {
4339
// The Default Admin has all roles
4440
if (AccessControl.hasRole(DEFAULT_ADMIN_ROLE, account)) {
4541
return true;

src/rules/interfaces/IAddressList.sol

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
pragma solidity ^0.8.0;
33

44
import {IIdentityRegistryContains} from "./IIdentityRegistry.sol";
5+
56
interface IAddressList is IIdentityRegistryContains {
67
/* ============ Events ============ */
78
/// @notice Emitted when multiple addresses are added.
@@ -20,7 +21,6 @@ interface IAddressList is IIdentityRegistryContains {
2021
/// @param targetAddress The removed address.
2122
event RemoveAddress(address targetAddress);
2223

23-
2424
/* ============ Write ============ */
2525
/**
2626
* @notice Adds multiple addresses to the set.
@@ -50,7 +50,6 @@ interface IAddressList is IIdentityRegistryContains {
5050
*/
5151
function removeAddress(address targetAddress) external;
5252

53-
5453
/* ============ Read ============ */
5554

5655
/**
@@ -71,8 +70,5 @@ interface IAddressList is IIdentityRegistryContains {
7170
* @param targetAddresses Array of addresses to check.
7271
* @return results Boolean array aligned by index with listing results.
7372
*/
74-
function areAddressesListed(address[] memory targetAddresses)
75-
external
76-
view
77-
returns (bool[] memory results);
78-
}
73+
function areAddressesListed(address[] memory targetAddresses) external view returns (bool[] memory results);
74+
}

src/rules/interfaces/IERC7943NonFungibleCompliance.sol

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ pragma solidity ^0.8.20;
1111
* whether a transfer is permitted according to rule-based restrictions.
1212
*/
1313
interface IERC7943NonFungibleCompliance {
14-
/**
14+
/**
1515
* @notice Verifies whether a transfer is permitted according to the token’s compliance rules.
1616
* @dev
1717
* This function must not modify state.
1818
* It may enforce checks such as:
19-
* - Allowlist / blocklist membership
20-
* - Freezing rules
21-
* - Transfer limitations
22-
* - Jurisdictional, regulatory, or policy-driven restrictions
19+
* - Allowlist / blocklist membership
20+
* - Freezing rules
21+
* - Transfer limitations
22+
* - Jurisdictional, regulatory, or policy-driven restrictions
2323
* If the transfer is not allowed, this function MUST return `false`.
2424
*
2525
* @param from The address currently holding the token.
@@ -28,25 +28,28 @@ interface IERC7943NonFungibleCompliance {
2828
* @param amount The amount being transferred (always `1` for ERC-721).
2929
* @return allowed `true` if the transfer is permitted, otherwise `false`.
3030
*/
31-
function canTransfer(address from, address to, uint256 tokenId, uint256 amount) external view returns (bool allowed);
31+
function canTransfer(address from, address to, uint256 tokenId, uint256 amount)
32+
external
33+
view
34+
returns (bool allowed);
3235
}
3336

3437
/**
3538
* @title IERC7943NonFungibleComplianceExtend
3639
* @notice Extended compliance interface for ERC-721/1155–style non-fungible assets.
3740
* @dev
3841
* Adds functionality for:
39-
* - Returning standardized transfer-restriction codes
40-
* - Compliance checks involving a spender (e.g., approvals and operators)
41-
* - Writing compliance-related state upon successful transfers
42+
* - Returning standardized transfer-restriction codes
43+
* - Compliance checks involving a spender (e.g., approvals and operators)
44+
* - Writing compliance-related state upon successful transfers
4245
* For ERC-721, `amount/value` MUST be set to `1`.
4346
*/
44-
interface IERC7943NonFungibleComplianceExtend is IERC7943NonFungibleCompliance {
47+
interface IERC7943NonFungibleComplianceExtend is IERC7943NonFungibleCompliance {
4548
/**
4649
* @notice Returns a transfer-restriction code describing why a transfer is blocked.
4750
* @dev
48-
* - MUST NOT modify state.
49-
* - MUST return `0` when the transfer is allowed.
51+
* - MUST NOT modify state.
52+
* - MUST return `0` when the transfer is allowed.
5053
* - Non-zero codes SHOULD follow the ERC-1404 or RuleEngine restriction-code conventions.
5154
*
5255
* @param from The address currently holding the token.
@@ -55,8 +58,11 @@ interface IERC7943NonFungibleCompliance {
5558
* @param amount The amount being transferred (always `1` for ERC-721).
5659
* @return code A restriction code: `0` for success, otherwise an implementation-defined error code.
5760
*/
58-
function detectTransferRestriction(address from, address to, uint256 tokenId, uint256 amount ) external view returns(uint8 code);
59-
61+
function detectTransferRestriction(address from, address to, uint256 tokenId, uint256 amount)
62+
external
63+
view
64+
returns (uint8 code);
65+
6066
/**
6167
* @notice Returns a transfer-restriction code for transfers triggered by a spender.
6268
* @dev
@@ -89,7 +95,9 @@ interface IERC7943NonFungibleCompliance {
8995
* @param value The transfer amount (always `1` for ERC-721).
9096
* @return allowed `true` if the transfer is permitted, otherwise `false`.
9197
*/
92-
function canTransferFrom(address spender, address from, address to, uint256 tokenId, uint256 value) external returns (bool allowed);
98+
function canTransferFrom(address spender, address from, address to, uint256 tokenId, uint256 value)
99+
external
100+
returns (bool allowed);
93101

94102
/**
95103
* @notice Notifies the rule engine or compliance module that a transfer has been executed.
@@ -106,4 +114,3 @@ interface IERC7943NonFungibleCompliance {
106114
*/
107115
function transferred(address spender, address from, address to, uint256 tokenId, uint256 value) external;
108116
}
109-

src/rules/validation/RuleBlacklist.sol

Lines changed: 52 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
pragma solidity ^0.8.20;
44

55
/* ==== Abtract contracts === */
6-
import {RuleBlacklistInvariantStorage} from "./abstract/RuleAddressSet/invariantStorage/RuleBlacklistInvariantStorage.sol";
6+
import {RuleBlacklistInvariantStorage} from
7+
"./abstract/RuleAddressSet/invariantStorage/RuleBlacklistInvariantStorage.sol";
78
import {RuleAddressSet} from "./abstract/RuleAddressSet/RuleAddressSet.sol";
89
import {RuleValidateTransfer} from "./abstract/RuleValidateTransfer.sol";
910
/* ==== Interfaces === */
@@ -54,7 +55,7 @@ contract RuleBlacklist is RuleValidateTransfer, RuleAddressSet, RuleBlacklistInv
5455
/*
5556
* @inheritdoc IERC7943NonFungibleComplianceExtend
5657
*/
57-
function detectTransferRestriction(address from, address to, uint256 /* tokenId */, uint256 value )
58+
function detectTransferRestriction(address from, address to, uint256, /* tokenId */ uint256 value)
5859
public
5960
view
6061
override(IERC7943NonFungibleComplianceExtend)
@@ -80,14 +81,15 @@ contract RuleBlacklist is RuleValidateTransfer, RuleAddressSet, RuleBlacklistInv
8081
}
8182

8283
/**
83-
* @inheritdoc IERC7943NonFungibleComplianceExtend
84-
*/
85-
function detectTransferRestrictionFrom(address spender, address from, address to, uint256 /* tokenId */, uint256 value )
86-
public
87-
view
88-
override(IERC7943NonFungibleComplianceExtend)
89-
returns (uint8)
90-
{
84+
* @inheritdoc IERC7943NonFungibleComplianceExtend
85+
*/
86+
function detectTransferRestrictionFrom(
87+
address spender,
88+
address from,
89+
address to,
90+
uint256, /* tokenId */
91+
uint256 value
92+
) public view override(IERC7943NonFungibleComplianceExtend) returns (uint8) {
9193
return detectTransferRestrictionFrom(spender, from, to, value);
9294
}
9395

@@ -97,7 +99,13 @@ contract RuleBlacklist is RuleValidateTransfer, RuleAddressSet, RuleBlacklistInv
9799
* @return true if the restriction code is known, false otherwise
98100
*
99101
*/
100-
function canReturnTransferRestrictionCode(uint8 _restrictionCode) public pure virtual override(IRule) returns (bool) {
102+
function canReturnTransferRestrictionCode(uint8 _restrictionCode)
103+
public
104+
pure
105+
virtual
106+
override(IRule)
107+
returns (bool)
108+
{
101109
return _restrictionCode == CODE_ADDRESS_FROM_IS_BLACKLISTED
102110
|| _restrictionCode == CODE_ADDRESS_TO_IS_BLACKLISTED || _restrictionCode == CODE_ADDRESS_SPENDER_IS_BLACKLISTED;
103111
}
@@ -108,7 +116,13 @@ contract RuleBlacklist is RuleValidateTransfer, RuleAddressSet, RuleBlacklistInv
108116
* @return true if the transfer is valid, false otherwise
109117
*
110118
*/
111-
function messageForTransferRestriction(uint8 _restrictionCode) public pure virtual override(IERC1404) returns (string memory) {
119+
function messageForTransferRestriction(uint8 _restrictionCode)
120+
public
121+
pure
122+
virtual
123+
override(IERC1404)
124+
returns (string memory)
125+
{
112126
if (_restrictionCode == CODE_ADDRESS_FROM_IS_BLACKLISTED) {
113127
return TEXT_ADDRESS_FROM_IS_BLACKLISTED;
114128
} else if (_restrictionCode == CODE_ADDRESS_TO_IS_BLACKLISTED) {
@@ -122,17 +136,38 @@ contract RuleBlacklist is RuleValidateTransfer, RuleAddressSet, RuleBlacklistInv
122136

123137
/* ============ State Functions ============ */
124138

125-
function transferred(address from, address to, uint256 value) public view virtual override(IERC3643IComplianceContract) {
139+
function transferred(address from, address to, uint256 value)
140+
public
141+
view
142+
virtual
143+
override(IERC3643IComplianceContract)
144+
{
126145
uint8 code = this.detectTransferRestriction(from, to, value);
127-
require(code == uint8(REJECTED_CODE_BASE.TRANSFER_OK), RuleBlacklist_InvalidTransfer(address(this), from, to, value, code));
146+
require(
147+
code == uint8(REJECTED_CODE_BASE.TRANSFER_OK),
148+
RuleBlacklist_InvalidTransfer(address(this), from, to, value, code)
149+
);
128150
}
129151

130-
function transferred(address spender, address from, address to, uint256 value) public view virtual override(IRuleEngine) {
152+
function transferred(address spender, address from, address to, uint256 value)
153+
public
154+
view
155+
virtual
156+
override(IRuleEngine)
157+
{
131158
uint8 code = this.detectTransferRestrictionFrom(spender, from, to, value);
132-
require(code == uint8(REJECTED_CODE_BASE.TRANSFER_OK), RuleBlacklist_InvalidTransfer(address(this), from, to, value, code));
159+
require(
160+
code == uint8(REJECTED_CODE_BASE.TRANSFER_OK),
161+
RuleBlacklist_InvalidTransfer(address(this), from, to, value, code)
162+
);
133163
}
134164

135-
function transferred(address spender, address from, address to, uint256 /* tokenId */, uint256 value) public view virtual override(IERC7943NonFungibleComplianceExtend) {
165+
function transferred(address spender, address from, address to, uint256, /* tokenId */ uint256 value)
166+
public
167+
view
168+
virtual
169+
override(IERC7943NonFungibleComplianceExtend)
170+
{
136171
transferred(spender, from, to, value);
137172
}
138173
}

0 commit comments

Comments
 (0)