Skip to content
Lattice

HSSAdapter

Git Source

Inherits: IHSSAdapter

Title: HSSAdapter

Authors: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80), Modified from hiero-ledger/hiero-contracts (https://github.com/hiero-ledger/hiero-contracts)

Diamond facet for Hedera Schedule Service automation: scheduled (self-)calls paid by the diamond, plus contract-key signatures on native scheduled transactions.

Stateless delegator over HSSAdapterLib. Only meaningful on Hedera.

Notes:

  • lattice-version: 0.1.0
  • lattice-source: Hedera

Functions

hasScheduleCapacity

True if the network can still accept a gasLimit call at expirySecond.

function hasScheduleCapacity(uint256 expirySecond, uint256 gasLimit) external view virtual override returns (bool);

Parameters

NameTypeDescription
expirySeconduint256
gasLimituint256

Returns

NameTypeDescription
<none>bool

scheduleOf

The schedule address recorded for jobId (zero if none / already cleared).

function scheduleOf(bytes32 jobId) external view virtual override returns (address scheduleAddress);

Parameters

NameTypeDescription
jobIdbytes32

Returns

NameTypeDescription
scheduleAddressaddress

scheduleCall

Schedules to.callvalue(data) at expirySecond, paid by the diamond, executed with the diamond as msg.sender. Returns the schedule entity's address.

function scheduleCall(address to, uint256 expirySecond, uint256 gasLimit, uint64 value, bytes calldata data)
        external
        virtual
        override
        returns (address scheduleAddress);

Parameters

NameTypeDescription
toaddress
expirySeconduint256
gasLimituint256
valueuint64
databytes

Returns

NameTypeDescription
scheduleAddressaddress

scheduleSelfCall

Schedules a call to the diamond itself under jobId (one live schedule per job). The callback must clear the job via completeSelfCall so it can be re-scheduled.

KNOWN PHASE-2 LIMITATION — a jobId can be stranded. completeSelfCall is the ONLY path that clears jobId, and it is callable only by the diamond executing its own scheduled call. So if the schedule never fires — the scheduler deletes it with deleteSchedule, the expiry passes unexecuted, or the diamond is out of HBAR at fire time — jobId stays occupied and every later scheduleSelfCall for it reverts HSSJobAlreadyScheduled forever. deleteSchedule takes a schedule address and cannot free the job. Recovery today needs a diamond cut. The fix (a scheduler-gated cancel that clears the map) is deliberately deferred: it changes this interface's function set and therefore its pinned interfaceId, and the whole self-call design rests on the unverified assumption that a fired schedule presents msg.sender == address(this) — probe 6 in script/config/hedera/ProbeHedera.s.sol settles that first. Do not build a recurring job on scheduleSelfCall until both land.

function scheduleSelfCall(bytes32 jobId, uint256 expirySecond, uint256 gasLimit, bytes calldata data)
        external
        virtual
        override
        returns (address scheduleAddress);

Parameters

NameTypeDescription
jobIdbytes32
expirySeconduint256
gasLimituint256
databytes

Returns

NameTypeDescription
scheduleAddressaddress

deleteSchedule

Deletes a schedule the diamond created (HIP-1215 deleteSchedule).

function deleteSchedule(address scheduleAddress) external virtual override;

Parameters

NameTypeDescription
scheduleAddressaddress

authorizeSchedule

Signs a native scheduled transaction with the diamond's contract key (HIP-755).

function authorizeSchedule(address scheduleAddress) external virtual override;

Parameters

NameTypeDescription
scheduleAddressaddress

completeSelfCall

Clears jobId's live schedule; callable only by the diamond executing its own scheduled call.

function completeSelfCall(bytes32 jobId) external virtual override;

Parameters

NameTypeDescription
jobIdbytes32

exportSelectors

ERC-8153 selector export: this facet's cuttable selectors, tightly packed (4 bytes each).

Excludes exportSelectors() itself (0x0ef22643). Order matches forge inspect HSSAdapter methodIdentifiers (alphabetical by signature); kept in exact parity by ExportSelectorsParityTest. Chunks: authorizeSchedule(address) 0xf0637961 completeSelfCall(bytes32) 0x1735e9e0 deleteSchedule(address) 0x72d42394 hasScheduleCapacity(uint256,uint256) 0xdfb4a999 scheduleCall(address,uint256,uint256,uint64,bytes) 0x6f5bfde8 scheduleOf(bytes32) 0xec2a7610 scheduleSelfCall(bytes32,uint256,uint256,bytes) 0x193704bb

function exportSelectors() external pure virtual returns (bytes memory selectors);

Returns

NameTypeDescription
selectorsbytes