Files
erc-3643/contracts/utils/InterfaceIdCalculator.sol
Mohamad HammoudandGitHub 94182deb9c ✨ BT-1418 integrate foundry & hardhat + migrating solidity tests (#76)
* ✨ 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
2025-12-31 16:58:16 +08:00

220 lines
9.1 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;
import "../compliance/modular/IModularCompliance.sol";
import "../compliance/modular/modules/IModule.sol";
import "../factory/ITREXGateway.sol";
import "../proxy/authority/IIAFactory.sol";
import "../proxy/authority/ITREXImplementationAuthority.sol";
import "../registry/interface/IClaimTopicsRegistry.sol";
import "../registry/interface/IIdentityRegistry.sol";
import "../registry/interface/IIdentityRegistryStorage.sol";
import "../registry/interface/ITrustedIssuersRegistry.sol";
import "../roles/IERC173.sol";
import "../token/IToken.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol";
import "@openzeppelin/contracts/utils/introspection/IERC165.sol";
contract InterfaceIdCalculator {
/**
* @dev Returns the interface ID for the IERC20 interface.
* IERC20 interface ID is 0x36372b07
*/
function getIERC20InterfaceId() external pure returns (bytes4) {
return type(IERC20).interfaceId;
}
/**
* @dev Returns the interface ID for the IERC20Permit interface.
* IERC20Permit interface ID is 0x0b4c7e4d
*/
function getIERC20PermitInterfaceId() external pure returns (bytes4) {
return type(IERC20Permit).interfaceId;
}
/**
* @dev Returns the interface ID for the IERC3643 interface.
* IERC3643 interface ID is 0xb97d944c
*/
function getIERC3643InterfaceId() external pure returns (bytes4) {
return type(IERC3643).interfaceId;
}
/**
* @dev Returns the interface ID for the IToken interface.
* IToken interface ID is 0x5c0cda7e
*/
function getITokenInterfaceId() external pure returns (bytes4) {
return type(IToken).interfaceId;
}
/**
* @dev Returns the interface ID for the IERC173 interface.
* IERC173 interface ID is 0x7f5828d0
*/
function getIERC173InterfaceId() external pure returns (bytes4) {
return type(IERC173).interfaceId;
}
/**
* @dev Returns the interface ID for the IERC165 interface.
* IERC165 interface ID is 0x01ffc9a7
*/
function getIERC165InterfaceId() external pure returns (bytes4) {
return type(IERC165).interfaceId;
}
/**
* @dev Returns the interface ID for the IERC3643ClaimTopicsRegistry interface.
* IERC3643ClaimTopicsRegistry interface ID is 0x10928b13
*/
function getIERC3643ClaimTopicsRegistryInterfaceId() external pure returns (bytes4) {
return type(IERC3643ClaimTopicsRegistry).interfaceId;
}
/**
* @dev Returns the interface ID for the IIdentityRegistry interface.
* IIdentityRegistry interface ID is 0xacb7b4db
*/
function getIIdentityRegistryInterfaceId() external pure returns (bytes4) {
return type(IIdentityRegistry).interfaceId;
}
/**
* @dev Returns the interface ID for the IERC3643IdentityRegistry interface.
* IERC3643IdentityRegistry interface ID is 0x8ff89f73
*/
function getIERC3643IdentityRegistryInterfaceId() external pure returns (bytes4) {
return type(IERC3643IdentityRegistry).interfaceId;
}
/**
* @dev Returns the interface ID for the IERC3643IdentityRegistryStorage interface.
* IERC3643IdentityRegistryStorage interface ID is 0x57defe0d
*/
function getIERC3643IdentityRegistryStorageInterfaceId() external pure returns (bytes4) {
return type(IERC3643IdentityRegistryStorage).interfaceId;
}
/**
* @dev Returns the interface ID for the IERC3643TrustedIssuersRegistry interface.
* IERC3643TrustedIssuersRegistry interface ID is 0xb0f773b8
*/
function getIERC3643TrustedIssuersRegistryInterfaceId() external pure returns (bytes4) {
return type(IERC3643TrustedIssuersRegistry).interfaceId;
}
/**
* @dev Returns the interface ID for the ITREXImplementationAuthority interface.
* ITREXImplementationAuthority interface ID is 0x62dd69be
*/
function getITREXImplementationAuthorityInterfaceId() external pure returns (bytes4) {
return type(ITREXImplementationAuthority).interfaceId;
}
/**
* @dev Returns the interface ID for the IIAFactory interface.
* IIAFactory interface ID is 0x8c76edf0
*/
function getIIAFactoryInterfaceId() external pure returns (bytes4) {
return type(IIAFactory).interfaceId;
}
/**
* @dev Returns the interface ID for the ITREXGateway interface.
* ITREXGateway interface ID is 0x80e89461
*/
function getITREXGatewayInterfaceId() external pure returns (bytes4) {
return type(ITREXGateway).interfaceId;
}
/**
* @dev Returns the interface ID for the IModularCompliance interface.
* IModularCompliance interface ID is 0x4d6b83d6
*/
function getIModularComplianceInterfaceId() external pure returns (bytes4) {
return type(IModularCompliance).interfaceId;
}
/**
* @dev Returns the interface ID for the IERC3643Compliance interface.
* IERC3643Compliance interface ID is 0x3144991c
*/
function getIERC3643ComplianceInterfaceId() external pure returns (bytes4) {
return type(IERC3643Compliance).interfaceId;
}
/**
* @dev Returns the interface ID for the IModule interface.
* IModule interface ID is 0xb795d01e
*/
function getIModuleInterfaceId() external pure returns (bytes4) {
return type(IModule).interfaceId;
}
}