Skip to main content

setFields(options)

Set the fields to be retrieved for data items of each supported type. The options object has the following structure:
Every field selector is a collection of boolean fields mapping one-to-one to the fields of data items within the batch context iterables. Setting a field of a field selector of a given type to true, like this
will cause the processor to populate the corresponding field (in this case origin) of all data items of that type (in this case Call). The field will be available in all data items of the type, including nested items. Suppose we used the processor defined above to subscribe to some calls as well as some events, and for each event we requested a parent call:
As a result, the origin field would be available both within the call items retrieved due to .addCall() and within the call items that provide parent call information for the events:
Some data fields are enabled by default but can be disabled by setting a field of a field selector to false. For example, this code will not compile:
Disabling unused fields will improve sync performance, as the disabled fields will not be fetched from SQD Network.

Data item types and field selectors

Most IDEs support smart suggestions to show the possible field selectors. For VS Code, press Ctrl+Space:
Here we describe the data item types as functions of the field selectors. In SubstrateBatchProcessor each field of a field selector maps to the eponymous field of its corresponding data item type. Item data fields are divided into three categories:
  • Fields that are added independently of the setFields() call. These are either fixed or depend on the related data retrieval flags (e.g. call for events).
  • Fields that can be disabled by setFields(). E.g. the args field will be fetched for calls by default, but can be disabled by setting args: false within the call field selector.
  • Fields that can be requested by setFields(). E.g. the tip field will only be available in extrinsics if the extrinsic field selector sets tip: true.
In addition to data fields, data items have methods that simplify access to related data, e.g. Call.getExtrinsic().

Events

Event data items may have the following fields:
Definition of the types mentioned are available in their respective sections:
The topics field is not supported by every historical gateway dataset. Requesting it from an older archive can fail even though RPC ingestion supports it.

Calls

Call data items may have the following fields:
Definition of the types mentioned are available in their respective sections:

Extrinsics

Extrinsic data items may have the following fields:
Definition of mentioned types are available in their respective sections:

Block headers

BlockHeader data items may have the following fields:
Runtime is an internal type that tools like squid-substrate-typegen use for dealing with Substrate runtime versions. The curious may take a look at the definition here.

A complete example

Fetch Balances.Transfer events and Balances.transfer_keep_alive calls along with their parent extrinsics. Enrich the extrinsics with hashes, fees and success flags: