Snapshot_CheckSnapPassed
Snapshot_CheckSnapPassed is an async mandate that uses Chainlink Functions to verify if a Snapshot proposal has concluded and if a specific choice has won.
Overview
Section titled “Overview”This mandate extends the verification logic of Snapshot_CheckSnapExists. In addition to verifying existence, it ensures that:
- The proposal has ended (state is “closed”).
- The specified choice has received the highest score (i.e., it won the vote).
If these conditions are met, it triggers a fulfillment on the Powers contract. Like Snapshot_CheckSnapExists, the current implementation acts purely as an oracle and does not execute downstream actions upon fulfillment.
Configuration
Section titled “Configuration”When adopting a Snapshot_CheckSnapPassed instance, the following parameters are required:
spaceId(string): The Snapshot Space ID (e.g., “yam.eth”).subscriptionId(uint64): The Chainlink Functions subscription ID.gasLimit(uint32): The gas limit for the Chainlink Functions callback.donID(bytes32): The Chainlink DON (Decentralized Oracle Network) ID.
Proposing an Action
Section titled “Proposing an Action”When calling the mandate, the following parameters must be provided:
proposalId(string): The ID of the Snapshot proposal to verify.choice(string): The voting choice to check for (e.g., “Yes”).targets(address[]): (Unused) Intended for future execution logic.values(uint256[]): (Unused) Intended for future execution logic.calldatas(bytes[]): (Unused) Intended for future execution logic.govDescription(string): A description of the governance action.
Execution Flow
Section titled “Execution Flow”-
Request Initiation (
handleRequest)- Prepares arguments for the Chainlink Function:
proposalIdandchoice. - Initiates the request to the Chainlink Oracle.
- Prepares arguments for the Chainlink Function:
-
Oracle Call (
_externalCall)- Sends the request to Chainlink.
- The off-chain script queries
https://hub.snapshot.org/graphqlto fetch proposal details and scores.
-
Verification & Fulfillment (
fulfillRequest)- Off-Chain Checks:
- Does the proposal exist?
- Is the state “closed”?
- Does the
choicesarray include the requestedchoice? - Does the
choicehave the highest score inscores?
- On-Chain Verification:
- Receives the result (“true” or error message).
- If “true”, calls
powers.fulfill.
- Note: The current implementation executes
fulfillwith empty action arrays.
- Off-Chain Checks:
Technical Specifications
Section titled “Technical Specifications”Chainlink Source
Section titled “Chainlink Source”The mandate uses a hardcoded JavaScript source to query the Snapshot API:
// ...if (snapshotData.proposal.state != "closed") return Functions.encodeString("Vote not closed.");// ...const maxScore = Math.max(...snapshotData.proposal.scores)if (maxScore != snapshotData.proposal.scores[index]) return Functions.encodeString("Choice did not pass.");return Functions.encodeString("true");Functions
Section titled “Functions”initializeMandate
Section titled “initializeMandate”function initializeMandate( uint16 index, string memory nameDescription, bytes memory inputParams, bytes memory config) public override- Initializes Chainlink configuration.
- Sets input parameters.
handleRequest
Section titled “handleRequest”function handleRequest(...) public view virtual override returns (...)- Prepares Chainlink request arguments.
fulfillRequest
Section titled “fulfillRequest”function fulfillRequest(bytes32 requestId, bytes memory response, bytes memory err) internal override- Callback from Chainlink.
- Verifies response is “true”.
- Calls
powers.fulfill.
Error Conditions
Section titled “Error Conditions”-
Chainlink Errors
- “Proposal not recognised.”
- “Vote not closed.”
- “Choice not present.”
- “Choice did not pass.”
- “Request failed” (API error).
-
Validation Errors
- “No response from the API”
- “Request not found”
Current Deployments
Section titled “Current Deployments”| Chain ID | Chain Name | Address |
|---|---|---|