Remove dupe FastHypERC20 for verifiable contracts (#3091)
### Description Duplicate FastHypERC20 implementations got into main following the v3 merge that prevent flattening used in verification ### Related issues - Unblocks https://github.com/hyperlane-xyz/issues/issues/886 ### Backward compatibility Yes ### Testing Unit Testspull/3182/head
parent
0d5a751982
commit
fa465b7233
@ -1,62 +0,0 @@ |
||||
// SPDX-License-Identifier: Apache-2.0 |
||||
pragma solidity >=0.8.0; |
||||
|
||||
import {HypERC20} from "./HypERC20.sol"; |
||||
|
||||
import {TokenRouter} from "./libs/TokenRouter.sol"; |
||||
import {FastTokenRouter} from "./libs/FastTokenRouter.sol"; |
||||
import {TokenMessage} from "./libs/TokenMessage.sol"; |
||||
|
||||
import {ERC20Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol"; |
||||
|
||||
/** |
||||
* @title Hyperlane ERC20 Token Router that extends ERC20 with remote transfer functionality. |
||||
* @author Abacus Works |
||||
* @dev Supply on each chain is not constant but the aggregate supply across all chains is. |
||||
*/ |
||||
contract FastHypERC20 is FastTokenRouter, HypERC20 { |
||||
constructor( |
||||
uint8 __decimals, |
||||
address _mailbox |
||||
) HypERC20(__decimals, _mailbox) {} |
||||
|
||||
/** |
||||
* @dev delegates transfer logic to `_transferTo`. |
||||
* @inheritdoc TokenRouter |
||||
*/ |
||||
function _handle( |
||||
uint32 _origin, |
||||
bytes32 _sender, |
||||
bytes calldata _message |
||||
) internal virtual override(FastTokenRouter, TokenRouter) { |
||||
FastTokenRouter._handle(_origin, _sender, _message); |
||||
} |
||||
|
||||
/** |
||||
* @dev Mints `_amount` of tokens to `_recipient`. |
||||
* @inheritdoc FastTokenRouter |
||||
*/ |
||||
function _fastTransferTo( |
||||
address _recipient, |
||||
uint256 _amount |
||||
) internal override { |
||||
_mint(_recipient, _amount); |
||||
} |
||||
|
||||
/** |
||||
* @dev Burns `_amount` of tokens from `_recipient`. |
||||
* @inheritdoc FastTokenRouter |
||||
*/ |
||||
function _fastRecieveFrom( |
||||
address _sender, |
||||
uint256 _amount |
||||
) internal override { |
||||
_burn(_sender, _amount); |
||||
} |
||||
|
||||
function balanceOf( |
||||
address _account |
||||
) public view virtual override(TokenRouter, HypERC20) returns (uint256) { |
||||
return HypERC20.balanceOf(_account); |
||||
} |
||||
} |
@ -1,61 +0,0 @@ |
||||
// SPDX-License-Identifier: Apache-2.0 |
||||
pragma solidity >=0.8.0; |
||||
|
||||
import {HypERC20Collateral} from "./HypERC20Collateral.sol"; |
||||
import {TokenRouter} from "./libs/TokenRouter.sol"; |
||||
import {FastTokenRouter} from "./libs/FastTokenRouter.sol"; |
||||
|
||||
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; |
||||
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; |
||||
|
||||
/** |
||||
* @title Hyperlane ERC20 Token Collateral that wraps an existing ERC20 with remote transfer functionality. |
||||
* @author Abacus Works |
||||
*/ |
||||
contract FastHypERC20Collateral is FastTokenRouter, HypERC20Collateral { |
||||
using SafeERC20 for IERC20; |
||||
|
||||
/** |
||||
* @notice Constructor |
||||
* @param erc20 Address of the token to keep as collateral |
||||
* @param _mailbox Address of the mailbox address |
||||
*/ |
||||
constructor( |
||||
address erc20, |
||||
address _mailbox |
||||
) HypERC20Collateral(erc20, _mailbox) {} |
||||
|
||||
/** |
||||
* @dev delegates transfer logic to `_transferTo`. |
||||
* @inheritdoc FastTokenRouter |
||||
*/ |
||||
function _handle( |
||||
uint32 _origin, |
||||
bytes32 _sender, |
||||
bytes calldata _message |
||||
) internal virtual override(FastTokenRouter, TokenRouter) { |
||||
FastTokenRouter._handle(_origin, _sender, _message); |
||||
} |
||||
|
||||
/** |
||||
* @dev Transfers `_amount` of `wrappedToken` to `_recipient`. |
||||
* @inheritdoc FastTokenRouter |
||||
*/ |
||||
function _fastTransferTo( |
||||
address _recipient, |
||||
uint256 _amount |
||||
) internal override { |
||||
wrappedToken.safeTransfer(_recipient, _amount); |
||||
} |
||||
|
||||
/** |
||||
* @dev Transfers in `_amount` of `wrappedToken` from `_recipient`. |
||||
* @inheritdoc FastTokenRouter |
||||
*/ |
||||
function _fastRecieveFrom( |
||||
address _sender, |
||||
uint256 _amount |
||||
) internal override { |
||||
wrappedToken.safeTransferFrom(_sender, address(this), _amount); |
||||
} |
||||
} |
Loading…
Reference in new issue