diff --git a/hyperfuel-client/Cargo.toml b/hyperfuel-client/Cargo.toml index f87cc75..713a381 100644 --- a/hyperfuel-client/Cargo.toml +++ b/hyperfuel-client/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hyperfuel-client" -version = "2.0.0" +version = "2.1.0" edition = "2021" description = "client library for Envio's HyperSync support of the Fuel Network" license = "MIT" @@ -35,9 +35,9 @@ alloy-dyn-abi = "0.5.0" alloy-json-abi = "0.5.0" xxhash-rust = { version = "0.8", features = ["xxh3"] } -hyperfuel-net-types = { package = "hyperfuel-net-types", path = "../hyperfuel-net-types", version = "2.0.0" } -hyperfuel-format = { package = "hyperfuel-format", path = "../hyperfuel-format", version = "2.0.0" } -hyperfuel-schema = { package = "hyperfuel-schema", path = "../hyperfuel-schema", version = "2.0.0" } +hyperfuel-net-types = { package = "hyperfuel-net-types", path = "../hyperfuel-net-types", version = "3.0.0" } +hyperfuel-format = { package = "hyperfuel-format", path = "../hyperfuel-format", version = "3.0.0" } +hyperfuel-schema = { package = "hyperfuel-schema", path = "../hyperfuel-schema", version = "3.0.0" } [dependencies.reqwest] version = "0.11" diff --git a/hyperfuel-client/src/filter.rs b/hyperfuel-client/src/filter.rs index cd7d043..68a6f56 100644 --- a/hyperfuel-client/src/filter.rs +++ b/hyperfuel-client/src/filter.rs @@ -101,6 +101,7 @@ fn receipt_selections_to_filter( let rc = batch.column::("rc").ok(); let rd = batch.column::("rd").ok(); let tx_status = batch.column::("tx_status").ok(); + let tx_type = batch.column::("tx_type").ok(); let chunk_len = batch.chunk.len(); let mut filter = unset_bool_array(chunk_len); @@ -119,6 +120,7 @@ fn receipt_selections_to_filter( rc, rd, tx_status, + tx_type, selection, chunk_len, ); @@ -142,6 +144,7 @@ fn receipt_selection_to_filter( rc: Option<&UInt64Array>, rd: Option<&UInt64Array>, tx_status: Option<&UInt8Array>, + tx_type: Option<&UInt8Array>, selection: &ReceiptSelection, chunk_len: usize, ) -> BooleanArray { @@ -214,6 +217,10 @@ fn receipt_selection_to_filter( ); } + if !selection.tx_type.is_empty() && tx_type.is_some() { + filter = compute::boolean::and(&filter, &in_set_u8(tx_type.unwrap(), &selection.tx_type)); + } + filter } @@ -269,14 +276,15 @@ fn input_selections_to_filter( let recipient = batch.column::>("recipient").ok(); let input_type = batch.column::("input_type").ok(); let tx_status = batch.column::("tx_status").ok(); + let tx_type = batch.column::("tx_type").ok(); let chunk_len = batch.chunk.len(); let mut filter = unset_bool_array(chunk_len); for selection in selections.iter() { let selection = input_selection_to_filter( - owner, asset_id, contract, sender, recipient, input_type, tx_status, selection, - chunk_len, + owner, asset_id, contract, sender, recipient, input_type, tx_status, tx_type, + selection, chunk_len, ); filter = compute::boolean::or(&filter, &selection); } @@ -293,6 +301,7 @@ fn input_selection_to_filter( recipient: Option<&BinaryArray>, input_type: Option<&UInt8Array>, tx_status: Option<&UInt8Array>, + tx_type: Option<&UInt8Array>, selection: &InputSelection, chunk_len: usize, ) -> BooleanArray { @@ -335,6 +344,10 @@ fn input_selection_to_filter( ); } + if !selection.tx_type.is_empty() && tx_type.is_some() { + filter = compute::boolean::and(&filter, &in_set_u8(tx_type.unwrap(), &selection.tx_type)); + } + filter } @@ -347,6 +360,7 @@ fn output_selections_to_filter( let contract = batch.column::>("contract").ok(); let output_type = batch.column::("output_type").ok(); let tx_status = batch.column::("tx_status").ok(); + let tx_type = batch.column::("tx_type").ok(); let chunk_len = batch.chunk.len(); let mut filter = unset_bool_array(chunk_len); @@ -358,6 +372,7 @@ fn output_selections_to_filter( contract, output_type, tx_status, + tx_type, selection, chunk_len, ); @@ -373,6 +388,7 @@ fn output_selection_to_filter( contract: Option<&BinaryArray>, output_type: Option<&UInt8Array>, tx_status: Option<&UInt8Array>, + tx_type: Option<&UInt8Array>, selection: &OutputSelection, chunk_len: usize, ) -> BooleanArray { @@ -404,6 +420,9 @@ fn output_selection_to_filter( &in_set_u8(tx_status.unwrap(), &selection.tx_status), ); } + if !selection.tx_type.is_empty() && tx_type.is_some() { + filter = compute::boolean::and(&filter, &in_set_u8(tx_type.unwrap(), &selection.tx_type)); + } filter } diff --git a/hyperfuel-client/src/from_arrow.rs b/hyperfuel-client/src/from_arrow.rs index eba5eb6..26f7b4c 100644 --- a/hyperfuel-client/src/from_arrow.rs +++ b/hyperfuel-client/src/from_arrow.rs @@ -454,6 +454,12 @@ impl FromArrow for Receipt { } } + if let Ok(col) = batch.column::("tx_type") { + for (target, val) in out.iter_mut().zip(col.values_iter()) { + target.tx_type = TransactionType::from_u8(*val).unwrap(); + } + } + if let Ok(col) = batch.column::("block_height") { for (target, &val) in out.iter_mut().zip(col.values_iter()) { target.block_height = val.into(); @@ -622,6 +628,11 @@ impl FromArrow for Input { target.tx_status = TransactionStatus::from_u8(*val).unwrap(); } } + if let Ok(col) = batch.column::("tx_type") { + for (target, val) in out.iter_mut().zip(col.values_iter()) { + target.tx_type = TransactionType::from_u8(*val).unwrap(); + } + } if let Ok(col) = batch.column::>("utxo_id") { for (target, val) in out.iter_mut().zip(col.iter()) { target.utxo_id = val.map(|v| v.try_into().unwrap()); @@ -736,6 +747,11 @@ impl FromArrow for Output { target.tx_status = TransactionStatus::from_u8(*val).unwrap(); } } + if let Ok(col) = batch.column::("tx_type") { + for (target, val) in out.iter_mut().zip(col.values_iter()) { + target.tx_type = TransactionType::from_u8(*val).unwrap(); + } + } if let Ok(col) = batch.column::>("to") { for (target, val) in out.iter_mut().zip(col.iter()) { target.to = val.map(|v| v.try_into().unwrap()); diff --git a/hyperfuel-client/src/lib.rs b/hyperfuel-client/src/lib.rs index f2b674f..2b8b0ed 100644 --- a/hyperfuel-client/src/lib.rs +++ b/hyperfuel-client/src/lib.rs @@ -409,6 +409,12 @@ fn add_selections_to_field_selection(query: &mut Query) -> Query { if !selection.rd.is_empty() { query.field_selection.receipt.insert("rd".into()); } + if !selection.tx_status.is_empty() { + query.field_selection.receipt.insert("tx_status".into()); + } + if !selection.tx_type.is_empty() { + query.field_selection.receipt.insert("tx_type".into()); + } }); query.inputs.iter_mut().for_each(|selection| { @@ -430,6 +436,12 @@ fn add_selections_to_field_selection(query: &mut Query) -> Query { if !selection.input_type.is_empty() { query.field_selection.input.insert("input_type".into()); } + if !selection.tx_status.is_empty() { + query.field_selection.input.insert("tx_status".into()); + } + if !selection.tx_type.is_empty() { + query.field_selection.receipt.insert("tx_type".into()); + } }); query.outputs.iter_mut().for_each(|selection| { @@ -445,6 +457,12 @@ fn add_selections_to_field_selection(query: &mut Query) -> Query { if !selection.output_type.is_empty() { query.field_selection.output.insert("output_type".into()); } + if !selection.tx_status.is_empty() { + query.field_selection.output.insert("tx_status".into()); + } + if !selection.tx_type.is_empty() { + query.field_selection.receipt.insert("tx_type".into()); + } }); query.clone() diff --git a/hyperfuel-format/Cargo.toml b/hyperfuel-format/Cargo.toml index bc4b8fc..2b0f4b7 100644 --- a/hyperfuel-format/Cargo.toml +++ b/hyperfuel-format/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hyperfuel-format" -version = "2.0.0" +version = "3.0.0" edition = "2021" description = "fuel network format library" license = "MIT" diff --git a/hyperfuel-format/src/types/mod.rs b/hyperfuel-format/src/types/mod.rs index ff20f82..6743b21 100644 --- a/hyperfuel-format/src/types/mod.rs +++ b/hyperfuel-format/src/types/mod.rs @@ -155,6 +155,8 @@ pub struct Receipt { pub tx_id: Hash, /// The status type of the transaction this receipt originated from pub tx_status: TransactionStatus, + /// The type of the transaction this receipt originated from + pub tx_type: TransactionType, /// block that the receipt originated in pub block_height: UInt, /// The value of the program counter register $pc, which is the memory address of the current instruction. @@ -221,6 +223,8 @@ pub struct Input { pub tx_id: Hash, /// The status type of the transaction this input originated from pub tx_status: TransactionStatus, + /// The type of the transaction this input originated from + pub tx_type: TransactionType, /// block that the input originated in pub block_height: UInt, /// InputCoin, InputContract, or InputMessage @@ -269,6 +273,8 @@ pub struct Output { pub tx_id: Hash, /// The status type of the transaction this output originated from pub tx_status: TransactionStatus, + /// The type of the transaction this output originated from + pub tx_type: TransactionType, /// block that the output originated in pub block_height: UInt, /// CoinOutput, ContractOutput, ChangeOutput, VariableOutput, or ContractCreated diff --git a/hyperfuel-net-types/Cargo.toml b/hyperfuel-net-types/Cargo.toml index addde79..9c5692f 100644 --- a/hyperfuel-net-types/Cargo.toml +++ b/hyperfuel-net-types/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hyperfuel-net-types" -version = "2.0.0" +version = "3.0.0" edition = "2021" description = "hyperfuel types for transport over network" license = "MIT" @@ -10,7 +10,7 @@ capnp = "0.18" serde = { version = "1", features = ["derive"] } arrayvec = { version = "0.7", features = ["serde"] } -hyperfuel-format = { package = "hyperfuel-format", path = "../hyperfuel-format", version = "2.0.0" } +hyperfuel-format = { package = "hyperfuel-format", path = "../hyperfuel-format", version = "3.0.0" } [build-dependencies] capnpc = "0.18" diff --git a/hyperfuel-net-types/src/lib.rs b/hyperfuel-net-types/src/lib.rs index a7e9572..5407cd6 100644 --- a/hyperfuel-net-types/src/lib.rs +++ b/hyperfuel-net-types/src/lib.rs @@ -35,6 +35,8 @@ pub struct ReceiptSelection { pub rd: Vec, #[serde(default)] pub tx_status: Vec, + #[serde(default)] + pub tx_type: Vec, } #[derive(Default, Serialize, Deserialize, Clone, Debug)] @@ -53,6 +55,8 @@ pub struct InputSelection { pub input_type: Vec, #[serde(default)] pub tx_status: Vec, + #[serde(default)] + pub tx_type: Vec, } #[derive(Default, Serialize, Deserialize, Clone, Debug)] @@ -67,6 +71,8 @@ pub struct OutputSelection { pub output_type: Vec, #[serde(default)] pub tx_status: Vec, + #[serde(default)] + pub tx_type: Vec, } #[derive(Default, Serialize, Deserialize, Clone, Debug)] diff --git a/hyperfuel-schema/Cargo.toml b/hyperfuel-schema/Cargo.toml index 475ba54..eac25f4 100644 --- a/hyperfuel-schema/Cargo.toml +++ b/hyperfuel-schema/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hyperfuel-schema" -version = "2.0.0" +version = "3.0.0" edition = "2021" description = "schema utilities for hyperfuel" license = "MIT" diff --git a/hyperfuel-schema/src/lib.rs b/hyperfuel-schema/src/lib.rs index 8a42bf9..e5efffd 100644 --- a/hyperfuel-schema/src/lib.rs +++ b/hyperfuel-schema/src/lib.rs @@ -110,6 +110,7 @@ pub fn receipt() -> SchemaRef { Field::new("root_contract_id", DataType::Binary, true), Field::new("tx_id", DataType::Binary, false), Field::new("tx_status", DataType::UInt8, false), // new + Field::new("tx_type", DataType::UInt8, false), // new Field::new("block_height", DataType::UInt64, false), Field::new("pc", DataType::UInt64, true), Field::new("is", DataType::UInt64, true), @@ -147,6 +148,7 @@ pub fn input() -> SchemaRef { // for mapping Field::new("tx_id", DataType::Binary, false), Field::new("tx_status", DataType::UInt8, false), // new + Field::new("tx_type", DataType::UInt8, false), // new Field::new("block_height", DataType::UInt64, false), Field::new("input_type", DataType::UInt8, false), Field::new("utxo_id", DataType::Binary, true), @@ -175,6 +177,7 @@ pub fn output() -> SchemaRef { // for mapping Field::new("tx_id", DataType::Binary, false), Field::new("tx_status", DataType::UInt8, false), // new + Field::new("tx_type", DataType::UInt8, false), // new Field::new("block_height", DataType::UInt64, false), Field::new("output_type", DataType::UInt8, false), Field::new("to", DataType::Binary, true),