Skip to content

Commit 7edb6d6

Browse files
authored
Fix BridgeMigration contract (#19)
* Fix wrong withdrawal's destination in BridgeMigration * Add a function to give back the admin of PausableAdmin, fix pause/unpause function
1 parent 65dfbe0 commit 7edb6d6

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

contracts/v0.8/migration/BridgeMigration.sol

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@ import "@openzeppelin/contracts/access/Ownable.sol";
55
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
66

77
interface IGateway {
8-
function paused() external returns (bool);
9-
10-
function pause() external;
11-
12-
function unpause() external;
13-
148
function withdrawTokenFor(
159
uint256 _withdrawalId,
1610
address _user,
@@ -24,12 +18,26 @@ interface IGatewayV2 {
2418
function receiveEther() external payable;
2519
}
2620

21+
interface IPausableAdmin {
22+
function pauseGateway() external;
23+
24+
function unpauseGateway() external;
25+
26+
function changeAdmin(address _newAdmin) external;
27+
}
28+
2729
contract BridgeMigration is Ownable {
2830
IGateway public gateway;
31+
IPausableAdmin public pausableAdmin;
2932
address public weth;
3033

31-
constructor(IGateway _gateway, address _weth) {
34+
constructor(
35+
IGateway _gateway,
36+
IPausableAdmin _pausableAdmin,
37+
address _weth
38+
) {
3239
gateway = _gateway;
40+
pausableAdmin = _pausableAdmin;
3341
weth = _weth;
3442
}
3543

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

4048
function pauseGateway() external onlyOwner {
41-
gateway.pause();
49+
pausableAdmin.pauseGateway();
4250
}
4351

4452
function unpauseGateway() external onlyOwner {
45-
gateway.unpause();
53+
pausableAdmin.unpauseGateway();
54+
}
55+
56+
function changePausableAdmin(address _newAdmin) external onlyOwner {
57+
pausableAdmin.changeAdmin(_newAdmin);
4658
}
4759

4860
function migrateAndTransfer(
@@ -60,11 +72,11 @@ contract BridgeMigration is Ownable {
6072
"BridgeMigration: invalid array length"
6173
);
6274

63-
gateway.unpause();
75+
pausableAdmin.pauseGateway();
6476
for (uint256 _i; _i < _withdrawalIds.length; _i++) {
65-
gateway.withdrawTokenFor(_withdrawalIds[_i], msg.sender, _tokens[_i], _amounts[_i], _signatures[_i]);
77+
gateway.withdrawTokenFor(_withdrawalIds[_i], address(this), _tokens[_i], _amounts[_i], _signatures[_i]);
6678
}
67-
gateway.pause();
79+
pausableAdmin.unpauseGateway();
6880

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

0 commit comments

Comments
 (0)