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 * 💥 added create 3 from createx library * 🙈 added dependencies folder and out to gitignore * 🚨 forge fmt linting * 💥 duplicated createX * refactor: organize CreateX files into utils/createx subfolder * 🚨 fix linting * 💥 added suffix contract type salt * ✅ added createX computeCreate3Address tests * 💥 updated saltBytes * ✅ tested multiple chains * 💥 immutable create3 factory variable * 💥 updated create3 sources * 💥 added fork links * ⚰️ removed unused code from createx * 🔧 added createx dependency * 💥 resolve dependency * 💥 added "@" to dependency * 💥 added deployment on different chains * 💥 added vm.createSelectFork * 🔧 Fix config for CI * 💚 Fix CI workflows --------- Co-authored-by: Philippe Gonday <[email protected]>
136 lines
6.5 KiB
Solidity
136 lines
6.5 KiB
Solidity
// SPDX-License-Identifier: UNLICENSED
|
|
pragma solidity 0.8.30;
|
|
|
|
import { CreateX } from "../../test/external/CreateX.sol";
|
|
import { IdentityFactoryHelper } from "./IdentityFactoryHelper.sol";
|
|
import { ImplementationAuthorityHelper } from "./ImplementationAuthorityHelper.sol";
|
|
import { TREXFactoryHelper } from "./TREXFactoryHelper.sol";
|
|
import { IdFactory } from "@onchain-id/solidity/contracts/factory/IdFactory.sol";
|
|
import { IIdentity } from "@onchain-id/solidity/contracts/interface/IIdentity.sol";
|
|
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
|
|
import { TREXFactory } from "contracts/factory/TREXFactory.sol";
|
|
import { ITREXImplementationAuthority } from "contracts/proxy/authority/ITREXImplementationAuthority.sol";
|
|
import { TREXImplementationAuthority } from "contracts/proxy/authority/TREXImplementationAuthority.sol";
|
|
import { Test } from "forge-std/Test.sol";
|
|
import { Addresses } from "test/utils/Addresses.sol";
|
|
|
|
/// @notice Comprehensive fixture that orchestrates all helpers to deploy the full ERC-3643/T-REX suite
|
|
/// @dev Combines all 3 helpers: IdentityFactoryHelper, ImplementationAuthorityHelper, TREXFactoryHelper
|
|
/// Provides standard test addresses and convenience getters for easy access to all components
|
|
contract TREXFactorySetup is Test {
|
|
|
|
// ONCHAINID Setup
|
|
IdentityFactoryHelper.ONCHAINIDSetup public onchainidSetup;
|
|
|
|
// TREX Implementation Authority Setup
|
|
ImplementationAuthorityHelper.ImplementationAuthoritySetup public implementationAuthoritySetup;
|
|
|
|
// TREX Factory
|
|
TREXFactory public trexFactory;
|
|
|
|
// Standard test addresses
|
|
address public deployer = makeAddr("deployer");
|
|
address public alice = makeAddr("alice");
|
|
address public bob = makeAddr("bob");
|
|
address public charlie = makeAddr("charlie");
|
|
address public david = makeAddr("david");
|
|
address public another = makeAddr("another");
|
|
|
|
//identities for common test addresses
|
|
IIdentity public aliceIdentity;
|
|
IIdentity public bobIdentity;
|
|
IIdentity public charlieIdentity;
|
|
|
|
/// @notice Sets up the complete TREX infrastructure with standard test addresses
|
|
/// Creates a reference Implementation Authority (isReference = true)
|
|
function setUp() public virtual {
|
|
// Deploy CreateX to the hardcoded address used by TREXFactory
|
|
_deployCreateX();
|
|
// Deploy complete suite (reference Implementation authority = true for main setup)
|
|
deploy(deployer, true);
|
|
}
|
|
|
|
/// @notice Deploys CreateX to the hardcoded address used by TREXFactory
|
|
function _deployCreateX() internal {
|
|
// Deploy CreateX directly to the hardcoded address
|
|
// Using deployCodeTo ensures immutables are correctly set for the target address
|
|
deployCodeTo("test/external/CreateX.sol:CreateX", Addresses.CREATEX);
|
|
}
|
|
|
|
/// @notice Deploys the complete TREX setup using all 3 helpers
|
|
/// @param deployerAddress The deployer address (used as management key for Identity and as owner)
|
|
/// @param isReference Whether to create a reference Implementation Authority
|
|
/// @dev Ownership: Contracts are initially owned by TREXSuite (since deployed from contract).
|
|
/// Ownership is transferred to deployerAddress where deployer is owner.
|
|
function deploy(address deployerAddress, bool isReference) public {
|
|
// Step 1: Deploy ONCHAINID Components
|
|
onchainidSetup = IdentityFactoryHelper.deploy(deployerAddress);
|
|
|
|
// Step 2: Deploy TREX Implementation Authority
|
|
implementationAuthoritySetup = ImplementationAuthorityHelper.deploy(isReference);
|
|
|
|
// Step 3: Deploy TREX Factory and link everything
|
|
trexFactory = TREXFactoryHelper.deploy(
|
|
implementationAuthoritySetup.implementationAuthority, onchainidSetup.idFactory, Addresses.CREATEX
|
|
);
|
|
|
|
// Transfer ownership to deployer after linking is complete
|
|
Ownable(address(implementationAuthoritySetup.implementationAuthority)).transferOwnership(deployerAddress);
|
|
Ownable(address(trexFactory)).transferOwnership(deployerAddress);
|
|
Ownable(address(onchainidSetup.idFactory)).transferOwnership(deployerAddress);
|
|
|
|
// common identities for test addresses (alice, bob, charlie)
|
|
vm.startPrank(deployerAddress);
|
|
aliceIdentity = IIdentity(onchainidSetup.idFactory.createIdentity(alice, "alice-salt"));
|
|
bobIdentity = IIdentity(onchainidSetup.idFactory.createIdentity(bob, "bob-salt"));
|
|
charlieIdentity = IIdentity(onchainidSetup.idFactory.createIdentity(charlie, "charlie-salt"));
|
|
vm.stopPrank();
|
|
}
|
|
|
|
/// @notice Returns the TREX Implementation Authority contract
|
|
function getTREXImplementationAuthority() public view returns (TREXImplementationAuthority) {
|
|
return implementationAuthoritySetup.implementationAuthority;
|
|
}
|
|
|
|
/// @notice Returns the Identity Factory (IdFactory) contract
|
|
function getIdFactory() public view returns (IdFactory) {
|
|
return onchainidSetup.idFactory;
|
|
}
|
|
|
|
/// @notice Returns the Identity implementation contract
|
|
function getIdentityImplementation() public view returns (address) {
|
|
return address(onchainidSetup.identityImplementation);
|
|
}
|
|
|
|
/// @notice Returns all TREX implementation contracts
|
|
function getTREXImplementations()
|
|
public
|
|
view
|
|
returns (address tokenImpl, address ctrImpl, address irImpl, address irsImpl, address tirImpl, address mcImpl)
|
|
{
|
|
return (
|
|
address(implementationAuthoritySetup.implementations.token),
|
|
address(implementationAuthoritySetup.implementations.claimTopicsRegistry),
|
|
address(implementationAuthoritySetup.implementations.identityRegistry),
|
|
address(implementationAuthoritySetup.implementations.identityRegistryStorage),
|
|
address(implementationAuthoritySetup.implementations.trustedIssuersRegistry),
|
|
address(implementationAuthoritySetup.implementations.modularCompliance)
|
|
);
|
|
}
|
|
|
|
/// @notice Returns TREXContracts struct using current implementation addresses
|
|
function getTREXContracts() public view returns (ITREXImplementationAuthority.TREXContracts memory) {
|
|
(address tokenImpl, address ctrImpl, address irImpl, address irsImpl, address tirImpl, address mcImpl) =
|
|
getTREXImplementations();
|
|
return ITREXImplementationAuthority.TREXContracts({
|
|
tokenImplementation: tokenImpl,
|
|
ctrImplementation: ctrImpl,
|
|
irImplementation: irImpl,
|
|
irsImplementation: irsImpl,
|
|
tirImplementation: tirImpl,
|
|
mcImplementation: mcImpl
|
|
});
|
|
}
|
|
|
|
}
|