Mappings
Mappings describe how Substate events and transactions should be handled by Hydra processor
A mapping file is a standalone typescript module defining how the Substrate events of interest should be handled by the Hydra indexer.
The event handlers (aka mappings) should be defined in the manifest file:
Handers receive a signle argument of type defined in @dzlzv/hydra-common
eventHanlder
receives a single argument of typeEventContext & StoreContext
extrinsicHandler
receives a single argument of typeExtrinsicContext & StoreContext
pre/postBlockHooks
receive a single argument of typeBlockContext & StoreContext
Let us look at the sample mapping generated by the scaffolder
Note that the required entity classes are exported from
and this is where all the auto-generated classes live by default.
Note how the handlers use the type-safe event classes Balances.TransferEvent
provided by typegen, and so native methods like toHuman()
become available
All the events and extrinsics for which we need the generate the types should be defined in the typegen section like below and can be imported from ./generated/types
. See also Hydra Typegen.
Last updated