ChainlinkCREAdapter
Inherits: IChainlinkCREAdapter
Title: ChainlinkCREAdapter
Authors: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80), Modified from the Chainlink CRE consumer-contract guide
Diamond facet that receives Chainlink CRE (Chainlink Runtime Environment) workflow reports
via the IReceiver.onReport entry point, delivered by the KeystoneForwarder.
Stateless delegator — all logic and storage live in ChainlinkCREAdapterLib.
onReport is gated to the configured forwarder and an admin-allowlisted workflow id, then
stores the latest report per workflow. Consumer facets that inherit this contract should
override onReport to act on the delivered report after calling super.onReport.
The module registers the canonical type(IReceiver).interfaceId for ERC-165 so CRE tooling
detects the receiver (the ERC-721/ERC-1155 canonical-id precedent).
This follows the guide's "Direct IReceiver Implementation" path, not the Ownable/
constructor-based ReceiverTemplate (incompatible with the stateless facet + ERC-7201 model);
the virtual onReport override is the Lattice analogue of ReceiverTemplate._processReport.
See ChainlinkCREAdapterLib for the full mapping.
Notes:
- lattice-version: 0.1.0
- lattice-source: Chainlink
Functions
getForwarder
Returns the configured KeystoneForwarder.
function getForwarder() external view virtual override returns (address);Returns
| Name | Type | Description |
|---|---|---|
| <none> | address |
isWorkflowAllowed
Returns whether workflowId is allowed to write reports.
function isWorkflowAllowed(bytes32 workflowId) external view virtual override 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
virtual
override
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 virtual override;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 virtual override;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 virtual override;Parameters
| Name | Type | Description |
|---|---|---|
| metadata | bytes | Packed workflow identity (workflowId, workflowName, workflowOwner) + report id. |
| report | bytes | The ABI-encoded workflow payload. |
exportSelectors
ERC-8153 selector export: this facet's cuttable selectors, tightly packed (4 bytes each).
Excludes exportSelectors() itself (0x0ef22643) - it is never cut into a diamond. Order matches
forge inspect ChainlinkCREAdapter methodIdentifiers (alphabetical by signature); kept in exact parity by
ExportSelectorsParityTest. Chunks:
getForwarder() 0xa0042526
getLatestReport(bytes32) 0x4def3188
isWorkflowAllowed(bytes32) 0xe35f6eba
onReport(bytes,bytes) 0x805f2132
setForwarder(address) 0xb9998a24
setWorkflow(bytes32,bool) 0x2a93711e
function exportSelectors() external pure virtual returns (bytes memory selectors);Returns
| Name | Type | Description |
|---|---|---|
| selectors | bytes |