From 3cf45b41fb99f9f9d6ef530f98cfde9d1c957d9b Mon Sep 17 00:00:00 2001 From: Mario Zupan Date: Tue, 12 May 2026 11:29:37 +0200 Subject: [PATCH] Rename Mandatory Emails Flag --- .github/workflows/rust.yml | 3 +- .github/workflows/wasm_release.yml | 3 +- CHANGELOG.md | 1 + crates/bcr-ebill-api/src/lib.rs | 4 +- .../src/service/bill_service/data_fetching.rs | 10 +- .../src/service/company_service.rs | 5 +- .../src/service/identity_service.rs | 5 +- crates/bcr-ebill-api/src/tests/mod.rs | 2 +- crates/bcr-ebill-transport/src/test_utils.rs | 2 +- crates/bcr-ebill-wasm/main.js | 2 +- crates/bcr-ebill-wasm/src/lib.rs | 4 +- scripts/install-wasm-pack.sh | 249 ------------------ 12 files changed, 14 insertions(+), 276 deletions(-) delete mode 100644 scripts/install-wasm-pack.sh diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index c51c6a0e..5cd3469f 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -87,8 +87,7 @@ jobs: - name: Install wasm-pack run: | - cd scripts - bash install-wasm-pack.sh + cargo install wasm-pack --version 0.14.0 - name: Build WASM version run: | diff --git a/.github/workflows/wasm_release.yml b/.github/workflows/wasm_release.yml index 48f3317d..4001f85f 100644 --- a/.github/workflows/wasm_release.yml +++ b/.github/workflows/wasm_release.yml @@ -73,8 +73,7 @@ jobs: - name: Install wasm-pack run: | - cd scripts - bash install-wasm-pack.sh + cargo install wasm-pack --version 0.14.0 - name: Build with wasm-pack env: diff --git a/CHANGELOG.md b/CHANGELOG.md index 78103f74..6ec84bd4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # 0.5.10 * Fix company creation with identity upload and missing nostr node id during block propagation +* rename `disable_mandatory_email_confirmations` to `mandatory_email_confirmations` with default = `true` (breaking CONFIG change) # 0.5.9 diff --git a/crates/bcr-ebill-api/src/lib.rs b/crates/bcr-ebill-api/src/lib.rs index 753e7333..2d714eac 100644 --- a/crates/bcr-ebill-api/src/lib.rs +++ b/crates/bcr-ebill-api/src/lib.rs @@ -73,12 +73,12 @@ pub struct CourtConfig { } /// Developer Mode specific configuration -#[derive(Debug, Clone, Default)] +#[derive(Debug, Clone)] pub struct DevModeConfig { /// Whether dev mode is on pub on: bool, /// Whether mandatory email confirmations should be enabled (disable for easier testing) - pub disable_mandatory_email_confirmations: bool, + pub mandatory_email_confirmations: bool, } /// Payment specific configuration diff --git a/crates/bcr-ebill-api/src/service/bill_service/data_fetching.rs b/crates/bcr-ebill-api/src/service/bill_service/data_fetching.rs index 9228b1a6..c421847c 100644 --- a/crates/bcr-ebill-api/src/service/bill_service/data_fetching.rs +++ b/crates/bcr-ebill-api/src/service/bill_service/data_fetching.rs @@ -173,10 +173,7 @@ impl BillService { .iter() .find(|ec| { &ec.0.witness - == if get_config() - .dev_mode_config - .disable_mandatory_email_confirmations - { + == if !get_config().dev_mode_config.mandatory_email_confirmations { &identified.node_id } else { witness @@ -190,10 +187,7 @@ impl BillService { .iter() .find(|ec| { &ec.0.witness - == if get_config() - .dev_mode_config - .disable_mandatory_email_confirmations - { + == if !get_config().dev_mode_config.mandatory_email_confirmations { &signatory_identity.identity.node_id } else { witness diff --git a/crates/bcr-ebill-api/src/service/company_service.rs b/crates/bcr-ebill-api/src/service/company_service.rs index 297ee1ac..ce44aeb1 100644 --- a/crates/bcr-ebill-api/src/service/company_service.rs +++ b/crates/bcr-ebill-api/src/service/company_service.rs @@ -370,10 +370,7 @@ impl CompanyService { company_id: &NodeId, email: &Email, ) -> Result<(SignedIdentityProof, EmailIdentityProofData)> { - if !get_config() - .dev_mode_config - .disable_mandatory_email_confirmations - { + if get_config().dev_mode_config.mandatory_email_confirmations { // Make sure there is a confirmed email let email_confirmations = self.store.get_email_confirmations(company_id).await?; if email_confirmations.is_empty() { diff --git a/crates/bcr-ebill-api/src/service/identity_service.rs b/crates/bcr-ebill-api/src/service/identity_service.rs index cee141b5..640a285c 100644 --- a/crates/bcr-ebill-api/src/service/identity_service.rs +++ b/crates/bcr-ebill-api/src/service/identity_service.rs @@ -311,10 +311,7 @@ impl IdentityService { return Err(ProtocolValidationError::FieldEmpty(Field::Email).into()); }; - if !get_config() - .dev_mode_config - .disable_mandatory_email_confirmations - { + if get_config().dev_mode_config.mandatory_email_confirmations { // Make sure there is a confirmed email let email_confirmations = self.store.get_email_confirmations().await?; if email_confirmations.is_empty() { diff --git a/crates/bcr-ebill-api/src/tests/mod.rs b/crates/bcr-ebill-api/src/tests/mod.rs index 3deb8909..c5921da3 100644 --- a/crates/bcr-ebill-api/src/tests/mod.rs +++ b/crates/bcr-ebill-api/src/tests/mod.rs @@ -558,7 +558,7 @@ pub mod tests { }, dev_mode_config: DevModeConfig { on: false, - disable_mandatory_email_confirmations: false, + mandatory_email_confirmations: true, }, court_config: CourtConfig { default_url: url::Url::parse("https://court-dev.minibill.tech").unwrap(), diff --git a/crates/bcr-ebill-transport/src/test_utils.rs b/crates/bcr-ebill-transport/src/test_utils.rs index 9559599d..01311900 100644 --- a/crates/bcr-ebill-transport/src/test_utils.rs +++ b/crates/bcr-ebill-transport/src/test_utils.rs @@ -150,7 +150,7 @@ pub fn init_test_cfg() { }, dev_mode_config: DevModeConfig { on: false, - disable_mandatory_email_confirmations: false, + mandatory_email_confirmations: true, }, court_config: CourtConfig { default_url: url::Url::parse("https://court-dev.minibill.tech").unwrap(), diff --git a/crates/bcr-ebill-wasm/main.js b/crates/bcr-ebill-wasm/main.js index b80028bc..94edb2de 100644 --- a/crates/bcr-ebill-wasm/main.js +++ b/crates/bcr-ebill-wasm/main.js @@ -136,7 +136,7 @@ let config = { default_mint_node_id: "bitcrt020e50d48b6b2897743ca257c82684e984509c05c9bf812176c717005698e57023", //wildcat0 clowder-dev num_confirmations_for_payment: 1, dev_mode: true, - disable_mandatory_email_confirmations: true, + mandatory_email_confirmations: false, // default_court_url: "http://localhost:8000", default_court_url: "https://bcr-court-dev.minibill.tech" }; diff --git a/crates/bcr-ebill-wasm/src/lib.rs b/crates/bcr-ebill-wasm/src/lib.rs index c5bce83e..fef9cca0 100644 --- a/crates/bcr-ebill-wasm/src/lib.rs +++ b/crates/bcr-ebill-wasm/src/lib.rs @@ -74,7 +74,7 @@ pub struct Config { pub default_mint_node_id: String, pub num_confirmations_for_payment: usize, pub dev_mode: bool, - pub disable_mandatory_email_confirmations: bool, + pub mandatory_email_confirmations: bool, pub default_court_url: String, } @@ -238,7 +238,7 @@ pub async fn initialize_api( }, dev_mode_config: DevModeConfig { on: config.dev_mode, - disable_mandatory_email_confirmations: config.disable_mandatory_email_confirmations, + mandatory_email_confirmations: config.mandatory_email_confirmations, }, court_config: CourtConfig { default_url: url::Url::parse(&config.default_court_url) diff --git a/scripts/install-wasm-pack.sh b/scripts/install-wasm-pack.sh deleted file mode 100644 index 0ea1703a..00000000 --- a/scripts/install-wasm-pack.sh +++ /dev/null @@ -1,249 +0,0 @@ -#!/bin/bash -# Copyright 2016 The Rust Project Developers. See the COPYRIGHT -# file at the top-level directory of this distribution and at -# http://rust-lang.org/COPYRIGHT. -# -# Licensed under the Apache License, Version 2.0 or the MIT license -# , at your -# option. This file may not be copied, modified, or distributed -# except according to those terms. - -# This is just a little script that can be downloaded from the internet to -# install wasm-pack. It just does platform detection, downloads the installer -# and runs it. - -set -u - -# Parse VERSION from environment or --version argument, default to "latest" -if [ -z "${VERSION:-}" ]; then - VERSION="" - ORIG_ARGS=("$@") - - while [ $# -gt 0 ]; do - case $1 in - --version) - VERSION="$2" - shift 2 - ;; - *) - shift - ;; - esac - done - - set -- "${ORIG_ARGS[@]}" - - if [ -z "v0.14.0" ]; then - VERSION="latest" - fi -fi - -# Resolve "latest" to actual version number -if [ "v0.14.0" = "latest" ]; then - VERSION=$(curl -s https://api.github.com/repos/drager/wasm-pack/releases/latest | grep '"tag_name"' | sed -E 's/.*"v?([^"]+)".*/\1/') - if [ -z "v0.14.0" ]; then - err "failed to fetch latest version from GitHub API" - fi -fi - -# Normalize version format for download URL -case "v0.14.0" in - v*) ;; - *) VERSION="vv0.14.0" ;; -esac - -UPDATE_ROOT="https://github.com/drager/wasm-pack/releases/download/v0.14.0" - -main() { - downloader --check - need_cmd uname - need_cmd mktemp - need_cmd chmod - need_cmd mkdir - need_cmd rm - need_cmd rmdir - need_cmd tar - need_cmd which - need_cmd dirname - - get_architecture || return 1 - local _arch="$RETVAL" - assert_nz "$_arch" "arch" - - local _ext="" - case "$_arch" in - *windows*) - _ext=".exe" - ;; - esac - - which rustup > /dev/null 2>&1 - need_ok "failed to find Rust installation, is rustup installed?" - local _rustup=$(which rustup) - local _tardir="wasm-pack-v0.14.0-${_arch}" - local _url="$UPDATE_ROOT/${_tardir}.tar.gz" - local _dir="$(mktemp -d 2>/dev/null || ensure mktemp -d -t wasm-pack)" - local _file="$_dir/input.tar.gz" - local _wasmpack="$_dir/wasm-pack$_ext" - local _wasmpackinit="$_dir/wasm-pack-init$_ext" - - printf '%s\n' 'info: downloading wasm-pack' 1>&2 - - ensure mkdir -p "$_dir" - downloader "$_url" "$_file" - if [ $? != 0 ]; then - say "failed to download $_url" - say "this may be a standard network error, but it may also indicate" - say "that wasm-pack's release process is not working. When in doubt" - say "please feel free to open an issue!" - exit 1 - fi - ensure tar xf "$_file" --strip-components 1 -C "$_dir" - mv "$_wasmpack" "$_wasmpackinit" - - # The installer may want to ask for confirmation on stdin for various - # operations. We were piped through `sh` though so we probably don't have - # access to a tty naturally. If it looks like we're attached to a terminal - # (`-t 1`) then pass the tty down to the installer explicitly. - if [ -t 1 ]; then - "$_wasmpackinit" "$@" < /dev/tty - else - "$_wasmpackinit" "$@" - fi - - local _retval=$? - - ignore rm -rf "$_dir" - - return "$_retval" -} - -get_architecture() { - local _ostype="$(uname -s)" - local _cputype="$(uname -m)" - - # This is when installing inside docker, or can be useful to side-step - # the script's built-in platform detection heuristic (if it drifts again in the future) - set +u - if [ -n "$TARGETOS" ]; then - _ostype="$TARGETOS" # probably always linux - fi - - if [ -n "$TARGETARCH" ]; then - _cputype="$TARGETARCH" - fi - set -u - - - if [ "$_ostype" = Darwin ] && [ "$_cputype" = i386 ]; then - # Darwin `uname -s` lies - if sysctl hw.optional.x86_64 | grep -q ': 1'; then - local _cputype=x86_64 - fi - fi - - case "$_ostype" in - Linux | linux) - local _ostype=unknown-linux-musl - ;; - - Darwin) - local _ostype=apple-darwin - ;; - - MINGW* | MSYS* | CYGWIN*) - local _ostype=pc-windows-msvc - ;; - - *) - err "no precompiled binaries available for OS: $_ostype" - ;; - esac - - case "$_cputype" in - x86_64 | x86-64 | x64 | amd64) - local _cputype=x86_64 - ;; - arm64 | aarch64) - local _cputype=aarch64 - ;; - *) - err "no precompiled binaries available for CPU architecture: $_cputype" - - esac - - # See https://github.com/drager/wasm-pack/pull/1088 - if [ "$_cputype" = "aarch64" ] && [ "$_ostype" = "apple-darwin" ]; then - _cputype="x86_64" - fi - - local _arch="$_cputype-$_ostype" - - RETVAL="$_arch" -} - -say() { - echo "wasm-pack-init: $1" -} - -err() { - say "$1" >&2 - exit 1 -} - -need_cmd() { - if ! check_cmd "$1" - then err "need '$1' (command not found)" - fi -} - -check_cmd() { - command -v "$1" > /dev/null 2>&1 - return $? -} - -need_ok() { - if [ $? != 0 ]; then err "$1"; fi -} - -assert_nz() { - if [ -z "$1" ]; then err "assert_nz $2"; fi -} - -# Run a command that should never fail. If the command fails execution -# will immediately terminate with an error showing the failing -# command. -ensure() { - "$@" - need_ok "command failed: $*" -} - -# This is just for indicating that commands' results are being -# intentionally ignored. Usually, because it's being executed -# as part of error handling. -ignore() { - "$@" -} - -# This wraps curl or wget. Try curl first, if not installed, -# use wget instead. -downloader() { - if check_cmd curl - then _dld=curl - elif check_cmd wget - then _dld=wget - else _dld='curl or wget' # to be used in error message of need_cmd - fi - - if [ "$1" = --check ] - then need_cmd "$_dld" - elif [ "$_dld" = curl ] - then curl -sSfL "$1" -o "$2" - elif [ "$_dld" = wget ] - then wget "$1" -O "$2" - else err "Unknown downloader" # should not reach here - fi -} - -main "$@" || exit 1