接口 - OpenZeppelin 文档

本文档描述了OpenZeppelin社区合约中定义的一系列标准接口,这些接口以.sol文件的形式提供,方便与实现了这些接口的第三方合约进行交互。文档详细列出了IERC7786GatewaySource、IERC7786Receiver、IERC7802、IERC7821和IERC7943等接口的ABI,包括函数、事件和错误定义,并提供了相关函数的详细说明,例如参数、返回值以及可能触发的事件和错误。

接口

https://docs.openzeppelin.com/contracts/api/interfaces 查看本文档效果更佳

标准化接口列表

这些接口以 .sol 文件的形式提供。它们可用于与实现它们的第三方合约进行交互。

详细 ABI

IERC7786GatewaySource

import "@openzeppelin/community-contracts/interfaces/IERC7786.sol";

ERC-7786 源网关的接口。

更多详情请参见 ERC-7786

函数

  • supportsAttribute(selector)

  • sendMessage(recipient, payload, attributes)

事件

  • MessageSent(sendId, sender, receiver, payload, value, attributes)

错误

  • UnsupportedAttribute(selector)
supportsAttribute(bytes4 selector) → bool external

用于检查是否支持某个属性的 Getter。

sendMessage(bytes recipient, bytes payload, bytes[] attributes) → bytes32 sendId external

用于创建新消息的端点。如果消息在发送到目标链之前需要进一步的(网关特定的)处理,则必须返回一个非零的 outboxId。否则,必须发送消息,并且此函数必须返回 0。

如果任何 attributes 不被支持,此函数应使用 UnsupportedAttribute 错误回滚。 其他错误应使用 ERC-7786 中未指定的错误回滚。

MessageSent(bytes32 indexed sendId, bytes sender, bytes receiver, bytes payload, uint256 value, bytes[] attributes) event

创建消息时发出的事件。如果 outboxId 为零,则无需进一步处理。如果 outboxId 不为零,则需要进一步的(网关特定的和非标准化的)操作。

UnsupportedAttribute(bytes4 selector) error

当由于指定了不支持的属性而导致消息创建失败时,会抛出此错误。

IERC7786Receiver

import "@openzeppelin/community-contracts/interfaces/IERC7786.sol";

ERC-7786 客户端合约(接收者)的接口。

更多详情请参见 ERC-7786

函数

  • executeMessage(receiveId, sender, payload, attributes)
executeMessage(bytes32 receiveId, bytes sender, bytes payload, bytes[] attributes) → bytes4 external

用于接收跨链消息的端点。

此函数可以直接由网关调用。

IERC7802

import "@openzeppelin/community-contracts/interfaces/IERC7802.sol";

函数

  • crosschainMint(_to, _amount)

  • crosschainBurn(_from, _amount)

IERC165

  • supportsInterface(interfaceId)

事件

  • CrosschainMint(to, amount, sender)

  • CrosschainBurn(from, amount, sender)

crosschainMint(address _to, uint256 _amount) external
crosschainBurn(address _from, uint256 _amount) external
CrosschainMint(address indexed to, uint256 amount, address indexed sender) event
CrosschainBurn(address indexed from, uint256 amount, address indexed sender) event

IERC7821

import "@openzeppelin/community-contracts/interfaces/IERC7821.sol";

最小批量执行器的接口。

函数

  • execute(mode, executionData)

  • supportsExecutionMode(mode)

execute(bytes32 mode, bytes executionData) external

执行 executionData 中的调用。 如果任何调用失败,则还原并冒泡错误。

executionData 编码:

支持的模式:

  • bytes32(0x01000000000000000000…​):不支持可选的 opData

  • bytes32(0x01000000000078210001…​):支持可选的 opData

授权检查:

  • 如果 opData 为空,则实现应要求 msg.sender == address(this)

  • 如果 opData 不为空,则实现应使用编码在 opData 中的签名来确定调用者是否可以执行该执行。

opData 可用于存储其他数据以进行身份验证、 paymaster 数据、gas 限制等。

supportsExecutionMode(bytes32 mode) → bool external

提供此函数是为了让前端检测支持。 仅对以下项返回 true:

  • bytes32(0x01000000000000000000…​):不支持可选的 opData

  • bytes32(0x01000000000078210001…​):支持可选的 opData

IERC7943

import "@openzeppelin/community-contracts/interfaces/IERC7943.sol";

函数

  • forceTransfer(from, to, tokenId, amount)

  • setFrozen(user, tokenId, amount)

  • getFrozen(user, tokenId)

  • isTransferAllowed(from, to, tokenId, amount)

  • isUserAllowed(user)

IERC165

  • supportsInterface(interfaceId)

事件

  • ForcedTransfer(from, to, tokenId, amount)

  • Frozen(user, tokenId, amount)

错误

  • ERC7943NotAllowedUser(account)

  • ERC7943NotAllowedTransfer(from, to, tokenId, amount)

  • ERC7943InsufficientUnfrozenBalance(user, tokenId, amount, unfrozen)

forceTransfer(address from, address to, uint256 tokenId, uint256 amount) external

需要特定授权。用于法规遵从或恢复场景。

setFrozen(address user, uint256 tokenId, uint256 amount) external

需要特定授权。冻结的 token 用户无法转移。

getFrozen(address user, uint256 tokenId) → uint256 amount external
isTransferAllowed(address from, address to, uint256 tokenId, uint256 amount) → bool allowed external

这可能涉及诸如允许列表、阻止列表、转移限制和其他策略定义的限制之类的检查。

isUserAllowed(address user) → bool allowed external

这通常用于允许列表/KYC/KYB/AML 检查。

ForcedTransfer(address indexed from, address indexed to, uint256 tokenId, uint256 amount) event
Frozen(address indexed user, uint256 indexed tokenId, uint256 amount) event
ERC7943NotAllowedUser(address account) error
ERC7943NotAllowedTransfer(address from, address to, uint256 tokenId, uint256 amount) error
ERC7943InsufficientUnfrozenBalance(address user, uint256 tokenId, uint256 amount, uint256 unfrozen) error

← Crosschain

Proxy →

  • 原文链接: docs.openzeppelin.com/co...
  • 登链社区 AI 助手,为大家转译优秀英文文章,如有翻译不通的地方,还请包涵~
点赞 0
收藏 0
分享
本文参与登链社区写作激励计划 ,好文好收益,欢迎正在阅读的你也加入。

0 条评论

请先 登录 后评论
OpenZeppelin
OpenZeppelin
江湖只有他的大名,没有他的介绍。