Skip to content

Commit

Permalink
update to include tx_type query
Browse files Browse the repository at this point in the history
  • Loading branch information
JossDuff committed Jun 6, 2024
1 parent 042c53a commit ab69069
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 9 deletions.
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
edition = "2021"
name = "envio_hyperfuel-client"
version = "1.1.0"
version = "1.2.0"

[lib]
crate-type = ["cdylib"]
Expand All @@ -21,9 +21,9 @@ anyhow = "1.0.83"
env_logger = "0.11"
faster-hex = "0.9.0"

hyperfuel-client = "2.0.0"
hyperfuel-net-types = "2.0.0"
hyperfuel-format = "2.0.0"
hyperfuel-client = "2.1.0"
hyperfuel-net-types = "3.0.0"
hyperfuel-format = "3.0.0"

[build-dependencies]
napi-build = "2.0.1"
Expand Down
2 changes: 1 addition & 1 deletion examples/asset-id/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# asset-id
We query from blocks 0 (inclusive) to 1299067 (exclusive) for all `Inputs` where the address `0x2a0d0ed9d2217ec7f32dcd9a1902ce2a66d68437aeff84e3a3cc8bebee0d2eea`
We query from blocks 0 (inclusive) to 1300000 (exclusive) for all `Inputs` where the address `0x2a0d0ed9d2217ec7f32dcd9a1902ce2a66d68437aeff84e3a3cc8bebee0d2eea`
matches on the `asset_id` field.

Can run `npx tsc && node dist/app.js` to run it.
2 changes: 1 addition & 1 deletion examples/asset-id/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ async function main() {
// start query from block 0
"fromBlock": 0,
// if to_block is not set, query runs to the end of the chain
"toBlock": 1299067,
"toBlock": 1300000,
// which inputs to load data from
"inputs": [
{
Expand Down
13 changes: 11 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface ReceiptSelection {
rc?: Array<bigint>
rd?: Array<bigint>
txStatus?: Array<number>
txType?: Array<number>
}
export interface InputSelection {
owner?: Array<string>
Expand All @@ -33,13 +34,15 @@ export interface InputSelection {
recipient?: Array<string>
inputType?: Array<number>
txStatus?: Array<number>
txType?: Array<number>
}
export interface OutputSelection {
to?: Array<string>
assetId?: Array<string>
contract?: Array<string>
outputType?: Array<number>
txStatus?: Array<number>
txType?: Array<number>
}
export interface FieldSelection {
block?: Array<string>
Expand Down Expand Up @@ -267,6 +270,8 @@ export interface Receipt {
txId: string
/** The status type of the transaction this receipt originated from */
txStatus: number
/** The type of the transaction this receipt originated from */
txType: number
/** block that the receipt originated in */
blockHeight: number
/** The value of the program counter register $pc, which is the memory address of the current instruction. */
Expand Down Expand Up @@ -328,8 +333,10 @@ export interface Receipt {
export interface Input {
/** transaction that this input originated from */
txId: string
/** The status type of the transaction this receipt originated from */
/** The status type of the transaction this input originated from */
txStatus: number
/** The type of the transaction this input originated from */
txType: number
/** block that the input originated in */
blockHeight: number
/** InputCoin, InputContract, or InputMessage */
Expand Down Expand Up @@ -375,8 +382,10 @@ export interface Input {
export interface Output {
/** transaction that this out originated from */
txId: string
/** The status type of the transaction this receipt originated from */
/** The status type of the transaction this output originated from */
txStatus: number
/** The type of the transaction this output originated from */
txType: number
/** block that the output originated in */
blockHeight: number
/** CoinOutput, ContractOutput, ChangeOutput, VariableOutput, or ContractCreated */
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@envio-dev/hyperfuel-client",
"version": "1.1.0",
"version": "1.2.0",
"main": "index.js",
"types": "index.d.ts",
"napi": {
Expand Down
6 changes: 6 additions & 0 deletions src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ pub struct ReceiptSelection {
pub rd: Option<Vec<BigInt>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub tx_status: Option<Vec<u8>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub tx_type: Option<Vec<u8>>,
}

#[napi(object)]
Expand All @@ -94,6 +96,8 @@ pub struct InputSelection {
pub input_type: Option<Vec<u8>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub tx_status: Option<Vec<u8>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub tx_type: Option<Vec<u8>>,
}

#[napi(object)]
Expand All @@ -109,6 +113,8 @@ pub struct OutputSelection {
pub output_type: Option<Vec<u8>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub tx_status: Option<Vec<u8>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub tx_type: Option<Vec<u8>>,
}

#[napi(object)]
Expand Down
9 changes: 9 additions & 0 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ pub struct Receipt {
pub tx_id: String,
/// The status type of the transaction this receipt originated from
pub tx_status: u8,
/// The type of the transaction this receipt originated from
pub tx_type: u8,
/// block that the receipt originated in
pub block_height: i64,
/// The value of the program counter register $pc, which is the memory address of the current instruction.
Expand Down Expand Up @@ -186,6 +188,8 @@ pub struct Input {
pub tx_id: String,
/// The status type of the transaction this input originated from
pub tx_status: u8,
/// The type of the transaction this input originated from
pub tx_type: u8,
/// block that the input originated in
pub block_height: i64,
/// InputCoin, InputContract, or InputMessage
Expand Down Expand Up @@ -234,6 +238,8 @@ pub struct Output {
pub tx_id: String,
/// The status type of the transaction this output originated from
pub tx_status: u8,
/// The type of the transaction this output originated from
pub tx_type: u8,
/// block that the output originated in
pub block_height: i64,
/// CoinOutput, ContractOutput, ChangeOutput, VariableOutput, or ContractCreated
Expand Down Expand Up @@ -342,6 +348,7 @@ impl From<hyperfuel_format::Receipt> for Receipt {
root_contract_id: r.root_contract_id.map(|d| d.encode_hex()),
tx_id: r.tx_id.encode_hex(),
tx_status: r.tx_status.as_u8(),
tx_type: r.tx_type.to_u8(),
block_height: as_i64(r.block_height),
pc: r.pc.map(|x| x.to_string()),
is: r.is.map(|x| x.to_string()),
Expand Down Expand Up @@ -419,6 +426,7 @@ impl From<hyperfuel_format::Input> for Input {
Self {
tx_id: i.tx_id.encode_hex(),
tx_status: i.tx_status.as_u8(),
tx_type: i.tx_type.to_u8(),
block_height: as_i64(i.block_height),
input_type: i.input_type.as_u8(),
utxo_id: i.utxo_id.map(|d| d.encode_hex()),
Expand Down Expand Up @@ -451,6 +459,7 @@ impl From<hyperfuel_format::Output> for Output {
Self {
tx_id: o.tx_id.encode_hex(),
tx_status: o.tx_status.as_u8(),
tx_type: o.tx_type.to_u8(),
block_height: as_i64(o.block_height),
output_type: o.output_type.as_u8(),
to: o.to.map(|d| d.encode_hex()),
Expand Down

0 comments on commit ab69069

Please sign in to comment.