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 Tests
pull/3182/head
Yorke Rhodes 9 months ago committed by GitHub
parent 0d5a751982
commit fa465b7233
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      .github/workflows/storage-analysis.yml
  2. 62
      solidity/contracts/token/FastHypERC20.sol
  3. 61
      solidity/contracts/token/FastHypERC20Collateral.sol
  4. 6
      typescript/infra/config/environments/mainnet3/warp/verification.json

@ -55,6 +55,7 @@ jobs:
# Compare outputs # Compare outputs
- name: Compare outputs - name: Compare outputs
continue-on-error: true # diff exits with 1 if files differ
run: diff --unified solidity/base-storage solidity/HEAD-storage > layout.diff run: diff --unified solidity/base-storage solidity/HEAD-storage > layout.diff
- name: Comment PR with layout diff - name: Comment PR with layout diff

@ -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);
}
}

@ -1,11 +1,5 @@
{ {
"arbitrum": [ "arbitrum": [
{
"name": "HypERC20",
"address": "0x93ca0d85837FF83158Cd14D65B169CdB223b1921",
"constructorArguments": "0000000000000000000000000000000000000000000000000000000000000006000000000000000000000000979ca5202784112f4738403dbec5d0f3b9daabb9",
"isProxy": false
},
{ {
"name": "HypERC20", "name": "HypERC20",
"address": "0x93ca0d85837FF83158Cd14D65B169CdB223b1921", "address": "0x93ca0d85837FF83158Cd14D65B169CdB223b1921",

Loading…
Cancel
Save