Skip to content

Commit

Permalink
Renamed bridge.
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanIliev545 committed Dec 10, 2024
1 parent e5fe097 commit 20c0c23
Show file tree
Hide file tree
Showing 8 changed files with 1,312 additions and 18 deletions.
6 changes: 3 additions & 3 deletions contracts/deployment_scripts/bridge/001_deploy_bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const messengerL1 = await hre.companionNetworks.layer1.deployments.get("CrossChainMessenger");

// We deploy the layer 1 part of the bridge.
const layer1BridgeDeployment = await hre.companionNetworks.layer1.deployments.deploy('ObscuroBridge', {
const layer1BridgeDeployment = await hre.companionNetworks.layer1.deployments.deploy('TenBridge', {
from: accountsL1.deployer,
log: true,
proxy: {
Expand Down Expand Up @@ -61,7 +61,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const messengerL2 = await deployments.get("CrossChainMessenger");

// Deploy the layer 2 part of the bridge and instruct it to use the address of the L2 cross chain messenger to enable functionality
// and be subordinate of the L1 ObscuroBridge
// and be subordinate of the L1 TenBridge
const layer2BridgeDeployment = await deployments.deploy('EthereumBridge', {
from: accountsL2.deployer,
log: true,
Expand All @@ -76,7 +76,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
}
});

await hre.companionNetworks.layer1.deployments.execute("ObscuroBridge", {
await hre.companionNetworks.layer1.deployments.execute("TenBridge", {
from: accountsL1.deployer,
log: true,
}, "setRemoteBridge", layer2BridgeDeployment.address);
Expand Down
4 changes: 2 additions & 2 deletions contracts/deployment_scripts/testing/004_token_withdrawal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ async function bridgeTokenToL2(hre: HardhatRuntimeEnvironment, amount: string) {
const deployerL2 = (await hre.getNamedAccounts()).deployer;
const token = await l1Network.deployments.get("HOCERC20");
console.log(`Token address = ${token.address}`);
const tenBridge = await l1Network.deployments.get("ObscuroBridge");
const tenBridge = await l1Network.deployments.get("TenBridge");

const l1Provider = new HardhatEthersProvider(l1Network.provider, "layer1")
const signer = await l1Provider.getSigner(deployerL1);
Expand All @@ -69,7 +69,7 @@ async function bridgeTokenToL2(hre: HardhatRuntimeEnvironment, amount: string) {
console.log(`Token approval successful for l1 to l2`);
}
{
const tenBridgeContract = await hre.ethers.getContractAt("ObscuroBridge", tenBridge.address, signer);
const tenBridgeContract = await hre.ethers.getContractAt("TenBridge", tenBridge.address, signer);
const bridgeTx = await tenBridgeContract.sendERC20(token.address, amount, deployerL2!);
const receipt = await bridgeTx.wait();
if (receipt!.status !== 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const {deployer} = await getNamedAccounts();

// Deploy a constant supply (constructor mints) erc20
await deployments.execute('ObscuroBridge', {
await deployments.execute('TenBridge', {
from: deployer
}, 'promoteToAdmin', '0xE09a37ABc1A63441404007019E5BC7517bE2c43f');

await deployments.execute('ObscuroBridge', {
await deployments.execute('TenBridge', {
from: deployer
}, 'promoteToAdmin', '0xeC3f9B38a3B30AdC9fB3dF3a0D8f50127E6c2C8f');
};

export default func;
func.tags = ['BRIDGEADMIN', 'BRIDGEADMIN_deploy'];
func.dependencies = ['ObscuroBridge']
func.dependencies = ['TenBridge']
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
console.log(`Loaded message bus address = ${l2messageBusAddress}`);

// Tell the bridge to whitelist the address of HOC token. This generates a cross chain message.
let hocResult = await l1Network.deployments.execute("ObscuroBridge", {
let hocResult = await l1Network.deployments.execute("TenBridge", {
from: l1Accounts.deployer,
log: true,
}, "whitelistToken", HOCDeployment.address, "HOC", "HOC");
Expand All @@ -47,7 +47,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
}

// Tell the bridge to whitelist POC. This also generates a cross chain message.
const pocResult = await l1Network.deployments.execute("ObscuroBridge", {
const pocResult = await l1Network.deployments.execute("TenBridge", {
from: l1Accounts.deployer,
log: true,
}, "whitelistToken", POCDeployment.address, "POC", "POC");
Expand Down
1,292 changes: 1,292 additions & 0 deletions contracts/generated/TenBridge/TenBridge.go

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity >=0.7.0 <0.9.0;

// The interface for the layer 1 bridge that drives the whitelist
// and has the functionality to modify it.
interface IObscuroBridgeAdmin {
interface ITenBridgeAdmin {
// This will whitelist a token and generate a cross chain message to the ITokenFactory
// to create wrapped tokens in case of success.
function whitelistToken(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

pragma solidity >=0.7.0 <0.9.0;

import "./IObscuroBridgeAdmin.sol";
import "./ITenBridgeAdmin.sol";
import "../IBridge.sol";
import "../ITokenFactory.sol";
import "../../messaging/messenger/CrossChainEnabledObscuro.sol";
Expand All @@ -12,10 +12,10 @@ import "@openzeppelin/contracts/proxy/utils/Initializable.sol";

// This is the Ethereum side of the Obscuro Bridge.
// End-users can interact with it to transfer ERC20 tokens and native eth to the Layer 2 Obscuro.
contract ObscuroBridge is
contract TenBridge is
CrossChainEnabledObscuro,
IBridge,
IObscuroBridgeAdmin,
ITenBridgeAdmin,
AccessControl
{
// This is the role that is given to the address that represents a native currency
Expand Down Expand Up @@ -59,7 +59,7 @@ contract ObscuroBridge is
data,
uint32(Topics.MANAGEMENT),
0,
0,
0,
0
);
}
Expand All @@ -79,6 +79,8 @@ contract ObscuroBridge is
// verify ETH deposit.
function sendNative(address receiver) external payable override {
require(msg.value > 0, "Empty transfer.");
bytes memory data = abi.encode(ValueTransfer(msg.value, receiver));
queueMessage(remoteBridgeAddress, data, uint32(Topics.VALUE), 0, 0, 0);
_messageBus().sendValueToL2{value: msg.value}(receiver, msg.value);
}

Expand Down
6 changes: 3 additions & 3 deletions contracts/test/bridge-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { expect } from "chai";
import hre, { ethers } from "hardhat";
import { time } from "@nomicfoundation/hardhat-network-helpers";
import { bridge } from "../typechain-types/src";
import { MessageBus, ObscuroBridge, WrappedERC20__factory } from "../typechain-types";
import { MessageBus, TenBridge, WrappedERC20__factory } from "../typechain-types";
import { EthereumBridge } from "../typechain-types/src/bridge/L2/EthereumBridge";
import { CrossChainMessenger } from "../typechain-types/src/messaging/messenger";
import { Contract } from "hardhat/internal/hardhat-network/stack-traces/model";
Expand All @@ -22,15 +22,15 @@ describe("Bridge", function () {
let messengerL1: CrossChainMessenger
let messengerL2: CrossChainMessenger

let bridgeL1 : ObscuroBridge
let bridgeL1 : TenBridge
let bridgeL2 : EthereumBridge

let erc20address : any

this.beforeEach(async function(){
const MessageBus = await hre.ethers.getContractFactory("MessageBus");
const Messenger = await hre.ethers.getContractFactory("CrossChainMessenger");
const L1Bridge = await hre.ethers.getContractFactory("ObscuroBridge");
const L1Bridge = await hre.ethers.getContractFactory("TenBridge");
const L2Bridge = await hre.ethers.getContractFactory("EthereumBridge");

const [owner] = await ethers.getSigners();
Expand Down

0 comments on commit 20c0c23

Please sign in to comment.