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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 5 additions & 3 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 6 additions & 4 deletions
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-

0 commit comments

Comments
 (0)