From 70c810a8776be8f0771d0a221b9d483601b7fd6c Mon Sep 17 00:00:00 2001 From: Simon Gellis Date: Fri, 15 Nov 2024 12:07:02 -0500 Subject: [PATCH] fix: formatting --- firefly-cardanoconnect/src/contracts.rs | 5 +--- .../src/contracts/ledger.rs | 30 +++++++++---------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/firefly-cardanoconnect/src/contracts.rs b/firefly-cardanoconnect/src/contracts.rs index 66ce992..e14cb2f 100644 --- a/firefly-cardanoconnect/src/contracts.rs +++ b/firefly-cardanoconnect/src/contracts.rs @@ -1,10 +1,7 @@ use std::{path::PathBuf, sync::Arc}; use anyhow::{bail, Result}; -use balius_runtime::{ - ledgers::Ledger, - Response, Runtime, Store, -}; +use balius_runtime::{ledgers::Ledger, Response, Runtime, Store}; use ledger::BlockfrostLedger; use serde::Deserialize; use serde_json::{json, Value}; diff --git a/firefly-cardanoconnect/src/contracts/ledger.rs b/firefly-cardanoconnect/src/contracts/ledger.rs index 71f8aa3..86f5cae 100644 --- a/firefly-cardanoconnect/src/contracts/ledger.rs +++ b/firefly-cardanoconnect/src/contracts/ledger.rs @@ -12,7 +12,7 @@ pub struct BlockfrostLedger { impl BlockfrostLedger { pub fn new(key: &str) -> Self { Self { - client: BlockfrostAPI::new(key, BlockFrostSettings::new()) + client: BlockfrostAPI::new(key, BlockFrostSettings::new()), } } } @@ -43,7 +43,9 @@ impl CustomLedger for BlockfrostLedger { max_items: u32, ) -> Result { if pattern.asset.is_some() { - return Err(LedgerError::Internal("querying by asset is not implemented".into())); + return Err(LedgerError::Internal( + "querying by asset is not implemented".into(), + )); } let Some(address) = pattern.address else { return Err(LedgerError::Internal("address is required".into())); @@ -52,8 +54,10 @@ impl CustomLedger for BlockfrostLedger { .and_then(|a| a.to_bech32()) .map_err(|err| LedgerError::Internal(err.to_string()))?; let page = match start { - Some(s) => s.parse::().map_err(|e| LedgerError::Internal(e.to_string()))?, - None => 1 + Some(s) => s + .parse::() + .map_err(|e| LedgerError::Internal(e.to_string()))?, + None => 1, }; let pagination = Pagination::new(blockfrost::Order::Asc, page, max_items as usize); @@ -66,8 +70,8 @@ impl CustomLedger for BlockfrostLedger { let mut utxos = vec![]; let mut txs = TxDict::new(&mut self.client); for utxo in query { - let raw_tx_hash = hex::decode(&utxo.tx_hash) - .map_err(|e| LedgerError::Upstream(e.to_string()))?; + let raw_tx_hash = + hex::decode(&utxo.tx_hash).map_err(|e| LedgerError::Upstream(e.to_string()))?; let ref_ = TxoRef { tx_hash: raw_tx_hash, tx_index: utxo.tx_index as u32, @@ -78,7 +82,7 @@ impl CustomLedger for BlockfrostLedger { let Some(txo) = tx.output_at(utxo.tx_index as usize) else { return Err(LedgerError::NotFound(ref_)); }; - + utxos.push(Utxo { ref_, body: txo.encode(), @@ -91,10 +95,7 @@ impl CustomLedger for BlockfrostLedger { None }; - Ok(UtxoPage { - utxos, - next_token, - }) + Ok(UtxoPage { utxos, next_token }) } } @@ -119,8 +120,8 @@ impl<'a> TxDict<'a> { .transactions_cbor(entry.key()) .await .map_err(|e| LedgerError::Upstream(e.to_string()))?; - let bytes = hex::decode(&tx.cbor) - .map_err(|e| LedgerError::Internal(e.to_string()))?; + let bytes = + hex::decode(&tx.cbor).map_err(|e| LedgerError::Internal(e.to_string()))?; Ok(entry.insert(bytes)) } @@ -128,7 +129,6 @@ impl<'a> TxDict<'a> { } fn decode_tx(bytes: &[u8]) -> Result, LedgerError> { - MultiEraTx::decode(bytes) - .map_err(|e| LedgerError::Internal(e.to_string())) + MultiEraTx::decode(bytes).map_err(|e| LedgerError::Internal(e.to_string())) } }