@bloxchain/contracts 1.0.0-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +49 -0
- package/abi/BareBlox.abi.json +1341 -0
- package/abi/BaseStateMachine.abi.json +1308 -0
- package/abi/ControlBlox.abi.json +6210 -0
- package/abi/EngineBlox.abi.json +872 -0
- package/abi/GuardController.abi.json +3045 -0
- package/abi/IDefinition.abi.json +94 -0
- package/abi/RoleBlox.abi.json +4569 -0
- package/abi/RuntimeRBAC.abi.json +1857 -0
- package/abi/RuntimeRBACDefinitions.abi.json +133 -0
- package/abi/SecureBlox.abi.json +4085 -0
- package/abi/SecureOwnable.abi.json +4085 -0
- package/abi/SecureOwnableDefinitions.abi.json +354 -0
- package/abi/SimpleRWA20.abi.json +5545 -0
- package/abi/SimpleRWA20Definitions.abi.json +172 -0
- package/abi/SimpleVault.abi.json +5208 -0
- package/abi/SimpleVaultDefinitions.abi.json +250 -0
- package/contracts/core/access/RuntimeRBAC.sol +344 -0
- package/contracts/core/access/interface/IRuntimeRBAC.sol +108 -0
- package/contracts/core/access/lib/definitions/RuntimeRBACDefinitions.sol +168 -0
- package/contracts/core/base/BaseStateMachine.sol +834 -0
- package/contracts/core/base/interface/IBaseStateMachine.sol +153 -0
- package/contracts/core/execution/GuardController.sol +507 -0
- package/contracts/core/execution/interface/IGuardController.sol +120 -0
- package/contracts/core/execution/lib/definitions/GuardControllerDefinitions.sol +401 -0
- package/contracts/core/lib/EngineBlox.sol +2283 -0
- package/contracts/core/security/SecureOwnable.sol +419 -0
- package/contracts/core/security/interface/ISecureOwnable.sol +118 -0
- package/contracts/core/security/lib/definitions/SecureOwnableDefinitions.sol +757 -0
- package/contracts/interfaces/IDefinition.sol +40 -0
- package/contracts/interfaces/IEventForwarder.sol +33 -0
- package/contracts/interfaces/IOnActionHook.sol +79 -0
- package/contracts/utils/SharedValidation.sol +486 -0
- package/package.json +47 -0
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
2
|
+
pragma solidity 0.8.33;
|
|
3
|
+
|
|
4
|
+
// Contracts imports
|
|
5
|
+
import "../base/BaseStateMachine.sol";
|
|
6
|
+
import "./lib/definitions/SecureOwnableDefinitions.sol";
|
|
7
|
+
import "../../interfaces/IDefinition.sol";
|
|
8
|
+
import "../../utils/SharedValidation.sol";
|
|
9
|
+
import "./interface/ISecureOwnable.sol";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @title SecureOwnable
|
|
13
|
+
* @dev Security-focused contract extending BaseStateMachine with ownership management
|
|
14
|
+
*
|
|
15
|
+
* SecureOwnable provides security-specific functionality built on top of the base state machine:
|
|
16
|
+
* - Multi-role security model with Owner, Broadcaster, and Recovery roles
|
|
17
|
+
* - Secure ownership transfer with time-locked operations
|
|
18
|
+
* - Broadcaster and recovery address management
|
|
19
|
+
* - Time-lock period configuration
|
|
20
|
+
*
|
|
21
|
+
* The contract implements four primary secure operation types:
|
|
22
|
+
* 1. OWNERSHIP_TRANSFER - For securely transferring contract ownership
|
|
23
|
+
* 2. BROADCASTER_UPDATE - For changing the broadcaster address
|
|
24
|
+
* 3. RECOVERY_UPDATE - For updating the recovery address
|
|
25
|
+
* 4. TIMELOCK_UPDATE - For modifying the time lock period
|
|
26
|
+
*
|
|
27
|
+
* Each operation follows a request -> approval workflow with appropriate time locks
|
|
28
|
+
* and authorization checks. Operations can be cancelled within specific time windows.
|
|
29
|
+
*
|
|
30
|
+
* This contract focuses purely on security logic while leveraging the BaseStateMachine
|
|
31
|
+
* for transaction management, meta-transactions, and state machine operations.
|
|
32
|
+
*/
|
|
33
|
+
abstract contract SecureOwnable is BaseStateMachine, ISecureOwnable {
|
|
34
|
+
using SharedValidation for *;
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
// Request flags
|
|
38
|
+
bool private _hasOpenOwnershipRequest;
|
|
39
|
+
bool private _hasOpenBroadcasterRequest;
|
|
40
|
+
|
|
41
|
+
event OwnershipTransferRequest(address currentOwner, address newOwner);
|
|
42
|
+
event OwnershipTransferCancelled(uint256 txId);
|
|
43
|
+
event OwnershipTransferUpdated(address oldOwner, address newOwner);
|
|
44
|
+
event BroadcasterUpdateRequest(address currentBroadcaster, address newBroadcaster);
|
|
45
|
+
event BroadcasterUpdateCancelled(uint256 txId);
|
|
46
|
+
event BroadcasterUpdated(address oldBroadcaster, address newBroadcaster);
|
|
47
|
+
event RecoveryAddressUpdated(address oldRecovery, address newRecovery);
|
|
48
|
+
event TimeLockPeriodUpdated(uint256 oldPeriod, uint256 newPeriod);
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @notice Initializer to initialize SecureOwnable state
|
|
53
|
+
* @param initialOwner The initial owner address
|
|
54
|
+
* @param broadcaster The broadcaster address
|
|
55
|
+
* @param recovery The recovery address
|
|
56
|
+
* @param timeLockPeriodSec The timelock period in seconds
|
|
57
|
+
* @param eventForwarder The event forwarder address
|
|
58
|
+
*/
|
|
59
|
+
function initialize(
|
|
60
|
+
address initialOwner,
|
|
61
|
+
address broadcaster,
|
|
62
|
+
address recovery,
|
|
63
|
+
uint256 timeLockPeriodSec,
|
|
64
|
+
address eventForwarder
|
|
65
|
+
) public virtual onlyInitializing {
|
|
66
|
+
// Initialize base state machine (only if not already initialized)
|
|
67
|
+
if (!_secureState.initialized) {
|
|
68
|
+
_initializeBaseStateMachine(initialOwner, broadcaster, recovery, timeLockPeriodSec, eventForwarder);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Load SecureOwnable-specific definitions
|
|
72
|
+
IDefinition.RolePermission memory secureOwnablePermissions = SecureOwnableDefinitions.getRolePermissions();
|
|
73
|
+
_loadDefinitions(
|
|
74
|
+
SecureOwnableDefinitions.getFunctionSchemas(),
|
|
75
|
+
secureOwnablePermissions.roleHashes,
|
|
76
|
+
secureOwnablePermissions.functionPermissions
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// ============ INTERFACE SUPPORT ============
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* @dev See {IERC165-supportsInterface}.
|
|
84
|
+
* @notice Adds ISecureOwnable interface ID for component detection
|
|
85
|
+
*/
|
|
86
|
+
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
|
|
87
|
+
return interfaceId == type(ISecureOwnable).interfaceId || super.supportsInterface(interfaceId);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Ownership Management
|
|
91
|
+
/**
|
|
92
|
+
* @dev Requests a transfer of ownership
|
|
93
|
+
* @return The transaction record
|
|
94
|
+
*/
|
|
95
|
+
function transferOwnershipRequest() public returns (EngineBlox.TxRecord memory) {
|
|
96
|
+
SharedValidation.validateRecovery(getRecovery());
|
|
97
|
+
if (_hasOpenOwnershipRequest) revert SharedValidation.ResourceAlreadyExists(bytes32(uint256(0)));
|
|
98
|
+
|
|
99
|
+
EngineBlox.TxRecord memory txRecord = _requestTransaction(
|
|
100
|
+
msg.sender,
|
|
101
|
+
address(this),
|
|
102
|
+
0, // value
|
|
103
|
+
0, // no gas limit
|
|
104
|
+
SecureOwnableDefinitions.OWNERSHIP_TRANSFER,
|
|
105
|
+
SecureOwnableDefinitions.TRANSFER_OWNERSHIP_SELECTOR,
|
|
106
|
+
abi.encode(getRecovery())
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
_hasOpenOwnershipRequest = true;
|
|
110
|
+
emit OwnershipTransferRequest(owner(), getRecovery());
|
|
111
|
+
return txRecord;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* @dev Approves a pending ownership transfer transaction after the release time
|
|
116
|
+
* @param txId The transaction ID
|
|
117
|
+
* @return The updated transaction record
|
|
118
|
+
*/
|
|
119
|
+
function transferOwnershipDelayedApproval(uint256 txId) public returns (EngineBlox.TxRecord memory) {
|
|
120
|
+
SharedValidation.validateOwnerOrRecovery(owner(), getRecovery());
|
|
121
|
+
|
|
122
|
+
EngineBlox.TxRecord memory updatedRecord = _approveTransaction(txId);
|
|
123
|
+
_hasOpenOwnershipRequest = false;
|
|
124
|
+
return updatedRecord;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* @dev Approves a pending ownership transfer transaction using a meta-transaction
|
|
129
|
+
* @param metaTx The meta-transaction
|
|
130
|
+
* @return The updated transaction record
|
|
131
|
+
*/
|
|
132
|
+
function transferOwnershipApprovalWithMetaTx(EngineBlox.MetaTransaction memory metaTx) public returns (EngineBlox.TxRecord memory) {
|
|
133
|
+
_validateBroadcaster(msg.sender);
|
|
134
|
+
SharedValidation.validateOwnerIsSigner(metaTx.params.signer, owner());
|
|
135
|
+
|
|
136
|
+
EngineBlox.TxRecord memory updatedRecord = _approveTransactionWithMetaTx(metaTx);
|
|
137
|
+
_hasOpenOwnershipRequest = false;
|
|
138
|
+
return updatedRecord;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* @dev Cancels a pending ownership transfer transaction
|
|
143
|
+
* @param txId The transaction ID
|
|
144
|
+
* @return The updated transaction record
|
|
145
|
+
*/
|
|
146
|
+
function transferOwnershipCancellation(uint256 txId) public returns (EngineBlox.TxRecord memory) {
|
|
147
|
+
SharedValidation.validateRecovery(getRecovery());
|
|
148
|
+
EngineBlox.TxRecord memory updatedRecord = _cancelTransaction(txId);
|
|
149
|
+
_hasOpenOwnershipRequest = false;
|
|
150
|
+
emit OwnershipTransferCancelled(txId);
|
|
151
|
+
return updatedRecord;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* @dev Cancels a pending ownership transfer transaction using a meta-transaction
|
|
156
|
+
* @param metaTx The meta-transaction
|
|
157
|
+
* @return The updated transaction record
|
|
158
|
+
*/
|
|
159
|
+
function transferOwnershipCancellationWithMetaTx(EngineBlox.MetaTransaction memory metaTx) public returns (EngineBlox.TxRecord memory) {
|
|
160
|
+
_validateBroadcaster(msg.sender);
|
|
161
|
+
SharedValidation.validateOwnerIsSigner(metaTx.params.signer, owner());
|
|
162
|
+
|
|
163
|
+
EngineBlox.TxRecord memory updatedRecord = _cancelTransactionWithMetaTx(metaTx);
|
|
164
|
+
_hasOpenOwnershipRequest = false;
|
|
165
|
+
emit OwnershipTransferCancelled(updatedRecord.txId);
|
|
166
|
+
return updatedRecord;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// Broadcaster Management
|
|
170
|
+
/**
|
|
171
|
+
* @dev Updates the broadcaster address
|
|
172
|
+
* @param newBroadcaster The new broadcaster address
|
|
173
|
+
* @return The execution options
|
|
174
|
+
*/
|
|
175
|
+
function updateBroadcasterRequest(address newBroadcaster) public returns (EngineBlox.TxRecord memory) {
|
|
176
|
+
SharedValidation.validateOwner(owner());
|
|
177
|
+
if (_hasOpenBroadcasterRequest) revert SharedValidation.ResourceAlreadyExists(bytes32(uint256(0)));
|
|
178
|
+
address[] memory broadcasters = getBroadcasters();
|
|
179
|
+
address currentBroadcaster = broadcasters.length > 0 ? broadcasters[0] : address(0);
|
|
180
|
+
SharedValidation.validateAddressUpdate(newBroadcaster, currentBroadcaster);
|
|
181
|
+
|
|
182
|
+
EngineBlox.TxRecord memory txRecord = _requestTransaction(
|
|
183
|
+
msg.sender,
|
|
184
|
+
address(this),
|
|
185
|
+
0, // value
|
|
186
|
+
0, // gas limit
|
|
187
|
+
SecureOwnableDefinitions.BROADCASTER_UPDATE,
|
|
188
|
+
SecureOwnableDefinitions.UPDATE_BROADCASTER_SELECTOR,
|
|
189
|
+
abi.encode(newBroadcaster)
|
|
190
|
+
);
|
|
191
|
+
|
|
192
|
+
_hasOpenBroadcasterRequest = true;
|
|
193
|
+
emit BroadcasterUpdateRequest(currentBroadcaster, newBroadcaster);
|
|
194
|
+
return txRecord;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* @dev Approves a pending broadcaster update transaction after the release time
|
|
199
|
+
* @param txId The transaction ID
|
|
200
|
+
* @return The updated transaction record
|
|
201
|
+
*/
|
|
202
|
+
function updateBroadcasterDelayedApproval(uint256 txId) public returns (EngineBlox.TxRecord memory) {
|
|
203
|
+
SharedValidation.validateOwner(owner());
|
|
204
|
+
EngineBlox.TxRecord memory updatedRecord = _approveTransaction(txId);
|
|
205
|
+
_hasOpenBroadcasterRequest = false;
|
|
206
|
+
return updatedRecord;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* @dev Approves a pending broadcaster update transaction using a meta-transaction
|
|
211
|
+
* @param metaTx The meta-transaction
|
|
212
|
+
* @return The updated transaction record
|
|
213
|
+
*/
|
|
214
|
+
function updateBroadcasterApprovalWithMetaTx(EngineBlox.MetaTransaction memory metaTx) public returns (EngineBlox.TxRecord memory) {
|
|
215
|
+
_validateBroadcaster(msg.sender);
|
|
216
|
+
SharedValidation.validateOwnerIsSigner(metaTx.params.signer, owner());
|
|
217
|
+
|
|
218
|
+
EngineBlox.TxRecord memory updatedRecord = _approveTransactionWithMetaTx(metaTx);
|
|
219
|
+
_hasOpenBroadcasterRequest = false;
|
|
220
|
+
return updatedRecord;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* @dev Cancels a pending broadcaster update transaction
|
|
225
|
+
* @param txId The transaction ID
|
|
226
|
+
* @return The updated transaction record
|
|
227
|
+
*/
|
|
228
|
+
function updateBroadcasterCancellation(uint256 txId) public returns (EngineBlox.TxRecord memory) {
|
|
229
|
+
SharedValidation.validateOwner(owner());
|
|
230
|
+
EngineBlox.TxRecord memory updatedRecord = _cancelTransaction(txId);
|
|
231
|
+
_hasOpenBroadcasterRequest = false;
|
|
232
|
+
emit BroadcasterUpdateCancelled(txId);
|
|
233
|
+
return updatedRecord;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* @dev Cancels a pending broadcaster update transaction using a meta-transaction
|
|
238
|
+
* @param metaTx The meta-transaction
|
|
239
|
+
* @return The updated transaction record
|
|
240
|
+
*/
|
|
241
|
+
function updateBroadcasterCancellationWithMetaTx(EngineBlox.MetaTransaction memory metaTx) public returns (EngineBlox.TxRecord memory) {
|
|
242
|
+
_validateBroadcaster(msg.sender);
|
|
243
|
+
SharedValidation.validateOwnerIsSigner(metaTx.params.signer, owner());
|
|
244
|
+
|
|
245
|
+
EngineBlox.TxRecord memory updatedRecord = _cancelTransactionWithMetaTx(metaTx);
|
|
246
|
+
_hasOpenBroadcasterRequest = false;
|
|
247
|
+
emit BroadcasterUpdateCancelled(updatedRecord.txId);
|
|
248
|
+
return updatedRecord;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// Recovery Management
|
|
252
|
+
/**
|
|
253
|
+
* @dev Creates execution params for updating the recovery address
|
|
254
|
+
* @param newRecoveryAddress The new recovery address
|
|
255
|
+
* @return The execution params
|
|
256
|
+
*/
|
|
257
|
+
function updateRecoveryExecutionParams(
|
|
258
|
+
address newRecoveryAddress
|
|
259
|
+
) public view returns (bytes memory) {
|
|
260
|
+
SharedValidation.validateAddressUpdate(newRecoveryAddress, getRecovery());
|
|
261
|
+
return abi.encode(newRecoveryAddress);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* @dev Requests and approves a recovery address update using a meta-transaction
|
|
266
|
+
* @param metaTx The meta-transaction
|
|
267
|
+
* @return The transaction record
|
|
268
|
+
*/
|
|
269
|
+
function updateRecoveryRequestAndApprove(
|
|
270
|
+
EngineBlox.MetaTransaction memory metaTx
|
|
271
|
+
) public returns (EngineBlox.TxRecord memory) {
|
|
272
|
+
_validateBroadcaster(msg.sender);
|
|
273
|
+
SharedValidation.validateOwnerIsSigner(metaTx.params.signer, owner());
|
|
274
|
+
|
|
275
|
+
return _requestAndApproveTransaction(metaTx);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// TimeLock Management
|
|
279
|
+
/**
|
|
280
|
+
* @dev Creates execution params for updating the time lock period
|
|
281
|
+
* @param newTimeLockPeriodSec The new time lock period in seconds
|
|
282
|
+
* @return The execution params
|
|
283
|
+
*/
|
|
284
|
+
function updateTimeLockExecutionParams(
|
|
285
|
+
uint256 newTimeLockPeriodSec
|
|
286
|
+
) public view returns (bytes memory) {
|
|
287
|
+
SharedValidation.validateTimeLockUpdate(newTimeLockPeriodSec, getTimeLockPeriodSec());
|
|
288
|
+
return abi.encode(newTimeLockPeriodSec);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* @dev Requests and approves a time lock period update using a meta-transaction
|
|
293
|
+
* @param metaTx The meta-transaction
|
|
294
|
+
* @return The transaction record
|
|
295
|
+
*/
|
|
296
|
+
function updateTimeLockRequestAndApprove(
|
|
297
|
+
EngineBlox.MetaTransaction memory metaTx
|
|
298
|
+
) public returns (EngineBlox.TxRecord memory) {
|
|
299
|
+
_validateBroadcaster(msg.sender);
|
|
300
|
+
SharedValidation.validateOwnerIsSigner(metaTx.params.signer, owner());
|
|
301
|
+
|
|
302
|
+
return _requestAndApproveTransaction(metaTx);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// Execution Functions
|
|
306
|
+
/**
|
|
307
|
+
* @dev External function that can only be called by the contract itself to execute ownership transfer
|
|
308
|
+
* @param newOwner The new owner address
|
|
309
|
+
*/
|
|
310
|
+
function executeTransferOwnership(address newOwner) external {
|
|
311
|
+
SharedValidation.validateInternalCall(address(this));
|
|
312
|
+
_transferOwnership(newOwner);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* @dev External function that can only be called by the contract itself to execute broadcaster update
|
|
317
|
+
* @param newBroadcaster The new broadcaster address
|
|
318
|
+
*/
|
|
319
|
+
function executeBroadcasterUpdate(address newBroadcaster) external {
|
|
320
|
+
SharedValidation.validateInternalCall(address(this));
|
|
321
|
+
_updateBroadcaster(newBroadcaster, 0);
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* @dev External function that can only be called by the contract itself to execute recovery update
|
|
326
|
+
* @param newRecoveryAddress The new recovery address
|
|
327
|
+
*/
|
|
328
|
+
function executeRecoveryUpdate(address newRecoveryAddress) external {
|
|
329
|
+
SharedValidation.validateInternalCall(address(this));
|
|
330
|
+
_updateRecoveryAddress(newRecoveryAddress);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* @dev External function that can only be called by the contract itself to execute timelock update
|
|
335
|
+
* @param newTimeLockPeriodSec The new timelock period in seconds
|
|
336
|
+
*/
|
|
337
|
+
function executeTimeLockUpdate(uint256 newTimeLockPeriodSec) external {
|
|
338
|
+
SharedValidation.validateInternalCall(address(this));
|
|
339
|
+
_updateTimeLockPeriod(newTimeLockPeriodSec);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
// ============ INTERNAL FUNCTIONS ============
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* @dev Transfers ownership of the contract
|
|
346
|
+
* @param newOwner The new owner of the contract
|
|
347
|
+
*/
|
|
348
|
+
function _transferOwnership(address newOwner) internal virtual {
|
|
349
|
+
address oldOwner = owner();
|
|
350
|
+
_updateAssignedWallet(EngineBlox.OWNER_ROLE, newOwner, oldOwner);
|
|
351
|
+
emit OwnershipTransferUpdated(oldOwner, newOwner);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* @dev Updates the broadcaster role at a specific index (location)
|
|
356
|
+
* @param newBroadcaster The new broadcaster address (zero address to revoke)
|
|
357
|
+
* @param location The index in the broadcaster role's authorized wallets set
|
|
358
|
+
*
|
|
359
|
+
* Logic:
|
|
360
|
+
* - If a broadcaster exists at `location` and `newBroadcaster` is non-zero,
|
|
361
|
+
* update that slot from old to new (role remains full).
|
|
362
|
+
* - If no broadcaster exists at `location` and `newBroadcaster` is non-zero,
|
|
363
|
+
* assign `newBroadcaster` to the broadcaster role (respecting maxWallets).
|
|
364
|
+
* - If `newBroadcaster` is the zero address and a broadcaster exists at `location`,
|
|
365
|
+
* revoke that broadcaster from the role.
|
|
366
|
+
*/
|
|
367
|
+
function _updateBroadcaster(address newBroadcaster, uint256 location) internal virtual {
|
|
368
|
+
EngineBlox.Role storage role = _getSecureState().roles[EngineBlox.BROADCASTER_ROLE];
|
|
369
|
+
|
|
370
|
+
address oldBroadcaster;
|
|
371
|
+
uint256 length = role.walletCount;
|
|
372
|
+
|
|
373
|
+
if (location < length) {
|
|
374
|
+
oldBroadcaster = _getAuthorizedWalletAt(EngineBlox.BROADCASTER_ROLE, location);
|
|
375
|
+
} else {
|
|
376
|
+
oldBroadcaster = address(0);
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
// Case 1: Revoke existing broadcaster at location
|
|
380
|
+
if (newBroadcaster == address(0)) {
|
|
381
|
+
if (oldBroadcaster != address(0)) {
|
|
382
|
+
_revokeWallet(EngineBlox.BROADCASTER_ROLE, oldBroadcaster);
|
|
383
|
+
emit BroadcasterUpdated(oldBroadcaster, address(0));
|
|
384
|
+
}
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
// Case 2: Update existing broadcaster at location
|
|
389
|
+
if (oldBroadcaster != address(0)) {
|
|
390
|
+
_updateAssignedWallet(EngineBlox.BROADCASTER_ROLE, newBroadcaster, oldBroadcaster);
|
|
391
|
+
emit BroadcasterUpdated(oldBroadcaster, newBroadcaster);
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
// Case 3: No broadcaster at location, assign a new one (will respect maxWallets)
|
|
396
|
+
_assignWallet(EngineBlox.BROADCASTER_ROLE, newBroadcaster);
|
|
397
|
+
emit BroadcasterUpdated(address(0), newBroadcaster);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* @dev Updates the recovery address
|
|
402
|
+
* @param newRecoveryAddress The new recovery address
|
|
403
|
+
*/
|
|
404
|
+
function _updateRecoveryAddress(address newRecoveryAddress) internal virtual {
|
|
405
|
+
address oldRecovery = getRecovery();
|
|
406
|
+
_updateAssignedWallet(EngineBlox.RECOVERY_ROLE, newRecoveryAddress, oldRecovery);
|
|
407
|
+
emit RecoveryAddressUpdated(oldRecovery, newRecoveryAddress);
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* @dev Updates the time lock period
|
|
412
|
+
* @param newTimeLockPeriodSec The new time lock period in seconds
|
|
413
|
+
*/
|
|
414
|
+
function _updateTimeLockPeriod(uint256 newTimeLockPeriodSec) internal virtual override {
|
|
415
|
+
uint256 oldPeriod = getTimeLockPeriodSec();
|
|
416
|
+
super._updateTimeLockPeriod(newTimeLockPeriodSec);
|
|
417
|
+
emit TimeLockPeriodUpdated(oldPeriod, newTimeLockPeriodSec);
|
|
418
|
+
}
|
|
419
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
2
|
+
pragma solidity 0.8.33;
|
|
3
|
+
|
|
4
|
+
// Contracts imports
|
|
5
|
+
import "../../lib/EngineBlox.sol";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @title ISecureOwnable
|
|
9
|
+
* @dev Interface for SecureOwnable functionality
|
|
10
|
+
* @notice This interface defines SecureOwnable-specific operations
|
|
11
|
+
* @notice Note: owner(), getBroadcasters(), and getRecovery() are available through BaseStateMachine
|
|
12
|
+
*/
|
|
13
|
+
interface ISecureOwnable {
|
|
14
|
+
// ============ OWNERSHIP MANAGEMENT ============
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @dev Requests a transfer of ownership
|
|
18
|
+
* @return The transaction record
|
|
19
|
+
*/
|
|
20
|
+
function transferOwnershipRequest() external returns (EngineBlox.TxRecord memory);
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @dev Approves a pending ownership transfer transaction after the release time
|
|
24
|
+
* @param txId The transaction ID
|
|
25
|
+
* @return The updated transaction record
|
|
26
|
+
*/
|
|
27
|
+
function transferOwnershipDelayedApproval(uint256 txId) external returns (EngineBlox.TxRecord memory);
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @dev Approves a pending ownership transfer transaction using a meta-transaction
|
|
31
|
+
* @param metaTx The meta-transaction
|
|
32
|
+
* @return The updated transaction record
|
|
33
|
+
*/
|
|
34
|
+
function transferOwnershipApprovalWithMetaTx(EngineBlox.MetaTransaction memory metaTx) external returns (EngineBlox.TxRecord memory);
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @dev Cancels a pending ownership transfer transaction
|
|
38
|
+
* @param txId The transaction ID
|
|
39
|
+
* @return The updated transaction record
|
|
40
|
+
*/
|
|
41
|
+
function transferOwnershipCancellation(uint256 txId) external returns (EngineBlox.TxRecord memory);
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @dev Cancels a pending ownership transfer transaction using a meta-transaction
|
|
45
|
+
* @param metaTx The meta-transaction
|
|
46
|
+
* @return The updated transaction record
|
|
47
|
+
*/
|
|
48
|
+
function transferOwnershipCancellationWithMetaTx(EngineBlox.MetaTransaction memory metaTx) external returns (EngineBlox.TxRecord memory);
|
|
49
|
+
|
|
50
|
+
// ============ BROADCASTER MANAGEMENT ============
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @dev Updates the broadcaster address
|
|
54
|
+
* @param newBroadcaster The new broadcaster address
|
|
55
|
+
* @return The transaction record
|
|
56
|
+
*/
|
|
57
|
+
function updateBroadcasterRequest(address newBroadcaster) external returns (EngineBlox.TxRecord memory);
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* @dev Approves a pending broadcaster update transaction after the release time
|
|
61
|
+
* @param txId The transaction ID
|
|
62
|
+
* @return The updated transaction record
|
|
63
|
+
*/
|
|
64
|
+
function updateBroadcasterDelayedApproval(uint256 txId) external returns (EngineBlox.TxRecord memory);
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* @dev Approves a pending broadcaster update transaction using a meta-transaction
|
|
68
|
+
* @param metaTx The meta-transaction
|
|
69
|
+
* @return The updated transaction record
|
|
70
|
+
*/
|
|
71
|
+
function updateBroadcasterApprovalWithMetaTx(EngineBlox.MetaTransaction memory metaTx) external returns (EngineBlox.TxRecord memory);
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @dev Cancels a pending broadcaster update transaction
|
|
75
|
+
* @param txId The transaction ID
|
|
76
|
+
* @return The updated transaction record
|
|
77
|
+
*/
|
|
78
|
+
function updateBroadcasterCancellation(uint256 txId) external returns (EngineBlox.TxRecord memory);
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* @dev Cancels a pending broadcaster update transaction using a meta-transaction
|
|
82
|
+
* @param metaTx The meta-transaction
|
|
83
|
+
* @return The updated transaction record
|
|
84
|
+
*/
|
|
85
|
+
function updateBroadcasterCancellationWithMetaTx(EngineBlox.MetaTransaction memory metaTx) external returns (EngineBlox.TxRecord memory);
|
|
86
|
+
|
|
87
|
+
// ============ RECOVERY MANAGEMENT ============
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* @dev Creates execution params for updating the recovery address
|
|
91
|
+
* @param newRecoveryAddress The new recovery address
|
|
92
|
+
* @return The execution params
|
|
93
|
+
*/
|
|
94
|
+
function updateRecoveryExecutionParams(address newRecoveryAddress) external view returns (bytes memory);
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* @dev Requests and approves a recovery address update using a meta-transaction
|
|
98
|
+
* @param metaTx The meta-transaction
|
|
99
|
+
* @return The transaction record
|
|
100
|
+
*/
|
|
101
|
+
function updateRecoveryRequestAndApprove(EngineBlox.MetaTransaction memory metaTx) external returns (EngineBlox.TxRecord memory);
|
|
102
|
+
|
|
103
|
+
// ============ TIMELOCK MANAGEMENT ============
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* @dev Creates execution params for updating the time lock period
|
|
107
|
+
* @param newTimeLockPeriodSec The new time lock period in seconds
|
|
108
|
+
* @return The execution params
|
|
109
|
+
*/
|
|
110
|
+
function updateTimeLockExecutionParams(uint256 newTimeLockPeriodSec) external view returns (bytes memory);
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* @dev Requests and approves a time lock period update using a meta-transaction
|
|
114
|
+
* @param metaTx The meta-transaction
|
|
115
|
+
* @return The transaction record
|
|
116
|
+
*/
|
|
117
|
+
function updateTimeLockRequestAndApprove(EngineBlox.MetaTransaction memory metaTx) external returns (EngineBlox.TxRecord memory);
|
|
118
|
+
}
|