@@ -14,12 +14,33 @@ import {NameRegistry} from "./NameRegistry.sol";
14
14
* reducing complexity for the caller.
15
15
*/
16
16
contract BundleRegistry is Ownable {
17
+ /*//////////////////////////////////////////////////////////////
18
+ ERRORS
19
+ //////////////////////////////////////////////////////////////*/
20
+
21
+ /// @dev Revert when the caller does not have the authority to perform the action
17
22
error Unauthorized ();
23
+
24
+ /// @dev Revert when excess funds could not be sent back to the caller
18
25
error CallFailed ();
19
26
27
+ /*//////////////////////////////////////////////////////////////
28
+ EVENTS
29
+ //////////////////////////////////////////////////////////////*/
30
+
20
31
/// @dev Emit when the trustedCaller is changed by the owner after the contract is deployed
21
32
event ChangeTrustedCaller (address indexed trustedCaller , address indexed owner );
22
33
34
+ /*//////////////////////////////////////////////////////////////
35
+ STORAGE
36
+ //////////////////////////////////////////////////////////////*/
37
+
38
+ /// @notice The data required to trustedBatchRegister a single user
39
+ struct BatchUser {
40
+ address to;
41
+ bytes16 username;
42
+ }
43
+
23
44
/// @dev The only address that can call trustedRegister and partialTrustedRegister
24
45
address internal trustedCaller;
25
46
@@ -29,6 +50,13 @@ contract BundleRegistry is Ownable {
29
50
/// @dev The address of the NameRegistry UUPS Proxy contract
30
51
NameRegistry internal immutable nameRegistry;
31
52
53
+ /*//////////////////////////////////////////////////////////////
54
+ CONSTANTS
55
+ //////////////////////////////////////////////////////////////*/
56
+
57
+ /// @dev The default homeUrl value for the IdRegistry call, to be used until Hubs are launched
58
+ string internal constant DEFAULT_URL = "https://www.farcaster.xyz/ " ;
59
+
32
60
/**
33
61
* @notice Configure the addresses of the Registry contracts and the trusted caller which is
34
62
* allowed to register during the invitation phase.
@@ -72,10 +100,11 @@ contract BundleRegistry is Ownable {
72
100
}
73
101
74
102
/**
75
- * @notice Register an fid and an fname during the Goerli phase, where registration can only be
76
- * performed by the Farcaster Invite Server (trustedCaller)
103
+ * @notice Register an fid and an fname during the first Mainnet phase, where registration of
104
+ * the fid is available to all, but registration of the fname can only be performed by
105
+ * the Farcaster Invite Server (trustedCaller)
77
106
*/
78
- function trustedRegister (
107
+ function partialTrustedRegister (
79
108
address to ,
80
109
address recovery ,
81
110
string calldata url ,
@@ -86,16 +115,15 @@ contract BundleRegistry is Ownable {
86
115
if (msg .sender != trustedCaller) revert Unauthorized ();
87
116
88
117
// Audit: is it possible to end up in a state where one passes but the other fails?
89
- idRegistry.trustedRegister (to, recovery, url);
118
+ idRegistry.register (to, recovery, url);
90
119
nameRegistry.trustedRegister (username, to, recovery, inviter, idRegistry.idOf (to));
91
120
}
92
121
93
122
/**
94
- * @notice Register an fid and an fname during the first Mainnet phase, where registration of
95
- * the fid is available to all, but registration of the fname can only be performed by
96
- * the Farcaster Invite Server (trustedCaller)
123
+ * @notice Register an fid and an fname during the Goerli phase, where registration can only be
124
+ * performed by the Farcaster Invite Server (trustedCaller)
97
125
*/
98
- function partialTrustedRegister (
126
+ function trustedRegister (
99
127
address to ,
100
128
address recovery ,
101
129
string calldata url ,
@@ -106,10 +134,26 @@ contract BundleRegistry is Ownable {
106
134
if (msg .sender != trustedCaller) revert Unauthorized ();
107
135
108
136
// Audit: is it possible to end up in a state where one passes but the other fails?
109
- idRegistry.register (to, recovery, url);
137
+ idRegistry.trustedRegister (to, recovery, url);
110
138
nameRegistry.trustedRegister (username, to, recovery, inviter, idRegistry.idOf (to));
111
139
}
112
140
141
+ /**
142
+ * @notice Register multiple fids and fname during a migration to a new network, where
143
+ * registration can only be performed by the Farcaster Invite Server (trustedCaller).
144
+ * Recovery address, inviter, invitee and homeUrl are initialized to default values
145
+ * during this migration.
146
+ */
147
+ function trustedBatchRegister (BatchUser[] calldata users ) external {
148
+ // Do not allow anyone except the Farcaster Invite Server (trustedCaller) to call this
149
+ if (msg .sender != trustedCaller) revert Unauthorized ();
150
+
151
+ for (uint256 i = 0 ; i < users.length ; i++ ) {
152
+ idRegistry.trustedRegister (users[i].to, address (0 ), DEFAULT_URL);
153
+ nameRegistry.trustedRegister (users[i].username, users[i].to, address (0 ), 0 , 0 );
154
+ }
155
+ }
156
+
113
157
/**
114
158
* @notice Change the trusted caller that can call trustedRegister and partialTrustedRegister
115
159
*/
0 commit comments