IChainlinkCREAdapter
Title: IChainlinkCREAdapter
Author: Modified from the Chainlink CRE consumer-contract guide
Interface for the ChainlinkCREAdapter Diamond facet — a Chainlink CRE (Chainlink Runtime Environment) workflow-report receiver.
Push receiver (the inverse of the price adapters' pull model). The KeystoneForwarder
validates the DON's report signatures off-chain, then calls onReport, which is gated so that
(a) only the configured forwarder may call it and (b) only an admin-allowlisted workflow id may
write. The latest report per workflow is stored. Consumer facets that inherit
ChainlinkCREAdapter should override onReport (calling super.onReport first) to act on the
decoded report.
The module registers the canonical type(IReceiver).interfaceId for ERC-165 (so CRE tooling
detects the receiver), analogous to how the token modules register canonical ERC-721/ERC-1155
ids rather than their Lattice-specific interface ids.
Functions
getForwarder
Returns the configured KeystoneForwarder.
function getForwarder() external view returns (address);Returns
| Name | Type | Description |
|---|---|---|
| <none> | address |
isWorkflowAllowed
Returns whether workflowId is allowed to write reports.
function isWorkflowAllowed(bytes32 workflowId) external view returns (bool);Parameters
| Name | Type | Description |
|---|---|---|
| workflowId | bytes32 | The CRE workflow id. |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | bool |
getLatestReport
Returns the latest report stored for workflowId.
function getLatestReport(bytes32 workflowId) external view returns (bytes memory report, uint256 timestamp);Parameters
| Name | Type | Description |
|---|---|---|
| workflowId | bytes32 | The CRE workflow id. |
Returns
| Name | Type | Description |
|---|---|---|
| report | bytes | The ABI-encoded report payload (empty if none stored). |
| timestamp | uint256 | The block timestamp when the report was received (0 if none). |
setForwarder
Sets or replaces the KeystoneForwarder.
Caller must hold DEFAULT_ADMIN_ROLE. Reverts CREInvalidForwarder on the zero address.
function setForwarder(address forwarder) external;Parameters
| Name | Type | Description |
|---|---|---|
| forwarder | address | The forwarder allowed to call onReport. |
setWorkflow
Allows or disallows a workflow id from writing reports.
Caller must hold DEFAULT_ADMIN_ROLE. Reverts CREInvalidWorkflowId on a zero id.
function setWorkflow(bytes32 workflowId, bool allowed) external;Parameters
| Name | Type | Description |
|---|---|---|
| workflowId | bytes32 | The CRE workflow id. |
| allowed | bool | True to allow, false to disallow. |
onReport
Called by the KeystoneForwarder to deliver a CRE workflow report.
Gated to the configured forwarder and to an allowlisted workflow id; decodes the metadata,
stores the latest report for that workflow, and emits ReportReceived. Consumer facets
should override this to consume the report.
function onReport(bytes calldata metadata, bytes calldata report) external;Parameters
| Name | Type | Description |
|---|---|---|
| metadata | bytes | Packed workflow identity (workflowId, workflowName, workflowOwner) + report id. |
| report | bytes | The ABI-encoded workflow payload. |
Events
CREForwarderSet
Emitted when the KeystoneForwarder is set.
event CREForwarderSet(address forwarder);Parameters
| Name | Type | Description |
|---|---|---|
| forwarder | address | The forwarder allowed to call onReport. |
CREWorkflowSet
Emitted when a workflow id's allowlist status changes.
event CREWorkflowSet(bytes32 indexed workflowId, bool allowed);Parameters
| Name | Type | Description |
|---|---|---|
| workflowId | bytes32 | The CRE workflow id. |
| allowed | bool | True if the workflow may now write reports. |
ReportReceived
Emitted when a report is accepted and stored.
event ReportReceived(bytes32 indexed workflowId, address indexed workflowOwner, bytes2 reportId);Parameters
| Name | Type | Description |
|---|---|---|
| workflowId | bytes32 | The CRE workflow id that produced the report. |
| workflowOwner | address | The workflow owner decoded from the metadata. |
| reportId | bytes2 | The 2-byte report id decoded from the metadata. |
Errors
CRENotConfigured
The forwarder has not been configured (forwarder address is zero).
error CRENotConfigured();CREInvalidForwarder
setForwarder was called with the zero address.
error CREInvalidForwarder();CREInvalidWorkflowId
setWorkflow was called with a zero workflow id.
error CREInvalidWorkflowId();CREOnlyForwarder
onReport was called by an address other than the configured forwarder.
error CREOnlyForwarder(address caller);Parameters
| Name | Type | Description |
|---|---|---|
| caller | address | The unauthorised caller. |
CREWorkflowNotAllowed
onReport carried a workflow id that is not on the allowlist.
error CREWorkflowNotAllowed(bytes32 workflowId);Parameters
| Name | Type | Description |
|---|---|---|
| workflowId | bytes32 | The disallowed workflow id. |
CREInvalidMetadata
onReport was called with metadata shorter than the required 64 bytes.
error CREInvalidMetadata();