From 45c8d05cebd76aeabf9466e8ba4669177c6a16f9 Mon Sep 17 00:00:00 2001 From: Philipp Hoenisch Date: Mon, 6 Sep 2021 11:34:15 +1000 Subject: [PATCH] Add and run dprint fmt --- Cargo.toml | 2 +- README.md | 2 +- cfd_protocol/src/lib.rs | 40 +++++++++++++++++----------------------- docs/roadmap.md | 1 - dprint.json | 14 ++++++++++++++ 5 files changed, 33 insertions(+), 26 deletions(-) create mode 100644 dprint.json diff --git a/Cargo.toml b/Cargo.toml index 292b3e4..e467376 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,3 +1,3 @@ [workspace] -members = [ "cfd_protocol" ] +members = ["cfd_protocol"] resolver = "2" diff --git a/README.md b/README.md index 900d6ba..bcdbc06 100644 --- a/README.md +++ b/README.md @@ -2,4 +2,4 @@ CFD trading on Bitcoin. -Coming soon. \ No newline at end of file +Coming soon. diff --git a/cfd_protocol/src/lib.rs b/cfd_protocol/src/lib.rs index 053e2f2..ac23492 100644 --- a/cfd_protocol/src/lib.rs +++ b/cfd_protocol/src/lib.rs @@ -1,26 +1,22 @@ -use anyhow::bail; -use anyhow::Context; -use anyhow::Result; +use anyhow::{bail, Context, Result}; use bdk::bitcoin::hashes::*; use bdk::bitcoin::Script; +use bdk::bitcoin::hashes::hex::ToHex; +use bdk::bitcoin::util::bip143::SigHashCache; +use bdk::bitcoin::util::psbt::{Global, PartiallySignedTransaction}; +use bdk::bitcoin::{ + self, Address, Amount, Network, OutPoint, PublicKey, SigHash, SigHashType, Transaction, TxIn, + TxOut, +}; use bdk::database::BatchDatabase; +use bdk::descriptor::Descriptor; +use bdk::miniscript::descriptor::Wsh; +use bdk::miniscript::DescriptorTrait; use bdk::wallet::AddressIndex; -use bdk::{ - bitcoin::{ - self, hashes::hex::ToHex, util::bip143::SigHashCache, util::psbt::Global, - util::psbt::PartiallySignedTransaction, Address, Amount, Network, OutPoint, PublicKey, - SigHash, SigHashType, Transaction, TxIn, TxOut, - }, - descriptor::Descriptor, - miniscript::{descriptor::Wsh, DescriptorTrait}, -}; use bitcoin::PrivateKey; use itertools::Itertools; -use secp256k1_zkp::EcdsaAdaptorSignature; -use secp256k1_zkp::SecretKey; -use secp256k1_zkp::SECP256K1; -use secp256k1_zkp::{self, schnorrsig, Signature}; +use secp256k1_zkp::{self, schnorrsig, EcdsaAdaptorSignature, SecretKey, Signature, SECP256K1}; use std::collections::HashMap; /// In satoshi per vbyte. @@ -826,11 +822,11 @@ impl LockTransaction { #[cfg(test)] mod tests { use super::*; - use bdk::bitcoin::{util::bip32::ExtendedPrivKey, PrivateKey}; + use bdk::bitcoin::util::bip32::ExtendedPrivKey; + use bdk::bitcoin::PrivateKey; use bdk::wallet::AddressIndex; use bdk::SignOptions; - use rand::SeedableRng; - use rand::{CryptoRng, RngCore}; + use rand::{CryptoRng, RngCore, SeedableRng}; use rand_chacha::ChaChaRng; #[test] @@ -1231,8 +1227,7 @@ mod tests { where R: RngCore + CryptoRng, { - use bdk::populate_test_db; - use bdk::testutils; + use bdk::{populate_test_db, testutils}; let mut seed = [0u8; 32]; rng.fill_bytes(&mut seed); @@ -1371,8 +1366,7 @@ mod tests { use secp256k1_zkp::secp256k1_zkp_sys::types::c_void; use secp256k1_zkp::secp256k1_zkp_sys::CPtr; - use std::os::raw::c_int; - use std::os::raw::c_uchar; + use std::os::raw::{c_int, c_uchar}; use std::ptr; /// Create a Schnorr signature using the provided nonce instead of generating one. diff --git a/docs/roadmap.md b/docs/roadmap.md index ea2c576..0709852 100644 --- a/docs/roadmap.md +++ b/docs/roadmap.md @@ -52,4 +52,3 @@ Constraints: - Anonymity - Orderbook - Multiple makers - diff --git a/dprint.json b/dprint.json new file mode 100644 index 0000000..26cc446 --- /dev/null +++ b/dprint.json @@ -0,0 +1,14 @@ +{ + "$schema": "https://dprint.dev/schemas/v0.json", + "incremental": true, + "rustfmt": { + "imports_granularity": "module" + }, + "includes": ["**/*.{md,rs,toml}"], + "excludes": ["**/target"], + "plugins": [ + "https://plugins.dprint.dev/markdown-0.9.2.wasm", + "https://plugins.dprint.dev/rustfmt-0.4.0.exe-plugin@c6bb223ef6e5e87580177f6461a0ab0554ac9ea6b54f78ea7ae8bf63b14f5bc2", + "https://plugins.dprint.dev/toml-0.4.0.wasm" + ] +}