diff --git a/contracts/SpokePoolVerifier.sol b/contracts/SpokePoolVerifier.sol new file mode 100644 index 000000000..bbb9490eb --- /dev/null +++ b/contracts/SpokePoolVerifier.sol @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: GPL-3.0-only +pragma solidity ^0.8.0; + +import "@openzeppelin/contracts/utils/Address.sol"; +import "./interfaces/SpokePoolInterface.sol"; + +/** + * @notice SpokePoolVerifier is a contract that verifies that the SpokePool exists on this chain before sending ETH to it. + */ +contract SpokePoolVerifier { + using Address for address; + + function deposit( + SpokePoolInterface spokePool, + address recipient, + address originToken, + uint256 amount, + uint256 destinationChainId, + int64 relayerFeePct, + uint32 quoteTimestamp, + bytes memory message, + uint256 maxCount + ) external payable { + require(msg.value == amount, "msg.value != amount"); + require(address(spokePool).isContract(), "spokePool is not a contract"); + spokePool.deposit{ value: msg.value }( + recipient, + originToken, + amount, + destinationChainId, + relayerFeePct, + quoteTimestamp, + message, + maxCount + ); + } +} diff --git a/deploy/023_deploy_spoke_pool_verifier.ts b/deploy/023_deploy_spoke_pool_verifier.ts new file mode 100644 index 000000000..d8605a6c6 --- /dev/null +++ b/deploy/023_deploy_spoke_pool_verifier.ts @@ -0,0 +1,19 @@ +import { DeployFunction } from "hardhat-deploy/types"; +import { HardhatRuntimeEnvironment } from "hardhat/types"; + +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + const { deployments, getNamedAccounts } = hre; + const { deploy } = deployments; + + const { deployer } = await getNamedAccounts(); + + await deploy("SpokePoolVerifier", { + from: deployer, + log: true, + skipIfAlreadyDeployed: true, + deterministicDeployment: "0x1234", // Salt for the create2 call. + }); +}; + +module.exports = func; +func.tags = ["SpokePoolVerifier", "polygon", "mainnet", "optimism", "arbitrum", "zksync"];