forked from farcasterxyz/contracts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RecoveryProxy.sol
83 lines (74 loc) · 3.02 KB
/
RecoveryProxy.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// SPDX-License-Identifier: MIT
pragma solidity 0.8.21;
import {IIdRegistry} from "./interfaces/IIdRegistry.sol";
import {Ownable2Step} from "openzeppelin/contracts/access/Ownable2Step.sol";
/**
* @title Farcaster RecoveryProxy
*
* @notice RecoveryProxy allows the recovery execution logic to be changed
* without changing the recovery address.
*
* The proxy is set to the recovery address and it delegates
* permissions to execute the recovery to its owner. The owner
* can be changed at any time, for example from an EOA to a 2/3
* multisig. This allows a recovery service operator to change the
* recovery mechanisms in the future without requiring each user to
* come online and execute a transaction.
*
* @custom:security-contact [email protected]
*/
contract RecoveryProxy is Ownable2Step {
/*//////////////////////////////////////////////////////////////
EVENTS
//////////////////////////////////////////////////////////////*/
/**
* @notice Emit an event when owner changes the IdRegistry
*
* @param oldIdRegistry The previous IIdRegistry
* @param newIdRegistry The new IIdRegistry
*/
event SetIdRegistry(IIdRegistry oldIdRegistry, IIdRegistry newIdRegistry);
/*//////////////////////////////////////////////////////////////
IMMUTABLES
//////////////////////////////////////////////////////////////*/
/**
* @dev Address of the IdRegistry contract
*/
IIdRegistry public idRegistry;
/*//////////////////////////////////////////////////////////////
CONSTRUCTOR
//////////////////////////////////////////////////////////////*/
/**
* @notice Configure the address of the IdRegistry contract and
* set the initial owner.
*
* @param _idRegistry Address of the IdRegistry contract
* @param _initialOwner Initial owner address
*/
constructor(address _idRegistry, address _initialOwner) {
idRegistry = IIdRegistry(_idRegistry);
_transferOwnership(_initialOwner);
}
/**
* @notice Recover an fid for a user who has set the RecoveryProxy as their recovery address.
* Only owner.
*
* @param from The address that currently owns the fid.
* @param to The address to transfer the fid to.
* @param deadline Expiration timestamp of the signature.
* @param sig EIP-712 Transfer signature signed by the to address.
*/
function recover(address from, address to, uint256 deadline, bytes calldata sig) external onlyOwner {
idRegistry.recover(from, to, deadline, sig);
}
/**
* @notice Set the IdRegistry address.
* Only owner.
*
* @param _idRegistry IDRegistry contract address.
*/
function setIdRegistry(IIdRegistry _idRegistry) external onlyOwner {
emit SetIdRegistry(idRegistry, _idRegistry);
idRegistry = _idRegistry;
}
}