TestERC1271Wallet.sol 932 Bytes
Newer Older
1 2 3 4 5 6 7
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;

import { IERC1271 } from "@openzeppelin/contracts/interfaces/IERC1271.sol";
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";

8
// solhint-disable max-line-length
9 10
/**
 * Simple ERC1271 wallet that can be used to test the ERC1271 signature checker.
James Kim's avatar
James Kim committed
11
 * https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/mocks/ERC1271WalletMock.sol
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
 */
contract TestERC1271Wallet is Ownable, IERC1271 {
    constructor(address originalOwner) {
        transferOwnership(originalOwner);
    }

    function isValidSignature(bytes32 hash, bytes memory signature)
        public
        view
        override
        returns (bytes4 magicValue)
    {
        return
            ECDSA.recover(hash, signature) == owner() ? this.isValidSignature.selector : bytes4(0);
    }
}