Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pinax-network/substreams-antelope
Substreams for Antelope
https://github.com/pinax-network/substreams-antelope
antelope substreams thegraph
Last synced: about 15 hours ago
JSON representation
Substreams for Antelope
- Host: GitHub
- URL: https://github.com/pinax-network/substreams-antelope
- Owner: pinax-network
- License: apache-2.0
- Created: 2023-01-04T20:12:30.000Z (almost 2 years ago)
- Default Branch: develop
- Last Pushed: 2024-10-16T22:36:30.000Z (29 days ago)
- Last Synced: 2024-10-18T22:37:58.962Z (27 days ago)
- Topics: antelope, substreams, thegraph
- Language: Rust
- Homepage: https://docs.rs/substreams-antelope
- Size: 698 KB
- Stars: 1
- Watchers: 5
- Forks: 1
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
- awesome-substreams - Substreams Antelope - This library contains the generated protobuffer for the Antelope blocks as well as helper methods to extract and parse block data. (Blockchains / Substreams)
README
# [`Substreams`](https://substreams.streamingfast.io/) for [**Antelope**](http://antelope.io/)
[](https://github.com/pinax-network/substreams-antelope)
[](https://crates.io/crates/substreams-antelope)
[](https://docs.rs/substreams-antelope)
[](https://github.com/pinax-network/substreams-antelope/actions?query=branch%3Adevelop)> This library contains the generated Rust protobuf bindings for [Antelope blocks](https://github.com/pinax-network/firehose-antelope/blob/develop/proto/sf/antelope/type/v1/type.proto) as well as helper methods to extract and parse block data.
## 📖 Documentation
### https://docs.rs/substreams-antelope
### Further resources
- [Substreams documentation](https://substreams.streamingfast.io)
## Install
```
$ cargo add substreams-antelope
```## Usage
Refer to [Docs.rs](https://docs.rs/substreams-antelope/latest/substreams_antelope/struct.Block.html#implementations) for helper methods on `Block` that extract action and transaction iterators from the Antelope block.
**Cargo.toml**
```toml
[dependencies]
substreams = "0.6"
substreams-antelope = "0.6"
```**src/lib.rs**
```rust
use substreams::prelude::*;
use substreams::errors::Error;
use substreams_antelope::{Block, ActionTraces};#[substreams::handlers::map]
fn map_action_traces(block: Block) -> Result {
let mut action_traces = vec![];for trx in block.transaction_traces() {
for trace in trx.action_traces {
action_traces.push(trace);
}
}
Ok(ActionTraces { action_traces })
}
```Or, using `actions()` helper method to filter all actions of `Statelog` type from `myaccount` account. As a parameter you can specify a list of contract account names to include actions from, that can be empty if you want actions with this signature from any contract account.
**src/lib.rs**
```rust
#[substreams::handlers::map]
fn map_actions(param_account: String, block: substreams_antelope::Block) -> Result {
Ok(Actions {
transfers: block.actions::(&["eosio.token"])
.map(|(action, trace)| Transfer {
// action.to, action.from, action.memo, action.quantity are available here.
})
.collect(),
})
}
```## Using Abigen
To generate ABI bindings for your smart contract you can add `abi/contract.abi.json` file containing the smart contract ABI, as well as the following `build.rs` file to the root of your project. This will ensure that `src/abi/contract.rs` module containing Rust bindings for your smart contract is always generated in your project:**build.rs**
```rust
fn main() {
substreams_antelope::Abigen::new("Contract", "abi/eosio.token.json")
.expect("failed to load abi")
.generate()
.expect("failed to generate contract")
.write_to_file("src/abi/eosio.token.rs")
.expect("failed to write contract");
}
```## Release
- Run `gen.sh` if there were changes in protobufs
- Bump up version in workspace `Cargo.toml`
- Commit changes
- Tag a release: https://github.com/pinax-network/substreams-antelope/releases
- Publish packages in this order: `substreams-antelope-core`, `substreams-antelope-abigen`, `substreams-antelope`.TODO: automate releases with github actions