Conversation
| @@ -0,0 +1 @@ | |||
| // DO NOT EDIT - the file is generated by build script | |||
| @@ -0,0 +1,4 @@ | |||
| [toolchain] | |||
There was a problem hiding this comment.
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
| @@ -0,0 +1,19 @@ | |||
| #[rustfmt::skip] | |||
| #[path = "../target/pb/messari.common.v1.rs"] | |||
| pub(in crate::pb) mod common_v1; | |||
There was a problem hiding this comment.
proto files aren't being used so we could remove them from the substream for now?
| @@ -1,7 +1,8 @@ | |||
| use substreams::{log, store}; | |||
| use substreams::pb; | |||
|
|
||
| protobuf: | ||
| files: | ||
| - test.proto |
| @@ -0,0 +1 @@ | |||
| // DO NOT EDIT - the file is generated by build script | |||
| @@ -0,0 +1,4 @@ | |||
| [toolchain] | |||
| use substreams::store::{StoreGet, StoreGetProto, StoreNew, StoreSet, StoreSetProto}; | ||
| use substreams_solana::pb::sol as solana; | ||
|
|
||
| #[substreams::handlers::map] |
There was a problem hiding this comment.
Perhaps you could move this to a modules folder like the other substreams are now doing?
| type: wasm/rust-v1 | ||
| file: "../target/wasm32-unknown-unknown/release/spl_balance.wasm" | ||
|
|
||
| modules: |
There was a problem hiding this comment.
Think these modules are back to front?
| output.set( | ||
| 0, | ||
| format!( | ||
| "address:{}", |
There was a problem hiding this comment.
Maybe use a storekey struct or a small fn that you can reuse between modules
| /// A C representation of Rust's `std::option::Option` | ||
| #[repr(C)] | ||
| #[derive(Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)] | ||
| pub enum COption<T> { |
There was a problem hiding this comment.
This whole file can be removed and you can switch back to using std::Option instead
| /// Instructions supported by the token program. | ||
| #[repr(C)] | ||
| #[derive(Clone, Debug, PartialEq)] | ||
| pub enum TokenInstruction<'a> { |
There was a problem hiding this comment.
Shrink this enum down to having just three fields:
- InitializeMint
- InitializeMint2
- NonMintInstruction
You will also be able to remove all C api code and a bunch of the map code
| /// Specifies the authority type for SetAuthority instructions | ||
| #[repr(u8)] | ||
| #[derive(Clone, Debug, PartialEq)] | ||
| pub enum AuthorityType { |
There was a problem hiding this comment.
You can remove this also
| name: "".to_string(), | ||
| symbol: "".to_string(), | ||
| decimals: decimal.into(), | ||
| freeze_authority: "".to_string(), |
There was a problem hiding this comment.
You could have this all on one line using .map() and then .unwrap_or_default(). This would then make it simple enough to doing the instantiation back inside the main module code rather than this fn here.
| ) -> proto::TokenAccount { | ||
| let mut token = proto::TokenAccount { | ||
| address: bs58::encode(&token_address).into_string(), | ||
| name: "".to_string(), |
There was a problem hiding this comment.
Think all protos inherit the default trait automatically so you might be able to get away with ..default at the bottom rather than manually spefying these fields during the instantiation
| return token; | ||
| } | ||
|
|
||
| // pull the TokenAccount using the key provided |
There was a problem hiding this comment.
What are your plans for this code block?
| @@ -0,0 +1,9 @@ | |||
| #[rustfmt::skip] | |||
| #[path = "../target/pb/messari.sol_token.v1.rs"] | |||
| pub(in crate::pb) mod sol_token_v1; | |||
There was a problem hiding this comment.
Just noting this here for the future but what we should do here is filter out all protos which are from substream-helpers in the build.rs script and not build bindings for them. Then we can just import the bindings from the substreams-helper crate instead which will avoid the unnecessary duplication of code here
| version = "0.1.0" | ||
| description = "Messari's standardized substream for solana SPL tokens" | ||
| edition = "2021" | ||
| repository = "https://github.com/messari/substreams" |
There was a problem hiding this comment.
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 :) )
New substream to get SPL token balances on solana.
Deliverables:
sol_token.prototo get the balances of all spl tokens on solanaModel off: https://github.com/streamingfast/substreams-playground/tree/master/modules/sol-spl-tokens