Store
Reference
StoreHook

IStoreHook

Usage SampleGit Source (opens in a new tab)

Inherits: IERC165

Functions

onBeforeSetRecord

Called before setting a record in the store.

function onBeforeSetRecord(
  ResourceId tableId,
  bytes32[] memory keyTuple,
  bytes memory staticData,
  PackedCounter encodedLengths,
  bytes memory dynamicData,
  FieldLayout fieldLayout
) external;

Parameters

NameTypeDescription
tableIdResourceIdThe ID of the table where the record is to be set.
keyTuplebytes32[]An array representing the composite key for the record.
staticDatabytesThe static data of the record.
encodedLengthsPackedCounterThe encoded lengths of the dynamic data of the record.
dynamicDatabytesThe dynamic data of the record.
fieldLayoutFieldLayoutThe layout of the field, see FieldLayout.sol.

onAfterSetRecord

Called after setting a record in the store.

function onAfterSetRecord(
  ResourceId tableId,
  bytes32[] memory keyTuple,
  bytes memory staticData,
  PackedCounter encodedLengths,
  bytes memory dynamicData,
  FieldLayout fieldLayout
) external;

Parameters

NameTypeDescription
tableIdResourceIdThe ID of the table where the record was set.
keyTuplebytes32[]An array representing the composite key for the record.
staticDatabytesThe static data of the record.
encodedLengthsPackedCounterThe encoded lengths of the dynamic data of the record.
dynamicDatabytesThe dynamic data of the record.
fieldLayoutFieldLayoutThe layout of the field, see FieldLayout.sol.

onBeforeSpliceStaticData

Called before splicing static data in the store.

Splice operations in static data always overwrite data starting at the start position, so the total length of the data remains the same and no data is shifted.

function onBeforeSpliceStaticData(
  ResourceId tableId,
  bytes32[] memory keyTuple,
  uint48 start,
  bytes memory data
) external;

Parameters

NameTypeDescription
tableIdResourceIdThe ID of the table where the data is to be spliced.
keyTuplebytes32[]An array representing the composite key for the record.
startuint48The start byte position for splicing.
databytesThe data to be written to the static data of the record at the start byte.

onAfterSpliceStaticData

Called after splicing static data in the store.

Splice operations in static data always overwrite data starting at the start position, so the total length of the data remains the same and no data is shifted.

function onAfterSpliceStaticData(
  ResourceId tableId,
  bytes32[] memory keyTuple,
  uint48 start,
  bytes memory data
) external;

Parameters

NameTypeDescription
tableIdResourceIdThe ID of the table where the data was spliced.
keyTuplebytes32[]An array representing the composite key for the record.
startuint48The start byte position for splicing.
databytesThe data written to the static data of the record at the start byte.

onBeforeSpliceDynamicData

Called before splicing dynamic data in the store.

Splice operations in dynamic data always reach the end of the dynamic data to avoid shifting data after the inserted or deleted data.

function onBeforeSpliceDynamicData(
  ResourceId tableId,
  bytes32[] memory keyTuple,
  uint8 dynamicFieldIndex,
  uint40 startWithinField,
  uint40 deleteCount,
  PackedCounter encodedLengths,
  bytes memory data
) external;

Parameters

NameTypeDescription
tableIdResourceIdThe ID of the table where the data is to be spliced.
keyTuplebytes32[]An array representing the composite key for the record.
dynamicFieldIndexuint8The index of the dynamic field.
startWithinFielduint40The start byte position within the field for splicing.
deleteCountuint40The number of bytes to delete in the dynamic data of the record.
encodedLengthsPackedCounterThe encoded lengths of the dynamic data of the record.
databytesThe data to be inserted into the dynamic data of the record at the start byte.

onAfterSpliceDynamicData

Called after splicing dynamic data in the store.

Splice operations in dynamic data always reach the end of the dynamic data to avoid shifting data after the inserted or deleted data.

function onAfterSpliceDynamicData(
  ResourceId tableId,
  bytes32[] memory keyTuple,
  uint8 dynamicFieldIndex,
  uint40 startWithinField,
  uint40 deleteCount,
  PackedCounter encodedLengths,
  bytes memory data
) external;

Parameters

NameTypeDescription
tableIdResourceIdThe ID of the table where the data was spliced.
keyTuplebytes32[]An array representing the composite key for the record.
dynamicFieldIndexuint8The index of the dynamic field.
startWithinFielduint40The start byte position within the field for splicing.
deleteCountuint40The number of bytes deleted in the dynamic data of the record.
encodedLengthsPackedCounterThe encoded lengths of the dynamic data of the record.
databytesThe data inserted into the dynamic data of the record at the start byte.

onBeforeDeleteRecord

Called before deleting a record from the store.

function onBeforeDeleteRecord(ResourceId tableId, bytes32[] memory keyTuple, FieldLayout fieldLayout) external;

Parameters

NameTypeDescription
tableIdResourceIdThe ID of the table where the record is to be deleted.
keyTuplebytes32[]An array representing the composite key for the record.
fieldLayoutFieldLayoutThe layout of the field, see FieldLayout.sol.

onAfterDeleteRecord

Called after deleting a record from the store.

function onAfterDeleteRecord(ResourceId tableId, bytes32[] memory keyTuple, FieldLayout fieldLayout) external;

Parameters

NameTypeDescription
tableIdResourceIdThe ID of the table where the record was deleted.
keyTuplebytes32[]An array representing the composite key for the record.
fieldLayoutFieldLayoutThe layout of the field, see FieldLayout.sol.

Errors

StoreHook_NotImplemented

Error emitted when a function is not implemented.

error StoreHook_NotImplemented();