Skip to content

Commit

Permalink
Kickstart Starknet
Browse files Browse the repository at this point in the history
  • Loading branch information
zolting committed Nov 23, 2024
1 parent 4c37bf5 commit c56eb40
Show file tree
Hide file tree
Showing 17 changed files with 2,666 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ members = [
"blocks/beacon",
"blocks/solana",
"blocks/bitcoin",
"blocks/starknet",
"common",
]
resolver = "2"
Expand Down
14 changes: 14 additions & 0 deletions blocks/starknet/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
name = "raw_blocks_starknet"
edition = { workspace = true }
version = { workspace = true }

[lib]
crate-type = ["cdylib"]

[dependencies]
common = { path = "../../common" }
substreams-bitcoin = { workspace = true }
substreams = { workspace = true }
prost = { workspace = true }
prost-types = { workspace = true }
30 changes: 30 additions & 0 deletions blocks/starknet/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
.PHONY: all
all:
make build
make pack
make graph
make info

.PHONY: build
build:
cargo build --target wasm32-unknown-unknown --release

.PHONY: pack
pack:
substreams pack

.PHONY: graph
graph:
substreams graph

.PHONY: info
info:
substreams info

.PHONY: protogen
protogen:
substreams protogen --exclude-paths google

.PHONY: parquet
parquet:
substreams-sink-files run starknet.substreams.pinax.network:443 substreams.yaml map_events './out' 0:500 --encoder parquet --file-block-count 100 --development-mode
2 changes: 2 additions & 0 deletions blocks/starknet/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mod map_events;
mod pb;
8 changes: 8 additions & 0 deletions blocks/starknet/src/map_events.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
use substreams::{errors::Error, pb::substreams::Clock};

use crate::pb::{pinax::starknet::EventsOutput, sf::starknet::r#type::v1::Block};

#[substreams::handlers::map]
pub fn map_events(_clock: Clock, _block: Block) -> Result<EventsOutput, Error> {
Ok(EventsOutput::default())
}
57 changes: 57 additions & 0 deletions blocks/starknet/src/pb/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// @generated
// @@protoc_insertion_point(attribute:parquet)
pub mod parquet {
include!("parquet.rs");
// @@protoc_insertion_point(parquet)
}
pub mod pinax {
// @@protoc_insertion_point(attribute:pinax.starknet)
pub mod starknet {
include!("pinax.starknet.rs");
// @@protoc_insertion_point(pinax.starknet)
}
}
pub mod sf {
pub mod starknet {
pub mod r#type {
// @@protoc_insertion_point(attribute:sf.starknet.type.v1)
pub mod v1 {
include!("sf.starknet.type.v1.rs");
// @@protoc_insertion_point(sf.starknet.type.v1)
}
}
}
// @@protoc_insertion_point(attribute:sf.substreams)
pub mod substreams {
include!("sf.substreams.rs");
// @@protoc_insertion_point(sf.substreams)
pub mod index {
// @@protoc_insertion_point(attribute:sf.substreams.index.v1)
pub mod v1 {
include!("sf.substreams.index.v1.rs");
// @@protoc_insertion_point(sf.substreams.index.v1)
}
}
pub mod rpc {
// @@protoc_insertion_point(attribute:sf.substreams.rpc.v2)
pub mod v2 {
include!("sf.substreams.rpc.v2.rs");
// @@protoc_insertion_point(sf.substreams.rpc.v2)
}
}
pub mod sink {
pub mod service {
// @@protoc_insertion_point(attribute:sf.substreams.sink.service.v1)
pub mod v1 {
include!("sf.substreams.sink.service.v1.rs");
// @@protoc_insertion_point(sf.substreams.sink.service.v1)
}
}
}
// @@protoc_insertion_point(attribute:sf.substreams.v1)
pub mod v1 {
include!("sf.substreams.v1.rs");
// @@protoc_insertion_point(sf.substreams.v1)
}
}
}
80 changes: 80 additions & 0 deletions blocks/starknet/src/pb/parquet.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// @generated
// This file is @generated by prost-build.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct Column {
/// Not implemented yet but planned so we reserved the field id now
/// optional string name = 1;
#[prost(enumeration="ColumnType", optional, tag="2")]
pub r#type: ::core::option::Option<i32>,
#[prost(enumeration="Compression", optional, tag="3")]
pub compression: ::core::option::Option<i32>,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum ColumnType {
UnspecifiedColumnType = 0,
Uint256 = 1,
Int256 = 2,
}
impl ColumnType {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
ColumnType::UnspecifiedColumnType => "UNSPECIFIED_COLUMN_TYPE",
ColumnType::Uint256 => "UINT256",
ColumnType::Int256 => "INT256",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"UNSPECIFIED_COLUMN_TYPE" => Some(Self::UnspecifiedColumnType),
"UINT256" => Some(Self::Uint256),
"INT256" => Some(Self::Int256),
_ => None,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum Compression {
Uncompressed = 0,
Snappy = 1,
Gzip = 2,
Lz4Raw = 3,
Brotli = 4,
Zstd = 5,
}
impl Compression {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Compression::Uncompressed => "UNCOMPRESSED",
Compression::Snappy => "SNAPPY",
Compression::Gzip => "GZIP",
Compression::Lz4Raw => "LZ4_RAW",
Compression::Brotli => "BROTLI",
Compression::Zstd => "ZSTD",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"UNCOMPRESSED" => Some(Self::Uncompressed),
"SNAPPY" => Some(Self::Snappy),
"GZIP" => Some(Self::Gzip),
"LZ4_RAW" => Some(Self::Lz4Raw),
"BROTLI" => Some(Self::Brotli),
"ZSTD" => Some(Self::Zstd),
_ => None,
}
}
}
// @@protoc_insertion_point(module)
Loading

0 comments on commit c56eb40

Please sign in to comment.