diff --git a/foundry.toml b/foundry.toml index 79c6b4e..9c1f60f 100644 --- a/foundry.toml +++ b/foundry.toml @@ -9,6 +9,10 @@ via_ir = true verbosity = 3 auto_detect_remappings = true +# Foundry 1.0 has Optimizer disabled by default +#optimizer = true +#optimizer_runs = 200 + [profile.e2e] match_path = "test/e2e/*" @@ -23,132 +27,26 @@ mainnet = "${RPC_MAINNET}" sepolia = "${RPC_SEPOLIA}" arbitrum = "${RPC_ARBITRUM}" arbitrumTestnet = "${RPC_ARBITRUM_SEPOLIA}" -holesky = "${RPC_HOLESKY}" bsc = "${RPC_BSC}" bscTestnet = "${RPC_BSC_TESTNET}" polygon = "${RPC_POLYGON}" polygonTestnet = "${RPC_POLYGON_TESTNET}" -zkEVM = "${RPC_ZKEVM}" -zkEVMTestnet = "${RPC_ZKEVM_TESTNET}" -base = "${RPC_BASE}" -baseTestnet = "${RPC_BASE_TESTNET}" -novaArbiscan = "${RPC_NOVA_ARBISCAN}" -linea = "${RPC_LINEA}" -lineaTestnet = "${RPC_LINEA_TESTNET}" -ftm = "${RPC_FTM}" -ftmTestnet = "${RPC_FTM_TESTNET}" -blast = "${RPC_BLAST}" -blastTestnet = "${RPC_BLAST_TESTNET}" -optimistic = "${RPC_OPTIMISTIC}" -optimisticSepolia = "${RPC_OPTIMISTIC_SEPOLIA}" -snow = "${RPC_SNOW}" -snowTestnet = "${RPC_SNOW_TESTNET}" -bttc = "${RPC_BTTC}" -donauBttc = "${RPC_DONAU_BTTC}" -celo = "${RPC_CELO}" -alfajoresCelo = "${RPC_ALFAJORES_CELO}" -cronos = "${RPC_CRONOS}" -frax = "${RPC_FRAX}" -fraxTestnet = "${RPC_FRAX_TESTNET}" gnosis = "${RPC_GNOSIS}" -kroma = "${RPC_KROMA}" -kromaTestnet = "${RPC_KROMA_TESTNET}" -mantle = "${RPC_MANTLE}" -mantleTestnet = "${RPC_MANTLE_TESTNET}" -moonbeam = "${RPC_MOONBEAM}" -moonriver = "${RPC_MOONRIVER}" -moonbase = "${RPC_MOONBASE}" -opbnb = "${RPC_OPBNB}" -opbnbTestnet = "${RPC_OPBNB_TESTNET}" -scroll = "${RPC_SCROLL}" -scrollTestnet = "${RPC_SCROLL_TESTNET}" -taiko = "${RPC_TAIKO}" -taikoTestnet = "${RPC_TAIKO_TESTNET}" -wemix = "${RPC_WEMIX}" -wemixTestnet = "${RPC_WEMIX_TESTNET}" -zkSync = "${RPC_ZKSYNC}" -zkSyncTestnet = "${RPC_ZKSYNC_TESTNET}" -xai = "${RPC_XAI}" -xaiSepolia = "${RPC_XAI_SEPOLIA}" +gnosisTestnet = "${RPC_GNOSIS_TESTNET}" [etherscan] ethereum = { key = "${ETHERSCAN_KEY}", chain = 1 } sepolia = { key = "${ETHERSCAN_KEY}", chain = 11155111 } -holesky = { key = "${ETHERSCAN_KEY}", chain = 17000 } -#[BSC] bsc = { key = "${ETHERSCAN_KEY}", chain = 56 } bscTestnet = { key = "${ETHERSCAN_KEY}", chain = 97 } -#[polygon] polygon = { key = "${ETHERSCAN_KEY}", chain = 137 } -polygonTestnet = { key = "${ETHERSCAN_KEY}", chain = 80002 } -#[zkEVM] -zkEVM = { key = "${ETHERSCAN_KEY}", chain = 1101 } -zkEVMTestnet = { key = "${ETHERSCAN_KEY}", chain = 2442 } -#[baseScan] -base = { key = "${ETHERSCAN_KEY}", chain = 8453 } -baseTestnet = { key = "${ETHERSCAN_KEY}", chain = 84532 } -#[arbiscan] +polygonTestnet = { key = "${ETHERSCAN_KEY}", chain = 80001 } +optimistic = { key = "${ETHERSCAN_KEY}", chain = 10 } +optimismTestnet = { key = "${ETHERSCAN_KEY}", chain = 420 } arbitrum = { key = "${ETHERSCAN_KEY}", chain = 42161 } -novaArbiscan = { key = "${ETHERSCAN_KEY}", chain = 42170 } arbitrumSepolia = { key = "${ETHERSCAN_KEY}", chain = 421614 } -#[lineaScan] -linea = { key = "${ETHERSCAN_KEY}", chain = 59144 } -lineaTestnet = { key = "${ETHERSCAN_KEY}", chain = 59141 } -#[ftmScan] -ftm = { key = "${ETHERSCAN_KEY}", chain = 250 } -ftmTestnet = { key = "${ETHERSCAN_KEY}", chain = 4002 } -#[blastScan] -blast = { key = "${ETHERSCAN_KEY}", chain = 81457 } -blastTestnet = { key = "${ETHERSCAN_KEY}", chain = 168587773 } -#[optimisticEtherscan] -optimistic = { key = "${ETHERSCAN_KEY}", chain = 10 } -optimisticSepolia = { key = "${ETHERSCAN_KEY}", chain = 11155420 } -#[snowScan] -snow = { key = "${ETHERSCAN_KEY}", chain = 43114 } -snowTestnet = { key = "${ETHERSCAN_KEY}", chain = 43113 } -#[bttcScan] -bttc = { key = "${ETHERSCAN_KEY}", chain = 199 } -donauBttc = { key = "${ETHERSCAN_KEY}", chain = 1028 } -#[celoScan] -celo = { key = "${ETHERSCAN_KEY}", chain = 42220 } -alfajoresCelo = { key = "${ETHERSCAN_KEY}", chain = 44787 } -#[cronoscan] -cronos = { key = "${ETHERSCAN_KEY}", chain = 25 } -#[fraxscan] -frax = { key = "${ETHERSCAN_KEY}", chain = 252 } -fraxTestnet = { key = "${ETHERSCAN_KEY}", chain = 2522 } -#[gnosisScan] gnosis = { key = "${ETHERSCAN_KEY}", chain = 100 } -#[kromaScan] -kroma = { key = "${ETHERSCAN_KEY}", chain = 255 } -kromaTestnet = { key = "${ETHERSCAN_KEY}", chain = 2358 } -#[mantlescan] -mantle = { key = "${ETHERSCAN_KEY}", chain = 5000 } -mantleTestnet = { key = "${ETHERSCAN_KEY}", chain = 5003 } -#[moonbeamScan] -moonbeam = { key = "${ETHERSCAN_KEY}", chain = 1284 } -#[moonriverScan] -moonriver = { key = "${ETHERSCAN_KEY}", chain = 1285 } -#[moonbaseScan] -moonbase = { key = "${ETHERSCAN_KEY}", chain = 1287 } -#[opbnbBscScan] -opbnb = { key = "${ETHERSCAN_KEY}", chain = 204 } -opbnbTestnet = { key = "${ETHERSCAN_KEY}", chain = 5611 } -#[scrollScan] -scroll = { key = "${ETHERSCAN_KEY}", chain = 534352 } -scrollTestnet = { key = "${ETHERSCAN_KEY}", chain = 534351 } -#[taikoScan] -taiko = { key = "${ETHERSCAN_KEY}", chain = 167000 } -taikoTestnet = { key = "${ETHERSCAN_KEY}", chain = 167009 } -#[wemixScan] -wemix = { key = "${ETHERSCAN_KEY}", chain = 1111 } -wemixTestnet = { key = "${ETHERSCAN_KEY}", chain = 1112 } -#[zkSyncEra] -zkSync = { key = "${ETHERSCAN_KEY}", chain = 324 } -zkSyncTestnet = { key = "${ETHERSCAN_KEY}", chain = 300 } -#[xaiScan] -xai = { key = "${ETHERSCAN_KEY}", chain = 660279 } -xaiSepolia = { key = "${ETHERSCAN_KEY}", chain = 37714555429 } +gnosisTestnet = { key = "${ETHERSCAN_KEY}", chain = 10200 } [fmt] line_length = 90 diff --git a/script/BaseScript.sol b/script/BaseScript.sol index 32b2624..3b0c19a 100644 --- a/script/BaseScript.sol +++ b/script/BaseScript.sol @@ -5,7 +5,6 @@ import "forge-std/Script.sol"; import { strings } from "./utils/strings.sol"; import { Create2 } from "./utils/Create2.sol"; import { ICreateX } from "./utils/ICreateX.sol"; -import "./Chains.sol"; abstract contract BaseScript is Script { type CreateXSeed is bytes32; @@ -18,6 +17,19 @@ abstract contract BaseScript is Script { string contractName; } + struct ChainConfig { + uint256 chainId; + string name; + uint256 testnetChainId; + string testnetName; + } + + struct ChainMetadata { + string name; + uint256 chainId; + bool isTestnet; + } + ICreateX private constant CREATE_X_FACTORY = ICreateX(0xba5Ed099633D3B313e4D5F7bdc1305d3c28ba5Ed); @@ -28,9 +40,34 @@ abstract contract BaseScript is Script { string private constant ENV_DEPLOY_NETWORK = "DEPLOY_NETWORK"; string private constant DEPLOY_HISTORY_PATH = "/deployment/"; string private constant KEY_CONTRACT_NAME = "contractName"; + string private constant CHAINS_CONFIG_FILE_NAME = "Chains"; + string private constant LOCAL_HOST_NETWORK_NAME = "localhost"; mapping(string => address) internal contracts; mapping(string => mapping(string => address)) internal contractsOtherNetworks; + mapping(uint256 => ChainMetadata) internal chainMetadata; + + constructor() { + _loadChains(); + _loadContracts(false); + } + + function _loadChains() private { + ChainConfig[] memory chainConfigs = + abi.decode(vm.parseJson(_getConfig(CHAINS_CONFIG_FILE_NAME)), (ChainConfig[])); + + ChainConfig memory indexChainConfig; + + for (uint256 i = 0; i < chainConfigs.length; ++i) { + indexChainConfig = chainConfigs[i]; + + chainMetadata[indexChainConfig.chainId] = + ChainMetadata(indexChainConfig.name, indexChainConfig.chainId, false); + + chainMetadata[indexChainConfig.testnetChainId] = + ChainMetadata(indexChainConfig.testnetName, indexChainConfig.testnetChainId, true); + } + } //Entrypoint for the script function run() external virtual; @@ -132,7 +169,7 @@ abstract contract BaseScript is Script { * @notice _getNetwork the current chain network's name. */ function _getNetwork() internal view returns (string memory) { - return Chains.getChainName(); + return chainMetadata[block.chainid].name; } /** @@ -225,11 +262,14 @@ abstract contract BaseScript is Script { } function _isTestnet() internal view returns (bool) { - return Chains.isTestnet(); + return chainMetadata[block.chainid].isTestnet; } function _isLocal() internal view returns (bool) { - return Chains.isLocal(); + bytes32 currentNetwork = keccak256(abi.encode(_getNetwork())); + bytes32 localNetwork = keccak256(abi.encode(LOCAL_HOST_NETWORK_NAME)); + + return currentNetwork == localNetwork; } /** diff --git a/script/Chains.sol b/script/Chains.sol deleted file mode 100644 index 18495fe..0000000 --- a/script/Chains.sol +++ /dev/null @@ -1,99 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -library Chains { - function getChainName() internal view returns (string memory) { - uint256 chainId = block.chainid; - - if (chainId == 1) return "ethereum"; - if (chainId == 56) return "bsc"; - if (chainId == 10) return "optimism"; - if (chainId == 42_161) return "arbitrum"; - if (chainId == 137) return "polygon"; - if (chainId == 1101) return "polygonzkEVM"; - if (chainId == 250) return "fantom"; - if (chainId == 252) return "fraxtal"; - if (chainId == 43_114) return "avalanche"; - if (chainId == 100) return "gnosis"; - if (chainId == 1285) return "moonriver"; - if (chainId == 1284) return "moonbeam"; - if (chainId == 42_220) return "celo"; - if (chainId == 1_313_161_554) return "aurora"; - if (chainId == 1_666_600_000) return "harmony"; - if (chainId == 122) return "fuse"; - if (chainId == 25) return "cronos"; - if (chainId == 9001) return "evmos"; - if (chainId == 288) return "boba"; - if (chainId == 7700) return "canto"; - if (chainId == 8453) return "base"; - if (chainId == 5000) return "mantle"; - if (chainId == 314) return "filecoin"; - if (chainId == 534_352) return "scroll"; - if (chainId == 59_144) return "linea"; - if (chainId == 7_777_777) return "zora"; - if (chainId == 42) return "lukso"; - if (chainId == 169) return "mantaPacific"; - if (chainId == 81_457) return "blast"; - if (chainId == 7979) return "DOS"; - if (chainId == 648) return "endurance"; - if (chainId == 2222) return "kava"; - if (chainId == 1088) return "metis"; - if (chainId == 34_443) return "mode"; - if (chainId == 196) return "XLayer"; - if (chainId == 11_155_111) return "sepolia"; - if (chainId == 17_000) return "holesky"; - if (chainId == 97) return "bscTestnet"; - if (chainId == 11_155_420) return "optimismTestnet"; - if (chainId == 421_614) return "arbitrumTestnet"; - if (chainId == 80_002) return "polygonTestnet"; - if (chainId == 1442) return "polygonzkEVMTestnet"; - if (chainId == 4002) return "fantomTestnet"; - if (chainId == 43_113) return "avalancheTestnet"; - if (chainId == 10_200) return "gnosisTestnet"; - if (chainId == 1287) return "moonbeamTestnet"; - if (chainId == 44_787) return "celoTestnet"; - if (chainId == 1_313_161_555) return "auroraTestnet"; - if (chainId == 1_666_700_000) return "harmonyTestnet"; - if (chainId == 123) return "fuseTestnet"; - if (chainId == 338) return "cronosTestnet"; - if (chainId == 9000) return "evmosTestnet"; - if (chainId == 2880) return "bobaTestnet"; - if (chainId == 777) return "cantoTestnet"; - if (chainId == 553) return "mantleTestnet"; - if (chainId == 121) return "sandbox"; - if (chainId == 199) return "bttc"; - if (chainId == 1028) return "donauBttc"; - if (chainId == 204) return "opbnb"; - if (chainId == 5611) return "opbnbTestnet"; - if (chainId == 5003) return "mantleTestnet"; - if (chainId == 1111) return "wemix"; - if (chainId == 1112) return "wemixTestnet"; - if (chainId == 324) return "zkSync"; - if (chainId == 300) return "zkSyncTestnet"; - if (chainId == 660_279) return "xai"; - if (chainId == 37_714_555_429) return "xaiSepolia"; - - return "localhost"; - } - - function isTestnet() internal view returns (bool) { - uint256 chainId = block.chainid; - - if ( - chainId == 11_155_111 || chainId == 17_000 || chainId == 97 || chainId == 11_155_420 - || chainId == 421_614 || chainId == 80_002 || chainId == 1442 || chainId == 4002 - || chainId == 43_113 || chainId == 10_200 || chainId == 1287 || chainId == 44_787 - || chainId == 1_313_161_555 || chainId == 1_666_700_000 || chainId == 123 - || chainId == 338 || chainId == 9000 || chainId == 2880 || chainId == 777 - || chainId == 553 || chainId == 121 || chainId == 1028 || chainId == 5611 - || chainId == 5003 || chainId == 1112 || chainId == 300 || chainId == 37_714_555_429 - || chainId == 204 || chainId == 660_279 - ) return true; - - return false; - } - - function isLocal() internal view returns (bool) { - return block.chainid == 31_337; - } -} diff --git a/script/config/Chains.json b/script/config/Chains.json new file mode 100644 index 0000000..8ac2d7c --- /dev/null +++ b/script/config/Chains.json @@ -0,0 +1,45 @@ +[ + + { + "chainId": 31337, + "name": "localhost", + "testnetChainId": 31337, + "testnetName": "localhost" + }, + { + "chainId": 1, + "name": "ethereum", + "testnetChainId": 11155111, + "testnetName": "sepolia" + }, + { + "chainId": 56, + "name": "bsc", + "testnetChainId": 97, + "testnetName": "bscTestnet" + }, + { + "chainId": 137, + "name": "polygon", + "testnetChainId": 80001, + "testnetName": "polygonTestnet" + }, + { + "chainId": 10, + "name": "optimism", + "testnetChainId": 420, + "testnetName": "optimismTestnet" + }, + { + "chainId": 42161, + "name": "arbitrum", + "testnetChainId": 421614, + "testnetName": "arbitrumSepolia" + }, + { + "chainId": 100, + "name": "gnosis", + "testnetChainId": 10200, + "testnetName": "gnosisTestnet" + } +] \ No newline at end of file diff --git a/script/deploy/HelloWorld.s.sol b/script/deploy/HelloWorld.s.sol index acb15da..56d2da3 100644 --- a/script/deploy/HelloWorld.s.sol +++ b/script/deploy/HelloWorld.s.sol @@ -43,8 +43,6 @@ contract HelloWorldScript is BaseScript { assert(config.owner == address(0xADaE1798F761Fa7fce29B6673D453d1a48A2931A)); assert(config.ownerTwo == address(0x912CE59144191C1204E64559FE8253a0e49E6548)); - _loadContracts(false); - address helloWorldAddress; if (_isTestnet() || _isLocal()) { diff --git a/test/base/BaseTest.t.sol b/test/base/BaseTest.t.sol index a0721ff..ed6b614 100644 --- a/test/base/BaseTest.t.sol +++ b/test/base/BaseTest.t.sol @@ -2,9 +2,8 @@ pragma solidity >=0.8.0; import "forge-std/Test.sol"; -import { MockERC20ABI } from "../mock/abi/MockERC20ABI.t.sol"; -contract BaseTest is Test, MockERC20ABI { +contract BaseTest is Test { uint256 internal constant MAX_UINT = type(uint256).max; address internal constant ZERO_ADDRESS = address(0); @@ -66,8 +65,9 @@ contract BaseTest is Test, MockERC20ABI { * @param _name Name that you will see in your terminal * @param _isContract Adds bytes code to * @param _ethBalance Set the initial balance - * @dev The generateAddress in the contract parameters is elegant, but be warned. If you have too many of these, - * you will run into a stack too deep on build, even with `via_ir` on. So it's better to generate them in setUp(). + * @dev The generateAddress in the contract parameters is elegant, but be warned. If you + * have too many of these, you will run into a stack too deep on build, even with + * `via_ir` on. So it's better to generate them in setUp(). */ function generateAddress(string memory _name, bool _isContract, uint256 _ethBalance) internal diff --git a/test/mock/contract/DefaultERC20.t.sol b/test/mock/DefaultERC20.t.sol similarity index 100% rename from test/mock/contract/DefaultERC20.t.sol rename to test/mock/DefaultERC20.t.sol diff --git a/test/mock/contract/FailOnReceive.t.sol b/test/mock/FailOnReceive.t.sol similarity index 100% rename from test/mock/contract/FailOnReceive.t.sol rename to test/mock/FailOnReceive.t.sol diff --git a/test/mock/FaucetERC20.t.sol b/test/mock/FaucetERC20.t.sol new file mode 100644 index 0000000..5b77510 --- /dev/null +++ b/test/mock/FaucetERC20.t.sol @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.0; + +import { DefaultERC20 } from "./DefaultERC20.t.sol"; + +contract FaucetERC20 is DefaultERC20 { + uint256 public immutable TAP_AMOUNT; + + constructor( + string memory name_, + string memory symbol_, + uint8 decimals_, + uint256 tapAmount + ) DefaultERC20(name_, symbol_, decimals_) { + TAP_AMOUNT = tapAmount; + } + + function tap() external { + _mint(msg.sender, TAP_AMOUNT); + } +} diff --git a/test/mock/contract/MockERC20.t.sol b/test/mock/NoApprovalERC20.sol similarity index 71% rename from test/mock/contract/MockERC20.t.sol rename to test/mock/NoApprovalERC20.sol index c3eb7c8..be582a0 100644 --- a/test/mock/contract/MockERC20.t.sol +++ b/test/mock/NoApprovalERC20.sol @@ -3,16 +3,12 @@ pragma solidity >=0.8.0; import { DefaultERC20 } from "./DefaultERC20.t.sol"; -contract MockERC20 is DefaultERC20 { - bool private ignoreLogic; - +contract NoApprovalERC20 is DefaultERC20 { constructor(string memory name_, string memory symbol_, uint8 decimals_) DefaultERC20(name_, symbol_, decimals_) { } function transfer(address to, uint256 amount) public override returns (bool) { - if (ignoreLogic) return true; - _transfer(msg.sender, to, amount); return true; @@ -23,13 +19,7 @@ contract MockERC20 is DefaultERC20 { override returns (bool) { - if (ignoreLogic) return true; - _transfer(from, to, amount); return true; } - - function setIgnoreLogic(bool status) external { - ignoreLogic = status; - } } diff --git a/test/mock/abi/MockERC20ABI.t.sol b/test/mock/abi/MockERC20ABI.t.sol deleted file mode 100644 index 49c3c5f..0000000 --- a/test/mock/abi/MockERC20ABI.t.sol +++ /dev/null @@ -1,114 +0,0 @@ -// SPDX-License-Identifier: Unlicense -pragma solidity >=0.8.0; - -import "forge-std/Test.sol"; - -contract MockERC20ABI is Test { - string private constant SIG_BALANCE_OF = "balanceOf(address)"; - string private constant SIG_MINT = "mint(address,uint256)"; - string private constant SIG_BURN = "burn(address,uint256)"; - string private constant SIG_NAME = "name()"; - string private constant SIG_SYMBOL = "symbol()"; - string private constant SIG_DECIMALS = "decimals()"; - string private constant SIG_TOTAL_SUPPLY = "totalSupply()"; - string private constant SIG_ALLOWANCE = "allowance(address,address)"; - string private constant SIG_APPROVE = "approve(address,uint256)"; - string private constant SIG_TRANSFER = "transfer(address,uint256)"; - string private constant SIG_TRANSFER_FROM = "transferFrom(address,address,uint256)"; - string private constant SIG_INCREASE_ALLOWANCE = "increaseAllowance(address,uint256)"; - string private constant SIG_DECREASE_ALLOWANCE = "decreaseAllowance(address,uint256)"; - - function mockBalance(address _token, address _of, uint256 _amount) internal { - vm.mockCall(_token, abi.encodeWithSignature(SIG_BALANCE_OF, _of), abi.encode(_amount)); - } - - function expectMint(address _token, address _of, uint256 _amount) internal { - vm.expectCall(_token, abi.encodeWithSignature(SIG_MINT, _of, _amount)); - } - - function expectBurn(address _token, address _from, uint256 _amount) internal { - vm.expectCall(_token, abi.encodeWithSignature(SIG_BURN, _from, _amount)); - } - - function mockName(address _token, string memory _name) internal { - vm.mockCall(_token, abi.encodeWithSignature(SIG_NAME), abi.encode(_name)); - } - - function mockDecimals(address _token, uint8 _decimals) internal { - vm.mockCall(_token, abi.encodeWithSignature(SIG_DECIMALS), abi.encode(_decimals)); - } - - function mockTotalSupply(address _token, uint256 _totalSupply) internal { - vm.mockCall( - _token, abi.encodeWithSignature(SIG_TOTAL_SUPPLY), abi.encode(_totalSupply) - ); - } - - function mockAllowance( - address _token, - address _of, - address _spender, - uint256 _allowance - ) internal { - vm.mockCall( - _token, - abi.encodeWithSignature(SIG_ALLOWANCE, _of, _spender), - abi.encode(_allowance) - ); - } - - function expectApprove(address _token, address _of, uint256 _amount) internal { - vm.expectCall(_token, abi.encodeWithSignature(SIG_APPROVE, _of, _amount)); - mockApprove(_token, _of, _amount, true); - } - - function mockApprove(address _token, address _of, uint256 _amount, bool _result) - internal - { - vm.mockCall( - _token, abi.encodeWithSignature(SIG_APPROVE, _of, _amount), abi.encode(_result) - ); - } - - function expectTransfer(address _token, address _to, uint256 _amount) internal { - vm.expectCall(_token, abi.encodeWithSignature(SIG_TRANSFER, _to, _amount)); - mockTransfer(_token, _to, _amount, true); - } - - function mockTransfer(address _token, address _to, uint256 _amount, bool _result) - internal - { - vm.mockCall( - _token, abi.encodeWithSignature(SIG_TRANSFER, _to, _amount), abi.encode(_result) - ); - } - - function mockAnyTransfer(address _token) internal { - vm.mockCall(_token, abi.encodeWithSignature(SIG_TRANSFER), abi.encode(true)); - } - - function expectTransferFrom(address _token, address _from, address _to, uint256 _amount) - internal - { - vm.expectCall(_token, abi.encodeWithSignature(SIG_TRANSFER_FROM, _from, _to, _amount)); - mockTransferFrom(_token, _from, _to, _amount, true); - } - - function mockTransferFrom( - address _token, - address _from, - address _to, - uint256 _amount, - bool _result - ) internal { - vm.mockCall( - _token, - abi.encodeWithSignature(SIG_TRANSFER_FROM, _from, _to, _amount), - abi.encode(_result) - ); - } - - function mockAnyTransferFrom(address _token) internal { - vm.mockCall(_token, abi.encodeWithSignature(SIG_TRANSFER_FROM), abi.encode(true)); - } -}