Browse Source

improve: nix flakebox fmt

thesimplekid 1 year ago
parent
commit
bf5ea01c1f
80 changed files with 1029 additions and 262 deletions
  1. 1 0
      .config/flakebox/id
  2. 32 0
      .config/flakebox/shellHook.sh
  3. 1 0
      .envrc
  4. 78 0
      .github/workflows/flakebox-ci.yml
  5. 35 0
      .github/workflows/flakebox-flakehub-publish.yml
  6. 4 0
      .rustfmt.toml
  7. 1 1
      bindings/cashu-ffi/Cargo.toml
  8. 5 6
      bindings/cashu-ffi/src/lib.rs
  9. 4 2
      bindings/cashu-ffi/src/nuts/nut00/blinded_messages.rs
  10. 1 3
      bindings/cashu-ffi/src/nuts/nut00/blinded_signature.rs
  11. 5 5
      bindings/cashu-ffi/src/nuts/nut00/proof.rs
  12. 1 2
      bindings/cashu-ffi/src/nuts/nut00/token.rs
  13. 4 2
      bindings/cashu-ffi/src/nuts/nut01/key_pair.rs
  14. 5 2
      bindings/cashu-ffi/src/nuts/nut01/keys.rs
  15. 1 3
      bindings/cashu-ffi/src/nuts/nut02/key_set.rs
  16. 2 1
      bindings/cashu-ffi/src/nuts/nut03/mod.rs
  17. 2 1
      bindings/cashu-ffi/src/nuts/nut04/mod.rs
  18. 10 9
      bindings/cashu-ffi/src/nuts/nut05/mod.rs
  19. 2 1
      bindings/cashu-ffi/src/nuts/nut06/mod.rs
  20. 2 1
      bindings/cashu-ffi/src/nuts/nut07/mod.rs
  21. 2 1
      bindings/cashu-ffi/src/nuts/nut09/mod.rs
  22. 2 1
      bindings/cashu-ffi/src/types/amount.rs
  23. 5 2
      bindings/cashu-ffi/src/types/bolt11_invoice.rs
  24. 2 1
      bindings/cashu-ffi/src/types/keyset_info.rs
  25. 1 1
      bindings/cashu-js/examples/amount.js
  26. 1 1
      bindings/cashu-js/justfile
  27. 2 2
      bindings/cashu-js/scripts/build.sh
  28. 1 1
      bindings/cashu-js/scripts/epilogue.d.ts
  29. 1 1
      bindings/cashu-js/scripts/epilogue.js
  30. 1 2
      bindings/cashu-js/src/nuts/nut00/blinded_messages.rs
  31. 3 1
      bindings/cashu-js/src/nuts/nut00/blinded_signature.rs
  32. 3 1
      bindings/cashu-js/src/nuts/nut00/proof.rs
  33. 4 2
      bindings/cashu-js/src/nuts/nut00/token.rs
  34. 2 5
      bindings/cashu-js/src/nuts/nut01/keys.rs
  35. 2 4
      bindings/cashu-js/src/nuts/nut02/keyset.rs
  36. 1 4
      bindings/cashu-js/src/nuts/nut02/mod.rs
  37. 2 4
      bindings/cashu-js/src/nuts/nut04.rs
  38. 2 4
      bindings/cashu-js/src/nuts/nut05.rs
  39. 2 4
      bindings/cashu-js/src/nuts/nut06.rs
  40. 4 8
      bindings/cashu-js/src/nuts/nut08.rs
  41. 1 2
      bindings/cashu-js/src/nuts/nut09.rs
  42. 2 1
      bindings/cashu-js/src/types/bolt11_invoice.rs
  43. 1 1
      bindings/cashu-sdk-ffi/src/cashu_sdk.udl
  44. 2 4
      bindings/cashu-sdk-ffi/src/mint.rs
  45. 3 3
      bindings/cashu-sdk-ffi/src/types/melted.rs
  46. 2 1
      bindings/cashu-sdk-ffi/src/types/proofs_status.rs
  47. 3 3
      bindings/cashu-sdk-ffi/src/types/send_proofs.rs
  48. 4 6
      bindings/cashu-sdk-ffi/src/wallet.rs
  49. 1 1
      bindings/cashu-sdk-js/examples/amount.js
  50. 1 1
      bindings/cashu-sdk-js/examples/wallet.js
  51. 1 1
      bindings/cashu-sdk-js/justfile
  52. 2 2
      bindings/cashu-sdk-js/scripts/build.sh
  53. 1 1
      bindings/cashu-sdk-js/scripts/epilogue.d.ts
  54. 1 1
      bindings/cashu-sdk-js/scripts/epilogue.js
  55. 9 11
      bindings/cashu-sdk-js/src/mint.rs
  56. 4 6
      bindings/cashu-sdk-js/src/wallet.rs
  57. 1 1
      bindings/uniffi-bindgen/Cargo.toml
  58. 13 17
      crates/cashu-sdk/src/client/blocking.rs
  59. 7 9
      crates/cashu-sdk/src/client/mod.rs
  60. 2 4
      crates/cashu-sdk/src/lib.rs
  61. 5 12
      crates/cashu-sdk/src/mint.rs
  62. 3 6
      crates/cashu-sdk/src/wallet.rs
  63. 2 9
      crates/cashu/src/dhke.rs
  64. 14 14
      crates/cashu/src/nuts/nut00.rs
  65. 4 6
      crates/cashu/src/nuts/nut01.rs
  66. 7 12
      crates/cashu/src/nuts/nut02.rs
  67. 1 2
      crates/cashu/src/nuts/nut05.rs
  68. 3 5
      crates/cashu/src/nuts/nut06.rs
  69. 2 2
      crates/cashu/src/nuts/nut08.rs
  70. 2 1
      crates/cashu/src/secret.rs
  71. 2 1
      crates/cashu/src/serde_utils.rs
  72. 2 4
      crates/cashu/src/types.rs
  73. 3 1
      crates/cashu/src/url.rs
  74. 2 2
      crates/cashu/src/utils.rs
  75. 375 0
      flake.lock
  76. 25 0
      flake.nix
  77. 87 20
      justfile
  78. 23 0
      misc/git-hooks/commit-msg
  79. 2 0
      misc/git-hooks/commit-template.txt
  80. 165 0
      misc/git-hooks/pre-commit

+ 1 - 0
.config/flakebox/id

@@ -0,0 +1 @@
+6ed8d7bac0d49950f28394f623607c29d00896bcf1505d366717626babadd81f8f111f93afd1b991b7087d5ce0684b4bcc10124aad93b3876ba1aba600a09cb4

+ 32 - 0
.config/flakebox/shellHook.sh

@@ -0,0 +1,32 @@
+#!/usr/bin/env bash
+root="$(git rev-parse --show-toplevel)"
+dot_git="$(git rev-parse --git-common-dir)"
+if [[ ! -d "${dot_git}/hooks" ]]; then mkdir -p "${dot_git}/hooks"; fi
+# fix old bug
+rm -f "${dot_git}/hooks/comit-msg"
+rm -f "${dot_git}/hooks/commit-msg"
+ln -sf "${root}/misc/git-hooks/commit-msg" "${dot_git}/hooks/commit-msg"
+
+root="$(git rev-parse --show-toplevel)"
+dot_git="$(git rev-parse --git-common-dir)"
+if [[ ! -d "${dot_git}/hooks" ]]; then mkdir -p "${dot_git}/hooks"; fi
+# fix old bug
+rm -f "${dot_git}/hooks/pre-comit"
+rm -f "${dot_git}/hooks/pre-commit"
+ln -sf "${root}/misc/git-hooks/pre-commit" "${dot_git}/hooks/pre-commit"
+
+# set template
+git config commit.template misc/git-hooks/commit-template.txt
+
+if ! flakebox lint --silent; then
+  >&2 echo "ℹ️  Project recommendations detected. Run 'flakebox lint' for more info."
+fi
+
+if [ -n "${DIRENV_IN_ENVRC:-}" ]; then
+  # and not set DIRENV_LOG_FORMAT
+  if [ -n "${DIRENV_LOG_FORMAT:-}" ]; then
+    >&2 echo "💡 Set 'DIRENV_LOG_FORMAT=\"\"' in your shell environment variables for a cleaner output of direnv"
+  fi
+fi
+
+>&2 echo "💡 Run 'just' for a list of available 'just ...' helper recipes"

+ 1 - 0
.envrc

@@ -0,0 +1 @@
+use flake

+ 78 - 0
.github/workflows/flakebox-ci.yml

@@ -0,0 +1,78 @@
+# THIS FILE IS AUTOGENERATED FROM FLAKEBOX CONFIGURATION
+
+jobs:
+  build:
+    name: Build
+    runs-on: ${{ matrix.runs-on }}
+    steps:
+    - uses: actions/checkout@v4
+    - name: Install Nix
+      uses: DeterminateSystems/nix-installer-action@v4
+    - name: Magic Nix Cache
+      uses: DeterminateSystems/magic-nix-cache-action@v2
+    - name: Build on ${{ matrix.host }}
+      run: 'nix flake check -L .#
+
+        '
+    strategy:
+      matrix:
+        host:
+        - macos
+        - linux
+        include:
+        - host: linux
+          runs-on: ubuntu-latest
+          timeout: 60
+        - host: macos
+          runs-on: macos-12
+          timeout: 60
+    timeout-minutes: ${{ matrix.timeout }}
+  flake:
+    name: Flake self-check
+    runs-on: ubuntu-latest
+    steps:
+    - uses: actions/checkout@v4
+    - name: Check Nix flake inputs
+      uses: DeterminateSystems/flake-checker-action@v5
+      with:
+        fail-mode: true
+  lint:
+    name: Lint
+    runs-on: ubuntu-latest
+    steps:
+    - uses: actions/checkout@v4
+    - name: Install Nix
+      uses: DeterminateSystems/nix-installer-action@v4
+    - name: Magic Nix Cache
+      uses: DeterminateSystems/magic-nix-cache-action@v2
+    - name: Cargo Cache
+      uses: actions/cache@v3
+      with:
+        key: ${{ runner.os }}-${{ hashFiles('Cargo.lock') }}
+        path: ~/.cargo
+    - name: Commit Check
+      run: '# run the same check that git `pre-commit` hook does
+
+        nix develop --ignore-environment .#lint --command ./misc/git-hooks/pre-commit
+
+        '
+name: CI
+'on':
+  merge_group:
+    branches:
+    - master
+    - main
+  pull_request:
+    branches:
+    - master
+    - main
+  push:
+    branches:
+    - master
+    - main
+    tags:
+    - v*
+  workflow_dispatch: {}
+
+
+# THIS FILE IS AUTOGENERATED FROM FLAKEBOX CONFIGURATION

+ 35 - 0
.github/workflows/flakebox-flakehub-publish.yml

@@ -0,0 +1,35 @@
+# THIS FILE IS AUTOGENERATED FROM FLAKEBOX CONFIGURATION
+
+jobs:
+  flakehub-publish:
+    permissions:
+      contents: read
+      id-token: write
+    runs-on: ubuntu-latest
+    steps:
+    - uses: actions/checkout@v4
+      with:
+        ref: ${{ (inputs.tag != null) && format('refs/tags/{0}', inputs.tag) || ''
+          }}
+    - name: Install Nix
+      uses: DeterminateSystems/nix-installer-action@v4
+    - name: Flakehub Push
+      uses: DeterminateSystems/flakehub-push@main
+      with:
+        name: ${{ github.repository }}
+        tag: ${{ inputs.tag }}
+        visibility: public
+name: Publish to Flakehub
+'on':
+  push:
+    tags:
+    - v?[0-9]+.[0-9]+.[0-9]+*
+  workflow_dispatch:
+    inputs:
+      tags:
+        description: The existing tag to publish to FlakeHub
+        required: true
+        type: string
+
+
+# THIS FILE IS AUTOGENERATED FROM FLAKEBOX CONFIGURATION

+ 4 - 0
.rustfmt.toml

@@ -0,0 +1,4 @@
+group_imports = "StdExternalCrate"
+wrap_comments = true
+format_code_in_doc_comments = true
+imports_granularity = "Module"

+ 1 - 1
bindings/cashu-ffi/Cargo.toml

@@ -17,4 +17,4 @@ url = { workspace = true }
 uniffi = { workspace = true }
 
 [build-dependencies]
-uniffi = { workspace = true, features = ["build"] }
+uniffi = { workspace = true, features = ["build"] }

+ 5 - 6
bindings/cashu-ffi/src/lib.rs

@@ -3,12 +3,15 @@ mod nuts;
 mod types;
 
 mod ffi {
+    pub use cashu::types::InvoiceStatus;
+
     pub use crate::error::CashuError;
     pub use crate::nuts::nut00::blinded_message::BlindedMessage;
     pub use crate::nuts::nut00::blinded_messages::BlindedMessages;
     pub use crate::nuts::nut00::blinded_signature::BlindedSignature;
     pub use crate::nuts::nut00::mint_proofs::MintProofs;
-    pub use crate::nuts::nut00::proof::{mint::Proof as MintProof, Proof};
+    pub use crate::nuts::nut00::proof::mint::Proof as MintProof;
+    pub use crate::nuts::nut00::proof::Proof;
     pub use crate::nuts::nut00::token::Token;
     pub use crate::nuts::nut01::key_pair::KeyPair;
     pub use crate::nuts::nut01::keys::{Keys, KeysResponse};
@@ -26,11 +29,7 @@ mod ffi {
     pub use crate::nuts::nut08::{MeltRequest, MeltResponse};
     pub use crate::nuts::nut09::{MintInfo, MintVersion};
     pub use crate::types::amount::Amount;
-    pub use crate::types::Bolt11Invoice;
-    pub use crate::types::KeySetInfo;
-    pub use crate::types::Secret;
-
-    pub use cashu::types::InvoiceStatus;
+    pub use crate::types::{Bolt11Invoice, KeySetInfo, Secret};
 
     // UDL
     uniffi::include_scaffolding!("cashu");

+ 4 - 2
bindings/cashu-ffi/src/nuts/nut00/blinded_messages.rs

@@ -1,8 +1,10 @@
-use std::{ops::Deref, sync::Arc};
+use std::ops::Deref;
+use std::sync::Arc;
 
 use cashu::nuts::nut00::wallet::BlindedMessages as BlindedMessagesSdk;
 
-use crate::{error::Result, Amount, BlindedMessage, Secret, SecretKey};
+use crate::error::Result;
+use crate::{Amount, BlindedMessage, Secret, SecretKey};
 
 pub struct BlindedMessages {
     inner: BlindedMessagesSdk,

+ 1 - 3
bindings/cashu-ffi/src/nuts/nut00/blinded_signature.rs

@@ -3,9 +3,7 @@ use std::sync::Arc;
 
 use cashu::nuts::nut00::BlindedSignature as BlindedSignatureSdk;
 
-use crate::Amount;
-use crate::Id;
-use crate::PublicKey;
+use crate::{Amount, Id, PublicKey};
 
 pub struct BlindedSignature {
     inner: BlindedSignatureSdk,

+ 5 - 5
bindings/cashu-ffi/src/nuts/nut00/proof.rs

@@ -1,8 +1,10 @@
-use std::{ops::Deref, sync::Arc};
+use std::ops::Deref;
+use std::sync::Arc;
 
 use cashu::nuts::nut00::Proof as ProofSdk;
 
-use crate::{types::Secret, Amount, Id, PublicKey};
+use crate::types::Secret;
+use crate::{Amount, Id, PublicKey};
 
 pub struct Proof {
     inner: ProofSdk,
@@ -73,9 +75,7 @@ pub mod mint {
     use cashu::nuts::nut00::mint::Proof as ProofSdk;
 
     use crate::types::Secret;
-    use crate::Amount;
-    use crate::Id;
-    use crate::PublicKey;
+    use crate::{Amount, Id, PublicKey};
 
     pub struct Proof {
         inner: ProofSdk,

+ 1 - 2
bindings/cashu-ffi/src/nuts/nut00/token.rs

@@ -5,8 +5,7 @@ use cashu::nuts::nut00::wallet::Token as TokenSdk;
 use cashu::url::UncheckedUrl;
 
 use crate::error::Result;
-use crate::MintProofs;
-use crate::Proof;
+use crate::{MintProofs, Proof};
 
 pub struct Token {
     inner: TokenSdk,

+ 4 - 2
bindings/cashu-ffi/src/nuts/nut01/key_pair.rs

@@ -1,8 +1,10 @@
-use std::{ops::Deref, sync::Arc};
+use std::ops::Deref;
+use std::sync::Arc;
 
-use crate::{PublicKey, SecretKey};
 use cashu::nuts::nut01::mint::KeyPair as KeyPairSdk;
 
+use crate::{PublicKey, SecretKey};
+
 pub struct KeyPair {
     inner: KeyPairSdk,
 }

+ 5 - 2
bindings/cashu-ffi/src/nuts/nut01/keys.rs

@@ -1,9 +1,12 @@
-use std::{collections::HashMap, ops::Deref, sync::Arc};
+use std::collections::HashMap;
+use std::ops::Deref;
+use std::sync::Arc;
 
-use crate::{Amount, PublicKey};
 use cashu::nuts::nut01::{Keys as KeysSdk, Response as KeysResponseSdk};
 use cashu::Amount as AmountSdk;
 
+use crate::{Amount, PublicKey};
+
 pub struct Keys {
     inner: KeysSdk,
 }

+ 1 - 3
bindings/cashu-ffi/src/nuts/nut02/key_set.rs

@@ -1,9 +1,7 @@
 use std::ops::Deref;
 use std::sync::Arc;
 
-use cashu::nuts::nut02::Id as IdSdk;
-use cashu::nuts::nut02::KeySet as KeySetSdk;
-use cashu::nuts::nut02::Response;
+use cashu::nuts::nut02::{Id as IdSdk, KeySet as KeySetSdk, Response};
 
 use crate::error::Result;
 use crate::nuts::nut01::keys::Keys;

+ 2 - 1
bindings/cashu-ffi/src/nuts/nut03/mod.rs

@@ -1,6 +1,7 @@
 use std::str::FromStr;
 
-use cashu::{nuts::nut03::RequestMintResponse as RequestMintResponseSdk, Bolt11Invoice};
+use cashu::nuts::nut03::RequestMintResponse as RequestMintResponseSdk;
+use cashu::Bolt11Invoice;
 
 use crate::error::Result;
 

+ 2 - 1
bindings/cashu-ffi/src/nuts/nut04/mod.rs

@@ -1,4 +1,5 @@
-use std::{ops::Deref, sync::Arc};
+use std::ops::Deref;
+use std::sync::Arc;
 
 use cashu::nuts::nut04::{MintRequest as MintRequestSdk, PostMintResponse as PostMintResponseSdk};
 

+ 10 - 9
bindings/cashu-ffi/src/nuts/nut05/mod.rs

@@ -1,14 +1,15 @@
-use std::{ops::Deref, str::FromStr, sync::Arc};
-
-use cashu::{
-    nuts::nut05::{
-        CheckFeesRequest as CheckFeesRequestSdk, CheckFeesResponse as CheckFeesResponseSdk,
-        MeltRequest as MeltRequestSdk, MeltResponse as MeltResponseSdk,
-    },
-    Bolt11Invoice,
+use std::ops::Deref;
+use std::str::FromStr;
+use std::sync::Arc;
+
+use cashu::nuts::nut05::{
+    CheckFeesRequest as CheckFeesRequestSdk, CheckFeesResponse as CheckFeesResponseSdk,
+    MeltRequest as MeltRequestSdk, MeltResponse as MeltResponseSdk,
 };
+use cashu::Bolt11Invoice;
 
-use crate::{error::Result, Amount, Proof};
+use crate::error::Result;
+use crate::{Amount, Proof};
 
 pub struct CheckFeesRequest {
     inner: CheckFeesRequestSdk,

+ 2 - 1
bindings/cashu-ffi/src/nuts/nut06/mod.rs

@@ -1,4 +1,5 @@
-use std::{ops::Deref, sync::Arc};
+use std::ops::Deref;
+use std::sync::Arc;
 
 use cashu::nuts::nut06::{SplitRequest as SplitRequestSdk, SplitResponse as SplitResponseSdk};
 

+ 2 - 1
bindings/cashu-ffi/src/nuts/nut07/mod.rs

@@ -1,4 +1,5 @@
-use std::{ops::Deref, sync::Arc};
+use std::ops::Deref;
+use std::sync::Arc;
 
 use cashu::nuts::nut07::{
     CheckSpendableRequest as CheckSpendableRequestSdk,

+ 2 - 1
bindings/cashu-ffi/src/nuts/nut09/mod.rs

@@ -1,4 +1,5 @@
-use std::{ops::Deref, sync::Arc};
+use std::ops::Deref;
+use std::sync::Arc;
 
 use cashu::nuts::nut09::{MintInfo as MintInfoSdk, MintVersion as MintVersionSdk};
 

+ 2 - 1
bindings/cashu-ffi/src/types/amount.rs

@@ -1,4 +1,5 @@
-use std::{ops::Deref, sync::Arc};
+use std::ops::Deref;
+use std::sync::Arc;
 
 use cashu::Amount as AmountSdk;
 

+ 5 - 2
bindings/cashu-ffi/src/types/bolt11_invoice.rs

@@ -1,8 +1,11 @@
-use std::{ops::Deref, str::FromStr, sync::Arc};
+use std::ops::Deref;
+use std::str::FromStr;
+use std::sync::Arc;
 
 use cashu::Bolt11Invoice as Bolt11InvoiceSdk;
 
-use crate::{error::Result, Amount};
+use crate::error::Result;
+use crate::Amount;
 
 pub struct Bolt11Invoice {
     inner: Bolt11InvoiceSdk,

+ 2 - 1
bindings/cashu-ffi/src/types/keyset_info.rs

@@ -1,4 +1,5 @@
-use std::{ops::Deref, sync::Arc};
+use std::ops::Deref;
+use std::sync::Arc;
 
 use cashu::types::KeysetInfo as KeySetInfoSdk;
 

+ 1 - 1
bindings/cashu-js/examples/amount.js

@@ -9,4 +9,4 @@ function main() {
   console.log(amount.toSat())
 }
 
-main();
+main();

+ 1 - 1
bindings/cashu-js/justfile

@@ -2,4 +2,4 @@ build:
 	wasm-pack build
 
 pack:
-	npm run package
+	npm run package

+ 2 - 2
bindings/cashu-js/scripts/build.sh

@@ -14,7 +14,7 @@
 
 set -e
 
-cd $(dirname "$0")/..
+cd "$(dirname "$0")"/..
 
 WASM_BINDGEN_WEAKREF=1 wasm-pack build --target nodejs --scope rust-cashu --out-dir pkg "${WASM_PACK_ARGS[@]}"
 
@@ -32,4 +32,4 @@ echo "module.exports = \`$(base64 pkg/cashu_js_bg.wasm)\`;" > pkg/cashu_js_bg.wa
 mv pkg/cashu_js.js.new pkg/cashu_js.js
 
 # also extend the typescript
-cat scripts/epilogue.d.ts >> pkg/cashu_js.d.ts
+cat scripts/epilogue.d.ts >> pkg/cashu_js.d.ts

+ 1 - 1
bindings/cashu-js/scripts/epilogue.d.ts

@@ -7,4 +7,4 @@
  */
  export function loadWasmAsync(): Promise<void>;
 
- export function loadWasmSync(): void;
+ export function loadWasmSync(): void;

+ 1 - 1
bindings/cashu-js/scripts/epilogue.js

@@ -73,4 +73,4 @@ function unbase64(sBase64) {
     }
 
     return taBytes;
-}
+}

+ 1 - 2
bindings/cashu-js/src/nuts/nut00/blinded_messages.rs

@@ -1,8 +1,7 @@
 use std::ops::Deref;
 
-use wasm_bindgen::prelude::*;
-
 use cashu::nuts::nut00::wallet::BlindedMessages;
+use wasm_bindgen::prelude::*;
 
 use crate::error::{into_err, Result};
 use crate::types::JsAmount;

+ 3 - 1
bindings/cashu-js/src/nuts/nut00/blinded_signature.rs

@@ -3,7 +3,9 @@ use std::ops::Deref;
 use cashu::nuts::nut00::BlindedSignature;
 use wasm_bindgen::prelude::*;
 
-use crate::{nuts::nut01::JsPublicKey, nuts::nut02::JsId, types::JsAmount};
+use crate::nuts::nut01::JsPublicKey;
+use crate::nuts::nut02::JsId;
+use crate::types::JsAmount;
 
 #[wasm_bindgen(js_name = BlindedSignature)]
 pub struct JsBlindedSignature {

+ 3 - 1
bindings/cashu-js/src/nuts/nut00/proof.rs

@@ -3,7 +3,9 @@ use std::ops::Deref;
 use cashu::nuts::nut00::Proof;
 use wasm_bindgen::prelude::*;
 
-use crate::{nuts::nut01::JsPublicKey, nuts::nut02::JsId, types::JsAmount, types::JsSecret};
+use crate::nuts::nut01::JsPublicKey;
+use crate::nuts::nut02::JsId;
+use crate::types::{JsAmount, JsSecret};
 
 #[wasm_bindgen(js_name = Proof)]
 pub struct JsProof {

+ 4 - 2
bindings/cashu-js/src/nuts/nut00/token.rs

@@ -1,6 +1,8 @@
-use std::{ops::Deref, str::FromStr};
+use std::ops::Deref;
+use std::str::FromStr;
 
-use cashu::{nuts::nut00::wallet::Token, url::UncheckedUrl};
+use cashu::nuts::nut00::wallet::Token;
+use cashu::url::UncheckedUrl;
 use wasm_bindgen::prelude::*;
 
 use crate::error::{into_err, Result};

+ 2 - 5
bindings/cashu-js/src/nuts/nut01/keys.rs

@@ -3,12 +3,9 @@ use std::ops::Deref;
 use cashu::nuts::nut01::Keys;
 use wasm_bindgen::prelude::*;
 
-use crate::{
-    error::{into_err, Result},
-    types::JsAmount,
-};
-
 use super::JsPublicKey;
+use crate::error::{into_err, Result};
+use crate::types::JsAmount;
 
 #[wasm_bindgen(js_name = Keys)]
 pub struct JsKeys {

+ 2 - 4
bindings/cashu-js/src/nuts/nut02/keyset.rs

@@ -4,10 +4,8 @@ use cashu::nuts::nut01::Response as KeysResponse;
 use cashu::nuts::nut02::{Id, KeySet, Response as KeySetsResponse};
 use wasm_bindgen::prelude::*;
 
-use crate::{
-    error::{into_err, Result},
-    nuts::nut01::JsKeys,
-};
+use crate::error::{into_err, Result};
+use crate::nuts::nut01::JsKeys;
 
 #[wasm_bindgen(js_name = Id)]
 pub struct JsId {

+ 1 - 4
bindings/cashu-js/src/nuts/nut02/mod.rs

@@ -1,8 +1,5 @@
 mod keyset;
 mod mint_keyset;
 
-pub use keyset::JsId;
-pub use keyset::JsKeySet;
-pub use keyset::JsKeySetsResponse;
-pub use keyset::JsKeysResponse;
+pub use keyset::{JsId, JsKeySet, JsKeySetsResponse, JsKeysResponse};
 pub use mint_keyset::JsMintKeySet;

+ 2 - 4
bindings/cashu-js/src/nuts/nut04.rs

@@ -3,10 +3,8 @@ use std::ops::Deref;
 use cashu::nuts::nut04::{MintRequest, PostMintResponse};
 use wasm_bindgen::prelude::*;
 
-use crate::{
-    error::{into_err, Result},
-    types::JsAmount,
-};
+use crate::error::{into_err, Result};
+use crate::types::JsAmount;
 
 #[wasm_bindgen(js_name = MintRequest)]
 pub struct JsMintRequest {

+ 2 - 4
bindings/cashu-js/src/nuts/nut05.rs

@@ -3,10 +3,8 @@ use std::ops::Deref;
 use cashu::nuts::nut05::{CheckFeesRequest, CheckFeesResponse};
 use wasm_bindgen::prelude::*;
 
-use crate::{
-    error::Result,
-    types::{JsAmount, JsBolt11Invoice},
-};
+use crate::error::Result;
+use crate::types::{JsAmount, JsBolt11Invoice};
 
 #[wasm_bindgen(js_name = CheckFeesRequest)]
 pub struct JsCheckFeesRequest {

+ 2 - 4
bindings/cashu-js/src/nuts/nut06.rs

@@ -3,10 +3,8 @@ use std::ops::Deref;
 use cashu::nuts::nut06::{SplitRequest, SplitResponse};
 use wasm_bindgen::prelude::*;
 
-use crate::{
-    error::{into_err, Result},
-    types::JsAmount,
-};
+use crate::error::{into_err, Result};
+use crate::types::JsAmount;
 
 #[wasm_bindgen(js_name = SplitRequest)]
 pub struct JsSplitRequest {

+ 4 - 8
bindings/cashu-js/src/nuts/nut08.rs

@@ -1,15 +1,11 @@
 use std::ops::Deref;
 
-use cashu::nuts::{
-    nut00::{BlindedMessage, BlindedSignature, Proof},
-    nut08::{MeltRequest, MeltResponse},
-};
+use cashu::nuts::nut00::{BlindedMessage, BlindedSignature, Proof};
+use cashu::nuts::nut08::{MeltRequest, MeltResponse};
 use wasm_bindgen::prelude::*;
 
-use crate::{
-    error::{into_err, Result},
-    types::{JsAmount, JsBolt11Invoice},
-};
+use crate::error::{into_err, Result};
+use crate::types::{JsAmount, JsBolt11Invoice};
 
 #[wasm_bindgen(js_name = MeltRequest)]
 pub struct JsMeltRequest {

+ 1 - 2
bindings/cashu-js/src/nuts/nut09.rs

@@ -3,9 +3,8 @@ use std::ops::Deref;
 use cashu::nuts::nut09::{MintInfo, MintVersion};
 use wasm_bindgen::prelude::*;
 
-use crate::error::{into_err, Result};
-
 use super::nut01::JsPublicKey;
+use crate::error::{into_err, Result};
 
 #[wasm_bindgen(js_name = MintVersion)]
 pub struct JsMintVersion {

+ 2 - 1
bindings/cashu-js/src/types/bolt11_invoice.rs

@@ -1,4 +1,5 @@
-use std::{ops::Deref, str::FromStr};
+use std::ops::Deref;
+use std::str::FromStr;
 
 use cashu::Bolt11Invoice;
 use wasm_bindgen::prelude::*;

+ 1 - 1
bindings/cashu-sdk-ffi/src/cashu_sdk.udl

@@ -352,4 +352,4 @@ interface Mint {
 	void verify_melt_request(MeltRequest melt_request);
     [Throws=CashuSdkError]
 	MeltResponse process_melt_request(MeltRequest melt_request, string preimage, Amount totoal_spent);
-};
+};

+ 2 - 4
bindings/cashu-sdk-ffi/src/mint.rs

@@ -1,7 +1,5 @@
-use std::{
-    ops::Deref,
-    sync::{Arc, RwLock},
-};
+use std::ops::Deref;
+use std::sync::{Arc, RwLock};
 
 use cashu_ffi::{
     Amount, CheckSpendableRequest, CheckSpendableResponse, Id, KeySet, KeySetInfo, KeySetResponse,

+ 3 - 3
bindings/cashu-sdk-ffi/src/types/melted.rs

@@ -1,8 +1,8 @@
-use std::{ops::Deref, sync::Arc};
-
-use cashu_sdk::types::Melted as MeltedSdk;
+use std::ops::Deref;
+use std::sync::Arc;
 
 use cashu_ffi::Proof;
+use cashu_sdk::types::Melted as MeltedSdk;
 
 pub struct Melted {
     inner: MeltedSdk,

+ 2 - 1
bindings/cashu-sdk-ffi/src/types/proofs_status.rs

@@ -1,4 +1,5 @@
-use std::{ops::Deref, sync::Arc};
+use std::ops::Deref;
+use std::sync::Arc;
 
 use cashu_sdk::types::ProofsStatus as ProofsStatusSdk;
 

+ 3 - 3
bindings/cashu-sdk-ffi/src/types/send_proofs.rs

@@ -1,8 +1,8 @@
-use std::{ops::Deref, sync::Arc};
-
-use cashu_sdk::types::SendProofs as SendProofsSdk;
+use std::ops::Deref;
+use std::sync::Arc;
 
 use cashu_ffi::Proof;
+use cashu_sdk::types::SendProofs as SendProofsSdk;
 
 pub struct SendProofs {
     inner: SendProofsSdk,

+ 4 - 6
bindings/cashu-sdk-ffi/src/wallet.rs

@@ -7,12 +7,10 @@ use cashu_ffi::{
 use cashu_sdk::types::ProofsStatus;
 use cashu_sdk::wallet::Wallet as WalletSdk;
 
-use crate::{
-    client::Client,
-    error::Result,
-    types::{Melted, SendProofs},
-    Amount, Keys, MintProof,
-};
+use crate::client::Client;
+use crate::error::Result;
+use crate::types::{Melted, SendProofs};
+use crate::{Amount, Keys, MintProof};
 
 pub struct Wallet {
     inner: WalletSdk,

+ 1 - 1
bindings/cashu-sdk-js/examples/amount.js

@@ -9,4 +9,4 @@ function main() {
   console.log(amount.toSat())
 }
 
-main();
+main();

+ 1 - 1
bindings/cashu-sdk-js/examples/wallet.js

@@ -16,4 +16,4 @@ async  function main() {
   console.log(pr);
 }
 
-main();
+main();

+ 1 - 1
bindings/cashu-sdk-js/justfile

@@ -2,4 +2,4 @@ build:
 	wasm-pack build
 
 pack:
-	npm run package
+	npm run package

+ 2 - 2
bindings/cashu-sdk-js/scripts/build.sh

@@ -14,7 +14,7 @@
 
 set -e
 
-cd $(dirname "$0")/..
+cd "$(dirname "$0")"/..
 
 WASM_BINDGEN_WEAKREF=1 wasm-pack build --target nodejs --scope rust-cashu --out-dir pkg "${WASM_PACK_ARGS[@]}"
 
@@ -32,4 +32,4 @@ echo "module.exports = \`$(base64 pkg/cashu_sdk_js_bg.wasm)\`;" > pkg/cashu_sdk_
 mv pkg/cashu_sdk_js.js.new pkg/cashu_sdk_js.js
 
 # also extend the typescript
-cat scripts/epilogue.d.ts >> pkg/cashu_sdk_js.d.ts
+cat scripts/epilogue.d.ts >> pkg/cashu_sdk_js.d.ts

+ 1 - 1
bindings/cashu-sdk-js/scripts/epilogue.d.ts

@@ -7,4 +7,4 @@
  */
  export function loadWasmAsync(): Promise<void>;
 
- export function loadWasmSync(): void;
+ export function loadWasmSync(): void;

+ 1 - 1
bindings/cashu-sdk-js/scripts/epilogue.js

@@ -73,4 +73,4 @@ function unbase64(sBase64) {
     }
 
     return taBytes;
-}
+}

+ 9 - 11
bindings/cashu-sdk-js/src/mint.rs

@@ -1,16 +1,14 @@
 use std::ops::Deref;
 
-use cashu_js::{
-    nuts::{
-        nut02::{JsId, JsKeySet, JsKeySetsResponse, JsKeysResponse, JsMintKeySet},
-        nut04::{JsMintRequest, JsPostMintResponse},
-        nut06::{JsSplitRequest, JsSplitResponse},
-        nut07::{JsCheckSpendableRequest, JsCheckSpendableResponse},
-        nut08::{JsMeltRequest, JsMeltResponse},
-    },
-    JsAmount,
-};
-use cashu_sdk::{mint::Mint, nuts::nut01, nuts::nut02::KeySet};
+use cashu_js::nuts::nut02::{JsId, JsKeySet, JsKeySetsResponse, JsKeysResponse, JsMintKeySet};
+use cashu_js::nuts::nut04::{JsMintRequest, JsPostMintResponse};
+use cashu_js::nuts::nut06::{JsSplitRequest, JsSplitResponse};
+use cashu_js::nuts::nut07::{JsCheckSpendableRequest, JsCheckSpendableResponse};
+use cashu_js::nuts::nut08::{JsMeltRequest, JsMeltResponse};
+use cashu_js::JsAmount;
+use cashu_sdk::mint::Mint;
+use cashu_sdk::nuts::nut01;
+use cashu_sdk::nuts::nut02::KeySet;
 use wasm_bindgen::prelude::*;
 
 use crate::error::{into_err, Result};

+ 4 - 6
bindings/cashu-sdk-js/src/wallet.rs

@@ -1,17 +1,15 @@
 use std::ops::Deref;
 
 use cashu_js::nuts::nut00::{JsBlindedMessages, JsToken};
+use cashu_js::nuts::nut01::JsKeys;
 use cashu_js::nuts::nut03::JsRequestMintResponse;
-use cashu_js::{nuts::nut01::JsKeys, JsAmount};
-use cashu_js::{JsBolt11Invoice, JsProofsStatus};
+use cashu_js::{JsAmount, JsBolt11Invoice, JsProofsStatus};
 use cashu_sdk::wallet::Wallet;
 use wasm_bindgen::prelude::*;
 
+use crate::error::{into_err, Result};
 use crate::types::{JsMelted, JsSendProofs};
-use crate::{
-    error::{into_err, Result},
-    JsClient,
-};
+use crate::JsClient;
 
 #[wasm_bindgen(js_name = Wallet)]
 pub struct JsWallet {

+ 1 - 1
bindings/uniffi-bindgen/Cargo.toml

@@ -9,4 +9,4 @@ rust-version.workspace = true
 uniffi = { workspace = true, features = ["cli"] }
 
 [build-dependencies]
-uniffi = { workspace = true, features = ["build"] }
+uniffi = { workspace = true, features = ["build"] }

+ 13 - 17
crates/cashu-sdk/src/client/blocking.rs

@@ -1,22 +1,18 @@
-use crate::RUNTIME;
-
-use cashu::{
-    nuts::{
-        nut00::{self, wallet::BlindedMessages, BlindedMessage, Proof},
-        nut01::Keys,
-        nut02,
-        nut03::RequestMintResponse,
-        nut04::PostMintResponse,
-        nut05::CheckFeesResponse,
-        nut06::{SplitRequest, SplitResponse},
-        nut07::CheckSpendableResponse,
-        nut08::MeltResponse,
-        nut09::MintInfo,
-    },
-    Amount, Bolt11Invoice,
-};
+use cashu::nuts::nut00::wallet::BlindedMessages;
+use cashu::nuts::nut00::{self, BlindedMessage, Proof};
+use cashu::nuts::nut01::Keys;
+use cashu::nuts::nut02;
+use cashu::nuts::nut03::RequestMintResponse;
+use cashu::nuts::nut04::PostMintResponse;
+use cashu::nuts::nut05::CheckFeesResponse;
+use cashu::nuts::nut06::{SplitRequest, SplitResponse};
+use cashu::nuts::nut07::CheckSpendableResponse;
+use cashu::nuts::nut08::MeltResponse;
+use cashu::nuts::nut09::MintInfo;
+use cashu::{Amount, Bolt11Invoice};
 
 use super::Error;
+use crate::RUNTIME;
 
 #[derive(Debug, Clone)]
 pub struct Client {

+ 7 - 9
crates/cashu-sdk/src/client/mod.rs

@@ -2,12 +2,8 @@
 use std::fmt;
 use std::str::FromStr;
 
-use cashu::url::UncheckedUrl;
-use serde::{Deserialize, Serialize};
-use serde_json::Value;
-use url::Url;
-
-use cashu::nuts::nut00::{wallet::BlindedMessages, BlindedMessage, Proof};
+use cashu::nuts::nut00::wallet::BlindedMessages;
+use cashu::nuts::nut00::{BlindedMessage, Proof};
 use cashu::nuts::nut01::Keys;
 use cashu::nuts::nut03::RequestMintResponse;
 use cashu::nuts::nut04::{MintRequest, PostMintResponse};
@@ -17,11 +13,13 @@ use cashu::nuts::nut07::{CheckSpendableRequest, CheckSpendableResponse};
 use cashu::nuts::nut08::{MeltRequest, MeltResponse};
 use cashu::nuts::nut09::MintInfo;
 use cashu::nuts::*;
-use cashu::utils;
-use cashu::Amount;
-
+use cashu::url::UncheckedUrl;
+use cashu::{utils, Amount};
 #[cfg(target_arch = "wasm32")]
 use gloo::net::http::Request;
+use serde::{Deserialize, Serialize};
+use serde_json::Value;
+use url::Url;
 
 #[cfg(feature = "blocking")]
 pub mod blocking;

+ 2 - 4
crates/cashu-sdk/src/lib.rs

@@ -2,14 +2,12 @@
 compile_error!("`blocking` feature can't be enabled for WASM targets");
 
 #[cfg(feature = "blocking")]
+use futures_util::Future;
+#[cfg(feature = "blocking")]
 use once_cell::sync::Lazy;
-
 #[cfg(feature = "blocking")]
 use tokio::runtime::Runtime;
 
-#[cfg(feature = "blocking")]
-use futures_util::Future;
-
 #[cfg(feature = "wallet")]
 pub mod client;
 

+ 5 - 12
crates/cashu-sdk/src/mint.rs

@@ -1,20 +1,13 @@
 use std::collections::{HashMap, HashSet};
 
+use cashu::dhke::{sign_message, verify_message};
 pub use cashu::error::mint::Error;
-
-use cashu::dhke::sign_message;
-use cashu::dhke::verify_message;
-use cashu::nuts::nut00::BlindedMessage;
-use cashu::nuts::nut00::BlindedSignature;
-use cashu::nuts::nut00::Proof;
+use cashu::nuts::nut00::{BlindedMessage, BlindedSignature, Proof};
 use cashu::nuts::nut02::mint::KeySet;
 use cashu::nuts::nut02::Id;
-use cashu::nuts::nut06::SplitRequest;
-use cashu::nuts::nut06::SplitResponse;
-use cashu::nuts::nut07::CheckSpendableRequest;
-use cashu::nuts::nut07::CheckSpendableResponse;
-use cashu::nuts::nut08::MeltRequest;
-use cashu::nuts::nut08::MeltResponse;
+use cashu::nuts::nut06::{SplitRequest, SplitResponse};
+use cashu::nuts::nut07::{CheckSpendableRequest, CheckSpendableResponse};
+use cashu::nuts::nut08::{MeltRequest, MeltResponse};
 use cashu::nuts::*;
 use cashu::secret::Secret;
 use cashu::types::KeysetInfo;

+ 3 - 6
crates/cashu-sdk/src/wallet.rs

@@ -3,11 +3,9 @@ use std::error::Error as StdError;
 use std::fmt;
 use std::str::FromStr;
 
-use cashu::dhke::construct_proofs;
-use cashu::dhke::unblind_message;
-use cashu::nuts::nut00::{
-    mint, wallet::BlindedMessages, wallet::Token, BlindedSignature, Proof, Proofs,
-};
+use cashu::dhke::{construct_proofs, unblind_message};
+use cashu::nuts::nut00::wallet::{BlindedMessages, Token};
+use cashu::nuts::nut00::{mint, BlindedSignature, Proof, Proofs};
 use cashu::nuts::nut01::Keys;
 use cashu::nuts::nut03::RequestMintResponse;
 use cashu::nuts::nut06::{SplitPayload, SplitRequest};
@@ -18,7 +16,6 @@ use tracing::warn;
 
 #[cfg(feature = "blocking")]
 use crate::client::blocking::Client;
-
 #[cfg(not(feature = "blocking"))]
 use crate::client::Client;
 

+ 2 - 9
crates/cashu/src/dhke.rs

@@ -2,25 +2,19 @@
 
 use std::ops::Mul;
 
-use bitcoin::hashes::sha256;
-use bitcoin::hashes::Hash;
-
+use bitcoin::hashes::{sha256, Hash};
 #[cfg(feature = "wallet")]
 use k256::ProjectivePoint;
-
 use k256::{Scalar, SecretKey};
 
 use crate::error;
-use crate::secret::Secret;
-
 #[cfg(feature = "wallet")]
 use crate::nuts::nut00::{BlindedSignature, Proof, Proofs};
-
 #[cfg(feature = "wallet")]
 use crate::nuts::nut01::{Keys, PublicKey};
-
 #[cfg(feature = "wallet")]
 use crate::nuts::*;
+use crate::secret::Secret;
 
 fn hash_to_curve(message: &[u8]) -> k256::PublicKey {
     let mut msg_to_hash = message.to_vec();
@@ -145,7 +139,6 @@ pub fn verify_message(
 #[cfg(test)]
 mod tests {
     use hex::decode;
-
     use k256::elliptic_curve::scalar::ScalarPrimitive;
 
     use super::*;

+ 14 - 14
crates/cashu/src/nuts/nut00.rs

@@ -1,11 +1,13 @@
 //! Notation and Models
 // https://github.com/cashubtc/nuts/blob/main/00.md
 
-use crate::{secret::Secret, url::UncheckedUrl, Amount};
 use serde::{Deserialize, Serialize};
 
 use super::nut01::PublicKey;
 use super::nut02::Id;
+use crate::secret::Secret;
+use crate::url::UncheckedUrl;
+use crate::Amount;
 
 /// Blinded Message [NUT-00]
 #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
@@ -21,21 +23,20 @@ pub struct BlindedMessage {
 pub mod wallet {
     use std::str::FromStr;
 
-    use base64::{engine::general_purpose, Engine as _};
+    use base64::engine::general_purpose;
+    use base64::Engine as _;
     use serde::{Deserialize, Serialize};
     use url::Url;
 
-    use crate::error;
+    use super::MintProofs;
+    use crate::dhke::blind_message;
     use crate::error::wallet;
-    use crate::nuts::nut00::BlindedMessage;
-    use crate::nuts::nut00::Proofs;
+    use crate::nuts::nut00::{BlindedMessage, Proofs};
     use crate::nuts::nut01;
     use crate::secret::Secret;
     use crate::url::UncheckedUrl;
-    use crate::Amount;
-    use crate::{dhke::blind_message, utils::split_amount};
-
-    use super::MintProofs;
+    use crate::utils::split_amount;
+    use crate::{error, Amount};
 
     /// Blinded Messages [NUT-00]
     #[derive(Debug, Default, Clone, PartialEq, Eq, Serialize)]
@@ -221,9 +222,10 @@ impl From<Proof> for mint::Proof {
 pub mod mint {
     use serde::{Deserialize, Serialize};
 
-    use crate::{nuts::nut02::Id, secret::Secret, Amount};
-
     use super::PublicKey;
+    use crate::nuts::nut02::Id;
+    use crate::secret::Secret;
+    use crate::Amount;
 
     /// Proofs [NUT-00]
     #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
@@ -273,9 +275,7 @@ mod tests {
 
         assert_eq!(
             token.token[0].mint,
-            UncheckedUrl::from_str("https://8333.space:3338")
-                .unwrap()
-                .into()
+            UncheckedUrl::from_str("https://8333.space:3338").unwrap()
         );
         assert_eq!(
             token.token[0].proofs[0].clone().id.unwrap(),

+ 4 - 6
crates/cashu/src/nuts/nut01.rs

@@ -1,8 +1,7 @@
 //! Mint public key exchange
 // https://github.com/cashubtc/nuts/blob/main/01.md
 
-use std::collections::BTreeMap;
-use std::collections::HashMap;
+use std::collections::{BTreeMap, HashMap};
 
 use serde::{Deserialize, Serialize};
 
@@ -156,7 +155,8 @@ impl<'de> serde::de::Deserialize<'de> for Response {
 
                         keys.insert(amount, pubkey);
                     }
-                    // TODO: Should return an error if an amount or key is invalid and not continue
+                    // TODO: Should return an error if an amount or key is
+                    // invalid and not continue
                 }
 
                 Ok(Response { keys: Keys(keys) })
@@ -172,11 +172,9 @@ pub mod mint {
 
     use serde::Serialize;
 
+    use super::{PublicKey, SecretKey};
     use crate::Amount;
 
-    use super::PublicKey;
-    use super::SecretKey;
-
     #[derive(Debug, Clone, PartialEq, Eq, Serialize)]
     pub struct Keys(pub BTreeMap<Amount, KeyPair>);
 

+ 7 - 12
crates/cashu/src/nuts/nut02.rs

@@ -4,9 +4,9 @@
 use std::collections::HashSet;
 use std::fmt;
 
-use base64::{engine::general_purpose, Engine as _};
-use bitcoin::hashes::sha256;
-use bitcoin::hashes::Hash;
+use base64::engine::general_purpose;
+use base64::Engine as _;
+use bitcoin::hashes::{sha256, Hash};
 use itertools::Itertools;
 use serde::{Deserialize, Serialize};
 
@@ -41,10 +41,8 @@ impl Id {
     const STRLEN: usize = 12;
 
     pub fn try_from_base64(b64: &str) -> Result<Self, Error> {
-        use base64::{
-            engine::general_purpose::{STANDARD, URL_SAFE},
-            Engine as _,
-        };
+        use base64::engine::general_purpose::{STANDARD, URL_SAFE};
+        use base64::Engine as _;
 
         if b64.len() != Self::STRLEN {
             return Err(Error::Length);
@@ -174,14 +172,12 @@ pub mod mint {
     use std::collections::BTreeMap;
 
     use bitcoin::hashes::sha256::Hash as Sha256;
-    use bitcoin::hashes::Hash;
-    use bitcoin::hashes::HashEngine;
+    use bitcoin::hashes::{Hash, HashEngine};
     use itertools::Itertools;
     use k256::SecretKey;
     use serde::Serialize;
 
     use super::Id;
-
     use crate::nuts::nut01::mint::{KeyPair, Keys};
     use crate::Amount;
 
@@ -268,9 +264,8 @@ pub mod mint {
 #[cfg(test)]
 mod test {
 
-    use crate::nuts::nut02::Id;
-
     use super::Keys;
+    use crate::nuts::nut02::Id;
 
     const SHORT_KEYSET_ID: &str = "esom3oyNLLit";
     const SHORT_KEYSET: &str = r#"

+ 1 - 2
crates/cashu/src/nuts/nut05.rs

@@ -5,8 +5,7 @@ use serde::{Deserialize, Serialize};
 
 use super::nut00::Proofs;
 use crate::error::Error;
-use crate::Amount;
-use crate::Bolt11Invoice;
+use crate::{Amount, Bolt11Invoice};
 
 /// Check Fees Response [NUT-05]
 #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]

+ 3 - 5
crates/cashu/src/nuts/nut06.rs

@@ -2,13 +2,11 @@
 // https://github.com/cashubtc/nuts/blob/main/06.md
 use serde::{Deserialize, Serialize};
 
-use crate::nuts::nut00::{BlindedMessage, Proofs};
-use crate::Amount;
-
+use super::nut00::BlindedSignature;
 #[cfg(feature = "wallet")]
 use crate::nuts::nut00::wallet::BlindedMessages;
-
-use super::nut00::BlindedSignature;
+use crate::nuts::nut00::{BlindedMessage, Proofs};
+use crate::Amount;
 
 #[cfg(feature = "wallet")]
 #[derive(Debug, Clone, PartialEq, Eq, Serialize)]

+ 2 - 2
crates/cashu/src/nuts/nut08.rs

@@ -4,9 +4,9 @@
 use lightning_invoice::Bolt11Invoice;
 use serde::{Deserialize, Serialize};
 
-use crate::{error::Error, Amount};
-
 use super::nut00::{BlindedMessage, BlindedSignature, Proofs};
+use crate::error::Error;
+use crate::Amount;
 
 /// Melt Request [NUT-08]
 #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]

+ 2 - 1
crates/cashu/src/secret.rs

@@ -26,7 +26,8 @@ impl Secret {
     const BIT_LENGTH: usize = 128;
     /// Create secret value
     pub fn new() -> Self {
-        use base64::{engine::general_purpose::URL_SAFE, Engine as _};
+        use base64::engine::general_purpose::URL_SAFE;
+        use base64::Engine as _;
         use rand::RngCore;
 
         let mut rng = rand::thread_rng();

+ 2 - 1
crates/cashu/src/serde_utils.rs

@@ -21,7 +21,8 @@ pub mod serde_url {
 }
 
 pub mod bytes_base64 {
-    use base64::{engine::general_purpose, Engine as _};
+    use base64::engine::general_purpose;
+    use base64::Engine as _;
     use serde::Deserialize;
 
     pub fn serialize<S>(my_bytes: &Vec<u8>, serializer: S) -> Result<S::Ok, S::Error>

+ 2 - 4
crates/cashu/src/types.rs

@@ -2,10 +2,8 @@
 
 use serde::{Deserialize, Serialize};
 
-use crate::nuts::{
-    nut00::{mint, Proofs},
-    nut02::Id,
-};
+use crate::nuts::nut00::{mint, Proofs};
+use crate::nuts::nut02::Id;
 
 #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
 pub struct ProofsStatus {

+ 3 - 1
crates/cashu/src/url.rs

@@ -5,6 +5,7 @@
 
 use core::fmt;
 use core::str::FromStr;
+
 use serde::{Deserialize, Serialize};
 use url::{ParseError, Url};
 
@@ -115,6 +116,7 @@ mod tests {
 
         assert_eq!(relay, unchecked_relay_url.to_string());
 
-        // assert_eq!(relay, serde_json::to_string(&unchecked_relay_url).unwrap())
+        // assert_eq!(relay,
+        // serde_json::to_string(&unchecked_relay_url).unwrap())
     }
 }

+ 2 - 2
crates/cashu/src/utils.rs

@@ -48,9 +48,9 @@ mod tests {
             split_amount(Amount::from_sat(3)),
             vec![Amount::from_sat(1), Amount::from_sat(2)]
         );
-        let amounts: Vec<Amount> = vec![1, 2, 8].iter().map(|a| Amount::from_sat(*a)).collect();
+        let amounts: Vec<Amount> = [1, 2, 8].iter().map(|a| Amount::from_sat(*a)).collect();
         assert_eq!(split_amount(Amount::from_sat(11)), amounts);
-        let amounts: Vec<Amount> = vec![1, 2, 4, 8, 16, 32, 64, 128]
+        let amounts: Vec<Amount> = [1, 2, 4, 8, 16, 32, 64, 128]
             .iter()
             .map(|a| Amount::from_sat(*a))
             .collect();

+ 375 - 0
flake.lock

@@ -0,0 +1,375 @@
+{
+  "nodes": {
+    "android-nixpkgs": {
+      "inputs": {
+        "devshell": "devshell",
+        "flake-utils": "flake-utils_2",
+        "nixpkgs": [
+          "flakebox",
+          "nixpkgs"
+        ]
+      },
+      "locked": {
+        "lastModified": 1695500413,
+        "narHash": "sha256-yinrAWIc4XZbWQoXOYkUO0lCNQ5z/vMyl+QCYuIwdPc=",
+        "owner": "dpc",
+        "repo": "android-nixpkgs",
+        "rev": "2e42268a196375ce9b010a10ec5250d2f91a09b4",
+        "type": "github"
+      },
+      "original": {
+        "owner": "dpc",
+        "repo": "android-nixpkgs",
+        "rev": "2e42268a196375ce9b010a10ec5250d2f91a09b4",
+        "type": "github"
+      }
+    },
+    "crane": {
+      "inputs": {
+        "flake-compat": "flake-compat",
+        "flake-utils": "flake-utils_3",
+        "nixpkgs": [
+          "flakebox",
+          "nixpkgs"
+        ],
+        "rust-overlay": "rust-overlay"
+      },
+      "locked": {
+        "lastModified": 1697596235,
+        "narHash": "sha256-4VTrrTdoA1u1wyf15krZCFl3c29YLesSNioYEgfb2FY=",
+        "owner": "dpc",
+        "repo": "crane",
+        "rev": "c97a0c0d83bfdf01c29113c5592a3defc27cb315",
+        "type": "github"
+      },
+      "original": {
+        "owner": "dpc",
+        "repo": "crane",
+        "rev": "c97a0c0d83bfdf01c29113c5592a3defc27cb315",
+        "type": "github"
+      }
+    },
+    "devshell": {
+      "inputs": {
+        "nixpkgs": [
+          "flakebox",
+          "android-nixpkgs",
+          "nixpkgs"
+        ],
+        "systems": "systems_2"
+      },
+      "locked": {
+        "lastModified": 1695195896,
+        "narHash": "sha256-pq9q7YsGXnQzJFkR5284TmxrLNFc0wo4NQ/a5E93CQU=",
+        "owner": "numtide",
+        "repo": "devshell",
+        "rev": "05d40d17bf3459606316e3e9ec683b784ff28f16",
+        "type": "github"
+      },
+      "original": {
+        "owner": "numtide",
+        "repo": "devshell",
+        "type": "github"
+      }
+    },
+    "fenix": {
+      "inputs": {
+        "nixpkgs": [
+          "flakebox",
+          "nixpkgs"
+        ],
+        "rust-analyzer-src": "rust-analyzer-src"
+      },
+      "locked": {
+        "lastModified": 1696918968,
+        "narHash": "sha256-18rAHsM9YsGp7aKKemO4gKIeWfrSyDsdJZ/mk4dQ3JI=",
+        "owner": "nix-community",
+        "repo": "fenix",
+        "rev": "638fc95a2a3d01b372c76f71cbb6d73c63909d6e",
+        "type": "github"
+      },
+      "original": {
+        "owner": "nix-community",
+        "repo": "fenix",
+        "type": "github"
+      }
+    },
+    "flake-compat": {
+      "flake": false,
+      "locked": {
+        "lastModified": 1673956053,
+        "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
+        "owner": "edolstra",
+        "repo": "flake-compat",
+        "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
+        "type": "github"
+      },
+      "original": {
+        "owner": "edolstra",
+        "repo": "flake-compat",
+        "type": "github"
+      }
+    },
+    "flake-utils": {
+      "inputs": {
+        "systems": "systems"
+      },
+      "locked": {
+        "lastModified": 1694529238,
+        "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
+        "owner": "numtide",
+        "repo": "flake-utils",
+        "rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
+        "type": "github"
+      },
+      "original": {
+        "owner": "numtide",
+        "repo": "flake-utils",
+        "type": "github"
+      }
+    },
+    "flake-utils_2": {
+      "inputs": {
+        "systems": "systems_3"
+      },
+      "locked": {
+        "lastModified": 1694529238,
+        "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
+        "owner": "numtide",
+        "repo": "flake-utils",
+        "rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
+        "type": "github"
+      },
+      "original": {
+        "owner": "numtide",
+        "repo": "flake-utils",
+        "type": "github"
+      }
+    },
+    "flake-utils_3": {
+      "inputs": {
+        "systems": "systems_4"
+      },
+      "locked": {
+        "lastModified": 1694529238,
+        "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
+        "owner": "numtide",
+        "repo": "flake-utils",
+        "rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
+        "type": "github"
+      },
+      "original": {
+        "owner": "numtide",
+        "repo": "flake-utils",
+        "type": "github"
+      }
+    },
+    "flake-utils_4": {
+      "inputs": {
+        "systems": [
+          "flakebox",
+          "systems"
+        ]
+      },
+      "locked": {
+        "lastModified": 1694529238,
+        "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
+        "owner": "numtide",
+        "repo": "flake-utils",
+        "rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
+        "type": "github"
+      },
+      "original": {
+        "owner": "numtide",
+        "repo": "flake-utils",
+        "type": "github"
+      }
+    },
+    "flakebox": {
+      "inputs": {
+        "android-nixpkgs": "android-nixpkgs",
+        "crane": "crane",
+        "fenix": "fenix",
+        "flake-utils": "flake-utils_4",
+        "nixpkgs": [
+          "nixpkgs"
+        ],
+        "nixpkgs-unstable": "nixpkgs-unstable",
+        "systems": "systems_5"
+      },
+      "locked": {
+        "lastModified": 1697876216,
+        "narHash": "sha256-Sxf43+wj7bW11yNMstEzn6mbI/Pk9fMSYWFF+swQV5s=",
+        "owner": "rustshop",
+        "repo": "flakebox",
+        "rev": "be3482250c7e7427e86aa8c2523df2cbc478ae5f",
+        "type": "github"
+      },
+      "original": {
+        "owner": "rustshop",
+        "repo": "flakebox",
+        "type": "github"
+      }
+    },
+    "nixpkgs": {
+      "locked": {
+        "lastModified": 1697777081,
+        "narHash": "sha256-n2vQARhKevRGyeo+LAa8g+CdUQsdH/caNk8jnylcPhY=",
+        "owner": "NixOS",
+        "repo": "nixpkgs",
+        "rev": "679cadfdfed2b90311a247b2d6ef6dfd3d6cab73",
+        "type": "github"
+      },
+      "original": {
+        "owner": "NixOS",
+        "ref": "nixos-23.05",
+        "repo": "nixpkgs",
+        "type": "github"
+      }
+    },
+    "nixpkgs-unstable": {
+      "locked": {
+        "lastModified": 1697456312,
+        "narHash": "sha256-roiSnrqb5r+ehnKCauPLugoU8S36KgmWraHgRqVYndo=",
+        "owner": "nixos",
+        "repo": "nixpkgs",
+        "rev": "ca012a02bf8327be9e488546faecae5e05d7d749",
+        "type": "github"
+      },
+      "original": {
+        "owner": "nixos",
+        "ref": "nixos-unstable",
+        "repo": "nixpkgs",
+        "type": "github"
+      }
+    },
+    "root": {
+      "inputs": {
+        "flake-utils": "flake-utils",
+        "flakebox": "flakebox",
+        "nixpkgs": "nixpkgs"
+      }
+    },
+    "rust-analyzer-src": {
+      "flake": false,
+      "locked": {
+        "lastModified": 1696840854,
+        "narHash": "sha256-wphOvjDSDsUN5DMe3MOhdargANIab7YE3hkh3Qv7qso=",
+        "owner": "rust-lang",
+        "repo": "rust-analyzer",
+        "rev": "aaa1e8e1b82d742b876d164a30dda02f318ce809",
+        "type": "github"
+      },
+      "original": {
+        "owner": "rust-lang",
+        "ref": "nightly",
+        "repo": "rust-analyzer",
+        "type": "github"
+      }
+    },
+    "rust-overlay": {
+      "inputs": {
+        "flake-utils": [
+          "flakebox",
+          "crane",
+          "flake-utils"
+        ],
+        "nixpkgs": [
+          "flakebox",
+          "crane",
+          "nixpkgs"
+        ]
+      },
+      "locked": {
+        "lastModified": 1695003086,
+        "narHash": "sha256-d1/ZKuBRpxifmUf7FaedCqhy0lyVbqj44Oc2s+P5bdA=",
+        "owner": "oxalica",
+        "repo": "rust-overlay",
+        "rev": "b87a14abea512d956f0b89d0d8a1e9b41f3e20ff",
+        "type": "github"
+      },
+      "original": {
+        "owner": "oxalica",
+        "repo": "rust-overlay",
+        "type": "github"
+      }
+    },
+    "systems": {
+      "locked": {
+        "lastModified": 1681028828,
+        "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
+        "owner": "nix-systems",
+        "repo": "default",
+        "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
+        "type": "github"
+      },
+      "original": {
+        "owner": "nix-systems",
+        "repo": "default",
+        "type": "github"
+      }
+    },
+    "systems_2": {
+      "locked": {
+        "lastModified": 1681028828,
+        "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
+        "owner": "nix-systems",
+        "repo": "default",
+        "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
+        "type": "github"
+      },
+      "original": {
+        "owner": "nix-systems",
+        "repo": "default",
+        "type": "github"
+      }
+    },
+    "systems_3": {
+      "locked": {
+        "lastModified": 1681028828,
+        "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
+        "owner": "nix-systems",
+        "repo": "default",
+        "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
+        "type": "github"
+      },
+      "original": {
+        "owner": "nix-systems",
+        "repo": "default",
+        "type": "github"
+      }
+    },
+    "systems_4": {
+      "locked": {
+        "lastModified": 1681028828,
+        "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
+        "owner": "nix-systems",
+        "repo": "default",
+        "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
+        "type": "github"
+      },
+      "original": {
+        "owner": "nix-systems",
+        "repo": "default",
+        "type": "github"
+      }
+    },
+    "systems_5": {
+      "locked": {
+        "lastModified": 1681028828,
+        "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
+        "owner": "nix-systems",
+        "repo": "default",
+        "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
+        "type": "github"
+      },
+      "original": {
+        "owner": "nix-systems",
+        "repo": "default",
+        "type": "github"
+      }
+    }
+  },
+  "root": "root",
+  "version": 7
+}

+ 25 - 0
flake.nix

@@ -0,0 +1,25 @@
+{
+  description = "A very basic flake";
+
+  inputs = {
+    nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
+
+    flakebox = {
+      url = "github:rustshop/flakebox";
+      inputs.nixpkgs.follows = "nixpkgs";
+    };
+
+    flake-utils.url = "github:numtide/flake-utils";
+  };
+
+  outputs = { self, nixpkgs, flakebox, flake-utils }:
+    flake-utils.lib.eachDefaultSystem (system:
+      let
+        flakeboxLib = flakebox.lib.${system} { };
+      in
+      {
+        devShells = flakeboxLib.mkShells {
+          packages = [ ];
+        };
+      });
+}

+ 87 - 20
justfile

@@ -1,20 +1,87 @@
-precommit:
-	rustup default stable
-	cargo fmt
-	cargo check -p cashu
-	cargo check -p cashu-sdk --no-default-features --features mint
-	cargo check -p cashu-sdk --no-default-features --features wallet
-	cargo check -p cashu-sdk --no-default-features --features blocking
-	typos
-	cargo test -p cashu
-	cargo test -p cashu-sdk
-	cargo clippy --target wasm32-unknown-unknown -p cashu
-	cargo clippy --target wasm32-unknown-unknown -p cashu-sdk
-	rustup default 1.70.0
-	cargo check -p cashu
-	cargo check -p cashu-sdk --no-default-features --features mint
-	cargo check -p cashu-sdk --no-default-features --features wallet
-	cargo check -p cashu-sdk --no-default-features --features blocking
-	cargo test -p cashu
-	cargo test -p cashu-sdk
-	rustup default stable
+# THIS FILE IS AUTOGENERATED FROM FLAKEBOX CONFIGURATION
+
+alias b := build
+alias c := check
+alias t := test
+
+
+[private]
+default:
+  @just --list
+
+
+# run `cargo build` on everything
+build:
+  cargo build --workspace --all-targets
+
+
+# run `cargo check` on everything
+check:
+  cargo check --workspace --all-targets
+
+
+# run all checks recommended before opening a PR
+final-check: lint clippy
+  cargo test --doc
+  just test
+
+
+# run code formatters
+format:
+  cargo fmt --all
+  nixpkgs-fmt $(echo **.nix)
+
+
+# run lints (git pre-commit hook)
+lint:
+  env NO_STASH=true $(git rev-parse --git-common-dir)/hooks/pre-commit
+
+
+# run tests
+test: build
+  cargo test
+
+
+# run and restart on changes
+watch:
+  env RUST_LOG=${RUST_LOG:-debug} cargo watch -x run
+
+
+# run `cargo clippy` on everything
+clippy:
+  cargo clippy --locked --offline --workspace --all-targets -- --deny warnings --allow deprecated
+
+# run `cargo clippy --fix` on everything
+clippy-fix:
+  cargo clippy --locked --offline --workspace --all-targets --fix
+
+
+# run `semgrep`
+semgrep:
+  env SEMGREP_ENABLE_VERSION_CHECK=0 \
+    semgrep --error --no-rewrite-rule-ids --config .config/semgrep.yaml
+
+
+# check typos
+[no-exit-message]
+typos *PARAMS:
+  #!/usr/bin/env bash
+  set -eo pipefail
+
+  export FLAKEBOX_GIT_LS
+  FLAKEBOX_GIT_LS="$(git ls-files)"
+  export FLAKEBOX_GIT_LS_TEXT
+  FLAKEBOX_GIT_LS_TEXT="$(echo "$FLAKEBOX_GIT_LS" | grep -v -E "^db/|\.(png|ods|jpg|jpeg|woff2|keystore|wasm|ttf|jar|ico)\$")"
+
+
+  if ! echo "$FLAKEBOX_GIT_LS_TEXT" | typos {{PARAMS}} --file-list - --force-exclude ; then
+    >&2 echo "Typos found: Valid new words can be added to '.typos.toml'"
+    return 1
+  fi
+
+# fix all typos
+[no-exit-message]
+typos-fix-all:
+  just typos -w
+
+# THIS FILE IS AUTOGENERATED FROM FLAKEBOX CONFIGURATION

+ 23 - 0
misc/git-hooks/commit-msg

@@ -0,0 +1,23 @@
+#!/usr/bin/env bash
+# Sanitize file first, by removing leading lines that are empty or start with a hash,
+# as `convco` currently does not do it automatically (but git will)
+# TODO: next release of convco should be able to do it automatically
+MESSAGE="$(
+  while read -r line ; do
+    # skip any initial comments (possibly from previous run)
+    if [ -z "${body_detected:-}" ] && { [[ "$line" =~ ^#.*$ ]] || [ "$line" == "" ]; }; then
+      continue
+    fi
+    body_detected="true"
+
+    echo "$line"
+  done < "$1"
+)"
+
+# convco fails on fixup!, so remove fixup! prefix
+MESSAGE="${MESSAGE#fixup! }"
+if ! convco check --from-stdin <<<"$MESSAGE" ; then
+   >&2 echo "Please follow conventional commits(https://www.conventionalcommits.org)"
+   >&2 echo "Use git recommit <args> to fix your commit"
+  exit 1
+fi

+ 2 - 0
misc/git-hooks/commit-template.txt

@@ -0,0 +1,2 @@
+
+# Explain *why* this change is being made                width limit ->|

+ 165 - 0
misc/git-hooks/pre-commit

@@ -0,0 +1,165 @@
+#!/usr/bin/env bash
+
+set -euo pipefail
+
+set +e
+git diff-files --quiet
+is_unclean=$?
+set -e
+
+# Revert `git stash` on exit
+function revert_git_stash {
+  >&2 echo "Unstashing uncommitted changes..."
+  git stash pop -q
+}
+
+# Stash pending changes and revert them when script ends
+if [ -z "${NO_STASH:-}" ] && [ $is_unclean -ne 0 ]; then
+  >&2 echo "Stashing uncommitted changes..."
+  GIT_LITERAL_PATHSPECS=0 git stash -q --keep-index
+  trap revert_git_stash EXIT
+fi
+
+export FLAKEBOX_GIT_LS
+FLAKEBOX_GIT_LS="$(git ls-files)"
+export FLAKEBOX_GIT_LS_TEXT
+FLAKEBOX_GIT_LS_TEXT="$(echo "$FLAKEBOX_GIT_LS" | grep -v -E "\.(png|ods|jpg|jpeg|woff2|keystore|wasm|ttf|jar|ico|gif)\$")"
+
+
+function check_nothing() {
+  true
+}
+export -f check_nothing
+
+function check_cargo_fmt() {
+    set -euo pipefail
+
+    cargo fmt --all --check
+
+}
+export -f check_cargo_fmt
+
+function check_cargo_lock() {
+    set -euo pipefail
+
+    # https://users.rust-lang.org/t/check-if-the-cargo-lock-is-up-to-date-without-building-anything/91048/5
+    cargo update --workspace --locked
+
+}
+export -f check_cargo_lock
+
+function check_leftover_dbg() {
+    set -euo pipefail
+
+    errors=""
+    for path in $(echo "$FLAKEBOX_GIT_LS_TEXT" | grep  '.*\.rs'); do
+      if grep 'dbg!(' "$path" > /dev/null; then
+        >&2 echo "$path contains dbg! macro"
+        errors="true"
+      fi
+    done
+
+    if [ -n "$errors" ]; then
+      >&2 echo "Fix the problems above or use --no-verify" 1>&2
+      return 1
+    fi
+
+}
+export -f check_leftover_dbg
+
+function check_semgrep() {
+    set -euo pipefail
+
+    # semgrep is not available on MacOS
+    if ! command -v semgrep > /dev/null ; then
+      >&2 echo "Skipping semgrep check: not available"
+      return 0
+    fi
+
+    if [ ! -f .config/semgrep.yaml ] ; then
+      >&2 echo "Skipping semgrep check: .config/semgrep.yaml doesn't exist"
+      return 0
+    fi
+
+    if [ ! -s .config/semgrep.yaml ] ; then
+      >&2 echo "Skipping semgrep check: .config/semgrep.yaml empty"
+      return 0
+    fi
+
+    env SEMGREP_ENABLE_VERSION_CHECK=0 \
+      semgrep -q --error --no-rewrite-rule-ids --config .config/semgrep.yaml
+
+}
+export -f check_semgrep
+
+function check_shellcheck() {
+    set -euo pipefail
+
+    for path in $(echo "$FLAKEBOX_GIT_LS_TEXT" | grep -E '.*\.sh$'); do
+      shellcheck --severity=warning "$path"
+    done
+
+}
+export -f check_shellcheck
+
+function check_trailing_newline() {
+    set -euo pipefail
+
+    errors=""
+    for path in $(echo "$FLAKEBOX_GIT_LS_TEXT"); do
+
+      # extra branches for clarity
+      if [ ! -s "$path" ]; then
+         # echo "$path is empty"
+         true
+      elif [ -z "$(tail -c 1 < "$path")" ]; then
+         # echo "$path ends with a newline or with a null byte"
+         true
+      else
+        >&2 echo "$path doesn't end with a newline" 1>&2
+        errors="true"
+      fi
+    done
+
+    if [ -n "$errors" ]; then
+      >&2 echo "Fix the problems above or use --no-verify" 1>&2
+      return 1
+    fi
+
+}
+export -f check_trailing_newline
+
+function check_trailing_whitespace() {
+    set -euo pipefail
+
+    if ! git diff --check HEAD ; then
+      echo "Trailing whitespace detected. Please remove them before committing."
+      return 1
+    fi
+
+}
+export -f check_trailing_whitespace
+
+function check_typos() {
+    set -euo pipefail
+
+    if ! echo "$FLAKEBOX_GIT_LS_TEXT" | typos --file-list - --force-exclude ; then
+      >&2 echo "Typos found: Valid new words can be added to '.typos.toml'"
+      return 1
+    fi
+
+}
+export -f check_typos
+
+parallel \
+  --nonotice \
+::: \
+    check_cargo_fmt \
+    check_cargo_lock \
+    check_leftover_dbg \
+    check_semgrep \
+    check_shellcheck \
+    check_trailing_newline \
+    check_trailing_whitespace \
+    check_typos \
+  check_nothing