mirror of
https://github.com/luxfi/erc-3643.git
synced 2026-10-30 16:58:28 +00:00
* ✨ integrate foundry alongside hardhat for dual testing framework - Add foundry.toml configuration - Reorganize test structure: test/forge/ and test/hardhat/ - Add Foundry scripts to package.json (build:forge, test:forge, coverage:forge) - Update hardhat.config.ts with evmVersion for compatibility - Add GitHub workflows and coverage scripts from template - Add Husky hooks (pre-commit, post-checkout, post-merge) - Add .vscode/settings.json for better IDE support - Disable coverage checks until tests are migrated (commented with TODO) This migration is based on TokenySolutions/contracts-template and enables gradual migration of tests from Hardhat (TypeScript) to Foundry (Solidity). Related to: BT-1418 * ✅ trex factory tests * ⚰️ remove trex suit * feat(forge): reorganize Foundry test structure and sync GitHub workflows - Move TREXFactorySetup to helpers folder - Rename TREXSuite.t.sol to TREXFactory.t.sol - Update fixture to inherit from Test for proper Foundry pattern - Transfer ownership to deployer address to match Hardhat behavior - Sync GitHub workflows with package.json scripts - Update test.yml to use npm run build and npm run test - Update push_checking.yml to use unified npm run lint - Update forge_coverage.sh to use npm run coverage * fix(ci): install Foundry and skip husky in push_checking workflow - Add Foundry installation step before npm ci - Set HUSKY=0 to skip husky setup in CI environment - Fixes 'forge: not found' error during npm prepare script * 🔧 keep hardhat settings * ✅ create addressess directly * ✅ removed test_StandardAddressesSet * ✅ fix lint * 💡 removed title natspecs * ✅ migrated trex factort tests * ✅ added test module multicall * ✅ migrate agent role test * ✅ migrate claim topics registry * ✅ migrated trusted issuer registry * ✅ migrate identity registry storage * ✅ migrated identity registry tests * ✅ migrated implementation authority test * ✅ migrated token agen restrictions * ✅ migrated token information test * ✅ migrated token recover * ✅ migrated token permit * ✅ migrated token transfer * ✅ migrated utilities upgrade * ✅ migrated freeze check * ✅ migrated compliance check in utilities test * ✅ migrated eligibility check * ✅ migrated transfer check in utilities * ✅ migrated compliance test * ✅ migrated gateway tests * 🔥 removed already defined events * 🗑️ imported Initializable error from openzeppelin * ➕ added already defined events and errors * ✅ added base test token * ✅ used idFactory * ♻️ refactored compliance test * ⚰️ remoced useless vm.prank * 🔧 deleted hardhat configurations * 💚 fixed ci * refactor: remove 100% coverage requirement from forge_coverage.sh - Remove strict 100% coverage checks that were causing workflow failures - Script now only generates and displays coverage report without failing - Aligns with previous behavior where coverage was informational only * ✅ resolve getVerifiedDetails * ✅ applied _getEligibility and remove via-ir from foundry.toml * ✅ cover tokena and token permit * ✅ cover compliance * ✅ cover identity registry * ✅ increased trex gateway coverage * ✅ increase coverage for trex factory * ✅ increased AbstractModuleUpgradeable.sol coverage * ⚰️ removed abstract module * 🔧 updted generate coverage * ✅ coverage 100% identity registry * ✅ coverage 100% trex gate way * ✅ coverage trex factory * ✅ coverage 100% AbstractModuleUpgradeable by test module * ✅ coverage IAFactory.sol * ✅ coverage 100% for implementation authority * ✅ coverage 1005 abstract proxy * ✅ coverage 100% claim topic registry * ✅ coverage 100% identity registry storage * ✅ coverage 100% modular compliance proxy * ✅ coverage trusted issuer registry proxy * ✅ coverage 100% identity registry * ✅ coverage 100% token proxy * 🚨 resolve linter in token information * ✅ coverage 100% roles * 🚨 resolve linter * 🔧 added no coverage for test, _testContracts and utils * ✅ coverage 100% for token.sol * ✅ coverage 100% for modular compliance * ✅ coverage 100% trusted issuer registry * 🔧 restore package.json * ✅ coverage 100% for utlity checker * 🚨 fix linter
278 lines
13 KiB
Solidity
278 lines
13 KiB
Solidity
// SPDX-License-Identifier: GPL-3.0
|
|
//
|
|
// :+#####%%%%%%%%%%%%%%+
|
|
// .-*@@@%+.:+%@@@@@%%#***%@@%=
|
|
// :=*%@@@#=. :#@@% *@@@%=
|
|
// .-+*%@%*-.:+%@@@@@@+. -*+: .=#. :%@@@%-
|
|
// :=*@@@@%%@@@@@@@@@%@@@- .=#@@@%@%= =@@@@#.
|
|
// -=+#%@@%#*=:. :%@@@@%. -*@@#*@@@@@@@#=:- *@@@@+
|
|
// =@@%=:. :=: *@@@@@%#- =%*%@@@@#+-. =+ :%@@@%-
|
|
// -@@%. .+@@@ =+=-. @@#- +@@@%- =@@@@%:
|
|
// :@@@. .+@@#%: : .=*=-::.-%@@@+*@@= +@@@@#.
|
|
// %@@: +@%%* =%@@@@@@@@@@@#. .*@%- +@@@@*.
|
|
// #@@= .+@@@@%:=*@@@@@- :%@%: .*@@@@+
|
|
// *@@* +@@@#-@@%-:%@@* +@@#. :%@@@@-
|
|
// -@@% .:-=++*##%%%@@@@@@@@@@@@*. :@+.@@@%: .#@@+ =@@@@#:
|
|
// .@@@*-+*#%%%@@@@@@@@@@@@@@@@%%#**@@%@@@. *@=*@@# :#@%= .#@@@@#-
|
|
// -%@@@@@@@@@@@@@@@*+==-:-@@@= *@# .#@*-=*@@@@%= -%@@@* =@@@@@%-
|
|
// -+%@@@#. %@%%= -@@:+@: -@@* *@@*-:: -%@@%=. .*@@@@@#
|
|
// *@@@* +@* *@@##@@- #@*@@+ -@@= . :+@@@#: .-+@@@%+-
|
|
// +@@@%*@@:..=@@@@* .@@@* .#@#. .=+- .=%@@@*. :+#@@@@*=:
|
|
// =@@@@%@@@@@@@@@@@@@@@@@@@@@@%- :+#*. :*@@@%=. .=#@@@@%+:
|
|
// .%@@= ..... .=#@@+. .#@@@*: -*%@@@@%+.
|
|
// +@@#+===---:::... .=%@@*- +@@@+. -*@@@@@%+.
|
|
// -@@@@@@@@@@@@@@@@@@@@@@%@@@@= -@@@+ -#@@@@@#=.
|
|
// ..:::---===+++***###%%%@@@#- .#@@+ -*@@@@@#=.
|
|
// @@@@@@+. +@@*. .+@@@@@%=.
|
|
// -@@@@@= =@@%: -#@@@@%+.
|
|
// +@@@@@. =@@@= .+@@@@@*:
|
|
// #@@@@#:%@@#. :*@@@@#-
|
|
// @@@@@%@@@= :#@@@@+.
|
|
// :@@@@@@@#.:#@@@%-
|
|
// +@@@@@@-.*@@@*:
|
|
// #@@@@#.=@@@+.
|
|
// @@@@+-%@%=
|
|
// :@@@#%@%=
|
|
// +@@@@%-
|
|
// :#%%=
|
|
//
|
|
/**
|
|
* NOTICE
|
|
*
|
|
* The T-REX software is licensed under a proprietary license or the GPL v.3.
|
|
* If you choose to receive it under the GPL v.3 license, the following applies:
|
|
* T-REX is a suite of smart contracts implementing the ERC-3643 standard and
|
|
* developed by Tokeny to manage and transfer financial assets on EVM blockchains
|
|
*
|
|
* Copyright (C) 2025, Tokeny sàrl.
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
pragma solidity 0.8.30;
|
|
|
|
/// events
|
|
|
|
/// @dev Event emitted when a new TREX version is added to the contract memory.
|
|
/// @param _version Version details.
|
|
/// @param _trex Address of contract for this version.
|
|
event TREXVersionAdded(
|
|
ITREXImplementationAuthority.Version indexed _version, ITREXImplementationAuthority.TREXContracts indexed _trex
|
|
);
|
|
|
|
/// @dev Event emitted when a new TREX version is fetched from reference contract by auxiliary contract.
|
|
/// @param _version Version details.
|
|
/// @param _trex Address of contract for this version.
|
|
event TREXVersionFetched(
|
|
ITREXImplementationAuthority.Version indexed _version, ITREXImplementationAuthority.TREXContracts indexed _trex
|
|
);
|
|
|
|
/// @dev Event emitted when the current version is updated.
|
|
/// @param _version Version details.
|
|
event VersionUpdated(ITREXImplementationAuthority.Version indexed _version);
|
|
|
|
/// @dev Event emitted by the constructor when the IA is deployed.
|
|
/// @param _referenceStatus Main implementation authority or auxiliary contract.
|
|
/// @param _trexFactory Address of trexFactory contract.
|
|
event ImplementationAuthoritySet(bool _referenceStatus, address _trexFactory);
|
|
|
|
/// @dev Event emitted when the TREX factory address is set.
|
|
/// @param _trexFactory Address of TRexFactory contract.
|
|
event TREXFactorySet(address indexed _trexFactory);
|
|
|
|
/// @dev Event emitted when the IA factory address is set.
|
|
/// @param _iaFactory Address of implementation authority contract.
|
|
event IAFactorySet(address indexed _iaFactory);
|
|
|
|
/// @dev Event emitted when a token issuer decides to change current IA for a new one.
|
|
/// @param _token Address of the token proxy contract.
|
|
/// @param _newImplementationAuthority Address of the new implementation authorirty contract.
|
|
event ImplementationAuthorityChanged(address indexed _token, address indexed _newImplementationAuthority);
|
|
|
|
interface ITREXImplementationAuthority {
|
|
|
|
/// types
|
|
struct TREXContracts {
|
|
// address of token implementation contract
|
|
address tokenImplementation;
|
|
// address of ClaimTopicsRegistry implementation contract
|
|
address ctrImplementation;
|
|
// address of IdentityRegistry implementation contract
|
|
address irImplementation;
|
|
// address of IdentityRegistryStorage implementation contract
|
|
address irsImplementation;
|
|
// address of TrustedIssuersRegistry implementation contract
|
|
address tirImplementation;
|
|
// address of ModularCompliance implementation contract
|
|
address mcImplementation;
|
|
}
|
|
|
|
struct Version {
|
|
// major version
|
|
uint8 major;
|
|
// minor version
|
|
uint8 minor;
|
|
// patch version
|
|
uint8 patch;
|
|
}
|
|
|
|
/// functions
|
|
|
|
/**
|
|
* @dev allows to fetch a TREX version available on the reference contract
|
|
* can be called only from auxiliary contracts, not on reference (main) contract
|
|
* throws if the version was already fetched
|
|
* adds the new version on the local storage
|
|
* allowing the update of contracts through the `useTREXVersion` afterwards
|
|
*/
|
|
function fetchVersion(Version calldata _version) external;
|
|
|
|
/**
|
|
* @dev setter for _trexFactory variable
|
|
* _trexFactory is set at deployment for auxiliary contracts
|
|
* for main contract it must be set post-deployment as main IA is
|
|
* deployed before the TREXFactory.
|
|
* @param trexFactory the address of TREXFactory contract
|
|
* emits a TREXFactorySet event
|
|
* only Owner can call
|
|
* can be called only on main contract, auxiliary contracts cannot call
|
|
*/
|
|
function setTREXFactory(address trexFactory) external;
|
|
|
|
/**
|
|
* @dev setter for _iaFactory variable
|
|
* _iaFactory is set at zero address for auxiliary contracts
|
|
* for main contract it can be set post-deployment or at deployment
|
|
* in the constructor
|
|
* @param iaFactory the address of IAFactory contract
|
|
* emits a IAFactorySet event
|
|
* only Owner can call
|
|
* can be called only on main contract, auxiliary contracts cannot call
|
|
*/
|
|
function setIAFactory(address iaFactory) external;
|
|
|
|
/**
|
|
* @dev adds a new Version of TREXContracts to the mapping
|
|
* only callable on the reference contract
|
|
* only Owner can call this function
|
|
* @param _version the new version to add to the mapping
|
|
* @param _trex the list of contracts corresponding to the new version
|
|
* _trex cannot contain zero addresses
|
|
* emits a `TREXVersionAdded` event
|
|
*/
|
|
function addTREXVersion(Version calldata _version, TREXContracts calldata _trex) external;
|
|
|
|
/**
|
|
* @dev updates the current version in use by the proxies
|
|
* variation of the `useTREXVersion` allowing to use a new version
|
|
* this function calls in a single transaction the `addTREXVersion`
|
|
* and the `useTREXVersion` using an existing version
|
|
* @param _version the version to use
|
|
* @param _trex the set of contracts corresponding to the version
|
|
* only Owner can call (check performed in addTREXVersion)
|
|
* only reference contract can call (check performed in addTREXVersion)
|
|
* emits a `TREXVersionAdded`event
|
|
* emits a `VersionUpdated` event
|
|
*/
|
|
function addAndUseTREXVersion(Version calldata _version, TREXContracts calldata _trex) external;
|
|
|
|
/**
|
|
* @dev updates the current version in use by the proxies
|
|
* @param _version the version to use
|
|
* reverts if _version is already used or if version does not exist
|
|
* only Owner can call
|
|
* emits a `VersionUpdated` event
|
|
*/
|
|
function useTREXVersion(Version calldata _version) external;
|
|
|
|
/**
|
|
* @dev change the implementationAuthority address of all proxy contracts linked to a given token
|
|
* only the owner of all proxy contracts can call this function
|
|
* @param _token the address of the token proxy
|
|
* @param _newImplementationAuthority the address of the new IA contract
|
|
* caller has to be owner of all contracts linked to the token and impacted by the change
|
|
* Set _newImplementationAuthority on zero address to deploy a new IA contract
|
|
* New IA contracts can only be deployed ONCE per token and only if current IA is the main IA
|
|
* if _newImplementationAuthority is not a new contract it must be using the same version
|
|
* as the current IA contract.
|
|
* calls `setImplementationAuthority` on all proxies linked to the token
|
|
* emits a `ImplementationAuthorityChanged` event
|
|
*/
|
|
function changeImplementationAuthority(address _token, address _newImplementationAuthority) external;
|
|
|
|
/**
|
|
* @dev getter function returning the current version of contracts used by proxies
|
|
*/
|
|
function getCurrentVersion() external view returns (Version memory);
|
|
|
|
/**
|
|
* @dev getter function returning the contracts corresponding to a version
|
|
* @param _version the version that contracts are requested for
|
|
*/
|
|
function getContracts(Version calldata _version) external view returns (TREXContracts memory);
|
|
|
|
/**
|
|
* @dev getter function returning address of reference TREX factory
|
|
*/
|
|
function getTREXFactory() external view returns (address);
|
|
|
|
/**
|
|
* @dev getter function returning address of token contract implementation
|
|
* currently used by the proxies using this TREXImplementationAuthority
|
|
*/
|
|
function getTokenImplementation() external view returns (address);
|
|
|
|
/**
|
|
* @dev getter function returning address of ClaimTopicsRegistry contract implementation
|
|
* currently used by the proxies using this TREXImplementationAuthority
|
|
*/
|
|
function getCTRImplementation() external view returns (address);
|
|
|
|
/**
|
|
* @dev getter function returning address of IdentityRegistry contract implementation
|
|
* currently used by the proxies using this TREXImplementationAuthority
|
|
*/
|
|
function getIRImplementation() external view returns (address);
|
|
|
|
/**
|
|
* @dev getter function returning address of IdentityRegistryStorage contract implementation
|
|
* currently used by the proxies using this TREXImplementationAuthority
|
|
*/
|
|
function getIRSImplementation() external view returns (address);
|
|
|
|
/**
|
|
* @dev getter function returning address of TrustedIssuersRegistry contract implementation
|
|
* currently used by the proxies using this TREXImplementationAuthority
|
|
*/
|
|
function getTIRImplementation() external view returns (address);
|
|
|
|
/**
|
|
* @dev getter function returning address of ModularCompliance contract implementation
|
|
* currently used by the proxies using this TREXImplementationAuthority
|
|
*/
|
|
function getMCImplementation() external view returns (address);
|
|
|
|
/**
|
|
* @dev returns true if the contract is the main contract
|
|
* returns false if the contract is an auxiliary contract
|
|
*/
|
|
function isReferenceContract() external view returns (bool);
|
|
|
|
/**
|
|
* @dev getter for reference contract address
|
|
*/
|
|
function getReferenceContract() external view returns (address);
|
|
|
|
}
|