@t-rex-network/t-rex 4.2.0-beta1 → 5.0.0-beta3

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 (386) hide show
  1. package/NOTICE.md +78 -0
  2. package/README.md +24 -27
  3. package/contracts/{roles/AgentRole.sol → ERC-3643/ERC3643ErrorsLib.sol} +60 -33
  4. package/contracts/ERC-3643/IERC3643.sol +61 -5
  5. package/contracts/ERC-3643/IERC3643ClaimTopicsRegistry.sol +11 -2
  6. package/contracts/ERC-3643/IERC3643Compliance.sol +21 -8
  7. package/contracts/ERC-3643/IERC3643IdentityRegistry.sol +33 -0
  8. package/contracts/ERC-3643/IERC3643IdentityRegistryStorage.sol +62 -7
  9. package/contracts/ERC-3643/IERC3643TrustedIssuersRegistry.sol +29 -12
  10. package/contracts/ERC-3643/base/ERC3643ClaimTopicsRegistry.sol +140 -0
  11. package/contracts/ERC-3643/base/ERC3643Compliance.sol +223 -0
  12. package/contracts/ERC-3643/base/ERC3643IdentityRegistry.sol +382 -0
  13. package/contracts/ERC-3643/base/ERC3643IdentityRegistryStorage.sol +290 -0
  14. package/contracts/ERC-3643/base/ERC3643Token.sol +601 -0
  15. package/contracts/ERC-3643/base/ERC3643TrustedIssuersRegistry.sol +237 -0
  16. package/contracts/compliance/modular/ComplianceLedger.sol +175 -0
  17. package/contracts/compliance/modular/ComplianceLedgerLib.sol +120 -0
  18. package/contracts/compliance/modular/IComplianceLedger.sol +104 -0
  19. package/contracts/compliance/modular/IModularCompliance.sol +119 -28
  20. package/contracts/compliance/modular/ITransferValidation.sol +308 -0
  21. package/contracts/compliance/modular/ModularCompliance.sol +399 -240
  22. package/contracts/compliance/modular/ModuleSetLib.sol +182 -0
  23. package/contracts/compliance/modular/MovementKindLib.sol +97 -0
  24. package/contracts/compliance/modular/TransferContextLib.sol +140 -0
  25. package/contracts/compliance/modular/TransferValidation.sol +822 -0
  26. package/contracts/compliance/modular/TransferValidationLib.sol +183 -0
  27. package/contracts/compliance/modular/modules/AbstractModuleUpgradeable.sol +87 -56
  28. package/contracts/compliance/modular/modules/IModule.sol +142 -58
  29. package/contracts/compliance/modular/modules/MaxBalancePerIdentityModule.sol +175 -0
  30. package/contracts/compliance/modular/modules/ModuleProxy.sol +24 -24
  31. package/contracts/compliance/modular/modules/SpenderVerificationModule.sol +149 -0
  32. package/contracts/compliance/modular/modules/SpenderWhitelistModule.sol +215 -0
  33. package/contracts/factory/ITREXFactory.sol +94 -44
  34. package/contracts/factory/TREXFactory.sol +408 -201
  35. package/contracts/interop/ISettlementHandler.sol +101 -0
  36. package/contracts/interop/ITREXMessaging.sol +166 -0
  37. package/contracts/{proxy/ModularComplianceProxy.sol → interop/ITrustedGatewayRegistry.sol} +48 -43
  38. package/contracts/interop/TREXMessaging.sol +189 -0
  39. package/contracts/interop/TREXMessagingLib.sol +425 -0
  40. package/contracts/{proxy/TrustedIssuersRegistryProxy.sol → interop/TrustedGatewayRegistry.sol} +46 -37
  41. package/contracts/libraries/AccessManagerSetupLib.sol +484 -0
  42. package/contracts/libraries/ErrorsLib.sol +172 -65
  43. package/contracts/libraries/EventsLib.sol +168 -66
  44. package/contracts/libraries/MessageTypesLib.sol +259 -0
  45. package/contracts/libraries/RolesLib.sol +146 -0
  46. package/contracts/{roles/Roles.sol → libraries/VersionLib.sol} +46 -49
  47. package/contracts/libraries/WalletKeyLib.sol +156 -0
  48. package/contracts/proxy/beacon/ITREXImplementationAuthority.sol +157 -0
  49. package/contracts/proxy/beacon/TREXImplementationAuthority.sol +188 -0
  50. package/contracts/registry/implementation/IdentityRegistryStorage.sol +215 -163
  51. package/contracts/registry/implementation/TREXRegistry.sol +475 -0
  52. package/contracts/registry/interface/IIdentityRegistryStorage.sol +30 -25
  53. package/contracts/registry/interface/ITREXRegistry.sol +180 -0
  54. package/contracts/token/IToken.sol +210 -49
  55. package/contracts/token/Token.sol +411 -476
  56. package/contracts/token/TokenDelegationLib.sol +339 -0
  57. package/contracts/token/TokenGuardsLib.sol +123 -0
  58. package/contracts/token/TokenLedgerLib.sol +316 -0
  59. package/contracts/token/TokenRecoveryLib.sol +130 -0
  60. package/contracts/{roles/AgentRoleUpgradeable.sol → utils/AccessManagedOwnable.sol} +31 -31
  61. package/contracts/{proxy/IdentityRegistryStorageProxy.sol → utils/AccessManagedOwnableBase.sol} +56 -34
  62. package/contracts/utils/AccessManagedOwnableUpgradeable.sol +116 -0
  63. package/contracts/utils/IUtilityChecker.sol +32 -26
  64. package/contracts/{roles/AbstractAgentRole.sol → utils/TREXAccessManager.sol} +54 -57
  65. package/contracts/utils/UtilityChecker.sol +175 -52
  66. package/contracts/utils/UtilityCheckerProxy.sol +24 -24
  67. package/contracts/{proxy/interface/IProxy.sol → vendor/IERC173.sol} +15 -28
  68. package/out/AbstractModuleUpgradeable.sol/AbstractModuleUpgradeable.json +1 -1
  69. package/out/AbstractSigner.sol/AbstractSigner.json +1 -0
  70. package/out/AccessManaged.sol/AccessManaged.json +1 -0
  71. package/out/AccessManagedOwnable.sol/AccessManagedOwnable.json +1 -0
  72. package/out/AccessManagedOwnableBase.sol/AccessManagedOwnableBase.json +1 -0
  73. package/out/AccessManagedOwnableUpgradeable.sol/AccessManagedOwnableUpgradeable.json +1 -0
  74. package/out/AccessManagedUpgradeable.sol/AccessManagedUpgradeable.json +1 -0
  75. package/out/AccessManager.sol/AccessManager.json +1 -0
  76. package/out/AccessManagerHelper.sol/AccessManagerHelper.json +1 -0
  77. package/out/AccessManagerSetupLib.sol/AccessManagerSetupLib.json +1 -0
  78. package/out/AccessManagerUpgradeable.sol/AccessManagerUpgradeable.json +1 -0
  79. package/out/Account.sol/Account.json +1 -0
  80. package/out/Address.sol/Address.json +1 -1
  81. package/out/Arrays.sol/Arrays.json +1 -1
  82. package/out/AuthorityUtils.sol/AuthorityUtils.json +1 -0
  83. package/out/Base.sol/CommonBase.json +1 -1
  84. package/out/Base.sol/ScriptBase.json +1 -1
  85. package/out/Base.sol/TestBase.json +1 -1
  86. package/out/Base64.sol/Base64.json +1 -0
  87. package/out/BeaconProxy.sol/BeaconProxy.json +1 -0
  88. package/out/BeaconProxyDeployer.sol/BeaconProxyDeployer.json +1 -0
  89. package/out/Bytes.sol/Bytes.json +1 -1
  90. package/out/Calldata.sol/Calldata.json +1 -0
  91. package/out/CapabilityModules.sol/AllTypesModule.json +1 -0
  92. package/out/CapabilityModules.sol/CappedRecipientModule.json +1 -0
  93. package/out/CapabilityModules.sol/DelegatedCapRuleModule.json +1 -0
  94. package/out/CapabilityModules.sol/DuplicateTypeModule.json +1 -0
  95. package/out/CapabilityModules.sol/LockedSenderModule.json +1 -0
  96. package/out/CapabilityModules.sol/NoTypeModule.json +1 -0
  97. package/out/CapabilityModules.sol/RecordingModule.json +1 -0
  98. package/out/CapabilityModules.sol/RuleAndMintTrackerModule.json +1 -0
  99. package/out/CapabilityModules.sol/RuleAndTrackerModule.json +1 -0
  100. package/out/CapabilityModules.sol/RuleOnlyModule.json +1 -0
  101. package/out/CapabilityModules.sol/SpenderOnlyModule.json +1 -0
  102. package/out/CapabilityModules.sol/TrackerOnlyModule.json +1 -0
  103. package/out/CapabilityModules.sol/UndeclaredRuleModule.json +1 -0
  104. package/out/CapabilityModules.sol/WritingRuleModule.json +1 -0
  105. package/out/ClaimIssuerAlwaysReverts.sol/ClaimIssuerAlwaysReverts.json +1 -0
  106. package/out/ClaimIssuerTrick.sol/ClaimIssuerTrick.json +1 -1
  107. package/out/Comparators.sol/Comparators.json +1 -1
  108. package/out/ComplianceLedger.sol/ComplianceLedger.json +1 -0
  109. package/out/ComplianceLedgerLib.sol/ComplianceLedgerLib.json +1 -0
  110. package/out/Context.sol/Context.json +1 -1
  111. package/out/ContextUpgradeable.sol/ContextUpgradeable.json +1 -1
  112. package/out/Countries.sol/Countries.json +1 -1
  113. package/out/Create2.sol/Create2.json +1 -1
  114. package/out/Create3.sol/Create3.json +1 -1
  115. package/out/DeployComplianceModules.s.sol/DeployComplianceModules.json +1 -0
  116. package/out/DeployComplianceModules.s.sol/ITokenCompliance.json +1 -0
  117. package/out/DeployUtilityChecker.s.sol/DeployUtilityChecker.json +1 -0
  118. package/out/ECDSA.sol/ECDSA.json +1 -1
  119. package/out/EIP712.sol/EIP712.json +1 -1
  120. package/out/EIP712Upgradeable.sol/EIP712Upgradeable.json +1 -1
  121. package/out/ERC165.sol/ERC165.json +1 -0
  122. package/out/ERC165Checker.sol/ERC165Checker.json +1 -0
  123. package/out/ERC165Upgradeable.sol/ERC165Upgradeable.json +1 -0
  124. package/out/ERC1967Proxy.sol/ERC1967Proxy.json +1 -1
  125. package/out/ERC1967Utils.sol/ERC1967Utils.json +1 -1
  126. package/out/ERC20.sol/ERC20.json +1 -1
  127. package/out/ERC20Pausable.sol/ERC20Pausable.json +1 -1
  128. package/out/ERC20PermitUpgradeable.sol/ERC20PermitUpgradeable.json +1 -1
  129. package/out/ERC20Upgradeable.sol/ERC20Upgradeable.json +1 -1
  130. package/out/ERC3643ClaimTopicsRegistry.sol/ERC3643ClaimTopicsRegistry.json +1 -0
  131. package/out/ERC3643Compliance.sol/ERC3643Compliance.json +1 -0
  132. package/out/ERC3643ErrorsLib.sol/ERC3643ErrorsLib.json +1 -0
  133. package/out/ERC3643IdentityRegistry.sol/ERC3643IdentityRegistry.json +1 -0
  134. package/out/ERC3643IdentityRegistryStorage.sol/ERC3643IdentityRegistryStorage.json +1 -0
  135. package/out/ERC3643Token.sol/ERC3643Token.json +1 -0
  136. package/out/ERC3643TrustedIssuersRegistry.sol/ERC3643TrustedIssuersRegistry.json +1 -0
  137. package/out/ERC4337Utils.sol/ERC4337Utils.json +1 -0
  138. package/out/ERC4337Utils.sol/IEntryPointExtra.json +1 -0
  139. package/out/ERC734Validator.sol/ERC734Validator.json +1 -0
  140. package/out/ERC7579Validator.sol/ERC7579Validator.json +1 -0
  141. package/out/ERC7786GatewayMock.sol/ERC7786GatewayMock.json +1 -0
  142. package/out/ERC7786Recipient.sol/ERC7786Recipient.json +1 -0
  143. package/out/ERC7913WebAuthnVerifier.sol/ERC7913WebAuthnVerifier.json +1 -0
  144. package/out/EnumerableSet.sol/EnumerableSet.json +1 -1
  145. package/out/Errors.sol/Errors.json +1 -1
  146. package/out/ErrorsLib.sol/ErrorsLib.json +1 -1
  147. package/out/EventsLib.sol/EventsLib.json +1 -1
  148. package/out/Hashes.sol/Hashes.json +1 -0
  149. package/out/HostileModules.sol/RevertEverywhereModule.json +1 -0
  150. package/out/HostileModules.sol/UnbindRevertingModule.json +1 -0
  151. package/out/IAccessManaged.sol/IAccessManaged.json +1 -0
  152. package/out/IAccessManager.sol/IAccessManager.json +1 -0
  153. package/out/IAuthority.sol/IAuthority.json +1 -0
  154. package/out/IBeacon.sol/IBeacon.json +1 -1
  155. package/out/IClaimIssuer.sol/IClaimIssuer.json +1 -1
  156. package/out/IComplianceLedger.sol/IComplianceLedger.json +1 -0
  157. package/out/IERC1271.sol/IERC1271.json +1 -0
  158. package/out/IERC165.sol/IERC165.json +1 -1
  159. package/out/IERC173.sol/IERC173.json +1 -1
  160. package/out/IERC1967.sol/IERC1967.json +1 -1
  161. package/out/IERC20.sol/IERC20.json +1 -1
  162. package/out/IERC20Metadata.sol/IERC20Metadata.json +1 -1
  163. package/out/IERC20Permit.sol/IERC20Permit.json +1 -1
  164. package/out/IERC3643.sol/IERC3643.json +1 -1
  165. package/out/IERC3643ClaimTopicsRegistry.sol/IERC3643ClaimTopicsRegistry.json +1 -1
  166. package/out/IERC3643Compliance.sol/IERC3643Compliance.json +1 -1
  167. package/out/IERC3643IdentityRegistry.sol/IERC3643IdentityRegistry.json +1 -1
  168. package/out/IERC3643IdentityRegistryStorage.sol/IERC3643IdentityRegistryStorage.json +1 -1
  169. package/out/IERC3643TrustedIssuersRegistry.sol/IERC3643TrustedIssuersRegistry.json +1 -1
  170. package/out/IERC4337.sol/IAccount.json +1 -0
  171. package/out/IERC4337.sol/IAccountExecute.json +1 -0
  172. package/out/IERC4337.sol/IAggregator.json +1 -0
  173. package/out/IERC4337.sol/IEntryPoint.json +1 -0
  174. package/out/IERC4337.sol/IEntryPointNonces.json +1 -0
  175. package/out/IERC4337.sol/IEntryPointStake.json +1 -0
  176. package/out/IERC4337.sol/IPaymaster.json +1 -0
  177. package/out/IERC5267.sol/IERC5267.json +1 -1
  178. package/out/IERC734.sol/IERC734.json +1 -1
  179. package/out/IERC735.sol/IERC735.json +1 -1
  180. package/out/IERC7913.sol/IERC7913SignatureVerifier.json +1 -0
  181. package/out/IIdentity.sol/IIdentity.json +1 -1
  182. package/out/IIdentityFactory.sol/IIdentityFactory.json +1 -0
  183. package/out/IIdentityRegistryStorage.sol/IIdentityRegistryStorage.json +1 -1
  184. package/out/IKeyExecutor.sol/IKeyExecutor.json +1 -0
  185. package/out/IModularCompliance.sol/IModularCompliance.json +1 -1
  186. package/out/IModule.sol/IModule.json +1 -1
  187. package/out/IMulticall3.sol/IMulticall3.json +1 -1
  188. package/out/IReputationRegistry.sol/IReputationRegistry.json +1 -0
  189. package/out/ISettlementHandler.sol/ISettlementHandler.json +1 -0
  190. package/out/ITREXFactory.sol/ITREXFactory.json +1 -1
  191. package/out/ITREXImplementationAuthority.sol/ITREXImplementationAuthority.json +1 -1
  192. package/out/ITREXMessaging.sol/ITREXMessaging.json +1 -0
  193. package/out/ITREXRegistry.sol/ITREXRegistry.json +1 -0
  194. package/out/IToken.sol/IToken.json +1 -1
  195. package/out/ITransferValidation.sol/ITransferValidation.json +1 -0
  196. package/out/ITrustedGatewayRegistry.sol/ITrustedGatewayRegistry.json +1 -0
  197. package/out/IUtilityChecker.sol/IUtilityChecker.json +1 -1
  198. package/out/Identity.sol/Identity.json +1 -1
  199. package/out/IdentityFactory.sol/IdentityFactory.json +1 -0
  200. package/out/IdentityModulesHelper.sol/IdentityModulesHelper.json +1 -0
  201. package/out/IdentityRegistryStorage.sol/IdentityRegistryStorage.json +1 -1
  202. package/out/IdentityTypes.sol/IdentityTypes.json +1 -0
  203. package/out/Initializable.sol/Initializable.json +1 -1
  204. package/out/InteropSuiteTest.sol/InteropSuiteTest.json +1 -0
  205. package/out/KeyApprovalModule.sol/IIdentityAccount.json +1 -0
  206. package/out/KeyApprovalModule.sol/KeyApprovalModule.json +1 -0
  207. package/out/KeyManager.sol/KeyManager.json +1 -0
  208. package/out/KeyPurposes.sol/KeyPurposes.json +1 -1
  209. package/out/KeyTypes.sol/KeyTypes.json +1 -1
  210. package/out/LowLevelCall.sol/LowLevelCall.json +1 -1
  211. package/out/Math.sol/Math.json +1 -1
  212. package/out/MaxBalancePerIdentityModule.sol/MaxBalancePerIdentityModule.json +1 -0
  213. package/out/MessageHashUtils.sol/MessageHashUtils.json +1 -1
  214. package/out/MessageTypesLib.sol/MessageTypesLib.json +1 -0
  215. package/out/MockTREXAccessManagerV2.sol/MockTREXAccessManagerV2.json +1 -0
  216. package/out/MockTokenV2.sol/MockTokenV2.json +1 -0
  217. package/out/Mocks.sol/ClaimTopicsRegistryMock.json +1 -0
  218. package/out/Mocks.sol/ComplianceMock.json +1 -0
  219. package/out/Mocks.sol/IdentityRegistryMock.json +1 -0
  220. package/out/Mocks.sol/IdentityRegistryStorageMock.json +1 -0
  221. package/out/Mocks.sol/TokenMock.json +1 -0
  222. package/out/Mocks.sol/TrustedIssuersRegistryMock.json +1 -0
  223. package/out/ModularCompliance.sol/ModularCompliance.json +1 -1
  224. package/out/ModuleNotPnP.sol/ModuleNotPnP.json +1 -1
  225. package/out/ModuleProxy.sol/ModuleProxy.json +1 -1
  226. package/out/ModuleSetLib.sol/ModuleSetLib.json +1 -0
  227. package/out/MovementKindLib.sol/MovementKindLib.json +1 -0
  228. package/out/Multicall.sol/Multicall.json +1 -0
  229. package/out/MulticallUpgradeable.sol/MulticallUpgradeable.json +1 -1
  230. package/out/Nonces.sol/Nonces.json +1 -1
  231. package/out/NoncesUpgradeable.sol/NoncesUpgradeable.json +1 -1
  232. package/out/Ownable.sol/Ownable.json +1 -1
  233. package/out/OwnableUpgradeable.sol/OwnableUpgradeable.json +1 -1
  234. package/out/P256.sol/P256.json +1 -0
  235. package/out/Packing.sol/Packing.json +1 -0
  236. package/out/Panic.sol/Panic.json +1 -1
  237. package/out/Pausable.sol/Pausable.json +1 -1
  238. package/out/PausableUpgradeable.sol/PausableUpgradeable.json +1 -1
  239. package/out/Proxy.sol/Proxy.json +1 -1
  240. package/out/ReentrancyGuardTransient.sol/ReentrancyGuardTransient.json +1 -0
  241. package/out/ReentrantModule.sol/ReentrantModule.json +1 -0
  242. package/out/ReputationRegistry.sol/ReputationRegistry.json +1 -0
  243. package/out/RolesLib.sol/RolesLib.json +1 -0
  244. package/out/SafeCalldataBatch.sol/SafeCalldataBatch.json +1 -0
  245. package/out/SafeCast.sol/SafeCast.json +1 -1
  246. package/out/SatelliteLiteMock.sol/SatelliteLiteMock.json +1 -0
  247. package/out/Script.sol/Script.json +1 -0
  248. package/out/ShortStrings.sol/ShortStrings.json +1 -1
  249. package/out/SignatureChecker.sol/SignatureChecker.json +1 -0
  250. package/out/SignedMath.sol/SignedMath.json +1 -1
  251. package/out/SlotDerivation.sol/SlotDerivation.json +1 -1
  252. package/out/SmartAccount.sol/SmartAccount.json +1 -0
  253. package/out/SpenderVerificationModule.sol/SpenderVerificationModule.json +1 -0
  254. package/out/SpenderWhitelistModule.sol/SpenderWhitelistModule.json +1 -0
  255. package/out/StdAssertions.sol/StdAssertions.json +1 -1
  256. package/out/StdChains.sol/StdChains.json +1 -1
  257. package/out/StdCheats.sol/StdCheats.json +1 -1
  258. package/out/StdCheats.sol/StdCheatsSafe.json +1 -1
  259. package/out/StdConstants.sol/StdConstants.json +1 -1
  260. package/out/StdError.sol/stdError.json +1 -1
  261. package/out/StdInvariant.sol/StdInvariant.json +1 -1
  262. package/out/StdJson.sol/stdJson.json +1 -1
  263. package/out/StdMath.sol/stdMath.json +1 -1
  264. package/out/StdStorage.sol/stdStorage.json +1 -1
  265. package/out/StdStorage.sol/stdStorageSafe.json +1 -1
  266. package/out/StdStyle.sol/StdStyle.json +1 -1
  267. package/out/StdToml.sol/stdToml.json +1 -1
  268. package/out/StdUtils.sol/StdUtils.json +1 -1
  269. package/out/StorageSlot.sol/StorageSlot.json +1 -1
  270. package/out/Strings.sol/Strings.json +1 -1
  271. package/out/Structs.sol/Structs.json +1 -1
  272. package/out/TREXAccessManager.sol/TREXAccessManager.json +1 -0
  273. package/out/TREXFactory.sol/TREXFactory.json +1 -1
  274. package/out/TREXImplementationAuthority.sol/TREXImplementationAuthority.json +1 -1
  275. package/out/TREXMessaging.sol/TREXMessaging.json +1 -0
  276. package/out/TREXMessagingLib.sol/TREXMessagingLib.json +1 -0
  277. package/out/TREXRegistry.sol/TREXRegistry.json +1 -0
  278. package/out/TestERC20.sol/TestERC20.json +1 -1
  279. package/out/TestModule.sol/TestModule.json +1 -1
  280. package/out/TestTREXFactory.sol/TestTREXFactory.json +1 -1
  281. package/out/Time.sol/Time.json +1 -0
  282. package/out/Token.sol/Token.json +1 -1
  283. package/out/TokenDelegationLib.sol/TokenDelegationLib.json +1 -0
  284. package/out/TokenGuardsLib.sol/TokenGuardsLib.json +1 -0
  285. package/out/TokenHandler.sol/TokenHandler.json +1 -0
  286. package/out/TokenLedgerHarness.sol/TokenLedgerHarness.json +1 -0
  287. package/out/TokenLedgerLib.sol/TokenLedgerLib.json +1 -0
  288. package/out/TokenRecoveryLib.sol/TokenRecoveryLib.json +1 -0
  289. package/out/TokenReservationStub.sol/TokenReservationStub.json +1 -0
  290. package/out/TransferContextLib.sol/TransferContextLib.json +1 -0
  291. package/out/TransferValidation.sol/TransferValidation.json +1 -0
  292. package/out/TransferValidationHarness.sol/TransferValidationHarness.json +1 -0
  293. package/out/TransferValidationLib.sol/TransferValidationLib.json +1 -0
  294. package/out/TransientSlot.sol/TransientSlot.json +1 -0
  295. package/out/TrustedGatewayRegistry.sol/TrustedGatewayRegistry.json +1 -0
  296. package/out/UUPSUpgradeable.sol/UUPSUpgradeable.json +1 -1
  297. package/out/UpgradeableBeacon.sol/UpgradeableBeacon.json +1 -0
  298. package/out/UtilityChecker.sol/UtilityChecker.json +1 -1
  299. package/out/UtilityCheckerProxy.sol/UtilityCheckerProxy.json +1 -1
  300. package/out/Utils.sol/Utils.json +1 -1
  301. package/out/VersionLib.sol/VersionLib.json +1 -0
  302. package/out/Vm.sol/Vm.json +1 -1
  303. package/out/Vm.sol/VmSafe.json +1 -1
  304. package/out/WalletKeyLib.sol/WalletKeyLib.json +1 -0
  305. package/out/WebAuthn.sol/WebAuthn.json +1 -0
  306. package/out/console.sol/console.json +1 -1
  307. package/out/draft-AccountERC7579Upgradeable.sol/AccountERC7579Upgradeable.json +1 -0
  308. package/out/draft-ERC7579Utils.sol/ERC7579Utils.json +1 -0
  309. package/out/draft-IERC1822.sol/IERC1822Proxiable.json +1 -1
  310. package/out/draft-IERC6093.sol/IERC1155Errors.json +1 -1
  311. package/out/draft-IERC6093.sol/IERC20Errors.json +1 -1
  312. package/out/draft-IERC6093.sol/IERC721Errors.json +1 -1
  313. package/out/draft-IERC7579.sol/IERC7579AccountConfig.json +1 -0
  314. package/out/draft-IERC7579.sol/IERC7579Execution.json +1 -0
  315. package/out/draft-IERC7579.sol/IERC7579Hook.json +1 -0
  316. package/out/draft-IERC7579.sol/IERC7579Module.json +1 -0
  317. package/out/draft-IERC7579.sol/IERC7579ModuleConfig.json +1 -0
  318. package/out/draft-IERC7579.sol/IERC7579Validator.json +1 -0
  319. package/out/draft-IERC7786.sol/IERC7786GatewaySource.json +1 -0
  320. package/out/draft-IERC7786.sol/IERC7786Recipient.json +1 -0
  321. package/out/draft-InteroperableAddress.sol/InteroperableAddress.json +1 -0
  322. package/out/libraries/Errors.sol/Errors.json +1 -1
  323. package/out/safeconsole.sol/safeconsole.json +1 -1
  324. package/package.json +14 -11
  325. package/contracts/ERC-3643/ERC3643EventsLib.sol +0 -150
  326. package/contracts/factory/ITREXGateway.sol +0 -234
  327. package/contracts/factory/TREXGateway.sol +0 -274
  328. package/contracts/proxy/AbstractProxy.sol +0 -146
  329. package/contracts/proxy/ClaimTopicsRegistryProxy.sol +0 -83
  330. package/contracts/proxy/IdentityRegistryProxy.sol +0 -95
  331. package/contracts/proxy/TokenProxy.sol +0 -97
  332. package/contracts/proxy/authority/IAFactory.sol +0 -122
  333. package/contracts/proxy/authority/IIAFactory.sol +0 -87
  334. package/contracts/proxy/authority/ITREXImplementationAuthority.sol +0 -239
  335. package/contracts/proxy/authority/TREXImplementationAuthority.sol +0 -350
  336. package/contracts/registry/implementation/ClaimTopicsRegistry.sol +0 -152
  337. package/contracts/registry/implementation/IdentityRegistry.sol +0 -352
  338. package/contracts/registry/implementation/TrustedIssuersRegistry.sol +0 -272
  339. package/contracts/registry/interface/IClaimTopicsRegistry.sol +0 -70
  340. package/contracts/registry/interface/IIdentityRegistry.sol +0 -102
  341. package/contracts/registry/interface/ITrustedIssuersRegistry.sol +0 -70
  342. package/contracts/roles/IERC173.sol +0 -21
  343. package/contracts/token/TokenStructs.sol +0 -74
  344. package/contracts/utils/InterfaceIdCalculator.sol +0 -223
  345. package/contracts/vendor/openzeppelin/Create3.sol +0 -143
  346. package/out/AbstractAgentRole.sol/AbstractAgentRole.json +0 -1
  347. package/out/AbstractProxy.sol/AbstractProxy.json +0 -1
  348. package/out/AgentRole.sol/AgentRole.json +0 -1
  349. package/out/AgentRoleUpgradeable.sol/AgentRoleUpgradeable.json +0 -1
  350. package/out/ClaimIssuer.sol/ClaimIssuer.json +0 -1
  351. package/out/ClaimTopicsRegistry.sol/ClaimTopicsRegistry.json +0 -1
  352. package/out/ClaimTopicsRegistryProxy.sol/ClaimTopicsRegistryProxy.json +0 -1
  353. package/out/ERC2771Context.sol/ERC2771Context.json +0 -1
  354. package/out/ERC2771ContextUpgradeable.sol/ERC2771ContextUpgradeable.json +0 -1
  355. package/out/ERC2771Forwarder.sol/ERC2771Forwarder.json +0 -1
  356. package/out/ERC3643EventsLib.sol/ERC3643EventsLib.json +0 -1
  357. package/out/IAFactory.sol/IAFactory.json +0 -1
  358. package/out/IClaimTopicsRegistry.sol/IClaimTopicsRegistry.json +0 -1
  359. package/out/IERC1363.sol/IERC1363.json +0 -1
  360. package/out/IIAFactory.sol/IIAFactory.json +0 -1
  361. package/out/IIdFactory.sol/IIdFactory.json +0 -1
  362. package/out/IIdentityRegistry.sol/IIdentityRegistry.json +0 -1
  363. package/out/IImplementationAuthority.sol/IImplementationAuthority.json +0 -1
  364. package/out/IProxy.sol/IProxy.json +0 -1
  365. package/out/ITREXGateway.sol/ITREXGateway.json +0 -1
  366. package/out/ITrustedIssuersRegistry.sol/ITrustedIssuersRegistry.json +0 -1
  367. package/out/IdFactory.sol/IdFactory.json +0 -1
  368. package/out/IdentityProxy.sol/IdentityProxy.json +0 -1
  369. package/out/IdentityRegistry.sol/IdentityRegistry.json +0 -1
  370. package/out/IdentityRegistryProxy.sol/IdentityRegistryProxy.json +0 -1
  371. package/out/IdentityRegistryStorageProxy.sol/IdentityRegistryStorageProxy.json +0 -1
  372. package/out/ImplementationAuthority.sol/ImplementationAuthority.json +0 -1
  373. package/out/InterfaceIdCalculator.sol/InterfaceIdCalculator.json +0 -1
  374. package/out/ModularComplianceProxy.sol/ModularComplianceProxy.json +0 -1
  375. package/out/Ownable2Step.sol/Ownable2Step.json +0 -1
  376. package/out/Ownable2StepUpgradeable.sol/Ownable2StepUpgradeable.json +0 -1
  377. package/out/Roles.sol/Roles.json +0 -1
  378. package/out/SafeERC20.sol/SafeERC20.json +0 -1
  379. package/out/Storage.sol/Storage.json +0 -1
  380. package/out/TREXGateway.sol/TREXGateway.json +0 -1
  381. package/out/TestAgentRole.sol/TestAgentRole.json +0 -1
  382. package/out/TestAgentRoleUpgradeable.sol/TestAgentRoleUpgradeable.json +0 -1
  383. package/out/TokenProxy.sol/TokenProxy.json +0 -1
  384. package/out/TrustedIssuersRegistry.sol/TrustedIssuersRegistry.json +0 -1
  385. package/out/TrustedIssuersRegistryProxy.sol/TrustedIssuersRegistryProxy.json +0 -1
  386. package/out/Version.sol/Version.json +0 -1
@@ -36,191 +36,243 @@
36
36
  // +@@@@%-
37
37
  // :#%%=
38
38
  //
39
- /**
40
- * NOTICE
41
- *
42
- * The T-REX software is licensed under a proprietary license or the GPL v.3.
43
- * If you choose to receive it under the GPL v.3 license, the following applies:
44
- * T-REX is a suite of smart contracts implementing the ERC-3643 standard and
45
- * developed by Tokeny to manage and transfer financial assets on EVM blockchains
46
- *
47
- * Copyright (C) 2025, Tokeny sàrl.
48
- *
49
- * This program is free software: you can redistribute it and/or modify
50
- * it under the terms of the GNU General Public License as published by
51
- * the Free Software Foundation, either version 3 of the License, or
52
- * (at your option) any later version.
53
- *
54
- * This program is distributed in the hope that it will be useful,
55
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
56
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57
- * GNU General Public License for more details.
58
- *
59
- * You should have received a copy of the GNU General Public License
60
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
61
- */
39
+
40
+ // T-REX Smart Contracts
41
+ // The ERC-3643 token suite of the T-REX ecosystem.
42
+ //
43
+ // Copyright (C) 2026 Digital Asset Operational Services ISAC Ltd. ("T-REX Network")
44
+ //
45
+ // This file is part of the T-REX smart contract suite.
46
+ //
47
+ // This program is free software: you can redistribute it and/or modify
48
+ // it under the terms of the GNU General Public License as published by
49
+ // the Free Software Foundation, either version 3 of the License, or
50
+ // (at your option) any later version.
51
+ //
52
+ // This program is distributed in the hope that it will be useful,
53
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
54
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
55
+ // GNU General Public License for more details.
56
+ //
57
+ // You should have received a copy of the GNU General Public License
58
+ // along with this program. If not, see <https://www.gnu.org/licenses/>.
62
59
 
63
60
  pragma solidity 0.8.30;
64
61
 
62
+ import { IIdentityFactory } from "@onchain-id/solidity/contracts/factory/IIdentityFactory.sol";
65
63
  import { IIdentity } from "@onchain-id/solidity/contracts/interface/IIdentity.sol";
66
- import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
67
- import { EnumerableSet } from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
64
+ import { InteroperableAddress } from "@openzeppelin/contracts/utils/draft-InteroperableAddress.sol";
68
65
 
69
- import { ERC3643EventsLib } from "../../ERC-3643/ERC3643EventsLib.sol";
66
+ import { IERC3643IdentityRegistryStorage } from "../../ERC-3643/IERC3643IdentityRegistryStorage.sol";
67
+ import { ERC3643IdentityRegistryStorage } from "../../ERC-3643/base/ERC3643IdentityRegistryStorage.sol";
70
68
  import { ErrorsLib } from "../../libraries/ErrorsLib.sol";
71
- import { AgentRoleUpgradeable } from "../../roles/AgentRoleUpgradeable.sol";
72
- import { IERC173 } from "../../roles/IERC173.sol";
73
- import { IERC3643IdentityRegistryStorage, IIdentityRegistryStorage } from "../interface/IIdentityRegistryStorage.sol";
74
-
75
- contract IdentityRegistryStorage is IIdentityRegistryStorage, AgentRoleUpgradeable, IERC165 {
69
+ import { EventsLib } from "../../libraries/EventsLib.sol";
70
+ import { AccessManagedOwnableUpgradeable } from "../../utils/AccessManagedOwnableUpgradeable.sol";
71
+ import { IIdentityRegistryStorage } from "../interface/IIdentityRegistryStorage.sol";
72
+ import { ITREXRegistry } from "../interface/ITREXRegistry.sol";
76
73
 
77
- using EnumerableSet for EnumerableSet.AddressSet;
74
+ /// @title IdentityRegistryStorage
75
+ /// @notice Local wallet-to-identity bindings shared by the registries bound to it, which all resolve through one
76
+ /// IdentityFactory. It holds only its own bindings: a wallet it does not bind resolves, in each registry, through
77
+ /// that registry's IdentityFactory.
78
+ /// @dev {ERC3643IdentityRegistryStorage} plus AccessManager authorization, the `onlySharedAuthority` guard on
79
+ /// binding, sticky bindings, revocation and ERC-165.
80
+ contract IdentityRegistryStorage is
81
+ IIdentityRegistryStorage,
82
+ ERC3643IdentityRegistryStorage,
83
+ AccessManagedOwnableUpgradeable
84
+ {
78
85
 
79
- /// @dev struct containing the identity contract and the country of the user
80
- struct Identity {
81
- IIdentity identityContract;
82
- uint16 investorCountry;
86
+ /// @custom:storage-location erc7201:erc3643.storage.TREXIdentityRegistryStorage
87
+ struct Storage {
88
+ /// @dev The status of each local wallet. Only `Revoked` is written. A wallet with no entry is `Active`
89
+ /// when it has a stored identity, and `None` otherwise.
90
+ mapping(address wallet => IIdentityFactory.AccountStatus) accountStatus;
91
+ /// @dev The IdentityFactory every bound registry resolves through. Set at `init` and never changed, so
92
+ /// unbinding registries can never lift the check on a write or let a registry on another factory in.
93
+ IIdentityFactory identityFactory;
83
94
  }
84
95
 
85
- /// @custom:storage-location erc7201:ERC3643.storage.IdentityRegistryStorage
86
- struct Storage {
87
- /// @dev mapping between a user address and the corresponding identity
88
- mapping(address user => Identity) identities;
96
+ // keccak256(abi.encode(uint256(keccak256("erc3643.storage.TREXIdentityRegistryStorage")) - 1)) & ~bytes32(uint256(0xff));
97
+ bytes32 private constant STORAGE_LOCATION = 0xcb64a18d0bc273a26dd2f33432c876864881ae0a84f136720d41c3286c288f00;
89
98
 
90
- /// @dev set of Identity Registries linked to this storage
91
- EnumerableSet.AddressSet identityRegistries;
99
+ /// @notice Upper bound on the registries bound to this storage. It caps the cost of enumerating them.
100
+ function MAX_BOUND_REGISTRIES() external pure returns (uint256) {
101
+ return MAX_IDENTITY_REGISTRIES;
92
102
  }
93
103
 
94
- // keccak256(abi.encode(uint256(keccak256("ERC3643.storage.IdentityRegistryStorage")) - 1)) & ~bytes32(uint256(0xff));
95
- bytes32 private constant STORAGE_LOCATION = 0x6d25db4721129739b3a7e96c2537b7170fb9cfd72348ce376c7a189a3ab3ba00;
96
-
97
104
  constructor() {
98
105
  _disableInitializers();
99
106
  }
100
107
 
101
- function init(address _owner, address _initialIR) external initializer {
102
- __Ownable_init(_owner);
103
- if (_initialIR != address(0)) {
104
- _bindIdentityRegistry(_initialIR);
108
+ /// @dev The initial registry is bound without asking it for its factory: the TREXFactory passes the registry's
109
+ /// predicted address, which has no code yet.
110
+ function init(address accessManagerAddress, address initialIRAddress, address identityFactoryAddress)
111
+ external
112
+ initializer
113
+ {
114
+ require(accessManagerAddress != address(0), ErrorsLib.ZeroAddress());
115
+ require(identityFactoryAddress != address(0), ErrorsLib.ZeroAddress());
116
+ __AccessManaged_init(accessManagerAddress);
117
+ _getStorage().identityFactory = IIdentityFactory(identityFactoryAddress);
118
+
119
+ if (initialIRAddress != address(0)) {
120
+ _bindIdentityRegistry(initialIRAddress);
105
121
  }
106
122
  }
107
123
 
108
- /**
109
- * @dev See {IIdentityRegistryStorage-addIdentityToStorage}.
110
- */
111
- function addIdentityToStorage(address _userAddress, IIdentity _identity, uint16 _country)
124
+ /// @inheritdoc IERC3643IdentityRegistryStorage
125
+ /// @dev DEPRECATED: this storage keeps no country; always reverts. The country is a compliance
126
+ /// concern, owned by the country module bound to the token's `ModularCompliance`.
127
+ function modifyStoredInvestorCountry(address, uint16)
128
+ external
129
+ pure
130
+ override(ERC3643IdentityRegistryStorage, IERC3643IdentityRegistryStorage)
131
+ {
132
+ revert ErrorsLib.Deprecated();
133
+ }
134
+
135
+ /// @inheritdoc IERC3643IdentityRegistryStorage
136
+ /// @dev `onlySharedAuthority` is a misconfiguration guard only: `authority()` is spoofable.
137
+ /// Every registry bound here must resolve through the same IdentityFactory. A registry checks a new local
138
+ /// binding against its own factory only, so on a storage shared across factories one registry's agent could
139
+ /// bind a wallet that another registry's factory links to another identity, and change who owns that
140
+ /// wallet's tokens in the other registry.
141
+ function bindIdentityRegistry(address identityRegistry)
142
+ external
143
+ override(ERC3643IdentityRegistryStorage, IERC3643IdentityRegistryStorage)
144
+ restricted
145
+ onlySharedAuthority(identityRegistry)
146
+ {
147
+ IIdentityFactory storageFactory = _getStorage().identityFactory;
148
+ IIdentityFactory registryFactory = ITREXRegistry(identityRegistry).identityFactory();
149
+ require(
150
+ registryFactory == storageFactory,
151
+ ErrorsLib.IdentityFactoryMismatch(address(storageFactory), address(registryFactory))
152
+ );
153
+ _bindIdentityRegistry(identityRegistry);
154
+ }
155
+
156
+ /// @inheritdoc IERC3643IdentityRegistryStorage
157
+ function unbindIdentityRegistry(address _identityRegistry)
158
+ external
159
+ override(ERC3643IdentityRegistryStorage, IERC3643IdentityRegistryStorage)
160
+ restricted
161
+ {
162
+ _unbindIdentityRegistry(_identityRegistry);
163
+ }
164
+
165
+ /// @inheritdoc IERC3643IdentityRegistryStorage
166
+ /// @dev DEPRECATED: this storage keeps no country; always returns 0. Read the country from the
167
+ /// country module bound to the token's `ModularCompliance`.
168
+ function storedInvestorCountry(address)
112
169
  external
113
- override
114
- onlyAgent
170
+ pure
171
+ override(ERC3643IdentityRegistryStorage, IERC3643IdentityRegistryStorage)
172
+ returns (uint16)
115
173
  {
116
- require(_userAddress != address(0) && address(_identity) != address(0), ErrorsLib.ZeroAddress());
117
-
118
- Storage storage s = _getStorage();
119
- require(address(s.identities[_userAddress].identityContract) == address(0), ErrorsLib.AddressAlreadyStored());
120
- s.identities[_userAddress].identityContract = _identity;
121
- s.identities[_userAddress].investorCountry = _country;
122
- emit ERC3643EventsLib.IdentityStored(_userAddress, _identity);
123
- }
124
-
125
- /**
126
- * @dev See {IIdentityRegistryStorage-modifyStoredIdentity}.
127
- */
128
- function modifyStoredIdentity(address _userAddress, IIdentity _identity) external override onlyAgent {
129
- require(_userAddress != address(0) && address(_identity) != address(0), ErrorsLib.ZeroAddress());
130
- Storage storage s = _getStorage();
131
- require(address(s.identities[_userAddress].identityContract) != address(0), ErrorsLib.AddressNotYetStored());
132
- IIdentity oldIdentity = s.identities[_userAddress].identityContract;
133
- s.identities[_userAddress].identityContract = _identity;
134
- emit ERC3643EventsLib.IdentityModified(oldIdentity, _identity);
135
- }
136
-
137
- /**
138
- * @dev See {IIdentityRegistryStorage-modifyStoredInvestorCountry}.
139
- */
140
- function modifyStoredInvestorCountry(address _userAddress, uint16 _country) external override onlyAgent {
141
- require(_userAddress != address(0), ErrorsLib.ZeroAddress());
142
- Storage storage s = _getStorage();
143
- require(address(s.identities[_userAddress].identityContract) != address(0), ErrorsLib.AddressNotYetStored());
144
- s.identities[_userAddress].investorCountry = _country;
145
- emit ERC3643EventsLib.CountryModified(_userAddress, _country);
146
- }
147
-
148
- /**
149
- * @dev See {IIdentityRegistryStorage-removeIdentityFromStorage}.
150
- */
151
- function removeIdentityFromStorage(address _userAddress) external override onlyAgent {
152
- require(_userAddress != address(0), ErrorsLib.ZeroAddress());
153
- Storage storage s = _getStorage();
154
- require(address(s.identities[_userAddress].identityContract) != address(0), ErrorsLib.AddressNotYetStored());
155
- IIdentity oldIdentity = s.identities[_userAddress].identityContract;
156
- delete s.identities[_userAddress];
157
- emit ERC3643EventsLib.IdentityUnstored(_userAddress, oldIdentity);
158
- }
159
-
160
- /**
161
- * @dev See {IIdentityRegistryStorage-bindIdentityRegistry}.
162
- */
163
- function bindIdentityRegistry(address _identityRegistry) external override onlyOwner {
164
- _bindIdentityRegistry(_identityRegistry);
165
- }
166
-
167
- /**
168
- * @dev See {IIdentityRegistryStorage-unbindIdentityRegistry}.
169
- */
170
- function unbindIdentityRegistry(address _identityRegistry) external override onlyOwner {
171
- require(_identityRegistry != address(0), ErrorsLib.ZeroAddress());
172
- Storage storage s = _getStorage();
173
- require(s.identityRegistries.length() > 0, ErrorsLib.IdentityRegistryNotStored());
174
- s.identityRegistries.remove(_identityRegistry);
175
-
176
- removeAgent(_identityRegistry);
177
- emit ERC3643EventsLib.IdentityRegistryUnbound(_identityRegistry);
178
- }
179
-
180
- /**
181
- * @dev See {IIdentityRegistryStorage-linkedIdentityRegistries}.
182
- */
183
- function linkedIdentityRegistries() external view override returns (address[] memory) {
184
- return _getStorage().identityRegistries.values();
185
- }
186
-
187
- /**
188
- * @dev See {IIdentityRegistryStorage-storedIdentity}.
189
- */
190
- function storedIdentity(address _userAddress) external view override returns (IIdentity) {
191
- return _getStorage().identities[_userAddress].identityContract;
192
- }
193
-
194
- /**
195
- * @dev See {IIdentityRegistryStorage-storedInvestorCountry}.
196
- */
197
- function storedInvestorCountry(address _userAddress) external view override returns (uint16) {
198
- return _getStorage().identities[_userAddress].investorCountry;
199
- }
200
-
201
- /**
202
- * @dev See {IERC165-supportsInterface}.
203
- */
204
- function supportsInterface(bytes4 interfaceId) public pure virtual override returns (bool) {
205
- return interfaceId == type(IERC3643IdentityRegistryStorage).interfaceId
206
- || interfaceId == type(IERC173).interfaceId || interfaceId == type(IERC165).interfaceId;
207
- }
208
-
209
- /// @dev Internal helper shared between the public `bindIdentityRegistry` (gated by `onlyOwner`) and the
210
- /// `init` flow where the factory pre-binds the identity registry it predicted via CREATE3.
211
- function _bindIdentityRegistry(address _identityRegistry) internal {
212
- require(_identityRegistry != address(0), ErrorsLib.ZeroAddress());
213
- Storage storage s = _getStorage();
214
- require(s.identityRegistries.length() < 300, ErrorsLib.MaxIRByIRSReached(300));
215
- _addAgent(_identityRegistry);
216
- s.identityRegistries.add(_identityRegistry);
217
- emit ERC3643EventsLib.IdentityRegistryBound(_identityRegistry);
218
- }
219
-
220
- function _getStorage() internal pure returns (Storage storage s) {
221
- // solhint-disable-next-line no-inline-assembly
222
- assembly {
223
- s.slot := STORAGE_LOCATION
174
+ return 0;
175
+ }
176
+
177
+ /// @inheritdoc IIdentityRegistryStorage
178
+ function localAccountStatus(address userAddress) external view override returns (IIdentityFactory.AccountStatus) {
179
+ return _localAccountStatus(userAddress);
180
+ }
181
+
182
+ /// @inheritdoc IIdentityRegistryStorage
183
+ function isIdentityRegistryBound(address identityRegistry) external view override returns (bool) {
184
+ return _isIdentityRegistryBound(identityRegistry);
185
+ }
186
+
187
+ /// @dev See {IERC165-supportsInterface}.
188
+ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
189
+ return interfaceId == type(IERC3643IdentityRegistryStorage).interfaceId || super.supportsInterface(interfaceId);
190
+ }
191
+
192
+ /// @dev A wallet may be bound only to the identity the storage's IdentityFactory gives it, if that factory knows
193
+ /// it. The check sits in the storage so it holds for every holder of the writer role, not only
194
+ /// for a bound registry. The country is ignored, since this storage keeps none.
195
+ function _addIdentityToStorage(address userAddress, IIdentity userIdentity, uint16) internal override {
196
+ require(
197
+ _getStorage().accountStatus[userAddress] != IIdentityFactory.AccountStatus.Revoked,
198
+ ErrorsLib.WalletAlreadyRevoked(userAddress)
199
+ );
200
+ address factoryIdentity = _factoryIdentityOf(userAddress);
201
+ bool factoryKnowsTheWallet = factoryIdentity != address(0);
202
+ bool factoryAgrees = factoryIdentity == address(userIdentity);
203
+ require(
204
+ !factoryKnowsTheWallet || factoryAgrees,
205
+ ErrorsLib.WalletBoundToAnotherIdentity(userAddress, factoryIdentity)
206
+ );
207
+ super._addIdentityToStorage(userAddress, userIdentity, 0);
208
+ }
209
+
210
+ /// @dev Always reverts, because a wallet never changes identity. To move an investor to a new identity,
211
+ /// register a wallet of that identity and force transfer to it.
212
+ function _modifyStoredIdentity(address userAddress, IIdentity userIdentity) internal view override {
213
+ IIdentity boundIdentity = _storedIdentity(userAddress);
214
+ require(address(boundIdentity) != address(0), ErrorsLib.AddressNotYetStored());
215
+ require(
216
+ _getStorage().accountStatus[userAddress] != IIdentityFactory.AccountStatus.Revoked,
217
+ ErrorsLib.WalletAlreadyRevoked(userAddress)
218
+ );
219
+ require(boundIdentity != userIdentity, ErrorsLib.WalletAlreadyLinkedToIdentity(userAddress));
220
+ revert ErrorsLib.WalletBoundToAnotherIdentity(userAddress, address(boundIdentity));
221
+ }
222
+
223
+ /// @dev Revokes the wallet, like the IdentityFactory's `revokeAccount`. The wallet keeps its identity, but
224
+ /// `isVerified` returns false and it can never be bound again. Emits `IdentityRevoked`, not the standard
225
+ /// `IdentityUnstored`, since the wallet stays in the registry.
226
+ function _removeIdentityFromStorage(address userAddress) internal override {
227
+ require(userAddress != address(0), ErrorsLib.ZeroAddress());
228
+ IIdentity boundIdentity = _storedIdentity(userAddress);
229
+ require(address(boundIdentity) != address(0), ErrorsLib.AddressNotYetStored());
230
+ require(
231
+ _localAccountStatus(userAddress) == IIdentityFactory.AccountStatus.Active,
232
+ ErrorsLib.WalletNotActive(userAddress)
233
+ );
234
+
235
+ _getStorage().accountStatus[userAddress] = IIdentityFactory.AccountStatus.Revoked;
236
+ emit EventsLib.IdentityRevoked(userAddress, boundIdentity);
237
+ }
238
+
239
+ /// @dev T-REX keeps no country here, so nothing is written and no `CountryModified` is emitted. The
240
+ /// country is a compliance concern, owned by the country module bound to the token's
241
+ /// `ModularCompliance`. The public country setter reverts; this only silences the internal path
242
+ /// `addIdentityToStorage` takes.
243
+ function _setStoredInvestorCountry(address, uint16) internal override { }
244
+
245
+ /// @dev T-REX authorization for the identity-writing functions: the configured AccessManager role.
246
+ function _authorizeIdentityWrite() internal override {
247
+ _checkCanCall(_msgSender(), _msgData());
248
+ }
249
+
250
+ /// @dev Binding is authorized by the two dedicated external overrides above, which apply `restricted`
251
+ /// and `onlySharedAuthority` directly. This hook is therefore never the sole gate on the public path;
252
+ /// it exists so any future internal caller still passes through the role check.
253
+ function _authorizeRegistryBinding(address) internal override {
254
+ _checkCanCall(_msgSender(), _msgData());
255
+ }
256
+
257
+ /// @dev The identity the storage's IdentityFactory links the wallet to, revoked or not. Zero when the factory
258
+ /// does not know the wallet.
259
+ function _factoryIdentityOf(address userAddress) private view returns (address factoryIdentity) {
260
+ bytes memory account = InteroperableAddress.formatEvmV1(block.chainid, userAddress);
261
+ (factoryIdentity,) = _getStorage().identityFactory.getIdentityIncludingRevoked(account);
262
+ }
263
+
264
+ /// @dev The status of a local wallet, as described on `Storage.accountStatus`.
265
+ function _localAccountStatus(address userAddress) private view returns (IIdentityFactory.AccountStatus) {
266
+ if (_getStorage().accountStatus[userAddress] == IIdentityFactory.AccountStatus.Revoked) {
267
+ return IIdentityFactory.AccountStatus.Revoked;
268
+ }
269
+ if (address(_storedIdentity(userAddress)) == address(0)) return IIdentityFactory.AccountStatus.None;
270
+ return IIdentityFactory.AccountStatus.Active;
271
+ }
272
+
273
+ function _getStorage() private pure returns (Storage storage store) {
274
+ assembly ("memory-safe") {
275
+ store.slot := STORAGE_LOCATION
224
276
  }
225
277
  }
226
278