-
Notifications
You must be signed in to change notification settings - Fork 18
feat(); SPL Tokens; new substream #124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
c674cd7
46b193d
c2d9581
c21815a
eadcc04
cca8220
340028b
a5b23e3
c528531
8334c51
c8713b4
426d351
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| syntax = "proto3"; | ||
|
|
||
| package messari.sol_token.v1; | ||
|
|
||
| message Transfers { | ||
| repeated Transfer transfers = 1; | ||
| } | ||
|
|
||
| message Transfer { | ||
| string signature = 1; | ||
| string from = 2; | ||
| string to = 3; | ||
| TokenAccount token = 4; | ||
| string mint = 5; | ||
| uint64 native_amount = 6; | ||
| uint64 amount = 7; | ||
| BalanceChanges balance_changes = 8; | ||
| } | ||
|
|
||
| message BalanceChanges { | ||
| repeated TokenBalance items = 1; | ||
| } | ||
|
|
||
| // balance change | ||
| message TokenBalance { | ||
| TokenAccount token = 1; | ||
| string transaction_id = 2; | ||
| uint64 block_height = 3; | ||
| string address = 4; // account address of the balance change | ||
| string pre_balance = 5; // BigInt, in token's native amount | ||
| string post_balance = 6; // BigInt, in token's native amount | ||
| } | ||
|
|
||
| message Tokens { | ||
| repeated TokenAccount tokens = 1; | ||
| } | ||
|
|
||
| message TokenAccount { | ||
| string address = 1; | ||
| string name = 2; | ||
| string symbol = 3; | ||
| uint64 decimals = 4; | ||
| string freeze_authority = 5; | ||
| string mint_authority = 6; | ||
| string tx_created = 7; | ||
| uint64 block_created = 8; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| use anyhow::{Ok, Result}; | ||
| use substreams_common::codegen; | ||
|
|
||
| fn main() -> Result<(), anyhow::Error> { | ||
| println!("cargo:rerun-if-changed=proto"); | ||
| println!("cargo:rerun-if-changed=abi"); | ||
| codegen::generate(None)?; | ||
|
|
||
| Ok(()) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| syntax = "proto3"; | ||
|
|
||
| package messari.common.v1; | ||
|
|
||
| message Block { | ||
| string item = 1; | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| [toolchain] | ||
| channel = "1.64.0" | ||
| components = [ "rustfmt" ] | ||
| targets = [ "wasm32-unknown-unknown" ] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| // DO NOT EDIT - the file is generated by build script | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rm |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,8 @@ | ||
| use substreams::{log, store}; | ||
| use substreams::pb; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same deal here |
||
| use substreams::store::{StoreSetRaw, StoreSet, StoreNew}; | ||
| use substreams_solana::pb::sol as solana; | ||
|
|
||
| #[substreams::handlers::store] | ||
| fn store_test(block: solana::v1::Block, _output: store::StoreSet) { | ||
| log::info!("block height: {}", block.blockhash); | ||
| fn store_test(block: solana::v1::Block, _output: StoreSetRaw) { | ||
| _output.set(0, 0_u64, &block); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| #[rustfmt::skip] | ||
| #[path = "../target/pb/messari.common.v1.rs"] | ||
| pub(in crate::pb) mod common_v1; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. proto files aren't being used so we could remove them from the substream for now? |
||
|
|
||
| pub mod common { | ||
| pub mod v1 { | ||
| pub use super::super::common_v1::*; | ||
| } | ||
| } | ||
|
|
||
| #[rustfmt::skip] | ||
| #[path = "../target/pb/messari.solana.type.rs"] | ||
| pub(in crate::pb) mod solana_type; | ||
|
|
||
| pub mod solana { | ||
| pub mod type { | ||
| pub use super::super::solana_type::*; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,15 +6,22 @@ package: | |
| imports: | ||
| sol: https://github.com/streamingfast/firehose-solana/releases/download/v0.1.0/solana-v0.1.0.spkg | ||
|
|
||
| protobuf: | ||
| files: | ||
| - test.proto | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rm? |
||
| importPaths: | ||
| - ./proto | ||
|
|
||
| binaries: | ||
| default: | ||
| type: wasm/rust-v1 | ||
| file: "../target/wasm32-unknown-unknown/release/solana_sample.wasm" | ||
|
|
||
| modules: | ||
| - name: store_test | ||
| kind: store | ||
| updatePolicy: set | ||
| valueType: bytes | ||
| inputs: | ||
| - source: sf.solana.type.v1.Block | ||
| # Will store the entire solana block as a string | ||
| - name: store_test | ||
| kind: store | ||
| updatePolicy: set | ||
| valueType: proto:sf.solana.type.v2.Block | ||
| inputs: | ||
| - source: sf.solana.type.v2.Block | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| [package] | ||
| name = "spl-balance" | ||
| version = "0.1.0" | ||
| description = "Messari's standardized substream for solana SPL tokens" | ||
| edition = "2021" | ||
| repository = "https://github.com/messari/substreams" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not really that important but it would be nice to have all these links be consistant. (If you use the CLI to create the substream projects it will do this for you :) ) |
||
|
|
||
| [lib] | ||
| crate-type = ["cdylib"] | ||
|
|
||
| [dependencies] | ||
| bs58 = "0.4.0" | ||
| prost = "0.11.2" | ||
| ethabi = "17.2.0" | ||
| num-bigint = "0.4" | ||
| hex-literal = "0.3.4" | ||
| substreams = { workspace = true } | ||
| substreams-solana = { workspace = true } | ||
| substreams-helper = { path = "../substreams-helper" } | ||
|
|
||
| [build-dependencies] | ||
| anyhow = "1" | ||
| substreams-common = { path = "../common" } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| .PHONY: build | ||
| build: | ||
| cargo build --target wasm32-unknown-unknown --release | ||
|
|
||
| .PHONY: run | ||
| run: | ||
| substreams run -e mainnet.sol.streamingfast.io:443 substreams.yaml map_balances -s 173531340 -t +1 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| # Solana SPL Token Balances | ||
|
|
||
| This substream is designed to get the token balances of all SPL tokens on Solana. In addition `store_tokens` will get all SPL tokens and metadata. | ||
|
|
||
| ## Notes | ||
|
|
||
| - TODO |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| use anyhow::{Ok, Result}; | ||
| use substreams_common::codegen; | ||
|
|
||
| fn main() -> Result<(), anyhow::Error> { | ||
| println!("cargo:rerun-if-changed=proto"); | ||
| println!("cargo:rerun-if-changed=abi"); | ||
| codegen::generate(None)?; | ||
|
|
||
| Ok(()) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| [toolchain] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rm if possible |
||
| channel = "1.64.0" | ||
| components = [ "rustfmt" ] | ||
| targets = [ "wasm32-unknown-unknown" ] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| // DO NOT EDIT - the file is generated by build script | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rm |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really a fan of local toolchains for each project. Would be best to have these settings configured globally for all projects by default if possible