Skip to content

Commit

Permalink
add winston to eosio.token substream
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisCarriere committed Feb 20, 2023
1 parent db8f9dc commit 1598403
Show file tree
Hide file tree
Showing 11 changed files with 260 additions and 206 deletions.
7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ members = [
[workspace.dependencies]
prost = "0.11"
prost-types = "0.11"
substreams = "0.5.2"
substreams-antelope = "0.1.1"
substreams = "0.5"
substreams-antelope = "0.1"
substreams-ethereum = "0.9"
substreams-sink-kv = "0.1"
substreams-sink-prometheus = "0.1.9"
substreams-sink-prometheus = "0.1"
substreams-sink-winston = "0.1"
substreams-database-change = "1.0.0"
substreams-entity-change = "1.0.0"
antelope = "0.0.11"
Expand Down
3 changes: 2 additions & 1 deletion eosio.token/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "eosio_token"
version = "0.4.0"
version = "0.4.1"
authors = ["Denis <[email protected]>", "Yaro <[email protected]>"]
description = "Antelope `eosio.token` token transfers"
license = "MIT OR Apache-2.0"
Expand All @@ -21,4 +21,5 @@ antelope = { workspace = true }
prost = { workspace = true }
prost-types = { workspace = true }
substreams = { workspace = true }
substreams-sink-winston = { workspace = true }
substreams-antelope = { workspace = true }
4 changes: 4 additions & 0 deletions eosio.token/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,7 @@ map_stat:
.PHONY: gui
gui:
substreams gui -e eos.firehose.eosnation.io:9001 map_transfers -s 292103130 -t +1000000

.PHONY: sink
sink:
substreams run -e eos.firehose.eosnation.io:9001 log_out -s 292442484 -t +1000000 -o jsonl
46 changes: 26 additions & 20 deletions eosio.token/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,37 +17,43 @@ $ make run
graph TD;
map_transfers[map: map_transfers]
sf.antelope.type.v1.Block[source: sf.antelope.type.v1.Block] --> map_transfers
store_accounts[store: store_accounts]
sf.antelope.type.v1.Block[source: sf.antelope.type.v1.Block] --> store_accounts
store_stat[store: store_stat]
sf.antelope.type.v1.Block[source: sf.antelope.type.v1.Block] --> store_stat
map_accounts[map: map_accounts]
sf.antelope.type.v1.Block[source: sf.antelope.type.v1.Block] --> map_accounts
map_stat[map: map_stat]
sf.antelope.type.v1.Block[source: sf.antelope.type.v1.Block] --> map_stat
log_out[map: log_out]
map_transfers --> log_out
```

### Modules

```yaml
Package name: eosio_token
Version: v0.4.0
Version: v0.4.1
Doc: Antelope `eosio.token` based action traces & database operations.
Modules:
----
Name: map_transfers
Initial block: 0
Kind: map
Output Type: proto:antelope.eosio.token.v1.TransferEvents
Hash: 1ea4eb006b21562d1de2a4f792094245503fbf0c

Name: store_accounts
Initial block: 2
Kind: store
Value Type: proto:antelope.eosio.token.v1.Account
Update Policy: UPDATE_POLICY_SET
Hash: 6d6755517f205c72fa4eb8588154dfe2a5cfd897

Name: store_stat
Initial block: 2
Kind: store
Value Type: proto:antelope.eosio.token.v1.CurrencyStats
Update Policy: UPDATE_POLICY_SET
Hash: a7ebd372cdb44c30b0066b200bd861654e67e924
Hash: b10a4a6d64558e639a1f571f256fae2ddf5f4edf

Name: map_accounts
Initial block: 0
Kind: map
Output Type: proto:antelope.eosio.token.v1.Accounts
Hash: cce87730d9af37f64afa65d6fa706c7fe121b680

Name: map_stat
Initial block: 0
Kind: map
Output Type: proto:antelope.eosio.token.v1.Stats
Hash: da0cf92815bce9889ea89e54dd636b7e11f3c9d2

Name: log_out
Initial block: 0
Kind: map
Output Type: proto:pinax.substreams.sink.winston.v1.LoggerOperations
Hash: 159780ff24f2b1b00dd7001bfe54726382e1be96
```
20 changes: 13 additions & 7 deletions eosio.token/proto/v1/eosio.token.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ syntax = "proto3";

package antelope.eosio.token.v1;

import "google/protobuf/timestamp.proto";

message Accounts {
repeated Account items = 1;
}
Expand Down Expand Up @@ -32,13 +30,21 @@ message TransferEvents {
}

message TransferEvent {
// transaction
string trx_id = 1;
uint32 action_ordinal = 2;

// contract & scope
string account = 3;
string symcode = 4;
uint32 precision = 5;
string from = 6;
string to = 7;
int64 amount = 8;
string memo = 9;

// data payload
string from = 5;
string to = 6;
string quantity = 7;
string memo = 8;

// extras
int64 amount = 9;
uint32 precision = 10;
}
13 changes: 0 additions & 13 deletions eosio.token/src/keyer.rs

This file was deleted.

2 changes: 1 addition & 1 deletion eosio.token/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ pub mod eosio_token;
pub use self::eosio_token::*;

mod abi;
mod keyer;
mod maps;
mod sinks;
19 changes: 12 additions & 7 deletions eosio.token/src/maps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use antelope::{Name, SymbolCode};
#[substreams::handlers::map]
fn map_accounts(block: Block) -> Result<Accounts, Error> {
let mut items = vec![];
for trx in block.clone().all_transaction_traces() {
for trx in block.all_transaction_traces() {
for db_op in &trx.db_ops {
if db_op.table_name != "accounts" { continue; }

Expand Down Expand Up @@ -38,7 +38,7 @@ fn map_accounts(block: Block) -> Result<Accounts, Error> {
#[substreams::handlers::map]
fn map_stat(block: Block) -> Result<Stats, Error> {
let mut items = vec![];
for trx in block.clone().all_transaction_traces() {
for trx in block.all_transaction_traces() {
for db_op in &trx.db_ops {
if db_op.table_name != "stat" { continue; }

Expand Down Expand Up @@ -68,7 +68,7 @@ fn map_stat(block: Block) -> Result<Stats, Error> {
fn map_transfers(block: Block) -> Result<TransferEvents, Error> {
let mut response = vec![];

for trx in block.clone().all_transaction_traces() {
for trx in block.all_transaction_traces() {
// action traces
for trace in &trx.action_traces {
let action_trace = trace.action.as_ref().unwrap().clone();
Expand All @@ -83,16 +83,21 @@ fn map_transfers(block: Block) -> Result<TransferEvents, Error> {
response.push(TransferEvent {
// trace information
trx_id: trx.id.clone(),
action_ordinal: trace.action_ordinal.clone(),
action_ordinal: trace.action_ordinal,

// action data
// contract & scope
account: action_trace.account,
symcode: quantity.symbol.code().to_string(),
precision: quantity.symbol.precision().into(),

// payload
from: data.from,
to: data.to,
amount: quantity.amount,
quantity: quantity.to_string(),
memo: data.memo,

// extras
precision: quantity.symbol.precision().into(),
amount: quantity.amount,
});
}
}
Expand Down
Loading

0 comments on commit 1598403

Please sign in to comment.