Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion deployments/mainnet.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"SocketVerifier": "0xa27A3f5A96DF7D8Be26EE2790999860C00eb688D",
"CCTPVerification": "0x978aF9cAD9b1808895e71BDcF5Ea420a1CAAA9b0",
"AcrossV3Verification": "0x4A9a81a78DCA81F2Fd5bEf12223D3e29727c1bEE"
"AcrossV3Verification": "0x4A9a81a78DCA81F2Fd5bEf12223D3e29727c1bEE",
"GnosisBridgeRouterVerification": "0xF8C868f37b1A26e15Ab9dA53b1853a222125a4b6"
}
3 changes: 2 additions & 1 deletion scripts/addVerifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ export const addVerifier = async () => {

// config
// const VerifierName: VerifierName = "AcrossV3Verification";
const VerifierName = "CCTPVerification";
// const VerifierName = "CCTPVerification";
const VerifierName = "GnosisBridgeRouterVerification";
const verifierAddress = deployment[VerifierName];
if (!verifierAddress) {
throw new Error(`${VerifierName} not deployed`);
Expand Down
8 changes: 6 additions & 2 deletions scripts/config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
export const create3Factory = "0xf2b6544589ab65e731883a0244cbefe5735322c5";

export type VerifierName = "AcrossV3Verification" | "CCTPVerification";
export type VerifierName =
| "AcrossV3Verification"
| "CCTPVerification"
| "GnosisBridgeRouterVerification";

// https://github.com/SocketDotTech/ll-core-v2/blob/main/src/addresses/index.ts
export const routeIdConfigs: Record<
string,
Record<VerifierName, number | undefined>
Partial<Record<VerifierName, number>>
> = {
avalanche: {
AcrossV3Verification: undefined, // across not supported on avalanche
Expand All @@ -22,6 +25,7 @@ export const routeIdConfigs: Record<
mainnet: {
AcrossV3Verification: 429,
CCTPVerification: 407,
GnosisBridgeRouterVerification: 444,
},
arbitrum: {
AcrossV3Verification: 415,
Expand Down
77 changes: 77 additions & 0 deletions scripts/deployGnosisBridgeRouterVerifier.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import fs from "fs";
import { ethers, run } from "hardhat";
import path from "path";

const hre = require("hardhat");
const CONTRACT_NAME = "GnosisBridgeRouterVerification";

export const deployGnosisBridgeRouterVerification = async () => {
try {
const { deployments, getNamedAccounts, network } = hre;
const { deployer } = await getNamedAccounts();
const owner = deployer;
const networkName = network.name;
const networkFilePath = path.join(
__dirname,
`../deployments/${networkName}.json`
);
// check if the contract is already deployed in deployments folder in json
let deployment_json = undefined;
deployment_json = fs.readFileSync(networkFilePath, "utf-8");
const deployment = JSON.parse(deployment_json);

// check if the contract is already deployed
const ContractAddress = deployment[CONTRACT_NAME];
if (ContractAddress) {
console.log(`${CONTRACT_NAME} already deployed to:`, ContractAddress);
return {
success: true,
address: ContractAddress,
};
}

const factory = await ethers.getContractFactory(CONTRACT_NAME);
const Contract = await factory.deploy();
console.log(`about to deploy ${CONTRACT_NAME}`);
await Contract.deployed();
console.log(`${CONTRACT_NAME} deployed to:`, Contract.address);

// save the contract address in deployments folder
const newDeployment = {
...deployment,
[CONTRACT_NAME]: Contract.address,
};

fs.writeFileSync(
networkFilePath,
JSON.stringify(newDeployment, null, 2),
"utf-8"
);

// verify the contract on etherscan
await run("verify:verify", {
address: Contract.address,
constructorArguments: [],
});

return {
success: true,
address: Contract.address,
};
} catch (error) {
console.log(`Error in deploying ${CONTRACT_NAME}`, error);
return {
success: false,
};
}
};

deployGnosisBridgeRouterVerification()
.then(() => {
console.log(`✅ finished running the deployment of ${CONTRACT_NAME}`);
process.exit(0);
})
.catch((err) => {
console.error(err);
process.exit(1);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import {BaseVerifier} from "../BaseVerification.sol";

contract GnosisBridgeRouterVerification is BaseVerifier {
address public constant NATIVE_TOKEN_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;

function bridgeERC20To(
bytes32 metadata,
address receiverAddress,
address fromTokenAddress,
uint256 toChainId,
uint256 amount
) external returns (SocketRequest memory) {
return SocketRequest({
amount: amount,
recipient: receiverAddress,
toChainId: toChainId,
token: fromTokenAddress,
signature: msg.sig
});
}

function bridgeNativeTo(bytes32 metadata, address receiverAddress, uint256 toChainId, uint256 amount)
external
returns (SocketRequest memory)
{
return SocketRequest({
amount: amount,
recipient: receiverAddress,
toChainId: toChainId,
token: NATIVE_TOKEN_ADDRESS,
signature: msg.sig
});
}

receive() external payable {}

// Fallback function is called when msg.data is not empty
fallback() external payable {}
}
Loading