diff --git a/contracts/forwarder/ForwarderNativePermissioned.sol b/contracts/forwarder/ForwarderNativePermissioned.sol index 7709b1e..f0ac453 100644 --- a/contracts/forwarder/ForwarderNativePermissioned.sol +++ b/contracts/forwarder/ForwarderNativePermissioned.sol @@ -19,7 +19,7 @@ error InvalidCallParams(address[] targets, bytes[] data, address caller); error InvalidOriginAddress(address originAddress); error InvalidCaller(address caller, address expected); -contract ForwarderNativePermissioned is IForwarder, IERC777Recipient, Context, Ownable { +contract ForwarderNativePermissioned is IERC777Recipient, Context, Ownable { using SafeERC20 for IERC20; address public immutable token; @@ -37,14 +37,6 @@ contract ForwarderNativePermissioned is IForwarder, IERC777Recipient, Context, O vault = _vault; // set it to 0 on an host chain } - modifier onlySelf() { - address msgSender = _msgSender(); - if (address(this) != msgSender) { - revert InvalidCaller(msgSender, address(this)); - } - _; - } - function tokensReceived( address /*_operator*/, address _from, @@ -83,22 +75,6 @@ contract ForwarderNativePermissioned is IForwarder, IERC777Recipient, Context, O } } - /// @inheritdoc IForwarder - function call(uint256 amount, address to, bytes calldata data, bytes4 chainId) external onlySelf() { - _call(token, amount, to, data, chainId); - } - - function call(address _token, uint256 amount, address to, bytes calldata data, bytes4 chainId) external onlySelf() { - _call(_token, amount, to, data, chainId); - } - - function _call(address _token, uint256 amount, address to, bytes calldata data, bytes4 chainId) internal { - bytes memory effectiveUserData = abi.encode(data, address(this)); - uint256 effectiveAmount = amount == 0 ? 1 : amount; - IERC20(_token).safeApprove(vault, effectiveAmount); - IErc20Vault(vault).pegIn(effectiveAmount, _token, Helpers.addressToAsciiString(to), effectiveUserData, chainId); - } - function whitelistOriginAddress(address originAddress) external onlyOwner { _whitelistedOriginAddresses[originAddress] = true; } diff --git a/test/fork/dao.test.js b/test/fork/dao.test.js index fe2b07f..13fed16 100644 --- a/test/fork/dao.test.js +++ b/test/fork/dao.test.js @@ -22,6 +22,7 @@ const { const AclAbi = require('../abi/ACL.json') const DandelionVotingAbi = require('../abi/DandelionVoting.json') const DaoPntAbi = require('../abi/daoPNT.json') +const ERC20VaultAbi = require('../abi/ERC20Vault.json') const EthPntAbi = require('../abi/ethPNT.json') const FinanceAbi = require('../abi/Finance.json') const VaultAbi = require('../abi/Vault.json') @@ -384,12 +385,17 @@ describe('Integration tests on Gnosis deployment', () => { const userData = encode( ['address[]', 'bytes[]'], [ - [ETH_PTN_ADDRESS, FORWARDER_ETH], + [ETH_PTN_ADDRESS, ETH_PTN_ADDRESS, ERC20_VAULT], [ new hre.ethers.Interface(EthPntAbi).encodeFunctionData('withdrawInflation', [RECEIVER, 10]), - new hre.ethers.Interface([ - 'function call(address _token, uint256 amount, address to, bytes calldata data, bytes4 chainId) external' - ]).encodeFunctionData('call', [ETHPNT_ADDRESS, 10, FINANCE_VAULT, '0x', PNETWORK_NETWORK_IDS.gnosisMainnet]) + new hre.ethers.Interface(EthPntAbi).encodeFunctionData('approve', [ERC20_VAULT, 10]), + new hre.ethers.Interface(ERC20VaultAbi).encodeFunctionData('pegIn(uint256,address,string,bytes,bytes4)', [ + 10, + ETHPNT_ADDRESS, + FINANCE_VAULT, + '0x', + PNETWORK_NETWORK_IDS.gnosisMainnet + ]) ] ] ) @@ -424,7 +430,7 @@ describe('Integration tests on Gnosis deployment', () => { 1, FORWARDER_ETH.slice(2).toLowerCase(), // secretlint-disable-next-line - '0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000cf759bccfef5f322af58adae2d28885658b5e020000000000000000000000000000000000000000000000000000000000000280000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000002000000000000000000000000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b200000000000000000000000001234567890123456789012345678901234567890000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000443352d49b0000000000000000000000000123456789012345678901234567890123456789000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c4a61e4cd0000000000000000000000000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b2000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000006239968e6231164687cb40f8389d933dd7f7e0a500000000000000000000000000000000000000000000000000000000000000a000f1918e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', + '0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000cf759bccfef5f322af58adae2d28885658b5e0200000000000000000000000000000000000000000000000000000000000003a0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000003000000000000000000000000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b2000000000000000000000000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b2000000000000000000000000e396757ec7e6ac7c8e5abe7285dde47b98f22db80000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000443352d49b0000000000000000000000000123456789012345678901234567890123456789000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000e396757ec7e6ac7c8e5abe7285dde47b98f22db8000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000124c322525d000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b200000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000010000f1918e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a30783632333939363865363233313136343638374342343066383338396439333364443766376530413500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', PNETWORK_NETWORK_IDS.gnosisMainnet, PNETWORK_NETWORK_IDS.ethereumMainnet ) @@ -514,7 +520,7 @@ describe('Integration tests on Ethereum deployment', () => { [ '0x02', // secretlint-disable-next-line - '0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000cf759bccfef5f322af58adae2d28885658b5e020000000000000000000000000000000000000000000000000000000000000280000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000002000000000000000000000000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b200000000000000000000000001234567890123456789012345678901234567890000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000443352d49b0000000000000000000000000123456789012345678901234567890123456789000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c4a61e4cd0000000000000000000000000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b2000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000006239968e6231164687cb40f8389d933dd7f7e0a500000000000000000000000000000000000000000000000000000000000000a000f1918e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'.replaceAll( + '0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000cf759bccfef5f322af58adae2d28885658b5e0200000000000000000000000000000000000000000000000000000000000003a0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000003000000000000000000000000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b2000000000000000000000000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b2000000000000000000000000e396757ec7e6ac7c8e5abe7285dde47b98f22db80000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000443352d49b0000000000000000000000000123456789012345678901234567890123456789000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000e396757ec7e6ac7c8e5abe7285dde47b98f22db8000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000124c322525d000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b200000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000010000f1918e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a30783632333939363865363233313136343638374342343066383338396439333364443766376530413500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'.replaceAll( '0123456789012345678901234567890123456789', (await forwarderNativePermissioned.getAddress()).slice(2) ), @@ -536,8 +542,8 @@ describe('Integration tests on Ethereum deployment', () => { PNT_ON_ETH_ADDRESS, await forwarderNativePermissioned.getAddress(), 10, - FINANCE_VAULT.slice(2).toLowerCase(), - encode(['bytes', 'address'], ['0x', await forwarderNativePermissioned.getAddress()]), + FINANCE_VAULT, + '0x', PNETWORK_NETWORK_IDS.ethereumMainnet, PNETWORK_NETWORK_IDS.gnosisMainnet )