Skip to content

Commit dfd0a24

Browse files
committed
fix: use upgradeable OZ contracts (C4 QA)
1 parent db2a17c commit dfd0a24

File tree

4 files changed

+32
-28
lines changed

4 files changed

+32
-28
lines changed

contracts/gateway/L1GraphTokenGateway.sol

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,17 @@ pragma solidity ^0.7.6;
44
pragma abicoder v2;
55

66
import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/Initializable.sol";
7-
import "@openzeppelin/contracts/utils/Address.sol";
8-
import "@openzeppelin/contracts/math/SafeMath.sol";
7+
import { AddressUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol";
8+
import { SafeMathUpgradeable } from "@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol";
99

10-
import "../arbitrum/L1ArbitrumMessenger.sol";
11-
import "./GraphTokenGateway.sol";
10+
import { L1ArbitrumMessenger } from "../arbitrum/L1ArbitrumMessenger.sol";
11+
import { IBridge } from "../arbitrum/IBridge.sol";
12+
import { IInbox } from "../arbitrum/IInbox.sol";
13+
import { IOutbox } from "../arbitrum/IOutbox.sol";
14+
import { ITokenGateway } from "../arbitrum/ITokenGateway.sol";
15+
import { Managed } from "../governance/Managed.sol";
16+
import { GraphTokenGateway } from "./GraphTokenGateway.sol";
17+
import { IGraphToken } from "../token/IGraphToken.sol";
1218

1319
/**
1420
* @title L1 Graph Token Gateway Contract
@@ -20,7 +26,7 @@ import "./GraphTokenGateway.sol";
2026
* and https://github.com/livepeer/arbitrum-lpt-bridge)
2127
*/
2228
contract L1GraphTokenGateway is Initializable, GraphTokenGateway, L1ArbitrumMessenger {
23-
using SafeMath for uint256;
29+
using SafeMathUpgradeable for uint256;
2430

2531
/// Address of the Graph Token contract on L2
2632
address public l2GRT;
@@ -112,8 +118,8 @@ contract L1GraphTokenGateway is Initializable, GraphTokenGateway, L1ArbitrumMess
112118
require(_inbox != address(0), "INVALID_INBOX");
113119
require(_l1Router != address(0), "INVALID_L1_ROUTER");
114120
require(!callhookAllowlist[_l1Router], "ROUTER_CANT_BE_ALLOWLISTED");
115-
require(Address.isContract(_inbox), "INBOX_MUST_BE_CONTRACT");
116-
require(Address.isContract(_l1Router), "ROUTER_MUST_BE_CONTRACT");
121+
require(AddressUpgradeable.isContract(_inbox), "INBOX_MUST_BE_CONTRACT");
122+
require(AddressUpgradeable.isContract(_l1Router), "ROUTER_MUST_BE_CONTRACT");
117123
inbox = _inbox;
118124
l1Router = _l1Router;
119125
emit ArbitrumAddressesSet(_inbox, _l1Router);
@@ -145,7 +151,7 @@ contract L1GraphTokenGateway is Initializable, GraphTokenGateway, L1ArbitrumMess
145151
*/
146152
function setEscrowAddress(address _escrow) external onlyGovernor {
147153
require(_escrow != address(0), "INVALID_ESCROW");
148-
require(Address.isContract(_escrow), "MUST_BE_CONTRACT");
154+
require(AddressUpgradeable.isContract(_escrow), "MUST_BE_CONTRACT");
149155
escrow = _escrow;
150156
emit EscrowAddressSet(_escrow);
151157
}
@@ -158,7 +164,7 @@ contract L1GraphTokenGateway is Initializable, GraphTokenGateway, L1ArbitrumMess
158164
function addToCallhookAllowlist(address _newAllowlisted) external onlyGovernor {
159165
require(_newAllowlisted != address(0), "INVALID_ADDRESS");
160166
require(_newAllowlisted != l1Router, "CANT_ALLOW_ROUTER");
161-
require(Address.isContract(_newAllowlisted), "MUST_BE_CONTRACT");
167+
require(AddressUpgradeable.isContract(_newAllowlisted), "MUST_BE_CONTRACT");
162168
require(!callhookAllowlist[_newAllowlisted], "ALREADY_ALLOWLISTED");
163169
callhookAllowlist[_newAllowlisted] = true;
164170
emit AddedToCallhookAllowlist(_newAllowlisted);

contracts/l2/gateway/L2GraphTokenGateway.sol

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
pragma solidity ^0.7.6;
44
pragma abicoder v2;
55

6-
import "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol";
7-
import "@openzeppelin/contracts/math/SafeMath.sol";
6+
import { ReentrancyGuardUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol";
7+
import { SafeMathUpgradeable } from "@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol";
88

9-
import "../../arbitrum/L2ArbitrumMessenger.sol";
10-
import "../../arbitrum/AddressAliasHelper.sol";
11-
import "../../gateway/GraphTokenGateway.sol";
12-
import "../../gateway/ICallhookReceiver.sol";
13-
import "../token/L2GraphToken.sol";
9+
import { L2ArbitrumMessenger } from "../../arbitrum/L2ArbitrumMessenger.sol";
10+
import { AddressAliasHelper } from "../../arbitrum/AddressAliasHelper.sol";
11+
import { ITokenGateway } from "../../arbitrum/ITokenGateway.sol";
12+
import { Managed } from "../../governance/Managed.sol";
13+
import { GraphTokenGateway } from "../../gateway/GraphTokenGateway.sol";
14+
import { ICallhookReceiver } from "../../gateway/ICallhookReceiver.sol";
15+
import { L2GraphToken } from "../token/L2GraphToken.sol";
1416

1517
/**
1618
* @title L2 Graph Token Gateway Contract
@@ -21,7 +23,7 @@ import "../token/L2GraphToken.sol";
2123
* and https://github.com/livepeer/arbitrum-lpt-bridge)
2224
*/
2325
contract L2GraphTokenGateway is GraphTokenGateway, L2ArbitrumMessenger, ReentrancyGuardUpgradeable {
24-
using SafeMath for uint256;
26+
using SafeMathUpgradeable for uint256;
2527

2628
/// Address of the Graph Token contract on L1
2729
address public l1GRT;

contracts/l2/token/GraphTokenUpgradeable.sol

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
pragma solidity ^0.7.6;
44

5-
import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20BurnableUpgradeable.sol";
6-
import "@openzeppelin/contracts/cryptography/ECDSA.sol";
5+
import { ERC20BurnableUpgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20BurnableUpgradeable.sol";
6+
import { ECDSAUpgradeable } from "@openzeppelin/contracts-upgradeable/cryptography/ECDSAUpgradeable.sol";
77

8-
import "../../upgrades/GraphUpgradeable.sol";
9-
import "../../governance/Governed.sol";
8+
import { GraphUpgradeable } from "../../upgrades/GraphUpgradeable.sol";
9+
import { Governed } from "../../governance/Governed.sol";
1010

1111
/**
1212
* @title GraphTokenUpgradeable contract
@@ -100,7 +100,7 @@ abstract contract GraphTokenUpgradeable is GraphUpgradeable, Governed, ERC20Burn
100100
)
101101
);
102102

103-
address recoveredAddress = ECDSA.recover(digest, _v, _r, _s);
103+
address recoveredAddress = ECDSAUpgradeable.recover(digest, _v, _r, _s);
104104
require(_owner == recoveredAddress, "GRT: invalid permit");
105105

106106
nonces[_owner] = nonces[_owner] + 1;

contracts/l2/token/L2GraphToken.sol

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,15 @@
22

33
pragma solidity ^0.7.6;
44

5-
import "@openzeppelin/contracts/math/SafeMath.sol";
6-
7-
import "./GraphTokenUpgradeable.sol";
8-
import "../../arbitrum/IArbToken.sol";
5+
import { GraphTokenUpgradeable } from "./GraphTokenUpgradeable.sol";
6+
import { IArbToken } from "../../arbitrum/IArbToken.sol";
97

108
/**
119
* @title L2 Graph Token Contract
1210
* @dev Provides the L2 version of the GRT token, meant to be minted/burned
1311
* through the L2GraphTokenGateway.
1412
*/
1513
contract L2GraphToken is GraphTokenUpgradeable, IArbToken {
16-
using SafeMath for uint256;
17-
1814
/// Address of the gateway (on L2) that is allowed to mint tokens
1915
address public gateway;
2016
/// Address of the corresponding Graph Token contract on L1

0 commit comments

Comments
 (0)