Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding more structs for list of compressed nft events. closes #20 #23

Merged
merged 4 commits into from
Mar 3, 2024
Merged
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
9 changes: 9 additions & 0 deletions src/api/enhanced_transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,13 @@ impl Helius {
pub async fn parse_transaction(&self, transactions: &ParseTransactionsRequest) -> Result<Vec<EnhancedTransaction>> {
self.handler.post(self.make_url("transactions")?, transactions).await
}

/// # Errors
///
/// Will return `HeliusError`
pub async fn parsed_transaction_history(&self, address: &str) -> Result<Vec<EnhancedTransaction>> {
let method = format!("addresses/{address}/transactions");
let url = self.make_url(&method)?;
self.handler.get(url).await
}
}
53 changes: 46 additions & 7 deletions src/api/types/enhanced.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@
}
}

#[derive(Deserialize, Serialize, Debug)]
#[derive(Deserialize, Serialize, Debug, Default)]
#[serde(rename_all = "camelCase")]
pub struct TransactionEvent {
pub nft: Option<NFTEvent>,
pub swap: Option<SwapEvent>,
pub compressed: Option<CompressedNftEvent>,
pub compressed: Option<Vec<CompressedNftEvent>>,
pub set_authority: Option<Vec<Authority>>,
}

#[derive(Deserialize, Serialize, Debug)]
Expand All @@ -51,13 +52,18 @@
#[serde(rename = "type")]
pub transaction_type: TransactionType,
pub tree_id: String,
pub leaf_index: Option<Number>,
pub seq: Option<Number>,
pub asset_id: Option<String>,
pub instruction_index: Option<Number>,
pub inner_instruction_index: Option<Number>,
pub leaf_index: Option<i32>,
pub seq: Option<i32>,
pub asset_id: String,
pub instruction_index: Option<i32>,
pub inner_instruction_index: Option<i32>,
pub new_leaf_owner: Option<String>,
pub old_leaf_owner: Option<String>,
pub new_leaf_delegate: Option<String>,
pub old_leaf_delegate: Option<serde_json::Value>,
pub tree_delegate: Option<String>,
pub metadata: Option<Metadata>,
pub update_args: Option<serde_json::Value>,
}

#[derive(Deserialize, Serialize, Debug)]
Expand Down Expand Up @@ -198,3 +204,36 @@
pub data: String,
pub program_id: String,
}

#[derive(Serialize, Deserialize, Debug)]

Check warning on line 208 in src/api/types/enhanced.rs

View check run for this annotation

Codecov / codecov/patch

src/api/types/enhanced.rs#L208

Added line #L208 was not covered by tests
pub struct Collection {
pub key: String,
pub verified: bool,
}

#[derive(Serialize, Deserialize, Debug)]

Check warning on line 214 in src/api/types/enhanced.rs

View check run for this annotation

Codecov / codecov/patch

src/api/types/enhanced.rs#L214

Added line #L214 was not covered by tests
#[serde(rename_all = "camelCase")]
pub struct Metadata {
pub name: String,
pub symbol: String,
pub uri: String,
pub seller_fee_basis_points: i32,
pub primary_sale_happened: bool,
#[serde(rename = "isMutable")]
pub mutable: bool,
pub edition_nonce: Option<i32>,
pub token_standard: Option<String>,
pub collection: Option<Collection>,
pub token_program_version: String,
pub creators: Option<Vec<serde_json::Value>>,
}

#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct Authority {
pub account: String,
pub from: String,
pub to: String,
pub instruction_index: Option<i32>,
pub inner_instruction_index: Option<i32>,
}
2 changes: 2 additions & 0 deletions src/api/types/webhook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ pub struct WebhookData {
pub webhook_type: WebhookType,
#[serde(skip_serializing_if = "Option::is_none")]
pub auth_header: Option<String>,
#[serde(default)]
pub txn_status: TxnStatus,
#[serde(default)]
pub encoding: AccountWebhookEncoding,
}

Expand Down
4 changes: 4 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ mod tests {
let res = client.parse_transaction(&sigs[0]).await?;
assert!(!res.is_empty());
assert!(res[0].timestamp > 0);

let res = client.parsed_transaction_history("M2mx93ekt1fmXSVkTrUL9xVFHkmME8HTUi5Cyc5aF7K").await?;
assert!(!res.is_empty());
assert!(res[0].timestamp > 0);
Ok(())
}

Expand Down