Package Logo
cosmos_common
cosmos-common@v0.1.1
Total Downloads
189
Published
1 months ago
Publisher
User Avatar streamingfast

Readme

cosmos-common

The Cosmos Foundational modules are Substreams modules extracting common data from different Cosmos blockchains (e.g. Injective or Mantra).

Usage

This module is a general Cosmos foundational module, so it can be run within any Cosmos blockchain. For example, to run it against the Injective endpoint:

substreams gui cosmos-common-v0.0.1.spkg all_events -e mainnet.injective.streamingfast.io:443

However, StreamingFast recommends using the blockchain-specific foundational modules specified (for example, injective-common for Injective or mantra-common for Mantra), instead of this generic Cosmos package.

Usually, foundational modules are directly imported and used in other Substreams. All the official foundational modules are stored in substreams.dev.

specVersion: v0.1.0
package:
  name: my_project
  version: v0.1.0

imports:
  cosmos: https://spkg.io/streamingfast/cosmos-common-v0.0.1.spkg # Import the package from substreams.dev

modules:
  - name: my_events # Define your Substreams module
    use: cosmos:filtered_events # Use the imported package
    initialBlock: 70000000

params:
  my_events: "(type:message && attr:action) || (type:wasm && attr:_contract_address)" # Pass the filter as parameter to the module

For a full example of importing the SPKG, take a look at the derived-substreams.yaml file, which defines a Substreams that imports the Cosmos foundational module.

Modules

all_events (map)

Retrieves all the events in the Cosmos blockchain without any filtering.

index_events (index)

The module create an index (a cache) to efficiently retrieve events by their type and/or attribute keys.

The module sets the keys corresponding to all event 'types' and 'attribute keys' in the block For example: type:coin_received, attr:action, attr:sender ...

The attribute values are never indexed because they have a high cardinality and would be too expensive to index.

filtered_events (map)

The module reads from all_events and applies a filter on the event types and attribute keys, only outputing the events that match the filter.

The filter is specificed in the parameters of the module.

...

params:
  filtered_events: "(type:rewards && attr:validator)"

filtered_event_groups (map)

The module reads from all_events and applies a filter on the event types and attribute keys, outputing all the events from transactions that have at least one event matching the filter.

params:
    filtered_event_groups: "type:rewards && attr:validator"

filtered_events_by_attribute_value (map)

The module reads from all_events and applies a filter on the event types, attribute keys and values, only outputing the events that match the filter.

NOTE: This module does not use the index created by index_events.

params:
    filtered_events_by_attribute_value: "type:rewards && attr:validator:any_validator"

filtered_event_groups_by_attribute_value (map)

The module reads from all_events and applies a filter on the event types, attribute keys and values, outputing all the events from transactions that have at least one event matching the filter.

NOTE: This module does not use the index created by index_events.

params:
    filtered_event_groups_by_attribute_value: "type:rewards && attr:validator:any_validator"

Documentation

Modules

Maps icon
Maps

map
all_events

b24f0114dba246b557c98626b3682edcc82b4c47
map all_events (
blocksf.cosmos.type.v2.Block
)  -> sf.substreams.cosmos.v1.EventList

all_events reads from the sf.cosmos.type.v2.Block source and outputs a list of all events in the block. Some events are at the block level, others appear inside the transactions.

substreams gui cosmos-common@v0.1.1 all_events

map
filtered_events

a43560dbea3e4846743619652f984ccae5790cf1
Default param : (type:message && attr:action) || (type:wasm && attr:_contract_address)
substreams gui cosmos-common@v0.1.1 filtered_events

map
filtered_event_groups

e4d2397a7435d5af59ce8497efefd66874be663c
Default param : type:wasm && attr:_contract_address
substreams gui cosmos-common@v0.1.1 filtered_event_groups

map
filtered_events_by_attribute_value

9db9c42e77fb22181c64de2625218bab147574d8
map filtered_events_by_attribute_value (
paramsstring
)  -> sf.substreams.cosmos.v1.EventList
Default param : type:wasm && attr:_contract_address:inj1v77y5ttah96dc9qkcpc88ad7rce8n88e99t3m5
substreams gui cosmos-common@v0.1.1 filtered_events_by_attribute_value

map
filtered_event_groups_by_attribute_value

29eecdaadceb5b39c0afacc561ed11cdf8eb3b1f
map filtered_event_groups_by_attribute_value (
paramsstring
)  -> sf.substreams.cosmos.v1.EventList
Default param : type:wasm && attr:_contract_address:inj1v77y5ttah96dc9qkcpc88ad7rce8n88e99t3m5
substreams gui cosmos-common@v0.1.1 filtered_event_groups_by_attribute_value
Block Indexes icon
Block Indexes

blockIndex
index_events

c58e05630f6be72a75791baeadbafbdd865bed48
substreams gui cosmos-common@v0.1.1 index_events
Protobuf

Protobuf Docs Explorer

sf.cosmos.type.v2