-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
02da68a
commit fc08c37
Showing
10 changed files
with
178 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ members = [ | |
"accounts", | ||
"params", | ||
"atomicmarket", | ||
"pomelo", | ||
] | ||
|
||
[workspace.dependencies] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
[package] | ||
name = "pomelo" | ||
version = "0.1.0" | ||
authors = ["Yaro <[email protected]>", "Charles <[email protected]>", ] | ||
description = "Antelope Pomelo substreams" | ||
license = "MIT OR Apache-2.0" | ||
edition = "2021" | ||
publish = false | ||
|
||
[badges] | ||
maintenance = { status = "actively-developed" } | ||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
|
||
[dependencies] | ||
prost = { workspace = true } | ||
prost-types = { workspace = true } | ||
substreams = { workspace = true } | ||
substreams-antelope = { workspace = true } | ||
substreams-entity-change = { workspace = true } | ||
serde_json = "1.0.91" | ||
serde = { version = "1.0", features = ["derive"] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
.PHONY: all | ||
all: | ||
make build | ||
make pack | ||
make graph | ||
make info | ||
|
||
.PHONY: build | ||
build: | ||
cargo build --target wasm32-unknown-unknown --release | ||
|
||
.PHONY: protogen | ||
protogen: | ||
substreams protogen --exclude-paths sf/substreams,google | ||
|
||
.PHONY: pack | ||
pack: | ||
substreams pack | ||
|
||
.PHONY: graph | ||
graph: | ||
substreams graph | ||
|
||
.PHONY: info | ||
info: | ||
substreams info | ||
|
||
.PHONY: run | ||
run: | ||
substreams run -e eos.firehose.eosnation.io:9001 entity_out -s 296787657 -t +100000 | ||
|
||
.PHONY: gui | ||
gui: | ||
substreams gui -e eos.firehose.eosnation.io:9001 entity_out -s 296787657 -t +100000 | ||
|
||
.PHONY: sink | ||
sink: | ||
substreams-sink-kv run badger3://badger_data.db eos.firehose.eosnation.io:9001 substreams.yaml kv_out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Antelope Pomelo Substreams | ||
|
||
> Antelope Pomelo Substreams | ||
### [Latest Releases](https://github.com/pinax-network/substreams/releases) | ||
|
||
### Sinks | ||
- Socials (stay tuned) | ||
|
||
### Quickstart | ||
|
||
```bash | ||
$ make | ||
$ make gui | ||
``` | ||
|
||
### Graph | ||
|
||
```mermaid | ||
graph TD; | ||
entity_out[map: entity_out] | ||
sf.antelope.type.v1.Block[source: sf.antelope.type.v1.Block] --> entity_out | ||
``` | ||
|
||
### Modules | ||
|
||
```yaml | ||
Package name: pomelo | ||
Version: v0.1.0 | ||
Doc: Antelope pomelo updates | ||
Modules: | ||
---- | ||
Name: entity_out | ||
Initial block: 0 | ||
Kind: map | ||
Output Type: proto:substreams.entity.v1.EntityChanges | ||
Hash: 04d8aeae95d104cdeda26c31994ff2f2e67e7392 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use substreams_antelope::ActionTrace; | ||
// use antelope::Asset; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Serialize, Deserialize, Debug)] | ||
#[serde(deny_unknown_fields)] | ||
pub struct SetGrant { | ||
pub author_id: String, | ||
pub project_id: String, | ||
pub funding_account: String, | ||
pub accepted_tokens: Vec<String>, | ||
} | ||
|
||
|
||
pub fn parse_setgrant(action_trace: &ActionTrace) -> Option<SetGrant> { | ||
let action = action_trace.action.as_ref()?; | ||
if action.name != "setgrant" { return None; } | ||
let data: SetGrant = serde_json::from_str(&action.json_data).unwrap(); | ||
Some(data) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#[allow(dead_code)] | ||
mod abi; | ||
mod sinks; | ||
mod utils; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use substreams::{log}; | ||
use substreams::errors::Error; | ||
use substreams_antelope::{Block}; | ||
use substreams_entity_change::pb::entity::{entity_change::Operation, EntityChanges}; | ||
|
||
use crate::abi::SetGrant; | ||
|
||
#[substreams::handlers::map] | ||
pub fn entity_out( block: Block) -> Result<EntityChanges, Error> { | ||
let mut entity_changes: EntityChanges = Default::default(); | ||
|
||
for trx in block.clone().all_transaction_traces() { | ||
for trace in &trx.action_traces { | ||
let action_trace = trace.action.as_ref().unwrap().clone(); | ||
if action_trace.account != "app.pomelo" { continue; } | ||
if action_trace.name == "setgrant" { | ||
let data: SetGrant = serde_json::from_str(&action_trace.json_data).unwrap(); | ||
log::info!("data={:?}", data); | ||
entity_changes.push_change("Grant", &data.project_id, 1, Operation::Create) | ||
.change::<&str, String>("author_id", data.author_id) | ||
.change::<&str, String>("project_id", data.project_id) | ||
.change::<&str, String>("funding_account", data.funding_account) | ||
.change::<&str, String>("accepted_tokens", data.accepted_tokens.join(",")); | ||
} | ||
} | ||
} | ||
Ok( entity_changes ) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
specVersion: v0.1.0 | ||
package: | ||
name: "pomelo" | ||
version: v0.1.0 | ||
url: https://github.com/pinax-network/substreams | ||
doc: Antelope pomelo updates | ||
|
||
imports: | ||
entities: https://github.com/streamingfast/substreams-entity-change/releases/download/v0.2.1/substreams-entity-change-v0.2.1.spkg | ||
|
||
binaries: | ||
default: | ||
type: wasm/rust-v1 | ||
file: ../target/wasm32-unknown-unknown/release/pomelo.wasm | ||
|
||
modules: | ||
|
||
- name: entity_out | ||
kind: map | ||
inputs: | ||
- source: sf.antelope.type.v1.Block | ||
output: | ||
type: proto:substreams.entity.v1.EntityChanges |