Skip to content

Commit

Permalink
adding esitmate fee endpoint (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
dougEfresh committed May 10, 2024
1 parent e062b1d commit a038e9d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "fireblocks-sdk"
resolver = "2"
version = "0.3.1"
version = "0.3.2"
authors = ["Doug Chimento <dchimento@gmail.com>"]
description = "Rust implementation of the Fireblocks SDK"
readme = "README.md"
Expand Down
6 changes: 6 additions & 0 deletions src/api/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,10 @@ impl Client {
let u = self.build_url(format!("estimate_network_fee?assetId={asset}"))?.0;
self.get(u).await
}

#[tracing::instrument(level = "debug", skip(self))]
pub async fn estimate_fee_transaction(&self, t: &TransactionArguments) -> crate::Result<EstimateFee> {
let u = self.build_url("transactions/estimate_fee")?.0;
self.post(u, Some(t)).await
}
}
14 changes: 14 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ mod tests {
}

let c = config.client();

let tx = c.create_transaction_vault(0, 1, ASSET_SOL_TEST, BigDecimal::from_str("0.001")?, None).await?.0;
assert_eq!(tx.status, TransactionStatus::SUBMITTED);
c.poll_transaction(&tx.id, Duration::from_secs(10), Duration::from_secs(5), |t: &Transaction| {
Expand All @@ -383,6 +384,19 @@ mod tests {
None,
)
.await?;

let args = &TransactionArguments {
asset_id: "SOL_TEST".to_string(),
operation: TransactionOperation::TRANSFER,
source: TransferPeerPath { id: Some("0".to_string()), ..Default::default() },
destination: Some(DestinationTransferPeerPath { id: "4".to_string(), ..Default::default() }),
amount: "0.001".to_string(),
gas_price: None,
gas_limit: None,
note: "created by fireblocks-sdk for rust".to_string(),
};

c.estimate_fee_transaction(args).await?;
Ok(())
}

Expand Down

0 comments on commit a038e9d

Please sign in to comment.