Skip to content
This repository has been archived by the owner on Dec 5, 2021. It is now read-only.

Commit

Permalink
Remove AddressManager from the L1 standard bridge
Browse files Browse the repository at this point in the history
  • Loading branch information
elenadimitrova authored and maurelian committed Jun 5, 2021
1 parent 0707d2b commit 3e709b4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import { iOVM_L2ERC20Bridge } from "../../../iOVM/bridge/tokens/iOVM_L2ERC20Brid
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";

/* Library Imports */
import { Lib_AddressResolver } from "../../../libraries/resolver/Lib_AddressResolver.sol";
import { Lib_AddressManager } from "../../../libraries/resolver/Lib_AddressManager.sol";
import { OVM_CrossDomainEnabled } from "../../../libraries/bridge/OVM_CrossDomainEnabled.sol";
import { Lib_PredeployAddresses } from "../../../libraries/constants/Lib_PredeployAddresses.sol";
import { SafeMath } from "@openzeppelin/contracts/math/SafeMath.sol";
Expand All @@ -25,7 +23,7 @@ import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
* Compiler used: solc
* Runtime target: EVM
*/
contract OVM_L1StandardBridge is iOVM_L1StandardBridge, OVM_CrossDomainEnabled, Lib_AddressResolver {
contract OVM_L1StandardBridge is iOVM_L1StandardBridge, OVM_CrossDomainEnabled {
using SafeMath for uint;
using SafeERC20 for IERC20;

Expand Down Expand Up @@ -53,7 +51,6 @@ contract OVM_L1StandardBridge is iOVM_L1StandardBridge, OVM_CrossDomainEnabled,
// This contract lives behind a proxy, so the constructor parameters will go unused.
constructor()
OVM_CrossDomainEnabled(address(0))
Lib_AddressResolver(address(0))
{}

/******************
Expand All @@ -73,12 +70,10 @@ contract OVM_L1StandardBridge is iOVM_L1StandardBridge, OVM_CrossDomainEnabled,
)
public
{
require(libAddressManager == Lib_AddressManager(0), "Contract has already been initialized.");
libAddressManager = Lib_AddressManager(_libAddressManager);
require(messenger == address(0), "Contract has already been initialized.");
messenger = _l1messenger;
l2TokenBridge = _l2TokenBridge;
ovmEth = _ovmEth;
messenger = resolve("Proxy__OVM_L1CrossDomainMessenger");
}

/**************
Expand Down Expand Up @@ -316,20 +311,10 @@ contract OVM_L1StandardBridge is iOVM_L1StandardBridge, OVM_CrossDomainEnabled,
* Temporary - Migrating ETH *
*****************************/

/**
* @dev Migrates entire ETH balance to another gateway.
* @param _to Gateway Proxy address to migrate ETH to.
*/
function migrateEth(address payable _to) external {
address owner = Lib_AddressManager(libAddressManager).owner();
require(msg.sender == owner, "Only the owner can migrate ETH");
uint256 balance = address(this).balance;
OVM_L1StandardBridge(_to).donateETH{value:balance}();
}

/**
* @dev Adds ETH balance to the account. This is meant to allow for ETH
* to be migrated from an old gateway to a new gateway.
* NOTE: This is left for one upgrade only so we are able to receive the migrated ETH from the old contract
*/
function donateETH() external payable {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -279,46 +279,6 @@ describe('OVM_L1StandardBridge', () => {
})
})

describe('migrating ETH', () => {
const migrateAmount = 1_000

let New_OVM_L1StandardBridge: Contract
beforeEach(async () => {
await OVM_L1StandardBridge.donateETH({ value: migrateAmount })
const bridgeBalance = await ethers.provider.getBalance(
OVM_L1StandardBridge.address
)
expect(bridgeBalance).to.equal(migrateAmount)

// Setup a new bridge to migrate to
New_OVM_L1StandardBridge = await (
await ethers.getContractFactory('OVM_L1StandardBridge')
).deploy()
await New_OVM_L1StandardBridge.initialize(
AddressManager.address,
Mock__OVM_L1CrossDomainMessenger.address,
DUMMY_L2_BRIDGE_ADDRESS,
Mock__OVM_ETH.address
)
})

it('should successfully migrate ETH to new bridge', async () => {
await OVM_L1StandardBridge.migrateEth(New_OVM_L1StandardBridge.address)
const newBridgeBalance = await ethers.provider.getBalance(
New_OVM_L1StandardBridge.address
)
expect(newBridgeBalance).to.equal(migrateAmount)
})

it('should not allow migrating ETH from non-owner', async () => {
await expect(
OVM_L1StandardBridge.connect(bob).migrateEth(
New_OVM_L1StandardBridge.address
)
).to.be.revertedWith('Only the owner can migrate ETH')
})
})

describe('ERC20 deposits', () => {
const INITIAL_DEPOSITER_BALANCE = 100_000
let depositer: string
Expand Down

0 comments on commit 3e709b4

Please sign in to comment.