Skip to content

Commit 7f50c19

Browse files
authored
Merge pull request #68 from PracticalParticle/dev
Dev
2 parents 3528678 + 66ac195 commit 7f50c19

17 files changed

Lines changed: 797 additions & 1299 deletions

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,10 @@ Deployed addresses are written to **`deployed-addresses.json`** under the networ
215215

216216
| Contract | Address |
217217
|----------|---------|
218-
| EngineBlox | [`0x69449f091f5eecdd8be9dc826bb74ec751a96ea2`](https://sepolia.etherscan.io/address/0x69449f091f5eecdd8be9dc826bb74ec751a96ea2) |
219-
| SecureOwnableDefinitions | [`0x9ece73a49cb5186d71ef513556ca69402dc5e681`](https://sepolia.etherscan.io/address/0x9ece73a49cb5186d71ef513556ca69402dc5e681) |
220-
| RuntimeRBACDefinitions | [`0xbc0980067ebb9170b2d4b341aac8d5172394c10d`](https://sepolia.etherscan.io/address/0xbc0980067ebb9170b2d4b341aac8d5172394c10d) |
221-
| GuardControllerDefinitions | [`0x0ad52b25df78f6af74d09bd61442a333b9a192d0`](https://sepolia.etherscan.io/address/0x0ad52b25df78f6af74d09bd61442a333b9a192d0) |
218+
| EngineBlox | [`0x5f91de8521fd0f5ca8b709e7f04d5c57dbcba4e1`](https://sepolia.etherscan.io/address/0x5f91de8521fd0f5ca8b709e7f04d5c57dbcba4e1) |
219+
| SecureOwnableDefinitions | [`0xdca4830d74b66093e29bb080d92f837b944b4001`](https://sepolia.etherscan.io/address/0xdca4830d74b66093e29bb080d92f837b944b4001) |
220+
| RuntimeRBACDefinitions | [`0x7b964d1878664a61ed9eec90b8354f7df307ff21`](https://sepolia.etherscan.io/address/0x7b964d1878664a61ed9eec90b8354f7df307ff21) |
221+
| GuardControllerDefinitions | [`0x7a5361a3b2ace07982813f0bfc3a0a684d4ea0fe`](https://sepolia.etherscan.io/address/0x7a5361a3b2ace07982813f0bfc3a0a684d4ea0fe) |
222222

223223

224224
## 📖 Usage Examples

abi/GuardControllerDefinitions.abi.json

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,107 @@
226226
"stateMutability": "pure",
227227
"type": "function"
228228
},
229+
{
230+
"inputs": [
231+
{
232+
"internalType": "bytes4",
233+
"name": "functionSelector",
234+
"type": "bytes4"
235+
},
236+
{
237+
"internalType": "address",
238+
"name": "target",
239+
"type": "address"
240+
}
241+
],
242+
"name": "encodeAddTargetToWhitelist",
243+
"outputs": [
244+
{
245+
"internalType": "bytes",
246+
"name": "",
247+
"type": "bytes"
248+
}
249+
],
250+
"stateMutability": "pure",
251+
"type": "function"
252+
},
253+
{
254+
"inputs": [
255+
{
256+
"internalType": "bytes4",
257+
"name": "functionSelector",
258+
"type": "bytes4"
259+
},
260+
{
261+
"internalType": "address",
262+
"name": "target",
263+
"type": "address"
264+
}
265+
],
266+
"name": "encodeRemoveTargetFromWhitelist",
267+
"outputs": [
268+
{
269+
"internalType": "bytes",
270+
"name": "",
271+
"type": "bytes"
272+
}
273+
],
274+
"stateMutability": "pure",
275+
"type": "function"
276+
},
277+
{
278+
"inputs": [
279+
{
280+
"internalType": "string",
281+
"name": "functionSignature",
282+
"type": "string"
283+
},
284+
{
285+
"internalType": "string",
286+
"name": "operationName",
287+
"type": "string"
288+
},
289+
{
290+
"internalType": "enum EngineBlox.TxAction[]",
291+
"name": "supportedActions",
292+
"type": "EngineBlox.TxAction[]"
293+
}
294+
],
295+
"name": "encodeRegisterFunction",
296+
"outputs": [
297+
{
298+
"internalType": "bytes",
299+
"name": "",
300+
"type": "bytes"
301+
}
302+
],
303+
"stateMutability": "pure",
304+
"type": "function"
305+
},
306+
{
307+
"inputs": [
308+
{
309+
"internalType": "bytes4",
310+
"name": "functionSelector",
311+
"type": "bytes4"
312+
},
313+
{
314+
"internalType": "bool",
315+
"name": "safeRemoval",
316+
"type": "bool"
317+
}
318+
],
319+
"name": "encodeUnregisterFunction",
320+
"outputs": [
321+
{
322+
"internalType": "bytes",
323+
"name": "",
324+
"type": "bytes"
325+
}
326+
],
327+
"stateMutability": "pure",
328+
"type": "function"
329+
},
229330
{
230331
"inputs": [
231332
{

abi/RuntimeRBACDefinitions.abi.json

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,162 @@
148148
"stateMutability": "pure",
149149
"type": "function"
150150
},
151+
{
152+
"inputs": [
153+
{
154+
"internalType": "string",
155+
"name": "roleName",
156+
"type": "string"
157+
},
158+
{
159+
"internalType": "uint256",
160+
"name": "maxWallets",
161+
"type": "uint256"
162+
}
163+
],
164+
"name": "encodeCreateRole",
165+
"outputs": [
166+
{
167+
"internalType": "bytes",
168+
"name": "",
169+
"type": "bytes"
170+
}
171+
],
172+
"stateMutability": "pure",
173+
"type": "function"
174+
},
175+
{
176+
"inputs": [
177+
{
178+
"internalType": "bytes32",
179+
"name": "roleHash",
180+
"type": "bytes32"
181+
}
182+
],
183+
"name": "encodeRemoveRole",
184+
"outputs": [
185+
{
186+
"internalType": "bytes",
187+
"name": "",
188+
"type": "bytes"
189+
}
190+
],
191+
"stateMutability": "pure",
192+
"type": "function"
193+
},
194+
{
195+
"inputs": [
196+
{
197+
"internalType": "bytes32",
198+
"name": "roleHash",
199+
"type": "bytes32"
200+
},
201+
{
202+
"internalType": "address",
203+
"name": "wallet",
204+
"type": "address"
205+
}
206+
],
207+
"name": "encodeAddWallet",
208+
"outputs": [
209+
{
210+
"internalType": "bytes",
211+
"name": "",
212+
"type": "bytes"
213+
}
214+
],
215+
"stateMutability": "pure",
216+
"type": "function"
217+
},
218+
{
219+
"inputs": [
220+
{
221+
"internalType": "bytes32",
222+
"name": "roleHash",
223+
"type": "bytes32"
224+
},
225+
{
226+
"internalType": "address",
227+
"name": "wallet",
228+
"type": "address"
229+
}
230+
],
231+
"name": "encodeRevokeWallet",
232+
"outputs": [
233+
{
234+
"internalType": "bytes",
235+
"name": "",
236+
"type": "bytes"
237+
}
238+
],
239+
"stateMutability": "pure",
240+
"type": "function"
241+
},
242+
{
243+
"inputs": [
244+
{
245+
"internalType": "bytes32",
246+
"name": "roleHash",
247+
"type": "bytes32"
248+
},
249+
{
250+
"components": [
251+
{
252+
"internalType": "bytes4",
253+
"name": "functionSelector",
254+
"type": "bytes4"
255+
},
256+
{
257+
"internalType": "uint16",
258+
"name": "grantedActionsBitmap",
259+
"type": "uint16"
260+
},
261+
{
262+
"internalType": "bytes4[]",
263+
"name": "handlerForSelectors",
264+
"type": "bytes4[]"
265+
}
266+
],
267+
"internalType": "struct EngineBlox.FunctionPermission",
268+
"name": "functionPermission",
269+
"type": "tuple"
270+
}
271+
],
272+
"name": "encodeAddFunctionToRole",
273+
"outputs": [
274+
{
275+
"internalType": "bytes",
276+
"name": "",
277+
"type": "bytes"
278+
}
279+
],
280+
"stateMutability": "pure",
281+
"type": "function"
282+
},
283+
{
284+
"inputs": [
285+
{
286+
"internalType": "bytes32",
287+
"name": "roleHash",
288+
"type": "bytes32"
289+
},
290+
{
291+
"internalType": "bytes4",
292+
"name": "functionSelector",
293+
"type": "bytes4"
294+
}
295+
],
296+
"name": "encodeRemoveFunctionFromRole",
297+
"outputs": [
298+
{
299+
"internalType": "bytes",
300+
"name": "",
301+
"type": "bytes"
302+
}
303+
],
304+
"stateMutability": "pure",
305+
"type": "function"
306+
},
151307
{
152308
"inputs": [
153309
{

contracts/core/access/lib/definitions/RuntimeRBACDefinitions.sol

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,66 @@ library RuntimeRBACDefinitions {
197197
formats[5] = "(bytes32 roleHash, bytes4 functionSelector)";
198198
}
199199

200+
// ============ ROLE CONFIG ACTION DATA ENCODERS ============
201+
// Use these helpers to build action.data for each RoleConfigActionType without reading the contract.
202+
// Each encoder returns bytes suitable for RoleConfigAction(actionType, data).
203+
204+
/**
205+
* @dev Encodes data for CREATE_ROLE. Use with RoleConfigActionType.CREATE_ROLE.
206+
* @param roleName Name of the role to create
207+
* @param maxWallets Maximum number of wallets that can be assigned to this role
208+
*/
209+
function encodeCreateRole(string memory roleName, uint256 maxWallets) public pure returns (bytes memory) {
210+
return abi.encode(roleName, maxWallets);
211+
}
212+
213+
/**
214+
* @dev Encodes data for REMOVE_ROLE. Use with RoleConfigActionType.REMOVE_ROLE.
215+
* @param roleHash keccak256 hash of the role name
216+
*/
217+
function encodeRemoveRole(bytes32 roleHash) public pure returns (bytes memory) {
218+
return abi.encode(roleHash);
219+
}
220+
221+
/**
222+
* @dev Encodes data for ADD_WALLET. Use with RoleConfigActionType.ADD_WALLET.
223+
* @param roleHash Role to add the wallet to
224+
* @param wallet Address to assign to the role
225+
*/
226+
function encodeAddWallet(bytes32 roleHash, address wallet) public pure returns (bytes memory) {
227+
return abi.encode(roleHash, wallet);
228+
}
229+
230+
/**
231+
* @dev Encodes data for REVOKE_WALLET. Use with RoleConfigActionType.REVOKE_WALLET.
232+
* @param roleHash Role to revoke the wallet from
233+
* @param wallet Address to revoke
234+
*/
235+
function encodeRevokeWallet(bytes32 roleHash, address wallet) public pure returns (bytes memory) {
236+
return abi.encode(roleHash, wallet);
237+
}
238+
239+
/**
240+
* @dev Encodes data for ADD_FUNCTION_TO_ROLE. Use with RoleConfigActionType.ADD_FUNCTION_TO_ROLE.
241+
* @param roleHash Role to grant the function permission to
242+
* @param functionPermission FunctionPermission (functionSelector, grantedActionsBitmap, handlerForSelectors)
243+
*/
244+
function encodeAddFunctionToRole(
245+
bytes32 roleHash,
246+
EngineBlox.FunctionPermission memory functionPermission
247+
) public pure returns (bytes memory) {
248+
return abi.encode(roleHash, functionPermission);
249+
}
250+
251+
/**
252+
* @dev Encodes data for REMOVE_FUNCTION_FROM_ROLE. Use with RoleConfigActionType.REMOVE_FUNCTION_FROM_ROLE.
253+
* @param roleHash Role to remove the function from
254+
* @param functionSelector Selector of the function to remove
255+
*/
256+
function encodeRemoveFunctionFromRole(bytes32 roleHash, bytes4 functionSelector) public pure returns (bytes memory) {
257+
return abi.encode(roleHash, functionSelector);
258+
}
259+
200260
/**
201261
* @dev Creates execution params for a RBAC configuration batch (pure helper for EngineBlox).
202262
* @param actions Encoded role configuration actions (IRuntimeRBAC.RoleConfigAction[] layout)

0 commit comments

Comments
 (0)