pragmasolidity^0.8.20;/**
* @notice Defines a common account recovery interface for smart accounts to implement.
* @notice 定义了一个通用的账户恢复接口,供智能账户实现。
*/interfaceIAccountRecovery{/**
* MUST be emitted whenever the owner of the account changes as a result
* of account recovery (e.g. in the `recoverOwnership` function).
* MUST 在账户所有者因账户恢复而发生更改时发出(例如,在 `recoverOwnership` 函数中)。
*/eventOwnershipRecovered(addressindexedoldOwner,addressindexednewOwner);/**
* MUST be emitted whenever a new recovery provider is added to
* the account (e.g. in the `addRecoveryProvider` function).
* MUST 在向账户添加新的恢复提供商时发出(例如,在 `addRecoveryProvider` 函数中)。
*/eventRecoveryProviderAdded(addressindexedprovider);/**
* MUST be emitted whenever a recovery provider is removed from
* the account (e.g. in the `removeRecoveryProvider` function).
* MUST 在从账户中删除恢复提供商时发出(例如,在 `removeRecoveryProvider` 函数中)。
*/eventRecoveryProviderRemoved(addressindexedprovider);/**
* @notice A function to add a new recovery provider.
* @notice 用于添加新的恢复提供商的函数。
* SHOULD be access controlled.
* SHOULD 应该是访问控制的。
* MUST check that `provider` is not `address(0)`.
* MUST 检查 `provider` 不是 `address(0)`。
* MUST call `subscribe` on the `provider`.
* MUST 调用 `provider` 上的 `subscribe`。
* MUST pass `recoveryData` to the `subscribe` function.
* MUST 将 `recoveryData` 传递给 `subscribe` 函数。
*
* @param provider the address of a recovery provider (ZKP verifier) to add.
* @param provider 要添加的恢复提供商(ZKP 验证器)的地址。
* @param recoveryData custom data (commitment) for the recovery provider.
* @param recoveryData 恢复提供商的自定义数据(承诺)。
*/functionaddRecoveryProvider(addressprovider,bytesmemoryrecoveryData)external;/**
* @notice A function to remove an existing recovery provider.
* @notice 用于删除现有恢复提供商的函数。
* SHOULD be access controlled.
* SHOULD 应该是访问控制的。
* MUST call `unsubscribe` on the `provider`.
* MUST 调用 `provider` 上的 `unsubscribe`。
*
* @param provider the address of a previously added recovery provider to remove.
* @param provider 要删除的先前添加的恢复提供商的地址。
*/functionremoveRecoveryProvider(addressprovider)external;/**
* @notice A view function to check if a provider has been previously added.
* @notice 用于检查提供商是否已先前添加的视图函数。
*
* @param provider the provider to check.
* @param provider 要检查的提供商。
* @return true if the provider exists in the account, false otherwise.
* @return 如果提供商存在于账户中,则返回 true,否则返回 false。
*/functionrecoveryProviderAdded(addressprovider)externalviewreturns(bool);/**
* @notice A non-view function to recover ownership of a smart account.
* @notice 用于恢复智能账户所有权的非视图函数。
* MUST check that `provider` exists in the account.
* MUST 检查 `provider` 是否存在于账户中。
* MUST call `recover` on the `provider`.
* MUST 调用 `provider` 上的 `recover`。
* MUST update the account owner to `newOwner` if `proof` verification succeeds.
* MUST 如果 `proof` 验证成功,则将账户所有者更新为 `newOwner`。
* MUST return `true` if the ownership recovery is successful.
* MUST 如果所有权恢复成功,则返回 `true`。
*
* @param newOwner the address of a new owner.
* @param newOwner 新所有者的地址。
* @param provider the address of a recovery provider.
* @param provider 恢复提供商的地址。
* @param proof an encoded proof of recovery (ZKP/ZKAI, signature, etc).
* @param proof 恢复的编码证明(ZKP/ZKAI、签名等)。
* @return `true` if recovery is successful, `false` (or revert) otherwise.
* @return 如果恢复成功,则返回 `true`,否则返回 `false`(或 revert)。
*/functionrecoverOwnership(addressnewOwner,addressprovider,bytesmemoryproof)externalreturns(bool);}
恢复提供商必须实现以下接口:
/**
* @notice Defines a common recovery provider interface.
* @notice 定义了一个通用的恢复提供商接口。
*/interfaceIRecoveryProvider{/**
* MUST be emitted whenever a new account subscribes to
* the recovery provider (e.g. in the `subscribe` function).
* MUST 在新账户订阅恢复提供商时发出(例如,在 `subscribe` 函数中)。
*/eventAccountSubscribed(addressindexedaccount);/**
* MUST be emitted whenever an account unsubscribes from
* the recovery provider (e.g. in the `unsubscribe` function).
* MUST 在账户取消订阅恢复提供商时发出(例如,在 `unsubscribe` 函数中)。
*/eventAccountUnsubscribed(addressindexedaccount);/**
* @notice A function that "subscribes" a smart account (msg.sender) to a recovery provider.
* @notice 一个将智能账户 (msg.sender)“订阅”到恢复提供商的函数。
* SHOULD process and assign the `recoveryData` to the `msg.sender`.
* SHOULD 处理并将 `recoveryData` 分配给 `msg.sender`。
*
* @param recoveryData a recovery commitment (hash/ZKP public output) to be used
* @param recoveryData 用于在 `recover` 函数中使用的恢复承诺(哈希/ZKP 公共输出)
* in the `recover` function to check a recovery proof validity.
* 用于检查恢复证明的有效性。
*/functionsubscribe(bytesmemoryrecoveryData)external;/**
* @notice A function that revokes a smart account subscription.
* @notice 一个撤销智能账户订阅的函数。
* MUST delete all the recovery data associated with the `msg.sender`.
* MUST 删除与 `msg.sender` 关联的所有恢复数据。
*/functionunsubscribe()external;/**
* @notice A function to get a recovery data (commitment) of an account.
* @notice 用于获取账户的恢复数据(承诺)的函数。
*
* @param account the account to get the recovery data of.
* @param account 要获取恢复数据的账户。
* @return the associated recovery data.
* @return 关联的恢复数据。
*/functiongetRecoveryData(addressaccount)externalviewreturns(bytesmemory);/**
* @notice A function that checks if a recovery of a smart account (msg.sender)
* @notice 一个检查智能账户 (msg.sender) 恢复到 `newOwner` 是否可能的函数。
* to the `newOwner` is possible.
* SHOULD use `msg.sender`'s `recoveryData` to check the `proof` validity.
* SHOULD 使用 `msg.sender` 的 `recoveryData` 来检查 `proof` 的有效性。
* MUST ensure that the `proof` can't be reused, e.g. update nonce.
* MUST 确保 `proof` 不能被重用,例如,更新 nonce。
*
* @param newOwner the new owner to recover the `msg.sender` ownership to.
* @param newOwner 用于恢复 `msg.sender` 所有权的新所有者。
* @param proof the recovery proof.
* @param proof 恢复证明。
*/functionrecover(addressnewOwner,bytesmemoryproof)external;}