Skip to content

Commit

Permalink
Fix BridgeMigration contract (#19)
Browse files Browse the repository at this point in the history
* Fix wrong withdrawal's destination in BridgeMigration

* Add a function to give back the admin of PausableAdmin, fix pause/unpause function
  • Loading branch information
minh-bq authored May 16, 2022
1 parent 65dfbe0 commit 7edb6d6
Showing 1 changed file with 24 additions and 12 deletions.
36 changes: 24 additions & 12 deletions contracts/v0.8/migration/BridgeMigration.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

interface IGateway {
function paused() external returns (bool);

function pause() external;

function unpause() external;

function withdrawTokenFor(
uint256 _withdrawalId,
address _user,
Expand All @@ -24,12 +18,26 @@ interface IGatewayV2 {
function receiveEther() external payable;
}

interface IPausableAdmin {
function pauseGateway() external;

function unpauseGateway() external;

function changeAdmin(address _newAdmin) external;
}

contract BridgeMigration is Ownable {
IGateway public gateway;
IPausableAdmin public pausableAdmin;
address public weth;

constructor(IGateway _gateway, address _weth) {
constructor(
IGateway _gateway,
IPausableAdmin _pausableAdmin,
address _weth
) {
gateway = _gateway;
pausableAdmin = _pausableAdmin;
weth = _weth;
}

Expand All @@ -38,11 +46,15 @@ contract BridgeMigration is Ownable {
receive() external payable {}

function pauseGateway() external onlyOwner {
gateway.pause();
pausableAdmin.pauseGateway();
}

function unpauseGateway() external onlyOwner {
gateway.unpause();
pausableAdmin.unpauseGateway();
}

function changePausableAdmin(address _newAdmin) external onlyOwner {
pausableAdmin.changeAdmin(_newAdmin);
}

function migrateAndTransfer(
Expand All @@ -60,11 +72,11 @@ contract BridgeMigration is Ownable {
"BridgeMigration: invalid array length"
);

gateway.unpause();
pausableAdmin.pauseGateway();
for (uint256 _i; _i < _withdrawalIds.length; _i++) {
gateway.withdrawTokenFor(_withdrawalIds[_i], msg.sender, _tokens[_i], _amounts[_i], _signatures[_i]);
gateway.withdrawTokenFor(_withdrawalIds[_i], address(this), _tokens[_i], _amounts[_i], _signatures[_i]);
}
gateway.pause();
pausableAdmin.unpauseGateway();

for (uint256 _i; _i < _tokens.length; _i++) {
if (_tokens[_i] == weth) {
Expand Down

0 comments on commit 7edb6d6

Please sign in to comment.