@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.
- package/LICENSE.md +674 -0
- package/README.md +137 -0
- package/contracts/ERC-3643/ERC3643EventsLib.sol +150 -0
- package/contracts/ERC-3643/IERC3643.sol +408 -0
- package/contracts/ERC-3643/IERC3643ClaimTopicsRegistry.sol +66 -0
- package/contracts/ERC-3643/IERC3643Compliance.sol +127 -0
- package/contracts/ERC-3643/IERC3643IdentityRegistry.sol +180 -0
- package/contracts/ERC-3643/IERC3643IdentityRegistryStorage.sol +120 -0
- package/contracts/ERC-3643/IERC3643TrustedIssuersRegistry.sol +120 -0
- package/contracts/compliance/modular/IModularCompliance.sol +143 -0
- package/contracts/compliance/modular/ModularCompliance.sol +381 -0
- package/contracts/compliance/modular/modules/AbstractModuleUpgradeable.sol +193 -0
- package/contracts/compliance/modular/modules/IModule.sol +158 -0
- package/contracts/compliance/modular/modules/ModuleProxy.sol +72 -0
- package/contracts/factory/ITREXFactory.sol +180 -0
- package/contracts/factory/ITREXGateway.sol +234 -0
- package/contracts/factory/TREXFactory.sol +358 -0
- package/contracts/factory/TREXGateway.sol +274 -0
- package/contracts/libraries/ErrorsLib.sol +168 -0
- package/contracts/libraries/EventsLib.sol +147 -0
- package/contracts/proxy/AbstractProxy.sol +146 -0
- package/contracts/proxy/ClaimTopicsRegistryProxy.sol +83 -0
- package/contracts/proxy/IdentityRegistryProxy.sol +95 -0
- package/contracts/proxy/IdentityRegistryStorageProxy.sol +83 -0
- package/contracts/proxy/ModularComplianceProxy.sol +88 -0
- package/contracts/proxy/TokenProxy.sol +97 -0
- package/contracts/proxy/TrustedIssuersRegistryProxy.sol +88 -0
- package/contracts/proxy/authority/IAFactory.sol +122 -0
- package/contracts/proxy/authority/IIAFactory.sol +87 -0
- package/contracts/proxy/authority/ITREXImplementationAuthority.sol +239 -0
- package/contracts/proxy/authority/TREXImplementationAuthority.sol +350 -0
- package/contracts/proxy/interface/IProxy.sol +72 -0
- package/contracts/registry/implementation/ClaimTopicsRegistry.sol +152 -0
- package/contracts/registry/implementation/IdentityRegistry.sol +352 -0
- package/contracts/registry/implementation/IdentityRegistryStorage.sol +227 -0
- package/contracts/registry/implementation/TrustedIssuersRegistry.sol +272 -0
- package/contracts/registry/interface/IClaimTopicsRegistry.sol +70 -0
- package/contracts/registry/interface/IIdentityRegistry.sol +102 -0
- package/contracts/registry/interface/IIdentityRegistryStorage.sol +70 -0
- package/contracts/registry/interface/ITrustedIssuersRegistry.sol +70 -0
- package/contracts/roles/AbstractAgentRole.sol +122 -0
- package/contracts/roles/AgentRole.sol +82 -0
- package/contracts/roles/AgentRoleUpgradeable.sol +82 -0
- package/contracts/roles/IERC173.sol +21 -0
- package/contracts/roles/Roles.sol +102 -0
- package/contracts/token/IToken.sol +97 -0
- package/contracts/token/Token.sol +664 -0
- package/contracts/token/TokenStructs.sol +74 -0
- package/contracts/utils/IUtilityChecker.sol +135 -0
- package/contracts/utils/InterfaceIdCalculator.sol +223 -0
- package/contracts/utils/UtilityChecker.sol +210 -0
- package/contracts/utils/UtilityCheckerProxy.sol +72 -0
- package/contracts/vendor/openzeppelin/Create3.sol +143 -0
- package/out/AbstractAgentRole.sol/AbstractAgentRole.json +1 -0
- package/out/AbstractModuleUpgradeable.sol/AbstractModuleUpgradeable.json +1 -0
- package/out/AbstractProxy.sol/AbstractProxy.json +1 -0
- package/out/Address.sol/Address.json +1 -0
- package/out/AgentRole.sol/AgentRole.json +1 -0
- package/out/AgentRoleUpgradeable.sol/AgentRoleUpgradeable.json +1 -0
- package/out/Arrays.sol/Arrays.json +1 -0
- package/out/Base.sol/CommonBase.json +1 -0
- package/out/Base.sol/ScriptBase.json +1 -0
- package/out/Base.sol/TestBase.json +1 -0
- package/out/Bytes.sol/Bytes.json +1 -0
- package/out/ClaimIssuer.sol/ClaimIssuer.json +1 -0
- package/out/ClaimIssuerTrick.sol/ClaimIssuerTrick.json +1 -0
- package/out/ClaimTopicsRegistry.sol/ClaimTopicsRegistry.json +1 -0
- package/out/ClaimTopicsRegistryProxy.sol/ClaimTopicsRegistryProxy.json +1 -0
- package/out/Comparators.sol/Comparators.json +1 -0
- package/out/Context.sol/Context.json +1 -0
- package/out/ContextUpgradeable.sol/ContextUpgradeable.json +1 -0
- package/out/Countries.sol/Countries.json +1 -0
- package/out/Create2.sol/Create2.json +1 -0
- package/out/Create3.sol/Create3.json +1 -0
- package/out/ECDSA.sol/ECDSA.json +1 -0
- package/out/EIP712.sol/EIP712.json +1 -0
- package/out/EIP712Upgradeable.sol/EIP712Upgradeable.json +1 -0
- package/out/ERC1967Proxy.sol/ERC1967Proxy.json +1 -0
- package/out/ERC1967Utils.sol/ERC1967Utils.json +1 -0
- package/out/ERC20.sol/ERC20.json +1 -0
- package/out/ERC20Pausable.sol/ERC20Pausable.json +1 -0
- package/out/ERC20PermitUpgradeable.sol/ERC20PermitUpgradeable.json +1 -0
- package/out/ERC20Upgradeable.sol/ERC20Upgradeable.json +1 -0
- package/out/ERC2771Context.sol/ERC2771Context.json +1 -0
- package/out/ERC2771ContextUpgradeable.sol/ERC2771ContextUpgradeable.json +1 -0
- package/out/ERC2771Forwarder.sol/ERC2771Forwarder.json +1 -0
- package/out/ERC3643EventsLib.sol/ERC3643EventsLib.json +1 -0
- package/out/EnumerableSet.sol/EnumerableSet.json +1 -0
- package/out/Errors.sol/Errors.json +1 -0
- package/out/ErrorsLib.sol/ErrorsLib.json +1 -0
- package/out/EventsLib.sol/EventsLib.json +1 -0
- package/out/IAFactory.sol/IAFactory.json +1 -0
- package/out/IBeacon.sol/IBeacon.json +1 -0
- package/out/IClaimIssuer.sol/IClaimIssuer.json +1 -0
- package/out/IClaimTopicsRegistry.sol/IClaimTopicsRegistry.json +1 -0
- package/out/IERC1363.sol/IERC1363.json +1 -0
- package/out/IERC165.sol/IERC165.json +1 -0
- package/out/IERC173.sol/IERC173.json +1 -0
- package/out/IERC1967.sol/IERC1967.json +1 -0
- package/out/IERC20.sol/IERC20.json +1 -0
- package/out/IERC20Metadata.sol/IERC20Metadata.json +1 -0
- package/out/IERC20Permit.sol/IERC20Permit.json +1 -0
- package/out/IERC3643.sol/IERC3643.json +1 -0
- package/out/IERC3643ClaimTopicsRegistry.sol/IERC3643ClaimTopicsRegistry.json +1 -0
- package/out/IERC3643Compliance.sol/IERC3643Compliance.json +1 -0
- package/out/IERC3643IdentityRegistry.sol/IERC3643IdentityRegistry.json +1 -0
- package/out/IERC3643IdentityRegistryStorage.sol/IERC3643IdentityRegistryStorage.json +1 -0
- package/out/IERC3643TrustedIssuersRegistry.sol/IERC3643TrustedIssuersRegistry.json +1 -0
- package/out/IERC5267.sol/IERC5267.json +1 -0
- package/out/IERC734.sol/IERC734.json +1 -0
- package/out/IERC735.sol/IERC735.json +1 -0
- package/out/IIAFactory.sol/IIAFactory.json +1 -0
- package/out/IIdFactory.sol/IIdFactory.json +1 -0
- package/out/IIdentity.sol/IIdentity.json +1 -0
- package/out/IIdentityRegistry.sol/IIdentityRegistry.json +1 -0
- package/out/IIdentityRegistryStorage.sol/IIdentityRegistryStorage.json +1 -0
- package/out/IImplementationAuthority.sol/IImplementationAuthority.json +1 -0
- package/out/IModularCompliance.sol/IModularCompliance.json +1 -0
- package/out/IModule.sol/IModule.json +1 -0
- package/out/IMulticall3.sol/IMulticall3.json +1 -0
- package/out/IProxy.sol/IProxy.json +1 -0
- package/out/ITREXFactory.sol/ITREXFactory.json +1 -0
- package/out/ITREXGateway.sol/ITREXGateway.json +1 -0
- package/out/ITREXImplementationAuthority.sol/ITREXImplementationAuthority.json +1 -0
- package/out/IToken.sol/IToken.json +1 -0
- package/out/ITrustedIssuersRegistry.sol/ITrustedIssuersRegistry.json +1 -0
- package/out/IUtilityChecker.sol/IUtilityChecker.json +1 -0
- package/out/IdFactory.sol/IdFactory.json +1 -0
- package/out/Identity.sol/Identity.json +1 -0
- package/out/IdentityProxy.sol/IdentityProxy.json +1 -0
- package/out/IdentityRegistry.sol/IdentityRegistry.json +1 -0
- package/out/IdentityRegistryProxy.sol/IdentityRegistryProxy.json +1 -0
- package/out/IdentityRegistryStorage.sol/IdentityRegistryStorage.json +1 -0
- package/out/IdentityRegistryStorageProxy.sol/IdentityRegistryStorageProxy.json +1 -0
- package/out/ImplementationAuthority.sol/ImplementationAuthority.json +1 -0
- package/out/Initializable.sol/Initializable.json +1 -0
- package/out/InterfaceIdCalculator.sol/InterfaceIdCalculator.json +1 -0
- package/out/KeyPurposes.sol/KeyPurposes.json +1 -0
- package/out/KeyTypes.sol/KeyTypes.json +1 -0
- package/out/LowLevelCall.sol/LowLevelCall.json +1 -0
- package/out/Math.sol/Math.json +1 -0
- package/out/MessageHashUtils.sol/MessageHashUtils.json +1 -0
- package/out/ModularCompliance.sol/ModularCompliance.json +1 -0
- package/out/ModularComplianceProxy.sol/ModularComplianceProxy.json +1 -0
- package/out/ModuleNotPnP.sol/ModuleNotPnP.json +1 -0
- package/out/ModuleProxy.sol/ModuleProxy.json +1 -0
- package/out/MulticallUpgradeable.sol/MulticallUpgradeable.json +1 -0
- package/out/Nonces.sol/Nonces.json +1 -0
- package/out/NoncesUpgradeable.sol/NoncesUpgradeable.json +1 -0
- package/out/Ownable.sol/Ownable.json +1 -0
- package/out/Ownable2Step.sol/Ownable2Step.json +1 -0
- package/out/Ownable2StepUpgradeable.sol/Ownable2StepUpgradeable.json +1 -0
- package/out/OwnableUpgradeable.sol/OwnableUpgradeable.json +1 -0
- package/out/Panic.sol/Panic.json +1 -0
- package/out/Pausable.sol/Pausable.json +1 -0
- package/out/PausableUpgradeable.sol/PausableUpgradeable.json +1 -0
- package/out/Proxy.sol/Proxy.json +1 -0
- package/out/Roles.sol/Roles.json +1 -0
- package/out/SafeCast.sol/SafeCast.json +1 -0
- package/out/SafeERC20.sol/SafeERC20.json +1 -0
- package/out/ShortStrings.sol/ShortStrings.json +1 -0
- package/out/SignedMath.sol/SignedMath.json +1 -0
- package/out/SlotDerivation.sol/SlotDerivation.json +1 -0
- package/out/StdAssertions.sol/StdAssertions.json +1 -0
- package/out/StdChains.sol/StdChains.json +1 -0
- package/out/StdCheats.sol/StdCheats.json +1 -0
- package/out/StdCheats.sol/StdCheatsSafe.json +1 -0
- package/out/StdConstants.sol/StdConstants.json +1 -0
- package/out/StdError.sol/stdError.json +1 -0
- package/out/StdInvariant.sol/StdInvariant.json +1 -0
- package/out/StdJson.sol/stdJson.json +1 -0
- package/out/StdMath.sol/stdMath.json +1 -0
- package/out/StdStorage.sol/stdStorage.json +1 -0
- package/out/StdStorage.sol/stdStorageSafe.json +1 -0
- package/out/StdStyle.sol/StdStyle.json +1 -0
- package/out/StdToml.sol/stdToml.json +1 -0
- package/out/StdUtils.sol/StdUtils.json +1 -0
- package/out/Storage.sol/Storage.json +1 -0
- package/out/StorageSlot.sol/StorageSlot.json +1 -0
- package/out/Strings.sol/Strings.json +1 -0
- package/out/Structs.sol/Structs.json +1 -0
- package/out/TREXFactory.sol/TREXFactory.json +1 -0
- package/out/TREXGateway.sol/TREXGateway.json +1 -0
- package/out/TREXImplementationAuthority.sol/TREXImplementationAuthority.json +1 -0
- package/out/TestAgentRole.sol/TestAgentRole.json +1 -0
- package/out/TestAgentRoleUpgradeable.sol/TestAgentRoleUpgradeable.json +1 -0
- package/out/TestERC20.sol/TestERC20.json +1 -0
- package/out/TestModule.sol/TestModule.json +1 -0
- package/out/TestTREXFactory.sol/TestTREXFactory.json +1 -0
- package/out/Token.sol/Token.json +1 -0
- package/out/TokenProxy.sol/TokenProxy.json +1 -0
- package/out/TrustedIssuersRegistry.sol/TrustedIssuersRegistry.json +1 -0
- package/out/TrustedIssuersRegistryProxy.sol/TrustedIssuersRegistryProxy.json +1 -0
- package/out/UUPSUpgradeable.sol/UUPSUpgradeable.json +1 -0
- package/out/UtilityChecker.sol/UtilityChecker.json +1 -0
- package/out/UtilityCheckerProxy.sol/UtilityCheckerProxy.json +1 -0
- package/out/Utils.sol/Utils.json +1 -0
- package/out/Version.sol/Version.json +1 -0
- package/out/Vm.sol/Vm.json +1 -0
- package/out/Vm.sol/VmSafe.json +1 -0
- package/out/console.sol/console.json +1 -0
- package/out/draft-IERC1822.sol/IERC1822Proxiable.json +1 -0
- package/out/draft-IERC6093.sol/IERC1155Errors.json +1 -0
- package/out/draft-IERC6093.sol/IERC20Errors.json +1 -0
- package/out/draft-IERC6093.sol/IERC721Errors.json +1 -0
- package/out/libraries/Errors.sol/Errors.json +1 -0
- package/out/safeconsole.sol/safeconsole.json +1 -0
- package/package.json +47 -0
|
@@ -0,0 +1,239 @@
|
|
|
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
|
+
|
|
63
|
+
pragma solidity 0.8.30;
|
|
64
|
+
|
|
65
|
+
interface ITREXImplementationAuthority {
|
|
66
|
+
|
|
67
|
+
/// types
|
|
68
|
+
struct TREXContracts {
|
|
69
|
+
// address of token implementation contract
|
|
70
|
+
address tokenImplementation;
|
|
71
|
+
// address of ClaimTopicsRegistry implementation contract
|
|
72
|
+
address ctrImplementation;
|
|
73
|
+
// address of IdentityRegistry implementation contract
|
|
74
|
+
address irImplementation;
|
|
75
|
+
// address of IdentityRegistryStorage implementation contract
|
|
76
|
+
address irsImplementation;
|
|
77
|
+
// address of TrustedIssuersRegistry implementation contract
|
|
78
|
+
address tirImplementation;
|
|
79
|
+
// address of ModularCompliance implementation contract
|
|
80
|
+
address mcImplementation;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
struct Version {
|
|
84
|
+
// major version
|
|
85
|
+
uint8 major;
|
|
86
|
+
// minor version
|
|
87
|
+
uint8 minor;
|
|
88
|
+
// patch version
|
|
89
|
+
uint8 patch;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/// functions
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* @dev allows to fetch a TREX version available on the reference contract
|
|
96
|
+
* can be called only from auxiliary contracts, not on reference (main) contract
|
|
97
|
+
* throws if the version was already fetched
|
|
98
|
+
* adds the new version on the local storage
|
|
99
|
+
* allowing the update of contracts through the `useTREXVersion` afterwards
|
|
100
|
+
*/
|
|
101
|
+
function fetchVersion(Version calldata _version) external;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* @dev setter for _trexFactory variable
|
|
105
|
+
* _trexFactory is set at deployment for auxiliary contracts
|
|
106
|
+
* for main contract it must be set post-deployment as main IA is
|
|
107
|
+
* deployed before the TREXFactory.
|
|
108
|
+
* @param trexFactory the address of TREXFactory contract
|
|
109
|
+
* emits a TREXFactorySet event
|
|
110
|
+
* only Owner can call
|
|
111
|
+
* can be called only on main contract, auxiliary contracts cannot call
|
|
112
|
+
*/
|
|
113
|
+
function setTREXFactory(address trexFactory) external;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* @dev setter for _iaFactory variable
|
|
117
|
+
* _iaFactory is set at zero address for auxiliary contracts
|
|
118
|
+
* for main contract it can be set post-deployment or at deployment
|
|
119
|
+
* in the constructor
|
|
120
|
+
* @param iaFactory the address of IAFactory contract
|
|
121
|
+
* emits a IAFactorySet event
|
|
122
|
+
* only Owner can call
|
|
123
|
+
* can be called only on main contract, auxiliary contracts cannot call
|
|
124
|
+
*/
|
|
125
|
+
function setIAFactory(address iaFactory) external;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* @dev adds a new Version of TREXContracts to the mapping
|
|
129
|
+
* only callable on the reference contract
|
|
130
|
+
* only Owner can call this function
|
|
131
|
+
* @param _version the new version to add to the mapping
|
|
132
|
+
* @param _trex the list of contracts corresponding to the new version
|
|
133
|
+
* _trex cannot contain zero addresses
|
|
134
|
+
* emits a `TREXVersionAdded` event
|
|
135
|
+
*/
|
|
136
|
+
function addTREXVersion(Version calldata _version, TREXContracts calldata _trex) external;
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* @dev updates the current version in use by the proxies
|
|
140
|
+
* variation of the `useTREXVersion` allowing to use a new version
|
|
141
|
+
* this function calls in a single transaction the `addTREXVersion`
|
|
142
|
+
* and the `useTREXVersion` using an existing version
|
|
143
|
+
* @param _version the version to use
|
|
144
|
+
* @param _trex the set of contracts corresponding to the version
|
|
145
|
+
* only Owner can call (check performed in addTREXVersion)
|
|
146
|
+
* only reference contract can call (check performed in addTREXVersion)
|
|
147
|
+
* emits a `TREXVersionAdded`event
|
|
148
|
+
* emits a `VersionUpdated` event
|
|
149
|
+
*/
|
|
150
|
+
function addAndUseTREXVersion(Version calldata _version, TREXContracts calldata _trex) external;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* @dev updates the current version in use by the proxies
|
|
154
|
+
* @param _version the version to use
|
|
155
|
+
* reverts if _version is already used or if version does not exist
|
|
156
|
+
* only Owner can call
|
|
157
|
+
* emits a `VersionUpdated` event
|
|
158
|
+
*/
|
|
159
|
+
function useTREXVersion(Version calldata _version) external;
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* @dev change the implementationAuthority address of all proxy contracts linked to a given token
|
|
163
|
+
* only the owner of all proxy contracts can call this function
|
|
164
|
+
* @param _token the address of the token proxy
|
|
165
|
+
* @param _newImplementationAuthority the address of the new IA contract
|
|
166
|
+
* caller has to be owner of all contracts linked to the token and impacted by the change
|
|
167
|
+
* Set _newImplementationAuthority on zero address to deploy a new IA contract
|
|
168
|
+
* New IA contracts can only be deployed ONCE per token and only if current IA is the main IA
|
|
169
|
+
* if _newImplementationAuthority is not a new contract it must be using the same version
|
|
170
|
+
* as the current IA contract.
|
|
171
|
+
* calls `setImplementationAuthority` on all proxies linked to the token
|
|
172
|
+
* emits a `ImplementationAuthorityChanged` event
|
|
173
|
+
*/
|
|
174
|
+
function changeImplementationAuthority(address _token, address _newImplementationAuthority) external;
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* @dev getter function returning the current version of contracts used by proxies
|
|
178
|
+
*/
|
|
179
|
+
function getCurrentVersion() external view returns (Version memory);
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* @dev getter function returning the contracts corresponding to a version
|
|
183
|
+
* @param _version the version that contracts are requested for
|
|
184
|
+
*/
|
|
185
|
+
function getContracts(Version calldata _version) external view returns (TREXContracts memory);
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* @dev getter function returning address of reference TREX factory
|
|
189
|
+
*/
|
|
190
|
+
function getTREXFactory() external view returns (address);
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* @dev getter function returning address of token contract implementation
|
|
194
|
+
* currently used by the proxies using this TREXImplementationAuthority
|
|
195
|
+
*/
|
|
196
|
+
function getTokenImplementation() external view returns (address);
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* @dev getter function returning address of ClaimTopicsRegistry contract implementation
|
|
200
|
+
* currently used by the proxies using this TREXImplementationAuthority
|
|
201
|
+
*/
|
|
202
|
+
function getCTRImplementation() external view returns (address);
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* @dev getter function returning address of IdentityRegistry contract implementation
|
|
206
|
+
* currently used by the proxies using this TREXImplementationAuthority
|
|
207
|
+
*/
|
|
208
|
+
function getIRImplementation() external view returns (address);
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* @dev getter function returning address of IdentityRegistryStorage contract implementation
|
|
212
|
+
* currently used by the proxies using this TREXImplementationAuthority
|
|
213
|
+
*/
|
|
214
|
+
function getIRSImplementation() external view returns (address);
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* @dev getter function returning address of TrustedIssuersRegistry contract implementation
|
|
218
|
+
* currently used by the proxies using this TREXImplementationAuthority
|
|
219
|
+
*/
|
|
220
|
+
function getTIRImplementation() external view returns (address);
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* @dev getter function returning address of ModularCompliance contract implementation
|
|
224
|
+
* currently used by the proxies using this TREXImplementationAuthority
|
|
225
|
+
*/
|
|
226
|
+
function getMCImplementation() external view returns (address);
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* @dev returns true if the contract is the main contract
|
|
230
|
+
* returns false if the contract is an auxiliary contract
|
|
231
|
+
*/
|
|
232
|
+
function isReferenceContract() external view returns (bool);
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* @dev getter for reference contract address
|
|
236
|
+
*/
|
|
237
|
+
function getReferenceContract() external view returns (address);
|
|
238
|
+
|
|
239
|
+
}
|
|
@@ -0,0 +1,350 @@
|
|
|
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
|
+
|
|
63
|
+
pragma solidity 0.8.30;
|
|
64
|
+
|
|
65
|
+
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
|
|
66
|
+
import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
|
|
67
|
+
|
|
68
|
+
import { IERC3643IdentityRegistry } from "../../ERC-3643/IERC3643IdentityRegistry.sol";
|
|
69
|
+
import { ITREXFactory } from "../../factory/ITREXFactory.sol";
|
|
70
|
+
import { ErrorsLib } from "../../libraries/ErrorsLib.sol";
|
|
71
|
+
import { EventsLib } from "../../libraries/EventsLib.sol";
|
|
72
|
+
import { IERC173 } from "../../roles/IERC173.sol";
|
|
73
|
+
import { IToken } from "../../token/IToken.sol";
|
|
74
|
+
import { IProxy } from "../interface/IProxy.sol";
|
|
75
|
+
import { IIAFactory } from "./IIAFactory.sol";
|
|
76
|
+
import { ITREXImplementationAuthority } from "./ITREXImplementationAuthority.sol";
|
|
77
|
+
|
|
78
|
+
contract TREXImplementationAuthority is ITREXImplementationAuthority, Ownable, IERC165 {
|
|
79
|
+
|
|
80
|
+
/// variables
|
|
81
|
+
/// current version
|
|
82
|
+
Version private _currentVersion;
|
|
83
|
+
|
|
84
|
+
/// mapping to get contracts of each version
|
|
85
|
+
mapping(bytes32 => TREXContracts) private _contracts;
|
|
86
|
+
|
|
87
|
+
/// reference ImplementationAuthority used by the TREXFactory
|
|
88
|
+
bool private _reference;
|
|
89
|
+
|
|
90
|
+
/// address of TREXFactory contract
|
|
91
|
+
address private _trexFactory;
|
|
92
|
+
|
|
93
|
+
/// address of factory for TREXImplementationAuthority contracts
|
|
94
|
+
address private _iaFactory;
|
|
95
|
+
|
|
96
|
+
/// functions
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* @dev Constructor of the ImplementationAuthority contract
|
|
100
|
+
* @param referenceStatus boolean value determining if the contract
|
|
101
|
+
* is the main IA or an auxiliary contract
|
|
102
|
+
* @param trexFactory the address of TREXFactory referencing the main IA
|
|
103
|
+
* if `referenceStatus` is true then `trexFactory` at deployment is set
|
|
104
|
+
* on zero address. In that scenario, call `setTREXFactory` post-deployment
|
|
105
|
+
* @param iaFactory the address for the factory of IA contracts
|
|
106
|
+
* emits `ImplementationAuthoritySet` event
|
|
107
|
+
* emits a `IAFactorySet` event
|
|
108
|
+
*/
|
|
109
|
+
constructor(bool referenceStatus, address trexFactory, address iaFactory) Ownable(msg.sender) {
|
|
110
|
+
_reference = referenceStatus;
|
|
111
|
+
_trexFactory = trexFactory;
|
|
112
|
+
_iaFactory = iaFactory;
|
|
113
|
+
emit EventsLib.ImplementationAuthoritySetWithStatus(referenceStatus, trexFactory);
|
|
114
|
+
emit EventsLib.IAFactorySet(iaFactory);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* @dev See {ITREXImplementationAuthority-setTREXFactory}.
|
|
119
|
+
*/
|
|
120
|
+
function setTREXFactory(address trexFactory) external override onlyOwner {
|
|
121
|
+
require(
|
|
122
|
+
isReferenceContract() && ITREXFactory(trexFactory).getImplementationAuthority() == address(this),
|
|
123
|
+
ErrorsLib.OnlyReferenceContractCanCall()
|
|
124
|
+
);
|
|
125
|
+
_trexFactory = trexFactory;
|
|
126
|
+
emit EventsLib.TREXFactorySet(trexFactory);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* @dev See {ITREXImplementationAuthority-setIAFactory}.
|
|
131
|
+
*/
|
|
132
|
+
function setIAFactory(address iaFactory) external override onlyOwner {
|
|
133
|
+
require(
|
|
134
|
+
isReferenceContract() && ITREXFactory(_trexFactory).getImplementationAuthority() == address(this),
|
|
135
|
+
ErrorsLib.OnlyReferenceContractCanCall()
|
|
136
|
+
);
|
|
137
|
+
_iaFactory = iaFactory;
|
|
138
|
+
emit EventsLib.IAFactorySet(iaFactory);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* @dev See {ITREXImplementationAuthority-useTREXVersion}.
|
|
143
|
+
*/
|
|
144
|
+
function addAndUseTREXVersion(Version calldata _version, TREXContracts calldata _trex) external override {
|
|
145
|
+
_addTREXVersion(_version, _trex);
|
|
146
|
+
_useTREXVersion(_version);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* @dev See {ITREXImplementationAuthority-fetchVersion}.
|
|
151
|
+
*/
|
|
152
|
+
function fetchVersion(Version calldata _version) external override {
|
|
153
|
+
require(!isReferenceContract(), ErrorsLib.CannotCallOnReferenceContract());
|
|
154
|
+
require(
|
|
155
|
+
_contracts[_versionToBytes(_version)].tokenImplementation == address(0), ErrorsLib.VersionAlreadyFetched()
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
_contracts[_versionToBytes(_version)] =
|
|
159
|
+
ITREXImplementationAuthority(getReferenceContract()).getContracts(_version);
|
|
160
|
+
emit EventsLib.TREXVersionFetched(_version, _contracts[_versionToBytes(_version)]);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* @dev See {ITREXImplementationAuthority-changeImplementationAuthority}.
|
|
165
|
+
*/
|
|
166
|
+
// solhint-disable-next-line code-complexity, function-max-lines
|
|
167
|
+
function changeImplementationAuthority(address _token, address _newImplementationAuthority) external override {
|
|
168
|
+
require(_token != address(0), ErrorsLib.ZeroAddress());
|
|
169
|
+
require(
|
|
170
|
+
_newImplementationAuthority != address(0) || isReferenceContract(), ErrorsLib.OnlyReferenceContractCanCall()
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
address _ir = address(IToken(_token).identityRegistry());
|
|
174
|
+
address _mc = address(IToken(_token).compliance());
|
|
175
|
+
address _irs = address(IERC3643IdentityRegistry(_ir).identityStorage());
|
|
176
|
+
address _ctr = address(IERC3643IdentityRegistry(_ir).topicsRegistry());
|
|
177
|
+
address _tir = address(IERC3643IdentityRegistry(_ir).issuersRegistry());
|
|
178
|
+
|
|
179
|
+
// calling this function requires ownership of ALL contracts of the T-REX suite
|
|
180
|
+
require(
|
|
181
|
+
Ownable(_token).owner() == msg.sender && Ownable(_ir).owner() == msg.sender
|
|
182
|
+
&& Ownable(_mc).owner() == msg.sender && Ownable(_irs).owner() == msg.sender
|
|
183
|
+
&& Ownable(_ctr).owner() == msg.sender && Ownable(_tir).owner() == msg.sender,
|
|
184
|
+
ErrorsLib.CallerNotOwnerOfAllImpactedContracts()
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
if (_newImplementationAuthority == address(0)) {
|
|
188
|
+
_newImplementationAuthority = IIAFactory(_iaFactory).deployIA(_token);
|
|
189
|
+
} else {
|
|
190
|
+
require(
|
|
191
|
+
_versionToBytes(ITREXImplementationAuthority(_newImplementationAuthority).getCurrentVersion())
|
|
192
|
+
== _versionToBytes(_currentVersion),
|
|
193
|
+
ErrorsLib.VersionOfNewIAMustBeTheSameAsCurrentIA()
|
|
194
|
+
);
|
|
195
|
+
require(
|
|
196
|
+
!ITREXImplementationAuthority(_newImplementationAuthority).isReferenceContract()
|
|
197
|
+
|| _newImplementationAuthority == getReferenceContract(),
|
|
198
|
+
ErrorsLib.NewIAIsNotAReferenceContract()
|
|
199
|
+
);
|
|
200
|
+
require(
|
|
201
|
+
IIAFactory(_iaFactory).deployedByFactory(_newImplementationAuthority)
|
|
202
|
+
|| _newImplementationAuthority == getReferenceContract(),
|
|
203
|
+
ErrorsLib.InvalidImplementationAuthority()
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
IProxy(_token).setImplementationAuthority(_newImplementationAuthority);
|
|
208
|
+
IProxy(_ir).setImplementationAuthority(_newImplementationAuthority);
|
|
209
|
+
IProxy(_mc).setImplementationAuthority(_newImplementationAuthority);
|
|
210
|
+
IProxy(_ctr).setImplementationAuthority(_newImplementationAuthority);
|
|
211
|
+
IProxy(_tir).setImplementationAuthority(_newImplementationAuthority);
|
|
212
|
+
// IRS can be shared by multiple tokens, and therefore could have been updated already
|
|
213
|
+
if (IProxy(_irs).getImplementationAuthority() == address(this)) {
|
|
214
|
+
IProxy(_irs).setImplementationAuthority(_newImplementationAuthority);
|
|
215
|
+
}
|
|
216
|
+
emit EventsLib.ImplementationAuthorityChanged(_token, _newImplementationAuthority);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* @dev See {ITREXImplementationAuthority-getCurrentVersion}.
|
|
221
|
+
*/
|
|
222
|
+
function getCurrentVersion() external view override returns (Version memory) {
|
|
223
|
+
return _currentVersion;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* @dev See {ITREXImplementationAuthority-getContracts}.
|
|
228
|
+
*/
|
|
229
|
+
function getContracts(Version calldata _version) external view override returns (TREXContracts memory) {
|
|
230
|
+
return _contracts[_versionToBytes(_version)];
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* @dev See {ITREXImplementationAuthority-getTREXFactory}.
|
|
235
|
+
*/
|
|
236
|
+
function getTREXFactory() external view override returns (address) {
|
|
237
|
+
return _trexFactory;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* @dev See {ITREXImplementationAuthority-getTokenImplementation}.
|
|
242
|
+
*/
|
|
243
|
+
function getTokenImplementation() external view override returns (address) {
|
|
244
|
+
return _contracts[_versionToBytes(_currentVersion)].tokenImplementation;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* @dev See {ITREXImplementationAuthority-getCTRImplementation}.
|
|
249
|
+
*/
|
|
250
|
+
function getCTRImplementation() external view override returns (address) {
|
|
251
|
+
return _contracts[_versionToBytes(_currentVersion)].ctrImplementation;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* @dev See {ITREXImplementationAuthority-getIRImplementation}.
|
|
256
|
+
*/
|
|
257
|
+
function getIRImplementation() external view override returns (address) {
|
|
258
|
+
return _contracts[_versionToBytes(_currentVersion)].irImplementation;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* @dev See {ITREXImplementationAuthority-getIRSImplementation}.
|
|
263
|
+
*/
|
|
264
|
+
function getIRSImplementation() external view override returns (address) {
|
|
265
|
+
return _contracts[_versionToBytes(_currentVersion)].irsImplementation;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* @dev See {ITREXImplementationAuthority-getTIRImplementation}.
|
|
270
|
+
*/
|
|
271
|
+
function getTIRImplementation() external view override returns (address) {
|
|
272
|
+
return _contracts[_versionToBytes(_currentVersion)].tirImplementation;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* @dev See {ITREXImplementationAuthority-getMCImplementation}.
|
|
277
|
+
*/
|
|
278
|
+
function getMCImplementation() external view override returns (address) {
|
|
279
|
+
return _contracts[_versionToBytes(_currentVersion)].mcImplementation;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* @dev See {ITREXImplementationAuthority-addTREXVersion}.
|
|
284
|
+
*/
|
|
285
|
+
function addTREXVersion(Version calldata _version, TREXContracts calldata _trex) public override onlyOwner {
|
|
286
|
+
_addTREXVersion(_version, _trex);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
function _addTREXVersion(Version calldata _version, TREXContracts calldata _trex) internal {
|
|
290
|
+
require(isReferenceContract(), ErrorsLib.OnlyReferenceContractCanCall());
|
|
291
|
+
require(
|
|
292
|
+
_contracts[_versionToBytes(_version)].tokenImplementation == address(0), ErrorsLib.VersionAlreadyExists()
|
|
293
|
+
);
|
|
294
|
+
|
|
295
|
+
require(
|
|
296
|
+
_trex.ctrImplementation != address(0) && _trex.irImplementation != address(0)
|
|
297
|
+
&& _trex.irsImplementation != address(0) && _trex.mcImplementation != address(0)
|
|
298
|
+
&& _trex.tirImplementation != address(0) && _trex.tokenImplementation != address(0),
|
|
299
|
+
ErrorsLib.ZeroAddress()
|
|
300
|
+
);
|
|
301
|
+
|
|
302
|
+
_contracts[_versionToBytes(_version)] = _trex;
|
|
303
|
+
emit EventsLib.TREXVersionAdded(_version, _trex);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* @dev See {ITREXImplementationAuthority-useTREXVersion}.
|
|
308
|
+
*/
|
|
309
|
+
function useTREXVersion(Version calldata _version) public override onlyOwner {
|
|
310
|
+
_useTREXVersion(_version);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
function _useTREXVersion(Version calldata _version) internal {
|
|
314
|
+
require(_versionToBytes(_version) != _versionToBytes(_currentVersion), ErrorsLib.VersionAlreadyInUse());
|
|
315
|
+
require(_contracts[_versionToBytes(_version)].tokenImplementation != address(0), ErrorsLib.NonExistingVersion());
|
|
316
|
+
|
|
317
|
+
_currentVersion = _version;
|
|
318
|
+
emit EventsLib.VersionUpdated(_version);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* @dev See {ITREXImplementationAuthority-isReferenceContract}.
|
|
323
|
+
*/
|
|
324
|
+
function isReferenceContract() public view override returns (bool) {
|
|
325
|
+
return _reference;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* @dev See {ITREXImplementationAuthority-getReferenceContract}.
|
|
330
|
+
*/
|
|
331
|
+
function getReferenceContract() public view override returns (address) {
|
|
332
|
+
return ITREXFactory(_trexFactory).getImplementationAuthority();
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* @dev See {IERC165-supportsInterface}.
|
|
337
|
+
*/
|
|
338
|
+
function supportsInterface(bytes4 interfaceId) public pure virtual override returns (bool) {
|
|
339
|
+
return interfaceId == type(ITREXImplementationAuthority).interfaceId || interfaceId == type(IERC173).interfaceId
|
|
340
|
+
|| interfaceId == type(IERC165).interfaceId;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* @dev casting function Version => bytes to allow compare values easier
|
|
345
|
+
*/
|
|
346
|
+
function _versionToBytes(Version memory _version) private pure returns (bytes32) {
|
|
347
|
+
return bytes32(keccak256(abi.encodePacked(_version.major, _version.minor, _version.patch)));
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
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
|
+
|
|
63
|
+
pragma solidity 0.8.30;
|
|
64
|
+
|
|
65
|
+
interface IProxy {
|
|
66
|
+
|
|
67
|
+
/// functions
|
|
68
|
+
function setImplementationAuthority(address _newImplementationAuthority) external;
|
|
69
|
+
|
|
70
|
+
function getImplementationAuthority() external view returns (address);
|
|
71
|
+
|
|
72
|
+
}
|