@t-rex-network/t-rex 4.2.0-beta1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (208) hide show
  1. package/LICENSE.md +674 -0
  2. package/README.md +137 -0
  3. package/contracts/ERC-3643/ERC3643EventsLib.sol +150 -0
  4. package/contracts/ERC-3643/IERC3643.sol +408 -0
  5. package/contracts/ERC-3643/IERC3643ClaimTopicsRegistry.sol +66 -0
  6. package/contracts/ERC-3643/IERC3643Compliance.sol +127 -0
  7. package/contracts/ERC-3643/IERC3643IdentityRegistry.sol +180 -0
  8. package/contracts/ERC-3643/IERC3643IdentityRegistryStorage.sol +120 -0
  9. package/contracts/ERC-3643/IERC3643TrustedIssuersRegistry.sol +120 -0
  10. package/contracts/compliance/modular/IModularCompliance.sol +143 -0
  11. package/contracts/compliance/modular/ModularCompliance.sol +381 -0
  12. package/contracts/compliance/modular/modules/AbstractModuleUpgradeable.sol +193 -0
  13. package/contracts/compliance/modular/modules/IModule.sol +158 -0
  14. package/contracts/compliance/modular/modules/ModuleProxy.sol +72 -0
  15. package/contracts/factory/ITREXFactory.sol +180 -0
  16. package/contracts/factory/ITREXGateway.sol +234 -0
  17. package/contracts/factory/TREXFactory.sol +358 -0
  18. package/contracts/factory/TREXGateway.sol +274 -0
  19. package/contracts/libraries/ErrorsLib.sol +168 -0
  20. package/contracts/libraries/EventsLib.sol +147 -0
  21. package/contracts/proxy/AbstractProxy.sol +146 -0
  22. package/contracts/proxy/ClaimTopicsRegistryProxy.sol +83 -0
  23. package/contracts/proxy/IdentityRegistryProxy.sol +95 -0
  24. package/contracts/proxy/IdentityRegistryStorageProxy.sol +83 -0
  25. package/contracts/proxy/ModularComplianceProxy.sol +88 -0
  26. package/contracts/proxy/TokenProxy.sol +97 -0
  27. package/contracts/proxy/TrustedIssuersRegistryProxy.sol +88 -0
  28. package/contracts/proxy/authority/IAFactory.sol +122 -0
  29. package/contracts/proxy/authority/IIAFactory.sol +87 -0
  30. package/contracts/proxy/authority/ITREXImplementationAuthority.sol +239 -0
  31. package/contracts/proxy/authority/TREXImplementationAuthority.sol +350 -0
  32. package/contracts/proxy/interface/IProxy.sol +72 -0
  33. package/contracts/registry/implementation/ClaimTopicsRegistry.sol +152 -0
  34. package/contracts/registry/implementation/IdentityRegistry.sol +352 -0
  35. package/contracts/registry/implementation/IdentityRegistryStorage.sol +227 -0
  36. package/contracts/registry/implementation/TrustedIssuersRegistry.sol +272 -0
  37. package/contracts/registry/interface/IClaimTopicsRegistry.sol +70 -0
  38. package/contracts/registry/interface/IIdentityRegistry.sol +102 -0
  39. package/contracts/registry/interface/IIdentityRegistryStorage.sol +70 -0
  40. package/contracts/registry/interface/ITrustedIssuersRegistry.sol +70 -0
  41. package/contracts/roles/AbstractAgentRole.sol +122 -0
  42. package/contracts/roles/AgentRole.sol +82 -0
  43. package/contracts/roles/AgentRoleUpgradeable.sol +82 -0
  44. package/contracts/roles/IERC173.sol +21 -0
  45. package/contracts/roles/Roles.sol +102 -0
  46. package/contracts/token/IToken.sol +97 -0
  47. package/contracts/token/Token.sol +664 -0
  48. package/contracts/token/TokenStructs.sol +74 -0
  49. package/contracts/utils/IUtilityChecker.sol +135 -0
  50. package/contracts/utils/InterfaceIdCalculator.sol +223 -0
  51. package/contracts/utils/UtilityChecker.sol +210 -0
  52. package/contracts/utils/UtilityCheckerProxy.sol +72 -0
  53. package/contracts/vendor/openzeppelin/Create3.sol +143 -0
  54. package/out/AbstractAgentRole.sol/AbstractAgentRole.json +1 -0
  55. package/out/AbstractModuleUpgradeable.sol/AbstractModuleUpgradeable.json +1 -0
  56. package/out/AbstractProxy.sol/AbstractProxy.json +1 -0
  57. package/out/Address.sol/Address.json +1 -0
  58. package/out/AgentRole.sol/AgentRole.json +1 -0
  59. package/out/AgentRoleUpgradeable.sol/AgentRoleUpgradeable.json +1 -0
  60. package/out/Arrays.sol/Arrays.json +1 -0
  61. package/out/Base.sol/CommonBase.json +1 -0
  62. package/out/Base.sol/ScriptBase.json +1 -0
  63. package/out/Base.sol/TestBase.json +1 -0
  64. package/out/Bytes.sol/Bytes.json +1 -0
  65. package/out/ClaimIssuer.sol/ClaimIssuer.json +1 -0
  66. package/out/ClaimIssuerTrick.sol/ClaimIssuerTrick.json +1 -0
  67. package/out/ClaimTopicsRegistry.sol/ClaimTopicsRegistry.json +1 -0
  68. package/out/ClaimTopicsRegistryProxy.sol/ClaimTopicsRegistryProxy.json +1 -0
  69. package/out/Comparators.sol/Comparators.json +1 -0
  70. package/out/Context.sol/Context.json +1 -0
  71. package/out/ContextUpgradeable.sol/ContextUpgradeable.json +1 -0
  72. package/out/Countries.sol/Countries.json +1 -0
  73. package/out/Create2.sol/Create2.json +1 -0
  74. package/out/Create3.sol/Create3.json +1 -0
  75. package/out/ECDSA.sol/ECDSA.json +1 -0
  76. package/out/EIP712.sol/EIP712.json +1 -0
  77. package/out/EIP712Upgradeable.sol/EIP712Upgradeable.json +1 -0
  78. package/out/ERC1967Proxy.sol/ERC1967Proxy.json +1 -0
  79. package/out/ERC1967Utils.sol/ERC1967Utils.json +1 -0
  80. package/out/ERC20.sol/ERC20.json +1 -0
  81. package/out/ERC20Pausable.sol/ERC20Pausable.json +1 -0
  82. package/out/ERC20PermitUpgradeable.sol/ERC20PermitUpgradeable.json +1 -0
  83. package/out/ERC20Upgradeable.sol/ERC20Upgradeable.json +1 -0
  84. package/out/ERC2771Context.sol/ERC2771Context.json +1 -0
  85. package/out/ERC2771ContextUpgradeable.sol/ERC2771ContextUpgradeable.json +1 -0
  86. package/out/ERC2771Forwarder.sol/ERC2771Forwarder.json +1 -0
  87. package/out/ERC3643EventsLib.sol/ERC3643EventsLib.json +1 -0
  88. package/out/EnumerableSet.sol/EnumerableSet.json +1 -0
  89. package/out/Errors.sol/Errors.json +1 -0
  90. package/out/ErrorsLib.sol/ErrorsLib.json +1 -0
  91. package/out/EventsLib.sol/EventsLib.json +1 -0
  92. package/out/IAFactory.sol/IAFactory.json +1 -0
  93. package/out/IBeacon.sol/IBeacon.json +1 -0
  94. package/out/IClaimIssuer.sol/IClaimIssuer.json +1 -0
  95. package/out/IClaimTopicsRegistry.sol/IClaimTopicsRegistry.json +1 -0
  96. package/out/IERC1363.sol/IERC1363.json +1 -0
  97. package/out/IERC165.sol/IERC165.json +1 -0
  98. package/out/IERC173.sol/IERC173.json +1 -0
  99. package/out/IERC1967.sol/IERC1967.json +1 -0
  100. package/out/IERC20.sol/IERC20.json +1 -0
  101. package/out/IERC20Metadata.sol/IERC20Metadata.json +1 -0
  102. package/out/IERC20Permit.sol/IERC20Permit.json +1 -0
  103. package/out/IERC3643.sol/IERC3643.json +1 -0
  104. package/out/IERC3643ClaimTopicsRegistry.sol/IERC3643ClaimTopicsRegistry.json +1 -0
  105. package/out/IERC3643Compliance.sol/IERC3643Compliance.json +1 -0
  106. package/out/IERC3643IdentityRegistry.sol/IERC3643IdentityRegistry.json +1 -0
  107. package/out/IERC3643IdentityRegistryStorage.sol/IERC3643IdentityRegistryStorage.json +1 -0
  108. package/out/IERC3643TrustedIssuersRegistry.sol/IERC3643TrustedIssuersRegistry.json +1 -0
  109. package/out/IERC5267.sol/IERC5267.json +1 -0
  110. package/out/IERC734.sol/IERC734.json +1 -0
  111. package/out/IERC735.sol/IERC735.json +1 -0
  112. package/out/IIAFactory.sol/IIAFactory.json +1 -0
  113. package/out/IIdFactory.sol/IIdFactory.json +1 -0
  114. package/out/IIdentity.sol/IIdentity.json +1 -0
  115. package/out/IIdentityRegistry.sol/IIdentityRegistry.json +1 -0
  116. package/out/IIdentityRegistryStorage.sol/IIdentityRegistryStorage.json +1 -0
  117. package/out/IImplementationAuthority.sol/IImplementationAuthority.json +1 -0
  118. package/out/IModularCompliance.sol/IModularCompliance.json +1 -0
  119. package/out/IModule.sol/IModule.json +1 -0
  120. package/out/IMulticall3.sol/IMulticall3.json +1 -0
  121. package/out/IProxy.sol/IProxy.json +1 -0
  122. package/out/ITREXFactory.sol/ITREXFactory.json +1 -0
  123. package/out/ITREXGateway.sol/ITREXGateway.json +1 -0
  124. package/out/ITREXImplementationAuthority.sol/ITREXImplementationAuthority.json +1 -0
  125. package/out/IToken.sol/IToken.json +1 -0
  126. package/out/ITrustedIssuersRegistry.sol/ITrustedIssuersRegistry.json +1 -0
  127. package/out/IUtilityChecker.sol/IUtilityChecker.json +1 -0
  128. package/out/IdFactory.sol/IdFactory.json +1 -0
  129. package/out/Identity.sol/Identity.json +1 -0
  130. package/out/IdentityProxy.sol/IdentityProxy.json +1 -0
  131. package/out/IdentityRegistry.sol/IdentityRegistry.json +1 -0
  132. package/out/IdentityRegistryProxy.sol/IdentityRegistryProxy.json +1 -0
  133. package/out/IdentityRegistryStorage.sol/IdentityRegistryStorage.json +1 -0
  134. package/out/IdentityRegistryStorageProxy.sol/IdentityRegistryStorageProxy.json +1 -0
  135. package/out/ImplementationAuthority.sol/ImplementationAuthority.json +1 -0
  136. package/out/Initializable.sol/Initializable.json +1 -0
  137. package/out/InterfaceIdCalculator.sol/InterfaceIdCalculator.json +1 -0
  138. package/out/KeyPurposes.sol/KeyPurposes.json +1 -0
  139. package/out/KeyTypes.sol/KeyTypes.json +1 -0
  140. package/out/LowLevelCall.sol/LowLevelCall.json +1 -0
  141. package/out/Math.sol/Math.json +1 -0
  142. package/out/MessageHashUtils.sol/MessageHashUtils.json +1 -0
  143. package/out/ModularCompliance.sol/ModularCompliance.json +1 -0
  144. package/out/ModularComplianceProxy.sol/ModularComplianceProxy.json +1 -0
  145. package/out/ModuleNotPnP.sol/ModuleNotPnP.json +1 -0
  146. package/out/ModuleProxy.sol/ModuleProxy.json +1 -0
  147. package/out/MulticallUpgradeable.sol/MulticallUpgradeable.json +1 -0
  148. package/out/Nonces.sol/Nonces.json +1 -0
  149. package/out/NoncesUpgradeable.sol/NoncesUpgradeable.json +1 -0
  150. package/out/Ownable.sol/Ownable.json +1 -0
  151. package/out/Ownable2Step.sol/Ownable2Step.json +1 -0
  152. package/out/Ownable2StepUpgradeable.sol/Ownable2StepUpgradeable.json +1 -0
  153. package/out/OwnableUpgradeable.sol/OwnableUpgradeable.json +1 -0
  154. package/out/Panic.sol/Panic.json +1 -0
  155. package/out/Pausable.sol/Pausable.json +1 -0
  156. package/out/PausableUpgradeable.sol/PausableUpgradeable.json +1 -0
  157. package/out/Proxy.sol/Proxy.json +1 -0
  158. package/out/Roles.sol/Roles.json +1 -0
  159. package/out/SafeCast.sol/SafeCast.json +1 -0
  160. package/out/SafeERC20.sol/SafeERC20.json +1 -0
  161. package/out/ShortStrings.sol/ShortStrings.json +1 -0
  162. package/out/SignedMath.sol/SignedMath.json +1 -0
  163. package/out/SlotDerivation.sol/SlotDerivation.json +1 -0
  164. package/out/StdAssertions.sol/StdAssertions.json +1 -0
  165. package/out/StdChains.sol/StdChains.json +1 -0
  166. package/out/StdCheats.sol/StdCheats.json +1 -0
  167. package/out/StdCheats.sol/StdCheatsSafe.json +1 -0
  168. package/out/StdConstants.sol/StdConstants.json +1 -0
  169. package/out/StdError.sol/stdError.json +1 -0
  170. package/out/StdInvariant.sol/StdInvariant.json +1 -0
  171. package/out/StdJson.sol/stdJson.json +1 -0
  172. package/out/StdMath.sol/stdMath.json +1 -0
  173. package/out/StdStorage.sol/stdStorage.json +1 -0
  174. package/out/StdStorage.sol/stdStorageSafe.json +1 -0
  175. package/out/StdStyle.sol/StdStyle.json +1 -0
  176. package/out/StdToml.sol/stdToml.json +1 -0
  177. package/out/StdUtils.sol/StdUtils.json +1 -0
  178. package/out/Storage.sol/Storage.json +1 -0
  179. package/out/StorageSlot.sol/StorageSlot.json +1 -0
  180. package/out/Strings.sol/Strings.json +1 -0
  181. package/out/Structs.sol/Structs.json +1 -0
  182. package/out/TREXFactory.sol/TREXFactory.json +1 -0
  183. package/out/TREXGateway.sol/TREXGateway.json +1 -0
  184. package/out/TREXImplementationAuthority.sol/TREXImplementationAuthority.json +1 -0
  185. package/out/TestAgentRole.sol/TestAgentRole.json +1 -0
  186. package/out/TestAgentRoleUpgradeable.sol/TestAgentRoleUpgradeable.json +1 -0
  187. package/out/TestERC20.sol/TestERC20.json +1 -0
  188. package/out/TestModule.sol/TestModule.json +1 -0
  189. package/out/TestTREXFactory.sol/TestTREXFactory.json +1 -0
  190. package/out/Token.sol/Token.json +1 -0
  191. package/out/TokenProxy.sol/TokenProxy.json +1 -0
  192. package/out/TrustedIssuersRegistry.sol/TrustedIssuersRegistry.json +1 -0
  193. package/out/TrustedIssuersRegistryProxy.sol/TrustedIssuersRegistryProxy.json +1 -0
  194. package/out/UUPSUpgradeable.sol/UUPSUpgradeable.json +1 -0
  195. package/out/UtilityChecker.sol/UtilityChecker.json +1 -0
  196. package/out/UtilityCheckerProxy.sol/UtilityCheckerProxy.json +1 -0
  197. package/out/Utils.sol/Utils.json +1 -0
  198. package/out/Version.sol/Version.json +1 -0
  199. package/out/Vm.sol/Vm.json +1 -0
  200. package/out/Vm.sol/VmSafe.json +1 -0
  201. package/out/console.sol/console.json +1 -0
  202. package/out/draft-IERC1822.sol/IERC1822Proxiable.json +1 -0
  203. package/out/draft-IERC6093.sol/IERC1155Errors.json +1 -0
  204. package/out/draft-IERC6093.sol/IERC20Errors.json +1 -0
  205. package/out/draft-IERC6093.sol/IERC721Errors.json +1 -0
  206. package/out/libraries/Errors.sol/Errors.json +1 -0
  207. package/out/safeconsole.sol/safeconsole.json +1 -0
  208. package/package.json +47 -0
@@ -0,0 +1,358 @@
1
+ // SPDX-License-Identifier: GPL-3.0
2
+ //
3
+ // :+#####%%%%%%%%%%%%%%+
4
+ // .-*@@@%+.:+%@@@@@%%#***%@@%=
5
+ // :=*%@@@#=. :#@@% *@@@%=
6
+ // .-+*%@%*-.:+%@@@@@@+. -*+: .=#. :%@@@%-
7
+ // :=*@@@@%%@@@@@@@@@%@@@- .=#@@@%@%= =@@@@#.
8
+ // -=+#%@@%#*=:. :%@@@@%. -*@@#*@@@@@@@#=:- *@@@@+
9
+ // =@@%=:. :=: *@@@@@%#- =%*%@@@@#+-. =+ :%@@@%-
10
+ // -@@%. .+@@@ =+=-. @@#- +@@@%- =@@@@%:
11
+ // :@@@. .+@@#%: : .=*=-::.-%@@@+*@@= +@@@@#.
12
+ // %@@: +@%%* =%@@@@@@@@@@@#. .*@%- +@@@@*.
13
+ // #@@= .+@@@@%:=*@@@@@- :%@%: .*@@@@+
14
+ // *@@* +@@@#-@@%-:%@@* +@@#. :%@@@@-
15
+ // -@@% .:-=++*##%%%@@@@@@@@@@@@*. :@+.@@@%: .#@@+ =@@@@#:
16
+ // .@@@*-+*#%%%@@@@@@@@@@@@@@@@%%#**@@%@@@. *@=*@@# :#@%= .#@@@@#-
17
+ // -%@@@@@@@@@@@@@@@*+==-:-@@@= *@# .#@*-=*@@@@%= -%@@@* =@@@@@%-
18
+ // -+%@@@#. %@%%= -@@:+@: -@@* *@@*-:: -%@@%=. .*@@@@@#
19
+ // *@@@* +@* *@@##@@- #@*@@+ -@@= . :+@@@#: .-+@@@%+-
20
+ // +@@@%*@@:..=@@@@* .@@@* .#@#. .=+- .=%@@@*. :+#@@@@*=:
21
+ // =@@@@%@@@@@@@@@@@@@@@@@@@@@@%- :+#*. :*@@@%=. .=#@@@@%+:
22
+ // .%@@= ..... .=#@@+. .#@@@*: -*%@@@@%+.
23
+ // +@@#+===---:::... .=%@@*- +@@@+. -*@@@@@%+.
24
+ // -@@@@@@@@@@@@@@@@@@@@@@%@@@@= -@@@+ -#@@@@@#=.
25
+ // ..:::---===+++***###%%%@@@#- .#@@+ -*@@@@@#=.
26
+ // @@@@@@+. +@@*. .+@@@@@%=.
27
+ // -@@@@@= =@@%: -#@@@@%+.
28
+ // +@@@@@. =@@@= .+@@@@@*:
29
+ // #@@@@#:%@@#. :*@@@@#-
30
+ // @@@@@%@@@= :#@@@@+.
31
+ // :@@@@@@@#.:#@@@%-
32
+ // +@@@@@@-.*@@@*:
33
+ // #@@@@#.=@@@+.
34
+ // @@@@+-%@%=
35
+ // :@@@#%@%=
36
+ // +@@@@%-
37
+ // :#%%=
38
+ //
39
+ /**
40
+ * NOTICE
41
+ *
42
+ * The T-REX software is licensed under a proprietary license or the GPL v.3.
43
+ * If you choose to receive it under the GPL v.3 license, the following applies:
44
+ * T-REX is a suite of smart contracts implementing the ERC-3643 standard and
45
+ * developed by Tokeny to manage and transfer financial assets on EVM blockchains
46
+ *
47
+ * Copyright (C) 2025, Tokeny sàrl.
48
+ *
49
+ * This program is free software: you can redistribute it and/or modify
50
+ * it under the terms of the GNU General Public License as published by
51
+ * the Free Software Foundation, either version 3 of the License, or
52
+ * (at your option) any later version.
53
+ *
54
+ * This program is distributed in the hope that it will be useful,
55
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
56
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57
+ * GNU General Public License for more details.
58
+ *
59
+ * You should have received a copy of the GNU General Public License
60
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
61
+ */
62
+ pragma solidity 0.8.30;
63
+
64
+ import { IIdFactory } from "@onchain-id/solidity/contracts/factory/IIdFactory.sol";
65
+
66
+ import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
67
+
68
+ import { ErrorsLib } from "../libraries/ErrorsLib.sol";
69
+ import { EventsLib } from "../libraries/EventsLib.sol";
70
+ import { ClaimTopicsRegistryProxy } from "../proxy/ClaimTopicsRegistryProxy.sol";
71
+ import { IdentityRegistryProxy } from "../proxy/IdentityRegistryProxy.sol";
72
+ import { IdentityRegistryStorageProxy } from "../proxy/IdentityRegistryStorageProxy.sol";
73
+ import { ModularComplianceProxy } from "../proxy/ModularComplianceProxy.sol";
74
+ import { TokenProxy } from "../proxy/TokenProxy.sol";
75
+ import { TrustedIssuersRegistryProxy } from "../proxy/TrustedIssuersRegistryProxy.sol";
76
+ import { ITREXImplementationAuthority } from "../proxy/authority/ITREXImplementationAuthority.sol";
77
+ import { IIdentityRegistryStorage } from "../registry/interface/IIdentityRegistryStorage.sol";
78
+ import { Create3 } from "../vendor/openzeppelin/Create3.sol";
79
+ import { ITREXFactory } from "./ITREXFactory.sol";
80
+
81
+ contract TREXFactory is ITREXFactory, Ownable {
82
+
83
+ /// the address of the implementation authority contract used in the tokens deployed by the factory
84
+ address private _implementationAuthority;
85
+
86
+ /// the address of the Identity Factory used to deploy token OIDs
87
+ address private _idFactory;
88
+
89
+ /// mapping containing info about the token contracts corresponding to salt already used for CREATE3 deployments
90
+ mapping(string => address) public tokenDeployed;
91
+
92
+ /// constructor is setting the implementation authority and the Identity Factory of the TREX factory
93
+ constructor(address implementationAuthority_, address idFactory_) Ownable(msg.sender) {
94
+ setImplementationAuthority(implementationAuthority_);
95
+ setIdFactory(idFactory_);
96
+ }
97
+
98
+ /**
99
+ * @dev See {ITREXFactory-deployTREXSuite}.
100
+ */
101
+ // solhint-disable-next-line code-complexity, function-max-lines
102
+ function deployTREXSuite(
103
+ string memory _salt,
104
+ TokenDetails calldata _tokenDetails,
105
+ ClaimDetails calldata _claimDetails
106
+ ) external override onlyOwner {
107
+ require(tokenDeployed[_salt] == address(0), ErrorsLib.TokenAlreadyDeployed());
108
+ require((_claimDetails.issuers).length == (_claimDetails.issuerClaims).length, ErrorsLib.InvalidClaimPattern());
109
+ require((_claimDetails.issuers).length <= 5, ErrorsLib.MaxClaimIssuersReached(5));
110
+ require((_claimDetails.claimTopics).length <= 5, ErrorsLib.MaxClaimTopicsReached(5));
111
+ require(
112
+ (_tokenDetails.irAgents).length <= 5 && (_tokenDetails.tokenAgents).length <= 5,
113
+ ErrorsLib.MaxAgentsReached(5)
114
+ );
115
+ require((_tokenDetails.complianceModules).length <= 30, ErrorsLib.MaxModuleActionsReached(30));
116
+ require(
117
+ (_tokenDetails.complianceModules).length >= (_tokenDetails.complianceSettings).length,
118
+ ErrorsLib.InvalidCompliancePattern()
119
+ );
120
+
121
+ address tir = _deployTIR(
122
+ _salt, _implementationAuthority, _tokenDetails.owner, _claimDetails.issuers, _claimDetails.issuerClaims
123
+ );
124
+ address ctr = _deployCTR(_salt, _implementationAuthority, _tokenDetails.owner, _claimDetails.claimTopics);
125
+
126
+ address irs = _tokenDetails.irs;
127
+ if (irs == address(0)) {
128
+ irs = _deployIRS(_salt, _tokenDetails);
129
+ }
130
+
131
+ address ir = _deployIR(_salt, _tokenDetails, tir, ctr, irs);
132
+ require(ir == _predictAddress(_salt, "IR"), ErrorsLib.AddressPredictionMismatch());
133
+ address mc = _deployMC(_salt, _tokenDetails);
134
+
135
+ // For a freshly-deployed IRS, the binding is folded into init; for a reused IRS, the binding is
136
+ // still applied here (the factory must be owner of the reused IRS, same precondition as before
137
+ // the refactor).
138
+ if (_tokenDetails.irs != address(0)) {
139
+ IIdentityRegistryStorage(irs).bindIdentityRegistry(ir);
140
+ }
141
+
142
+ address token = _deployToken(_salt, _tokenDetails, ir, mc);
143
+ tokenDeployed[_salt] = token;
144
+
145
+ emit EventsLib.TREXSuiteDeployed(token, ir, irs, tir, ctr, mc, _salt);
146
+ }
147
+
148
+ /**
149
+ * @dev See {ITREXFactory-recoverContractOwnership}.
150
+ */
151
+ function recoverContractOwnership(address _contract, address _newOwner) external override onlyOwner {
152
+ (Ownable(_contract)).transferOwnership(_newOwner);
153
+ }
154
+
155
+ /**
156
+ * @dev See {ITREXFactory-getImplementationAuthority}.
157
+ */
158
+ function getImplementationAuthority() external view override returns (address) {
159
+ return _implementationAuthority;
160
+ }
161
+
162
+ /**
163
+ * @dev See {ITREXFactory-getIdFactory}.
164
+ */
165
+ function getIdFactory() external view override returns (address) {
166
+ return _idFactory;
167
+ }
168
+
169
+ /**
170
+ * @dev See {ITREXFactory-getToken}.
171
+ */
172
+ function getToken(string calldata _salt) external view override returns (address) {
173
+ return tokenDeployed[_salt];
174
+ }
175
+
176
+ /**
177
+ * @dev See {ITREXFactory-setImplementationAuthority}.
178
+ */
179
+ function setImplementationAuthority(address implementationAuthority_) public override onlyOwner {
180
+ require(implementationAuthority_ != address(0), ErrorsLib.ZeroAddress());
181
+ // should not be possible to set an implementation authority that is not complete
182
+ require(
183
+ (ITREXImplementationAuthority(implementationAuthority_)).getTokenImplementation() != address(0)
184
+ && (ITREXImplementationAuthority(implementationAuthority_)).getCTRImplementation() != address(0)
185
+ && (ITREXImplementationAuthority(implementationAuthority_)).getIRImplementation() != address(0)
186
+ && (ITREXImplementationAuthority(implementationAuthority_)).getIRSImplementation() != address(0)
187
+ && (ITREXImplementationAuthority(implementationAuthority_)).getMCImplementation() != address(0)
188
+ && (ITREXImplementationAuthority(implementationAuthority_)).getTIRImplementation() != address(0),
189
+ ErrorsLib.InvalidImplementationAuthority()
190
+ );
191
+ _implementationAuthority = implementationAuthority_;
192
+ emit EventsLib.ImplementationAuthoritySet(implementationAuthority_);
193
+ }
194
+
195
+ /**
196
+ * @dev See {ITREXFactory-setIdFactory}.
197
+ */
198
+ function setIdFactory(address idFactory_) public override onlyOwner {
199
+ require(idFactory_ != address(0), ErrorsLib.ZeroAddress());
200
+ _idFactory = idFactory_;
201
+ emit EventsLib.IdFactorySet(idFactory_);
202
+ }
203
+
204
+ /**
205
+ * @dev Deploys a contract using CREATE3
206
+ * @param salt Base salt for deployment
207
+ * @param contractType Contract type identifier (e.g., "TIR", "CTR")
208
+ * @param bytecode Full creation bytecode including constructor parameters
209
+ */
210
+ function _deploy(string memory salt, string memory contractType, bytes memory bytecode) internal returns (address) {
211
+ address addr = Create3.deploy(0, _saltBytes(salt, contractType), bytecode);
212
+ emit EventsLib.Deployed(addr);
213
+ return addr;
214
+ }
215
+
216
+ /**
217
+ * @dev Returns the address at which `_deploy(salt, contractType, ...)` would land.
218
+ * Pure function of (factory address, salt, contractType) — bytecode does not influence the result under
219
+ * CREATE3, which lets the factory pre-compute one suite contract's address while feeding it into another
220
+ * contract's constructor (e.g. pre-binding the IR address into the IRS proxy).
221
+ */
222
+ function _predictAddress(string memory salt, string memory contractType) internal view returns (address) {
223
+ return Create3.computeAddress(_saltBytes(salt, contractType), address(this));
224
+ }
225
+
226
+ /**
227
+ * @dev Computes the CREATE3 salt for a given (salt, contractType) pair.
228
+ * Salt layout (32 bytes) — preserved from the previous CreateX integration so the per-factory address
229
+ * derivation stays unchanged should an operator deploy this factory at the same address on multiple
230
+ * chains.
231
+ * 1) 20 bytes: factory address
232
+ * 2) 1 byte: 0x00
233
+ * 3) 11 bytes: bytes11(keccak256(salt, contractType))
234
+ *
235
+ * The contractType discriminator prevents the 6 suite contracts from colliding on a single CREATE3 slot
236
+ * (they all share the user-provided salt).
237
+ */
238
+ function _saltBytes(string memory salt, string memory contractType) private view returns (bytes32) {
239
+ return bytes32(
240
+ abi.encodePacked(address(this), bytes1(0x00), bytes11(keccak256(abi.encodePacked(salt, contractType))))
241
+ );
242
+ }
243
+
244
+ /// function used to deploy a trusted issuers registry using CREATE3
245
+ function _deployTIR(
246
+ string memory _salt,
247
+ address implementationAuthority_,
248
+ address _owner,
249
+ address[] memory _issuers,
250
+ uint256[][] memory _issuerClaims
251
+ ) private returns (address) {
252
+ bytes memory _code = type(TrustedIssuersRegistryProxy).creationCode;
253
+ bytes memory _constructData = abi.encode(implementationAuthority_, _owner, _issuers, _issuerClaims);
254
+ bytes memory bytecode = abi.encodePacked(_code, _constructData);
255
+ return _deploy(_salt, "TIR", bytecode);
256
+ }
257
+
258
+ /// function used to deploy a claim topics registry using CREATE3
259
+ function _deployCTR(
260
+ string memory _salt,
261
+ address implementationAuthority_,
262
+ address _owner,
263
+ uint256[] memory _initialTopics
264
+ ) private returns (address) {
265
+ bytes memory _code = type(ClaimTopicsRegistryProxy).creationCode;
266
+ bytes memory _constructData = abi.encode(implementationAuthority_, _owner, _initialTopics);
267
+ bytes memory bytecode = abi.encodePacked(_code, _constructData);
268
+ return _deploy(_salt, "CTR", bytecode);
269
+ }
270
+
271
+ /// function used to deploy modular compliance contract using CREATE3
272
+ function _deployMC(string memory _salt, TokenDetails calldata _tokenDetails) private returns (address) {
273
+ bytes memory _code = type(ModularComplianceProxy).creationCode;
274
+ bytes memory _constructData = abi.encode(
275
+ _implementationAuthority,
276
+ _predictAddress(_salt, "Token"),
277
+ _tokenDetails.owner,
278
+ _tokenDetails.complianceModules,
279
+ _tokenDetails.complianceSettings
280
+ );
281
+ bytes memory bytecode = abi.encodePacked(_code, _constructData);
282
+ return _deploy(_salt, "MC", bytecode);
283
+ }
284
+
285
+ function _deployIRS(string memory _salt, TokenDetails calldata _tokenDetails) private returns (address) {
286
+ bytes memory _code = type(IdentityRegistryStorageProxy).creationCode;
287
+ bytes memory _constructData =
288
+ abi.encode(_implementationAuthority, _tokenDetails.owner, _predictAddress(_salt, "IR"));
289
+ bytes memory bytecode = abi.encodePacked(_code, _constructData);
290
+ return _deploy(_salt, "IRS", bytecode);
291
+ }
292
+
293
+ /// Deploy the IR with the Token's predicted CREATE3 address baked in so the IR grants the agent
294
+ /// role to the Token at init time, and the factory never needs to call `addAgent` post-deploy.
295
+ function _deployIR(
296
+ string memory _salt,
297
+ TokenDetails calldata _tokenDetails,
298
+ address _trustedIssuersRegistry,
299
+ address _claimTopicsRegistry,
300
+ address _identityStorage
301
+ ) private returns (address) {
302
+ bytes memory _code = type(IdentityRegistryProxy).creationCode;
303
+ bytes memory _constructData = abi.encode(
304
+ _implementationAuthority,
305
+ _trustedIssuersRegistry,
306
+ _claimTopicsRegistry,
307
+ _identityStorage,
308
+ _tokenDetails.owner,
309
+ _tokenDetails.irAgents,
310
+ _predictAddress(_salt, "Token")
311
+ );
312
+ bytes memory bytecode = abi.encodePacked(_code, _constructData);
313
+ return _deploy(_salt, "IR", bytecode);
314
+ }
315
+
316
+ /// Resolve the OID (caller-supplied or freshly minted via `IIdFactory.createTokenIdentity` against
317
+ /// the Token's predicted CREATE3 address) and deploy the Token proxy whose `init` carries the final
318
+ /// owner, configured agents and the resolved OID. Asserts the deployed Token's CREATE3 address
319
+ /// matches the prediction reused by the IR + MC + OID wiring.
320
+ function _deployToken(
321
+ string memory _salt,
322
+ TokenDetails calldata _tokenDetails,
323
+ address _identityRegistry,
324
+ address _compliance
325
+ ) private returns (address) {
326
+ address token = _deploy(_salt, "Token", _tokenBytecode(_salt, _tokenDetails, _identityRegistry, _compliance));
327
+ require(token == _predictAddress(_salt, "Token"), ErrorsLib.AddressPredictionMismatch());
328
+ return token;
329
+ }
330
+
331
+ function _tokenBytecode(
332
+ string memory _salt,
333
+ TokenDetails calldata _tokenDetails,
334
+ address _identityRegistry,
335
+ address _compliance
336
+ ) private returns (bytes memory) {
337
+ address oid = _tokenDetails.ONCHAINID;
338
+ if (oid == address(0)) {
339
+ oid =
340
+ IIdFactory(_idFactory).createTokenIdentity(_predictAddress(_salt, "Token"), _tokenDetails.owner, _salt);
341
+ }
342
+ return abi.encodePacked(
343
+ type(TokenProxy).creationCode,
344
+ abi.encode(
345
+ _implementationAuthority,
346
+ _identityRegistry,
347
+ _compliance,
348
+ _tokenDetails.name,
349
+ _tokenDetails.symbol,
350
+ _tokenDetails.decimals,
351
+ oid,
352
+ _tokenDetails.owner,
353
+ _tokenDetails.tokenAgents
354
+ )
355
+ );
356
+ }
357
+
358
+ }
@@ -0,0 +1,274 @@
1
+ // SPDX-License-Identifier: GPL-3.0
2
+ //
3
+ // :+#####%%%%%%%%%%%%%%+
4
+ // .-*@@@%+.:+%@@@@@%%#***%@@%=
5
+ // :=*%@@@#=. :#@@% *@@@%=
6
+ // .-+*%@%*-.:+%@@@@@@+. -*+: .=#. :%@@@%-
7
+ // :=*@@@@%%@@@@@@@@@%@@@- .=#@@@%@%= =@@@@#.
8
+ // -=+#%@@%#*=:. :%@@@@%. -*@@#*@@@@@@@#=:- *@@@@+
9
+ // =@@%=:. :=: *@@@@@%#- =%*%@@@@#+-. =+ :%@@@%-
10
+ // -@@%. .+@@@ =+=-. @@#- +@@@%- =@@@@%:
11
+ // :@@@. .+@@#%: : .=*=-::.-%@@@+*@@= +@@@@#.
12
+ // %@@: +@%%* =%@@@@@@@@@@@#. .*@%- +@@@@*.
13
+ // #@@= .+@@@@%:=*@@@@@- :%@%: .*@@@@+
14
+ // *@@* +@@@#-@@%-:%@@* +@@#. :%@@@@-
15
+ // -@@% .:-=++*##%%%@@@@@@@@@@@@*. :@+.@@@%: .#@@+ =@@@@#:
16
+ // .@@@*-+*#%%%@@@@@@@@@@@@@@@@%%#**@@%@@@. *@=*@@# :#@%= .#@@@@#-
17
+ // -%@@@@@@@@@@@@@@@*+==-:-@@@= *@# .#@*-=*@@@@%= -%@@@* =@@@@@%-
18
+ // -+%@@@#. %@%%= -@@:+@: -@@* *@@*-:: -%@@%=. .*@@@@@#
19
+ // *@@@* +@* *@@##@@- #@*@@+ -@@= . :+@@@#: .-+@@@%+-
20
+ // +@@@%*@@:..=@@@@* .@@@* .#@#. .=+- .=%@@@*. :+#@@@@*=:
21
+ // =@@@@%@@@@@@@@@@@@@@@@@@@@@@%- :+#*. :*@@@%=. .=#@@@@%+:
22
+ // .%@@= ..... .=#@@+. .#@@@*: -*%@@@@%+.
23
+ // +@@#+===---:::... .=%@@*- +@@@+. -*@@@@@%+.
24
+ // -@@@@@@@@@@@@@@@@@@@@@@%@@@@= -@@@+ -#@@@@@#=.
25
+ // ..:::---===+++***###%%%@@@#- .#@@+ -*@@@@@#=.
26
+ // @@@@@@+. +@@*. .+@@@@@%=.
27
+ // -@@@@@= =@@%: -#@@@@%+.
28
+ // +@@@@@. =@@@= .+@@@@@*:
29
+ // #@@@@#:%@@#. :*@@@@#-
30
+ // @@@@@%@@@= :#@@@@+.
31
+ // :@@@@@@@#.:#@@@%-
32
+ // +@@@@@@-.*@@@*:
33
+ // #@@@@#.=@@@+.
34
+ // @@@@+-%@%=
35
+ // :@@@#%@%=
36
+ // +@@@@%-
37
+ // :#%%=
38
+ //
39
+ /**
40
+ * NOTICE
41
+ *
42
+ * The T-REX software is licensed under a proprietary license or the GPL v.3.
43
+ * If you choose to receive it under the GPL v.3 license, the following applies:
44
+ * T-REX is a suite of smart contracts implementing the ERC-3643 standard and
45
+ * developed by Tokeny to manage and transfer financial assets on EVM blockchains
46
+ *
47
+ * Copyright (C) 2025, Tokeny sàrl.
48
+ *
49
+ * This program is free software: you can redistribute it and/or modify
50
+ * it under the terms of the GNU General Public License as published by
51
+ * the Free Software Foundation, either version 3 of the License, or
52
+ * (at your option) any later version.
53
+ *
54
+ * This program is distributed in the hope that it will be useful,
55
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
56
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57
+ * GNU General Public License for more details.
58
+ *
59
+ * You should have received a copy of the GNU General Public License
60
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
61
+ */
62
+ pragma solidity 0.8.30;
63
+
64
+ import { ErrorsLib } from "../libraries/ErrorsLib.sol";
65
+ import { EventsLib } from "../libraries/EventsLib.sol";
66
+ import { AgentRole } from "../roles/AgentRole.sol";
67
+ import { IERC173 } from "../roles/IERC173.sol";
68
+ import { ITREXFactory } from "./ITREXFactory.sol";
69
+ import { ITREXGateway } from "./ITREXGateway.sol";
70
+ import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
71
+ import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
72
+ import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
73
+ import { Strings } from "@openzeppelin/contracts/utils/Strings.sol";
74
+ import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
75
+
76
+ contract TREXGateway is ITREXGateway, AgentRole, IERC165 {
77
+
78
+ using SafeERC20 for IERC20;
79
+
80
+ /// address of the TREX Factory that is managed by the Gateway
81
+ address private _factory;
82
+
83
+ /// public deployment status variable
84
+ bool private _publicDeploymentStatus;
85
+
86
+ /// deployment fee details
87
+ Fee private _deploymentFee;
88
+
89
+ /// deployment fees enabling variable
90
+ bool private _deploymentFeeEnabled;
91
+
92
+ /// mapping containing all deployer addresses
93
+ mapping(address => bool) private _deployers;
94
+
95
+ /// mapping for deployment discounts on fees
96
+ mapping(address => uint16) private _feeDiscount;
97
+
98
+ /// constructor of the contract, setting up the factory address and
99
+ /// the public deployment status
100
+ constructor(address factory, bool publicDeploymentStatus) {
101
+ _factory = factory;
102
+ _publicDeploymentStatus = publicDeploymentStatus;
103
+ emit EventsLib.FactorySet(factory);
104
+ emit EventsLib.PublicDeploymentStatusSet(publicDeploymentStatus);
105
+ }
106
+
107
+ /**
108
+ * @dev See {ITREXGateway-setFactory}.
109
+ */
110
+ function setFactory(address factory) external override onlyOwner {
111
+ require(factory != address(0), ErrorsLib.ZeroAddress());
112
+
113
+ _factory = factory;
114
+ emit EventsLib.FactorySet(factory);
115
+ }
116
+
117
+ /**
118
+ * @dev See {ITREXGateway-setPublicDeploymentStatus}.
119
+ */
120
+ function setPublicDeploymentStatus(bool _isEnabled) external override onlyOwner {
121
+ if (_isEnabled == _publicDeploymentStatus) {
122
+ if (_isEnabled) {
123
+ revert ErrorsLib.PublicDeploymentAlreadyEnabled();
124
+ }
125
+ revert ErrorsLib.PublicDeploymentAlreadyDisabled();
126
+ }
127
+
128
+ _publicDeploymentStatus = _isEnabled;
129
+ emit EventsLib.PublicDeploymentStatusSet(_isEnabled);
130
+ }
131
+
132
+ /**
133
+ * @dev See {ITREXGateway-transferFactoryOwnership}.
134
+ */
135
+ function transferFactoryOwnership(address _newOwner) external override onlyOwner {
136
+ Ownable(_factory).transferOwnership(_newOwner);
137
+ }
138
+
139
+ /**
140
+ * @dev See {ITREXGateway-enableDeploymentFee}.
141
+ */
142
+ function enableDeploymentFee(bool _isEnabled) external override onlyOwner {
143
+ if (_isEnabled == _deploymentFeeEnabled) {
144
+ if (_isEnabled) {
145
+ revert ErrorsLib.DeploymentFeesAlreadyEnabled();
146
+ }
147
+ revert ErrorsLib.DeploymentFeesAlreadyDisabled();
148
+ }
149
+
150
+ _deploymentFeeEnabled = _isEnabled;
151
+ emit EventsLib.DeploymentFeeEnabled(_isEnabled);
152
+ }
153
+
154
+ /**
155
+ * @dev See {ITREXGateway-setDeploymentFee}.
156
+ */
157
+ function setDeploymentFee(uint256 _fee, address _feeToken, address _feeCollector) external override onlyOwner {
158
+ require(_feeToken != address(0) && _feeCollector != address(0), ErrorsLib.ZeroAddress());
159
+
160
+ _deploymentFee.fee = _fee;
161
+ _deploymentFee.feeToken = _feeToken;
162
+ _deploymentFee.feeCollector = _feeCollector;
163
+ emit EventsLib.DeploymentFeeSet(_fee, _feeToken, _feeCollector);
164
+ }
165
+
166
+ /**
167
+ * @dev See {ITREXGateway-addDeployer}.
168
+ */
169
+ function addDeployer(address deployer) external override {
170
+ require(isAgent(msg.sender) || msg.sender == owner(), ErrorsLib.SenderIsNotAdmin());
171
+ require(!isDeployer(deployer), ErrorsLib.DeployerAlreadyExists(deployer));
172
+
173
+ _deployers[deployer] = true;
174
+ emit EventsLib.DeployerAdded(deployer);
175
+ }
176
+
177
+ /**
178
+ * @dev See {ITREXGateway-removeDeployer}.
179
+ */
180
+ function removeDeployer(address deployer) external override {
181
+ require(isAgent(msg.sender) || msg.sender == owner(), ErrorsLib.SenderIsNotAdmin());
182
+ require(isDeployer(deployer), ErrorsLib.DeployerDoesNotExist(deployer));
183
+
184
+ delete _deployers[deployer];
185
+ emit EventsLib.DeployerRemoved(deployer);
186
+ }
187
+
188
+ /**
189
+ * @dev See {ITREXGateway-applyFeeDiscount}.
190
+ */
191
+ function applyFeeDiscount(address deployer, uint16 discount) external override {
192
+ require(isAgent(msg.sender) || msg.sender == owner(), ErrorsLib.SenderIsNotAdmin());
193
+ require(discount <= 10000, ErrorsLib.DiscountOutOfRange());
194
+
195
+ _feeDiscount[deployer] = discount;
196
+ emit EventsLib.FeeDiscountApplied(deployer, discount);
197
+ }
198
+
199
+ /**
200
+ * @dev See {ITREXGateway-getPublicDeploymentStatus}.
201
+ */
202
+ function getPublicDeploymentStatus() external view override returns (bool) {
203
+ return _publicDeploymentStatus;
204
+ }
205
+
206
+ /**
207
+ * @dev See {ITREXGateway-getFactory}.
208
+ */
209
+ function getFactory() external view override returns (address) {
210
+ return _factory;
211
+ }
212
+
213
+ /**
214
+ * @dev See {ITREXGateway-getDeploymentFee}.
215
+ */
216
+ function getDeploymentFee() external view override returns (Fee memory) {
217
+ return _deploymentFee;
218
+ }
219
+
220
+ /**
221
+ * @dev See {ITREXGateway-isDeploymentFeeEnabled}.
222
+ */
223
+ function isDeploymentFeeEnabled() external view override returns (bool) {
224
+ return _deploymentFeeEnabled;
225
+ }
226
+
227
+ /**
228
+ * @dev See {ITREXGateway-deployTREXSuite}.
229
+ */
230
+ function deployTREXSuite(
231
+ ITREXFactory.TokenDetails memory _tokenDetails,
232
+ ITREXFactory.ClaimDetails memory _claimDetails
233
+ ) public override {
234
+ require(_publicDeploymentStatus || isDeployer(msg.sender), ErrorsLib.PublicDeploymentsNotAllowed());
235
+ require(
236
+ !_publicDeploymentStatus || msg.sender == _tokenDetails.owner || isDeployer(msg.sender),
237
+ ErrorsLib.PublicCannotDeployOnBehalf()
238
+ );
239
+
240
+ uint256 feeApplied = 0;
241
+ if (_deploymentFeeEnabled) {
242
+ if (_deploymentFee.fee > 0 && _feeDiscount[msg.sender] < 10000) {
243
+ feeApplied = calculateFee(msg.sender);
244
+ IERC20(_deploymentFee.feeToken).safeTransferFrom(msg.sender, _deploymentFee.feeCollector, feeApplied);
245
+ }
246
+ }
247
+ string memory _salt = string(abi.encodePacked(Strings.toHexString(_tokenDetails.owner), _tokenDetails.name));
248
+ ITREXFactory(_factory).deployTREXSuite(_salt, _tokenDetails, _claimDetails);
249
+ emit EventsLib.GatewaySuiteDeploymentProcessed(msg.sender, _tokenDetails.owner, feeApplied);
250
+ }
251
+
252
+ /**
253
+ * @dev See {ITREXGateway-isDeployer}.
254
+ */
255
+ function isDeployer(address deployer) public view override returns (bool) {
256
+ return _deployers[deployer];
257
+ }
258
+
259
+ /**
260
+ * @dev See {ITREXGateway-calculateFee}.
261
+ */
262
+ function calculateFee(address deployer) public view override returns (uint256) {
263
+ return _deploymentFee.fee - ((_feeDiscount[deployer] * _deploymentFee.fee) / 10000);
264
+ }
265
+
266
+ /**
267
+ * @dev See {IERC165-supportsInterface}.
268
+ */
269
+ function supportsInterface(bytes4 interfaceId) public pure virtual override returns (bool) {
270
+ return interfaceId == type(ITREXGateway).interfaceId || interfaceId == type(IERC173).interfaceId
271
+ || interfaceId == type(IERC165).interfaceId;
272
+ }
273
+
274
+ }