/**
* @dev Structure representing an identity with its signature/proof verification logic.
* Represents an EOA/CA account when signer is empty, use `guardianVerifier`as the actual signer for signature verification.
* OtherWise execute IPermissionVerifier(guardianVerifier).isValidPermission(hash, signer, signature).
*/structIdentity{addressguardianVerifier;bytessigner;}/**
* @dev Structure representing a guardian with a property
* The property of Guardian are defined by the associated RecoveryPolicyVerifier contract.
*/structGuardianInfo{Identityguardian;uint64property;//eg.,Weight,Percentage,Role with weight,etc.
}/**
* @dev Structure representing a threshold configuration
*/structThresholdConfig{uint64threshold;// Threshold value
int48lockPeriod;// Lock period for the threshold
}/**
* @dev Structure representing a recovery configuration
* A RecoveryConfig can have multiple threshold configurations for different threshold values and their lock periods, and the policyVerifier is optional.
*/structRecoveryConfigArg{addresspolicyVerifier;GuardianInfo[]guardianInfos;ThresholdConfig[]thresholdConfigs;}structPermission{Identityguardian;bytessignature;}
/**
* @dev Interface for recovery policy verification
*/interfaceIRecoveryPolicyVerifier{/**
* @dev Verify recovery policy and return verification success and lock period
* Verification includes checking if guardians exist in the Guardians List
*/functionverifyRecoveryPolicy(Permission[]memorypermissions,uint64[]memoryproperties)externalviewreturns(boolsucc,uint64weight);/**
* @dev Returns supported policy settings and accompanying property definitions for Guardian.
*/functiongetPolicyVerifierInfo()publicviewreturns(bytesmemory);}
interfaceIRecoveryAccount{modifieronlySelf(){require(msg.sender==address(this),"onlySelf: NOT_AUTHORIZED");_;}modifierInRecovering(addresspolicyVerifyAddress){(boolisRecovering,)=getRecoveryStatus(policyVerifierAddress);require(isRecovering,"InRecovering: no ongoing recovery");_;}/**
* @dev Events for updating guardians, starting for recovery, executing recovery, and canceling recovery
*/eventRecoveryStarted(bytesnewOwners,uint256nonce,uint48expiryTime);eventRecoveryExecuted(bytesnewOwners,uint256nonce);eventRecoveryCanceled(uint256nonce);/**
* @dev Return the domain separator name and version for signatures
* Also return the domainSeparator for EIP-712 signature
*//// @notice Domain separator name for signatures
functionDOMAIN_SEPARATOR_NAME()externalviewreturns(stringmemory);/// @notice Domain separator version for signatures
functionDOMAIN_SEPARATOR_VERSION()externalviewreturns(stringmemory);/// @notice returns the domainSeparator for EIP-712 signature
/// @return the bytes32 domainSeparator for EIP-712 signature
functiondomainSeparatorV4()externalviewreturns(bytes32);/**
* @dev Update /replace guardians and recovery policies
* Multiple recovery policies can be set using an array of RecoveryConfigArg
*/functionupdateGuardians(RecoveryConfigArg[]recoveryConfigArgs)externalonlySelf;// Generate EIP-712 message hash,
// Iterate over signatures for verification,
// Verify recovery policy,
// Store temporary state or recover immediately based on the result returned by verifyRecoveryPolicy.
functionstartRecovery(uint256configIndex,bytesnewOwner,Permission[]permissions)external;/**
* @dev Execute recovery
* temporary state -> ownerKey rotation
*/functionexecuteRecovery(uint256configIndex)external;functioncancelRecovery(uint256configIndex)externalonlySelfInRecovering(policyVerifier);functioncancelRecoveryByGuardians(uint256configIndex,Permission[]permissions)externalInRecovering(policyVerifier);/**
* @dev Get wallet recovery config, check if an identity is a guardian, get the nonce of social recovery, and get the recovery status of the wallet
*/functionisGuardian(uint256configIndex,identityguardian)publicviewreturns(bool);functiongetRecoveryConfigs()publicviewreturns(RecoveryConfigArg[]recoveryConfigArgs);functiongetRecoveryNonce()publicviewreturns(uint256nonce);functiongetRecoveryStatus(addresspolicyVerifier)publicviewreturns(boolisRecovering,uint48expiryTime);}