@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,457 @@
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 "../registry/interface/IIdentityRegistry.sol";
66
+ import "../compliance/modular/IModularCompliance.sol";
67
+ import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
68
+
69
+ /// @dev interface
70
+ interface IToken is IERC20 {
71
+ /// events
72
+
73
+ /**
74
+ * this event is emitted when the token information is updated.
75
+ * the event is emitted by the token init function and by the setTokenInformation function
76
+ * `_newName` is the name of the token
77
+ * `_newSymbol` is the symbol of the token
78
+ * `_newDecimals` is the decimals of the token
79
+ * `_newVersion` is the version of the token, current version is 3.0
80
+ * `_newOnchainID` is the address of the onchainID of the token
81
+ */
82
+ event UpdatedTokenInformation(
83
+ string indexed _newName,
84
+ string indexed _newSymbol,
85
+ uint8 _newDecimals,
86
+ string _newVersion,
87
+ address indexed _newOnchainID
88
+ );
89
+
90
+ /**
91
+ * this event is emitted when the IdentityRegistry has been set for the token
92
+ * the event is emitted by the token constructor and by the setIdentityRegistry function
93
+ * `_identityRegistry` is the address of the Identity Registry of the token
94
+ */
95
+ event IdentityRegistryAdded(address indexed _identityRegistry);
96
+
97
+ /**
98
+ * this event is emitted when the Compliance has been set for the token
99
+ * the event is emitted by the token constructor and by the setCompliance function
100
+ * `_compliance` is the address of the Compliance contract of the token
101
+ */
102
+ event ComplianceAdded(address indexed _compliance);
103
+
104
+ /**
105
+ * this event is emitted when an investor successfully recovers his tokens
106
+ * the event is emitted by the recoveryAddress function
107
+ * `_lostWallet` is the address of the wallet that the investor lost access to
108
+ * `_newWallet` is the address of the wallet that the investor provided for the recovery
109
+ * `_investorOnchainID` is the address of the onchainID of the investor who asked for a recovery
110
+ */
111
+ event RecoverySuccess(address indexed _lostWallet, address indexed _newWallet, address indexed _investorOnchainID);
112
+
113
+ /**
114
+ * this event is emitted when the wallet of an investor is frozen or unfrozen
115
+ * the event is emitted by setAddressFrozen and batchSetAddressFrozen functions
116
+ * `_userAddress` is the wallet of the investor that is concerned by the freezing status
117
+ * `_isFrozen` is the freezing status of the wallet
118
+ * if `_isFrozen` equals `true` the wallet is frozen after emission of the event
119
+ * if `_isFrozen` equals `false` the wallet is unfrozen after emission of the event
120
+ * `_owner` is the address of the agent who called the function to freeze the wallet
121
+ */
122
+ event AddressFrozen(address indexed _userAddress, bool indexed _isFrozen, address indexed _owner);
123
+
124
+ /**
125
+ * this event is emitted when a certain amount of tokens is frozen on a wallet
126
+ * the event is emitted by freezePartialTokens and batchFreezePartialTokens functions
127
+ * `_userAddress` is the wallet of the investor that is concerned by the freezing status
128
+ * `_amount` is the amount of tokens that are frozen
129
+ */
130
+ event TokensFrozen(address indexed _userAddress, uint256 _amount);
131
+
132
+ /**
133
+ * this event is emitted when a certain amount of tokens is unfrozen on a wallet
134
+ * the event is emitted by unfreezePartialTokens and batchUnfreezePartialTokens functions
135
+ * `_userAddress` is the wallet of the investor that is concerned by the freezing status
136
+ * `_amount` is the amount of tokens that are unfrozen
137
+ */
138
+ event TokensUnfrozen(address indexed _userAddress, uint256 _amount);
139
+
140
+ /**
141
+ * this event is emitted when the token is paused
142
+ * the event is emitted by the pause function
143
+ * `_userAddress` is the address of the wallet that called the pause function
144
+ */
145
+ event Paused(address _userAddress);
146
+
147
+ /**
148
+ * this event is emitted when the token is unpaused
149
+ * the event is emitted by the unpause function
150
+ * `_userAddress` is the address of the wallet that called the unpause function
151
+ */
152
+ event Unpaused(address _userAddress);
153
+
154
+ /// functions
155
+
156
+ /**
157
+ * @dev sets the token name
158
+ * @param _name the name of token to set
159
+ * Only the owner of the token smart contract can call this function
160
+ * emits a `UpdatedTokenInformation` event
161
+ */
162
+ function setName(string calldata _name) external;
163
+
164
+ /**
165
+ * @dev sets the token symbol
166
+ * @param _symbol the token symbol to set
167
+ * Only the owner of the token smart contract can call this function
168
+ * emits a `UpdatedTokenInformation` event
169
+ */
170
+ function setSymbol(string calldata _symbol) external;
171
+
172
+ /**
173
+ * @dev sets the onchain ID of the token
174
+ * @param _onchainID the address of the onchain ID to set
175
+ * Only the owner of the token smart contract can call this function
176
+ * emits a `UpdatedTokenInformation` event
177
+ */
178
+ function setOnchainID(address _onchainID) external;
179
+
180
+ /**
181
+ * @dev pauses the token contract, when contract is paused investors cannot transfer tokens anymore
182
+ * This function can only be called by a wallet set as agent of the token
183
+ * emits a `Paused` event
184
+ */
185
+ function pause() external;
186
+
187
+ /**
188
+ * @dev unpauses the token contract, when contract is unpaused investors can transfer tokens
189
+ * if their wallet is not blocked & if the amount to transfer is <= to the amount of free tokens
190
+ * This function can only be called by a wallet set as agent of the token
191
+ * emits an `Unpaused` event
192
+ */
193
+ function unpause() external;
194
+
195
+ /**
196
+ * @dev sets an address frozen status for this token.
197
+ * @param _userAddress The address for which to update frozen status
198
+ * @param _freeze Frozen status of the address
199
+ * This function can only be called by a wallet set as agent of the token
200
+ * emits an `AddressFrozen` event
201
+ */
202
+ function setAddressFrozen(address _userAddress, bool _freeze) external;
203
+
204
+ /**
205
+ * @dev freezes token amount specified for given address.
206
+ * @param _userAddress The address for which to update frozen tokens
207
+ * @param _amount Amount of Tokens to be frozen
208
+ * This function can only be called by a wallet set as agent of the token
209
+ * emits a `TokensFrozen` event
210
+ */
211
+ function freezePartialTokens(address _userAddress, uint256 _amount) external;
212
+
213
+ /**
214
+ * @dev unfreezes token amount specified for given address
215
+ * @param _userAddress The address for which to update frozen tokens
216
+ * @param _amount Amount of Tokens to be unfrozen
217
+ * This function can only be called by a wallet set as agent of the token
218
+ * emits a `TokensUnfrozen` event
219
+ */
220
+ function unfreezePartialTokens(address _userAddress, uint256 _amount) external;
221
+
222
+ /**
223
+ * @dev sets the Identity Registry for the token
224
+ * @param _identityRegistry the address of the Identity Registry to set
225
+ * Only the owner of the token smart contract can call this function
226
+ * emits an `IdentityRegistryAdded` event
227
+ */
228
+ function setIdentityRegistry(address _identityRegistry) external;
229
+
230
+ /**
231
+ * @dev sets the compliance contract of the token
232
+ * @param _compliance the address of the compliance contract to set
233
+ * Only the owner of the token smart contract can call this function
234
+ * calls bindToken on the compliance contract
235
+ * emits a `ComplianceAdded` event
236
+ */
237
+ function setCompliance(address _compliance) external;
238
+
239
+ /**
240
+ * @dev force a transfer of tokens between 2 whitelisted wallets
241
+ * In case the `from` address has not enough free tokens (unfrozen tokens)
242
+ * but has a total balance higher or equal to the `amount`
243
+ * the amount of frozen tokens is reduced in order to have enough free tokens
244
+ * to proceed the transfer, in such a case, the remaining balance on the `from`
245
+ * account is 100% composed of frozen tokens post-transfer.
246
+ * Require that the `to` address is a verified address,
247
+ * @param _from The address of the sender
248
+ * @param _to The address of the receiver
249
+ * @param _amount The number of tokens to transfer
250
+ * @return `true` if successful and revert if unsuccessful
251
+ * This function can only be called by a wallet set as agent of the token
252
+ * emits a `TokensUnfrozen` event if `_amount` is higher than the free balance of `_from`
253
+ * emits a `Transfer` event
254
+ */
255
+ function forcedTransfer(address _from, address _to, uint256 _amount) external returns (bool);
256
+
257
+ /**
258
+ * @dev mint tokens on a wallet
259
+ * Improved version of default mint method. Tokens can be minted
260
+ * to an address if only it is a verified address as per the security token.
261
+ * @param _to Address to mint the tokens to.
262
+ * @param _amount Amount of tokens to mint.
263
+ * This function can only be called by a wallet set as agent of the token
264
+ * emits a `Transfer` event
265
+ */
266
+ function mint(address _to, uint256 _amount) external;
267
+
268
+ /**
269
+ * @dev burn tokens on a wallet
270
+ * In case the `account` address has not enough free tokens (unfrozen tokens)
271
+ * but has a total balance higher or equal to the `value` amount
272
+ * the amount of frozen tokens is reduced in order to have enough free tokens
273
+ * to proceed the burn, in such a case, the remaining balance on the `account`
274
+ * is 100% composed of frozen tokens post-transaction.
275
+ * @param _userAddress Address to burn the tokens from.
276
+ * @param _amount Amount of tokens to burn.
277
+ * This function can only be called by a wallet set as agent of the token
278
+ * emits a `TokensUnfrozen` event if `_amount` is higher than the free balance of `_userAddress`
279
+ * emits a `Transfer` event
280
+ */
281
+ function burn(address _userAddress, uint256 _amount) external;
282
+
283
+ /**
284
+ * @dev recovery function used to force transfer tokens from a
285
+ * lost wallet to a new wallet for an investor.
286
+ * @param _lostWallet the wallet that the investor lost
287
+ * @param _newWallet the newly provided wallet on which tokens have to be transferred
288
+ * @param _investorOnchainID the onchainID of the investor asking for a recovery
289
+ * This function can only be called by a wallet set as agent of the token
290
+ * emits a `TokensUnfrozen` event if there is some frozen tokens on the lost wallet if the recovery process is
291
+ * successful
292
+ * emits a `Transfer` event if the recovery process is successful
293
+ * emits a `RecoverySuccess` event if the recovery process is successful
294
+ * emits a `RecoveryFails` event if the recovery process fails
295
+ */
296
+ function recoveryAddress(address _lostWallet, address _newWallet, address _investorOnchainID) external returns (bool);
297
+
298
+ /**
299
+ * @dev function allowing to issue transfers in batch
300
+ * Require that the msg.sender and `to` addresses are not frozen.
301
+ * Require that the total value should not exceed available balance.
302
+ * Require that the `to` addresses are all verified addresses,
303
+ * IMPORTANT : THIS TRANSACTION COULD EXCEED GAS LIMIT IF `_toList.length` IS TOO HIGH,
304
+ * USE WITH CARE OR YOU COULD LOSE TX FEES WITH AN "OUT OF GAS" TRANSACTION
305
+ * @param _toList The addresses of the receivers
306
+ * @param _amounts The number of tokens to transfer to the corresponding receiver
307
+ * emits _toList.length `Transfer` events
308
+ */
309
+ function batchTransfer(address[] calldata _toList, uint256[] calldata _amounts) external;
310
+
311
+ /**
312
+ * @dev function allowing to issue forced transfers in batch
313
+ * Require that `_amounts[i]` should not exceed available balance of `_fromList[i]`.
314
+ * Require that the `_toList` addresses are all verified addresses
315
+ * IMPORTANT : THIS TRANSACTION COULD EXCEED GAS LIMIT IF `_fromList.length` IS TOO HIGH,
316
+ * USE WITH CARE OR YOU COULD LOSE TX FEES WITH AN "OUT OF GAS" TRANSACTION
317
+ * @param _fromList The addresses of the senders
318
+ * @param _toList The addresses of the receivers
319
+ * @param _amounts The number of tokens to transfer to the corresponding receiver
320
+ * This function can only be called by a wallet set as agent of the token
321
+ * emits `TokensUnfrozen` events if `_amounts[i]` is higher than the free balance of `_fromList[i]`
322
+ * emits _fromList.length `Transfer` events
323
+ */
324
+ function batchForcedTransfer(
325
+ address[] calldata _fromList,
326
+ address[] calldata _toList,
327
+ uint256[] calldata _amounts
328
+ )
329
+ external;
330
+
331
+ /**
332
+ * @dev function allowing to mint tokens in batch
333
+ * Require that the `_toList` addresses are all verified addresses
334
+ * IMPORTANT : THIS TRANSACTION COULD EXCEED GAS LIMIT IF `_toList.length` IS TOO HIGH,
335
+ * USE WITH CARE OR YOU COULD LOSE TX FEES WITH AN "OUT OF GAS" TRANSACTION
336
+ * @param _toList The addresses of the receivers
337
+ * @param _amounts The number of tokens to mint to the corresponding receiver
338
+ * This function can only be called by a wallet set as agent of the token
339
+ * emits _toList.length `Transfer` events
340
+ */
341
+ function batchMint(address[] calldata _toList, uint256[] calldata _amounts) external;
342
+
343
+ /**
344
+ * @dev function allowing to burn tokens in batch
345
+ * Require that the `_userAddresses` addresses are all verified addresses
346
+ * IMPORTANT : THIS TRANSACTION COULD EXCEED GAS LIMIT IF `_userAddresses.length` IS TOO HIGH,
347
+ * USE WITH CARE OR YOU COULD LOSE TX FEES WITH AN "OUT OF GAS" TRANSACTION
348
+ * @param _userAddresses The addresses of the wallets concerned by the burn
349
+ * @param _amounts The number of tokens to burn from the corresponding wallets
350
+ * This function can only be called by a wallet set as agent of the token
351
+ * emits _userAddresses.length `Transfer` events
352
+ */
353
+ function batchBurn(address[] calldata _userAddresses, uint256[] calldata _amounts) external;
354
+
355
+ /**
356
+ * @dev function allowing to set frozen addresses in batch
357
+ * IMPORTANT : THIS TRANSACTION COULD EXCEED GAS LIMIT IF `_userAddresses.length` IS TOO HIGH,
358
+ * USE WITH CARE OR YOU COULD LOSE TX FEES WITH AN "OUT OF GAS" TRANSACTION
359
+ * @param _userAddresses The addresses for which to update frozen status
360
+ * @param _freeze Frozen status of the corresponding address
361
+ * This function can only be called by a wallet set as agent of the token
362
+ * emits _userAddresses.length `AddressFrozen` events
363
+ */
364
+ function batchSetAddressFrozen(address[] calldata _userAddresses, bool[] calldata _freeze) external;
365
+
366
+ /**
367
+ * @dev function allowing to freeze tokens partially in batch
368
+ * IMPORTANT : THIS TRANSACTION COULD EXCEED GAS LIMIT IF `_userAddresses.length` IS TOO HIGH,
369
+ * USE WITH CARE OR YOU COULD LOSE TX FEES WITH AN "OUT OF GAS" TRANSACTION
370
+ * @param _userAddresses The addresses on which tokens need to be frozen
371
+ * @param _amounts the amount of tokens to freeze on the corresponding address
372
+ * This function can only be called by a wallet set as agent of the token
373
+ * emits _userAddresses.length `TokensFrozen` events
374
+ */
375
+ function batchFreezePartialTokens(address[] calldata _userAddresses, uint256[] calldata _amounts) external;
376
+
377
+ /**
378
+ * @dev function allowing to unfreeze tokens partially in batch
379
+ * IMPORTANT : THIS TRANSACTION COULD EXCEED GAS LIMIT IF `_userAddresses.length` IS TOO HIGH,
380
+ * USE WITH CARE OR YOU COULD LOSE TX FEES WITH AN "OUT OF GAS" TRANSACTION
381
+ * @param _userAddresses The addresses on which tokens need to be unfrozen
382
+ * @param _amounts the amount of tokens to unfreeze on the corresponding address
383
+ * This function can only be called by a wallet set as agent of the token
384
+ * emits _userAddresses.length `TokensUnfrozen` events
385
+ */
386
+ function batchUnfreezePartialTokens(address[] calldata _userAddresses, uint256[] calldata _amounts) external;
387
+
388
+ /**
389
+ * @dev Returns the number of decimals used to get its user representation.
390
+ * For example, if `decimals` equals `2`, a balance of `505` tokens should
391
+ * be displayed to a user as `5,05` (`505 / 1 ** 2`).
392
+ *
393
+ * Tokens usually opt for a value of 18, imitating the relationship between
394
+ * Ether and Wei.
395
+ *
396
+ * NOTE: This information is only used for _display_ purposes: it in
397
+ * no way affects any of the arithmetic of the contract, including
398
+ * balanceOf() and transfer().
399
+ */
400
+ function decimals() external view returns (uint8);
401
+
402
+ /**
403
+ * @dev Returns the name of the token.
404
+ */
405
+ function name() external view returns (string memory);
406
+
407
+ /**
408
+ * @dev Returns the address of the onchainID of the token.
409
+ * the onchainID of the token gives all the information available
410
+ * about the token and is managed by the token issuer or his agent.
411
+ */
412
+ function onchainID() external view returns (address);
413
+
414
+ /**
415
+ * @dev Returns the symbol of the token, usually a shorter version of the
416
+ * name.
417
+ */
418
+ function symbol() external view returns (string memory);
419
+
420
+ /**
421
+ * @dev Returns the TREX version of the token.
422
+ * current version is 3.0.0
423
+ */
424
+ function version() external view returns (string memory);
425
+
426
+ /**
427
+ * @dev Returns the Identity Registry linked to the token
428
+ */
429
+ function identityRegistry() external view returns (IIdentityRegistry);
430
+
431
+ /**
432
+ * @dev Returns the Compliance contract linked to the token
433
+ */
434
+ function compliance() external view returns (IModularCompliance);
435
+
436
+ /**
437
+ * @dev Returns true if the contract is paused, and false otherwise.
438
+ */
439
+ function paused() external view returns (bool);
440
+
441
+ /**
442
+ * @dev Returns the freezing status of a wallet
443
+ * if isFrozen returns `true` the wallet is frozen
444
+ * if isFrozen returns `false` the wallet is not frozen
445
+ * isFrozen returning `true` doesn't mean that the balance is free, tokens could be blocked by
446
+ * a partial freeze or the whole token could be blocked by pause
447
+ * @param _userAddress the address of the wallet on which isFrozen is called
448
+ */
449
+ function isFrozen(address _userAddress) external view returns (bool);
450
+
451
+ /**
452
+ * @dev Returns the amount of tokens that are partially frozen on a wallet
453
+ * the amount of frozen tokens is always <= to the total balance of the wallet
454
+ * @param _userAddress the address of the wallet on which getFrozenTokens is called
455
+ */
456
+ function getFrozenTokens(address _userAddress) external view returns (uint256);
457
+ }
@@ -0,0 +1,53 @@
1
+ // SPDX-License-Identifier: GPL-3.0
2
+ pragma solidity ^0.8.23;
3
+
4
+ import "./IIdentity.sol";
5
+
6
+ interface IClaimIssuer is IIdentity {
7
+ /**
8
+ * @dev Emitted when a claim is revoked.
9
+ *
10
+ * Specification: MUST be triggered when revoking a claim.
11
+ */
12
+ event ClaimRevoked(bytes indexed signature);
13
+
14
+ /**
15
+ * @dev Revoke a claim previously issued, the claim is no longer considered as valid after revocation.
16
+ * @notice will fetch the claim from the identity contract (unsafe).
17
+ * @param _claimId the id of the claim
18
+ * @param _identity the address of the identity contract
19
+ * @return isRevoked true when the claim is revoked
20
+ */
21
+ function revokeClaim(bytes32 _claimId, address _identity) external returns (bool);
22
+
23
+ /**
24
+ * @dev Revoke a claim previously issued, the claim is no longer considered as valid after revocation.
25
+ * @param signature the signature of the claim
26
+ */
27
+ function revokeClaimBySignature(bytes calldata signature) external;
28
+
29
+ /**
30
+ * @dev Returns revocation status of a claim.
31
+ * @param _sig the signature of the claim
32
+ * @return isRevoked true if the claim is revoked and false otherwise
33
+ */
34
+ function isClaimRevoked(bytes calldata _sig) external view returns (bool);
35
+
36
+ /**
37
+ * @dev Checks if a claim is valid.
38
+ * @param _identity the identity contract related to the claim
39
+ * @param claimTopic the claim topic of the claim
40
+ * @param sig the signature of the claim
41
+ * @param data the data field of the claim
42
+ * @return claimValid true if the claim is valid, false otherwise
43
+ */
44
+ function isClaimValid(
45
+ IIdentity _identity,
46
+ uint256 claimTopic,
47
+ bytes calldata sig,
48
+ bytes calldata data
49
+ )
50
+ external
51
+ view
52
+ returns (bool);
53
+ }
@@ -0,0 +1,110 @@
1
+ // SPDX-License-Identifier: GPL-3.0
2
+ pragma solidity ^0.8.23;
3
+
4
+ /**
5
+ * @dev interface of the ERC734 (Key Holder) standard as defined in the EIP.
6
+ */
7
+ interface IERC734 {
8
+ /**
9
+ * @dev Emitted when an execution request was approved.
10
+ *
11
+ * Specification: MUST be triggered when approve was successfully called.
12
+ */
13
+ event Approved(uint256 indexed executionId, bool approved);
14
+
15
+ /**
16
+ * @dev Emitted when an execute operation was approved and successfully performed.
17
+ *
18
+ * Specification: MUST be triggered when approve was called and the execution was successfully approved.
19
+ */
20
+ event Executed(uint256 indexed executionId, address indexed to, uint256 indexed value, bytes data);
21
+
22
+ /**
23
+ * @dev Emitted when an execution request was performed via `execute`.
24
+ *
25
+ * Specification: MUST be triggered when execute was successfully called.
26
+ */
27
+ event ExecutionRequested(uint256 indexed executionId, address indexed to, uint256 indexed value, bytes data);
28
+
29
+ /**
30
+ * @dev Emitted when an execute operation was called and failed
31
+ *
32
+ * Specification: MUST be triggered when execute call failed
33
+ */
34
+ event ExecutionFailed(uint256 indexed executionId, address indexed to, uint256 indexed value, bytes data);
35
+
36
+ /**
37
+ * @dev Emitted when a key was added to the Identity.
38
+ *
39
+ * Specification: MUST be triggered when addKey was successfully called.
40
+ */
41
+ event KeyAdded(bytes32 indexed key, uint256 indexed purpose, uint256 indexed keyType);
42
+
43
+ /**
44
+ * @dev Emitted when a key was removed from the Identity.
45
+ *
46
+ * Specification: MUST be triggered when removeKey was successfully called.
47
+ */
48
+ event KeyRemoved(bytes32 indexed key, uint256 indexed purpose, uint256 indexed keyType);
49
+
50
+ /**
51
+ * @dev Adds a _key to the identity. The _purpose specifies the purpose of the key.
52
+ *
53
+ * Triggers Event: `KeyAdded`
54
+ *
55
+ * Specification: MUST only be done by keys of purpose 1, or the identity
56
+ * itself. If it's the identity itself, the approval process will determine its approval.
57
+ */
58
+ function addKey(bytes32 _key, uint256 _purpose, uint256 _keyType) external returns (bool success);
59
+
60
+ /**
61
+ * @dev Approves an execution.
62
+ *
63
+ * Triggers Event: `Approved`
64
+ * Triggers on execution successful Event: `Executed`
65
+ * Triggers on execution failure Event: `ExecutionFailed`
66
+ */
67
+ function approve(uint256 _id, bool _approve) external returns (bool success);
68
+
69
+ /**
70
+ * @dev Removes _purpose for _key from the identity.
71
+ *
72
+ * Triggers Event: `KeyRemoved`
73
+ *
74
+ * Specification: MUST only be done by keys of purpose 1, or the identity itself.
75
+ * If it's the identity itself, the approval process will determine its approval.
76
+ */
77
+ function removeKey(bytes32 _key, uint256 _purpose) external returns (bool success);
78
+
79
+ /**
80
+ * @dev Passes an execution instruction to an ERC734 identity.
81
+ * How the execution is handled is up to the identity implementation:
82
+ * An execution COULD be requested and require `approve` to be called with one or more keys of purpose 1 or 2 to
83
+ * approve this execution.
84
+ * Execute COULD be used as the only accessor for `addKey` and `removeKey`.
85
+ *
86
+ * Triggers Event: ExecutionRequested
87
+ * Triggers on direct execution Event: Executed
88
+ */
89
+ function execute(address _to, uint256 _value, bytes calldata _data) external payable returns (uint256 executionId);
90
+
91
+ /**
92
+ * @dev Returns the full key data, if present in the identity.
93
+ */
94
+ function getKey(bytes32 _key) external view returns (uint256[] memory purposes, uint256 keyType, bytes32 key);
95
+
96
+ /**
97
+ * @dev Returns the list of purposes associated with a key.
98
+ */
99
+ function getKeyPurposes(bytes32 _key) external view returns (uint256[] memory _purposes);
100
+
101
+ /**
102
+ * @dev Returns an array of public key bytes32 held by this identity.
103
+ */
104
+ function getKeysByPurpose(uint256 _purpose) external view returns (bytes32[] memory keys);
105
+
106
+ /**
107
+ * @dev Returns TRUE if a key is present and has the given purpose. If the key is not present it returns FALSE.
108
+ */
109
+ function keyHasPurpose(bytes32 _key, uint256 _purpose) external view returns (bool exists);
110
+ }