Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions hypersync-client/src/preset_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ use std::collections::BTreeSet;

use arrayvec::ArrayVec;
use hypersync_format::{Address, LogArgument};
use hypersync_net_types::{FieldSelection, LogSelection, Query, TransactionSelection};
use hypersync_net_types::{
FieldSelection, LogArgumentSchema, LogSelection, Query, TransactionSelection,
};

/// Returns a query for all Blocks and Transactions within the block range (from_block, to_block]
/// If to_block is None then query runs to the head of the chain.
Expand Down Expand Up @@ -82,7 +84,7 @@ pub fn logs(from_block: u64, to_block: Option<u64>, contract_address: Address) -
from_block,
to_block,
logs: vec![LogSelection {
address: vec![contract_address],
address: vec![contract_address.into()],
..Default::default()
}],
field_selection: FieldSelection {
Expand Down Expand Up @@ -117,8 +119,11 @@ pub fn logs_of_event(
from_block,
to_block,
logs: vec![LogSelection {
address: vec![contract_address],
topics,
address: vec![contract_address.into()],
topics: topics
.into_iter()
.map(|vec| vec.into_iter().map(LogArgumentSchema).collect())
.collect(),
..Default::default()
}],
field_selection: FieldSelection {
Expand Down Expand Up @@ -171,7 +176,7 @@ pub fn transactions_from_address(
from_block,
to_block,
transactions: vec![TransactionSelection {
from: vec![address],
from: vec![address.into()],
..Default::default()
}],
field_selection: FieldSelection {
Expand Down
8 changes: 7 additions & 1 deletion hypersync-net-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,16 @@ license = "MPL-2.0"

[dependencies]
capnp = "0.19"
schemars = "0.8.21"
serde = { version = "1", features = ["derive"] }
arrayvec = { version = "0.7", features = ["serde"] }

hypersync-format = { path = "../hypersync-format", version = "0.4" }
serde_json = "1.0.128"
anyhow = "1"

[build-dependencies]
capnpc = "0.19"

[[bin]]
name = "generate_schema"
path = "src/generate_schema.rs"
7 changes: 7 additions & 0 deletions hypersync-net-types/src/generate_schema.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
use hypersync_net_types::Query;
use schemars::schema_for;

fn main() {
let schema = schema_for!(Query);
println!("{}", serde_json::to_string_pretty(&schema).unwrap());
}
Loading
Loading