@t-rex-network/t-rex 4.2.0-beta1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +674 -0
- package/README.md +137 -0
- package/contracts/ERC-3643/ERC3643EventsLib.sol +150 -0
- package/contracts/ERC-3643/IERC3643.sol +408 -0
- package/contracts/ERC-3643/IERC3643ClaimTopicsRegistry.sol +66 -0
- package/contracts/ERC-3643/IERC3643Compliance.sol +127 -0
- package/contracts/ERC-3643/IERC3643IdentityRegistry.sol +180 -0
- package/contracts/ERC-3643/IERC3643IdentityRegistryStorage.sol +120 -0
- package/contracts/ERC-3643/IERC3643TrustedIssuersRegistry.sol +120 -0
- package/contracts/compliance/modular/IModularCompliance.sol +143 -0
- package/contracts/compliance/modular/ModularCompliance.sol +381 -0
- package/contracts/compliance/modular/modules/AbstractModuleUpgradeable.sol +193 -0
- package/contracts/compliance/modular/modules/IModule.sol +158 -0
- package/contracts/compliance/modular/modules/ModuleProxy.sol +72 -0
- package/contracts/factory/ITREXFactory.sol +180 -0
- package/contracts/factory/ITREXGateway.sol +234 -0
- package/contracts/factory/TREXFactory.sol +358 -0
- package/contracts/factory/TREXGateway.sol +274 -0
- package/contracts/libraries/ErrorsLib.sol +168 -0
- package/contracts/libraries/EventsLib.sol +147 -0
- package/contracts/proxy/AbstractProxy.sol +146 -0
- package/contracts/proxy/ClaimTopicsRegistryProxy.sol +83 -0
- package/contracts/proxy/IdentityRegistryProxy.sol +95 -0
- package/contracts/proxy/IdentityRegistryStorageProxy.sol +83 -0
- package/contracts/proxy/ModularComplianceProxy.sol +88 -0
- package/contracts/proxy/TokenProxy.sol +97 -0
- package/contracts/proxy/TrustedIssuersRegistryProxy.sol +88 -0
- package/contracts/proxy/authority/IAFactory.sol +122 -0
- package/contracts/proxy/authority/IIAFactory.sol +87 -0
- package/contracts/proxy/authority/ITREXImplementationAuthority.sol +239 -0
- package/contracts/proxy/authority/TREXImplementationAuthority.sol +350 -0
- package/contracts/proxy/interface/IProxy.sol +72 -0
- package/contracts/registry/implementation/ClaimTopicsRegistry.sol +152 -0
- package/contracts/registry/implementation/IdentityRegistry.sol +352 -0
- package/contracts/registry/implementation/IdentityRegistryStorage.sol +227 -0
- package/contracts/registry/implementation/TrustedIssuersRegistry.sol +272 -0
- package/contracts/registry/interface/IClaimTopicsRegistry.sol +70 -0
- package/contracts/registry/interface/IIdentityRegistry.sol +102 -0
- package/contracts/registry/interface/IIdentityRegistryStorage.sol +70 -0
- package/contracts/registry/interface/ITrustedIssuersRegistry.sol +70 -0
- package/contracts/roles/AbstractAgentRole.sol +122 -0
- package/contracts/roles/AgentRole.sol +82 -0
- package/contracts/roles/AgentRoleUpgradeable.sol +82 -0
- package/contracts/roles/IERC173.sol +21 -0
- package/contracts/roles/Roles.sol +102 -0
- package/contracts/token/IToken.sol +97 -0
- package/contracts/token/Token.sol +664 -0
- package/contracts/token/TokenStructs.sol +74 -0
- package/contracts/utils/IUtilityChecker.sol +135 -0
- package/contracts/utils/InterfaceIdCalculator.sol +223 -0
- package/contracts/utils/UtilityChecker.sol +210 -0
- package/contracts/utils/UtilityCheckerProxy.sol +72 -0
- package/contracts/vendor/openzeppelin/Create3.sol +143 -0
- package/out/AbstractAgentRole.sol/AbstractAgentRole.json +1 -0
- package/out/AbstractModuleUpgradeable.sol/AbstractModuleUpgradeable.json +1 -0
- package/out/AbstractProxy.sol/AbstractProxy.json +1 -0
- package/out/Address.sol/Address.json +1 -0
- package/out/AgentRole.sol/AgentRole.json +1 -0
- package/out/AgentRoleUpgradeable.sol/AgentRoleUpgradeable.json +1 -0
- package/out/Arrays.sol/Arrays.json +1 -0
- package/out/Base.sol/CommonBase.json +1 -0
- package/out/Base.sol/ScriptBase.json +1 -0
- package/out/Base.sol/TestBase.json +1 -0
- package/out/Bytes.sol/Bytes.json +1 -0
- package/out/ClaimIssuer.sol/ClaimIssuer.json +1 -0
- package/out/ClaimIssuerTrick.sol/ClaimIssuerTrick.json +1 -0
- package/out/ClaimTopicsRegistry.sol/ClaimTopicsRegistry.json +1 -0
- package/out/ClaimTopicsRegistryProxy.sol/ClaimTopicsRegistryProxy.json +1 -0
- package/out/Comparators.sol/Comparators.json +1 -0
- package/out/Context.sol/Context.json +1 -0
- package/out/ContextUpgradeable.sol/ContextUpgradeable.json +1 -0
- package/out/Countries.sol/Countries.json +1 -0
- package/out/Create2.sol/Create2.json +1 -0
- package/out/Create3.sol/Create3.json +1 -0
- package/out/ECDSA.sol/ECDSA.json +1 -0
- package/out/EIP712.sol/EIP712.json +1 -0
- package/out/EIP712Upgradeable.sol/EIP712Upgradeable.json +1 -0
- package/out/ERC1967Proxy.sol/ERC1967Proxy.json +1 -0
- package/out/ERC1967Utils.sol/ERC1967Utils.json +1 -0
- package/out/ERC20.sol/ERC20.json +1 -0
- package/out/ERC20Pausable.sol/ERC20Pausable.json +1 -0
- package/out/ERC20PermitUpgradeable.sol/ERC20PermitUpgradeable.json +1 -0
- package/out/ERC20Upgradeable.sol/ERC20Upgradeable.json +1 -0
- package/out/ERC2771Context.sol/ERC2771Context.json +1 -0
- package/out/ERC2771ContextUpgradeable.sol/ERC2771ContextUpgradeable.json +1 -0
- package/out/ERC2771Forwarder.sol/ERC2771Forwarder.json +1 -0
- package/out/ERC3643EventsLib.sol/ERC3643EventsLib.json +1 -0
- package/out/EnumerableSet.sol/EnumerableSet.json +1 -0
- package/out/Errors.sol/Errors.json +1 -0
- package/out/ErrorsLib.sol/ErrorsLib.json +1 -0
- package/out/EventsLib.sol/EventsLib.json +1 -0
- package/out/IAFactory.sol/IAFactory.json +1 -0
- package/out/IBeacon.sol/IBeacon.json +1 -0
- package/out/IClaimIssuer.sol/IClaimIssuer.json +1 -0
- package/out/IClaimTopicsRegistry.sol/IClaimTopicsRegistry.json +1 -0
- package/out/IERC1363.sol/IERC1363.json +1 -0
- package/out/IERC165.sol/IERC165.json +1 -0
- package/out/IERC173.sol/IERC173.json +1 -0
- package/out/IERC1967.sol/IERC1967.json +1 -0
- package/out/IERC20.sol/IERC20.json +1 -0
- package/out/IERC20Metadata.sol/IERC20Metadata.json +1 -0
- package/out/IERC20Permit.sol/IERC20Permit.json +1 -0
- package/out/IERC3643.sol/IERC3643.json +1 -0
- package/out/IERC3643ClaimTopicsRegistry.sol/IERC3643ClaimTopicsRegistry.json +1 -0
- package/out/IERC3643Compliance.sol/IERC3643Compliance.json +1 -0
- package/out/IERC3643IdentityRegistry.sol/IERC3643IdentityRegistry.json +1 -0
- package/out/IERC3643IdentityRegistryStorage.sol/IERC3643IdentityRegistryStorage.json +1 -0
- package/out/IERC3643TrustedIssuersRegistry.sol/IERC3643TrustedIssuersRegistry.json +1 -0
- package/out/IERC5267.sol/IERC5267.json +1 -0
- package/out/IERC734.sol/IERC734.json +1 -0
- package/out/IERC735.sol/IERC735.json +1 -0
- package/out/IIAFactory.sol/IIAFactory.json +1 -0
- package/out/IIdFactory.sol/IIdFactory.json +1 -0
- package/out/IIdentity.sol/IIdentity.json +1 -0
- package/out/IIdentityRegistry.sol/IIdentityRegistry.json +1 -0
- package/out/IIdentityRegistryStorage.sol/IIdentityRegistryStorage.json +1 -0
- package/out/IImplementationAuthority.sol/IImplementationAuthority.json +1 -0
- package/out/IModularCompliance.sol/IModularCompliance.json +1 -0
- package/out/IModule.sol/IModule.json +1 -0
- package/out/IMulticall3.sol/IMulticall3.json +1 -0
- package/out/IProxy.sol/IProxy.json +1 -0
- package/out/ITREXFactory.sol/ITREXFactory.json +1 -0
- package/out/ITREXGateway.sol/ITREXGateway.json +1 -0
- package/out/ITREXImplementationAuthority.sol/ITREXImplementationAuthority.json +1 -0
- package/out/IToken.sol/IToken.json +1 -0
- package/out/ITrustedIssuersRegistry.sol/ITrustedIssuersRegistry.json +1 -0
- package/out/IUtilityChecker.sol/IUtilityChecker.json +1 -0
- package/out/IdFactory.sol/IdFactory.json +1 -0
- package/out/Identity.sol/Identity.json +1 -0
- package/out/IdentityProxy.sol/IdentityProxy.json +1 -0
- package/out/IdentityRegistry.sol/IdentityRegistry.json +1 -0
- package/out/IdentityRegistryProxy.sol/IdentityRegistryProxy.json +1 -0
- package/out/IdentityRegistryStorage.sol/IdentityRegistryStorage.json +1 -0
- package/out/IdentityRegistryStorageProxy.sol/IdentityRegistryStorageProxy.json +1 -0
- package/out/ImplementationAuthority.sol/ImplementationAuthority.json +1 -0
- package/out/Initializable.sol/Initializable.json +1 -0
- package/out/InterfaceIdCalculator.sol/InterfaceIdCalculator.json +1 -0
- package/out/KeyPurposes.sol/KeyPurposes.json +1 -0
- package/out/KeyTypes.sol/KeyTypes.json +1 -0
- package/out/LowLevelCall.sol/LowLevelCall.json +1 -0
- package/out/Math.sol/Math.json +1 -0
- package/out/MessageHashUtils.sol/MessageHashUtils.json +1 -0
- package/out/ModularCompliance.sol/ModularCompliance.json +1 -0
- package/out/ModularComplianceProxy.sol/ModularComplianceProxy.json +1 -0
- package/out/ModuleNotPnP.sol/ModuleNotPnP.json +1 -0
- package/out/ModuleProxy.sol/ModuleProxy.json +1 -0
- package/out/MulticallUpgradeable.sol/MulticallUpgradeable.json +1 -0
- package/out/Nonces.sol/Nonces.json +1 -0
- package/out/NoncesUpgradeable.sol/NoncesUpgradeable.json +1 -0
- package/out/Ownable.sol/Ownable.json +1 -0
- package/out/Ownable2Step.sol/Ownable2Step.json +1 -0
- package/out/Ownable2StepUpgradeable.sol/Ownable2StepUpgradeable.json +1 -0
- package/out/OwnableUpgradeable.sol/OwnableUpgradeable.json +1 -0
- package/out/Panic.sol/Panic.json +1 -0
- package/out/Pausable.sol/Pausable.json +1 -0
- package/out/PausableUpgradeable.sol/PausableUpgradeable.json +1 -0
- package/out/Proxy.sol/Proxy.json +1 -0
- package/out/Roles.sol/Roles.json +1 -0
- package/out/SafeCast.sol/SafeCast.json +1 -0
- package/out/SafeERC20.sol/SafeERC20.json +1 -0
- package/out/ShortStrings.sol/ShortStrings.json +1 -0
- package/out/SignedMath.sol/SignedMath.json +1 -0
- package/out/SlotDerivation.sol/SlotDerivation.json +1 -0
- package/out/StdAssertions.sol/StdAssertions.json +1 -0
- package/out/StdChains.sol/StdChains.json +1 -0
- package/out/StdCheats.sol/StdCheats.json +1 -0
- package/out/StdCheats.sol/StdCheatsSafe.json +1 -0
- package/out/StdConstants.sol/StdConstants.json +1 -0
- package/out/StdError.sol/stdError.json +1 -0
- package/out/StdInvariant.sol/StdInvariant.json +1 -0
- package/out/StdJson.sol/stdJson.json +1 -0
- package/out/StdMath.sol/stdMath.json +1 -0
- package/out/StdStorage.sol/stdStorage.json +1 -0
- package/out/StdStorage.sol/stdStorageSafe.json +1 -0
- package/out/StdStyle.sol/StdStyle.json +1 -0
- package/out/StdToml.sol/stdToml.json +1 -0
- package/out/StdUtils.sol/StdUtils.json +1 -0
- package/out/Storage.sol/Storage.json +1 -0
- package/out/StorageSlot.sol/StorageSlot.json +1 -0
- package/out/Strings.sol/Strings.json +1 -0
- package/out/Structs.sol/Structs.json +1 -0
- package/out/TREXFactory.sol/TREXFactory.json +1 -0
- package/out/TREXGateway.sol/TREXGateway.json +1 -0
- package/out/TREXImplementationAuthority.sol/TREXImplementationAuthority.json +1 -0
- package/out/TestAgentRole.sol/TestAgentRole.json +1 -0
- package/out/TestAgentRoleUpgradeable.sol/TestAgentRoleUpgradeable.json +1 -0
- package/out/TestERC20.sol/TestERC20.json +1 -0
- package/out/TestModule.sol/TestModule.json +1 -0
- package/out/TestTREXFactory.sol/TestTREXFactory.json +1 -0
- package/out/Token.sol/Token.json +1 -0
- package/out/TokenProxy.sol/TokenProxy.json +1 -0
- package/out/TrustedIssuersRegistry.sol/TrustedIssuersRegistry.json +1 -0
- package/out/TrustedIssuersRegistryProxy.sol/TrustedIssuersRegistryProxy.json +1 -0
- package/out/UUPSUpgradeable.sol/UUPSUpgradeable.json +1 -0
- package/out/UtilityChecker.sol/UtilityChecker.json +1 -0
- package/out/UtilityCheckerProxy.sol/UtilityCheckerProxy.json +1 -0
- package/out/Utils.sol/Utils.json +1 -0
- package/out/Version.sol/Version.json +1 -0
- package/out/Vm.sol/Vm.json +1 -0
- package/out/Vm.sol/VmSafe.json +1 -0
- package/out/console.sol/console.json +1 -0
- package/out/draft-IERC1822.sol/IERC1822Proxiable.json +1 -0
- package/out/draft-IERC6093.sol/IERC1155Errors.json +1 -0
- package/out/draft-IERC6093.sol/IERC20Errors.json +1 -0
- package/out/draft-IERC6093.sol/IERC721Errors.json +1 -0
- package/out/libraries/Errors.sol/Errors.json +1 -0
- package/out/safeconsole.sol/safeconsole.json +1 -0
- package/package.json +47 -0
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0
|
|
2
|
+
//
|
|
3
|
+
// :+#####%%%%%%%%%%%%%%+
|
|
4
|
+
// .-*@@@%+.:+%@@@@@%%#***%@@%=
|
|
5
|
+
// :=*%@@@#=. :#@@% *@@@%=
|
|
6
|
+
// .-+*%@%*-.:+%@@@@@@+. -*+: .=#. :%@@@%-
|
|
7
|
+
// :=*@@@@%%@@@@@@@@@%@@@- .=#@@@%@%= =@@@@#.
|
|
8
|
+
// -=+#%@@%#*=:. :%@@@@%. -*@@#*@@@@@@@#=:- *@@@@+
|
|
9
|
+
// =@@%=:. :=: *@@@@@%#- =%*%@@@@#+-. =+ :%@@@%-
|
|
10
|
+
// -@@%. .+@@@ =+=-. @@#- +@@@%- =@@@@%:
|
|
11
|
+
// :@@@. .+@@#%: : .=*=-::.-%@@@+*@@= +@@@@#.
|
|
12
|
+
// %@@: +@%%* =%@@@@@@@@@@@#. .*@%- +@@@@*.
|
|
13
|
+
// #@@= .+@@@@%:=*@@@@@- :%@%: .*@@@@+
|
|
14
|
+
// *@@* +@@@#-@@%-:%@@* +@@#. :%@@@@-
|
|
15
|
+
// -@@% .:-=++*##%%%@@@@@@@@@@@@*. :@+.@@@%: .#@@+ =@@@@#:
|
|
16
|
+
// .@@@*-+*#%%%@@@@@@@@@@@@@@@@%%#**@@%@@@. *@=*@@# :#@%= .#@@@@#-
|
|
17
|
+
// -%@@@@@@@@@@@@@@@*+==-:-@@@= *@# .#@*-=*@@@@%= -%@@@* =@@@@@%-
|
|
18
|
+
// -+%@@@#. %@%%= -@@:+@: -@@* *@@*-:: -%@@%=. .*@@@@@#
|
|
19
|
+
// *@@@* +@* *@@##@@- #@*@@+ -@@= . :+@@@#: .-+@@@%+-
|
|
20
|
+
// +@@@%*@@:..=@@@@* .@@@* .#@#. .=+- .=%@@@*. :+#@@@@*=:
|
|
21
|
+
// =@@@@%@@@@@@@@@@@@@@@@@@@@@@%- :+#*. :*@@@%=. .=#@@@@%+:
|
|
22
|
+
// .%@@= ..... .=#@@+. .#@@@*: -*%@@@@%+.
|
|
23
|
+
// +@@#+===---:::... .=%@@*- +@@@+. -*@@@@@%+.
|
|
24
|
+
// -@@@@@@@@@@@@@@@@@@@@@@%@@@@= -@@@+ -#@@@@@#=.
|
|
25
|
+
// ..:::---===+++***###%%%@@@#- .#@@+ -*@@@@@#=.
|
|
26
|
+
// @@@@@@+. +@@*. .+@@@@@%=.
|
|
27
|
+
// -@@@@@= =@@%: -#@@@@%+.
|
|
28
|
+
// +@@@@@. =@@@= .+@@@@@*:
|
|
29
|
+
// #@@@@#:%@@#. :*@@@@#-
|
|
30
|
+
// @@@@@%@@@= :#@@@@+.
|
|
31
|
+
// :@@@@@@@#.:#@@@%-
|
|
32
|
+
// +@@@@@@-.*@@@*:
|
|
33
|
+
// #@@@@#.=@@@+.
|
|
34
|
+
// @@@@+-%@%=
|
|
35
|
+
// :@@@#%@%=
|
|
36
|
+
// +@@@@%-
|
|
37
|
+
// :#%%=
|
|
38
|
+
//
|
|
39
|
+
/**
|
|
40
|
+
* NOTICE
|
|
41
|
+
*
|
|
42
|
+
* The T-REX software is licensed under a proprietary license or the GPL v.3.
|
|
43
|
+
* If you choose to receive it under the GPL v.3 license, the following applies:
|
|
44
|
+
* T-REX is a suite of smart contracts implementing the ERC-3643 standard and
|
|
45
|
+
* developed by Tokeny to manage and transfer financial assets on EVM blockchains
|
|
46
|
+
*
|
|
47
|
+
* Copyright (C) 2025, Tokeny sàrl.
|
|
48
|
+
*
|
|
49
|
+
* This program is free software: you can redistribute it and/or modify
|
|
50
|
+
* it under the terms of the GNU General Public License as published by
|
|
51
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
52
|
+
* (at your option) any later version.
|
|
53
|
+
*
|
|
54
|
+
* This program is distributed in the hope that it will be useful,
|
|
55
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
56
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
57
|
+
* GNU General Public License for more details.
|
|
58
|
+
*
|
|
59
|
+
* You should have received a copy of the GNU General Public License
|
|
60
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
61
|
+
*/
|
|
62
|
+
|
|
63
|
+
pragma solidity 0.8.30;
|
|
64
|
+
|
|
65
|
+
import { Ownable2StepUpgradeable } from "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol";
|
|
66
|
+
import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
|
|
67
|
+
import { EnumerableSet } from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
|
|
68
|
+
|
|
69
|
+
import { ERC3643EventsLib } from "../../ERC-3643/ERC3643EventsLib.sol";
|
|
70
|
+
import { IERC3643Compliance } from "../../ERC-3643/IERC3643Compliance.sol";
|
|
71
|
+
import { ErrorsLib } from "../../libraries/ErrorsLib.sol";
|
|
72
|
+
import { EventsLib } from "../../libraries/EventsLib.sol";
|
|
73
|
+
import { IERC173 } from "../../roles/IERC173.sol";
|
|
74
|
+
import { IModularCompliance } from "./IModularCompliance.sol";
|
|
75
|
+
import { IModule } from "./modules/IModule.sol";
|
|
76
|
+
|
|
77
|
+
contract ModularCompliance is IModularCompliance, Ownable2StepUpgradeable, IERC165 {
|
|
78
|
+
|
|
79
|
+
using EnumerableSet for EnumerableSet.AddressSet;
|
|
80
|
+
|
|
81
|
+
/// @custom:storage-location erc7201:ERC3643.storage.ModularCompliance
|
|
82
|
+
struct Storage {
|
|
83
|
+
/// token linked to the compliance contract
|
|
84
|
+
address tokenBound;
|
|
85
|
+
/// Set of modules bound to the compliance
|
|
86
|
+
EnumerableSet.AddressSet modules;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// keccak256(abi.encode(uint256(keccak256("ERC3643.storage.ModularCompliance")) - 1)) & ~bytes32(uint256(0xff));
|
|
90
|
+
bytes32 private constant STORAGE_LOCATION = 0x44b49c37d3109105ef492022bec834e94dca859d191a0d5323d3afbc4aa69400;
|
|
91
|
+
|
|
92
|
+
/// modifiers
|
|
93
|
+
/**
|
|
94
|
+
* @dev Throws if called by any address that is not a token bound to the compliance.
|
|
95
|
+
*/
|
|
96
|
+
modifier onlyBoundedToken() {
|
|
97
|
+
require(msg.sender == _getStorage().tokenBound, ErrorsLib.AddressNotATokenBoundToComplianceContract());
|
|
98
|
+
_;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
constructor() {
|
|
102
|
+
_disableInitializers();
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* @dev Initializes the modular compliance with its final owner, the bound token, the initial set of
|
|
107
|
+
* modules and matching module settings.
|
|
108
|
+
* @param _token address of the token bound to this compliance — pre-computed via CREATE3 by the factory so
|
|
109
|
+
* the compliance never needs the deprecated `Token-self-bind` indirection
|
|
110
|
+
* @param _owner final owner of the compliance (no intermediate factory ownership)
|
|
111
|
+
* @param _modules initial set of modules to bind (capped at 25 — matches the existing post-init cap)
|
|
112
|
+
* @param _moduleSettings optional per-module settings forwarded via `_callModuleFunction` after each module is
|
|
113
|
+
* bound. `_moduleSettings.length` must be `<= _modules.length`; settings beyond `_modules.length` are
|
|
114
|
+
* not accepted
|
|
115
|
+
* emits a `TokenBound` event
|
|
116
|
+
* emits a `ModuleAdded` event for each module
|
|
117
|
+
* emits a `ModuleInteraction` event for each `_moduleSettings[i]` applied
|
|
118
|
+
*/
|
|
119
|
+
function init(address _token, address _owner, address[] calldata _modules, bytes[] calldata _moduleSettings)
|
|
120
|
+
external
|
|
121
|
+
initializer
|
|
122
|
+
{
|
|
123
|
+
require(_token != address(0) && _owner != address(0), ErrorsLib.ZeroAddress());
|
|
124
|
+
require(_modules.length >= _moduleSettings.length, ErrorsLib.InvalidCompliancePattern());
|
|
125
|
+
require(_modules.length <= 25, ErrorsLib.MaxModulesReached(25));
|
|
126
|
+
|
|
127
|
+
__Ownable_init(_owner);
|
|
128
|
+
_bindToken(_token);
|
|
129
|
+
|
|
130
|
+
for (uint256 i = 0; i < _modules.length; i++) {
|
|
131
|
+
if (!_getStorage().modules.contains(_modules[i])) {
|
|
132
|
+
_addModule(_modules[i]);
|
|
133
|
+
}
|
|
134
|
+
if (i < _moduleSettings.length) {
|
|
135
|
+
_callModuleFunction(_moduleSettings[i], _modules[i]);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* @dev See {IERC3643Compliance-bindToken}.
|
|
142
|
+
*/
|
|
143
|
+
function bindToken(address _token) external override {
|
|
144
|
+
Storage storage s = _getStorage();
|
|
145
|
+
require(
|
|
146
|
+
owner() == msg.sender || (s.tokenBound == address(0) && msg.sender == _token),
|
|
147
|
+
ErrorsLib.OnlyOwnerOrTokenCanCall()
|
|
148
|
+
);
|
|
149
|
+
_bindToken(_token);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* @dev See {IERC3643Compliance-unbindToken}.
|
|
154
|
+
*/
|
|
155
|
+
function unbindToken(address _token) external override {
|
|
156
|
+
require(owner() == msg.sender || msg.sender == _token, ErrorsLib.OnlyOwnerOrTokenCanCall());
|
|
157
|
+
|
|
158
|
+
Storage storage s = _getStorage();
|
|
159
|
+
require(_token == s.tokenBound, ErrorsLib.TokenNotBound());
|
|
160
|
+
require(_token != address(0), ErrorsLib.ZeroAddress());
|
|
161
|
+
delete s.tokenBound;
|
|
162
|
+
emit ERC3643EventsLib.TokenUnbound(_token);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* @dev See {IModularCompliance-removeModule}.
|
|
167
|
+
*/
|
|
168
|
+
function removeModule(address _module) external override onlyOwner {
|
|
169
|
+
require(_module != address(0), ErrorsLib.ZeroAddress());
|
|
170
|
+
|
|
171
|
+
Storage storage s = _getStorage();
|
|
172
|
+
require(s.modules.contains(_module), ErrorsLib.ModuleNotBound());
|
|
173
|
+
IModule(_module).unbindCompliance(address(this));
|
|
174
|
+
s.modules.remove(_module);
|
|
175
|
+
emit EventsLib.ModuleRemoved(_module);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* @dev See {IERC3643Compliance-transferred}.
|
|
180
|
+
*/
|
|
181
|
+
function transferred(address _from, address _to, uint256 _value) external override onlyBoundedToken {
|
|
182
|
+
require(_from != address(0) && _to != address(0), ErrorsLib.ZeroAddress());
|
|
183
|
+
require(_value > 0, ErrorsLib.ZeroValue());
|
|
184
|
+
Storage storage s = _getStorage();
|
|
185
|
+
uint256 length = s.modules.length();
|
|
186
|
+
for (uint256 i = 0; i < length; i++) {
|
|
187
|
+
IModule(s.modules.at(i)).moduleTransferAction(_from, _to, _value);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* @dev See {IERC3643Compliance-created}.
|
|
193
|
+
*/
|
|
194
|
+
function created(address _to, uint256 _value) external override onlyBoundedToken {
|
|
195
|
+
require(_to != address(0), ErrorsLib.ZeroAddress());
|
|
196
|
+
require(_value > 0, ErrorsLib.ZeroValue());
|
|
197
|
+
Storage storage s = _getStorage();
|
|
198
|
+
uint256 length = s.modules.length();
|
|
199
|
+
for (uint256 i = 0; i < length; i++) {
|
|
200
|
+
IModule(s.modules.at(i)).moduleMintAction(_to, _value);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* @dev See {IERC3643Compliance-destroyed}.
|
|
206
|
+
*/
|
|
207
|
+
function destroyed(address _from, uint256 _value) external override onlyBoundedToken {
|
|
208
|
+
require(_from != address(0), ErrorsLib.ZeroAddress());
|
|
209
|
+
require(_value > 0, ErrorsLib.ZeroValue());
|
|
210
|
+
Storage storage s = _getStorage();
|
|
211
|
+
uint256 length = s.modules.length();
|
|
212
|
+
for (uint256 i = 0; i < length; i++) {
|
|
213
|
+
IModule(s.modules.at(i)).moduleBurnAction(_from, _value);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* @dev See {IModularCompliance-addAndSetModule}.
|
|
219
|
+
*/
|
|
220
|
+
function addAndSetModule(address _module, bytes[] calldata _interactions) external override onlyOwner {
|
|
221
|
+
require(_interactions.length <= 5, ErrorsLib.ArraySizeLimited(5));
|
|
222
|
+
_addModule(_module);
|
|
223
|
+
for (uint256 i = 0; i < _interactions.length; i++) {
|
|
224
|
+
_callModuleFunction(_interactions[i], _module);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* @dev See {IModularCompliance-isModuleBound}.
|
|
230
|
+
*/
|
|
231
|
+
function isModuleBound(address _module) external view override returns (bool) {
|
|
232
|
+
return _getStorage().modules.contains(_module);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* @dev See {IModularCompliance-getModules}.
|
|
237
|
+
*/
|
|
238
|
+
function getModules() external view override returns (address[] memory) {
|
|
239
|
+
return _getStorage().modules.values();
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* @dev See {IERC3643Compliance-getTokenBound}.
|
|
244
|
+
*/
|
|
245
|
+
function getTokenBound() external view override returns (address) {
|
|
246
|
+
return _getStorage().tokenBound;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* @dev See {IERC3643Compliance-getTokenBound}.
|
|
251
|
+
*/
|
|
252
|
+
function isTokenBound(address _token) external view override returns (bool) {
|
|
253
|
+
return _token == _getStorage().tokenBound;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* @dev See {IERC3643Compliance-canTransfer}.
|
|
258
|
+
*/
|
|
259
|
+
function canTransfer(address _from, address _to, uint256 _value) external view override returns (bool) {
|
|
260
|
+
Storage storage s = _getStorage();
|
|
261
|
+
uint256 length = s.modules.length();
|
|
262
|
+
for (uint256 i = 0; i < length; i++) {
|
|
263
|
+
if (!IModule(s.modules.at(i)).moduleCheck(_from, _to, _value, address(this))) {
|
|
264
|
+
return false;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
return true;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* @dev See {IModularCompliance-addModule}.
|
|
273
|
+
*/
|
|
274
|
+
function addModule(address _module) public override onlyOwner {
|
|
275
|
+
_addModule(_module);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* @dev see {IModularCompliance-callModuleFunction}.
|
|
280
|
+
*/
|
|
281
|
+
function callModuleFunction(bytes calldata callData, address _module) public override onlyOwner {
|
|
282
|
+
_callModuleFunction(callData, _module);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* @dev See {IERC165-supportsInterface}.
|
|
287
|
+
*/
|
|
288
|
+
function supportsInterface(bytes4 interfaceId) public pure virtual override returns (bool) {
|
|
289
|
+
return interfaceId == type(IModularCompliance).interfaceId
|
|
290
|
+
|| interfaceId == type(IERC3643Compliance).interfaceId || interfaceId == type(IERC173).interfaceId
|
|
291
|
+
|| interfaceId == type(IERC165).interfaceId;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/// @dev Sets the bound token on the compliance storage and emits the corresponding event.
|
|
295
|
+
/// No caller check — the public `bindToken` wrapper enforces the owner/Token-self-bind policy.
|
|
296
|
+
function _bindToken(address _token) internal {
|
|
297
|
+
require(_token != address(0), ErrorsLib.ZeroAddress());
|
|
298
|
+
_getStorage().tokenBound = _token;
|
|
299
|
+
emit ERC3643EventsLib.TokenBound(_token);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/// @dev Binds a module to the compliance with the existing validation rules (zero check, duplicate check,
|
|
303
|
+
/// cap of 25, plug-and-play / canComplianceBind requirement). No caller check — wrappers enforce it.
|
|
304
|
+
function _addModule(address _module) internal {
|
|
305
|
+
require(_module != address(0), ErrorsLib.ZeroAddress());
|
|
306
|
+
Storage storage s = _getStorage();
|
|
307
|
+
require(!s.modules.contains(_module), ErrorsLib.ModuleAlreadyBound());
|
|
308
|
+
require(s.modules.length() < 25, ErrorsLib.MaxModulesReached(25));
|
|
309
|
+
IModule module = IModule(_module);
|
|
310
|
+
require(
|
|
311
|
+
module.isPlugAndPlay() || module.canComplianceBind(address(this)),
|
|
312
|
+
ErrorsLib.ComplianceNotSuitableForBindingToModule(_module)
|
|
313
|
+
);
|
|
314
|
+
|
|
315
|
+
module.bindCompliance(address(this));
|
|
316
|
+
s.modules.add(_module);
|
|
317
|
+
emit EventsLib.ModuleAdded(_module);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/// @dev Forwards `callData` to a bound `_module` via low-level call and emits the interaction event.
|
|
321
|
+
/// Reverts when `_module` is not bound or when the underlying call fails. No caller check —
|
|
322
|
+
/// wrappers enforce it.
|
|
323
|
+
function _callModuleFunction(bytes calldata callData, address _module) internal {
|
|
324
|
+
require(_getStorage().modules.contains(_module), ErrorsLib.ModuleNotBound());
|
|
325
|
+
// NOTE: Use assembly to call the interaction instead of a low level
|
|
326
|
+
// call for two reasons:
|
|
327
|
+
// - We don't want to copy the return data, since we discard it for
|
|
328
|
+
// interactions.
|
|
329
|
+
// - Solidity will under certain conditions generate code to copy input
|
|
330
|
+
// calldata twice to memory (the second being a "memcopy loop").
|
|
331
|
+
// solhint-disable-next-line no-inline-assembly
|
|
332
|
+
assembly {
|
|
333
|
+
let freeMemoryPointer := mload(0x40) // Load the free memory pointer from memory location 0x40
|
|
334
|
+
|
|
335
|
+
// Copy callData from calldata to the free memory location
|
|
336
|
+
calldatacopy(freeMemoryPointer, callData.offset, callData.length)
|
|
337
|
+
|
|
338
|
+
if iszero( // Check if the call returns zero (indicating failure)
|
|
339
|
+
call( // Perform the external call
|
|
340
|
+
gas(), // Provide all available gas
|
|
341
|
+
_module, // Address of the target module
|
|
342
|
+
0, // No ether is sent with the call
|
|
343
|
+
freeMemoryPointer, // Input data starts at the free memory pointer
|
|
344
|
+
callData.length, // Input data length
|
|
345
|
+
0, // Output data location (not used)
|
|
346
|
+
0 // Output data size (not used)
|
|
347
|
+
)
|
|
348
|
+
) {
|
|
349
|
+
returndatacopy(0, 0, returndatasize()) // Copy return data to memory starting at position 0
|
|
350
|
+
revert(0, returndatasize()) // Revert the transaction with the return data
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
emit EventsLib.ModuleInteraction(_module, _selector(callData));
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/// @dev Extracts the Solidity ABI selector for the specified interaction.
|
|
358
|
+
/// @param callData Interaction data.
|
|
359
|
+
/// @return result The 4 byte function selector of the call encoded in this interaction.
|
|
360
|
+
function _selector(bytes calldata callData) internal pure returns (bytes4 result) {
|
|
361
|
+
if (callData.length >= 4) {
|
|
362
|
+
// NOTE: Read the first word of the interaction's calldata. The
|
|
363
|
+
// value does not need to be shifted since `bytesN` values are left
|
|
364
|
+
// aligned, and the value does not need to be masked since masking
|
|
365
|
+
// occurs when the value is accessed and not stored:
|
|
366
|
+
// <https://docs.soliditylang.org/en/v0.7.6/abi-spec.html#encoding-of-indexed-event-parameters>
|
|
367
|
+
// <https://docs.soliditylang.org/en/v0.7.6/assembly.html#access-to-external-variables-functions-and-libraries>
|
|
368
|
+
assembly {
|
|
369
|
+
result := calldataload(callData.offset)
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
function _getStorage() internal pure returns (Storage storage s) {
|
|
375
|
+
assembly {
|
|
376
|
+
s.slot := STORAGE_LOCATION
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
}
|
|
381
|
+
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0
|
|
2
|
+
//
|
|
3
|
+
// :+#####%%%%%%%%%%%%%%+
|
|
4
|
+
// .-*@@@%+.:+%@@@@@%%#***%@@%=
|
|
5
|
+
// :=*%@@@#=. :#@@% *@@@%=
|
|
6
|
+
// .-+*%@%*-.:+%@@@@@@+. -*+: .=#. :%@@@%-
|
|
7
|
+
// :=*@@@@%%@@@@@@@@@%@@@- .=#@@@%@%= =@@@@#.
|
|
8
|
+
// -=+#%@@%#*=:. :%@@@@%. -*@@#*@@@@@@@#=:- *@@@@+
|
|
9
|
+
// =@@%=:. :=: *@@@@@%#- =%*%@@@@#+-. =+ :%@@@%-
|
|
10
|
+
// -@@%. .+@@@ =+=-. @@#- +@@@%- =@@@@%:
|
|
11
|
+
// :@@@. .+@@#%: : .=*=-::.-%@@@+*@@= +@@@@#.
|
|
12
|
+
// %@@: +@%%* =%@@@@@@@@@@@#. .*@%- +@@@@*.
|
|
13
|
+
// #@@= .+@@@@%:=*@@@@@- :%@%: .*@@@@+
|
|
14
|
+
// *@@* +@@@#-@@%-:%@@* +@@#. :%@@@@-
|
|
15
|
+
// -@@% .:-=++*##%%%@@@@@@@@@@@@*. :@+.@@@%: .#@@+ =@@@@#:
|
|
16
|
+
// .@@@*-+*#%%%@@@@@@@@@@@@@@@@%%#**@@%@@@. *@=*@@# :#@%= .#@@@@#-
|
|
17
|
+
// -%@@@@@@@@@@@@@@@*+==-:-@@@= *@# .#@*-=*@@@@%= -%@@@* =@@@@@%-
|
|
18
|
+
// -+%@@@#. %@%%= -@@:+@: -@@* *@@*-:: -%@@%=. .*@@@@@#
|
|
19
|
+
// *@@@* +@* *@@##@@- #@*@@+ -@@= . :+@@@#: .-+@@@%+-
|
|
20
|
+
// +@@@%*@@:..=@@@@* .@@@* .#@#. .=+- .=%@@@*. :+#@@@@*=:
|
|
21
|
+
// =@@@@%@@@@@@@@@@@@@@@@@@@@@@%- :+#*. :*@@@%=. .=#@@@@%+:
|
|
22
|
+
// .%@@= ..... .=#@@+. .#@@@*: -*%@@@@%+.
|
|
23
|
+
// +@@#+===---:::... .=%@@*- +@@@+. -*@@@@@%+.
|
|
24
|
+
// -@@@@@@@@@@@@@@@@@@@@@@%@@@@= -@@@+ -#@@@@@#=.
|
|
25
|
+
// ..:::---===+++***###%%%@@@#- .#@@+ -*@@@@@#=.
|
|
26
|
+
// @@@@@@+. +@@*. .+@@@@@%=.
|
|
27
|
+
// -@@@@@= =@@%: -#@@@@%+.
|
|
28
|
+
// +@@@@@. =@@@= .+@@@@@*:
|
|
29
|
+
// #@@@@#:%@@#. :*@@@@#-
|
|
30
|
+
// @@@@@%@@@= :#@@@@+.
|
|
31
|
+
// :@@@@@@@#.:#@@@%-
|
|
32
|
+
// +@@@@@@-.*@@@*:
|
|
33
|
+
// #@@@@#.=@@@+.
|
|
34
|
+
// @@@@+-%@%=
|
|
35
|
+
// :@@@#%@%=
|
|
36
|
+
// +@@@@%-
|
|
37
|
+
// :#%%=
|
|
38
|
+
//
|
|
39
|
+
/**
|
|
40
|
+
* NOTICE
|
|
41
|
+
*
|
|
42
|
+
* The T-REX software is licensed under a proprietary license or the GPL v.3.
|
|
43
|
+
* If you choose to receive it under the GPL v.3 license, the following applies:
|
|
44
|
+
* T-REX is a suite of smart contracts implementing the ERC-3643 standard and
|
|
45
|
+
* developed by Tokeny to manage and transfer financial assets on EVM blockchains
|
|
46
|
+
*
|
|
47
|
+
* Copyright (C) 2025, Tokeny sàrl.
|
|
48
|
+
*
|
|
49
|
+
* This program is free software: you can redistribute it and/or modify
|
|
50
|
+
* it under the terms of the GNU General Public License as published by
|
|
51
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
52
|
+
* (at your option) any later version.
|
|
53
|
+
*
|
|
54
|
+
* This program is distributed in the hope that it will be useful,
|
|
55
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
56
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
57
|
+
* GNU General Public License for more details.
|
|
58
|
+
*
|
|
59
|
+
* You should have received a copy of the GNU General Public License
|
|
60
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
61
|
+
*/
|
|
62
|
+
|
|
63
|
+
pragma solidity 0.8.30;
|
|
64
|
+
|
|
65
|
+
import { Ownable2StepUpgradeable } from "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol";
|
|
66
|
+
import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
|
|
67
|
+
import { UUPSUpgradeable } from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
|
|
68
|
+
import { MulticallUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/MulticallUpgradeable.sol";
|
|
69
|
+
import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
|
|
70
|
+
|
|
71
|
+
import { ErrorsLib } from "../../../libraries/ErrorsLib.sol";
|
|
72
|
+
import { EventsLib } from "../../../libraries/EventsLib.sol";
|
|
73
|
+
import { IERC173 } from "../../../roles/IERC173.sol";
|
|
74
|
+
import { IModule } from "./IModule.sol";
|
|
75
|
+
|
|
76
|
+
abstract contract AbstractModuleUpgradeable is
|
|
77
|
+
IModule,
|
|
78
|
+
Initializable,
|
|
79
|
+
Ownable2StepUpgradeable,
|
|
80
|
+
UUPSUpgradeable,
|
|
81
|
+
MulticallUpgradeable,
|
|
82
|
+
IERC165
|
|
83
|
+
{
|
|
84
|
+
|
|
85
|
+
/// @custom:storage-location erc7201:ERC3643.storage.AbstractModule
|
|
86
|
+
struct AbstractModuleStorage {
|
|
87
|
+
/// compliance contract binding status
|
|
88
|
+
mapping(address => bool) complianceBound;
|
|
89
|
+
/// nonce for the module
|
|
90
|
+
mapping(address => uint256) nonces;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// keccak256(abi.encode(uint256(keccak256("ERC3643.storage.AbstractModule")) - 1)) & ~bytes32(uint256(0xff))
|
|
94
|
+
bytes32 private constant _ABSTRACT_MODULE_STORAGE_LOCATION =
|
|
95
|
+
0xf6cc97de1266c180cd39f3b311632644143ce7873d2927755382ad4b39e8ae00;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* @dev Throws if `_compliance` is not a bound compliance contract address.
|
|
99
|
+
*/
|
|
100
|
+
modifier onlyBoundCompliance(address _compliance) {
|
|
101
|
+
require(_getAbstractModuleStorage().complianceBound[_compliance], ErrorsLib.ComplianceNotBound());
|
|
102
|
+
_;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* @dev Throws if called from an address that is not a bound compliance contract.
|
|
107
|
+
*/
|
|
108
|
+
modifier onlyComplianceCall() {
|
|
109
|
+
require(_getAbstractModuleStorage().complianceBound[msg.sender], ErrorsLib.OnlyBoundComplianceCanCall());
|
|
110
|
+
_;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* @dev prevents use of the implementation contracts
|
|
115
|
+
*/
|
|
116
|
+
constructor() {
|
|
117
|
+
_disableInitializers();
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* @dev See {IModule-bindCompliance}.
|
|
122
|
+
*/
|
|
123
|
+
function bindCompliance(address _compliance) external override onlyProxy {
|
|
124
|
+
AbstractModuleStorage storage s = _getAbstractModuleStorage();
|
|
125
|
+
require(_compliance != address(0), ErrorsLib.ZeroAddress());
|
|
126
|
+
require(!s.complianceBound[_compliance], ErrorsLib.ComplianceAlreadyBound());
|
|
127
|
+
require(msg.sender == _compliance, ErrorsLib.OnlyComplianceContractCanCall());
|
|
128
|
+
s.complianceBound[_compliance] = true;
|
|
129
|
+
emit EventsLib.ComplianceBound(_compliance);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* @dev See {IModule-unbindCompliance}.
|
|
134
|
+
*/
|
|
135
|
+
function unbindCompliance(address _compliance) external override onlyComplianceCall onlyProxy {
|
|
136
|
+
AbstractModuleStorage storage s = _getAbstractModuleStorage();
|
|
137
|
+
require(_compliance != address(0), ErrorsLib.ZeroAddress());
|
|
138
|
+
require(msg.sender == _compliance, ErrorsLib.OnlyComplianceContractCanCall());
|
|
139
|
+
|
|
140
|
+
s.complianceBound[_compliance] = false;
|
|
141
|
+
s.nonces[_compliance]++;
|
|
142
|
+
|
|
143
|
+
emit EventsLib.ComplianceUnbound(_compliance);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* @dev See {IModule-isComplianceBound}.
|
|
148
|
+
*/
|
|
149
|
+
function isComplianceBound(address _compliance) external view override returns (bool) {
|
|
150
|
+
AbstractModuleStorage storage s = _getAbstractModuleStorage();
|
|
151
|
+
return s.complianceBound[_compliance];
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function getNonce(address _compliance) public view returns (uint256) {
|
|
155
|
+
AbstractModuleStorage storage s = _getAbstractModuleStorage();
|
|
156
|
+
return s.nonces[_compliance];
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* @dev See {IERC165-supportsInterface}.
|
|
161
|
+
*/
|
|
162
|
+
function supportsInterface(bytes4 interfaceId) public pure virtual override returns (bool) {
|
|
163
|
+
return interfaceId == type(IModule).interfaceId || interfaceId == type(IERC173).interfaceId
|
|
164
|
+
|| interfaceId == type(IERC165).interfaceId;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// solhint-disable-next-line func-name-mixedcase
|
|
168
|
+
function __AbstractModule_init() internal onlyInitializing {
|
|
169
|
+
__Ownable_init(msg.sender);
|
|
170
|
+
__AbstractModule_init_unchained();
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// solhint-disable-next-line no-empty-blocks, func-name-mixedcase
|
|
174
|
+
function __AbstractModule_init_unchained() internal onlyInitializing { }
|
|
175
|
+
|
|
176
|
+
// solhint-disable-next-line no-empty-blocks
|
|
177
|
+
function _authorizeUpgrade(
|
|
178
|
+
address /*newImplementation*/
|
|
179
|
+
)
|
|
180
|
+
internal
|
|
181
|
+
virtual
|
|
182
|
+
override
|
|
183
|
+
onlyOwner
|
|
184
|
+
{ }
|
|
185
|
+
|
|
186
|
+
function _getAbstractModuleStorage() private pure returns (AbstractModuleStorage storage s) {
|
|
187
|
+
// solhint-disable-next-line no-inline-assembly
|
|
188
|
+
assembly {
|
|
189
|
+
s.slot := _ABSTRACT_MODULE_STORAGE_LOCATION
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
}
|