Skip to content

Commit 1abe18c

Browse files
authored
Merge pull request #10 from reddyismav/halborn-audit
halborn audit fixes
2 parents d7c12b2 + 20c2b1f commit 1abe18c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+8424
-17348
lines changed

contracts/FxChild.sol

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: MIT
2-
pragma solidity 0.7.3;
2+
pragma solidity ^0.8.0;
33

44
// IStateReceiver represents interface to receive state
55
interface IStateReceiver {
@@ -19,7 +19,7 @@ contract FxChild is IStateReceiver {
1919

2020
event NewFxMessage(address rootMessageSender, address receiver, bytes data);
2121

22-
function setFxRoot(address _fxRoot) public {
22+
function setFxRoot(address _fxRoot) external {
2323
require(fxRoot == address(0x0));
2424
fxRoot = _fxRoot;
2525
}

contracts/FxRoot.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: MIT
2-
pragma solidity 0.7.3;
2+
pragma solidity ^0.8.0;
33

44

55
interface IStateSender {

contracts/examples/erc1155-transfer/FxERC1155ChildTunnel.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: MIT
2-
pragma solidity 0.7.3;
2+
pragma solidity ^0.8.0;
33

44
import {IFxERC1155} from "../../tokens/IFxERC1155.sol";
55
import {ERC1155Holder} from "../../lib/ERC1155Holder.sol" ;

contracts/examples/erc1155-transfer/FxERC1155RootTunnel.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: MIT
2-
pragma solidity 0.7.3;
2+
pragma solidity ^0.8.0;
33

44
import {ERC1155} from "../../lib/ERC1155.sol";
55
import {ERC1155Holder} from "../../lib/ERC1155Holder.sol" ;

contracts/examples/erc20-transfer/FxERC20ChildTunnel.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: MIT
2-
pragma solidity 0.7.3;
2+
pragma solidity ^0.8.0;
33

44
import { FxBaseChildTunnel } from '../../tunnel/FxBaseChildTunnel.sol';
55
import { Create2 } from '../../lib/Create2.sol';

contracts/examples/erc20-transfer/FxERC20RootTunnel.sol

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
// SPDX-License-Identifier: MIT
2-
pragma solidity 0.7.3;
2+
pragma solidity ^0.8.0;
33

44
import { ERC20 } from "../../lib/ERC20.sol";
55
import { Create2 } from "../../lib/Create2.sol";
66
import { FxBaseRootTunnel } from "../../tunnel/FxBaseRootTunnel.sol";
7+
import {SafeERC20,IERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
78

89
/**
910
* @title FxERC20RootTunnel
1011
*/
1112
contract FxERC20RootTunnel is FxBaseRootTunnel, Create2 {
13+
using SafeERC20 for IERC20;
1214
// maybe DEPOSIT and MAP_TOKEN can be reduced to bytes4
1315
bytes32 public constant DEPOSIT = keccak256("DEPOSIT");
1416
bytes32 public constant MAP_TOKEN = keccak256("MAP_TOKEN");
@@ -57,7 +59,7 @@ contract FxERC20RootTunnel is FxBaseRootTunnel, Create2 {
5759
}
5860

5961
// transfer from depositor to this contract
60-
ERC20(rootToken).transferFrom(
62+
IERC20(rootToken).safeTransferFrom(
6163
msg.sender, // depositor
6264
address(this), // manager contract
6365
amount
@@ -75,7 +77,7 @@ contract FxERC20RootTunnel is FxBaseRootTunnel, Create2 {
7577
require(rootToChildTokens[rootToken] == childToken, "FxERC20RootTunnel: INVALID_MAPPING_ON_EXIT");
7678

7779
// transfer from tokens to
78-
ERC20(rootToken).transfer(
80+
IERC20(rootToken).safeTransfer(
7981
to,
8082
amount
8183
);

contracts/examples/erc721-transfer/FxERC721ChildTunnel.sol

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: MIT
2-
pragma solidity 0.7.3;
2+
pragma solidity ^0.8.0;
33

44
import { FxBaseChildTunnel } from '../../tunnel/FxBaseChildTunnel.sol';
55
import { Create2 } from '../../lib/Create2.sol';
@@ -33,7 +33,7 @@ contract FxERC721ChildTunnel is FxBaseChildTunnel, Create2, IERC721Receiver {
3333
return this.onERC721Received.selector;
3434
}
3535

36-
function withdraw(address childToken, uint256 tokenId, bytes memory data) public {
36+
function withdraw(address childToken, uint256 tokenId, bytes memory data) external {
3737
IFxERC721 childTokenContract = IFxERC721(childToken);
3838
// child token contract will have root token
3939
address rootToken = childTokenContract.connectedToken();

contracts/examples/erc721-transfer/FxERC721RootTunnel.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: MIT
2-
pragma solidity 0.7.3;
2+
pragma solidity ^0.8.0;
33

44
import { ERC721 } from "../../lib/ERC721.sol";
55
import { Create2 } from "../../lib/Create2.sol";

contracts/examples/mintable-erc20-transfer/FxMintableERC20ChildTunnel.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: MIT
2-
pragma solidity 0.7.3;
2+
pragma solidity ^0.8.0;
33

44
import { FxBaseChildTunnel } from '../../tunnel/FxBaseChildTunnel.sol';
55
import { Create2 } from '../../lib/Create2.sol';

contracts/examples/mintable-erc20-transfer/FxMintableERC20RootTunnel.sol

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
// SPDX-License-Identifier: MIT
2-
pragma solidity 0.7.3;
2+
pragma solidity ^0.8.0;
33

44
import { Create2 } from "../../lib/Create2.sol";
55
import { SafeMath } from "../../lib/SafeMath.sol";
66
import { FxERC20 } from "../../tokens/FxERC20.sol";
77
import { FxBaseRootTunnel } from "../../tunnel/FxBaseRootTunnel.sol";
8+
import {SafeERC20,IERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
9+
810

911
/**
1012
* @title FxMintableERC20RootTunnel
1113
*/
1214
contract FxMintableERC20RootTunnel is FxBaseRootTunnel, Create2 {
1315
using SafeMath for uint256;
16+
using SafeERC20 for IERC20;
1417

1518
// maybe DEPOSIT and MAP_TOKEN can be reduced to bytes4
1619
bytes32 public constant DEPOSIT = keccak256("DEPOSIT");
@@ -30,7 +33,7 @@ contract FxMintableERC20RootTunnel is FxBaseRootTunnel, Create2 {
3033
require(rootToChildTokens[rootToken] != address(0x0), "FxMintableERC20RootTunnel: NO_MAPPING_FOUND");
3134

3235
// transfer from depositor to this contract
33-
FxERC20(rootToken).transferFrom(
36+
IERC20(rootToken).safeTransferFrom(
3437
msg.sender, // depositor
3538
address(this), // manager contract
3639
amount
@@ -68,7 +71,7 @@ contract FxMintableERC20RootTunnel is FxBaseRootTunnel, Create2 {
6871
tokenObj.approve(address(this), amount);
6972

7073
// transfer from tokens
71-
tokenObj.transferFrom(
74+
IERC20(rootToken).safeTransferFrom(
7275
address(this),
7376
to,
7477
amount
@@ -96,4 +99,3 @@ contract FxMintableERC20RootTunnel is FxBaseRootTunnel, Create2 {
9699
return (size > 0);
97100
}
98101
}
99-

contracts/examples/state-transfer/FxStateChildTunnel.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: MIT
2-
pragma solidity 0.7.3;
2+
pragma solidity ^0.8.0;
33

44
import { FxBaseChildTunnel } from '../../tunnel/FxBaseChildTunnel.sol';
55

contracts/examples/state-transfer/FxStateRootTunnel.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: MIT
2-
pragma solidity 0.7.3;
2+
pragma solidity ^0.8.0;
33

44
import { FxBaseRootTunnel } from '../../tunnel/FxBaseRootTunnel.sol';
55

contracts/lib/Address.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: MIT
22

3-
pragma solidity 0.7.3;
3+
pragma solidity ^0.8.0;
44

55
/**
66
* @dev Collection of functions related to the address type

contracts/lib/Context.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: MIT
22

3-
pragma solidity 0.7.3;
3+
pragma solidity ^0.8.0;
44

55
/*
66
* @dev Provides information about the current execution context, including the

contracts/lib/Create2.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: MIT
2-
pragma solidity 0.7.3;
2+
pragma solidity ^0.8.0;
33

44

55
// Create2 adds common methods for minimal proxy with create2

contracts/lib/ERC1155.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: MIT
22

3-
pragma solidity 0.7.3;
3+
pragma solidity ^0.8.0;
44

55
import "./IERC1155.sol";
66
import "./IERC1155Receiver.sol";

contracts/lib/ERC1155Holder.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: MIT
22

3-
pragma solidity 0.7.3;
3+
pragma solidity ^0.8.0;
44

55
import "./ERC1155Receiver.sol";
66

contracts/lib/ERC1155Receiver.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: MIT
22

3-
pragma solidity 0.7.3;
3+
pragma solidity ^0.8.0;
44

55
import "./IERC1155Receiver.sol";
66
import "./ERC165.sol";

contracts/lib/ERC165.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: MIT
22

3-
pragma solidity 0.7.3;
3+
pragma solidity ^0.8.0;
44

55
import "./IERC165.sol";
66

contracts/lib/ERC20.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: MIT
2-
pragma solidity 0.7.3;
2+
pragma solidity ^0.8.0;
33

44
import { IERC20 } from './IERC20.sol';
55
import { SafeMath } from './SafeMath.sol';

contracts/lib/ERC721.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: MIT
22

3-
pragma solidity 0.7.3;
3+
pragma solidity ^0.8.0;
44

55
import "./IERC721.sol";
66
import "./IERC721Receiver.sol";

contracts/lib/IERC1155.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: MIT
22

3-
pragma solidity 0.7.3;
3+
pragma solidity ^0.8.0;
44

55
import "./IERC165.sol";
66

contracts/lib/IERC1155MetadataURI.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: MIT
22

3-
pragma solidity 0.7.3;
3+
pragma solidity ^0.8.0;
44

55
import "./IERC1155.sol";
66

contracts/lib/IERC1155Receiver.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: MIT
22

3-
pragma solidity 0.7.3;
3+
pragma solidity ^0.8.0;
44

55
import "./IERC165.sol";
66

contracts/lib/IERC165.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: MIT
22

3-
pragma solidity 0.7.3;
3+
pragma solidity ^0.8.0;
44

55
/**
66
* @dev Interface of the ERC165 standard, as defined in the

contracts/lib/IERC20.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: MIT
2-
pragma solidity 0.7.3;
2+
pragma solidity ^0.8.0;
33

44
/**
55
* @dev Interface of the ERC20 standard as defined in the EIP.

contracts/lib/IERC721.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: MIT
22

3-
pragma solidity 0.7.3;
3+
pragma solidity ^0.8.0;
44

55
import "./IERC165.sol";
66

contracts/lib/IERC721Metadata.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: MIT
22

3-
pragma solidity 0.7.3;
3+
pragma solidity ^0.8.0;
44

55
import "./IERC721.sol";
66

contracts/lib/IERC721Receiver.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: MIT
22

3-
pragma solidity 0.7.3;
3+
pragma solidity ^0.8.0;
44

55
/**
66
* @title ERC721 token receiver interface

contracts/lib/Merkle.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: MIT
2-
pragma solidity 0.7.3;
2+
pragma solidity ^0.8.0;
33

44
library Merkle {
55
function checkMembership(

contracts/lib/MerklePatriciaProof.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: MIT
2-
pragma solidity 0.7.3;
2+
pragma solidity ^0.8.0;
33

44
import {RLPReader} from "./RLPReader.sol";
55

contracts/lib/Ownable.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: MIT
2-
pragma solidity 0.7.3;
2+
pragma solidity ^0.8.0;
33

44
/**
55
* @dev Contract module which provides a basic access control mechanism, where

0 commit comments

Comments
 (0)