Skip to content

Commit f9f5e90

Browse files
authored
Refactoring & Tests (#5)
* init module tests + debug * refactored & coverage 100% * fix * refactored example & bumped version * fix * typo lic
1 parent bedabe3 commit f9f5e90

40 files changed

+11499
-387
lines changed

contracts/core/KYCCompliance.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ abstract contract KYCCompliance is IKYCCompliance, KYCComplianceStorage, AgentAc
4040
}
4141

4242
/// @inheritdoc IKYCCompliance
43-
function isKYCed(TokenF.Context calldata ctx_) public view virtual returns (bool) {
43+
function isKYCed(TokenF.Context memory ctx_) public view virtual returns (bool) {
4444
address[] memory regulatoryModules_ = getKYCModules();
4545

4646
for (uint256 i = 0; i < regulatoryModules_.length; ++i) {

contracts/core/RegulatoryCompliance.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ abstract contract RegulatoryCompliance is
5252
}
5353

5454
/// @inheritdoc IRegulatoryCompliance
55-
function transferred(TokenF.Context calldata ctx_) public virtual onlyThis {
55+
function transferred(TokenF.Context memory ctx_) public virtual onlyThis {
5656
address[] memory regulatoryModules_ = getRegulatoryModules();
5757

5858
for (uint256 i = 0; i < regulatoryModules_.length; ++i) {
@@ -61,7 +61,7 @@ abstract contract RegulatoryCompliance is
6161
}
6262

6363
/// @inheritdoc IRegulatoryCompliance
64-
function canTransfer(TokenF.Context calldata ctx_) public view virtual returns (bool) {
64+
function canTransfer(TokenF.Context memory ctx_) public view virtual returns (bool) {
6565
address[] memory regulatoryModules_ = getRegulatoryModules();
6666

6767
for (uint256 i = 0; i < regulatoryModules_.length; ++i) {

contracts/interfaces/IKYCCompliance.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,5 @@ interface IKYCCompliance is IKYCComplianceView {
5656
* @param ctx_ The context of the transaction
5757
* @return true if the passed context satisfies the checks on all modules
5858
*/
59-
function isKYCed(ITokenF.Context calldata ctx_) external view returns (bool);
59+
function isKYCed(ITokenF.Context memory ctx_) external view returns (bool);
6060
}

contracts/interfaces/IRegulatoryCompliance.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ interface IRegulatoryCompliance is IRegulatoryComplianceView {
5656
*
5757
* @param ctx_ The context of transaction
5858
*/
59-
function transferred(ITokenF.Context calldata ctx_) external;
59+
function transferred(ITokenF.Context memory ctx_) external;
6060

6161
/**
6262
* @notice Function that is used to verify that all necessary regulatory rules that have been added to `RegulatoryCompliance` have been met.
@@ -66,5 +66,5 @@ interface IRegulatoryCompliance is IRegulatoryComplianceView {
6666
* @param ctx_ The context of transaction
6767
* @return true if the passed context satisfies the rules in all installed regulatory modules.
6868
*/
69-
function canTransfer(ITokenF.Context calldata ctx_) external view returns (bool);
69+
function canTransfer(ITokenF.Context memory ctx_) external view returns (bool);
7070
}

contracts/mock/core/ComplianceFalseHooksMock.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ pragma solidity ^0.8.20;
44
import {TokenF} from "../../core/TokenF.sol";
55

66
contract ComplianceFalseHooksMock {
7-
function isKYCed(TokenF.Context calldata) external returns (bool) {
7+
function isKYCed(TokenF.Context memory) external pure returns (bool) {
88
return false;
99
}
1010

11-
function canTransfer(TokenF.Context calldata) external returns (bool) {
11+
function canTransfer(TokenF.Context memory) external pure returns (bool) {
1212
return false;
1313
}
1414
}

contracts/mock/core/ComplianceRevertHooksMock.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ pragma solidity ^0.8.20;
44
import {TokenF} from "../../core/TokenF.sol";
55

66
contract ComplianceRevertHooksMock {
7-
function transferred(TokenF.Context calldata) external {
7+
function transferred(TokenF.Context memory) external pure {
88
revert("ComplianceRevertHooksMock: revert");
99
}
1010

11-
function isKYCed(TokenF.Context calldata) external view returns (bool) {
11+
function isKYCed(TokenF.Context memory) external pure returns (bool) {
1212
revert("ComplianceRevertHooksMock: revert");
1313
}
1414

15-
function canTransfer(TokenF.Context calldata) external view returns (bool) {
15+
function canTransfer(TokenF.Context memory) external pure returns (bool) {
1616
revert("ComplianceRevertHooksMock: revert");
1717
}
1818
}

contracts/mock/core/KYCComplianceMock.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ contract KYCComplianceMock is KYCCompliance {
1818
return super._KYCComplianceRole();
1919
}
2020

21-
function _KYCComplianceRole() internal view override returns (bytes32) {
21+
function _KYCComplianceRole() internal pure override returns (bytes32) {
2222
return KYC_COMPLIANCE_ROLE;
2323
}
2424
}

contracts/mock/core/RegulatoryComplianceMock.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ contract RegulatoryComplianceMock is RegulatoryCompliance {
2121
return super._regulatoryComplianceRole();
2222
}
2323

24-
function _regulatoryComplianceRole() internal view override returns (bytes32) {
24+
function _regulatoryComplianceRole() internal pure override returns (bytes32) {
2525
return REGULATORY_COMPLIANCE_ROLE;
2626
}
2727
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.0;
3+
4+
import {TokenF} from "../../core/TokenF.sol";
5+
import {AbstractRegulatoryModule} from "../../modules/AbstractRegulatoryModule.sol";
6+
import {AbstractKYCModule} from "../../modules/AbstractKYCModule.sol";
7+
8+
contract ModuleMock is AbstractRegulatoryModule, AbstractKYCModule {
9+
bytes32 public constant MOCK_TOPIC = keccak256("MOCK");
10+
11+
function __ModuleMock_init(address tokenF_) external initializer {
12+
__AbstractModule_init(tokenF_);
13+
__AbstractRegulatoryModule_init();
14+
__AbstractKYCModule_init();
15+
}
16+
17+
function _handlerer() internal override {}
18+
19+
function handlerer() external {
20+
_setHandler(MOCK_TOPIC, _handleMockTopic);
21+
}
22+
23+
function __AbstractModuleDirect_init() external {
24+
__AbstractModule_init(address(0));
25+
}
26+
27+
function __AbstractRegulatoryModuleDirect_init() external {
28+
__AbstractRegulatoryModule_init();
29+
}
30+
31+
function __AbstractKYCModuleDirect_init() external {
32+
__AbstractKYCModule_init();
33+
}
34+
35+
function getClaimTopicKey(bytes4 selector_) external view returns (bytes32) {
36+
TokenF.Context memory ctx_;
37+
ctx_.selector = selector_;
38+
39+
return _getClaimTopicKey(ctx_);
40+
}
41+
42+
function _handleMockTopic(TokenF.Context memory ctx_) internal view virtual returns (bool) {
43+
return true;
44+
}
45+
}

contracts/mock/modules/kyc/KYCCorrectModuleMock.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {AbstractKYCModule} from "../../../modules/AbstractKYCModule.sol";
77
contract KYCCorrectModuleMock is AbstractKYCModule {
88
function _handlerer() internal override {}
99

10-
function isKYCed(TokenF.Context calldata) public pure override returns (bool) {
10+
function isKYCed(TokenF.Context memory) public pure override returns (bool) {
1111
return true;
1212
}
1313
}

0 commit comments

Comments
 (0)