账户
0xa6...a219
AssetLocker

AssetLocker

$500
此合同的源代码已经过验证!
合同元数据
编译器
0.8.20+commit.a1b79de6
语言
Solidity
合同源代码
文件 1 的 18:AssetBox.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {Callable} from "./base/Callable.sol";
import {NFTHolder} from "./base/NFTHolder.sol";
import {Receivable} from "./base/Receivable.sol";
import {Withdrawable} from "./base/Withdrawable.sol";

contract AssetBox is Ownable, Callable, NFTHolder, Receivable, Withdrawable {
  function name()
  external pure virtual
  returns (string memory) {
    return "AssetBox";
  }

  function version()
  external pure virtual
  returns (string memory) {
    return "1.1.0";
  }

  constructor(address initialOwner) Ownable(initialOwner) {}

  function _authorizeWithdraw(address)
  internal view virtual override(Withdrawable) onlyOwner {}

  function _authorizeCall(address)
  internal view virtual override(Callable) onlyOwner {}
}
合同源代码
文件 2 的 18:AssetLocker.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {IAssetLocker} from "./interface/IAssetLocker.sol";
import {AssetBox} from "@timeholder/asset-box/contracts/AssetBox.sol";

contract AssetLocker is IAssetLocker, AssetBox {
  function name()
  external pure virtual override
  returns (string memory) {
    return "AssetLocker";
  }

  function version()
  external pure virtual override
  returns (string memory) {
    return "1.1.1";
  }

  error ShortenedTimeMustBeGreaterThanZero();
  error UnauthorizedAccount(address account);
  error UnlockTimeHasNotArrivedYet(uint256 timestamp);

  address private _guardian;
  uint256 private _unlockTime;

  constructor(
    address initialOwner,
    address initialGuardian,
    uint256 lockTime
  ) AssetBox(initialOwner) {
    _transferGuardianship(initialGuardian);
    _setUnlockTime(block.timestamp + lockTime);
  }

  function _authorizeWithdraw(address)
  internal view override(AssetBox) onlyOwner {
    if (block.timestamp < _unlockTime) revert UnlockTimeHasNotArrivedYet(block.timestamp);
  }

  function _authorizeCall(address)
  internal view override(AssetBox) onlyOwner {
    if (block.timestamp < _unlockTime) revert UnlockTimeHasNotArrivedYet(block.timestamp);
  }

  modifier onlyGuardian() {
    if (_guardian != msg.sender) revert UnauthorizedAccount(msg.sender);
    _;
  }

  function guardian()
  external view
  returns (address) {
    return _guardian;
  }

  function unlockTime()
  external view
  returns (uint256) {
    return _unlockTime;
  }

  function isUnlocked()
  external view
  returns (bool) {
    return block.timestamp >= _unlockTime;
  }

  function transferGuardianship(address newGuardian)
  external
  onlyGuardian {
    _transferGuardianship(newGuardian);
  }

  function _transferGuardianship(address newGuardian)
  private {
    address oldGuardian = _guardian;
    _guardian = newGuardian;
    emit GuardianshipTransferred(oldGuardian, newGuardian);
  }

  function unlock()
  external
  onlyGuardian {
    _setUnlockTime(block.timestamp);
  }

  function shortenUnlockTime(uint256 shortenedTime)
  external
  onlyGuardian {
    if (shortenedTime == 0) revert ShortenedTimeMustBeGreaterThanZero();
    _setUnlockTime(_unlockTime - shortenedTime);
  }

  function _setUnlockTime(uint256 newUnlockTime)
  private {
    _unlockTime = newUnlockTime;
    emit UpdateUnlockTime(newUnlockTime);
  }
}
合同源代码
文件 3 的 18:Callable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {ICallable} from "../interface/ICallable.sol";

abstract contract Callable is ICallable {
  error CallableInsufficientBalance(uint256 balance, uint256 needed);
  error CallableContractCallFailed();

  /**
   * @dev Function that should revert when `msg.sender` is not authorized to call.
   *
   * ```solidity
   * function _authorizeCall(address) internal override(Callable) onlyOwner {}
   * ```
   */
  function _authorizeCall(address sender)
  internal virtual;

  function callContract(address target, bytes calldata data)
  external payable virtual
  returns (bytes memory) {
    _authorizeCall(msg.sender);
    (bool success, bytes memory result) = target.call{value: msg.value}(data);
    if (!success) revert CallableContractCallFailed();
    emit ContractCalled(target, data, result);
    return result;
  }

  function callContract(address target, bytes calldata data, uint256 amount)
  external virtual
  returns (bytes memory) {
    _authorizeCall(msg.sender);
    uint256 balance = address(this).balance;
    if (balance < amount) revert CallableInsufficientBalance(balance, amount);
    (bool success, bytes memory result) = target.call{value: amount}(data);
    if (!success) revert CallableContractCallFailed();
    emit ContractCalled(target, data, result);
    return result;
  }
}
合同源代码
文件 4 的 18:Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)

pragma solidity ^0.8.20;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}
合同源代码
文件 5 的 18:ERC1155Holder.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC1155/utils/ERC1155Holder.sol)

pragma solidity ^0.8.20;

import {IERC165, ERC165} from "../../../utils/introspection/ERC165.sol";
import {IERC1155Receiver} from "../IERC1155Receiver.sol";

/**
 * @dev Simple implementation of `IERC1155Receiver` that will allow a contract to hold ERC1155 tokens.
 *
 * IMPORTANT: When inheriting this contract, you must include a way to use the received tokens, otherwise they will be
 * stuck.
 */
abstract contract ERC1155Holder is ERC165, IERC1155Receiver {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
        return interfaceId == type(IERC1155Receiver).interfaceId || super.supportsInterface(interfaceId);
    }

    function onERC1155Received(
        address,
        address,
        uint256,
        uint256,
        bytes memory
    ) public virtual override returns (bytes4) {
        return this.onERC1155Received.selector;
    }

    function onERC1155BatchReceived(
        address,
        address,
        uint256[] memory,
        uint256[] memory,
        bytes memory
    ) public virtual override returns (bytes4) {
        return this.onERC1155BatchReceived.selector;
    }
}
合同源代码
文件 6 的 18:ERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)

pragma solidity ^0.8.20;

import {IERC165} from "./IERC165.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 */
abstract contract ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}
合同源代码
文件 7 的 18:ERC721Holder.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/utils/ERC721Holder.sol)

pragma solidity ^0.8.20;

import {IERC721Receiver} from "../IERC721Receiver.sol";

/**
 * @dev Implementation of the {IERC721Receiver} interface.
 *
 * Accepts all token transfers.
 * Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or
 * {IERC721-setApprovalForAll}.
 */
abstract contract ERC721Holder is IERC721Receiver {
    /**
     * @dev See {IERC721Receiver-onERC721Received}.
     *
     * Always returns `IERC721Receiver.onERC721Received.selector`.
     */
    function onERC721Received(address, address, uint256, bytes memory) public virtual returns (bytes4) {
        return this.onERC721Received.selector;
    }
}
合同源代码
文件 8 的 18:IAssetLocker.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

interface IAssetLocker {
  event GuardianshipTransferred(address indexed previousGuardian, address indexed newGuardian);
  event UpdateUnlockTime(uint256 unlockTime);

  function guardian() external view returns (address);
  function unlockTime() external view returns (uint256);

  /**
   * @dev The return value indicates whether it has been unlocked.
   */
  function isUnlocked() external view returns (bool);

  /**
   * @dev Transfers guardianship of the contract to a new account (`newGuardian`).
   * Can only be called by the current guardian.
   */
  function transferGuardianship(address newGuardian) external;

  /**
   * @dev Unlock.
   * Can only be called by the current guardian.
   */
  function unlock() external;

  /**
   * @dev Shorten unlock time.
   * Can only be called by the current guardian.
   *
   * @param shortenedTime is seconds and must be greater than `0`.
   */
  function shortenUnlockTime(uint256 shortenedTime) external;
}
合同源代码
文件 9 的 18:ICallable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

interface ICallable {
  event ContractCalled(address indexed target, bytes data, bytes result);

  /**
   * @dev Call the specified contract's function.
   * @param target The address of the target contract to call.
   * @param data The bytecode of the target contract to call function and parameters.
   *
   * You can choose to send ETH to the target contract when calling the function.
   */
  function callContract(address target, bytes calldata data) external payable returns (bytes memory result);

  /**
   * @dev Call the specified contract's function.
   * @param target The address of the target contract to call.
   * @param data The bytecode of the target contract to call function and parameters.
   * @param amount Send a specified amount of ETH from the current contract to the target contract.
   */
  function callContract(address target, bytes calldata data, uint256 amount) external returns (bytes memory result);
}
合同源代码
文件 10 的 18:IERC1155Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC1155/IERC1155Receiver.sol)

pragma solidity ^0.8.20;

import {IERC165} from "../../utils/introspection/IERC165.sol";

/**
 * @dev Interface that must be implemented by smart contracts in order to receive
 * ERC-1155 token transfers.
 */
interface IERC1155Receiver is IERC165 {
    /**
     * @dev Handles the receipt of a single ERC1155 token type. This function is
     * called at the end of a `safeTransferFrom` after the balance has been updated.
     *
     * NOTE: To accept the transfer, this must return
     * `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`
     * (i.e. 0xf23a6e61, or its own function selector).
     *
     * @param operator The address which initiated the transfer (i.e. msg.sender)
     * @param from The address which previously owned the token
     * @param id The ID of the token being transferred
     * @param value The amount of tokens being transferred
     * @param data Additional data with no specified format
     * @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed
     */
    function onERC1155Received(
        address operator,
        address from,
        uint256 id,
        uint256 value,
        bytes calldata data
    ) external returns (bytes4);

    /**
     * @dev Handles the receipt of a multiple ERC1155 token types. This function
     * is called at the end of a `safeBatchTransferFrom` after the balances have
     * been updated.
     *
     * NOTE: To accept the transfer(s), this must return
     * `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
     * (i.e. 0xbc197c81, or its own function selector).
     *
     * @param operator The address which initiated the batch transfer (i.e. msg.sender)
     * @param from The address which previously owned the token
     * @param ids An array containing ids of each token being transferred (order and length must match values array)
     * @param values An array containing amounts of each token being transferred (order and length must match ids array)
     * @param data Additional data with no specified format
     * @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed
     */
    function onERC1155BatchReceived(
        address operator,
        address from,
        uint256[] calldata ids,
        uint256[] calldata values,
        bytes calldata data
    ) external returns (bytes4);
}
合同源代码
文件 11 的 18:IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
合同源代码
文件 12 的 18:IERC721Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721Receiver.sol)

pragma solidity ^0.8.20;

/**
 * @title ERC721 token receiver interface
 * @dev Interface for any contract that wants to support safeTransfers
 * from ERC721 asset contracts.
 */
interface IERC721Receiver {
    /**
     * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
     * by `operator` from `from`, this function is called.
     *
     * It must return its Solidity selector to confirm the token transfer.
     * If any other value is returned or the interface is not implemented by the recipient, the transfer will be
     * reverted.
     *
     * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
     */
    function onERC721Received(
        address operator,
        address from,
        uint256 tokenId,
        bytes calldata data
    ) external returns (bytes4);
}
合同源代码
文件 13 的 18:IReceivable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

interface IReceivable {
  event Received(address indexed sender, uint256 value);

  receive() external payable;
}
合同源代码
文件 14 的 18:IWithdrawable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

interface IWithdrawable {
  event Withdrawal(address indexed sender, uint256 amount);
  event WithdrawalERC20(address indexed sender, address indexed token, uint256 amount);
  event WithdrawalERC721(address indexed sender, address indexed token, uint256 tokenId);
  event WithdrawalERC1155(address indexed sender, address indexed token, uint256 id, uint256 value);
  event WithdrawalERC1155Batch(address indexed sender, address indexed token, uint256[] ids, uint256[] values);

  /**
   * @dev Withdraw all ETH.
   * Can only be called by the authorized.
   */
  function withdraw() external;

  /**
   * @dev Withdraw a specified amount of ETH.
   * Can only be called by the authorized.
   */
  function withdraw(uint256 amount) external;

  /**
   * @dev Withdraw all ERC20 tokens.
   * Can only be called by the authorized.
   */
  function withdrawERC20(address token) external;

  /**
   * @dev Withdraw a specified amount of ERC20 tokens.
   * Can only be called by the authorized.
   */
  function withdrawERC20(address token, uint256 amount) external;

  /**
   * @dev Withdraw a ERC721 token.
   * Can only be called by the authorized.
   */
  function withdrawERC721(address token, uint256 tokenId, bytes calldata data) external;

  /**
   * @dev Withdraw a ERC1155 token.
   * Can only be called by the authorized.
   */
  function withdrawERC1155(address token, uint256 id, uint256 value, bytes calldata data) external;

  /**
   * @dev Withdraw multiple ERC1155 tokens.
   * Can only be called by the authorized.
   */
  function withdrawERC1155Batch(address token, uint256[] calldata ids, uint256[] calldata values, bytes calldata data) external;
}
合同源代码
文件 15 的 18:NFTHolder.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.20;

import {ERC721Holder} from "@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol";
import {ERC1155Holder} from "@openzeppelin/contracts/token/ERC1155/utils/ERC1155Holder.sol";

abstract contract NFTHolder is ERC721Holder, ERC1155Holder {}
合同源代码
文件 16 的 18:Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)

pragma solidity ^0.8.20;

import {Context} from "../utils/Context.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * The initial owner is set to the address provided by the deployer. This can
 * later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    /**
     * @dev The caller account is not authorized to perform an operation.
     */
    error OwnableUnauthorizedAccount(address account);

    /**
     * @dev The owner is not a valid owner account. (eg. `address(0)`)
     */
    error OwnableInvalidOwner(address owner);

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.
     */
    constructor(address initialOwner) {
        if (initialOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(initialOwner);
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        if (owner() != _msgSender()) {
            revert OwnableUnauthorizedAccount(_msgSender());
        }
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby disabling any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        if (newOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}
合同源代码
文件 17 的 18:Receivable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {IReceivable} from "../interface/IReceivable.sol";

abstract contract Receivable is IReceivable {
  receive() external payable virtual {
    emit Received(msg.sender, msg.value);
  }
}
合同源代码
文件 18 的 18:Withdrawable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {IWithdrawable} from "../interface/IWithdrawable.sol";

abstract contract Withdrawable is IWithdrawable {
  error WithdrawableInsufficientBalance(uint256 balance, uint256 needed);
  error WithdrawableERC20InsufficientBalance(address token, uint256 balance, uint256 needed);
  error WithdrawableWithdrawalFailed();

  /**
   * @dev Function that should revert when `msg.sender` is not authorized to withdraw.
   *
   * ```solidity
   * function _authorizeWithdraw(address) internal override(Withdrawable) onlyOwner {}
   * ```
   */
  function _authorizeWithdraw(address sender)
  internal virtual;

  function withdraw()
  external virtual {
    _authorizeWithdraw(msg.sender);
    _withdraw(0);
  }

  function withdraw(uint256 amount)
  external virtual {
    _authorizeWithdraw(msg.sender);
    _withdraw(amount);
  }

  function withdrawERC20(address token)
  external virtual {
    _authorizeWithdraw(msg.sender);
    _withdrawERC20(token, 0);
  }

  function withdrawERC20(address token, uint256 amount)
  external virtual {
    _authorizeWithdraw(msg.sender);
    _withdrawERC20(token, amount);
  }

  function withdrawERC721(address token, uint256 tokenId, bytes calldata data)
  external virtual {
    _authorizeWithdraw(msg.sender);
    _withdrawERC721(token, tokenId, data);
  }

  function withdrawERC1155(address token, uint256 id, uint256 value, bytes calldata data)
  external virtual {
    _authorizeWithdraw(msg.sender);
    _withdrawERC1155(token, id, value, data);
  }

  function withdrawERC1155Batch(address token, uint256[] calldata ids, uint256[] calldata values, bytes calldata data)
  external virtual {
    _authorizeWithdraw(msg.sender);
    _withdrawERC1155Batch(token, ids, values, data);
  }

  function _withdraw(uint256 amount)
  private {
    uint256 balance = address(this).balance;

    if (amount == 0) amount = balance;
    else if (balance < amount) revert WithdrawableInsufficientBalance(balance, amount);

    (bool ok,) = payable(msg.sender).call{value: amount}("");
    if (!ok) revert WithdrawableWithdrawalFailed();

    emit Withdrawal(msg.sender, amount);
  }

  function _withdrawERC20(address token, uint256 amount)
  private {
    (bool success, bytes memory result) = token.call(
      abi.encodeWithSignature("balanceOf(address)", address(this))
    );
    if (!success) revert WithdrawableWithdrawalFailed();
    uint256 balance = abi.decode(result, (uint256));

    if (amount == 0) amount = balance;
    else if (balance < amount) revert WithdrawableERC20InsufficientBalance(token, balance, amount);

    (bool ok,) = token.call(
      abi.encodeWithSignature("transfer(address,uint256)", msg.sender, amount)
    );
    if (!ok) revert WithdrawableWithdrawalFailed();

    emit WithdrawalERC20(msg.sender, token, amount);
  }

  function _withdrawERC721(address token, uint256 tokenId, bytes calldata data)
  private {
    (bool ok,) = token.call(
      abi.encodeWithSignature("safeTransferFrom(address,address,uint256,bytes)", address(this), msg.sender, tokenId, data)
    );
    if (!ok) revert WithdrawableWithdrawalFailed();

    emit WithdrawalERC721(msg.sender, token, tokenId);
  }

  function _withdrawERC1155(address token, uint256 id, uint256 value, bytes calldata data)
  private {
    (bool ok,) = token.call(
      abi.encodeWithSignature("safeTransferFrom(address,address,uint256,uint256,bytes)", address(this), msg.sender, id, value, data)
    );
    if (!ok) revert WithdrawableWithdrawalFailed();

    emit WithdrawalERC1155(msg.sender, token, id, value);
  }

  function _withdrawERC1155Batch(address token, uint256[] calldata ids, uint256[] calldata values, bytes calldata data)
  private {
    (bool ok,) = token.call(
      abi.encodeWithSignature("safeBatchTransferFrom(address,address,uint256[],uint256[],bytes)", address(this), msg.sender, ids, values, data)
    );
    if (!ok) revert WithdrawableWithdrawalFailed();

    emit WithdrawalERC1155Batch(msg.sender, token, ids, values);
  }
}
设置
{
  "compilationTarget": {
    "@timeholder/asset-locker/contracts/AssetLocker.sol": "AssetLocker"
  },
  "evmVersion": "paris",
  "libraries": {},
  "metadata": {
    "bytecodeHash": "ipfs"
  },
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "remappings": []
}
ABI
[{"inputs":[{"internalType":"address","name":"initialOwner","type":"address"},{"internalType":"address","name":"initialGuardian","type":"address"},{"internalType":"uint256","name":"lockTime","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"CallableContractCallFailed","type":"error"},{"inputs":[{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"CallableInsufficientBalance","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[],"name":"ShortenedTimeMustBeGreaterThanZero","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"UnauthorizedAccount","type":"error"},{"inputs":[{"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"UnlockTimeHasNotArrivedYet","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"WithdrawableERC20InsufficientBalance","type":"error"},{"inputs":[{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"WithdrawableInsufficientBalance","type":"error"},{"inputs":[],"name":"WithdrawableWithdrawalFailed","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"target","type":"address"},{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"},{"indexed":false,"internalType":"bytes","name":"result","type":"bytes"}],"name":"ContractCalled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousGuardian","type":"address"},{"indexed":true,"internalType":"address","name":"newGuardian","type":"address"}],"name":"GuardianshipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Received","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"unlockTime","type":"uint256"}],"name":"UpdateUnlockTime","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdrawal","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"WithdrawalERC1155","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"values","type":"uint256[]"}],"name":"WithdrawalERC1155Batch","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"WithdrawalERC20","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"WithdrawalERC721","type":"event"},{"inputs":[{"internalType":"address","name":"target","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"callContract","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"target","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"callContract","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"guardian","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isUnlocked","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC1155BatchReceived","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC1155Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"shortenedTime","type":"uint256"}],"name":"shortenUnlockTime","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newGuardian","type":"address"}],"name":"transferGuardianship","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unlock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unlockTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"version","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"withdrawERC1155","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"uint256[]","name":"values","type":"uint256[]"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"withdrawERC1155Batch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdrawERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"withdrawERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"withdrawERC721","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]