@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,251 @@
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
+ import "./ITrustedIssuersRegistry.sol";
65
+ import "./IClaimTopicsRegistry.sol";
66
+ import "./IIdentityRegistryStorage.sol";
67
+
68
+ import "../../../onchain-id/interface/IClaimIssuer.sol";
69
+ import "../../../onchain-id/interface/IIdentity.sol";
70
+
71
+ interface IIdentityRegistry {
72
+ /**
73
+ * this event is emitted when the ClaimTopicsRegistry has been set for the IdentityRegistry
74
+ * the event is emitted by the IdentityRegistry constructor
75
+ * `claimTopicsRegistry` is the address of the Claim Topics Registry contract
76
+ */
77
+ event ClaimTopicsRegistrySet(address indexed claimTopicsRegistry);
78
+
79
+ /**
80
+ * this event is emitted when the IdentityRegistryStorage has been set for the IdentityRegistry
81
+ * the event is emitted by the IdentityRegistry constructor
82
+ * `identityStorage` is the address of the Identity Registry Storage contract
83
+ */
84
+ event IdentityStorageSet(address indexed identityStorage);
85
+
86
+ /**
87
+ * this event is emitted when the TrustedIssuersRegistry has been set for the IdentityRegistry
88
+ * the event is emitted by the IdentityRegistry constructor
89
+ * `trustedIssuersRegistry` is the address of the Trusted Issuers Registry contract
90
+ */
91
+ event TrustedIssuersRegistrySet(address indexed trustedIssuersRegistry);
92
+
93
+ /**
94
+ * this event is emitted when an Identity is registered into the Identity Registry.
95
+ * the event is emitted by the 'registerIdentity' function
96
+ * `investorAddress` is the address of the investor's wallet
97
+ * `identity` is the address of the Identity smart contract (onchainID)
98
+ */
99
+ event IdentityRegistered(address indexed investorAddress, IIdentity indexed identity);
100
+
101
+ /**
102
+ * this event is emitted when an Identity is removed from the Identity Registry.
103
+ * the event is emitted by the 'deleteIdentity' function
104
+ * `investorAddress` is the address of the investor's wallet
105
+ * `identity` is the address of the Identity smart contract (onchainID)
106
+ */
107
+ event IdentityRemoved(address indexed investorAddress, IIdentity indexed identity);
108
+
109
+ /**
110
+ * this event is emitted when an Identity has been updated
111
+ * the event is emitted by the 'updateIdentity' function
112
+ * `oldIdentity` is the old Identity contract's address to update
113
+ * `newIdentity` is the new Identity contract's
114
+ */
115
+ event IdentityUpdated(IIdentity indexed oldIdentity, IIdentity indexed newIdentity);
116
+
117
+ /**
118
+ * this event is emitted when an Identity's country has been updated
119
+ * the event is emitted by the 'updateCountry' function
120
+ * `investorAddress` is the address on which the country has been updated
121
+ * `country` is the numeric code (ISO 3166-1) of the new country
122
+ */
123
+ event CountryUpdated(address indexed investorAddress, uint16 indexed country);
124
+
125
+ /**
126
+ * @dev Register an identity contract corresponding to a user address.
127
+ * Requires that the user doesn't have an identity contract already registered.
128
+ * This function can only be called by a wallet set as agent of the smart contract
129
+ * @param _userAddress The address of the user
130
+ * @param _identity The address of the user's identity contract
131
+ * @param _country The country of the investor
132
+ * emits `IdentityRegistered` event
133
+ */
134
+ function registerIdentity(address _userAddress, IIdentity _identity, uint16 _country) external;
135
+
136
+ /**
137
+ * @dev Removes an user from the identity registry.
138
+ * Requires that the user have an identity contract already deployed that will be deleted.
139
+ * This function can only be called by a wallet set as agent of the smart contract
140
+ * @param _userAddress The address of the user to be removed
141
+ * emits `IdentityRemoved` event
142
+ */
143
+ function deleteIdentity(address _userAddress) external;
144
+
145
+ /**
146
+ * @dev Replace the actual identityRegistryStorage contract with a new one.
147
+ * This function can only be called by the wallet set as owner of the smart contract
148
+ * @param _identityRegistryStorage The address of the new Identity Registry Storage
149
+ * emits `IdentityStorageSet` event
150
+ */
151
+ function setIdentityRegistryStorage(address _identityRegistryStorage) external;
152
+
153
+ /**
154
+ * @dev Replace the actual claimTopicsRegistry contract with a new one.
155
+ * This function can only be called by the wallet set as owner of the smart contract
156
+ * @param _claimTopicsRegistry The address of the new claim Topics Registry
157
+ * emits `ClaimTopicsRegistrySet` event
158
+ */
159
+ function setClaimTopicsRegistry(address _claimTopicsRegistry) external;
160
+
161
+ /**
162
+ * @dev Replace the actual trustedIssuersRegistry contract with a new one.
163
+ * This function can only be called by the wallet set as owner of the smart contract
164
+ * @param _trustedIssuersRegistry The address of the new Trusted Issuers Registry
165
+ * emits `TrustedIssuersRegistrySet` event
166
+ */
167
+ function setTrustedIssuersRegistry(address _trustedIssuersRegistry) external;
168
+
169
+ /**
170
+ * @dev Updates the country corresponding to a user address.
171
+ * Requires that the user should have an identity contract already deployed that will be replaced.
172
+ * This function can only be called by a wallet set as agent of the smart contract
173
+ * @param _userAddress The address of the user
174
+ * @param _country The new country of the user
175
+ * emits `CountryUpdated` event
176
+ */
177
+ function updateCountry(address _userAddress, uint16 _country) external;
178
+
179
+ /**
180
+ * @dev Updates an identity contract corresponding to a user address.
181
+ * Requires that the user address should be the owner of the identity contract.
182
+ * Requires that the user should have an identity contract already deployed that will be replaced.
183
+ * This function can only be called by a wallet set as agent of the smart contract
184
+ * @param _userAddress The address of the user
185
+ * @param _identity The address of the user's new identity contract
186
+ * emits `IdentityUpdated` event
187
+ */
188
+ function updateIdentity(address _userAddress, IIdentity _identity) external;
189
+
190
+ /**
191
+ * @dev function allowing to register identities in batch
192
+ * This function can only be called by a wallet set as agent of the smart contract
193
+ * Requires that none of the users has an identity contract already registered.
194
+ * IMPORTANT : THIS TRANSACTION COULD EXCEED GAS LIMIT IF `_userAddresses.length` IS TOO HIGH,
195
+ * USE WITH CARE OR YOU COULD LOSE TX FEES WITH AN "OUT OF GAS" TRANSACTION
196
+ * @param _userAddresses The addresses of the users
197
+ * @param _identities The addresses of the corresponding identity contracts
198
+ * @param _countries The countries of the corresponding investors
199
+ * emits _userAddresses.length `IdentityRegistered` events
200
+ */
201
+ function batchRegisterIdentity(
202
+ address[] calldata _userAddresses,
203
+ IIdentity[] calldata _identities,
204
+ uint16[] calldata _countries
205
+ )
206
+ external;
207
+
208
+ /**
209
+ * @dev This functions checks whether a wallet has its Identity registered or not
210
+ * in the Identity Registry.
211
+ * @param _userAddress The address of the user to be checked.
212
+ * @return 'True' if the address is contained in the Identity Registry, 'false' if not.
213
+ */
214
+ function contains(address _userAddress) external view returns (bool);
215
+
216
+ /**
217
+ * @dev This functions checks whether an identity contract
218
+ * corresponding to the provided user address has the required claims or not based
219
+ * on the data fetched from trusted issuers registry and from the claim topics registry
220
+ * @param _userAddress The address of the user to be verified.
221
+ * @return 'True' if the address is verified, 'false' if not.
222
+ */
223
+ function isVerified(address _userAddress) external view returns (bool);
224
+
225
+ /**
226
+ * @dev Returns the onchainID of an investor.
227
+ * @param _userAddress The wallet of the investor
228
+ */
229
+ function identity(address _userAddress) external view returns (IIdentity);
230
+
231
+ /**
232
+ * @dev Returns the country code of an investor.
233
+ * @param _userAddress The wallet of the investor
234
+ */
235
+ function investorCountry(address _userAddress) external view returns (uint16);
236
+
237
+ /**
238
+ * @dev Returns the IdentityRegistryStorage linked to the current IdentityRegistry.
239
+ */
240
+ function identityStorage() external view returns (IIdentityRegistryStorage);
241
+
242
+ /**
243
+ * @dev Returns the TrustedIssuersRegistry linked to the current IdentityRegistry.
244
+ */
245
+ function issuersRegistry() external view returns (ITrustedIssuersRegistry);
246
+
247
+ /**
248
+ * @dev Returns the ClaimTopicsRegistry linked to the current IdentityRegistry.
249
+ */
250
+ function topicsRegistry() external view returns (IClaimTopicsRegistry);
251
+ }
@@ -0,0 +1,191 @@
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
+ import "../../../onchain-id/interface/IIdentity.sol";
65
+
66
+ interface IIdentityRegistryStorage {
67
+ /// events
68
+
69
+ /**
70
+ * this event is emitted when an Identity is registered into the storage contract.
71
+ * the event is emitted by the 'registerIdentity' function
72
+ * `investorAddress` is the address of the investor's wallet
73
+ * `identity` is the address of the Identity smart contract (onchainID)
74
+ */
75
+ event IdentityStored(address indexed investorAddress, IIdentity indexed identity);
76
+
77
+ /**
78
+ * this event is emitted when an Identity is removed from the storage contract.
79
+ * the event is emitted by the 'deleteIdentity' function
80
+ * `investorAddress` is the address of the investor's wallet
81
+ * `identity` is the address of the Identity smart contract (onchainID)
82
+ */
83
+ event IdentityUnstored(address indexed investorAddress, IIdentity indexed identity);
84
+
85
+ /**
86
+ * this event is emitted when an Identity has been updated
87
+ * the event is emitted by the 'updateIdentity' function
88
+ * `oldIdentity` is the old Identity contract's address to update
89
+ * `newIdentity` is the new Identity contract's
90
+ */
91
+ event IdentityModified(IIdentity indexed oldIdentity, IIdentity indexed newIdentity);
92
+
93
+ /**
94
+ * this event is emitted when an Identity's country has been updated
95
+ * the event is emitted by the 'updateCountry' function
96
+ * `investorAddress` is the address on which the country has been updated
97
+ * `country` is the numeric code (ISO 3166-1) of the new country
98
+ */
99
+ event CountryModified(address indexed investorAddress, uint16 indexed country);
100
+
101
+ /**
102
+ * this event is emitted when an Identity Registry is bound to the storage contract
103
+ * the event is emitted by the 'addIdentityRegistry' function
104
+ * `identityRegistry` is the address of the identity registry added
105
+ */
106
+ event IdentityRegistryBound(address indexed identityRegistry);
107
+
108
+ /**
109
+ * this event is emitted when an Identity Registry is unbound from the storage contract
110
+ * the event is emitted by the 'removeIdentityRegistry' function
111
+ * `identityRegistry` is the address of the identity registry removed
112
+ */
113
+ event IdentityRegistryUnbound(address indexed identityRegistry);
114
+
115
+ /// functions
116
+
117
+ /**
118
+ * @dev adds an identity contract corresponding to a user address in the storage.
119
+ * Requires that the user doesn't have an identity contract already registered.
120
+ * This function can only be called by an address set as agent of the smart contract
121
+ * @param _userAddress The address of the user
122
+ * @param _identity The address of the user's identity contract
123
+ * @param _country The country of the investor
124
+ * emits `IdentityStored` event
125
+ */
126
+ function addIdentityToStorage(address _userAddress, IIdentity _identity, uint16 _country) external;
127
+
128
+ /**
129
+ * @dev Removes an user from the storage.
130
+ * Requires that the user have an identity contract already deployed that will be deleted.
131
+ * This function can only be called by an address set as agent of the smart contract
132
+ * @param _userAddress The address of the user to be removed
133
+ * emits `IdentityUnstored` event
134
+ */
135
+ function removeIdentityFromStorage(address _userAddress) external;
136
+
137
+ /**
138
+ * @dev Updates the country corresponding to a user address.
139
+ * Requires that the user should have an identity contract already deployed that will be replaced.
140
+ * This function can only be called by an address set as agent of the smart contract
141
+ * @param _userAddress The address of the user
142
+ * @param _country The new country of the user
143
+ * emits `CountryModified` event
144
+ */
145
+ function modifyStoredInvestorCountry(address _userAddress, uint16 _country) external;
146
+
147
+ /**
148
+ * @dev Updates an identity contract corresponding to a user address.
149
+ * Requires that the user address should be the owner of the identity contract.
150
+ * Requires that the user should have an identity contract already deployed that will be replaced.
151
+ * This function can only be called by an address set as agent of the smart contract
152
+ * @param _userAddress The address of the user
153
+ * @param _identity The address of the user's new identity contract
154
+ * emits `IdentityModified` event
155
+ */
156
+ function modifyStoredIdentity(address _userAddress, IIdentity _identity) external;
157
+
158
+ /**
159
+ * @notice Adds an identity registry as agent of the Identity Registry Storage Contract.
160
+ * This function can only be called by the wallet set as owner of the smart contract
161
+ * This function adds the identity registry to the list of identityRegistries linked to the storage contract
162
+ * cannot bind more than 300 IR to 1 IRS
163
+ * @param _identityRegistry The identity registry address to add.
164
+ */
165
+ function bindIdentityRegistry(address _identityRegistry) external;
166
+
167
+ /**
168
+ * @notice Removes an identity registry from being agent of the Identity Registry Storage Contract.
169
+ * This function can only be called by the wallet set as owner of the smart contract
170
+ * This function removes the identity registry from the list of identityRegistries linked to the storage contract
171
+ * @param _identityRegistry The identity registry address to remove.
172
+ */
173
+ function unbindIdentityRegistry(address _identityRegistry) external;
174
+
175
+ /**
176
+ * @dev Returns the identity registries linked to the storage contract
177
+ */
178
+ function linkedIdentityRegistries() external view returns (address[] memory);
179
+
180
+ /**
181
+ * @dev Returns the onchainID of an investor.
182
+ * @param _userAddress The wallet of the investor
183
+ */
184
+ function storedIdentity(address _userAddress) external view returns (IIdentity);
185
+
186
+ /**
187
+ * @dev Returns the country code of an investor.
188
+ * @param _userAddress The wallet of the investor
189
+ */
190
+ function storedInvestorCountry(address _userAddress) external view returns (uint16);
191
+ }
@@ -0,0 +1,161 @@
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
+ /**
41
+ * NOTICE
42
+ *
43
+ * The T-REX software is licensed under a proprietary license or the GPL v.3.
44
+ * If you choose to receive it under the GPL v.3 license, the following applies:
45
+ * T-REX is a suite of smart contracts implementing the ERC-3643 standard and
46
+ * developed by Tokeny to manage and transfer financial assets on EVM blockchains
47
+ *
48
+ * Copyright (C) 2023, Tokeny sàrl.
49
+ *
50
+ * This program is free software: you can redistribute it and/or modify
51
+ * it under the terms of the GNU General Public License as published by
52
+ * the Free Software Foundation, either version 3 of the License, or
53
+ * (at your option) any later version.
54
+ *
55
+ * This program is distributed in the hope that it will be useful,
56
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
57
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
58
+ * GNU General Public License for more details.
59
+ *
60
+ * You should have received a copy of the GNU General Public License
61
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
62
+ */
63
+ pragma solidity ^0.8.23;
64
+
65
+ import "../../../onchain-id/interface/IClaimIssuer.sol";
66
+
67
+ interface ITrustedIssuersRegistry {
68
+ /**
69
+ * this event is emitted when a trusted issuer is added in the registry.
70
+ * the event is emitted by the addTrustedIssuer function
71
+ * `trustedIssuer` is the address of the trusted issuer's ClaimIssuer contract
72
+ * `claimTopics` is the set of claims that the trusted issuer is allowed to emit
73
+ */
74
+ event TrustedIssuerAdded(IClaimIssuer indexed trustedIssuer, uint256[] claimTopics);
75
+
76
+ /**
77
+ * this event is emitted when a trusted issuer is removed from the registry.
78
+ * the event is emitted by the removeTrustedIssuer function
79
+ * `trustedIssuer` is the address of the trusted issuer's ClaimIssuer contract
80
+ */
81
+ event TrustedIssuerRemoved(IClaimIssuer indexed trustedIssuer);
82
+
83
+ /**
84
+ * this event is emitted when the set of claim topics is changed for a given trusted issuer.
85
+ * the event is emitted by the updateIssuerClaimTopics function
86
+ * `trustedIssuer` is the address of the trusted issuer's ClaimIssuer contract
87
+ * `claimTopics` is the set of claims that the trusted issuer is allowed to emit
88
+ */
89
+ event ClaimTopicsUpdated(IClaimIssuer indexed trustedIssuer, uint256[] claimTopics);
90
+
91
+ /**
92
+ * @dev registers a ClaimIssuer contract as trusted claim issuer.
93
+ * Requires that a ClaimIssuer contract doesn't already exist
94
+ * Requires that the claimTopics set is not empty
95
+ * Requires that there is no more than 15 claimTopics
96
+ * Requires that there is no more than 50 Trusted issuers
97
+ * @param _trustedIssuer The ClaimIssuer contract address of the trusted claim issuer.
98
+ * @param _claimTopics the set of claim topics that the trusted issuer is allowed to emit
99
+ * This function can only be called by the owner of the Trusted Issuers Registry contract
100
+ * emits a `TrustedIssuerAdded` event
101
+ */
102
+ function addTrustedIssuer(IClaimIssuer _trustedIssuer, uint256[] calldata _claimTopics) external;
103
+
104
+ /**
105
+ * @dev Removes the ClaimIssuer contract of a trusted claim issuer.
106
+ * Requires that the claim issuer contract to be registered first
107
+ * @param _trustedIssuer the claim issuer to remove.
108
+ * This function can only be called by the owner of the Trusted Issuers Registry contract
109
+ * emits a `TrustedIssuerRemoved` event
110
+ */
111
+ function removeTrustedIssuer(IClaimIssuer _trustedIssuer) external;
112
+
113
+ /**
114
+ * @dev Updates the set of claim topics that a trusted issuer is allowed to emit.
115
+ * Requires that this ClaimIssuer contract already exists in the registry
116
+ * Requires that the provided claimTopics set is not empty
117
+ * Requires that there is no more than 15 claimTopics
118
+ * @param _trustedIssuer the claim issuer to update.
119
+ * @param _claimTopics the set of claim topics that the trusted issuer is allowed to emit
120
+ * This function can only be called by the owner of the Trusted Issuers Registry contract
121
+ * emits a `ClaimTopicsUpdated` event
122
+ */
123
+ function updateIssuerClaimTopics(IClaimIssuer _trustedIssuer, uint256[] calldata _claimTopics) external;
124
+
125
+ /**
126
+ * @dev Function for getting all the trusted claim issuers stored.
127
+ * @return array of all claim issuers registered.
128
+ */
129
+ function getTrustedIssuers() external view returns (IClaimIssuer[] memory);
130
+
131
+ /**
132
+ * @dev Function for getting all the trusted issuer allowed for a given claim topic.
133
+ * @param claimTopic the claim topic to get the trusted issuers for.
134
+ * @return array of all claim issuer addresses that are allowed for the given claim topic.
135
+ */
136
+ function getTrustedIssuersForClaimTopic(uint256 claimTopic) external view returns (IClaimIssuer[] memory);
137
+
138
+ /**
139
+ * @dev Checks if the ClaimIssuer contract is trusted
140
+ * @param _issuer the address of the ClaimIssuer contract
141
+ * @return true if the issuer is trusted, false otherwise.
142
+ */
143
+ function isTrustedIssuer(address _issuer) external view returns (bool);
144
+
145
+ /**
146
+ * @dev Function for getting all the claim topic of trusted claim issuer
147
+ * Requires the provided ClaimIssuer contract to be registered in the trusted issuers registry.
148
+ * @param _trustedIssuer the trusted issuer concerned.
149
+ * @return The set of claim topics that the trusted issuer is allowed to emit
150
+ */
151
+ function getTrustedIssuerClaimTopics(IClaimIssuer _trustedIssuer) external view returns (uint256[] memory);
152
+
153
+ /**
154
+ * @dev Function for checking if the trusted claim issuer is allowed
155
+ * to emit a certain claim topic
156
+ * @param _issuer the address of the trusted issuer's ClaimIssuer contract
157
+ * @param _claimTopic the Claim Topic that has to be checked to know if the `issuer` is allowed to emit it
158
+ * @return true if the issuer is trusted for this claim topic.
159
+ */
160
+ function hasClaimTopic(address _issuer, uint256 _claimTopic) external view returns (bool);
161
+ }