Skip to content

Commit

Permalink
improve: nix flakebox fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
thesimplekid committed Oct 22, 2023
1 parent dafa007 commit bf5ea01
Show file tree
Hide file tree
Showing 80 changed files with 1,029 additions and 262 deletions.
1 change: 1 addition & 0 deletions .config/flakebox/id
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6ed8d7bac0d49950f28394f623607c29d00896bcf1505d366717626babadd81f8f111f93afd1b991b7087d5ce0684b4bcc10124aad93b3876ba1aba600a09cb4
32 changes: 32 additions & 0 deletions .config/flakebox/shellHook.sh
Original file line number Diff line number Diff line change
@@ -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 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
78 changes: 78 additions & 0 deletions .github/workflows/flakebox-ci.yml
Original file line number Diff line number Diff line change
@@ -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 changes: 35 additions & 0 deletions .github/workflows/flakebox-flakehub-publish.yml
Original file line number Diff line number Diff line change
@@ -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 changes: 4 additions & 0 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
group_imports = "StdExternalCrate"
wrap_comments = true
format_code_in_doc_comments = true
imports_granularity = "Module"
2 changes: 1 addition & 1 deletion bindings/cashu-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ url = { workspace = true }
uniffi = { workspace = true }

[build-dependencies]
uniffi = { workspace = true, features = ["build"] }
uniffi = { workspace = true, features = ["build"] }
11 changes: 5 additions & 6 deletions bindings/cashu-ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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");
Expand Down
6 changes: 4 additions & 2 deletions bindings/cashu-ffi/src/nuts/nut00/blinded_messages.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
4 changes: 1 addition & 3 deletions bindings/cashu-ffi/src/nuts/nut00/blinded_signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions bindings/cashu-ffi/src/nuts/nut00/proof.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions bindings/cashu-ffi/src/nuts/nut00/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 4 additions & 2 deletions bindings/cashu-ffi/src/nuts/nut01/key_pair.rs
Original file line number Diff line number Diff line change
@@ -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,
}
Expand Down
7 changes: 5 additions & 2 deletions bindings/cashu-ffi/src/nuts/nut01/keys.rs
Original file line number Diff line number Diff line change
@@ -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,
}
Expand Down
4 changes: 1 addition & 3 deletions bindings/cashu-ffi/src/nuts/nut02/key_set.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
3 changes: 2 additions & 1 deletion bindings/cashu-ffi/src/nuts/nut03/mod.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
3 changes: 2 additions & 1 deletion bindings/cashu-ffi/src/nuts/nut04/mod.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand Down
19 changes: 10 additions & 9 deletions bindings/cashu-ffi/src/nuts/nut05/mod.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
3 changes: 2 additions & 1 deletion bindings/cashu-ffi/src/nuts/nut06/mod.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand Down
3 changes: 2 additions & 1 deletion bindings/cashu-ffi/src/nuts/nut07/mod.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
3 changes: 2 additions & 1 deletion bindings/cashu-ffi/src/nuts/nut09/mod.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand Down
3 changes: 2 additions & 1 deletion bindings/cashu-ffi/src/types/amount.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::{ops::Deref, sync::Arc};
use std::ops::Deref;
use std::sync::Arc;

use cashu::Amount as AmountSdk;

Expand Down
7 changes: 5 additions & 2 deletions bindings/cashu-ffi/src/types/bolt11_invoice.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
3 changes: 2 additions & 1 deletion bindings/cashu-ffi/src/types/keyset_info.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::{ops::Deref, sync::Arc};
use std::ops::Deref;
use std::sync::Arc;

use cashu::types::KeysetInfo as KeySetInfoSdk;

Expand Down
2 changes: 1 addition & 1 deletion bindings/cashu-js/examples/amount.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ function main() {
console.log(amount.toSat())
}

main();
main();
2 changes: 1 addition & 1 deletion bindings/cashu-js/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ build:
wasm-pack build

pack:
npm run package
npm run package
Loading

0 comments on commit bf5ea01

Please sign in to comment.