-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Chuck
authored
Aug 21, 2023
1 parent
b9d99e8
commit 2d3df7b
Showing
7 changed files
with
204 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
use std::collections::HashMap; | ||
|
||
use alloy_primitives::{FixedBytes, U256}; | ||
|
||
use crate::ApiCall; | ||
|
||
#[derive(Debug, Clone, serde::Deserialize, serde::Serialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct ExplorerTxResponse { | ||
pub transactions: Vec<ExplorerTx>, | ||
} | ||
|
||
#[derive(Debug, Clone, serde::Deserialize, serde::Serialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct ExplorerTx { | ||
pub id: String, | ||
pub emitter_chain: u16, | ||
pub emitter_address: FixedBytes<32>, | ||
|
||
pub tx_hash: Option<String>, | ||
|
||
pub emitter_native_addr: Option<String>, | ||
pub global_tx: Option<GlobalTx>, | ||
pub symbol: Option<String>, | ||
pub timestamp: Option<String>, | ||
pub token_amount: Option<String>, | ||
pub usd_amount: Option<String>, | ||
|
||
#[serde(default, skip_serializing_if = "HashMap::is_empty")] | ||
pub payload: HashMap<String, serde_json::Value>, | ||
|
||
#[serde(default, skip_serializing_if = "HashMap::is_empty")] | ||
pub standardized_properties: HashMap<String, serde_json::Value>, | ||
} | ||
|
||
#[derive(Debug, Clone, serde::Deserialize, serde::Serialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct GlobalTx { | ||
pub destination_tx: Option<DestinationTx>, | ||
pub id: String, | ||
pub origin_tx: OriginTx, | ||
} | ||
|
||
#[derive(Debug, Clone, serde::Deserialize, serde::Serialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct DestinationTx { | ||
pub block_number: U256, | ||
pub chain_id: u16, | ||
pub from: String, | ||
pub method: String, | ||
pub status: String, | ||
pub timestamp: String, | ||
pub to: String, | ||
pub tx_hash: String, | ||
pub updated_at: String, | ||
} | ||
|
||
#[derive(Debug, Clone, serde::Deserialize, serde::Serialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct OriginTx { | ||
pub from: String, | ||
pub status: String, | ||
pub tx_hash: String, | ||
} | ||
|
||
#[derive(Debug, Clone, serde::Deserialize, serde::Serialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct AllTxnsRequest; | ||
|
||
impl ApiCall for AllTxnsRequest { | ||
type Return = ExplorerTxResponse; | ||
|
||
fn endpoint(&self) -> String { | ||
"/api/v1/transactions/".to_string() | ||
} | ||
} | ||
|
||
#[derive(Debug, Clone, serde::Deserialize, serde::Serialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct SingleTxRequest { | ||
pub chain_id: u16, | ||
pub emitter: FixedBytes<32>, | ||
pub sequence: u64, | ||
} | ||
|
||
impl ApiCall for SingleTxRequest { | ||
type Return = ExplorerTx; | ||
|
||
fn endpoint(&self) -> String { | ||
format!( | ||
"/api/v1/transactions/{}/{}/{}", | ||
self.chain_id, self.emitter, self.sequence | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#![allow(dead_code)] | ||
use wormhole_explorer_client::{ | ||
endpoints::tx::{AllTxnsRequest, SingleTxRequest}, | ||
Client, | ||
}; | ||
|
||
use hex_literal::hex; | ||
|
||
// #[tokio::test] | ||
async fn retrieve_txs() { | ||
let req = AllTxnsRequest; | ||
|
||
let client = Client::new( | ||
"https://api.wormholescan.io/".parse().unwrap(), | ||
Default::default(), | ||
); | ||
|
||
let resp = client.send(&req).await; | ||
dbg!(&resp); | ||
|
||
assert!(resp.is_ok()); | ||
} | ||
|
||
// #[tokio::test] | ||
async fn retrieve_eth_token_bridge() { | ||
let req = SingleTxRequest { | ||
chain_id: 2, | ||
emitter: hex!("0000000000000000000000003ee18B2214AFF97000D974cf647E7C347E8fa585").into(), | ||
sequence: 5, | ||
}; | ||
|
||
let client = Client::new( | ||
"https://api.wormholescan.io/".parse().unwrap(), | ||
Default::default(), | ||
); | ||
|
||
let resp = client.send(&req).await; | ||
|
||
let tx = resp.unwrap(); | ||
dbg!(&tx); | ||
} |