Skip to content

Commit

Permalink
add to_or_from filter
Browse files Browse the repository at this point in the history
  • Loading branch information
YaroShkvorets committed May 8, 2023
1 parent 9f827b5 commit 6a92eba
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
29 changes: 23 additions & 6 deletions eosio.token/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,23 @@
### [Latest Releases](https://github.com/pinax-network/substreams/releases)


### Params
Params allow to filter messages and can be supplied to modules in the form of URL query, i.e. `to=swap.defi&contract=eosio.token` - filter EOS transfers to `swap.defi` account
- `map_transfers` - filter transfers
- `to` - receiver
- `from` - sender
- `symcode` - symbol code
- `contract` - token contract
- `to_or_from` - either receiver or sender
- `map_accounts` - filter account balance changes
- `account` - account
- `symcode` - symbol code
- `contract` - token contract
- `map_stat` - filter token stats
- `symcode` - symbol code
- `contract` - token contract

### Quickstart

```bash
Expand Down Expand Up @@ -34,37 +51,37 @@ graph TD;

```yaml
Package name: eosio_token
Version: v0.8.1
Version: v0.9.0
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: 9709be9b7bcfa5d7026187d356900bcefba7bcec
Hash: e832d395d7c4ad888f045ffe08fd3fa6952b5598

Name: map_accounts
Initial block: 0
Kind: map
Output Type: proto:antelope.eosio.token.v1.Accounts
Hash: 9235d38296f953ebba46ce9426fc978bf7d62626
Hash: 92884539c7ceb7107b48965b48da26fabd6b96a5

Name: map_stat
Initial block: 0
Kind: map
Output Type: proto:antelope.eosio.token.v1.Stats
Hash: 21f1030a86f5a4ceaf4377d86e7a9f35cb51464f
Hash: 61356dd96ff90b2f8bc32c28e1e6e57c268c0175

Name: db_out
Initial block: 0
Kind: map
Output Type: proto:sf.substreams.sink.database.v1.DatabaseChanges
Hash: c830d5c825f125dfc92c720d73059a47698aaef2
Hash: a63bf736a39ac384ef038d92961ade52b90c5908

Name: kv_out
Initial block: 0
Kind: map
Output Type: proto:sf.substreams.sink.kv.v1.KVOperations
Hash: d2a5746797ae42a9ebd31607c4068b7f504f4cfe
Hash: 785658f5d1ffc6857196a7e1619ba138f46afd3e
```
2 changes: 2 additions & 0 deletions eosio.token/src/maps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ fn map_transfers(params: String, block: Block) -> Result<TransferEvents, Error>
let filter_to = utils::create_filters(params.as_str(), "to");
let filter_symcode = utils::create_filters(params.as_str(), "symcode");
let filter_contract = utils::create_filters(params.as_str(), "contract");
let filter_tofrom = utils::create_filters(params.as_str(), "to_or_from");

for trx in block.all_transaction_traces() {
// action traces
Expand All @@ -126,6 +127,7 @@ fn map_transfers(params: String, block: Block) -> Result<TransferEvents, Error>
if !filter_to.is_empty() && !filter_to.contains(&data.to) { continue; }
if !filter_symcode.is_empty() && !filter_symcode.contains(&symcode) { continue; }
if !filter_contract.is_empty() && !filter_contract.contains(&contract) { continue; }
if !filter_tofrom.is_empty() && !(filter_tofrom.contains(&data.to) || filter_tofrom.contains(&data.from)) { continue; }

response.push(TransferEvent {
// trace information
Expand Down
2 changes: 1 addition & 1 deletion eosio.token/substreams.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
specVersion: v0.1.0
package:
name: eosio_token
version: v0.8.1
version: v0.9.0
url: https://github.com/pinax-network/substreams
doc: Antelope `eosio.token` based action traces & database operations.

Expand Down

0 comments on commit 6a92eba

Please sign in to comment.