Skip to content

Commit

Permalink
update skar-client, cargo update
Browse files Browse the repository at this point in the history
  • Loading branch information
ozgrakkurt committed Feb 24, 2024
1 parent 31fc36e commit 4c41f6c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 20 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ anyhow = "1"

serde_json = "1"

skar-client = "0.13"
skar-net-types = "0.1"
skar-client = "0.16"
skar-net-types = "0.2"
skar-format = "0.2"

[build-dependencies]
Expand Down
30 changes: 12 additions & 18 deletions examples/parquet-out/src/app.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
import { HypersyncClient } from "@envio-dev/hypersync-client";
import fs from "node:fs";

async function main() {
// Create hypersync client using the mainnet hypersync endpoint
const client = HypersyncClient.new({
url: "https://eth.hypersync.xyz"
url: "https://eth.hypersync.xyz",
});

// The query to run
const query = {
"fromBlock": 18500123,
"toBlock": 18550123,
"transactions": [{}],
"toBlock": 18501123,
"logs": [{
"address": ["0xdAC17F958D2ee523a2206206994597C13D831ec7"],
"topics": [["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"]],
}],
// Select the fields we are interested in, notice topics are selected as topic0,1,2,3
"fieldSelection": {
"block": [
"number",
"timestamp",
"hash"
],
"log": [
"block_number",
"log_index",
Expand All @@ -31,15 +28,6 @@ async function main() {
"topic2",
"topic3"
],
"transaction": [
"block_number",
"transaction_index",
"hash",
"from",
"to",
"value",
"input"
]
},
};

Expand All @@ -51,6 +39,12 @@ async function main() {
retry: true,
/// Convert binary columns to prefixed hex format like '0x1ab..'
hexOutput: true,
columnMapping: {
decodedLog: {
"value": "float64",
},
},
eventSignature: "Transfer(address indexed from, address indexed to, uint256 value)",
});

console.log("finished writing parquet");
Expand Down
3 changes: 3 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@ export interface ParquetConfig {
retry?: boolean
/** Define type mapping for output columns */
columnMapping?: ColumnMapping
/** Event signature for decoding logs */
eventSignature?: string
}
export interface ColumnMapping {
block?: Record<string, string>
transaction?: Record<string, string>
log?: Record<string, string>
decodedLog?: Record<string, string>
}
export interface StreamConfig {
/** Block range size to use when making individual requests. */
Expand Down
5 changes: 5 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ pub struct ParquetConfig {
#[serde(skip_serializing_if = "Option::is_none")]
/// Define type mapping for output columns
pub column_mapping: Option<ColumnMapping>,
#[serde(skip_serializing_if = "Option::is_none")]
/// Event signature for decoding logs
pub event_signature: Option<String>,
}

#[napi(object)]
Expand All @@ -34,6 +37,8 @@ pub struct ColumnMapping {
pub transaction: Option<HashMap<String, String>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub log: Option<HashMap<String, String>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub decoded_log: Option<HashMap<String, String>>,
}

impl ParquetConfig {
Expand Down

0 comments on commit 4c41f6c

Please sign in to comment.