github.com/ethereum-optimism/optimism@v1.7.2/packages/contracts-bedrock/test/mocks/TestERC1271Wallet.sol (about)

     1  // SPDX-License-Identifier: MIT
     2  pragma solidity ^0.8.0;
     3  
     4  import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
     5  import { IERC1271 } from "@openzeppelin/contracts/interfaces/IERC1271.sol";
     6  import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
     7  
     8  /// @notice Simple ERC1271 wallet that can be used to test the ERC1271 signature checker.
     9  /// @notice https://github.com/OpenZeppelin/openzeppelin-contracts/
    10  ///         blob/master/contracts/mocks/ERC1271WalletMock.sol
    11  contract TestERC1271Wallet is Ownable, IERC1271 {
    12      constructor(address originalOwner) {
    13          transferOwnership(originalOwner);
    14      }
    15  
    16      function isValidSignature(bytes32 hash, bytes memory signature) public view override returns (bytes4 magicValue) {
    17          return ECDSA.recover(hash, signature) == owner() ? this.isValidSignature.selector : bytes4(0);
    18      }
    19  }