Skip to content

Commit 7d45ee8

Browse files
authored
Merge pull request #106 from PracticalParticle/work
Work
2 parents ab99b08 + c0be397 commit 7d45ee8

58 files changed

Lines changed: 2523 additions & 2280 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CONTRIBUTING.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,11 +273,14 @@ npm run test:coverage
273273

274274
## Documentation
275275

276+
**Source of truth:** Solidity contracts are the source of truth for protocol API and behavior. The `docs/` directory is generated from contract NatSpec; do not edit those generated files by hand. For the full documentation map, updating process, and audit checklist, see **[CODEBASE_DOCUMENTATION.md](CODEBASE_DOCUMENTATION.md)**.
277+
276278
### Contract Documentation
277279
- **NatSpec comments** for all public functions
278280
- **Security annotations** for sensitive operations
279281
- **Usage examples** in comments
280282
- **Parameter descriptions** for all inputs/outputs
283+
- **Regenerate API docs** after contract changes: `npm run docgen` (see [docgen/README.md](docgen/README.md))
281284

282285
### SDK Documentation
283286
- **JSDoc comments** for all public methods

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,16 +111,16 @@ Addresses are written to **`deployed-addresses.json`**.
111111

112112
| Contract | Address |
113113
|----------|---------|
114-
| EngineBlox | [`0xd0db4bcfac215e86371c55ba9d91030082fe7adb`](https://sepolia.etherscan.io/address/0xd0db4bcfac215e86371c55ba9d91030082fe7adb) |
115-
| SecureOwnableDefinitions | [`0xd21e88564377cbbed7885416cf0462b1a7e424aa`](https://sepolia.etherscan.io/address/0xd21e88564377cbbed7885416cf0462b1a7e424aa) |
116-
| RuntimeRBACDefinitions | [`0x03156b0dcbd104c397aa3463705964b933ed4d3f`](https://sepolia.etherscan.io/address/0x03156b0dcbd104c397aa3463705964b933ed4d3f) |
117-
| GuardControllerDefinitions | [`0x4b828c8575fcb375158d0926fd2ca01e5f41ca1f`](https://sepolia.etherscan.io/address/0x4b828c8575fcb375158d0926fd2ca01e5f41ca1f) |
114+
| EngineBlox | [`0xb2cb295d62b1296d426344bcaea7f13e6415db33`](https://sepolia.etherscan.io/address/0xb2cb295d62b1296d426344bcaea7f13e6415db33) |
115+
| SecureOwnableDefinitions | [`0x58a6f5cb9b5bbbc4700b26dca21a07b5d628a329`](https://sepolia.etherscan.io/address/0x58a6f5cb9b5bbbc4700b26dca21a07b5d628a329) |
116+
| RuntimeRBACDefinitions | [`0xc897e8cc3d33f22153edee9bc82bf62d62dd7c94`](https://sepolia.etherscan.io/address/0xc897e8cc3d33f22153edee9bc82bf62d62dd7c94) |
117+
| GuardControllerDefinitions | [`0x922454de0599640a7cd223e2f955d45025f3cfda`](https://sepolia.etherscan.io/address/0x922454de0599640a7cd223e2f955d45025f3cfda) |
118118

119119
#### Account
120120

121121
| Contract | Address |
122122
|----------|---------|
123-
| AccountBlox | [`0x5886d5760551fae5f826ebb71d5b8a125da57a15`](https://sepolia.etherscan.io/address/0x5886d5760551fae5f826ebb71d5b8a125da57a15) |
123+
| AccountBlox | [`0xb73f8e5f08e30a9326d7127aaffe897a26c49f70`](https://sepolia.etherscan.io/address/0xb73f8e5f08e30a9326d7127aaffe897a26c49f70) |
124124

125125
#### Examples
126126

@@ -175,7 +175,9 @@ npm run docgen && npm run format # docs & format
175175

176176
## 📚 Documentation
177177

178+
- **[Codebase documentation process & audit checklist](CODEBASE_DOCUMENTATION.md)** – Source of truth, how to update docs, audit-ready checklist
178179
- [Protocol Architecture](./sdk/typescript/docs/bloxchain-architecture.md) · [State Machine](./sdk/typescript/docs/state-machine-engine.md) · [Getting Started](./sdk/typescript/docs/getting-started.md) · [API Reference](./sdk/typescript/docs/api-reference.md) · [SecureOwnable](./sdk/typescript/docs/secure-ownable.md) · [RuntimeRBAC](./sdk/typescript/docs/dynamic-rbac.md) · [Best Practices](./sdk/typescript/docs/best-practices.md) · [Examples](./sdk/typescript/docs/examples-basic.md)
180+
- **Contract API (generated):** [docs/](docs/) – generated from Solidity NatSpec via `npm run docgen`
179181

180182
## 🛡️ Security Features
181183

contracts/core/access/RuntimeRBAC.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ abstract contract RuntimeRBAC is BaseStateMachine, IRuntimeRBAC {
7171
/**
7272
* @dev Requests and approves a RBAC configuration batch using a meta-transaction
7373
* @param metaTx The meta-transaction
74-
* @return The transaction record
74+
* @return The transaction ID of the applied batch
7575
* @notice OWNER signs, BROADCASTER executes according to RuntimeRBACDefinitions
7676
*/
7777
function roleConfigBatchRequestAndApprove(

contracts/core/access/interface/IRuntimeRBAC.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import "../../lib/EngineBlox.sol";
1212
*
1313
* Key Features:
1414
* - Batch-based role configuration (atomic operations)
15-
* - Runtime function schema registration
15+
* - Role and permission management (function schema registration is handled by GuardController)
1616
* - Integration with EngineBlox for secure operations
1717
* - Query functions for role and permission inspection
1818
*
@@ -47,7 +47,7 @@ interface IRuntimeRBAC {
4747
/**
4848
* @dev Requests and approves a RBAC configuration batch using a meta-transaction
4949
* @param metaTx The meta-transaction
50-
* @return The transaction record
50+
* @return The transaction ID of the applied batch
5151
*/
5252
function roleConfigBatchRequestAndApprove(
5353
EngineBlox.MetaTransaction memory metaTx

contracts/core/base/BaseStateMachine.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,7 @@ abstract contract BaseStateMachine is Initializable, ERC165Upgradeable, Reentran
520520
* @dev Gets function schema information
521521
* @param functionSelector The function selector to get information for
522522
* @return The full FunctionSchema struct (functionSignature, functionSelector, operationType, operationName, supportedActionsBitmap, enforceHandlerRelations, isProtected, handlerForSelectors)
523+
* @notice Reverts with ResourceNotFound if the schema does not exist
523524
*/
524525
function getFunctionSchema(bytes4 functionSelector) external view returns (EngineBlox.FunctionSchema memory) {
525526
_validateAnyRole();

contracts/core/execution/GuardController.sol

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import "./interface/IGuardController.sol";
3232
*
3333
* Usage Flow:
3434
* 1. Deploy GuardController (or combine with RuntimeRBAC/SecureOwnable for role management)
35-
* 2. Function schemas should be registered via definitions or RuntimeRBAC if combined
35+
* 2. Function schemas are registered via definitions at init or via GuardController guard config batch (REGISTER_FUNCTION)
3636
* 3. Create roles and assign function permissions with action bitmaps (via RuntimeRBAC if combined)
3737
* 4. Assign wallets to roles (via RuntimeRBAC if combined)
3838
* 5. Configure target whitelists per function selector (REQUIRED for execution)
@@ -173,7 +173,7 @@ abstract contract GuardController is BaseStateMachine {
173173
/**
174174
* @dev Approves and executes a time-locked transaction
175175
* @param txId The transaction ID
176-
* @return result The execution result
176+
* @return txId The transaction ID
177177
* @notice Requires STANDARD execution type and EXECUTE_TIME_DELAY_APPROVE permission for the execution function
178178
*/
179179
function approveTimeLockExecution(
@@ -191,7 +191,7 @@ abstract contract GuardController is BaseStateMachine {
191191
/**
192192
* @dev Cancels a time-locked transaction
193193
* @param txId The transaction ID
194-
* @return The updated transaction record
194+
* @return The transaction ID
195195
* @notice Requires STANDARD execution type and EXECUTE_TIME_DELAY_CANCEL permission for the execution function
196196
*/
197197
function cancelTimeLockExecution(
@@ -209,7 +209,7 @@ abstract contract GuardController is BaseStateMachine {
209209
/**
210210
* @dev Approves a time-locked transaction using a meta-transaction
211211
* @param metaTx The meta-transaction containing the transaction record and signature
212-
* @return The updated transaction record
212+
* @return The transaction ID
213213
* @notice Requires STANDARD execution type and EXECUTE_META_APPROVE permission for the execution function
214214
*/
215215
function approveTimeLockExecutionWithMetaTx(
@@ -226,7 +226,7 @@ abstract contract GuardController is BaseStateMachine {
226226
/**
227227
* @dev Cancels a time-locked transaction using a meta-transaction
228228
* @param metaTx The meta-transaction containing the transaction record and signature
229-
* @return The updated transaction record
229+
* @return The transaction ID
230230
* @notice Requires STANDARD execution type and EXECUTE_META_CANCEL permission for the execution function
231231
*/
232232
function cancelTimeLockExecutionWithMetaTx(
@@ -243,7 +243,7 @@ abstract contract GuardController is BaseStateMachine {
243243
/**
244244
* @dev Requests and approves a transaction in one step using a meta-transaction
245245
* @param metaTx The meta-transaction containing the transaction record and signature
246-
* @return The transaction record after request and approval
246+
* @return The transaction ID
247247
* @notice Requires STANDARD execution type
248248
* @notice Validates function schema and permissions for the execution function (same as executeWithTimeLock)
249249
* @notice Requires EXECUTE_META_REQUEST_AND_APPROVE permission for the execution function selector
@@ -304,7 +304,7 @@ abstract contract GuardController is BaseStateMachine {
304304
/**
305305
* @dev Requests and approves a Guard configuration batch using a meta-transaction
306306
* @param metaTx The meta-transaction
307-
* @return The transaction record
307+
* @return The transaction ID
308308
* @notice OWNER signs, BROADCASTER executes according to GuardControllerDefinitions
309309
*/
310310
function guardConfigBatchRequestAndApprove(

contracts/core/execution/interface/IGuardController.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import "../../lib/EngineBlox.sol";
55

66
/**
77
* @title IGuardController
8-
* @dev Interface for GuardController contract that GuardianSafeV3 and other contracts delegate to
8+
* @dev Interface for GuardController contract that AccountBlox and other contracts delegate to
99
* @notice This interface defines only GuardController-specific methods
10-
* @notice Functions from BaseStateMachine (createMetaTxParams, generateUnsignedMetaTransaction*, getTransaction, functionSchemaExists, getFunctionSchema, owner, getBroadcaster, getRecovery) should be accessed via IBaseStateMachine
11-
* @notice Functions from RuntimeRBAC (registerFunction, unregisterFunction, createNewRole, addWalletToRole, revokeWallet) should be accessed via IRuntimeRBAC
10+
* @notice Functions from BaseStateMachine (createMetaTxParams, generateUnsignedMetaTransaction*, getTransaction, getFunctionSchema, owner, getBroadcasters, getRecovery) should be accessed via IBaseStateMachine
11+
* @notice Functions from RuntimeRBAC (role management: createNewRole, addWalletToRole, revokeWallet, etc.) should be accessed via IRuntimeRBAC. Function schema registration is performed via GuardController (guard config batch), not RuntimeRBAC.
1212
* @custom:security-contact security@particlecrypto.com
1313
*/
1414
interface IGuardController {

docgen/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ This directory contains a separate npm workspace for generating documentation us
2525

2626
## Configuration
2727

28-
- Hardhat config: `hardhat.config.cjs`
28+
- Hardhat config: `hardhat.config.cjs` (script uses `--config hardhat.config.cjs` so the parent’s `hardhat.config.ts` is not loaded).
2929
- Templates: `templates/contract.hbs`
3030
- Output: `../docs/` (parent directory)
31+
- Requires `ts-node` as a devDependency (Hardhat 2.x detects TypeScript from the repo and expects it).

docgen/hardhat.config.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module.exports = {
1515
}
1616
},
1717
paths: {
18-
// Reference parent directory's contracts, artifacts, and cache
18+
// Root at parent so contracts are "inside" the project; use --config hardhat.config.cjs so this CJS file is loaded
1919
root: path.resolve(__dirname, ".."),
2020
sources: path.resolve(__dirname, "../contracts"),
2121
tests: path.resolve(__dirname, "../test"),

docgen/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
"version": "1.0.0",
44
"description": "Documentation generation workspace for Bloxchain protocol (isolated Hardhat 2.x dependencies)",
55
"private": true,
6+
"type": "commonjs",
67
"scripts": {
7-
"docgen": "hardhat docgen",
8+
"docgen": "hardhat docgen --config hardhat.config.cjs",
89
"install-deps": "npm install"
910
},
1011
"devDependencies": {
1112
"hardhat": "^2.28.3",
12-
"solidity-docgen": "^0.6.0-beta.36"
13+
"solidity-docgen": "^0.6.0-beta.36",
14+
"ts-node": "^10.9.2"
1315
}
1416
}

0 commit comments

Comments
 (0)