forked from streamingfast/substreams-erc20-balance-changes
-
Notifications
You must be signed in to change notification settings - Fork 0
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
0cd2b33
commit c449fcf
Showing
7 changed files
with
162 additions
and
25 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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: CI | ||
on: [push, pull_request] | ||
|
||
jobs: | ||
check: | ||
name: Check | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout sources | ||
uses: actions/checkout@v3 | ||
|
||
- name: Run cargo check | ||
run: cargo check | ||
|
||
test: | ||
name: Test Suite | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout sources | ||
uses: actions/checkout@v3 | ||
|
||
- name: Run cargo test | ||
run: cargo test | ||
|
||
lints: | ||
name: Lints | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout sources | ||
uses: actions/checkout@v3 | ||
|
||
- name: Run cargo fmt | ||
run: cargo fmt --all -- --check | ||
|
||
- name: Run cargo clippy | ||
run: cargo clippy -- -D warnings |
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 |
---|---|---|
@@ -1,18 +1,93 @@ | ||
CREATE TABLE IF NOT EXISTS balance_changes ( | ||
------------------------------------------------- | ||
-- Meta tables to store Substreams information -- | ||
------------------------------------------------- | ||
CREATE TABLE IF NOT EXISTS cursors | ||
( | ||
id String, | ||
cursor String, | ||
block_num Int64, | ||
block_id String | ||
) | ||
ENGINE = ReplacingMergeTree() | ||
PRIMARY KEY (id) | ||
ORDER BY (id); | ||
|
||
------------------------------------------------- | ||
-- Balance changes events -- | ||
------------------------------------------------- | ||
CREATE TABLE IF NOT EXISTS balance_changes ( | ||
-- block -- | ||
block_num UInt32, | ||
block_hash FixedString(64), | ||
timestamp DateTime(0, 'UTC'), | ||
date Date, | ||
|
||
-- transaction -- | ||
-- storage -- | ||
transaction_id FixedString(64), | ||
|
||
-- call -- | ||
call_index UInt32, | ||
|
||
-- log -- | ||
log_index UInt32, | ||
log_block_index UInt32, | ||
log_ordinal UInt64, | ||
|
||
-- storage change -- | ||
storage_key FixedString(64), | ||
storage_ordinal UInt64, | ||
|
||
-- balance change -- | ||
"contract" TEXT NOT NULL, | ||
"owner" TEXT NOT NULL, | ||
"amount" NUMERIC NOT NULL, | ||
"old_balance" NUMERIC NOT NULL, | ||
"new_balance" NUMERIC NOT NULL, | ||
"transaction_id" TEXT NOT NULL, | ||
"block_num" INT NOT NULL, | ||
"timestamp" TEXT NOT NULL, | ||
"change_type" INT NOT NULL, | ||
"call_index" INT NOT NULL, | ||
PRIMARY KEY ("block_num", "transaction_id", "call_index") | ||
); | ||
contract FixedString(40), | ||
owner FixedString(40), | ||
old_balance UInt256, | ||
new_balance UInt256, | ||
amount UInt256, | ||
|
||
-- transfer -- | ||
`from` FixedString(40), | ||
`to` FixedString(40), | ||
value UInt256, | ||
|
||
-- indexing -- | ||
version UInt64, | ||
|
||
-- debug -- | ||
balance_change_type Int32 | ||
) | ||
ENGINE = ReplacingMergeTree PRIMARY KEY (transaction_id, storage_ordinal) | ||
ORDER BY (transaction_id, storage_ordinal); | ||
|
||
------------------------------------------------- | ||
-- Transfer events -- | ||
------------------------------------------------- | ||
CREATE TABLE IF NOT EXISTS transfers ( | ||
-- block -- | ||
block_num UInt32, | ||
block_hash FixedString(64), | ||
timestamp DateTime(0, 'UTC'), | ||
date Date, | ||
|
||
-- transaction -- | ||
transaction_id FixedString(64), | ||
|
||
-- call -- | ||
call_index UInt32, | ||
call_address FixedString(40), | ||
|
||
-- log -- | ||
log_index UInt32, | ||
log_block_index UInt32, | ||
log_ordinal UInt64, | ||
|
||
-- transfer -- | ||
contract FixedString(40), -- log.address | ||
`from` FixedString(40), | ||
`to` FixedString(40), | ||
value UInt256, | ||
|
||
-- debug -- | ||
transfer_type Int32 | ||
) | ||
ENGINE = ReplacingMergeTree PRIMARY KEY (transaction_id, log_index) | ||
ORDER BY (transaction_id, log_index); |
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,12 @@ | ||
-- latest balances -- | ||
CREATE MATERIALIZED VIEW balances | ||
ENGINE = ReplacingMergeTree(version) | ||
ORDER BY (owner, contract) | ||
POPULATE | ||
AS | ||
SELECT | ||
owner, | ||
new_balance AS balance, | ||
contract, | ||
version | ||
FROM balance_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
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