@chainlink/ace 0.5.0

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.
Files changed (150) hide show
  1. package/.foundry-version +1 -0
  2. package/.github/CODEOWNERS +1 -0
  3. package/.github/workflows/auto-release-version.yml +107 -0
  4. package/.github/workflows/create-version-pr.yml +95 -0
  5. package/.github/workflows/forge-docs.yml +90 -0
  6. package/.github/workflows/forge-test.yml +59 -0
  7. package/.solhint-test.json +18 -0
  8. package/.solhint.json +16 -0
  9. package/.solhintignore +3 -0
  10. package/.solhintignore-test +2 -0
  11. package/Glossary.md +141 -0
  12. package/LICENSE +59 -0
  13. package/README.md +218 -0
  14. package/assets/chainlink-logo.svg +21 -0
  15. package/chainlink-ace-License-grants +2 -0
  16. package/foundry.toml +33 -0
  17. package/getting_started/GETTING_STARTED.md +477 -0
  18. package/getting_started/MyVault.sol +48 -0
  19. package/getting_started/advanced/.env.example +36 -0
  20. package/getting_started/advanced/GETTING_STARTED_ADVANCED.md +431 -0
  21. package/getting_started/advanced/SanctionsList.sol +25 -0
  22. package/getting_started/advanced/SanctionsPolicy.sol +58 -0
  23. package/package.json +41 -0
  24. package/packages/cross-chain-identity/README.md +148 -0
  25. package/packages/cross-chain-identity/docs/API_GUIDE.md +120 -0
  26. package/packages/cross-chain-identity/docs/API_REFERENCE.md +271 -0
  27. package/packages/cross-chain-identity/docs/CONCEPTS.md +253 -0
  28. package/packages/cross-chain-identity/docs/CREDENTIAL_FLOW.md +195 -0
  29. package/packages/cross-chain-identity/docs/SECURITY.md +70 -0
  30. package/packages/cross-chain-identity/src/CredentialRegistry.sol +245 -0
  31. package/packages/cross-chain-identity/src/CredentialRegistryIdentityValidator.sol +339 -0
  32. package/packages/cross-chain-identity/src/CredentialRegistryIdentityValidatorPolicy.sol +71 -0
  33. package/packages/cross-chain-identity/src/IdentityRegistry.sol +123 -0
  34. package/packages/cross-chain-identity/src/TrustedIssuerRegistry.sol +140 -0
  35. package/packages/cross-chain-identity/src/interfaces/ICredentialDataValidator.sol +30 -0
  36. package/packages/cross-chain-identity/src/interfaces/ICredentialRegistry.sol +170 -0
  37. package/packages/cross-chain-identity/src/interfaces/ICredentialRequirements.sol +192 -0
  38. package/packages/cross-chain-identity/src/interfaces/ICredentialValidator.sol +37 -0
  39. package/packages/cross-chain-identity/src/interfaces/IIdentityRegistry.sol +85 -0
  40. package/packages/cross-chain-identity/src/interfaces/IIdentityValidator.sol +18 -0
  41. package/packages/cross-chain-identity/src/interfaces/ITrustedIssuerRegistry.sol +61 -0
  42. package/packages/cross-chain-identity/test/CredentialRegistry.t.sol +220 -0
  43. package/packages/cross-chain-identity/test/CredentialRegistryIdentityValidator.t.sol +554 -0
  44. package/packages/cross-chain-identity/test/CredentialRegistryIdentityValidatorPolicy.t.sol +114 -0
  45. package/packages/cross-chain-identity/test/IdentityRegistry.t.sol +106 -0
  46. package/packages/cross-chain-identity/test/IdentityValidator.t.sol +969 -0
  47. package/packages/cross-chain-identity/test/TrustedIssuerRegistry.t.sol +123 -0
  48. package/packages/cross-chain-identity/test/helpers/BaseProxyTest.sol +112 -0
  49. package/packages/cross-chain-identity/test/helpers/MockCredentialDataValidator.sol +26 -0
  50. package/packages/cross-chain-identity/test/helpers/MockCredentialRegistryReverting.sol +131 -0
  51. package/packages/policy-management/README.md +197 -0
  52. package/packages/policy-management/docs/API_GUIDE.md +290 -0
  53. package/packages/policy-management/docs/API_REFERENCE.md +173 -0
  54. package/packages/policy-management/docs/CONCEPTS.md +156 -0
  55. package/packages/policy-management/docs/CUSTOM_POLICIES_TUTORIAL.md +195 -0
  56. package/packages/policy-management/docs/POLICY_ORDERING_GUIDE.md +91 -0
  57. package/packages/policy-management/docs/SECURITY.md +57 -0
  58. package/packages/policy-management/src/core/Policy.sol +124 -0
  59. package/packages/policy-management/src/core/PolicyEngine.sol +382 -0
  60. package/packages/policy-management/src/core/PolicyFactory.sol +92 -0
  61. package/packages/policy-management/src/core/PolicyProtected.sol +126 -0
  62. package/packages/policy-management/src/extractors/ComplianceTokenForceTransferExtractor.sol +57 -0
  63. package/packages/policy-management/src/extractors/ComplianceTokenFreezeUnfreezeExtractor.sol +54 -0
  64. package/packages/policy-management/src/extractors/ComplianceTokenMintBurnExtractor.sol +61 -0
  65. package/packages/policy-management/src/extractors/ERC20ApproveExtractor.sol +57 -0
  66. package/packages/policy-management/src/extractors/ERC20TransferExtractor.sol +62 -0
  67. package/packages/policy-management/src/extractors/ERC3643ForcedTransferExtractor.sol +56 -0
  68. package/packages/policy-management/src/extractors/ERC3643FreezeUnfreezeExtractor.sol +55 -0
  69. package/packages/policy-management/src/extractors/ERC3643MintBurnExtractor.sol +51 -0
  70. package/packages/policy-management/src/extractors/ERC3643SetAddressFrozenExtractor.sol +51 -0
  71. package/packages/policy-management/src/interfaces/IExtractor.sol +17 -0
  72. package/packages/policy-management/src/interfaces/IMapper.sol +17 -0
  73. package/packages/policy-management/src/interfaces/IPolicy.sol +61 -0
  74. package/packages/policy-management/src/interfaces/IPolicyEngine.sol +264 -0
  75. package/packages/policy-management/src/interfaces/IPolicyProtected.sol +48 -0
  76. package/packages/policy-management/src/policies/AllowPolicy.sol +104 -0
  77. package/packages/policy-management/src/policies/BypassPolicy.sol +90 -0
  78. package/packages/policy-management/src/policies/IntervalPolicy.sol +223 -0
  79. package/packages/policy-management/src/policies/MaxPolicy.sol +73 -0
  80. package/packages/policy-management/src/policies/OnlyAuthorizedSenderPolicy.sol +84 -0
  81. package/packages/policy-management/src/policies/OnlyOwnerPolicy.sol +35 -0
  82. package/packages/policy-management/src/policies/PausePolicy.sol +82 -0
  83. package/packages/policy-management/src/policies/README.md +632 -0
  84. package/packages/policy-management/src/policies/RejectPolicy.sol +89 -0
  85. package/packages/policy-management/src/policies/RoleBasedAccessControlPolicy.sol +162 -0
  86. package/packages/policy-management/src/policies/SecureMintPolicy.sol +271 -0
  87. package/packages/policy-management/src/policies/VolumePolicy.sol +133 -0
  88. package/packages/policy-management/src/policies/VolumeRatePolicy.sol +192 -0
  89. package/packages/policy-management/test/PolicyEngine.t.sol +368 -0
  90. package/packages/policy-management/test/PolicyFactory.t.sol +114 -0
  91. package/packages/policy-management/test/PolicyProtectedToken.t.sol +75 -0
  92. package/packages/policy-management/test/extractors/ComplianceTokenForceTransferExtractor.t.sol +59 -0
  93. package/packages/policy-management/test/extractors/ComplianceTokenFreezeUnfreezeExtractor.t.sol +74 -0
  94. package/packages/policy-management/test/extractors/ComplianceTokenMintBurnExtractor.t.sol +92 -0
  95. package/packages/policy-management/test/extractors/ERC20ApproveExtractor.t.sol +58 -0
  96. package/packages/policy-management/test/extractors/ERC3643ForcedTransferExtractor.t.sol +59 -0
  97. package/packages/policy-management/test/extractors/ERC3643FreezeUnfreezeExtractor.t.sol +74 -0
  98. package/packages/policy-management/test/extractors/ERC3643MintBurnExtractor.t.sol +73 -0
  99. package/packages/policy-management/test/extractors/ERC3643SetAddressFrozenExtractor.t.sol +56 -0
  100. package/packages/policy-management/test/helpers/BaseProxyTest.sol +75 -0
  101. package/packages/policy-management/test/helpers/CustomMapper.sol +26 -0
  102. package/packages/policy-management/test/helpers/DummyExtractor.sol +11 -0
  103. package/packages/policy-management/test/helpers/ExpectedParameterPolicy.sol +39 -0
  104. package/packages/policy-management/test/helpers/MockAggregatorV3.sol +51 -0
  105. package/packages/policy-management/test/helpers/MockToken.sol +66 -0
  106. package/packages/policy-management/test/helpers/MockTokenExtractor.sol +34 -0
  107. package/packages/policy-management/test/helpers/PolicyAlwaysAllowed.sol +45 -0
  108. package/packages/policy-management/test/helpers/PolicyAlwaysContinue.sol +23 -0
  109. package/packages/policy-management/test/helpers/PolicyAlwaysRejected.sol +23 -0
  110. package/packages/policy-management/test/helpers/PolicyFailingRun.sol +22 -0
  111. package/packages/policy-management/test/policies/AllowPolicy.t.sol +174 -0
  112. package/packages/policy-management/test/policies/BypassPolicy.t.sol +159 -0
  113. package/packages/policy-management/test/policies/IntervalPolicy.t.sol +307 -0
  114. package/packages/policy-management/test/policies/MaxPolicy.t.sol +54 -0
  115. package/packages/policy-management/test/policies/OnlyAuthorizedSenderPolicy.t.sol +95 -0
  116. package/packages/policy-management/test/policies/OnlyOwnerPolicy.t.sol +47 -0
  117. package/packages/policy-management/test/policies/PausePolicy.t.sol +75 -0
  118. package/packages/policy-management/test/policies/RejectPolicy.t.sol +182 -0
  119. package/packages/policy-management/test/policies/RoleBasedAccessControlPolicy.t.sol +223 -0
  120. package/packages/policy-management/test/policies/SecureMintPolicy.t.sol +442 -0
  121. package/packages/policy-management/test/policies/VolumePolicy.t.sol +158 -0
  122. package/packages/policy-management/test/policies/VolumeRatePolicy.t.sol +165 -0
  123. package/packages/tokens/erc-20/src/ComplianceTokenERC20.sol +345 -0
  124. package/packages/tokens/erc-20/src/ComplianceTokenStoreERC20.sol +29 -0
  125. package/packages/tokens/erc-20/test/ComplianceTokenERC20.t.sol +556 -0
  126. package/packages/tokens/erc-20/test/helpers/BaseProxyTest.sol +75 -0
  127. package/packages/tokens/erc-3643/README.md +24 -0
  128. package/packages/tokens/erc-3643/src/ComplianceTokenERC3643.sol +564 -0
  129. package/packages/tokens/erc-3643/src/ComplianceTokenStoreERC3643.sol +30 -0
  130. package/packages/tokens/erc-3643/test/ComplianceTokenERC3643.t.sol +815 -0
  131. package/packages/tokens/erc-3643/test/helpers/BaseProxyTest.sol +76 -0
  132. package/packages/tokens/erc-3643/test/helpers/ExpectedContextPolicy.sol +32 -0
  133. package/packages/vendor/erc-3643/compliance/modular/IModularCompliance.sol +220 -0
  134. package/packages/vendor/erc-3643/registry/interface/IClaimTopicsRegistry.sol +101 -0
  135. package/packages/vendor/erc-3643/registry/interface/IIdentityRegistry.sol +251 -0
  136. package/packages/vendor/erc-3643/registry/interface/IIdentityRegistryStorage.sol +191 -0
  137. package/packages/vendor/erc-3643/registry/interface/ITrustedIssuersRegistry.sol +161 -0
  138. package/packages/vendor/erc-3643/token/IToken.sol +457 -0
  139. package/packages/vendor/onchain-id/interface/IClaimIssuer.sol +53 -0
  140. package/packages/vendor/onchain-id/interface/IERC734.sol +110 -0
  141. package/packages/vendor/onchain-id/interface/IERC735.sol +105 -0
  142. package/packages/vendor/onchain-id/interface/IIdentity.sol +26 -0
  143. package/packages/vendor/onchain-id/interface/IImplementationAuthority.sol +21 -0
  144. package/remappings.txt +6 -0
  145. package/script/DeployComplianceTokenERC20.s.sol +191 -0
  146. package/script/DeployComplianceTokenERC3643.s.sol +208 -0
  147. package/script/DeploySimpleComplianceToken.s.sol +38 -0
  148. package/script/getting_started/DeployGettingStarted.s.sol +74 -0
  149. package/script/getting_started/advanced/DeployAdvancedGettingStarted.s.sol +332 -0
  150. package/script/getting_started/advanced/DeploySanctionsList.s.sol +26 -0
@@ -0,0 +1,76 @@
1
+ // SPDX-License-Identifier: BUSL-1.1
2
+ pragma solidity 0.8.26;
3
+
4
+ import {Test} from "forge-std/Test.sol";
5
+ import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
6
+ import {IPolicyEngine} from "@chainlink/policy-management/interfaces/IPolicyEngine.sol";
7
+ import {PolicyEngine} from "@chainlink/policy-management/core/PolicyEngine.sol";
8
+ import {Policy} from "@chainlink/policy-management/core/Policy.sol";
9
+ import {ComplianceTokenERC3643} from "../../src/ComplianceTokenERC3643.sol";
10
+
11
+ /**
12
+ * @title BaseProxyTest
13
+ * @notice Base contract for ERC-3643 token tests that need to deploy upgradeable contracts through proxies
14
+ * @dev Provides helper functions to deploy common ERC-3643 token contracts with proper proxy pattern
15
+ */
16
+ abstract contract BaseProxyTest is Test {
17
+ /**
18
+ * @notice Deploy PolicyEngine through proxy
19
+ * @param defaultAllow Whether the default policy engine rule will allow or reject the transaction
20
+ * @param initialOwner The address of the initial owner of the policy engine
21
+ * @return The deployed PolicyEngine proxy instance
22
+ */
23
+ function _deployPolicyEngine(bool defaultAllow, address initialOwner) internal returns (PolicyEngine) {
24
+ PolicyEngine policyEngineImpl = new PolicyEngine();
25
+ bytes memory policyEngineData = abi.encodeWithSelector(PolicyEngine.initialize.selector, defaultAllow, initialOwner);
26
+ ERC1967Proxy policyEngineProxy = new ERC1967Proxy(address(policyEngineImpl), policyEngineData);
27
+ return PolicyEngine(address(policyEngineProxy));
28
+ }
29
+
30
+ /**
31
+ * @notice Deploy any Policy-based contract through proxy
32
+ * @param policyImpl The implementation contract (must inherit from Policy)
33
+ * @param policyEngine The address of the policy engine contract
34
+ * @param owner The address of the policy owner
35
+ * @param parameters ABI-encoded parameters for policy initialization
36
+ * @return The deployed policy proxy address
37
+ */
38
+ function _deployPolicy(
39
+ address policyImpl,
40
+ address policyEngine,
41
+ address owner,
42
+ bytes memory parameters
43
+ )
44
+ internal
45
+ returns (address)
46
+ {
47
+ bytes memory policyData = abi.encodeWithSelector(Policy.initialize.selector, policyEngine, owner, parameters);
48
+ ERC1967Proxy policyProxy = new ERC1967Proxy(policyImpl, policyData);
49
+ return address(policyProxy);
50
+ }
51
+
52
+ /**
53
+ * @notice Deploy ComplianceTokenERC3643 through proxy
54
+ * @param tokenName The name of the token
55
+ * @param tokenSymbol The symbol of the token
56
+ * @param tokenDecimals The number of decimals for the token
57
+ * @param policyEngine The address of the policy engine contract
58
+ * @return The deployed ComplianceTokenERC3643 proxy instance
59
+ */
60
+ function _deployComplianceTokenERC3643(
61
+ string memory tokenName,
62
+ string memory tokenSymbol,
63
+ uint8 tokenDecimals,
64
+ address policyEngine
65
+ )
66
+ internal
67
+ returns (ComplianceTokenERC3643)
68
+ {
69
+ ComplianceTokenERC3643 tokenImpl = new ComplianceTokenERC3643();
70
+ bytes memory tokenData = abi.encodeWithSelector(
71
+ ComplianceTokenERC3643.initialize.selector, tokenName, tokenSymbol, tokenDecimals, policyEngine
72
+ );
73
+ ERC1967Proxy tokenProxy = new ERC1967Proxy(address(tokenImpl), tokenData);
74
+ return ComplianceTokenERC3643(address(tokenProxy));
75
+ }
76
+ }
@@ -0,0 +1,32 @@
1
+ // SPDX-License-Identifier: BUSL-1.1
2
+ pragma solidity 0.8.26;
3
+
4
+ import {IPolicyEngine} from "@chainlink/policy-management/interfaces/IPolicyEngine.sol";
5
+ import {Policy} from "@chainlink/policy-management/core/Policy.sol";
6
+
7
+ contract ExpectedContextPolicy is Policy {
8
+ bytes private s_expectedContext;
9
+
10
+ function configure(bytes calldata parameters) internal override onlyInitializing {
11
+ bytes memory expectedContext = abi.decode(parameters, (bytes));
12
+ s_expectedContext = expectedContext;
13
+ }
14
+
15
+ function run(
16
+ address,
17
+ address,
18
+ bytes4,
19
+ bytes[] calldata,
20
+ bytes calldata context
21
+ )
22
+ public
23
+ view
24
+ override
25
+ returns (IPolicyEngine.PolicyResult)
26
+ {
27
+ if (keccak256(s_expectedContext) == keccak256(context)) {
28
+ return IPolicyEngine.PolicyResult.Continue;
29
+ }
30
+ revert IPolicyEngine.PolicyRejected("context does not match expected value");
31
+ }
32
+ }
@@ -0,0 +1,220 @@
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) 2023, 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
+ pragma solidity ^0.8.23;
63
+
64
+ interface IModularCompliance {
65
+ /// events
66
+
67
+ /**
68
+ * @dev Event emitted for each executed interaction with a module contract.
69
+ * For gas efficiency, only the interaction calldata selector (first 4
70
+ * bytes) is included in the event. For interactions without calldata or
71
+ * whose calldata is shorter than 4 bytes, the selector will be `0`.
72
+ */
73
+ event ModuleInteraction(address indexed target, bytes4 selector);
74
+
75
+ /**
76
+ * this event is emitted when a token has been bound to the compliance contract
77
+ * the event is emitted by the bindToken function
78
+ * `_token` is the address of the token to bind
79
+ */
80
+ event TokenBound(address _token);
81
+
82
+ /**
83
+ * this event is emitted when a token has been unbound from the compliance contract
84
+ * the event is emitted by the unbindToken function
85
+ * `_token` is the address of the token to unbind
86
+ */
87
+ event TokenUnbound(address _token);
88
+
89
+ /**
90
+ * this event is emitted when a module has been added to the list of modules bound to the compliance contract
91
+ * the event is emitted by the addModule function
92
+ * `_module` is the address of the compliance module
93
+ */
94
+ event ModuleAdded(address indexed _module);
95
+
96
+ /**
97
+ * this event is emitted when a module has been removed from the list of modules bound to the compliance contract
98
+ * the event is emitted by the removeModule function
99
+ * `_module` is the address of the compliance module
100
+ */
101
+ event ModuleRemoved(address indexed _module);
102
+
103
+ /// functions
104
+
105
+ /**
106
+ * @dev binds a token to the compliance contract
107
+ * @param _token address of the token to bind
108
+ * This function can be called ONLY by the owner of the compliance contract
109
+ * Emits a TokenBound event
110
+ */
111
+ function bindToken(address _token) external;
112
+
113
+ /**
114
+ * @dev unbinds a token from the compliance contract
115
+ * @param _token address of the token to unbind
116
+ * This function can be called ONLY by the owner of the compliance contract
117
+ * Emits a TokenUnbound event
118
+ */
119
+ function unbindToken(address _token) external;
120
+
121
+ /**
122
+ * @dev adds a module to the list of compliance modules
123
+ * @param _module address of the module to add
124
+ * there cannot be more than 25 modules bound to the modular compliance for gas cost reasons
125
+ * This function can be called ONLY by the owner of the compliance contract
126
+ * Emits a ModuleAdded event
127
+ */
128
+ function addModule(address _module) external;
129
+
130
+ /**
131
+ * @dev removes a module from the list of compliance modules
132
+ * @param _module address of the module to remove
133
+ * This function can be called ONLY by the owner of the compliance contract
134
+ * Emits a ModuleRemoved event
135
+ */
136
+ function removeModule(address _module) external;
137
+
138
+ /**
139
+ * @dev calls any function on bound modules
140
+ * can be called only on bound modules
141
+ * @param callData the bytecode for interaction with the module, abi encoded
142
+ * @param _module The address of the module
143
+ * This function can be called only by the modular compliance owner
144
+ * emits a `ModuleInteraction` event
145
+ */
146
+ function callModuleFunction(bytes calldata callData, address _module) external;
147
+
148
+ /**
149
+ * @dev function called whenever tokens are transferred
150
+ * from one wallet to another
151
+ * this function can update state variables in the modules bound to the compliance
152
+ * these state variables being used by the module checks to decide if a transfer
153
+ * is compliant or not depending on the values stored in these state variables and on
154
+ * the parameters of the modules
155
+ * This function can be called ONLY by the token contract bound to the compliance
156
+ * @param _from The address of the sender
157
+ * @param _to The address of the receiver
158
+ * @param _amount The amount of tokens involved in the transfer
159
+ * This function calls moduleTransferAction() on each module bound to the compliance contract
160
+ */
161
+ function transferred(address _from, address _to, uint256 _amount) external;
162
+
163
+ /**
164
+ * @dev function called whenever tokens are created on a wallet
165
+ * this function can update state variables in the modules bound to the compliance
166
+ * these state variables being used by the module checks to decide if a transfer
167
+ * is compliant or not depending on the values stored in these state variables and on
168
+ * the parameters of the modules
169
+ * This function can be called ONLY by the token contract bound to the compliance
170
+ * @param _to The address of the receiver
171
+ * @param _amount The amount of tokens involved in the minting
172
+ * This function calls moduleMintAction() on each module bound to the compliance contract
173
+ */
174
+ function created(address _to, uint256 _amount) external;
175
+
176
+ /**
177
+ * @dev function called whenever tokens are destroyed from a wallet
178
+ * this function can update state variables in the modules bound to the compliance
179
+ * these state variables being used by the module checks to decide if a transfer
180
+ * is compliant or not depending on the values stored in these state variables and on
181
+ * the parameters of the modules
182
+ * This function can be called ONLY by the token contract bound to the compliance
183
+ * @param _from The address on which tokens are burnt
184
+ * @param _amount The amount of tokens involved in the burn
185
+ * This function calls moduleBurnAction() on each module bound to the compliance contract
186
+ */
187
+ function destroyed(address _from, uint256 _amount) external;
188
+
189
+ /**
190
+ * @dev checks that the transfer is compliant.
191
+ * default compliance always returns true
192
+ * READ ONLY FUNCTION, this function cannot be used to increment
193
+ * counters, emit events, ...
194
+ * @param _from The address of the sender
195
+ * @param _to The address of the receiver
196
+ * @param _amount The amount of tokens involved in the transfer
197
+ * This function will call moduleCheck() on every module bound to the compliance
198
+ * If each of the module checks return TRUE, this function will return TRUE as well
199
+ * returns FALSE otherwise
200
+ */
201
+ function canTransfer(address _from, address _to, uint256 _amount) external view returns (bool);
202
+
203
+ /**
204
+ * @dev getter for the modules bound to the compliance contract
205
+ * returns address array of module contracts bound to the compliance
206
+ */
207
+ function getModules() external view returns (address[] memory);
208
+
209
+ /**
210
+ * @dev getter for the address of the token bound
211
+ * returns the address of the token
212
+ */
213
+ function getTokenBound() external view returns (address);
214
+
215
+ /**
216
+ * @dev checks if a module is bound to the compliance contract
217
+ * returns true if module is bound, false otherwise
218
+ */
219
+ function isModuleBound(address _module) external view returns (bool);
220
+ }
@@ -0,0 +1,101 @@
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) 2023, 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
+ pragma solidity ^0.8.23;
63
+
64
+ interface IClaimTopicsRegistry {
65
+ /**
66
+ * this event is emitted when a claim topic has been added to the ClaimTopicsRegistry
67
+ * the event is emitted by the 'addClaimTopic' function
68
+ * `claimTopic` is the required claim added to the Claim Topics Registry
69
+ */
70
+ event ClaimTopicAdded(uint256 indexed claimTopic);
71
+
72
+ /**
73
+ * this event is emitted when a claim topic has been removed from the ClaimTopicsRegistry
74
+ * the event is emitted by the 'removeClaimTopic' function
75
+ * `claimTopic` is the required claim removed from the Claim Topics Registry
76
+ */
77
+ event ClaimTopicRemoved(uint256 indexed claimTopic);
78
+
79
+ /**
80
+ * @dev Add a trusted claim topic (For example: KYC=1, AML=2).
81
+ * Only owner can call.
82
+ * emits `ClaimTopicAdded` event
83
+ * cannot add more than 15 topics for 1 token as adding more could create gas issues
84
+ * @param _claimTopic The claim topic index
85
+ */
86
+ function addClaimTopic(uint256 _claimTopic) external;
87
+
88
+ /**
89
+ * @dev Remove a trusted claim topic (For example: KYC=1, AML=2).
90
+ * Only owner can call.
91
+ * emits `ClaimTopicRemoved` event
92
+ * @param _claimTopic The claim topic index
93
+ */
94
+ function removeClaimTopic(uint256 _claimTopic) external;
95
+
96
+ /**
97
+ * @dev Get the trusted claim topics for the security token
98
+ * @return Array of trusted claim topics
99
+ */
100
+ function getClaimTopics() external view returns (uint256[] memory);
101
+ }