contract EthAdapter is AssetAdapter {

    uint16 internal constant ETH_TYPE_ID = 1;

    // the hashes are generated using `genTypeHashes` from `eip712.swaps`
    constructor() internal AssetAdapter(
        ETH_TYPE_ID,
        0x3f5e83ffc9f619035e6bbc5b772db010a6ea49213f31e8a5d137b6cebf8d19c7,
        0x4edc3bd27f6cb13e1f0e97fa9dd936fa2dc988debb1378354f49e2bb59be435e
    ) {}

    /**
    * @dev byte offsets, byte length & contents for ether asset data:
    * +00  32  uint256  data length (== 0x22 == 34 bytes)
    * +32   2  uint16   asset type  (== 1)
    * +34  32  uint256  ether amount in wei
    */
    function getAmount(bytes memory assetData) internal pure returns (uint256 amount) {
        // solium-disable-next-line security/no-inline-assembly
        assembly {
            amount := mload(add(assetData, 34))
        }
    }

    function sendAssetTo(
        bytes memory assetData, address payable _to
    ) internal returns (bool success) {
        _to.transfer(getAmount(assetData));  // always throws on failure
        return true;
    }

    function lockAssetFrom(
        bytes memory assetData, address _from
    ) internal returns (bool success) {
        require(msg.sender == _from, "invalid ether sender");
        require(msg.value == getAmount(assetData), "invalid ether amount sent");
        return true;
    }

    /**
     * Returns the EIP712 hash of the eth asset data struct:
     * EIP712EthAsset {
     *    ethAmount: uint256;
     * }
     */
    function getAssetTypedHash(bytes memory data) internal view returns (bytes32) {
        return keccak256(
            abi.encode(
                EIP712_ASSET_TYPEHASH,
                getAmount(data)
            )
        );
    }

}
/**
 * An adapter for handling ether swaps.
 *
 * @author Ramp Network sp. z o.o.
 */
function getAmount(bytes memory assetData) internal pure returns (uint256 amount) {
    // solium-disable-next-line security/no-inline-assembly
    assembly {
        amount := mload(add(assetData, 34))
    }
}

/**
 * @dev byte offsets, byte length & contents for ether asset data:
 * +00  32  uint256  data length (== 0x22 == 34 bytes)
 * +32   2  uint16   asset type  (== 1)
 * +34  32  uint256  ether amount in wei
 */