Skip to content

Commit

Permalink
fix entity for graph_out
Browse files Browse the repository at this point in the history
  • Loading branch information
colindickson committed Nov 17, 2023
1 parent d43f799 commit 5bdf4ba
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 24 deletions.
14 changes: 3 additions & 11 deletions schema.graphql
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
# Log

enum BalanceChangeType {
TYPE_UNKNOWN
TYPE_1
TYPE_2
}

type BalanceChange @entity(immutable: true) {
type BalanceChange @entity {
id: ID!

contract: String
Expand All @@ -15,7 +7,7 @@ type BalanceChange @entity(immutable: true) {
newBalance: String
transaction: String
storageKey: String
callIndex: Int
callIndex: BigInt
transferValue: String
changeType: BalanceChangeType
changeType: Int
}
18 changes: 7 additions & 11 deletions src/sinks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ use substreams_database_change::pb::database::DatabaseChanges;
#[substreams::handlers::map]
pub fn graph_out(clock: Clock, balance_changes: BalanceChanges) -> Result<EntityChanges, Error> {
let mut tables = substreams_entity_change::tables::Tables::new();
let block_num = clock.number.to_string();
let timestamp = clock.timestamp.unwrap().seconds.to_string();

for balance_change in balance_changes.balance_changes {
if balance_change.change_type == 0 {
Expand All @@ -17,18 +15,16 @@ pub fn graph_out(clock: Clock, balance_changes: BalanceChanges) -> Result<Entity
let key = format!("{}:{}:{}", balance_change.contract, balance_change.owner, balance_change.transaction);

tables
.create_row("balance_change", key)
.create_row("BalanceChange", key)
.set("contract", balance_change.contract)
.set("owner", balance_change.owner)
.set("transfer_value", balance_change.transfer_value)
.set("old_balance", balance_change.old_balance)
.set("new_balance", balance_change.new_balance)
.set("storage_key", balance_change.storage_key)
.set("call_index", balance_change.call_index)
.set("transferValue", balance_change.transfer_value)
.set("oldBalance", balance_change.old_balance)
.set("newBalance", balance_change.new_balance)
.set("storageKey", balance_change.storage_key)
.set("callIndex", balance_change.call_index)
.set("transaction", balance_change.transaction)
.set("change_type", balance_change.change_type)
.set_bigint("block_num", &block_num)
.set_bigint("timestamp", &timestamp);
.set("changeType", balance_change.change_type);
}

Ok(tables.to_entity_changes())
Expand Down
2 changes: 1 addition & 1 deletion subgraph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dataSources:
source:
package:
moduleName: graph_out
file: ./erc20-balance-changes-v1.0.0.spkg
file: ./erc20-balance-changes-v1.1.0.spkg
mapping:
kind: substreams/graph-entities
apiVersion: 0.0.7
2 changes: 1 addition & 1 deletion substreams.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
specVersion: v0.1.0
package:
name: erc20_balance_changes
version: v1.0.0
version: v1.1.0
url: https://github.com/streamingfast/erc20-balance-changes
image: logo.png
doc: |
Expand Down

0 comments on commit 5bdf4ba

Please sign in to comment.