Skip to content
Lattice

HSSAdapterLib

Git Source

Title: HSSAdapterLib

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

Logic + ERC-7201 storage for the diamond's use of the Hedera Schedule Service.

scheduleCall makes the CALLING CONTRACT the schedule payer and the schedule's admin key, so the diamond funds execution from its own HBAR and can delete what it scheduled. When the network fires the call, the diamond is the sender — a self-scheduled callback therefore sees msg.sender == address(this), which checkScheduledSelfCall uses as its guard.

Functions

hssAdapterStorage

function hssAdapterStorage() internal pure returns (HSSAdapterStorage storage $);

Returns

NameTypeDescription
$HSSAdapterStorage

__HSSAdapter_init

function __HSSAdapter_init() internal;

registerInterface

function registerInterface() internal;

hasScheduleCapacity

function hasScheduleCapacity(uint256 expirySecond, uint256 gasLimit) internal view returns (bool);

Parameters

NameTypeDescription
expirySeconduint256
gasLimituint256

Returns

NameTypeDescription
<none>bool

scheduleOf

function scheduleOf(bytes32 jobId) internal view returns (address);

Parameters

NameTypeDescription
jobIdbytes32

Returns

NameTypeDescription
<none>address

checkScheduledSelfCall

Reverts unless the current frame is the diamond executing its own scheduled call.

function checkScheduledSelfCall() internal view;

scheduleCall

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

Parameters

NameTypeDescription
toaddress
expirySeconduint256
gasLimituint256
valueuint64
databytes

Returns

NameTypeDescription
scheduleAddressaddress

scheduleSelfCall

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

Parameters

NameTypeDescription
jobIdbytes32
expirySeconduint256
gasLimituint256
databytes

Returns

NameTypeDescription
scheduleAddressaddress

completeSelfCall

The ONLY path that clears jobId. See the stranding limitation on IHSSAdapter.scheduleSelfCall: a schedule that is deleted or expires unfired leaves its job permanently occupied, because nothing else may write this mapping.

function completeSelfCall(bytes32 jobId) internal;

Parameters

NameTypeDescription
jobIdbytes32

deleteSchedule

function deleteSchedule(address scheduleAddress) internal;

Parameters

NameTypeDescription
scheduleAddressaddress

authorizeSchedule

function authorizeSchedule(address scheduleAddress) internal;

Parameters

NameTypeDescription
scheduleAddressaddress

_schedule

function _schedule(address to, uint256 expirySecond, uint256 gasLimit, uint64 value, bytes calldata data)
        private
        returns (address scheduleAddress);

Parameters

NameTypeDescription
toaddress
expirySeconduint256
gasLimituint256
valueuint64
databytes

Returns

NameTypeDescription
scheduleAddressaddress

_callForCode

function _callForCode(bytes memory data) private returns (int64 code);

Parameters

NameTypeDescription
databytes

Returns

NameTypeDescription
codeint64