From 44f7cac09f2b89df6c299de36e7291acf16f37b3 Mon Sep 17 00:00:00 2001 From: "kody.low" Date: Sat, 13 Apr 2024 11:17:48 -0700 Subject: [PATCH] fix: fix --- flake.lock | 128 ++------------- misc/git-hooks/pre-commit | 173 ++++++++++---------- wrappers/fedimint-go/cmd/main.go | 38 ++--- wrappers/fedimint-go/pkg/fedimint/client.go | 4 +- 4 files changed, 122 insertions(+), 221 deletions(-) diff --git a/flake.lock b/flake.lock index a2ec040..112303e 100644 --- a/flake.lock +++ b/flake.lock @@ -69,104 +69,6 @@ "type": "github" } }, -<<<<<<< HEAD -||||||| parent of cdebb0d (fix::> Added support func to tests and Updated CreateNewFedimintClient()) - "devshell_2": { - "inputs": { - "nixpkgs": [ - "flakebox", - "android-nixpkgs", - "nixpkgs" - ], - "systems": "systems_6" - }, - "locked": { - "lastModified": 1695195896, - "narHash": "sha256-pq9q7YsGXnQzJFkR5284TmxrLNFc0wo4NQ/a5E93CQU=", - "owner": "numtide", - "repo": "devshell", - "rev": "05d40d17bf3459606316e3e9ec683b784ff28f16", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "devshell", - "type": "github" - } - }, - "fedimint": { - "inputs": { - "advisory-db": "advisory-db", - "bundlers": "bundlers", - "fenix": "fenix", - "flake-utils": "flake-utils_2", - "flakebox": "flakebox", - "nixpkgs": "nixpkgs_4" - }, - "locked": { - "lastModified": 1710534977, - "narHash": "sha256-RWzV+/NZkV87JnydefwRMwJ9tDkwDCg6m3pCxsVlKeY=", - "owner": "fedimint", - "repo": "fedimint", - "rev": "9d552fdf82f4af429165a1fd409615809ada4058", - "type": "github" - }, - "original": { - "owner": "fedimint", - "repo": "fedimint", - "rev": "9d552fdf82f4af429165a1fd409615809ada4058", - "type": "github" - } - }, -======= - "devshell_2": { - "inputs": { - "nixpkgs": [ - "flakebox", - "android-nixpkgs", - "nixpkgs" - ], - "systems": "systems_6" - }, - "locked": { - "lastModified": 1695195896, - "narHash": "sha256-pq9q7YsGXnQzJFkR5284TmxrLNFc0wo4NQ/a5E93CQU=", - "owner": "numtide", - "repo": "devshell", - "rev": "05d40d17bf3459606316e3e9ec683b784ff28f16", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "devshell", - "type": "github" - } - }, - "fedimint": { - "inputs": { - "advisory-db": "advisory-db", - "bundlers": "bundlers", - "fenix": "fenix", - "flake-utils": "flake-utils_2", - "flakebox": "flakebox", - "nixpkgs": "nixpkgs_4" - }, - "locked": { - "lastModified": 1711405975, - "narHash": "sha256-I8uUhpqN5oGDkT+sN4jztzun/wD/mN/CtzCxlV3pdjY=", - "owner": "fedimint", - "repo": "fedimint", - "rev": "c32bbe8ed8d95ae420b5879e92dda6ce48f5c914", - "type": "github" - }, - "original": { - "owner": "fedimint", - "repo": "fedimint", - "rev": "c32bbe8ed8d95ae420b5879e92dda6ce48f5c914", - "type": "github" - } - }, ->>>>>>> cdebb0d (fix::> Added support func to tests and Updated CreateNewFedimintClient()) "fenix": { "inputs": { "nixpkgs": [ @@ -175,11 +77,11 @@ "rust-analyzer-src": "rust-analyzer-src" }, "locked": { - "lastModified": 1712730246, - "narHash": "sha256-iB8bFj+07RHpmt+XuGGvYQk2Iwm12u6+DklGq/+Tg5s=", + "lastModified": 1712903033, + "narHash": "sha256-KcvsEm0h1mIwBHFAzWFBjGihnbf2fxpAaXOdVbUfAI4=", "owner": "nix-community", "repo": "fenix", - "rev": "d402ae4a5e5676722290470f61a5e8e3155b5487", + "rev": "c739f83545e625227f4d0af7fe2a71e69931fa4c", "type": "github" }, "original": { @@ -193,11 +95,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1701680307, - "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", "owner": "numtide", "repo": "flake-utils", - "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", "type": "github" }, "original": { @@ -232,11 +134,11 @@ ] }, "locked": { - "lastModified": 1694529238, - "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", "owner": "numtide", "repo": "flake-utils", - "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", "type": "github" }, "original": { @@ -275,11 +177,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1712437997, - "narHash": "sha256-g0whLLwRvgO2FsyhY8fNk+TWenS3jg5UdlWL4uqgFeo=", + "lastModified": 1712867921, + "narHash": "sha256-edTFV4KldkCMdViC/rmpJa7oLIU8SE/S35lh/ukC7bg=", "owner": "nixos", "repo": "nixpkgs", - "rev": "e38d7cb66ea4f7a0eb6681920615dfcc30fc2920", + "rev": "51651a540816273b67bc4dedea2d37d116c5f7fe", "type": "github" }, "original": { @@ -300,11 +202,11 @@ "rust-analyzer-src": { "flake": false, "locked": { - "lastModified": 1712663608, - "narHash": "sha256-tN9ZL6kGppmHg84lxlpAlaN+kXWNctKK7Yitq/iXDEw=", + "lastModified": 1712818880, + "narHash": "sha256-VDxsvgj/bNypHq48tQWtc3VRbWvzlFjzKf9ZZIVO10Y=", "owner": "rust-lang", "repo": "rust-analyzer", - "rev": "a5feb4f05f09adca661c869b1bf2324898cbaa43", + "rev": "657b33b0cb9bd49085202e91ad5b4676532c9140", "type": "github" }, "original": { diff --git a/misc/git-hooks/pre-commit b/misc/git-hooks/pre-commit index 7959e97..d21df26 100755 --- a/misc/git-hooks/pre-commit +++ b/misc/git-hooks/pre-commit @@ -9,13 +9,13 @@ set -e # Revert `git stash` on exit function revert_git_stash { - >&2 echo "Unstashing uncommitted changes..." + echo >&2 "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..." + echo >&2 "Stashing uncommitted changes..." GIT_LITERAL_PATHSPECS=0 git stash -q --keep-index trap revert_git_stash EXIT fi @@ -25,146 +25,145 @@ 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 + set -euo pipefail - flakebox-in-each-cargo-workspace cargo fmt --all --check + flakebox-in-each-cargo-workspace cargo fmt --all --check } export -f check_cargo_fmt function check_cargo_lock() { - set -euo pipefail + set -euo pipefail - # https://users.rust-lang.org/t/check-if-the-cargo-lock-is-up-to-date-without-building-anything/91048/5 - flakebox-in-each-cargo-workspace cargo update --workspace --locked + # https://users.rust-lang.org/t/check-if-the-cargo-lock-is-up-to-date-without-building-anything/91048/5 + flakebox-in-each-cargo-workspace 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 + set -euo pipefail + + errors="" + for path in $(echo "$FLAKEBOX_GIT_LS_TEXT" | grep '.*\.rs'); do + if grep 'dbg!(' "$path" >/dev/null; then + echo >&2 "$path contains dbg! macro" + errors="true" fi + done + + if [ -n "$errors" ]; then + echo >&2 "Fix the problems above or use --no-verify" 1>&2 + return 1 + fi } export -f check_leftover_dbg function check_semgrep() { - set -euo pipefail + 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 + # semgrep is not available on MacOS + if ! command -v semgrep >/dev/null; then + echo >&2 "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 [ ! -f .config/semgrep.yaml ]; then + echo >&2 "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 + if [ ! -s .config/semgrep.yaml ]; then + echo >&2 "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 + 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 + set -euo pipefail - for path in $(echo "$FLAKEBOX_GIT_LS_TEXT" | grep -E '.*\.sh$'); do - shellcheck --severity=warning "$path" - done + 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 + 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 + echo >&2 "$path doesn't end with a newline" 1>&2 + errors="true" fi + done + + if [ -n "$errors" ]; then + echo >&2 "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 - - rev="HEAD" - if ! git rev-parse -q 1>/dev/null HEAD 2>/dev/null ; then - >&2 echo "Warning: no commits yet, checking against --root" - rev="--root" - fi - if ! git diff --check $rev ; then - >&2 echo "Trailing whitespace detected. Please remove them before committing." - return 1 - fi + set -euo pipefail + + rev="HEAD" + if ! git rev-parse -q HEAD 1>/dev/null 2>/dev/null; then + echo >&2 "Warning: no commits yet, checking against --root" + rev="--root" + fi + if ! git diff --check $rev; then + echo >&2 "Trailing whitespace detected. Please remove them before committing." + return 1 + fi } export -f check_trailing_whitespace function check_typos() { - set -euo pipefail + 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 + if ! echo "$FLAKEBOX_GIT_LS_TEXT" | typos --file-list - --force-exclude; then + echo >&2 "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_cargo_fmt \ + check_cargo_lock \ + check_leftover_dbg \ + check_semgrep \ + check_shellcheck \ + check_trailing_newline \ + check_trailing_whitespace \ + check_typos \ check_nothing diff --git a/wrappers/fedimint-go/cmd/main.go b/wrappers/fedimint-go/cmd/main.go index be05dac..cfd198c 100644 --- a/wrappers/fedimint-go/cmd/main.go +++ b/wrappers/fedimint-go/cmd/main.go @@ -101,7 +101,7 @@ func main() { var fedimintResponseData interface{} err = json.Unmarshal(jsonBytes, &fedimintResponseData) if err != nil { - fmt.Println("Error unmarshaling JSON(discover-version):", err) + fmt.Println("Error unmarshalling JSON(discover-version):", err) return } @@ -132,7 +132,7 @@ func main() { var infoResponseData interface{} err = json.Unmarshal(jsonBytes, &infoResponseData) if err != nil { - fmt.Println("Error unmarshaling JSON(discover-version):", err) + fmt.Println("Error unmarshalling JSON(discover-version):", err) return } @@ -158,7 +158,7 @@ func main() { var joinResponseData interface{} err = json.Unmarshal(jsonBytes, &joinResponseData) if err != nil { - fmt.Println("Error unmarshaling JSON(join):", err) + fmt.Println("Error unmarshalling JSON(join):", err) return } @@ -180,7 +180,7 @@ func main() { var listOperationsResponseData interface{} err = json.Unmarshal(jsonBytes, &listOperationsResponseData) if err != nil { - fmt.Println("Error unmarshaling JSON(list-operations):", err) + fmt.Println("Error unmarshalling JSON(list-operations):", err) return } @@ -206,7 +206,7 @@ func main() { var gatewayListResponseData interface{} err = json.Unmarshal(jsonBytes, &gatewayListResponseData) if err != nil { - fmt.Println("Error unmarshaling JSON(list-gateways):", err) + fmt.Println("Error unmarshalling JSON(list-gateways):", err) return } @@ -228,7 +228,7 @@ func main() { var invoiceResponseData interface{} err = json.Unmarshal(jsonBytes, &invoiceResponseData) if err != nil { - fmt.Println("Error unmarshaling JSON(invoice):", err) + fmt.Println("Error unmarshalling JSON(invoice):", err) return } @@ -250,7 +250,7 @@ func main() { var payResponseData interface{} err = json.Unmarshal(jsonBytes, &payResponseData) if err != nil { - fmt.Println("Error unmarshaling JSON(pay):", err) + fmt.Println("Error unmarshalling JSON(pay):", err) return } @@ -272,7 +272,7 @@ func main() { var awaitInvoiceResponseData interface{} err = json.Unmarshal(jsonBytes, &awaitInvoiceResponseData) if err != nil { - fmt.Println("Error unmarshaling JSON(await-invoice):", err) + fmt.Println("Error unmarshalling JSON(await-invoice):", err) return } @@ -294,7 +294,7 @@ func main() { var tweakInvoiceResponseData interface{} err = json.Unmarshal(jsonBytes, &tweakInvoiceResponseData) if err != nil { - fmt.Println("Error unmarshaling JSON(await-invoice):", err) + fmt.Println("Error unmarshalling JSON(await-invoice):", err) return } @@ -319,7 +319,7 @@ func main() { var claimInvoiceResponseData interface{} err = json.Unmarshal(jsonBytes, &claimInvoiceResponseData) if err != nil { - fmt.Println("Error unmarshaling JSON(claim-external-pubkey-tweaked):", err) + fmt.Println("Error unmarshalling JSON(claim-external-pubkey-tweaked):", err) return } @@ -345,7 +345,7 @@ func main() { var mintResponseData interface{} err = json.Unmarshal(jsonBytes, &mintResponseData) if err != nil { - fmt.Println("Error unmarshaling JSON(spend):", err) + fmt.Println("Error unmarshalling JSON(spend):", err) return } @@ -367,7 +367,7 @@ func main() { var decodedResponseData interface{} err = json.Unmarshal(jsonBytes, &decodedResponseData) if err != nil { - fmt.Println("Error unmarshaling JSON(decode-notes):", err) + fmt.Println("Error unmarshalling JSON(decode-notes):", err) return } @@ -389,7 +389,7 @@ func main() { var encodedResponseData interface{} err = json.Unmarshal(jsonBytes, &encodedResponseData) if err != nil { - fmt.Println("Error unmarshaling JSON(encode-notes):", err) + fmt.Println("Error unmarshalling JSON(encode-notes):", err) return } @@ -411,7 +411,7 @@ func main() { var validateResponseData interface{} err = json.Unmarshal(jsonBytes, &validateResponseData) if err != nil { - fmt.Println("Error unmarshaling JSON(validate):", err) + fmt.Println("Error unmarshalling JSON(validate):", err) return } @@ -433,7 +433,7 @@ func main() { var reissueResponseData interface{} err = json.Unmarshal(jsonBytes, &reissueResponseData) if err != nil { - fmt.Println("Error unmarshaling JSON(reissue):", err) + fmt.Println("Error unmarshalling JSON(reissue):", err) return } @@ -455,7 +455,7 @@ func main() { var splitResponseData interface{} err = json.Unmarshal(jsonBytes, &splitResponseData) if err != nil { - fmt.Println("Error unmarshaling JSON(split):", err) + fmt.Println("Error unmarshalling JSON(split):", err) return } @@ -484,7 +484,7 @@ func main() { var combineResponseData interface{} err = json.Unmarshal(jsonBytes, &combineResponseData) if err != nil { - fmt.Println("Error unmarshaling JSON(split):", err) + fmt.Println("Error unmarshalling JSON(split):", err) return } @@ -510,7 +510,7 @@ func main() { var addrResponseData interface{} err = json.Unmarshal(jsonBytes, &addrResponseData) if err != nil { - fmt.Println("Error unmarshaling JSON(deposit-address):", err) + fmt.Println("Error unmarshalling JSON(deposit-address):", err) return } @@ -532,7 +532,7 @@ func main() { var withdrawResponseData interface{} err = json.Unmarshal(jsonBytes, &withdrawResponseData) if err != nil { - fmt.Println("Error unmarshaling JSON(withdraw):", err) + fmt.Println("Error unmarshalling JSON(withdraw):", err) return } diff --git a/wrappers/fedimint-go/pkg/fedimint/client.go b/wrappers/fedimint-go/pkg/fedimint/client.go index d2a6b82..a4ce78c 100644 --- a/wrappers/fedimint-go/pkg/fedimint/client.go +++ b/wrappers/fedimint-go/pkg/fedimint/client.go @@ -591,8 +591,8 @@ func (ln *LnModule) Pay(paymentInfo string, gatewayId string, amountMsat *uint64 return &payResp, nil } -func (ln *LnModule) ListGateways(gatewayId *string) ([]modules.Gateway, error) { - resp, err := ln.Client.get("/ln/list-gateways") +func (ln *LnModule) ListGateways(federationId *string) ([]modules.Gateway, error) { + resp, err := ln.Client.postWithFederationId("/ln/list-gateways", nil, federationId) if err != nil { return nil, err }