Understanding Approvals
Approvals provide a governance layer for events that require consensus:- Approval Requests: Sent to designated approvers
- Voting: Approvers vote to accept or reject events
- Quorum: Minimum number of approvals required
- States: Track approval progress and outcomes
core/src/approval/manager.rs:1.
Approval Entity Structure
Approval Request
When an event requires approval, anApprovalRequest is created:
Approval States
Approvals progress through different states:- Pending: Waiting for votes
- RespondedAccepted: This node voted to accept
- RespondedRejected: This node voted to reject
- Obsolete: Request is no longer valid
Getting Approval Requests
Get Pending Requests
Retrieve all approval requests awaiting your vote:core/src/api/api.rs:113.
Get Single Request
Retrieve a specific approval request:core/src/api/api.rs:134 for the implementation.
Get All Approvals
Retrieve approvals with optional state filtering:core/src/api/api.rs:426.
Get Single Approval
Get detailed information about an approval:core/src/api/api.rs:409.
Voting on Approvals
Approve a Request
Vote to accept an approval request:Reject a Request
Vote to reject an approval request:approval_request method is defined in core/src/api/api.rs:301.
Your vote is cryptographically signed and sent to the event owner for collection.
Approval API Interface
TheApprovalAPI provides programmatic access:
Request Approval
Submit a signed approval request:core/src/approval/manager.rs:65.
Emit Vote
Generate and send a vote:core/src/approval/manager.rs:75 for implementation details.
Get All Requests
Retrieve all approval requests:Get Single Request
Fetch a specific request:Approval Manager Processing
Processing Approval Requests
The approval manager handles incoming requests:core/src/approval/manager.rs:219.
Generating Votes
When you vote, the manager generates a signed response:core/src/approval/manager.rs:280.
Governance Version Handling
Approvals track governance versions to ensure consistency:core/src/approval/manager.rs:236-276.
Approval Workflow
let msg = create_approver_response(approval);
messenger_channel.tell(
MessageTaskCommand::Request(
None,
msg,
vec![sender],
MessageConfig::direct_response(),
)
).await?;
Database Operations
Store Approval
Persist an approval entity:core/src/database/db.rs:438.
Get Approval
Retrieve an approval from storage:core/src/database/db.rs:425.
Get Approvals with Filter
Retrieve approvals by state:core/src/database/db.rs:429.
Delete Approval
Remove an approval:Approval Indexing
Index by Subject
Link approvals to subjects:Get Approvals by Subject
Retrieve all approvals for a subject:core/src/database/db.rs:450.
Index by Governance
Link approvals to governance:Get Approvals by Governance
Retrieve approvals for a governance:core/src/database/db.rs:475.
Approval Manager Lifecycle
The approval manager runs continuously:core/src/approval/manager.rs:151.
Pass Votation Setting
Configure automatic approval behavior:Error Handling
Common approval errors:VoteNotNeeded: Your vote is not required or already countedNotFound: Approval request doesn’t existInvalidParameters: Malformed request IDInternalError: Processing failureAPIChannelNotAvailable: Communication failureOurGovIsLower: Local governance is outdatedOurGovIsHigher: Remote governance is outdated
Best Practices
- Monitor Pending Requests: Regularly check for pending approval requests
- Timely Voting: Vote promptly to avoid delaying event processing
- Verify Governance: Ensure governance version matches before voting
- Audit Trail: Log all approval decisions for compliance
- Quorum Configuration: Set appropriate quorum thresholds in governance
- Error Recovery: Handle governance version mismatches gracefully
