Skip to content

Commit

Permalink
chore: fix fmt style
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Oct 31, 2024
1 parent d8e28e1 commit c6ca77c
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
edition = "2021"
version = "Two"
style_edition = "2021"

max_width = 100
array_width = 100
Expand Down
4 changes: 2 additions & 2 deletions cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ use baid64::DisplayBaid64;
use bpstd::psbt::{Psbt, PsbtVer};
use bpstd::seals::SecretSeal;
use bpstd::{Sats, XpubDerivable};
use bpwallet::Wallet;
use bpwallet::cli::{BpCommand, Config, Exec};
use bpwallet::Wallet;
use rgb::containers::{
BuilderSeal, ConsignmentExt, ContainerVer, ContentId, ContentSigs, Contract, FileContent,
Supplement, Transfer, UniversalFile,
Expand All @@ -53,8 +53,8 @@ use rgbstd::persistence::{MemContractState, StockError};
use rgbstd::stl::rgb_contract_stl;
use rgbstd::{KnownState, OutputAssignment};
use serde_crate::{Deserialize, Serialize};
use strict_types::StrictVal;
use strict_types::encoding::{FieldName, TypeName};
use strict_types::StrictVal;

use crate::RgbArgs;

Expand Down
6 changes: 3 additions & 3 deletions psbt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ use bp::dbc::opret::OpretProof;
use bp::dbc::tapret::TapretProof;
pub use bpstd::psbt::*;
pub use rgb::*;
use rgbstd::XChain;
use rgbstd::containers::{AnchorSet, Batch, CloseMethodSet, Fascia, PubWitness, XPubWitness};
use rgbstd::XChain;

pub use self::rgb::{
PSBT_GLOBAL_RGB_TRANSITION, PSBT_IN_RGB_CONSUMED_BY, PSBT_OUT_RGB_VELOCITY_HINT,
PSBT_RGB_PREFIX, ProprietaryKeyRgb, RgbExt, RgbInExt, RgbOutExt, RgbPsbtError,
ProprietaryKeyRgb, RgbExt, RgbInExt, RgbOutExt, RgbPsbtError, PSBT_GLOBAL_RGB_TRANSITION,
PSBT_IN_RGB_CONSUMED_BY, PSBT_OUT_RGB_VELOCITY_HINT, PSBT_RGB_PREFIX,
};

#[derive(Clone, Eq, PartialEq, Debug, Display, Error)]
Expand Down
8 changes: 6 additions & 2 deletions psbt/src/rgb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
use std::collections::{BTreeMap, BTreeSet, HashMap};

use amplify::confinement::{Confined, SmallOrdMap, U24};
use amplify::{FromSliceError, confinement};
use amplify::{confinement, FromSliceError};
use bp::dbc::Method;
use bp::seals::txout::CloseMethod;
use bpstd::psbt;
Expand Down Expand Up @@ -418,7 +418,11 @@ pub trait RgbOutExt {
impl RgbOutExt for psbt::Output {
fn rgb_velocity_hint(&self) -> Option<VelocityHint> {
let data = self.proprietary.get(&PropKey::rgb_out_velocity_hint())?;
if data.len() != 1 { None } else { data.first().map(VelocityHint::with_value) }
if data.len() != 1 {
None

Check warning on line 422 in psbt/src/rgb.rs

View check run for this annotation

Codecov / codecov/patch

psbt/src/rgb.rs#L421-L422

Added lines #L421 - L422 were not covered by tests
} else {
data.first().map(VelocityHint::with_value)

Check warning on line 424 in psbt/src/rgb.rs

View check run for this annotation

Codecov / codecov/patch

psbt/src/rgb.rs#L424

Added line #L424 was not covered by tests
}
}

fn set_rgb_velocity_hint(&mut self, hint: VelocityHint) -> bool {
Expand Down
2 changes: 1 addition & 1 deletion src/descriptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ use std::iter;
use std::str::FromStr;

use amplify::Wrapper;
use bp::dbc::Method;
use bp::dbc::tapret::TapretCommitment;
use bp::dbc::Method;
use bp::seals::txout::CloseMethod;
use bp::{LegacyPk, SigScript, Witness};
use bpstd::{
Expand Down
26 changes: 10 additions & 16 deletions src/indexers/electrum_blocking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,21 +95,17 @@ impl RgbResolver for Client {
let Some(confirmations) = tx_details.get("confirmations") else {
return Ok(WitnessOrd::Tentative);
};
let confirmations = check!(
confirmations
.as_u64()
.and_then(|x| u32::try_from(x).ok())
.ok_or(Error::InvalidResponse(tx_details.clone()))
);
let confirmations = check!(confirmations
.as_u64()
.and_then(|x| u32::try_from(x).ok())
.ok_or(Error::InvalidResponse(tx_details.clone())));

Check warning on line 101 in src/indexers/electrum_blocking.rs

View check run for this annotation

Codecov / codecov/patch

src/indexers/electrum_blocking.rs#L98-L101

Added lines #L98 - L101 were not covered by tests
if confirmations == 0 {
return Ok(WitnessOrd::Tentative);
}
let block_time = check!(
tx_details
.get("blocktime")
.and_then(|v| v.as_i64())
.ok_or(Error::InvalidResponse(tx_details.clone()))
);
let block_time = check!(tx_details
.get("blocktime")
.and_then(|v| v.as_i64())
.ok_or(Error::InvalidResponse(tx_details.clone())));

Check warning on line 108 in src/indexers/electrum_blocking.rs

View check run for this annotation

Codecov / codecov/patch

src/indexers/electrum_blocking.rs#L105-L108

Added lines #L105 - L108 were not covered by tests

let tip_height = u32::try_from(header.height).map_err(|_| s!("impossible height value"))?;
let height: isize = (tip_height - confirmations) as isize;
Expand All @@ -127,10 +123,8 @@ impl RgbResolver for Client {

let height =
check!(NonZeroU32::new(tx_height).ok_or(Error::InvalidResponse(tx_details.clone())));
let pos = check!(
WitnessPos::bitcoin(height, block_time)
.ok_or(Error::InvalidResponse(tx_details.clone()))
);
let pos = check!(WitnessPos::bitcoin(height, block_time)
.ok_or(Error::InvalidResponse(tx_details.clone())));

Check warning on line 127 in src/indexers/electrum_blocking.rs

View check run for this annotation

Codecov / codecov/patch

src/indexers/electrum_blocking.rs#L124-L127

Added lines #L124 - L127 were not covered by tests

Ok(WitnessOrd::Mined(pos))
}
Expand Down
18 changes: 9 additions & 9 deletions src/pay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ struct ContractOutpointsFilter<
}

impl<
'stock,
'wallet,
W: WalletProvider<K, L2> + ?Sized,
K,
S: StashProvider,
H: StateProvider,
P: IndexProvider,
L2: Layer2,
> AssignmentsFilter for ContractOutpointsFilter<'stock, 'wallet, W, K, S, H, P, L2>
'stock,
'wallet,
W: WalletProvider<K, L2> + ?Sized,
K,
S: StashProvider,
H: StateProvider,
P: IndexProvider,
L2: Layer2,
> AssignmentsFilter for ContractOutpointsFilter<'stock, 'wallet, W, K, S, H, P, L2>
where W::Descr: DescriptorRgb<K>
{
fn should_include(&self, output: impl Into<XOutpoint>, id: Option<XWitnessId>) -> bool {

Check warning on line 94 in src/pay.rs

View check run for this annotation

Codecov / codecov/patch

src/pay.rs#L94

Added line #L94 was not covered by tests
Expand Down
10 changes: 8 additions & 2 deletions src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,14 @@ impl<K, D: DescriptorRgb<K>, S: StashProvider, H: StateProvider, P: IndexProvide
}
}

impl<K, W: WalletProvider<K, L2>, S: StashProvider, H: StateProvider, P: IndexProvider, L2: Layer2>
RgbWallet<W, K, S, H, P, L2>
impl<
K,
W: WalletProvider<K, L2>,
S: StashProvider,
H: StateProvider,
P: IndexProvider,
L2: Layer2,
> RgbWallet<W, K, S, H, P, L2>
where W::Descr: DescriptorRgb<K>
{
pub fn new(stock: Stock<S, H, P>, wallet: W) -> Self {
Expand Down

0 comments on commit c6ca77c

Please sign in to comment.