Skip to content

Commit

Permalink
feat: add contract verifier (#285)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrice32 committed Jul 12, 2023
1 parent de3ee43 commit b9cf4de
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
37 changes: 37 additions & 0 deletions contracts/SpokePoolVerifier.sol
Original file line number Diff line number Diff line change
@@ -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
);
}
}
19 changes: 19 additions & 0 deletions deploy/023_deploy_spoke_pool_verifier.ts
Original file line number Diff line number Diff line change
@@ -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"];

0 comments on commit b9cf4de

Please sign in to comment.