diff --git a/.github/workflows/publish-python.yaml b/.github/workflows/publish-python.yaml deleted file mode 100644 index d0b2ca811..000000000 --- a/.github/workflows/publish-python.yaml +++ /dev/null @@ -1,204 +0,0 @@ -name: Publish nostr-protocol to PyPI - -on: - workflow_dispatch: - inputs: - dry-run: - description: "Compile without publish to PyPI" - type: boolean - default: false - required: true - -jobs: - build-linux-x86_64: - name: "Build manylinux_2_28_x86_64 wheel" - runs-on: ubuntu-20.04 - strategy: - matrix: - python: - - cp39-cp39 - - cp310-cp310 - - cp311-cp311 - - cp312-cp312 - defaults: - run: - working-directory: bindings/nostr-ffi/bindings-python - container: - image: quay.io/pypa/manylinux_2_28_x86_64 - env: - PYBIN: "/opt/python/${{ matrix.python }}/bin" - steps: - - name: "Checkout" - uses: actions/checkout@v3 - - # Needed because inside container - - name: "Setup Rust" - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - - - name: "Generate nostr.py and binaries" - run: bash ./scripts/generate-linux-x86_64.sh - - - name: "Build wheel" - run: ${PYBIN}/python setup.py bdist_wheel --plat-name manylinux_2_28_x86_64 --verbose - - - uses: actions/upload-artifact@v4 - with: - name: nostr_protocol-manylinux_2_28_x86_64-${{ matrix.python }} - path: /home/runner/work/nostr/nostr/bindings/nostr-ffi/bindings-python/dist/*.whl - - build-linux-aarch64: - name: "Build manylinux_2_31 aarch64 wheel" - runs-on: ubuntu-20.04 - strategy: - matrix: - python: ["3.9", "3.10", "3.11", "3.12"] - defaults: - run: - working-directory: bindings/nostr-ffi/bindings-python - steps: - - name: "Checkout" - uses: actions/checkout@v3 - - - name: "Setup Python" - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python }} - - - name: Install gcc-aarch64-linux-gnu - run: | - sudo apt-get update -y - sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu - - - name: "Generate nostr.py and binaries" - run: bash ./scripts/generate-linux-aarch64.sh - - - name: "Build wheel" - run: python3 setup.py bdist_wheel --plat-name manylinux_2_31_aarch64 --verbose - - - uses: actions/upload-artifact@v4 - with: - name: nostr_protocol-manylinux_2_31_aarch64-${{ matrix.python }} - path: /home/runner/work/nostr/nostr/bindings/nostr-ffi/bindings-python/dist/*.whl - - build-macos-arm64: - name: "Build macOS arm64 wheel" - runs-on: macos-13 - defaults: - run: - working-directory: bindings/nostr-ffi/bindings-python - strategy: - matrix: - python: ["3.9", "3.10", "3.11", "3.12"] - steps: - - name: "Checkout" - uses: actions/checkout@v3 - with: - submodules: true - - - name: "Install Python" - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python }} - - - name: "Generate nostr.py and binaries" - run: bash ./scripts/generate-macos-arm64.sh - - - name: "Build wheel" - # Specifying the plat-name argument is necessary to build a wheel with the correct name, - # see issue #350 for more information - run: python3 setup.py bdist_wheel --plat-name macosx_11_0_arm64 --verbose - - - name: "Upload artifacts" - uses: actions/upload-artifact@v4 - with: - name: nostr_protocol-macos-arm64-${{ matrix.python }} - path: /Users/runner/work/nostr/nostr/bindings/nostr-ffi/bindings-python/dist/*.whl - - build-macos-x86_64: - name: "Build macOS x86_64 wheel" - runs-on: macos-13 - defaults: - run: - working-directory: bindings/nostr-ffi/bindings-python - strategy: - matrix: - python: ["3.9", "3.10", "3.11", "3.12"] - steps: - - name: "Checkout" - uses: actions/checkout@v3 - with: - submodules: true - - - name: "Install Python" - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python }} - - - name: "Generate nostr.py and binaries" - run: bash ./scripts/generate-macos-x86_64.sh - - - name: "Build wheel" - # Specifying the plat-name argument is necessary to build a wheel with the correct name, - # see issue #350 for more information - run: python3 setup.py bdist_wheel --plat-name macosx_11_0_x86_64 --verbose - - - uses: actions/upload-artifact@v4 - with: - name: nostr_protocol-macos-x86_64-${{ matrix.python }} - path: /Users/runner/work/nostr/nostr/bindings/nostr-ffi/bindings-python/dist/*.whl - - build-windows: - name: "Build Windows wheel" - runs-on: windows-2022 - defaults: - run: - working-directory: bindings/nostr-ffi/bindings-python - strategy: - matrix: - python: ["3.9", "3.10", "3.11", "3.12"] - steps: - - name: "Checkout" - uses: actions/checkout@v3 - with: - submodules: true - - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python }} - - - name: "Generate nostr.py and binaries" - run: bash ./scripts/generate-windows.sh - - - name: "Build wheel" - run: python setup.py bdist_wheel --verbose - - - name: "Upload artifacts" - uses: actions/upload-artifact@v4 - with: - name: nostr_protocol-win-${{ matrix.python }} - path: D:\a\nostr\nostr\bindings\nostr-ffi\bindings-python\dist\*.whl - - publish-pypi: - name: "Publish on PyPI" - runs-on: ubuntu-20.04 - defaults: - run: - working-directory: bindings/nostr-ffi/bindings-python - needs: [build-linux-x86_64, build-linux-aarch64, build-macos-arm64, build-macos-x86_64, build-windows] - if: github.event.inputs.dry-run == 'false' - steps: - - name: "Checkout" - uses: actions/checkout@v3 - - - name: "Download artifacts in dist/ directory" - uses: actions/download-artifact@v4 - with: - path: dist/ - - - name: "Publish on PyPI" - uses: pypa/gh-action-pypi-publish@release/v1 - with: - user: __token__ - password: ${{ secrets.PYPI_API_TOKEN }} - packages-dir: dist/*/ diff --git a/CHANGELOG.md b/CHANGELOG.md index cd319f0a4..4e5fc2325 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -73,8 +73,9 @@ * lmdb: mark event as deleted only if database have the target event ([Yuki Kishimoto]) * signer: bootstrap NIP46 signer on demand ([Yuki Kishimoto]) * bindings(nostr): adj. `tag` module ([Yuki Kishimoto]) -* js: change `opt-level` to `z` ([Yuki Kishimoto]) +* ffi: merge `nostr-ffi` in `nostr-sdk-ffi` ([Yuki Kishimoto]) * js: merge `nostr-js` into `nostr-sdk-js` ([Yuki Kishimoto]) +* js: change `opt-level` to `z` ([Yuki Kishimoto]) ### Added diff --git a/Cargo.lock b/Cargo.lock index 226fe4968..60a1beee1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2828,15 +2828,6 @@ dependencies = [ "tracing-subscriber", ] -[[package]] -name = "nostr-ffi" -version = "0.1.0" -dependencies = [ - "async-trait", - "nostr", - "uniffi", -] - [[package]] name = "nostr-indexeddb" version = "0.35.0" @@ -2951,8 +2942,8 @@ version = "0.1.0" dependencies = [ "async-trait", "async-utility", + "nostr", "nostr-connect", - "nostr-ffi", "nostr-relay-builder", "nostr-sdk", "paranoid-android", diff --git a/Cargo.toml b/Cargo.toml index 8beafcb46..5b713d6c1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,5 @@ [workspace] members = [ - "bindings/nostr-ffi", "bindings/nostr-sdk-ffi", "bindings/nostr-sdk-js", "bindings/uniffi-bindgen", diff --git a/bindings/README.md b/bindings/README.md index 0540eaca0..9737a5c3e 100644 --- a/bindings/README.md +++ b/bindings/README.md @@ -1,8 +1,7 @@ # rust-nostr bindings - UniFFI (Python, Kotlin, Swift): - * [nostr-ffi](./nostr-ffi): UniFFI bindings of the [nostr] crate - * [nostr-sdk-ffi](./nostr-sdk-ffi): UniFFI bindings of the [nostr-sdk] crate + * [nostr-sdk-ffi](./nostr-sdk-ffi): UniFFI bindings of the [nostr] and [nostr-sdk] crates - JavaScript: * [nostr-sdk-js](./nostr-sdk-js): JavaScript bindings of the [nostr] and [nostr-sdk] crates diff --git a/bindings/nostr-ffi/.gitignore b/bindings/nostr-ffi/.gitignore deleted file mode 100644 index 3a3ab136e..000000000 --- a/bindings/nostr-ffi/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -ffi/ -ENV/ \ No newline at end of file diff --git a/bindings/nostr-ffi/Cargo.toml b/bindings/nostr-ffi/Cargo.toml deleted file mode 100644 index 029d19c18..000000000 --- a/bindings/nostr-ffi/Cargo.toml +++ /dev/null @@ -1,17 +0,0 @@ -[package] -name = "nostr-ffi" -version = "0.1.0" -edition = "2021" -publish = false - -[lib] -name = "nostr_ffi" -crate-type = ["lib", "cdylib", "staticlib"] - -[dependencies] -async-trait.workspace = true -nostr = { workspace = true, features = ["std", "all-nips"] } -uniffi = { workspace = true, features = ["tokio"] } - -[dev-dependencies] -uniffi = { workspace = true, features = ["bindgen-tests"] } diff --git a/bindings/nostr-ffi/README.md b/bindings/nostr-ffi/README.md deleted file mode 100644 index ef09a9168..000000000 --- a/bindings/nostr-ffi/README.md +++ /dev/null @@ -1,86 +0,0 @@ -# Nostr FFI - -## Prerequisites - -* Rust: https://www.rust-lang.org/tools/install -* Just: https://just.systems/man/en/ (install with `cargo install just`) -* When building for Android: - * NDK v26 - * Set the `ANDROID_SDK_ROOT` env variable (ex. Linux: `~/Android/Sdk`, macOS: `~/Library/Android/sdk`) - * Set the `ANDROID_NDK_HOME` env variable (ex. Linux: `~/Android/Sdk/ndk/`, macOS: `~/Library/Android/sdk/ndk/`) - -## Build - -On first usage you will need to run: - -```bash -just init -``` - -### Python - -For most users, we recommend using our official Python package: [nostr-protocol](https://pypi.org/project/nostr-protocol/) - -If you want to compile from source or need more options, read on. - -### Wheel - -```bash -just python -``` - -### Kotlin - -For most users, we recommend using our official Kotlin package: [org.rust-nostr:nostr](https://central.sonatype.com/artifact/org.rust-nostr/nostr/). - -If you want to compile from source or need more options, read on. - -#### Libraries and Bindings - -This command will build libraries for different platforms in `target/` folder and copy them to `ffi/kotlin/jniLibs`. -In addition it will generate Kotlin bindings in `ffi/kotlin/nostr`. - -```bash -just kotlin -``` - -#### Android Archive (AAR) - -This command will build an AAR file in `ffi/android/lib-release.aar`: - -```bash -just bindings-android -``` - -See [Add your AAR or JAR as a dependency](https://developer.android.com/studio/projects/android-library#psd-add-aar-jar-dependency) in Android's docs for more information on how to integrate such an archive into your project. - -### Swift - -For most users, we recommend using our official Swift package: [rust-nostr/nostr-swift](https://github.com/rust-nostr/nostr-swift). - -If you want to compile from source or need more options, read on. - -#### Swift Module - -These commands will build libraries for different architectures in `../../target/` and generate Swift bindings as well as Swift module artifacts in `ffi/swift-ios/` and `ffi/swift-darwin/` respectively: - -```bash -just swift-ios -``` - -```bash -just swift-darwin -``` - -#### Swift Package - -This command will produce a fully configured Swift Package in `bindings-swift/`. -See [Adding package dependencies to your app](https://developer.apple.com/documentation/xcode/adding-package-dependencies-to-your-app) in Apple's docs for more information on how to integrate such a package into your project. - -```bash -just bindings-swift -``` - -## License - -This project is distributed under the MIT software license - see the [LICENSE](../../LICENSE) file for details \ No newline at end of file diff --git a/bindings/nostr-ffi/bindings-android/.gitignore b/bindings/nostr-ffi/bindings-android/.gitignore deleted file mode 100644 index 64b29cdc0..000000000 --- a/bindings/nostr-ffi/bindings-android/.gitignore +++ /dev/null @@ -1,48 +0,0 @@ -# Created by https://www.toptal.com/developers/gitignore/api/android -# Edit at https://www.toptal.com/developers/gitignore?templates=android - -### Android ### -# Gradle files -.gradle/ -build/ - -# Local configuration file (sdk path, etc) -local.properties - -# Log/OS Files -*.log - -# Android Studio generated files and folders -captures/ -.externalNativeBuild/ -.cxx/ -*.apk -output.json - -# IntelliJ -*.iml -.idea/ -misc.xml -deploymentTargetDropDown.xml -render.experimental.xml - -# Keystore files -*.jks -*.keystore - -# Google Services (e.g. APIs or Firebase) -google-services.json - -# Android Profiling -*.hprof - -### Android Patch ### -gen-external-apklibs - -# Replacement of .externalNativeBuild directories introduced -# with Android Studio 3.5. - -# End of https://www.toptal.com/developers/gitignore/api/android - -lib/src/main/jniLibs/ -lib/src/main/kotlin/ diff --git a/bindings/nostr-ffi/bindings-android/build.gradle.kts b/bindings/nostr-ffi/bindings-android/build.gradle.kts deleted file mode 100644 index ff1ab1adf..000000000 --- a/bindings/nostr-ffi/bindings-android/build.gradle.kts +++ /dev/null @@ -1,9 +0,0 @@ -buildscript { - repositories { - google() - mavenCentral() - } - dependencies { - classpath("com.android.tools.build:gradle:8.3.0") - } -} diff --git a/bindings/nostr-ffi/bindings-android/gradle.properties b/bindings/nostr-ffi/bindings-android/gradle.properties deleted file mode 100644 index 0ff3d4641..000000000 --- a/bindings/nostr-ffi/bindings-android/gradle.properties +++ /dev/null @@ -1,5 +0,0 @@ -org.gradle.jvmargs=-Xmx1536m -org.gradle.warning.mode=all -android.useAndroidX=true -android.enableJetifier=true -kotlin.code.style=official diff --git a/bindings/nostr-ffi/bindings-android/gradle/wrapper/gradle-wrapper.jar b/bindings/nostr-ffi/bindings-android/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 7454180f2..000000000 Binary files a/bindings/nostr-ffi/bindings-android/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/bindings/nostr-ffi/bindings-android/gradle/wrapper/gradle-wrapper.properties b/bindings/nostr-ffi/bindings-android/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index e411586a5..000000000 --- a/bindings/nostr-ffi/bindings-android/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/bindings/nostr-ffi/bindings-android/gradlew b/bindings/nostr-ffi/bindings-android/gradlew deleted file mode 100755 index 1b6c78733..000000000 --- a/bindings/nostr-ffi/bindings-android/gradlew +++ /dev/null @@ -1,234 +0,0 @@ -#!/bin/sh - -# -# Copyright © 2015-2021 the original authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -############################################################################## -# -# Gradle start up script for POSIX generated by Gradle. -# -# Important for running: -# -# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is -# noncompliant, but you have some other compliant shell such as ksh or -# bash, then to run this script, type that shell name before the whole -# command line, like: -# -# ksh Gradle -# -# Busybox and similar reduced shells will NOT work, because this script -# requires all of these POSIX shell features: -# * functions; -# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», -# «${var#prefix}», «${var%suffix}», and «$( cmd )»; -# * compound commands having a testable exit status, especially «case»; -# * various built-in commands including «command», «set», and «ulimit». -# -# Important for patching: -# -# (2) This script targets any POSIX shell, so it avoids extensions provided -# by Bash, Ksh, etc; in particular arrays are avoided. -# -# The "traditional" practice of packing multiple parameters into a -# space-separated string is a well documented source of bugs and security -# problems, so this is (mostly) avoided, by progressively accumulating -# options in "$@", and eventually passing that to Java. -# -# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, -# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; -# see the in-line comments for details. -# -# There are tweaks for specific operating systems such as AIX, CygWin, -# Darwin, MinGW, and NonStop. -# -# (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt -# within the Gradle project. -# -# You can find Gradle at https://github.com/gradle/gradle/. -# -############################################################################## - -# Attempt to set APP_HOME - -# Resolve links: $0 may be a link -app_path=$0 - -# Need this for daisy-chained symlinks. -while - APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path - [ -h "$app_path" ] -do - ls=$( ls -ld "$app_path" ) - link=${ls#*' -> '} - case $link in #( - /*) app_path=$link ;; #( - *) app_path=$APP_HOME$link ;; - esac -done - -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" -APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD=maximum - -warn () { - echo "$*" -} >&2 - -die () { - echo - echo "$*" - echo - exit 1 -} >&2 - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "$( uname )" in #( - CYGWIN* ) cygwin=true ;; #( - Darwin* ) darwin=true ;; #( - MSYS* | MINGW* ) msys=true ;; #( - NONSTOP* ) nonstop=true ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD=$JAVA_HOME/jre/sh/java - else - JAVACMD=$JAVA_HOME/bin/java - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then - case $MAX_FD in #( - max*) - MAX_FD=$( ulimit -H -n ) || - warn "Could not query maximum file descriptor limit" - esac - case $MAX_FD in #( - '' | soft) :;; #( - *) - ulimit -n "$MAX_FD" || - warn "Could not set maximum file descriptor limit to $MAX_FD" - esac -fi - -# Collect all arguments for the java command, stacking in reverse order: -# * args from the command line -# * the main class name -# * -classpath -# * -D...appname settings -# * --module-path (only if needed) -# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. - -# For Cygwin or MSYS, switch paths to Windows format before running java -if "$cygwin" || "$msys" ; then - APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) - - JAVACMD=$( cygpath --unix "$JAVACMD" ) - - # Now convert the arguments - kludge to limit ourselves to /bin/sh - for arg do - if - case $arg in #( - -*) false ;; # don't mess with options #( - /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath - [ -e "$t" ] ;; #( - *) false ;; - esac - then - arg=$( cygpath --path --ignore --mixed "$arg" ) - fi - # Roll the args list around exactly as many times as the number of - # args, so each arg winds up back in the position where it started, but - # possibly modified. - # - # NB: a `for` loop captures its iteration list before it begins, so - # changing the positional parameters here affects neither the number of - # iterations, nor the values presented in `arg`. - shift # remove old arg - set -- "$@" "$arg" # push replacement arg - done -fi - -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. - -set -- \ - "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ - "$@" - -# Use "xargs" to parse quoted args. -# -# With -n1 it outputs one arg per line, with the quotes and backslashes removed. -# -# In Bash we could simply go: -# -# readarray ARGS < <( xargs -n1 <<<"$var" ) && -# set -- "${ARGS[@]}" "$@" -# -# but POSIX shell has neither arrays nor command substitution, so instead we -# post-process each arg (as a line of input to sed) to backslash-escape any -# character that might be a shell metacharacter, then use eval to reverse -# that process (while maintaining the separation between arguments), and wrap -# the whole thing up as a single "set" statement. -# -# This will of course break if any of these variables contains a newline or -# an unmatched quote. -# - -eval "set -- $( - printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | - xargs -n1 | - sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | - tr '\n' ' ' - )" '"$@"' - -exec "$JAVACMD" "$@" diff --git a/bindings/nostr-ffi/bindings-android/gradlew.bat b/bindings/nostr-ffi/bindings-android/gradlew.bat deleted file mode 100644 index 107acd32c..000000000 --- a/bindings/nostr-ffi/bindings-android/gradlew.bat +++ /dev/null @@ -1,89 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/bindings/nostr-ffi/bindings-android/lib/build.gradle.kts b/bindings/nostr-ffi/bindings-android/lib/build.gradle.kts deleted file mode 100644 index 468894e85..000000000 --- a/bindings/nostr-ffi/bindings-android/lib/build.gradle.kts +++ /dev/null @@ -1,86 +0,0 @@ -plugins { - id("com.android.library") - id("org.jetbrains.kotlin.android") version "1.9.22" - id("com.vanniktech.maven.publish") version "0.28.0" - id("signing") -} - -repositories { - mavenCentral() - google() -} - -android { - namespace = "rust.nostr.protocol" - - compileSdk = 34 - - defaultConfig { - minSdk = 21 - - consumerProguardFiles("consumer-rules.pro") - } - - buildTypes { - release { - isMinifyEnabled = false - proguardFiles(file("proguard-android-optimize.txt"), file("proguard-rules.pro")) - } - } - - compileOptions { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 - } - - kotlinOptions { - jvmTarget = "1.8" - } -} - -dependencies { - implementation("net.java.dev.jna:jna:5.12.0@aar") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4") - implementation("androidx.appcompat:appcompat:1.6.1") -} - -mavenPublishing { - configure(com.vanniktech.maven.publish.AndroidMultiVariantLibrary( - sourcesJar = true, - publishJavadocJar = true, - )) - - publishToMavenCentral(com.vanniktech.maven.publish.SonatypeHost.CENTRAL_PORTAL, automaticRelease = true) - - signAllPublications() - - coordinates("org.rust-nostr", "nostr", "0.35.0") - - pom { - name.set("nostr") - description.set("Nostr protocol implementation") - url.set("https://rust-nostr.org") - licenses { - license { - name.set("MIT") - url.set("https://github.com/rust-nostr/nostr/blob/master/LICENSE") - } - } - developers { - developer { - id.set("yukibtc") - name.set("Yuki Kishimoto") - email.set("yukikishimoto@protonmail.com") - } - } - scm { - connection.set("scm:git:github.com/rust-nostr/nostr.git") - developerConnection.set("scm:git:ssh://github.com/rust-nostr/nostr.git") - url.set("https://github.com/rust-nostr/nostr") - } - } -} - -signing { - useGpgCmd() -} diff --git a/bindings/nostr-ffi/bindings-android/lib/consumer-rules.pro b/bindings/nostr-ffi/bindings-android/lib/consumer-rules.pro deleted file mode 100644 index e69de29bb..000000000 diff --git a/bindings/nostr-ffi/bindings-android/lib/proguard-rules.pro b/bindings/nostr-ffi/bindings-android/lib/proguard-rules.pro deleted file mode 100644 index 5287e7c47..000000000 --- a/bindings/nostr-ffi/bindings-android/lib/proguard-rules.pro +++ /dev/null @@ -1,28 +0,0 @@ -# Add project specific ProGuard rules here. -# You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} - -# Uncomment this to preserve the line number information for -# debugging stack traces. -#-keepattributes SourceFile,LineNumberTable - -# If you keep the line number information, uncomment this to -# hide the original source file name. -#-renamesourcefileattribute SourceFile - -# for JNA --dontwarn java.awt.* --keep class com.sun.jna.* { *; } --keep class rust.nostr.* { *; } --keepclassmembers class * extends rust.nostr.* { public *; } --keepclassmembers class * extends com.sun.jna.* { public *; } diff --git a/bindings/nostr-ffi/bindings-android/lib/src/main/AndroidManifest.xml b/bindings/nostr-ffi/bindings-android/lib/src/main/AndroidManifest.xml deleted file mode 100644 index f79cac1ac..000000000 --- a/bindings/nostr-ffi/bindings-android/lib/src/main/AndroidManifest.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/bindings/nostr-ffi/bindings-android/settings.gradle.kts b/bindings/nostr-ffi/bindings-android/settings.gradle.kts deleted file mode 100644 index 93a18881b..000000000 --- a/bindings/nostr-ffi/bindings-android/settings.gradle.kts +++ /dev/null @@ -1,3 +0,0 @@ -rootProject.name = "nostr" - -include(":lib") diff --git a/bindings/nostr-ffi/bindings-python/.gitignore b/bindings/nostr-ffi/bindings-python/.gitignore deleted file mode 100644 index 5aa595e0d..000000000 --- a/bindings/nostr-ffi/bindings-python/.gitignore +++ /dev/null @@ -1,16 +0,0 @@ -.tox/ -dist/ -nostr_protocol.egg-info/ -__pycache__/ -libnostr_ffi.dylib -.idea/ -.DS_Store - -*.swp - -src/nostr/nostr_ffi.py -src/nostr/*.so -*.whl -build/ - -testing-setup-py-simple-example.py diff --git a/bindings/nostr-ffi/bindings-python/LICENSE b/bindings/nostr-ffi/bindings-python/LICENSE deleted file mode 100644 index 2ff564424..000000000 --- a/bindings/nostr-ffi/bindings-python/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2022-2023 Yuki Kishimoto - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/bindings/nostr-ffi/bindings-python/MANIFEST.in b/bindings/nostr-ffi/bindings-python/MANIFEST.in deleted file mode 100644 index 676770a1f..000000000 --- a/bindings/nostr-ffi/bindings-python/MANIFEST.in +++ /dev/null @@ -1,3 +0,0 @@ -include ./src/nostr/libnostr_ffi.dylib -include ./src/nostr/libnostr_ffi.so -include ./src/nostr/nostr_ffi.dll diff --git a/bindings/nostr-ffi/bindings-python/README.md b/bindings/nostr-ffi/bindings-python/README.md deleted file mode 100644 index cc3351ae4..000000000 --- a/bindings/nostr-ffi/bindings-python/README.md +++ /dev/null @@ -1,47 +0,0 @@ -# Nostr - Python Package - -## Description - -Python bindings of [nostr](https://github.com/rust-nostr/nostr) library. - -If you're writing a typical Nostr client or bot, you may be interested in [nostr-sdk](https://pypi.org/project/nostr-sdk/). - -## Getting started - -```shell -pip install nostr-protocol -``` - -```python -from nostr_protocol import Keys, EventBuilder - -keys = Keys.generate() -print(keys.secret_key().to_bech32()) -print(keys.public_key().to_bech32()) - -print("Mining a POW text note...") -event = EventBuilder.text_note("Hello from Rust Nostr Python bindings!", []).to_pow_event(keys, 20) -print(event.as_json()) -``` - -More examples can be found in the [examples/](https://github.com/rust-nostr/nostr/tree/master/bindings/nostr-ffi/bindings-python/examples) directory. - -## Supported NIPs - -Look at - -## Book - -Learn more about `rust-nostr` at . - -## State - -**This library is in an ALPHA state**, things that are implemented generally work but the API will change in breaking ways. - -## Donations - -`rust-nostr` is free and open-source. This means we do not earn any revenue by selling it. Instead, we rely on your financial support. If you actively use any of the `rust-nostr` libs/software/services, then please [donate](https://rust-nostr.org/donate). - -## License - -This project is distributed under the MIT software license - see the [LICENSE](https://github.com/rust-nostr/nostr/tree/master/LICENSE) file for details \ No newline at end of file diff --git a/bindings/nostr-ffi/bindings-python/pyproject.toml b/bindings/nostr-ffi/bindings-python/pyproject.toml deleted file mode 100644 index 133d9fc92..000000000 --- a/bindings/nostr-ffi/bindings-python/pyproject.toml +++ /dev/null @@ -1,7 +0,0 @@ -[build-system] -requires = ["setuptools", "wheel"] - -[tool.pytest.ini_options] -pythonpath = [ - "." -] \ No newline at end of file diff --git a/bindings/nostr-ffi/bindings-python/requirements.txt b/bindings/nostr-ffi/bindings-python/requirements.txt deleted file mode 100644 index bd0cfaa7c..000000000 --- a/bindings/nostr-ffi/bindings-python/requirements.txt +++ /dev/null @@ -1,4 +0,0 @@ -semantic-version==2.9.0 -typing_extensions==4.0.1 -setuptools==70.0.0 -wheel==0.38.4 diff --git a/bindings/nostr-ffi/bindings-python/scripts/generate-linux-aarch64.sh b/bindings/nostr-ffi/bindings-python/scripts/generate-linux-aarch64.sh deleted file mode 100755 index 95dcfa168..000000000 --- a/bindings/nostr-ffi/bindings-python/scripts/generate-linux-aarch64.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail -python --version -pip install -r requirements.txt - -cd ../ - -echo "Generating native binaries..." -rustup target add aarch64-unknown-linux-gnu -CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc cargo build --release --target aarch64-unknown-linux-gnu - -echo "Generating nostr.py..." -cargo run -p uniffi-bindgen generate --library ../../target/aarch64-unknown-linux-gnu/release/libnostr_ffi.so --language python --no-format -o bindings-python/src/nostr/ - -echo "Copying linux libnostr_ffi.so..." -cp ../../target/aarch64-unknown-linux-gnu/release/libnostr_ffi.so bindings-python/src/nostr/ - -echo "All done!" diff --git a/bindings/nostr-ffi/bindings-python/scripts/generate-linux-x86_64.sh b/bindings/nostr-ffi/bindings-python/scripts/generate-linux-x86_64.sh deleted file mode 100644 index 2b92ed303..000000000 --- a/bindings/nostr-ffi/bindings-python/scripts/generate-linux-x86_64.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail -${PYBIN}/python --version -${PYBIN}/pip install -r requirements.txt - -echo "Generating native binaries..." -rustup target add x86_64-unknown-linux-gnu -cargo build --release --target x86_64-unknown-linux-gnu - -echo "Generating nostr.py..." -cd ../ -cargo run -p uniffi-bindgen generate --library ../../target/x86_64-unknown-linux-gnu/release/libnostr_ffi.so --language python --no-format -o bindings-python/src/nostr/ - -echo "Copying linux libnostr_ffi.so..." -cp ../../target/x86_64-unknown-linux-gnu/release/libnostr_ffi.so bindings-python/src/nostr/ - -echo "All done!" diff --git a/bindings/nostr-ffi/bindings-python/scripts/generate-macos-arm64.sh b/bindings/nostr-ffi/bindings-python/scripts/generate-macos-arm64.sh deleted file mode 100644 index 4540d1fcd..000000000 --- a/bindings/nostr-ffi/bindings-python/scripts/generate-macos-arm64.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail -python3 --version -pip install --user -r requirements.txt - -cd ../ - -echo "Generating native binaries..." -rustup target add aarch64-apple-darwin -cargo build --release --target aarch64-apple-darwin - -echo "Generating nostr.py..." -cargo run -p uniffi-bindgen generate --library ../../target/aarch64-apple-darwin/release/libnostr_ffi.dylib --language python --no-format -o bindings-python/src/nostr/ - -echo "Copying libraries libnostr_ffi.dylib..." -cp ../../target/aarch64-apple-darwin/release/libnostr_ffi.dylib bindings-python/src/nostr/ - -echo "All done!" diff --git a/bindings/nostr-ffi/bindings-python/scripts/generate-macos-x86_64.sh b/bindings/nostr-ffi/bindings-python/scripts/generate-macos-x86_64.sh deleted file mode 100644 index 2ab745e7c..000000000 --- a/bindings/nostr-ffi/bindings-python/scripts/generate-macos-x86_64.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail -python3 --version -pip install --user -r requirements.txt - -cd ../ - -echo "Generating native binaries..." -rustup target add x86_64-apple-darwin -cargo build --release --target x86_64-apple-darwin - -echo "Generating nostr.py..." -cargo run -p uniffi-bindgen generate --library ../../target/x86_64-apple-darwin/release/libnostr_ffi.dylib --language python --no-format -o bindings-python/src/nostr/ - -echo "Copying libraries libnostr_ffi.dylib..." -cp ../../target/x86_64-apple-darwin/release/libnostr_ffi.dylib bindings-python/src/nostr/ - -echo "All done!" diff --git a/bindings/nostr-ffi/bindings-python/scripts/generate-windows.sh b/bindings/nostr-ffi/bindings-python/scripts/generate-windows.sh deleted file mode 100644 index fc56a3870..000000000 --- a/bindings/nostr-ffi/bindings-python/scripts/generate-windows.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail -python3 --version -pip install --user -r requirements.txt - -cd ../ - -echo "Generating native binaries..." -rustup target add x86_64-pc-windows-msvc -cargo build --release --target x86_64-pc-windows-msvc - -echo "Generating nostr.py..." -cargo run -p uniffi-bindgen generate --library ../../target/x86_64-pc-windows-msvc/release/nostr_ffi.dll --language python --no-format -o bindings-python/src/nostr/ - -echo "Copying libraries nostr_ffi.dll..." -cp ../../target/x86_64-pc-windows-msvc/release/nostr_ffi.dll bindings-python/src/nostr/ - -echo "All done!" diff --git a/bindings/nostr-ffi/bindings-python/setup.py b/bindings/nostr-ffi/bindings-python/setup.py deleted file mode 100644 index 8ca11414f..000000000 --- a/bindings/nostr-ffi/bindings-python/setup.py +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env python - -from setuptools import setup -from pathlib import Path - -this_directory = Path(__file__).parent -long_description = (this_directory / "README.md").read_text() - -setup( - name='nostr-protocol', - version='0.35.0', - description="Nostr protocol implementation", - long_description=long_description, - long_description_content_type='text/markdown', - include_package_data=True, - zip_safe=False, - packages=['nostr_protocol'], - package_dir={'nostr_protocol': './src/nostr'}, - url="https://github.com/rust-nostr/nostr", - author="Yuki Kishimoto ", - license="MIT", - # This is required to ensure the library name includes the python version, abi, and platform tags - # See issue #350 for more information - has_ext_modules=lambda: True, -) diff --git a/bindings/nostr-ffi/bindings-python/src/nostr/__init__.py b/bindings/nostr-ffi/bindings-python/src/nostr/__init__.py deleted file mode 100644 index 86b391625..000000000 --- a/bindings/nostr-ffi/bindings-python/src/nostr/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from nostr_protocol.nostr_ffi import * diff --git a/bindings/nostr-ffi/bindings-swift/.gitignore b/bindings/nostr-ffi/bindings-swift/.gitignore deleted file mode 100644 index ec5d58614..000000000 --- a/bindings/nostr-ffi/bindings-swift/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -.swiftpm/ -.build/ -*.xcodeproj -Sources/ -**/Headers/*.h -**/nostrFFI.a diff --git a/bindings/nostr-ffi/bindings-swift/Package.swift b/bindings/nostr-ffi/bindings-swift/Package.swift deleted file mode 100644 index f01bcc703..000000000 --- a/bindings/nostr-ffi/bindings-swift/Package.swift +++ /dev/null @@ -1,21 +0,0 @@ -// swift-tools-version:5.5 -// The swift-tools-version declares the minimum version of Swift required to build this package. - -import PackageDescription - -let package = Package( - name: "nostr-swift", - platforms: [ - .macOS(.v12), - .iOS(.v14), - ], - products: [ - .library(name: "Nostr", targets: ["nostrFFI", "Nostr"]), - ], - dependencies: [], - targets: [ - .binaryTarget(name: "nostrFFI", path: "./nostrFFI.xcframework"), - .target(name: "Nostr", dependencies: ["nostrFFI"]), - .testTarget(name: "NostrTests", dependencies: ["Nostr"]), - ] -) diff --git a/bindings/nostr-ffi/bindings-swift/Tests/NostrTests/NostrTests.swift b/bindings/nostr-ffi/bindings-swift/Tests/NostrTests/NostrTests.swift deleted file mode 100644 index 2aecaf8e1..000000000 --- a/bindings/nostr-ffi/bindings-swift/Tests/NostrTests/NostrTests.swift +++ /dev/null @@ -1,6 +0,0 @@ -import XCTest -@testable import Nostr - -final class NostrTests: XCTestCase { - func testExample() throws {} -} diff --git a/bindings/nostr-ffi/bindings-swift/nostrFFI.xcframework/Info.plist b/bindings/nostr-ffi/bindings-swift/nostrFFI.xcframework/Info.plist deleted file mode 100644 index 90bcc1e9f..000000000 --- a/bindings/nostr-ffi/bindings-swift/nostrFFI.xcframework/Info.plist +++ /dev/null @@ -1,59 +0,0 @@ - - - - - AvailableLibraries - - - HeadersPath - Headers - LibraryIdentifier - macos-arm64_x86_64 - LibraryPath - nostrFFI.a - SupportedArchitectures - - arm64 - x86_64 - - SupportedPlatform - macos - - - HeadersPath - Headers - LibraryIdentifier - ios-arm64_x86_64-simulator - LibraryPath - nostrFFI.a - SupportedArchitectures - - arm64 - x86_64 - - SupportedPlatform - ios - SupportedPlatformVariant - simulator - - - HeadersPath - Headers - LibraryIdentifier - ios-arm64 - LibraryPath - nostrFFI.a - SupportedArchitectures - - arm64 - - SupportedPlatform - ios - - - CFBundlePackageType - XFWK - XCFrameworkFormatVersion - 1.0 - - diff --git a/bindings/nostr-ffi/bindings-swift/nostrFFI.xcframework/ios-arm64/Headers/module.modulemap b/bindings/nostr-ffi/bindings-swift/nostrFFI.xcframework/ios-arm64/Headers/module.modulemap deleted file mode 100644 index 4362a360e..000000000 --- a/bindings/nostr-ffi/bindings-swift/nostrFFI.xcframework/ios-arm64/Headers/module.modulemap +++ /dev/null @@ -1,4 +0,0 @@ -module nostrFFI { - header "nostrFFI.h" - export * -} diff --git a/bindings/nostr-ffi/bindings-swift/nostrFFI.xcframework/ios-arm64_x86_64-simulator/Headers/module.modulemap b/bindings/nostr-ffi/bindings-swift/nostrFFI.xcframework/ios-arm64_x86_64-simulator/Headers/module.modulemap deleted file mode 100644 index 4362a360e..000000000 --- a/bindings/nostr-ffi/bindings-swift/nostrFFI.xcframework/ios-arm64_x86_64-simulator/Headers/module.modulemap +++ /dev/null @@ -1,4 +0,0 @@ -module nostrFFI { - header "nostrFFI.h" - export * -} diff --git a/bindings/nostr-ffi/bindings-swift/nostrFFI.xcframework/macos-arm64_x86_64/Headers/module.modulemap b/bindings/nostr-ffi/bindings-swift/nostrFFI.xcframework/macos-arm64_x86_64/Headers/module.modulemap deleted file mode 100644 index 4362a360e..000000000 --- a/bindings/nostr-ffi/bindings-swift/nostrFFI.xcframework/macos-arm64_x86_64/Headers/module.modulemap +++ /dev/null @@ -1,4 +0,0 @@ -module nostrFFI { - header "nostrFFI.h" - export * -} diff --git a/bindings/nostr-ffi/build.rs b/bindings/nostr-ffi/build.rs deleted file mode 100644 index 399133a1f..000000000 --- a/bindings/nostr-ffi/build.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) 2022-2023 Yuki Kishimoto -// Copyright (c) 2023-2024 Rust Nostr Developers -// Distributed under the MIT software license - -use std::process::Command; - -fn main() { - if let Ok(output) = Command::new("git").args(["rev-parse", "HEAD"]).output() { - if let Ok(git_hash) = String::from_utf8(output.stdout) { - println!("cargo:rerun-if-changed={git_hash}"); - println!("cargo:rustc-env=GIT_HASH={git_hash}"); - } - } -} diff --git a/bindings/nostr-ffi/justfile b/bindings/nostr-ffi/justfile deleted file mode 100755 index 9818c5f4c..000000000 --- a/bindings/nostr-ffi/justfile +++ /dev/null @@ -1,149 +0,0 @@ -set windows-shell := ["powershell.exe", "-NoLogo", "-Command"] - -# Check if ANDROID_NDK_HOME env is set -[private] -ndk-home: - @if [ ! -d "${ANDROID_NDK_HOME}" ] ; then \ - echo "Error: Please, set the ANDROID_NDK_HOME env variable to point to your NDK folder" ; \ - exit 1 ; \ - fi - -# Check if ANDROID_SDK_ROOT env is set -[private] -sdk-root: - @if [ ! -d "${ANDROID_SDK_ROOT}" ] ; then \ - echo "Error: Please, set the ANDROID_SDK_ROOT env variable to point to your SDK folder" ; \ - exit 1 ; \ - fi - -# Get toolchain targets and required binaries for compilation -init: - rustup target add aarch64-apple-ios x86_64-apple-ios aarch64-apple-ios-sim - rustup target add aarch64-apple-darwin x86_64-apple-darwin - rustup target add aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android - #@if os() == "macos" { cargo install cargo-lipo } - cargo install cargo-lipo - cargo install cbindgen - cargo install cargo-ndk - -[private] -clean-android: - rm -rf ffi/android - rm -rf ffi/kotlin - -[private] -aarch64-linux-android: ndk-home - cargo ndk -t aarch64-linux-android -o ffi/kotlin/jniLibs build --release - -[private] -armv7-linux-androideabi: ndk-home - cargo ndk -t armv7-linux-androideabi -o ffi/kotlin/jniLibs build --release - -[private] -i686-linux-android: ndk-home - cargo ndk -t i686-linux-android -o ffi/kotlin/jniLibs build --release - -[private] -x86_64-linux-android: ndk-home - cargo ndk -t x86_64-linux-android -o ffi/kotlin/jniLibs build --release - -[private] -android: aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android - -kotlin: clean-android android - find ./ffi/kotlin/jniLibs -name libnostr_sdk_ffi.so -type f -delete - cargo run -p uniffi-bindgen generate --library ../../target/x86_64-linux-android/release/libnostr_ffi.so --language kotlin --no-format -o ffi/kotlin - -# Copy required modules and libs and assemble AAR -assemble-aar: - rm -rf bindings-android/lib/src/main/jniLibs - rm -rf bindings-android/lib/src/main/kotlin - cp -r ffi/kotlin/jniLibs bindings-android/lib/src/main - mkdir -p bindings-android/lib/src/main/kotlin/ - cp -r ffi/kotlin/rust bindings-android/lib/src/main/kotlin/ - cd bindings-android && ./gradlew assembleRelease - mkdir -p ffi/android - cp bindings-android/lib/build/outputs/aar/lib-release.aar ffi/android - -# Compile and build Android Archive (AAR) -bindings-android: sdk-root kotlin assemble-aar - -# Publish android bindings -[confirm] -publish-android: bindings-android - cd bindings-android && ./gradlew publishAndReleaseToMavenCentral --no-configuration-cache - -[private] -ios-universal: - mkdir -p ../../target/ios-universal/release - mkdir -p ../../target/ios-universal-sim/release - cargo build --release --target aarch64-apple-ios - cargo build --release --target x86_64-apple-ios - cargo build --release --target aarch64-apple-ios-sim - lipo -create -output ../../target/ios-universal/release/libnostr_ffi.a ../../target/aarch64-apple-ios/release/libnostr_ffi.a ../../target/x86_64-apple-ios/release/libnostr_ffi.a - lipo -create -output ../../target/ios-universal-sim/release/libnostr_ffi.a ../../target/aarch64-apple-ios-sim/release/libnostr_ffi.a ../../target/x86_64-apple-ios/release/libnostr_ffi.a - -[private] -darwin-universal: - mkdir -p ../../target/darwin-universal/release - cargo lipo --release --targets aarch64-apple-darwin - cargo lipo --release --targets x86_64-apple-darwin - lipo -create -output ../../target/darwin-universal/release/libnostr_ffi.dylib ../../target/aarch64-apple-darwin/release/libnostr_ffi.dylib ../../target/x86_64-apple-darwin/release/libnostr_ffi.dylib - lipo -create -output ../../target/darwin-universal/release/libnostr_ffi.a ../../target/aarch64-apple-darwin/release/libnostr_ffi.a ../../target/x86_64-apple-darwin/release/libnostr_ffi.a - -swift-ios: ios-universal - cargo run -p uniffi-bindgen generate --library ../../target/aarch64-apple-ios/release/libnostr_ffi.a --language swift -o ffi/swift-ios - cp ../../target/ios-universal/release/libnostr_ffi.a ffi/swift-ios - cd ffi/swift-ios && "swiftc" "-emit-module" "-module-name" "nostr_ffi" "-Xcc" "-fmodule-map-file={{invocation_directory()}}/ffi/swift-ios/nostrFFI.modulemap" "-I" "." "-L" "." "-lnostr_ffi" nostr_ffi.swift - -swift-darwin: darwin-universal - cargo run -p uniffi-bindgen generate --library ../../target/aarch64-apple-darwin/release/libnostr_ffi.a --language swift -o ffi/swift-darwin - cp ../../target/darwin-universal/release/libnostr_ffi.dylib ffi/swift-darwin - cd ffi/swift-darwin && "swiftc" "-emit-module" "-module-name" "nostr_ffi" "-Xcc" "-fmodule-map-file={{invocation_directory()}}/ffi/swift-darwin/nostrFFI.modulemap" "-I" "." "-L" "." "-lnostr_ffi" nostr_ffi.swift - -# Copy required modules and libs and assemble Swift Package -assemble-swift-package: - mkdir -p bindings-swift/Sources/Nostr - cargo run -p uniffi-bindgen generate --library ../../target/aarch64-apple-ios/release/libnostr_ffi.a --no-format --language swift --out-dir bindings-swift/Sources/Nostr - mv bindings-swift/Sources/Nostr/nostr_ffi.swift bindings-swift/Sources/Nostr/Nostr.swift - cp bindings-swift/Sources/Nostr/*.h bindings-swift/nostrFFI.xcframework/ios-arm64/Headers - cp bindings-swift/Sources/Nostr/*.h bindings-swift/nostrFFI.xcframework/ios-arm64_x86_64-simulator/Headers - cp bindings-swift/Sources/Nostr/*.h bindings-swift/nostrFFI.xcframework/macos-arm64_x86_64/Headers - cp ../../target/aarch64-apple-ios/release/libnostr_ffi.a bindings-swift/nostrFFI.xcframework/ios-arm64/nostrFFI.a - cp ../../target/ios-universal-sim/release/libnostr_ffi.a bindings-swift/nostrFFI.xcframework/ios-arm64_x86_64-simulator/nostrFFI.a - cp ../../target/darwin-universal/release/libnostr_ffi.a bindings-swift/nostrFFI.xcframework/macos-arm64_x86_64/nostrFFI.a - rm bindings-swift/Sources/Nostr/*.h - rm bindings-swift/Sources/Nostr/*.modulemap - -# Compile and build Swift Package -bindings-swift: ios-universal darwin-universal assemble-swift-package - -[linux] -python: - rm -rf bindings-python/dist - pip install -r bindings-python/requirements.txt - cargo build --release - cargo run -p uniffi-bindgen generate --library ../../target/release/libnostr_ffi.so --language python --no-format -o bindings-python/src/nostr/ - cp ../../target/release/libnostr_ffi.so bindings-python/src/nostr/ - cd bindings-python && python setup.py --verbose bdist_wheel - pip install ./bindings-python/dist/nostr_protocol*.whl --force-reinstall - -[macos] -python: - rm -rf bindings-python/dist - pip install -r bindings-python/requirements.txt - cargo build --release - cargo run -p uniffi-bindgen generate --library ../../target/release/libnostr_ffi.dylib --language python --no-format -o bindings-python/src/nostr/ - cp ../../target/release/libnostr_ffi.dylib bindings-python/src/nostr/ - cd bindings-python && python setup.py --verbose bdist_wheel - pip install ./bindings-python/dist/nostr_protocol*.whl --force-reinstall - -[windows] -python: - pip install -r bindings-python\requirements.txt - cargo build --release - cargo run -p uniffi-bindgen generate --library ..\..\target\release\nostr_ffi.dll --language python --no-format -o bindings-python\src\nostr\ - copy ..\..\target\release\nostr_ffi.dll bindings-python\src\nostr - del /F /Q bindings-python\dist\* 2>nul || exit /b 0 - cd bindings-python && python setup.py --verbose bdist_wheel - FOR %%i in (.\bindings-python\dist\*.whl) DO pip install %i --force-reinstall diff --git a/bindings/nostr-ffi/src/error.rs b/bindings/nostr-ffi/src/error.rs deleted file mode 100644 index 046174ed6..000000000 --- a/bindings/nostr-ffi/src/error.rs +++ /dev/null @@ -1,225 +0,0 @@ -// Copyright (c) 2022-2023 Yuki Kishimoto -// Copyright (c) 2023-2024 Rust Nostr Developers -// Distributed under the MIT software license - -use std::fmt; -use std::net::AddrParseError; - -use nostr::message::MessageHandleError; -use uniffi::Error; - -pub type Result = std::result::Result; - -#[derive(Debug, Error)] -#[uniffi(flat_error)] -pub enum NostrError { - Generic(String), -} - -impl std::error::Error for NostrError {} - -impl fmt::Display for NostrError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self { - Self::Generic(e) => write!(f, "{e}"), - } - } -} - -impl From for NostrError { - fn from(e: std::num::ParseIntError) -> NostrError { - Self::Generic(e.to_string()) - } -} - -impl From for NostrError { - fn from(e: std::char::ParseCharError) -> NostrError { - Self::Generic(e.to_string()) - } -} - -impl From for NostrError { - fn from(e: nostr::signer::SignerError) -> NostrError { - Self::Generic(e.to_string()) - } -} - -impl From for NostrError { - fn from(e: nostr::key::Error) -> NostrError { - Self::Generic(e.to_string()) - } -} - -impl From for NostrError { - fn from(e: nostr::key::vanity::Error) -> NostrError { - Self::Generic(e.to_string()) - } -} - -impl From for NostrError { - fn from(e: MessageHandleError) -> NostrError { - Self::Generic(e.to_string()) - } -} - -impl From for NostrError { - fn from(e: nostr::types::metadata::Error) -> NostrError { - Self::Generic(e.to_string()) - } -} - -impl From for NostrError { - fn from(e: nostr::event::Error) -> NostrError { - Self::Generic(e.to_string()) - } -} - -impl From for NostrError { - fn from(e: nostr::event::builder::Error) -> NostrError { - Self::Generic(e.to_string()) - } -} - -impl From for NostrError { - fn from(e: nostr::event::unsigned::Error) -> NostrError { - Self::Generic(e.to_string()) - } -} - -impl From for NostrError { - fn from(e: nostr::event::tag::Error) -> NostrError { - Self::Generic(e.to_string()) - } -} - -impl From for NostrError { - fn from(e: nostr::nips::nip01::Error) -> NostrError { - Self::Generic(e.to_string()) - } -} - -impl From for NostrError { - fn from(e: nostr::nips::nip04::Error) -> NostrError { - Self::Generic(e.to_string()) - } -} - -impl From for NostrError { - fn from(e: nostr::nips::nip05::Error) -> NostrError { - Self::Generic(e.to_string()) - } -} - -impl From for NostrError { - fn from(e: nostr::nips::nip06::Error) -> NostrError { - Self::Generic(e.to_string()) - } -} - -impl From for NostrError { - fn from(e: nostr::nips::nip11::Error) -> NostrError { - Self::Generic(e.to_string()) - } -} - -impl From for NostrError { - fn from(e: nostr::nips::nip19::Error) -> NostrError { - Self::Generic(e.to_string()) - } -} - -impl From for NostrError { - fn from(e: nostr::nips::nip21::Error) -> NostrError { - Self::Generic(e.to_string()) - } -} - -impl From for NostrError { - fn from(e: nostr::nips::nip26::Error) -> NostrError { - Self::Generic(e.to_string()) - } -} - -impl From for NostrError { - fn from(e: nostr::nips::nip44::Error) -> NostrError { - Self::Generic(e.to_string()) - } -} - -impl From for NostrError { - fn from(e: nostr::nips::nip46::Error) -> NostrError { - Self::Generic(e.to_string()) - } -} - -impl From for NostrError { - fn from(e: nostr::nips::nip47::Error) -> NostrError { - Self::Generic(e.to_string()) - } -} - -impl From for NostrError { - fn from(e: nostr::nips::nip49::Error) -> NostrError { - Self::Generic(e.to_string()) - } -} - -impl From for NostrError { - fn from(e: nostr::nips::nip53::Error) -> NostrError { - Self::Generic(e.to_string()) - } -} - -impl From for NostrError { - fn from(e: nostr::nips::nip57::Error) -> NostrError { - Self::Generic(e.to_string()) - } -} - -impl From for NostrError { - fn from(e: nostr::nips::nip59::Error) -> NostrError { - Self::Generic(e.to_string()) - } -} - -impl From for NostrError { - fn from(e: nostr::nips::nip90::Error) -> NostrError { - Self::Generic(e.to_string()) - } -} - -impl From for NostrError { - fn from(e: nostr::secp256k1::Error) -> NostrError { - Self::Generic(e.to_string()) - } -} - -impl From for NostrError { - fn from(e: nostr::types::url::ParseError) -> NostrError { - Self::Generic(e.to_string()) - } -} - -impl From for NostrError { - fn from(e: nostr::hashes::hex::HexToArrayError) -> NostrError { - Self::Generic(e.to_string()) - } -} - -impl From for NostrError { - fn from(e: nostr::serde_json::Error) -> NostrError { - Self::Generic(e.to_string()) - } -} - -impl From for NostrError { - fn from(e: nostr::event::id::Error) -> NostrError { - Self::Generic(e.to_string()) - } -} - -impl From for NostrError { - fn from(e: AddrParseError) -> NostrError { - Self::Generic(e.to_string()) - } -} diff --git a/bindings/nostr-ffi/src/lib.rs b/bindings/nostr-ffi/src/lib.rs deleted file mode 100644 index 0db018c58..000000000 --- a/bindings/nostr-ffi/src/lib.rs +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (c) 2022-2023 Yuki Kishimoto -// Copyright (c) 2023-2024 Rust Nostr Developers -// Distributed under the MIT software license - -//! Nostr FFI - -#![allow(clippy::new_without_default)] - -use uniffi::Object; - -mod error; -pub mod event; -pub mod helper; -pub mod key; -pub mod message; -pub mod nips; -pub mod signer; -pub mod types; -pub mod util; - -pub use crate::error::NostrError; -pub use crate::event::{Event, EventBuilder, EventId, Kind, KindEnum, Tag, TagKind, UnsignedEvent}; -pub use crate::key::{Keys, PublicKey, SecretKey}; -pub use crate::message::{ClientMessage, ClientMessageEnum, RelayMessage, RelayMessageEnum}; -pub use crate::nips::nip04::{nip04_decrypt, nip04_encrypt}; -pub use crate::nips::nip05::{get_nip05_profile, verify_nip05}; -pub use crate::nips::nip11::RelayInformationDocument; -pub use crate::nips::nip46::{NostrConnectMessage, NostrConnectMetadata, NostrConnectURI}; -pub use crate::nips::nip53::{Image, LiveEvent, LiveEventHost, LiveEventStatus, Person}; -pub use crate::nips::nip65::RelayMetadata; -pub use crate::nips::nip94::FileMetadata; -pub use crate::types::{ - Alphabet, Contact, Filter, ImageDimensions, Metadata, SingleLetterTag, Timestamp, -}; -pub use crate::util::{generate_shared_key, JsonValue}; - -#[derive(Object)] -pub struct NostrLibrary; - -#[uniffi::export] -impl NostrLibrary { - #[inline] - #[uniffi::constructor] - pub fn new() -> Self { - Self - } - - #[inline] - pub fn git_hash_version(&self) -> Option { - option_env!("GIT_HASH").map(|v| v.to_string()) - } -} - -uniffi::setup_scaffolding!(); diff --git a/bindings/nostr-ffi/uniffi.toml b/bindings/nostr-ffi/uniffi.toml deleted file mode 100644 index 385b700b1..000000000 --- a/bindings/nostr-ffi/uniffi.toml +++ /dev/null @@ -1,3 +0,0 @@ -[bindings.kotlin] -package_name = "rust.nostr.protocol" -android_cleaner = true \ No newline at end of file diff --git a/bindings/nostr-sdk-ffi/Cargo.toml b/bindings/nostr-sdk-ffi/Cargo.toml index 890c8604e..0b4e85098 100644 --- a/bindings/nostr-sdk-ffi/Cargo.toml +++ b/bindings/nostr-sdk-ffi/Cargo.toml @@ -16,8 +16,8 @@ ndb = ["nostr-sdk/ndb"] [dependencies] async-trait.workspace = true async-utility.workspace = true +nostr = { workspace = true, features = ["std", "all-nips"] } nostr-connect.workspace = true -nostr-ffi = { path = "../nostr-ffi" } nostr-relay-builder.workspace = true nostr-sdk = { workspace = true, default-features = false, features = ["all-nips", "tor"] } tracing = { workspace = true, features = ["std"] } @@ -26,3 +26,6 @@ uniffi = { workspace = true, features = ["tokio"] } [target.'cfg(target_os = "android")'.dependencies] paranoid-android = "0.2" + +[dev-dependencies] +uniffi = { workspace = true, features = ["bindgen-tests"] } diff --git a/bindings/nostr-sdk-ffi/bindings-python/README.md b/bindings/nostr-sdk-ffi/bindings-python/README.md index b8049b7e7..1c5c8baa0 100644 --- a/bindings/nostr-sdk-ffi/bindings-python/README.md +++ b/bindings/nostr-sdk-ffi/bindings-python/README.md @@ -73,10 +73,7 @@ async def main(): asyncio.run(main()) ``` -More examples can be found at: - -* https://github.com/rust-nostr/nostr/tree/master/bindings/nostr-ffi/bindings-python/examples -* https://github.com/rust-nostr/nostr/tree/master/bindings/nostr-sdk-ffi/bindings-python/examples +More examples can be found [here](https://github.com/rust-nostr/nostr/tree/master/bindings/nostr-sdk-ffi/bindings-python/examples). ## Supported NIPs diff --git a/bindings/nostr-ffi/bindings-python/examples/event_builder.py b/bindings/nostr-sdk-ffi/bindings-python/examples/event_builder.py similarity index 94% rename from bindings/nostr-ffi/bindings-python/examples/event_builder.py rename to bindings/nostr-sdk-ffi/bindings-python/examples/event_builder.py index 58232a09f..de8d000fd 100644 --- a/bindings/nostr-ffi/bindings-python/examples/event_builder.py +++ b/bindings/nostr-sdk-ffi/bindings-python/examples/event_builder.py @@ -1,5 +1,5 @@ import asyncio -from nostr_protocol import Keys, EventBuilder, Kind +from nostr_sdk import Keys, EventBuilder, Kind async def main(): diff --git a/bindings/nostr-ffi/bindings-python/examples/filters.py b/bindings/nostr-sdk-ffi/bindings-python/examples/filters.py similarity index 79% rename from bindings/nostr-ffi/bindings-python/examples/filters.py rename to bindings/nostr-sdk-ffi/bindings-python/examples/filters.py index 22f777042..2f29f69aa 100644 --- a/bindings/nostr-ffi/bindings-python/examples/filters.py +++ b/bindings/nostr-sdk-ffi/bindings-python/examples/filters.py @@ -1,4 +1,4 @@ -from nostr_protocol import Filter, Alphabet, Keys, SingleLetterTag, Kind, KindEnum +from nostr_sdk import Filter, Alphabet, Keys, SingleLetterTag, Kind, KindEnum keys = Keys.generate() diff --git a/bindings/nostr-ffi/bindings-python/examples/git_version.py b/bindings/nostr-sdk-ffi/bindings-python/examples/git_version.py similarity index 60% rename from bindings/nostr-ffi/bindings-python/examples/git_version.py rename to bindings/nostr-sdk-ffi/bindings-python/examples/git_version.py index 8df462e75..40c7685a3 100644 --- a/bindings/nostr-ffi/bindings-python/examples/git_version.py +++ b/bindings/nostr-sdk-ffi/bindings-python/examples/git_version.py @@ -1,4 +1,4 @@ -from nostr_protocol import NostrLibrary +from nostr_sdk import NostrLibrary git_hash = NostrLibrary().git_hash_version() print(git_hash) diff --git a/bindings/nostr-ffi/bindings-python/examples/nip57.py b/bindings/nostr-sdk-ffi/bindings-python/examples/nip57.py similarity index 82% rename from bindings/nostr-ffi/bindings-python/examples/nip57.py rename to bindings/nostr-sdk-ffi/bindings-python/examples/nip57.py index aa5f28675..99a831b67 100644 --- a/bindings/nostr-ffi/bindings-python/examples/nip57.py +++ b/bindings/nostr-sdk-ffi/bindings-python/examples/nip57.py @@ -1,4 +1,4 @@ -from nostr_protocol import Keys, Event, ZapRequestData, PublicKey, SecretKey, EventBuilder, nip57_anonymous_zap_request, nip57_private_zap_request, nip57_decrypt_private_zap_message +from nostr_sdk import Keys, Event, ZapRequestData, PublicKey, SecretKey, EventBuilder, nip57_anonymous_zap_request, nip57_private_zap_request, nip57_decrypt_private_zap_message secret_key = SecretKey.from_hex("6b911fd37cdf5c81d4c0adb1ab7fa822ed253ab0ad9aa18d77257c88b29b718e") keys = Keys(secret_key) diff --git a/bindings/nostr-ffi/bindings-python/examples/tags.py b/bindings/nostr-sdk-ffi/bindings-python/examples/tags.py similarity index 88% rename from bindings/nostr-ffi/bindings-python/examples/tags.py rename to bindings/nostr-sdk-ffi/bindings-python/examples/tags.py index d7f9fa788..ed72c7bce 100644 --- a/bindings/nostr-ffi/bindings-python/examples/tags.py +++ b/bindings/nostr-sdk-ffi/bindings-python/examples/tags.py @@ -1,4 +1,4 @@ -from nostr_protocol import Keys, EventBuilder, PublicKey, Tag, TagEnum +from nostr_sdk import Keys, EventBuilder, PublicKey, Tag, TagEnum keys = Keys.generate() diff --git a/bindings/nostr-sdk-ffi/bindings-python/src/nostr-sdk/__init__.py b/bindings/nostr-sdk-ffi/bindings-python/src/nostr-sdk/__init__.py index 300411ef8..f2d5c77ff 100644 --- a/bindings/nostr-sdk-ffi/bindings-python/src/nostr-sdk/__init__.py +++ b/bindings/nostr-sdk-ffi/bindings-python/src/nostr-sdk/__init__.py @@ -1,2 +1 @@ -from nostr_sdk.nostr_ffi import * from nostr_sdk.nostr_sdk_ffi import * \ No newline at end of file diff --git a/bindings/nostr-sdk-ffi/build.rs b/bindings/nostr-sdk-ffi/build.rs index a4e1c45f8..c9df5e2ec 100644 --- a/bindings/nostr-sdk-ffi/build.rs +++ b/bindings/nostr-sdk-ffi/build.rs @@ -2,42 +2,50 @@ // Copyright (c) 2023-2024 Rust Nostr Developers // Distributed under the MIT software license -use std::env; -use std::path::Path; +// use std::env; +// use std::path::Path; +use std::process::Command; -const DEFAULT_CLANG_VERSION: &str = "17"; +// const DEFAULT_CLANG_VERSION: &str = "17"; fn main() { - setup_x86_64_android_workaround(); -} - -/// Adds a temporary workaround for an issue with the Rust compiler and Android -/// in x86_64 devices: https://github.com/rust-lang/rust/issues/109717. -/// The workaround comes from: https://github.com/mozilla/application-services/pull/5442 -fn setup_x86_64_android_workaround() { - let target_os = env::var("CARGO_CFG_TARGET_OS").expect("CARGO_CFG_TARGET_OS not set"); - let target_arch = env::var("CARGO_CFG_TARGET_ARCH").expect("CARGO_CFG_TARGET_ARCH not set"); - if target_arch == "x86_64" && target_os == "android" { - let android_ndk_home = env::var("ANDROID_NDK_HOME").expect("ANDROID_NDK_HOME not set"); - let build_os = match env::consts::OS { - "linux" => "linux", - "macos" => "darwin", - "windows" => "windows", - _ => panic!( - "Unsupported OS. You must use either Linux, MacOS or Windows to build the crate." - ), - }; - let clang_version = - env::var("NDK_CLANG_VERSION").unwrap_or_else(|_| DEFAULT_CLANG_VERSION.to_owned()); - let linux_x86_64_lib_dir = format!( - "toolchains/llvm/prebuilt/{build_os}-x86_64/lib/clang/{clang_version}/lib/linux/" - ); - let linkpath = format!("{android_ndk_home}/{linux_x86_64_lib_dir}"); - if Path::new(&linkpath).exists() { - println!("cargo:rustc-link-search={android_ndk_home}/{linux_x86_64_lib_dir}"); - println!("cargo:rustc-link-lib=static=clang_rt.builtins-x86_64-android"); - } else { - panic!("Path {linkpath} not exists"); + if let Ok(output) = Command::new("git").args(["rev-parse", "HEAD"]).output() { + if let Ok(git_hash) = String::from_utf8(output.stdout) { + println!("cargo:rerun-if-changed={git_hash}"); + println!("cargo:rustc-env=GIT_HASH={git_hash}"); } } + + // setup_x86_64_android_workaround(); } + +// /// Adds a temporary workaround for an issue with the Rust compiler and Android +// /// in x86_64 devices: https://github.com/rust-lang/rust/issues/109717. +// /// The workaround comes from: https://github.com/mozilla/application-services/pull/5442 +// fn setup_x86_64_android_workaround() { +// let target_os = env::var("CARGO_CFG_TARGET_OS").expect("CARGO_CFG_TARGET_OS not set"); +// let target_arch = env::var("CARGO_CFG_TARGET_ARCH").expect("CARGO_CFG_TARGET_ARCH not set"); +// if target_arch == "x86_64" && target_os == "android" { +// let android_ndk_home = env::var("ANDROID_NDK_HOME").expect("ANDROID_NDK_HOME not set"); +// let build_os = match env::consts::OS { +// "linux" => "linux", +// "macos" => "darwin", +// "windows" => "windows", +// _ => panic!( +// "Unsupported OS. You must use either Linux, MacOS or Windows to build the crate." +// ), +// }; +// let clang_version = +// env::var("NDK_CLANG_VERSION").unwrap_or_else(|_| DEFAULT_CLANG_VERSION.to_owned()); +// let linux_x86_64_lib_dir = format!( +// "toolchains/llvm/prebuilt/{build_os}-x86_64/lib/clang/{clang_version}/lib/linux/" +// ); +// let linkpath = format!("{android_ndk_home}/{linux_x86_64_lib_dir}"); +// if Path::new(&linkpath).exists() { +// println!("cargo:rustc-link-search={android_ndk_home}/{linux_x86_64_lib_dir}"); +// println!("cargo:rustc-link-lib=static=clang_rt.builtins-x86_64-android"); +// } else { +// panic!("Path {linkpath} not exists"); +// } +// } +// } diff --git a/bindings/nostr-sdk-ffi/justfile b/bindings/nostr-sdk-ffi/justfile index 85b95bb4e..2e9200589 100755 --- a/bindings/nostr-sdk-ffi/justfile +++ b/bindings/nostr-sdk-ffi/justfile @@ -124,8 +124,8 @@ python: rm -rf bindings-python/dist pip install -r bindings-python/requirements.txt cargo build --release - cargo run -p uniffi-bindgen generate --library ../../target/release/libnostr_sdk_ffi.so --language python --no-format -o bindings-python/src/nostr-sdk/ - cp ../../target/release/libnostr_sdk_ffi.so bindings-python/src/nostr-sdk/ + cargo run -p uniffi-bindgen generate --library ../../target/x86_64-unknown-linux-gnu/release/libnostr_sdk_ffi.so --language python --no-format -o bindings-python/src/nostr-sdk/ + cp ../../target/x86_64-unknown-linux-gnu/release/libnostr_sdk_ffi.so bindings-python/src/nostr-sdk/ cd bindings-python && python setup.py --verbose bdist_wheel pip install ./bindings-python/dist/nostr_sdk*.whl --force-reinstall diff --git a/bindings/nostr-sdk-ffi/src/client/builder.rs b/bindings/nostr-sdk-ffi/src/client/builder.rs index 00484044c..6a1178f4b 100644 --- a/bindings/nostr-sdk-ffi/src/client/builder.rs +++ b/bindings/nostr-sdk-ffi/src/client/builder.rs @@ -5,8 +5,6 @@ use std::ops::Deref; use std::sync::Arc; -use nostr_ffi::helper::unwrap_or_clone_arc; -use nostr_ffi::signer::{NostrSigner, NostrSignerFFI2Rust}; use nostr_sdk::database::DynNostrDatabase; use nostr_sdk::zapper::DynNostrZapper; use uniffi::Object; @@ -14,6 +12,8 @@ use uniffi::Object; use super::zapper::NostrZapper; use super::{Client, ClientSdk, Options}; use crate::database::NostrDatabase; +use crate::protocol::helper::unwrap_or_clone_arc; +use crate::protocol::signer::{NostrSigner, NostrSignerFFI2Rust}; #[derive(Clone, Default, Object)] pub struct ClientBuilder { diff --git a/bindings/nostr-sdk-ffi/src/client/mod.rs b/bindings/nostr-sdk-ffi/src/client/mod.rs index 8c1eceabd..1074dc3b5 100644 --- a/bindings/nostr-sdk-ffi/src/client/mod.rs +++ b/bindings/nostr-sdk-ffi/src/client/mod.rs @@ -7,12 +7,6 @@ use std::ops::Deref; use std::sync::Arc; use std::time::Duration; -use nostr_ffi::nips::nip59::UnwrappedGift; -use nostr_ffi::signer::{NostrSigner, NostrSignerFFI2Rust, NostrSignerRust2FFI}; -use nostr_ffi::{ - ClientMessage, Event, EventBuilder, EventId, FileMetadata, Filter, Metadata, PublicKey, - Timestamp, -}; use nostr_sdk::client::Client as ClientSdk; use nostr_sdk::pool::RelayPoolNotification as RelayPoolNotificationSdk; use nostr_sdk::{SubscriptionId, UncheckedUrl}; @@ -29,6 +23,12 @@ use crate::database::events::Events; use crate::error::Result; use crate::pool::result::{Output, ReconciliationOutput, SendEventOutput, SubscribeOutput}; use crate::pool::RelayPool; +use crate::protocol::nips::nip59::UnwrappedGift; +use crate::protocol::signer::{NostrSigner, NostrSignerFFI2Rust, NostrSignerRust2FFI}; +use crate::protocol::{ + ClientMessage, Event, EventBuilder, EventId, FileMetadata, Filter, Metadata, PublicKey, + Timestamp, +}; use crate::relay::options::{SubscribeAutoCloseOptions, SyncOptions}; use crate::relay::RelayFiltering; use crate::{HandleNotification, NostrDatabase, Relay}; diff --git a/bindings/nostr-sdk-ffi/src/client/options.rs b/bindings/nostr-sdk-ffi/src/client/options.rs index 18f0cefca..d8c8c0de3 100644 --- a/bindings/nostr-sdk-ffi/src/client/options.rs +++ b/bindings/nostr-sdk-ffi/src/client/options.rs @@ -7,12 +7,12 @@ use std::ops::Deref; use std::sync::Arc; use std::time::Duration; -use nostr_ffi::helper::unwrap_or_clone_arc; use nostr_sdk::client::options; use nostr_sdk::pool; use uniffi::{Enum, Object}; use crate::error::Result; +use crate::protocol::helper::unwrap_or_clone_arc; use crate::relay::{ConnectionMode, RelayFilteringMode, RelayLimits}; #[derive(Clone, Object)] diff --git a/bindings/nostr-sdk-ffi/src/client/zapper.rs b/bindings/nostr-sdk-ffi/src/client/zapper.rs index ecec087b2..54af7d6a4 100644 --- a/bindings/nostr-sdk-ffi/src/client/zapper.rs +++ b/bindings/nostr-sdk-ffi/src/client/zapper.rs @@ -5,14 +5,14 @@ use core::ops::Deref; use std::sync::Arc; -use nostr_ffi::helper::unwrap_or_clone_arc; -use nostr_ffi::nips::nip57::ZapType; -use nostr_ffi::{EventId, PublicKey}; use nostr_sdk::zapper::{DynNostrZapper, IntoNostrZapper}; use nostr_sdk::{client, nwc}; use uniffi::Object; use crate::nwc::NWC; +use crate::protocol::helper::unwrap_or_clone_arc; +use crate::protocol::nips::nip57::ZapType; +use crate::protocol::{EventId, PublicKey}; /// Zap entity #[derive(Debug, PartialEq, Eq, Hash, Object)] diff --git a/bindings/nostr-sdk-ffi/src/connect.rs b/bindings/nostr-sdk-ffi/src/connect.rs index 33cb34a0f..ff4450d4c 100644 --- a/bindings/nostr-sdk-ffi/src/connect.rs +++ b/bindings/nostr-sdk-ffi/src/connect.rs @@ -7,14 +7,14 @@ use std::sync::Arc; use std::time::Duration; use nostr_connect::{client, signer}; -use nostr_ffi::nips::nip46::{Nip46Request, NostrConnectURI}; -use nostr_ffi::signer::NostrSigner; -use nostr_ffi::{Event, Keys, NostrError, PublicKey, SecretKey, UnsignedEvent}; use nostr_sdk::nostr::nips::nip46::Request; use nostr_sdk::signer::NostrSigner as _; use uniffi::Object; use crate::error::Result; +use crate::protocol::nips::nip46::{Nip46Request, NostrConnectURI}; +use crate::protocol::signer::NostrSigner; +use crate::protocol::{Event, Keys, PublicKey, SecretKey, UnsignedEvent}; use crate::relay::RelayOptions; #[derive(Object)] @@ -79,14 +79,11 @@ impl NostrConnect { #[uniffi::export] #[async_trait::async_trait] impl NostrSigner for NostrConnect { - async fn get_public_key(&self) -> Result>, NostrError> { + async fn get_public_key(&self) -> Result>> { Ok(Some(Arc::new(self.inner.get_public_key().await?.into()))) } - async fn sign_event( - &self, - unsigned: Arc, - ) -> Result>, NostrError> { + async fn sign_event(&self, unsigned: Arc) -> Result>> { Ok(Some(Arc::new( self.inner .sign_event(unsigned.as_ref().deref().clone()) @@ -95,11 +92,7 @@ impl NostrSigner for NostrConnect { ))) } - async fn nip04_encrypt( - &self, - public_key: Arc, - content: String, - ) -> Result { + async fn nip04_encrypt(&self, public_key: Arc, content: String) -> Result { Ok(self .inner .nip04_encrypt(public_key.as_ref().deref(), &content) @@ -110,29 +103,21 @@ impl NostrSigner for NostrConnect { &self, public_key: Arc, encrypted_content: String, - ) -> Result { + ) -> Result { Ok(self .inner .nip04_decrypt(public_key.as_ref().deref(), &encrypted_content) .await?) } - async fn nip44_encrypt( - &self, - public_key: Arc, - content: String, - ) -> Result { + async fn nip44_encrypt(&self, public_key: Arc, content: String) -> Result { Ok(self .inner .nip44_encrypt(public_key.as_ref().deref(), &content) .await?) } - async fn nip44_decrypt( - &self, - public_key: Arc, - payload: String, - ) -> Result { + async fn nip44_decrypt(&self, public_key: Arc, payload: String) -> Result { Ok(self .inner .nip44_decrypt(public_key.as_ref().deref(), &payload) diff --git a/bindings/nostr-sdk-ffi/src/database/custom.rs b/bindings/nostr-sdk-ffi/src/database/custom.rs index 7d1cd3ace..494162a43 100644 --- a/bindings/nostr-sdk-ffi/src/database/custom.rs +++ b/bindings/nostr-sdk-ffi/src/database/custom.rs @@ -5,12 +5,12 @@ use std::fmt; use std::sync::Arc; -use nostr_ffi::nips::nip01::Coordinate; -use nostr_ffi::{Event, EventId, Filter, Timestamp}; use nostr_sdk::database; use uniffi::Enum; use crate::error::Result; +use crate::protocol::nips::nip01::Coordinate; +use crate::protocol::{Event, EventId, Filter, Timestamp}; #[derive(Enum)] pub enum DatabaseEventStatus { diff --git a/bindings/nostr-sdk-ffi/src/database/events.rs b/bindings/nostr-sdk-ffi/src/database/events.rs index a5098f807..f6fb8356a 100644 --- a/bindings/nostr-sdk-ffi/src/database/events.rs +++ b/bindings/nostr-sdk-ffi/src/database/events.rs @@ -5,10 +5,11 @@ use std::ops::Deref; use std::sync::Arc; -use nostr_ffi::Event; use nostr_sdk::database; use uniffi::Object; +use crate::protocol::Event; + #[derive(Clone, Object)] pub struct Events { inner: database::Events, diff --git a/bindings/nostr-sdk-ffi/src/database/mod.rs b/bindings/nostr-sdk-ffi/src/database/mod.rs index 2524e1a79..af4e5a388 100644 --- a/bindings/nostr-sdk-ffi/src/database/mod.rs +++ b/bindings/nostr-sdk-ffi/src/database/mod.rs @@ -5,7 +5,6 @@ use std::ops::Deref; use std::sync::Arc; -use nostr_ffi::{Event, EventId, Filter, PublicKey}; use nostr_sdk::database::{DynNostrDatabase, IntoNostrDatabase, NostrDatabaseExt}; #[cfg(feature = "ndb")] use nostr_sdk::NdbDatabase; @@ -19,6 +18,7 @@ pub mod events; use self::custom::{CustomNostrDatabase, IntermediateCustomNostrDatabase}; use crate::error::Result; use crate::profile::Profile; +use crate::protocol::{Event, EventId, Filter, PublicKey}; #[derive(Object)] pub struct NostrDatabase { diff --git a/bindings/nostr-sdk-ffi/src/error.rs b/bindings/nostr-sdk-ffi/src/error.rs index a6db995fe..7a5871da7 100644 --- a/bindings/nostr-sdk-ffi/src/error.rs +++ b/bindings/nostr-sdk-ffi/src/error.rs @@ -5,6 +5,7 @@ use std::fmt; use std::net::AddrParseError; +use nostr::message::MessageHandleError; use tracing::subscriber::SetGlobalDefaultError; use uniffi::Error; @@ -26,38 +27,194 @@ impl fmt::Display for NostrSdkError { } } -impl From for NostrSdkError { - fn from(e: nostr_ffi::NostrError) -> NostrSdkError { +impl From for NostrSdkError { + fn from(e: std::num::ParseIntError) -> NostrSdkError { Self::Generic(e.to_string()) } } -impl From for NostrSdkError { - fn from(e: nostr_sdk::nips::nip59::Error) -> NostrSdkError { +impl From for NostrSdkError { + fn from(e: std::char::ParseCharError) -> NostrSdkError { Self::Generic(e.to_string()) } } -impl From for NostrSdkError { - fn from(e: SetGlobalDefaultError) -> NostrSdkError { +impl From for NostrSdkError { + fn from(e: nostr::signer::SignerError) -> NostrSdkError { Self::Generic(e.to_string()) } } -impl From for NostrSdkError { - fn from(e: nostr_sdk::client::Error) -> NostrSdkError { +impl From for NostrSdkError { + fn from(e: nostr::key::Error) -> NostrSdkError { Self::Generic(e.to_string()) } } -impl From for NostrSdkError { - fn from(e: nostr_sdk::pool::relay::Error) -> NostrSdkError { +impl From for NostrSdkError { + fn from(e: nostr::key::vanity::Error) -> NostrSdkError { Self::Generic(e.to_string()) } } -impl From for NostrSdkError { - fn from(e: nostr_sdk::pool::pool::Error) -> NostrSdkError { +impl From for NostrSdkError { + fn from(e: MessageHandleError) -> NostrSdkError { + Self::Generic(e.to_string()) + } +} + +impl From for NostrSdkError { + fn from(e: nostr::types::metadata::Error) -> NostrSdkError { + Self::Generic(e.to_string()) + } +} + +impl From for NostrSdkError { + fn from(e: nostr::event::Error) -> NostrSdkError { + Self::Generic(e.to_string()) + } +} + +impl From for NostrSdkError { + fn from(e: nostr::event::builder::Error) -> NostrSdkError { + Self::Generic(e.to_string()) + } +} + +impl From for NostrSdkError { + fn from(e: nostr::event::unsigned::Error) -> NostrSdkError { + Self::Generic(e.to_string()) + } +} + +impl From for NostrSdkError { + fn from(e: nostr::event::tag::Error) -> NostrSdkError { + Self::Generic(e.to_string()) + } +} + +impl From for NostrSdkError { + fn from(e: nostr::nips::nip01::Error) -> NostrSdkError { + Self::Generic(e.to_string()) + } +} + +impl From for NostrSdkError { + fn from(e: nostr::nips::nip04::Error) -> NostrSdkError { + Self::Generic(e.to_string()) + } +} + +impl From for NostrSdkError { + fn from(e: nostr::nips::nip05::Error) -> NostrSdkError { + Self::Generic(e.to_string()) + } +} + +impl From for NostrSdkError { + fn from(e: nostr::nips::nip06::Error) -> NostrSdkError { + Self::Generic(e.to_string()) + } +} + +impl From for NostrSdkError { + fn from(e: nostr::nips::nip11::Error) -> NostrSdkError { + Self::Generic(e.to_string()) + } +} + +impl From for NostrSdkError { + fn from(e: nostr::nips::nip19::Error) -> NostrSdkError { + Self::Generic(e.to_string()) + } +} + +impl From for NostrSdkError { + fn from(e: nostr::nips::nip21::Error) -> NostrSdkError { + Self::Generic(e.to_string()) + } +} + +impl From for NostrSdkError { + fn from(e: nostr::nips::nip26::Error) -> NostrSdkError { + Self::Generic(e.to_string()) + } +} + +impl From for NostrSdkError { + fn from(e: nostr::nips::nip44::Error) -> NostrSdkError { + Self::Generic(e.to_string()) + } +} + +impl From for NostrSdkError { + fn from(e: nostr::nips::nip46::Error) -> NostrSdkError { + Self::Generic(e.to_string()) + } +} + +impl From for NostrSdkError { + fn from(e: nostr::nips::nip47::Error) -> NostrSdkError { + Self::Generic(e.to_string()) + } +} + +impl From for NostrSdkError { + fn from(e: nostr::nips::nip49::Error) -> NostrSdkError { + Self::Generic(e.to_string()) + } +} + +impl From for NostrSdkError { + fn from(e: nostr::nips::nip53::Error) -> NostrSdkError { + Self::Generic(e.to_string()) + } +} + +impl From for NostrSdkError { + fn from(e: nostr::nips::nip57::Error) -> NostrSdkError { + Self::Generic(e.to_string()) + } +} + +impl From for NostrSdkError { + fn from(e: nostr::nips::nip59::Error) -> NostrSdkError { + Self::Generic(e.to_string()) + } +} + +impl From for NostrSdkError { + fn from(e: nostr::nips::nip90::Error) -> NostrSdkError { + Self::Generic(e.to_string()) + } +} + +impl From for NostrSdkError { + fn from(e: nostr::secp256k1::Error) -> NostrSdkError { + Self::Generic(e.to_string()) + } +} + +impl From for NostrSdkError { + fn from(e: nostr::types::url::ParseError) -> NostrSdkError { + Self::Generic(e.to_string()) + } +} + +impl From for NostrSdkError { + fn from(e: nostr::hashes::hex::HexToArrayError) -> NostrSdkError { + Self::Generic(e.to_string()) + } +} + +impl From for NostrSdkError { + fn from(e: nostr::serde_json::Error) -> NostrSdkError { + Self::Generic(e.to_string()) + } +} + +impl From for NostrSdkError { + fn from(e: nostr::event::id::Error) -> NostrSdkError { Self::Generic(e.to_string()) } } @@ -68,20 +225,32 @@ impl From for NostrSdkError { } } -impl From for NostrSdkError { - fn from(e: nostr_sdk::types::url::ParseError) -> NostrSdkError { +impl From for NostrSdkError { + fn from(e: SetGlobalDefaultError) -> NostrSdkError { Self::Generic(e.to_string()) } } -impl From for NostrSdkError { - fn from(e: nostr_sdk::database::DatabaseError) -> NostrSdkError { +impl From for NostrSdkError { + fn from(e: nostr_sdk::client::Error) -> NostrSdkError { + Self::Generic(e.to_string()) + } +} + +impl From for NostrSdkError { + fn from(e: nostr_sdk::pool::relay::Error) -> NostrSdkError { Self::Generic(e.to_string()) } } -impl From for NostrSdkError { - fn from(e: nostr_sdk::signer::SignerError) -> NostrSdkError { +impl From for NostrSdkError { + fn from(e: nostr_sdk::pool::pool::Error) -> NostrSdkError { + Self::Generic(e.to_string()) + } +} + +impl From for NostrSdkError { + fn from(e: nostr_sdk::database::DatabaseError) -> NostrSdkError { Self::Generic(e.to_string()) } } diff --git a/bindings/nostr-sdk-ffi/src/lib.rs b/bindings/nostr-sdk-ffi/src/lib.rs index 6c63749b1..d5c50da9d 100644 --- a/bindings/nostr-sdk-ffi/src/lib.rs +++ b/bindings/nostr-sdk-ffi/src/lib.rs @@ -4,7 +4,7 @@ #![allow(clippy::new_without_default)] -nostr_ffi::uniffi_reexport_scaffolding!(); +use uniffi::Object; pub mod client; pub mod connect; @@ -17,6 +17,7 @@ pub mod notifications; pub mod nwc; pub mod pool; pub mod profile; +pub mod protocol; pub mod relay; pub use self::client::{Client, ClientBuilder, Options}; @@ -26,4 +27,21 @@ pub use self::logger::{init_logger, LogLevel}; pub use self::notifications::HandleNotification; pub use self::relay::{Relay, RelayConnectionStats, RelayStatus}; +#[derive(Object)] +pub struct NostrLibrary; + +#[uniffi::export] +impl NostrLibrary { + #[inline] + #[uniffi::constructor] + pub fn new() -> Self { + Self + } + + #[inline] + pub fn git_hash_version(&self) -> Option { + option_env!("GIT_HASH").map(|v| v.to_string()) + } +} + uniffi::setup_scaffolding!(); diff --git a/bindings/nostr-sdk-ffi/src/logger.rs b/bindings/nostr-sdk-ffi/src/logger.rs index 9c2e2857b..d47ee94ea 100644 --- a/bindings/nostr-sdk-ffi/src/logger.rs +++ b/bindings/nostr-sdk-ffi/src/logger.rs @@ -2,7 +2,6 @@ // Copyright (c) 2023-2024 Rust Nostr Developers // Distributed under the MIT software license -use nostr_ffi::NostrLibrary; use tracing::Level; #[cfg(any(target_os = "android", target_os = "ios"))] use tracing_subscriber::filter::Targets; @@ -16,6 +15,8 @@ use tracing_subscriber::util::SubscriberInitExt; use tracing_subscriber::Layer; use uniffi::Enum; +use crate::NostrLibrary; + #[derive(Enum)] pub enum LogLevel { Error, diff --git a/bindings/nostr-sdk-ffi/src/negentropy.rs b/bindings/nostr-sdk-ffi/src/negentropy.rs index 9d2a6e1fa..36c27236c 100644 --- a/bindings/nostr-sdk-ffi/src/negentropy.rs +++ b/bindings/nostr-sdk-ffi/src/negentropy.rs @@ -4,9 +4,10 @@ use std::sync::Arc; -use nostr_ffi::{EventId, Timestamp}; use uniffi::Record; +use crate::protocol::{EventId, Timestamp}; + #[derive(Record)] pub struct NegentropyItem { pub id: Arc, diff --git a/bindings/nostr-sdk-ffi/src/notifications.rs b/bindings/nostr-sdk-ffi/src/notifications.rs index 05c6a9a54..cf2b03bf5 100644 --- a/bindings/nostr-sdk-ffi/src/notifications.rs +++ b/bindings/nostr-sdk-ffi/src/notifications.rs @@ -4,7 +4,7 @@ use std::sync::Arc; -use nostr_ffi::{Event, RelayMessage}; +use crate::protocol::{Event, RelayMessage}; #[uniffi::export(with_foreign)] #[async_trait::async_trait] diff --git a/bindings/nostr-sdk-ffi/src/nwc/mod.rs b/bindings/nostr-sdk-ffi/src/nwc/mod.rs index f4e2e9235..c7b1fba81 100644 --- a/bindings/nostr-sdk-ffi/src/nwc/mod.rs +++ b/bindings/nostr-sdk-ffi/src/nwc/mod.rs @@ -4,11 +4,6 @@ use std::ops::Deref; -use nostr_ffi::nips::nip47::{ - GetInfoResponseResult, ListTransactionsRequestParams, LookupInvoiceRequestParams, - LookupInvoiceResponseResult, MakeInvoiceRequestParams, MakeInvoiceResponseResult, - NostrWalletConnectURI, PayKeysendRequestParams, PayKeysendResponseResult, -}; use nostr_sdk::nwc; use uniffi::Object; @@ -16,6 +11,11 @@ pub mod options; use self::options::NostrWalletConnectOptions; use crate::error::Result; +use crate::protocol::nips::nip47::{ + GetInfoResponseResult, ListTransactionsRequestParams, LookupInvoiceRequestParams, + LookupInvoiceResponseResult, MakeInvoiceRequestParams, MakeInvoiceResponseResult, + NostrWalletConnectURI, PayKeysendRequestParams, PayKeysendResponseResult, +}; /// Nostr Wallet Connect client #[derive(Object)] diff --git a/bindings/nostr-sdk-ffi/src/nwc/options.rs b/bindings/nostr-sdk-ffi/src/nwc/options.rs index 40fcd7278..6bc7091fc 100644 --- a/bindings/nostr-sdk-ffi/src/nwc/options.rs +++ b/bindings/nostr-sdk-ffi/src/nwc/options.rs @@ -6,11 +6,11 @@ use std::ops::Deref; use std::sync::Arc; use std::time::Duration; -use nostr_ffi::helper::unwrap_or_clone_arc; use nostr_sdk::{nwc, pool}; use uniffi::Object; use crate::error::Result; +use crate::protocol::helper::unwrap_or_clone_arc; use crate::relay::options::ConnectionMode; /// NWC options diff --git a/bindings/nostr-sdk-ffi/src/pool/mod.rs b/bindings/nostr-sdk-ffi/src/pool/mod.rs index aab642275..5f3f31368 100644 --- a/bindings/nostr-sdk-ffi/src/pool/mod.rs +++ b/bindings/nostr-sdk-ffi/src/pool/mod.rs @@ -7,7 +7,6 @@ use std::ops::Deref; use std::sync::Arc; use std::time::Duration; -use nostr_ffi::{ClientMessage, Event, Filter}; use nostr_sdk::database::DynNostrDatabase; use nostr_sdk::{RelayPoolOptions, SubscriptionId}; use uniffi::Object; @@ -18,6 +17,7 @@ use self::result::{Output, SendEventOutput, SubscribeOutput}; use crate::database::events::Events; use crate::error::Result; use crate::pool::result::ReconciliationOutput; +use crate::protocol::{ClientMessage, Event, Filter}; use crate::relay::options::{FilterOptions, SyncOptions}; use crate::relay::{RelayFiltering, RelayOptions, RelaySendOptions, SubscribeOptions}; use crate::{HandleNotification, NostrDatabase, Relay}; diff --git a/bindings/nostr-sdk-ffi/src/pool/result.rs b/bindings/nostr-sdk-ffi/src/pool/result.rs index 6a88c735e..32ef93d71 100644 --- a/bindings/nostr-sdk-ffi/src/pool/result.rs +++ b/bindings/nostr-sdk-ffi/src/pool/result.rs @@ -5,10 +5,10 @@ use std::collections::{HashMap, HashSet}; use std::sync::Arc; -use nostr_ffi::EventId; use nostr_sdk::{pool, SubscriptionId, Url}; use uniffi::Record; +use crate::protocol::EventId; use crate::relay::Reconciliation; /// Output diff --git a/bindings/nostr-sdk-ffi/src/profile.rs b/bindings/nostr-sdk-ffi/src/profile.rs index bf824b56f..bea4eeb74 100644 --- a/bindings/nostr-sdk-ffi/src/profile.rs +++ b/bindings/nostr-sdk-ffi/src/profile.rs @@ -5,10 +5,11 @@ use std::ops::Deref; use std::sync::Arc; -use nostr_ffi::{Metadata, PublicKey}; use nostr_sdk::database; use uniffi::Object; +use crate::protocol::{Metadata, PublicKey}; + #[derive(Debug, PartialEq, Eq, Hash, Object)] #[uniffi::export(Debug, Eq, Hash)] pub struct Profile { diff --git a/bindings/nostr-ffi/src/event/builder.rs b/bindings/nostr-sdk-ffi/src/protocol/event/builder.rs similarity index 97% rename from bindings/nostr-ffi/src/event/builder.rs rename to bindings/nostr-sdk-ffi/src/protocol/event/builder.rs index 249dc8e3c..c5374d067 100644 --- a/bindings/nostr-ffi/src/event/builder.rs +++ b/bindings/nostr-sdk-ffi/src/protocol/event/builder.rs @@ -12,19 +12,21 @@ use uniffi::Object; use super::{Event, EventId, Kind}; use crate::error::Result; -use crate::helper::unwrap_or_clone_arc; -use crate::key::Keys; -use crate::nips::nip01::Coordinate; -use crate::nips::nip15::{ProductData, StallData}; -use crate::nips::nip34::{GitIssue, GitPatch, GitRepositoryAnnouncement}; -use crate::nips::nip51::{ArticlesCuration, Bookmarks, EmojiInfo, Emojis, Interests, MuteList}; -use crate::nips::nip53::LiveEvent; -use crate::nips::nip57::ZapRequestData; -use crate::nips::nip90::JobFeedbackData; -use crate::nips::nip98::HttpData; -use crate::signer::{NostrSigner, NostrSignerFFI2Rust}; -use crate::types::{Contact, Metadata}; -use crate::{ +use crate::protocol::helper::unwrap_or_clone_arc; +use crate::protocol::key::Keys; +use crate::protocol::nips::nip01::Coordinate; +use crate::protocol::nips::nip15::{ProductData, StallData}; +use crate::protocol::nips::nip34::{GitIssue, GitPatch, GitRepositoryAnnouncement}; +use crate::protocol::nips::nip51::{ + ArticlesCuration, Bookmarks, EmojiInfo, Emojis, Interests, MuteList, +}; +use crate::protocol::nips::nip53::LiveEvent; +use crate::protocol::nips::nip57::ZapRequestData; +use crate::protocol::nips::nip90::JobFeedbackData; +use crate::protocol::nips::nip98::HttpData; +use crate::protocol::signer::{NostrSigner, NostrSignerFFI2Rust}; +use crate::protocol::types::{Contact, Metadata}; +use crate::protocol::{ FileMetadata, Image, ImageDimensions, NostrConnectMessage, PublicKey, RelayMetadata, Tag, Timestamp, UnsignedEvent, }; diff --git a/bindings/nostr-ffi/src/event/id.rs b/bindings/nostr-sdk-ffi/src/protocol/event/id.rs similarity index 98% rename from bindings/nostr-ffi/src/event/id.rs rename to bindings/nostr-sdk-ffi/src/protocol/event/id.rs index 48e22e4e2..d3659997b 100644 --- a/bindings/nostr-ffi/src/event/id.rs +++ b/bindings/nostr-sdk-ffi/src/protocol/event/id.rs @@ -11,7 +11,7 @@ use uniffi::Object; use super::Kind; use crate::error::Result; -use crate::{PublicKey, Tag, Timestamp}; +use crate::protocol::{PublicKey, Tag, Timestamp}; #[derive(Debug, PartialEq, Eq, Hash, Object)] #[uniffi::export(Debug, Eq, Hash)] diff --git a/bindings/nostr-ffi/src/event/kind.rs b/bindings/nostr-sdk-ffi/src/protocol/event/kind.rs similarity index 100% rename from bindings/nostr-ffi/src/event/kind.rs rename to bindings/nostr-sdk-ffi/src/protocol/event/kind.rs diff --git a/bindings/nostr-ffi/src/event/mod.rs b/bindings/nostr-sdk-ffi/src/protocol/event/mod.rs similarity index 98% rename from bindings/nostr-ffi/src/event/mod.rs rename to bindings/nostr-sdk-ffi/src/protocol/event/mod.rs index e0933d0b5..e60efa84a 100644 --- a/bindings/nostr-ffi/src/event/mod.rs +++ b/bindings/nostr-sdk-ffi/src/protocol/event/mod.rs @@ -20,7 +20,7 @@ pub use self::kind::{Kind, KindEnum}; pub use self::tag::{Tag, TagKind, TagStandard, Tags}; pub use self::unsigned::UnsignedEvent; use crate::error::Result; -use crate::{PublicKey, Timestamp}; +use crate::protocol::{PublicKey, Timestamp}; #[derive(Debug, PartialEq, Eq, Hash, Object)] #[uniffi::export(Debug, Eq, Hash)] diff --git a/bindings/nostr-ffi/src/event/raw.rs b/bindings/nostr-sdk-ffi/src/protocol/event/raw.rs similarity index 100% rename from bindings/nostr-ffi/src/event/raw.rs rename to bindings/nostr-sdk-ffi/src/protocol/event/raw.rs diff --git a/bindings/nostr-ffi/src/event/tag/kind.rs b/bindings/nostr-sdk-ffi/src/protocol/event/tag/kind.rs similarity index 99% rename from bindings/nostr-ffi/src/event/tag/kind.rs rename to bindings/nostr-sdk-ffi/src/protocol/event/tag/kind.rs index 97ea36d61..bac6ea9c7 100644 --- a/bindings/nostr-ffi/src/event/tag/kind.rs +++ b/bindings/nostr-sdk-ffi/src/protocol/event/tag/kind.rs @@ -8,7 +8,7 @@ use std::sync::Arc; use nostr::event::tag; use uniffi::Enum; -use crate::SingleLetterTag; +use crate::protocol::SingleLetterTag; #[derive(Enum)] pub enum TagKind { diff --git a/bindings/nostr-ffi/src/event/tag/list.rs b/bindings/nostr-sdk-ffi/src/protocol/event/tag/list.rs similarity index 97% rename from bindings/nostr-ffi/src/event/tag/list.rs rename to bindings/nostr-sdk-ffi/src/protocol/event/tag/list.rs index 337fed87c..f5d51caf6 100644 --- a/bindings/nostr-ffi/src/event/tag/list.rs +++ b/bindings/nostr-sdk-ffi/src/protocol/event/tag/list.rs @@ -9,8 +9,8 @@ use nostr::event::tag::list; use uniffi::Object; use super::{Tag, TagKind, TagStandard}; -use crate::nips::nip01::Coordinate; -use crate::{EventId, PublicKey, Timestamp}; +use crate::protocol::nips::nip01::Coordinate; +use crate::protocol::{EventId, PublicKey, Timestamp}; #[derive(Object)] pub struct Tags { diff --git a/bindings/nostr-ffi/src/event/tag/mod.rs b/bindings/nostr-sdk-ffi/src/protocol/event/tag/mod.rs similarity index 96% rename from bindings/nostr-ffi/src/event/tag/mod.rs rename to bindings/nostr-sdk-ffi/src/protocol/event/tag/mod.rs index 874d3e4b0..523911c40 100644 --- a/bindings/nostr-ffi/src/event/tag/mod.rs +++ b/bindings/nostr-sdk-ffi/src/protocol/event/tag/mod.rs @@ -18,11 +18,11 @@ pub use self::kind::TagKind; pub use self::list::Tags; pub use self::standard::TagStandard; use crate::error::Result; -use crate::nips::nip01::Coordinate; -use crate::nips::nip56::Report; -use crate::nips::nip65::RelayMetadata; -use crate::types::filter::SingleLetterTag; -use crate::{EventId, ImageDimensions, PublicKey, Timestamp}; +use crate::protocol::nips::nip01::Coordinate; +use crate::protocol::nips::nip56::Report; +use crate::protocol::nips::nip65::RelayMetadata; +use crate::protocol::types::filter::SingleLetterTag; +use crate::protocol::{EventId, ImageDimensions, PublicKey, Timestamp}; /// Tag #[derive(Debug, PartialEq, Eq, Hash, Object)] diff --git a/bindings/nostr-ffi/src/event/tag/standard.rs b/bindings/nostr-sdk-ffi/src/protocol/event/tag/standard.rs similarity index 97% rename from bindings/nostr-ffi/src/event/tag/standard.rs rename to bindings/nostr-sdk-ffi/src/protocol/event/tag/standard.rs index a169701dd..56c25278b 100644 --- a/bindings/nostr-ffi/src/event/tag/standard.rs +++ b/bindings/nostr-sdk-ffi/src/protocol/event/tag/standard.rs @@ -15,18 +15,18 @@ use nostr::secp256k1::schnorr::Signature; use nostr::{UncheckedUrl, Url}; use uniffi::Enum; -use crate::error::NostrError; -use crate::event::kind::KindEnum; -use crate::nips::nip01::Coordinate; -use crate::nips::nip10::Marker; -use crate::nips::nip39::Identity; -use crate::nips::nip48::Protocol; -use crate::nips::nip53::LiveEventMarker; -use crate::nips::nip56::Report; -use crate::nips::nip65::RelayMetadata; -use crate::nips::nip90::DataVendingMachineStatus; -use crate::nips::nip98::HttpMethod; -use crate::{Event, EventId, ImageDimensions, LiveEventStatus, PublicKey, Timestamp}; +use crate::error::NostrSdkError; +use crate::protocol::event::kind::KindEnum; +use crate::protocol::nips::nip01::Coordinate; +use crate::protocol::nips::nip10::Marker; +use crate::protocol::nips::nip39::Identity; +use crate::protocol::nips::nip48::Protocol; +use crate::protocol::nips::nip53::LiveEventMarker; +use crate::protocol::nips::nip56::Report; +use crate::protocol::nips::nip65::RelayMetadata; +use crate::protocol::nips::nip90::DataVendingMachineStatus; +use crate::protocol::nips::nip98::HttpMethod; +use crate::protocol::{Event, EventId, ImageDimensions, LiveEventStatus, PublicKey, Timestamp}; /// Standardized tag #[derive(Enum)] @@ -466,7 +466,7 @@ impl From for TagStandard { } impl TryFrom for tag::TagStandard { - type Error = NostrError; + type Error = NostrSdkError; fn try_from(value: TagStandard) -> crate::error::Result { match value { diff --git a/bindings/nostr-ffi/src/event/unsigned.rs b/bindings/nostr-sdk-ffi/src/protocol/event/unsigned.rs similarity index 95% rename from bindings/nostr-ffi/src/event/unsigned.rs rename to bindings/nostr-sdk-ffi/src/protocol/event/unsigned.rs index d0390f14e..de87b98e2 100644 --- a/bindings/nostr-ffi/src/event/unsigned.rs +++ b/bindings/nostr-sdk-ffi/src/protocol/event/unsigned.rs @@ -12,8 +12,8 @@ use uniffi::Object; use super::EventId; use crate::error::Result; -use crate::signer::{NostrSigner, NostrSignerFFI2Rust}; -use crate::{Event, Keys, Kind, PublicKey, Tag, Timestamp}; +use crate::protocol::signer::{NostrSigner, NostrSignerFFI2Rust}; +use crate::protocol::{Event, Keys, Kind, PublicKey, Tag, Timestamp}; #[derive(Debug, PartialEq, Eq, Hash, Object)] #[uniffi::export(Debug, Eq, Hash)] diff --git a/bindings/nostr-ffi/src/helper.rs b/bindings/nostr-sdk-ffi/src/protocol/helper.rs similarity index 100% rename from bindings/nostr-ffi/src/helper.rs rename to bindings/nostr-sdk-ffi/src/protocol/helper.rs diff --git a/bindings/nostr-ffi/src/key/mod.rs b/bindings/nostr-sdk-ffi/src/protocol/key/mod.rs similarity index 98% rename from bindings/nostr-ffi/src/key/mod.rs rename to bindings/nostr-sdk-ffi/src/protocol/key/mod.rs index e08d9c7e2..495d21844 100644 --- a/bindings/nostr-ffi/src/key/mod.rs +++ b/bindings/nostr-sdk-ffi/src/protocol/key/mod.rs @@ -16,8 +16,8 @@ mod secret_key; pub use self::public_key::PublicKey; pub use self::secret_key::SecretKey; use crate::error::Result; -use crate::signer::NostrSigner; -use crate::{Event, UnsignedEvent}; +use crate::protocol::signer::NostrSigner; +use crate::protocol::{Event, UnsignedEvent}; /// Nostr keys #[derive(Debug, PartialEq, Eq, Object)] diff --git a/bindings/nostr-ffi/src/key/public_key.rs b/bindings/nostr-sdk-ffi/src/protocol/key/public_key.rs similarity index 100% rename from bindings/nostr-ffi/src/key/public_key.rs rename to bindings/nostr-sdk-ffi/src/protocol/key/public_key.rs diff --git a/bindings/nostr-ffi/src/key/secret_key.rs b/bindings/nostr-sdk-ffi/src/protocol/key/secret_key.rs similarity index 97% rename from bindings/nostr-ffi/src/key/secret_key.rs rename to bindings/nostr-sdk-ffi/src/protocol/key/secret_key.rs index d61f551cc..793d3be7c 100644 --- a/bindings/nostr-ffi/src/key/secret_key.rs +++ b/bindings/nostr-sdk-ffi/src/protocol/key/secret_key.rs @@ -8,7 +8,7 @@ use nostr::nips::nip19::{FromBech32, ToBech32}; use uniffi::Object; use crate::error::Result; -use crate::nips::nip49::EncryptedSecretKey; +use crate::protocol::nips::nip49::EncryptedSecretKey; #[derive(Debug, PartialEq, Eq, Object)] #[uniffi::export(Debug, Eq)] diff --git a/bindings/nostr-ffi/src/message/client.rs b/bindings/nostr-sdk-ffi/src/protocol/message/client.rs similarity index 99% rename from bindings/nostr-ffi/src/message/client.rs rename to bindings/nostr-sdk-ffi/src/protocol/message/client.rs index 927ce307f..17d6bd05d 100644 --- a/bindings/nostr-ffi/src/message/client.rs +++ b/bindings/nostr-sdk-ffi/src/protocol/message/client.rs @@ -9,8 +9,8 @@ use nostr::{JsonUtil, SubscriptionId}; use uniffi::{Enum, Object}; use crate::error::Result; -use crate::types::filter::Filter; -use crate::Event; +use crate::protocol::types::filter::Filter; +use crate::protocol::Event; /// Messages sent by clients, received by relays #[derive(Enum)] diff --git a/bindings/nostr-ffi/src/message/mod.rs b/bindings/nostr-sdk-ffi/src/protocol/message/mod.rs similarity index 100% rename from bindings/nostr-ffi/src/message/mod.rs rename to bindings/nostr-sdk-ffi/src/protocol/message/mod.rs diff --git a/bindings/nostr-ffi/src/message/relay.rs b/bindings/nostr-sdk-ffi/src/protocol/message/relay.rs similarity index 99% rename from bindings/nostr-ffi/src/message/relay.rs rename to bindings/nostr-sdk-ffi/src/protocol/message/relay.rs index 42b6d4bd6..97bad315d 100644 --- a/bindings/nostr-ffi/src/message/relay.rs +++ b/bindings/nostr-sdk-ffi/src/protocol/message/relay.rs @@ -10,7 +10,7 @@ use nostr::{JsonUtil, SubscriptionId}; use uniffi::{Enum, Object}; use crate::error::Result; -use crate::{Event, EventId}; +use crate::protocol::{Event, EventId}; #[derive(Enum)] pub enum RelayMessageEnum { diff --git a/bindings/nostr-sdk-ffi/src/protocol/mod.rs b/bindings/nostr-sdk-ffi/src/protocol/mod.rs new file mode 100644 index 000000000..8cbba7c62 --- /dev/null +++ b/bindings/nostr-sdk-ffi/src/protocol/mod.rs @@ -0,0 +1,27 @@ +// Copyright (c) 2022-2023 Yuki Kishimoto +// Copyright (c) 2023-2024 Rust Nostr Developers +// Distributed under the MIT software license + +pub mod event; +pub mod helper; +pub mod key; +pub mod message; +pub mod nips; +pub mod signer; +pub mod types; +pub mod util; + +pub use self::event::{Event, EventBuilder, EventId, Kind, KindEnum, Tag, TagKind, UnsignedEvent}; +pub use self::key::{Keys, PublicKey, SecretKey}; +pub use self::message::{ClientMessage, ClientMessageEnum, RelayMessage, RelayMessageEnum}; +pub use self::nips::nip04::{nip04_decrypt, nip04_encrypt}; +pub use self::nips::nip05::{get_nip05_profile, verify_nip05}; +pub use self::nips::nip11::RelayInformationDocument; +pub use self::nips::nip46::{NostrConnectMessage, NostrConnectMetadata, NostrConnectURI}; +pub use self::nips::nip53::{Image, LiveEvent, LiveEventHost, LiveEventStatus, Person}; +pub use self::nips::nip65::RelayMetadata; +pub use self::nips::nip94::FileMetadata; +pub use self::types::{ + Alphabet, Contact, Filter, ImageDimensions, Metadata, SingleLetterTag, Timestamp, +}; +pub use self::util::{generate_shared_key, JsonValue}; diff --git a/bindings/nostr-ffi/src/nips/mod.rs b/bindings/nostr-sdk-ffi/src/protocol/nips/mod.rs similarity index 100% rename from bindings/nostr-ffi/src/nips/mod.rs rename to bindings/nostr-sdk-ffi/src/protocol/nips/mod.rs diff --git a/bindings/nostr-ffi/src/nips/nip01.rs b/bindings/nostr-sdk-ffi/src/protocol/nips/nip01.rs similarity index 98% rename from bindings/nostr-ffi/src/nips/nip01.rs rename to bindings/nostr-sdk-ffi/src/protocol/nips/nip01.rs index 150e079e5..e0d3958ee 100644 --- a/bindings/nostr-ffi/src/nips/nip01.rs +++ b/bindings/nostr-sdk-ffi/src/protocol/nips/nip01.rs @@ -12,7 +12,7 @@ use nostr::nips::nip21::NostrURI; use uniffi::Object; use crate::error::Result; -use crate::{Kind, PublicKey}; +use crate::protocol::{Kind, PublicKey}; /// Coordinate for event (`a` tag) #[derive(Debug, PartialEq, Eq, Hash, Object)] diff --git a/bindings/nostr-ffi/src/nips/nip04.rs b/bindings/nostr-sdk-ffi/src/protocol/nips/nip04.rs similarity index 94% rename from bindings/nostr-ffi/src/nips/nip04.rs rename to bindings/nostr-sdk-ffi/src/protocol/nips/nip04.rs index 7fe4c2205..05949d08d 100644 --- a/bindings/nostr-ffi/src/nips/nip04.rs +++ b/bindings/nostr-sdk-ffi/src/protocol/nips/nip04.rs @@ -7,7 +7,7 @@ use std::ops::Deref; use nostr::nips::nip04; use crate::error::Result; -use crate::{PublicKey, SecretKey}; +use crate::protocol::{PublicKey, SecretKey}; #[uniffi::export] pub fn nip04_encrypt( diff --git a/bindings/nostr-ffi/src/nips/nip05.rs b/bindings/nostr-sdk-ffi/src/protocol/nips/nip05.rs similarity index 98% rename from bindings/nostr-ffi/src/nips/nip05.rs rename to bindings/nostr-sdk-ffi/src/protocol/nips/nip05.rs index cbe85d4f8..3adfafc5c 100644 --- a/bindings/nostr-ffi/src/nips/nip05.rs +++ b/bindings/nostr-sdk-ffi/src/protocol/nips/nip05.rs @@ -10,7 +10,7 @@ use nostr::nips::nip05; use uniffi::Object; use crate::error::Result; -use crate::PublicKey; +use crate::protocol::PublicKey; #[derive(Object)] pub struct Nip05Profile { diff --git a/bindings/nostr-ffi/src/nips/nip10.rs b/bindings/nostr-sdk-ffi/src/protocol/nips/nip10.rs similarity index 100% rename from bindings/nostr-ffi/src/nips/nip10.rs rename to bindings/nostr-sdk-ffi/src/protocol/nips/nip10.rs diff --git a/bindings/nostr-ffi/src/nips/nip11.rs b/bindings/nostr-sdk-ffi/src/protocol/nips/nip11.rs similarity index 99% rename from bindings/nostr-ffi/src/nips/nip11.rs rename to bindings/nostr-sdk-ffi/src/protocol/nips/nip11.rs index ed3d322f0..07a273307 100644 --- a/bindings/nostr-ffi/src/nips/nip11.rs +++ b/bindings/nostr-sdk-ffi/src/protocol/nips/nip11.rs @@ -10,7 +10,7 @@ use nostr::Url; use uniffi::{Enum, Object, Record}; use crate::error::Result; -use crate::Timestamp; +use crate::protocol::Timestamp; #[derive(Debug, PartialEq, Eq, Hash, Object)] #[uniffi::export(Debug, Eq, Hash)] diff --git a/bindings/nostr-ffi/src/nips/nip13.rs b/bindings/nostr-sdk-ffi/src/protocol/nips/nip13.rs similarity index 100% rename from bindings/nostr-ffi/src/nips/nip13.rs rename to bindings/nostr-sdk-ffi/src/protocol/nips/nip13.rs diff --git a/bindings/nostr-ffi/src/nips/nip15.rs b/bindings/nostr-sdk-ffi/src/protocol/nips/nip15.rs similarity index 99% rename from bindings/nostr-ffi/src/nips/nip15.rs rename to bindings/nostr-sdk-ffi/src/protocol/nips/nip15.rs index 362fe32bf..685e566fa 100644 --- a/bindings/nostr-ffi/src/nips/nip15.rs +++ b/bindings/nostr-sdk-ffi/src/protocol/nips/nip15.rs @@ -9,7 +9,7 @@ use nostr::JsonUtil; use uniffi::{Object, Record}; use crate::error::Result; -use crate::helper::unwrap_or_clone_arc; +use crate::protocol::helper::unwrap_or_clone_arc; /// Payload for creating or updating stall #[derive(Record)] diff --git a/bindings/nostr-ffi/src/nips/nip19.rs b/bindings/nostr-sdk-ffi/src/protocol/nips/nip19.rs similarity index 98% rename from bindings/nostr-ffi/src/nips/nip19.rs rename to bindings/nostr-sdk-ffi/src/protocol/nips/nip19.rs index c6be1ca39..80f4d6522 100644 --- a/bindings/nostr-ffi/src/nips/nip19.rs +++ b/bindings/nostr-sdk-ffi/src/protocol/nips/nip19.rs @@ -11,7 +11,7 @@ use uniffi::{Enum, Object}; use super::nip01::Coordinate; use super::nip49::EncryptedSecretKey; use crate::error::Result; -use crate::{EventId, Kind, PublicKey, SecretKey}; +use crate::protocol::{EventId, Kind, PublicKey, SecretKey}; /// A representation any `NIP19` bech32 nostr object. Useful for decoding /// `NIP19` bech32 strings without necessarily knowing what you're decoding diff --git a/bindings/nostr-ffi/src/nips/nip21.rs b/bindings/nostr-sdk-ffi/src/protocol/nips/nip21.rs similarity index 93% rename from bindings/nostr-ffi/src/nips/nip21.rs rename to bindings/nostr-sdk-ffi/src/protocol/nips/nip21.rs index 1a8aa07ec..bb351c424 100644 --- a/bindings/nostr-ffi/src/nips/nip21.rs +++ b/bindings/nostr-sdk-ffi/src/protocol/nips/nip21.rs @@ -7,9 +7,9 @@ use nostr::nips::nip21; use uniffi::{Enum, Object}; use crate::error::Result; -use crate::nips::nip01::Coordinate; -use crate::nips::nip19::{Nip19Event, Nip19Profile}; -use crate::{EventId, PublicKey}; +use crate::protocol::nips::nip01::Coordinate; +use crate::protocol::nips::nip19::{Nip19Event, Nip19Profile}; +use crate::protocol::{EventId, PublicKey}; /// A representation any `NIP21` object. Useful for decoding /// `NIP21` strings without necessarily knowing what you're decoding diff --git a/bindings/nostr-ffi/src/nips/nip26.rs b/bindings/nostr-sdk-ffi/src/protocol/nips/nip26.rs similarity index 98% rename from bindings/nostr-ffi/src/nips/nip26.rs rename to bindings/nostr-sdk-ffi/src/protocol/nips/nip26.rs index 83521c194..7cd3f3e7a 100644 --- a/bindings/nostr-ffi/src/nips/nip26.rs +++ b/bindings/nostr-sdk-ffi/src/protocol/nips/nip26.rs @@ -8,7 +8,7 @@ use nostr::nips::nip26::{self, Conditions, DelegationTag, EventProperties}; use nostr::secp256k1::schnorr::Signature; use crate::error::Result; -use crate::{Keys, Kind, PublicKey}; +use crate::protocol::{Keys, Kind, PublicKey}; /// Create a NIP26 delegation tag (including the signature). /// See also validate_delegation_tag(). diff --git a/bindings/nostr-ffi/src/nips/nip34.rs b/bindings/nostr-sdk-ffi/src/protocol/nips/nip34.rs similarity index 96% rename from bindings/nostr-ffi/src/nips/nip34.rs rename to bindings/nostr-sdk-ffi/src/protocol/nips/nip34.rs index 039f07565..1828d28c4 100644 --- a/bindings/nostr-ffi/src/nips/nip34.rs +++ b/bindings/nostr-sdk-ffi/src/protocol/nips/nip34.rs @@ -11,9 +11,9 @@ use nostr::nips::nip34; use nostr::Url; use uniffi::{Enum, Record}; -use crate::error::NostrError; -use crate::nips::nip01::Coordinate; -use crate::{EventId, PublicKey, Timestamp}; +use crate::error::NostrSdkError; +use crate::protocol::nips::nip01::Coordinate; +use crate::protocol::{EventId, PublicKey, Timestamp}; /// Git Repository Announcement /// @@ -152,7 +152,7 @@ pub enum GitPatchContent { } impl TryFrom for nip34::GitPatchContent { - type Error = NostrError; + type Error = NostrSdkError; fn try_from(value: GitPatchContent) -> Result { match value { @@ -200,7 +200,7 @@ pub struct GitPatch { } impl TryFrom for nip34::GitPatch { - type Error = NostrError; + type Error = NostrSdkError; fn try_from(value: GitPatch) -> Result { Ok(Self { diff --git a/bindings/nostr-ffi/src/nips/nip39.rs b/bindings/nostr-sdk-ffi/src/protocol/nips/nip39.rs similarity index 100% rename from bindings/nostr-ffi/src/nips/nip39.rs rename to bindings/nostr-sdk-ffi/src/protocol/nips/nip39.rs diff --git a/bindings/nostr-ffi/src/nips/nip44.rs b/bindings/nostr-sdk-ffi/src/protocol/nips/nip44.rs similarity index 96% rename from bindings/nostr-ffi/src/nips/nip44.rs rename to bindings/nostr-sdk-ffi/src/protocol/nips/nip44.rs index a727fa5b6..02d5f2dab 100644 --- a/bindings/nostr-ffi/src/nips/nip44.rs +++ b/bindings/nostr-sdk-ffi/src/protocol/nips/nip44.rs @@ -8,7 +8,7 @@ use nostr::nips::nip44::{self, Version}; use uniffi::Enum; use crate::error::Result; -use crate::{PublicKey, SecretKey}; +use crate::protocol::{PublicKey, SecretKey}; /// NIP44 Version #[derive(Enum)] diff --git a/bindings/nostr-ffi/src/nips/nip46.rs b/bindings/nostr-sdk-ffi/src/protocol/nips/nip46.rs similarity index 97% rename from bindings/nostr-ffi/src/nips/nip46.rs rename to bindings/nostr-sdk-ffi/src/protocol/nips/nip46.rs index e6c30290b..ee35b434e 100644 --- a/bindings/nostr-ffi/src/nips/nip46.rs +++ b/bindings/nostr-sdk-ffi/src/protocol/nips/nip46.rs @@ -10,9 +10,9 @@ use nostr::nips::nip46::{self, Method, Request, ResponseResult}; use nostr::{JsonUtil, Url}; use uniffi::{Enum, Object}; -use crate::error::Result; -use crate::helper::unwrap_or_clone_arc; -use crate::{NostrError, PublicKey, UnsignedEvent}; +use crate::error::{NostrSdkError, Result}; +use crate::protocol::helper::unwrap_or_clone_arc; +use crate::protocol::{PublicKey, UnsignedEvent}; /// Request (NIP46) #[derive(Enum)] @@ -206,7 +206,7 @@ pub enum NostrConnectMessage { } impl TryFrom for nip46::Message { - type Error = NostrError; + type Error = NostrSdkError; fn try_from(value: NostrConnectMessage) -> Result { Ok(match value { diff --git a/bindings/nostr-ffi/src/nips/nip47.rs b/bindings/nostr-sdk-ffi/src/protocol/nips/nip47.rs similarity index 99% rename from bindings/nostr-ffi/src/nips/nip47.rs rename to bindings/nostr-sdk-ffi/src/protocol/nips/nip47.rs index e9ff0d9b6..4e43ace3b 100644 --- a/bindings/nostr-ffi/src/nips/nip47.rs +++ b/bindings/nostr-sdk-ffi/src/protocol/nips/nip47.rs @@ -10,7 +10,7 @@ use nostr::{JsonUtil, Url}; use uniffi::{Enum, Object, Record}; use crate::error::Result; -use crate::{JsonValue, PublicKey, SecretKey, Timestamp}; +use crate::protocol::{JsonValue, PublicKey, SecretKey, Timestamp}; /// NIP47 Response Error codes #[derive(Enum)] diff --git a/bindings/nostr-ffi/src/nips/nip48.rs b/bindings/nostr-sdk-ffi/src/protocol/nips/nip48.rs similarity index 100% rename from bindings/nostr-ffi/src/nips/nip48.rs rename to bindings/nostr-sdk-ffi/src/protocol/nips/nip48.rs diff --git a/bindings/nostr-ffi/src/nips/nip49.rs b/bindings/nostr-sdk-ffi/src/protocol/nips/nip49.rs similarity index 98% rename from bindings/nostr-ffi/src/nips/nip49.rs rename to bindings/nostr-sdk-ffi/src/protocol/nips/nip49.rs index 99589f878..9730c8ce9 100644 --- a/bindings/nostr-ffi/src/nips/nip49.rs +++ b/bindings/nostr-sdk-ffi/src/protocol/nips/nip49.rs @@ -10,7 +10,7 @@ use nostr::{FromBech32, ToBech32}; use uniffi::{Enum, Object}; use crate::error::Result; -use crate::SecretKey; +use crate::protocol::SecretKey; /// Encrypted Secret Key version (NIP49) #[derive(Enum)] diff --git a/bindings/nostr-ffi/src/nips/nip51.rs b/bindings/nostr-sdk-ffi/src/protocol/nips/nip51.rs similarity index 97% rename from bindings/nostr-ffi/src/nips/nip51.rs rename to bindings/nostr-sdk-ffi/src/protocol/nips/nip51.rs index cba5f7e39..b0adbe29a 100644 --- a/bindings/nostr-ffi/src/nips/nip51.rs +++ b/bindings/nostr-sdk-ffi/src/protocol/nips/nip51.rs @@ -10,8 +10,8 @@ use nostr::{UncheckedUrl, Url}; use uniffi::Record; use super::nip01::Coordinate; -use crate::error::Result; -use crate::{EventId, NostrError, PublicKey}; +use crate::error::{NostrSdkError, Result}; +use crate::protocol::{EventId, PublicKey}; /// Things the user doesn't want to see in their feeds /// @@ -55,7 +55,7 @@ pub struct Bookmarks { } impl TryFrom for nip51::Bookmarks { - type Error = NostrError; + type Error = NostrSdkError; fn try_from(value: Bookmarks) -> Result { let mut url_list: Vec = Vec::with_capacity(value.urls.len()); diff --git a/bindings/nostr-ffi/src/nips/nip53.rs b/bindings/nostr-sdk-ffi/src/protocol/nips/nip53.rs similarity index 98% rename from bindings/nostr-ffi/src/nips/nip53.rs rename to bindings/nostr-sdk-ffi/src/protocol/nips/nip53.rs index 7ebdb0030..dd4fad778 100644 --- a/bindings/nostr-ffi/src/nips/nip53.rs +++ b/bindings/nostr-sdk-ffi/src/protocol/nips/nip53.rs @@ -9,7 +9,7 @@ use nostr::secp256k1::schnorr::Signature; use nostr::types::url::{UncheckedUrl, Url}; use uniffi::{Enum, Record}; -use crate::{ImageDimensions, PublicKey, Timestamp}; +use crate::protocol::{ImageDimensions, PublicKey, Timestamp}; #[derive(Enum)] /// Live Event Marker diff --git a/bindings/nostr-ffi/src/nips/nip56.rs b/bindings/nostr-sdk-ffi/src/protocol/nips/nip56.rs similarity index 100% rename from bindings/nostr-ffi/src/nips/nip56.rs rename to bindings/nostr-sdk-ffi/src/protocol/nips/nip56.rs diff --git a/bindings/nostr-ffi/src/nips/nip57.rs b/bindings/nostr-sdk-ffi/src/protocol/nips/nip57.rs similarity index 96% rename from bindings/nostr-ffi/src/nips/nip57.rs rename to bindings/nostr-sdk-ffi/src/protocol/nips/nip57.rs index 7e82eab16..03e549668 100644 --- a/bindings/nostr-ffi/src/nips/nip57.rs +++ b/bindings/nostr-sdk-ffi/src/protocol/nips/nip57.rs @@ -10,8 +10,8 @@ use nostr::Url; use uniffi::{Enum, Object}; use crate::error::Result; -use crate::helper::unwrap_or_clone_arc; -use crate::{Event, EventId, Keys, PublicKey, SecretKey}; +use crate::protocol::helper::unwrap_or_clone_arc; +use crate::protocol::{Event, EventId, Keys, PublicKey, SecretKey}; #[derive(Enum)] pub enum ZapType { diff --git a/bindings/nostr-ffi/src/nips/nip59.rs b/bindings/nostr-sdk-ffi/src/protocol/nips/nip59.rs similarity index 94% rename from bindings/nostr-ffi/src/nips/nip59.rs rename to bindings/nostr-sdk-ffi/src/protocol/nips/nip59.rs index ecb69866a..39de484f9 100644 --- a/bindings/nostr-ffi/src/nips/nip59.rs +++ b/bindings/nostr-sdk-ffi/src/protocol/nips/nip59.rs @@ -9,8 +9,8 @@ use nostr::EventBuilder; use uniffi::Object; use crate::error::Result; -use crate::signer::{NostrSigner, NostrSignerFFI2Rust}; -use crate::{Event, PublicKey, Timestamp, UnsignedEvent}; +use crate::protocol::signer::{NostrSigner, NostrSignerFFI2Rust}; +use crate::protocol::{Event, PublicKey, Timestamp, UnsignedEvent}; /// Build Gift Wrap /// diff --git a/bindings/nostr-ffi/src/nips/nip65.rs b/bindings/nostr-sdk-ffi/src/protocol/nips/nip65.rs similarity index 97% rename from bindings/nostr-ffi/src/nips/nip65.rs rename to bindings/nostr-sdk-ffi/src/protocol/nips/nip65.rs index d6b3f8c41..cf3d18d33 100644 --- a/bindings/nostr-ffi/src/nips/nip65.rs +++ b/bindings/nostr-sdk-ffi/src/protocol/nips/nip65.rs @@ -7,7 +7,7 @@ use std::ops::Deref; use nostr::nips::nip65; use uniffi::Enum; -use crate::Event; +use crate::protocol::Event; #[derive(Enum)] pub enum RelayMetadata { diff --git a/bindings/nostr-ffi/src/nips/nip90.rs b/bindings/nostr-sdk-ffi/src/protocol/nips/nip90.rs similarity index 97% rename from bindings/nostr-ffi/src/nips/nip90.rs rename to bindings/nostr-sdk-ffi/src/protocol/nips/nip90.rs index dfd4d5083..fe5e9ccbb 100644 --- a/bindings/nostr-ffi/src/nips/nip90.rs +++ b/bindings/nostr-sdk-ffi/src/protocol/nips/nip90.rs @@ -7,8 +7,8 @@ use std::sync::Arc; use nostr::nips::nip90; use uniffi::{Enum, Object}; -use crate::helper::unwrap_or_clone_arc; -use crate::Event; +use crate::protocol::helper::unwrap_or_clone_arc; +use crate::protocol::Event; #[derive(Enum)] pub enum DataVendingMachineStatus { diff --git a/bindings/nostr-ffi/src/nips/nip94.rs b/bindings/nostr-sdk-ffi/src/protocol/nips/nip94.rs similarity index 96% rename from bindings/nostr-ffi/src/nips/nip94.rs rename to bindings/nostr-sdk-ffi/src/protocol/nips/nip94.rs index ea323e1fd..a28003ce8 100644 --- a/bindings/nostr-ffi/src/nips/nip94.rs +++ b/bindings/nostr-sdk-ffi/src/protocol/nips/nip94.rs @@ -12,8 +12,8 @@ use nostr::Url; use uniffi::Object; use crate::error::Result; -use crate::helper::unwrap_or_clone_arc; -use crate::ImageDimensions; +use crate::protocol::helper::unwrap_or_clone_arc; +use crate::protocol::ImageDimensions; #[derive(Debug, Clone, PartialEq, Eq, Hash, Object)] #[uniffi::export(Debug, Eq, Hash)] diff --git a/bindings/nostr-ffi/src/nips/nip98.rs b/bindings/nostr-sdk-ffi/src/protocol/nips/nip98.rs similarity index 100% rename from bindings/nostr-ffi/src/nips/nip98.rs rename to bindings/nostr-sdk-ffi/src/protocol/nips/nip98.rs diff --git a/bindings/nostr-ffi/src/signer.rs b/bindings/nostr-sdk-ffi/src/protocol/signer.rs similarity index 95% rename from bindings/nostr-ffi/src/signer.rs rename to bindings/nostr-sdk-ffi/src/protocol/signer.rs index 2e0fae188..3984591b6 100644 --- a/bindings/nostr-ffi/src/signer.rs +++ b/bindings/nostr-sdk-ffi/src/protocol/signer.rs @@ -6,9 +6,9 @@ use std::fmt; use std::ops::Deref; use std::sync::Arc; +use super::event::{Event, UnsignedEvent}; +use super::key::PublicKey; use crate::error::Result; -use crate::event::{Event, UnsignedEvent}; -use crate::key::PublicKey; // NOTE: for some weird reason the `Arc` as output must be wrapped inside a `Vec` or an `Option` // otherwise compilation will fail. @@ -120,7 +120,7 @@ mod inner { use nostr::prelude::*; use super::NostrSignerFFI2Rust; - use crate::NostrError; + use crate::error::NostrSdkError; #[async_trait] impl NostrSigner for NostrSignerFFI2Rust { @@ -131,7 +131,7 @@ mod inner { .await .map_err(SignerError::backend)? .ok_or_else(|| { - SignerError::backend(NostrError::Generic(String::from( + SignerError::backend(NostrSdkError::Generic(String::from( "Received None instead of public key", ))) })?; @@ -146,7 +146,7 @@ mod inner { .await .map_err(SignerError::backend)? .ok_or_else(|| { - SignerError::backend(NostrError::Generic(String::from( + SignerError::backend(NostrSdkError::Generic(String::from( "Received None instead of event", ))) })?; diff --git a/bindings/nostr-ffi/src/types/contact.rs b/bindings/nostr-sdk-ffi/src/protocol/types/contact.rs similarity index 97% rename from bindings/nostr-ffi/src/types/contact.rs rename to bindings/nostr-sdk-ffi/src/protocol/types/contact.rs index d4b2f205a..0c984cf8b 100644 --- a/bindings/nostr-ffi/src/types/contact.rs +++ b/bindings/nostr-sdk-ffi/src/protocol/types/contact.rs @@ -8,7 +8,7 @@ use std::sync::Arc; use nostr::UncheckedUrl; use uniffi::Object; -use crate::PublicKey; +use crate::protocol::PublicKey; #[derive(Debug, PartialEq, Eq, Hash, Object)] #[uniffi::export(Debug, Eq, Hash)] diff --git a/bindings/nostr-ffi/src/types/filter.rs b/bindings/nostr-sdk-ffi/src/protocol/types/filter.rs similarity index 98% rename from bindings/nostr-ffi/src/types/filter.rs rename to bindings/nostr-sdk-ffi/src/protocol/types/filter.rs index c0a22b432..5130db9f5 100644 --- a/bindings/nostr-ffi/src/types/filter.rs +++ b/bindings/nostr-sdk-ffi/src/protocol/types/filter.rs @@ -10,9 +10,9 @@ use nostr::JsonUtil; use uniffi::{Enum, Object, Record}; use crate::error::Result; -use crate::helper::unwrap_or_clone_arc; -use crate::nips::nip01::Coordinate; -use crate::{Event, EventId, Kind, PublicKey, Timestamp}; +use crate::protocol::helper::unwrap_or_clone_arc; +use crate::protocol::nips::nip01::Coordinate; +use crate::protocol::{Event, EventId, Kind, PublicKey, Timestamp}; #[derive(Enum)] pub enum Alphabet { diff --git a/bindings/nostr-ffi/src/types/image.rs b/bindings/nostr-sdk-ffi/src/protocol/types/image.rs similarity index 100% rename from bindings/nostr-ffi/src/types/image.rs rename to bindings/nostr-sdk-ffi/src/protocol/types/image.rs diff --git a/bindings/nostr-ffi/src/types/metadata.rs b/bindings/nostr-sdk-ffi/src/protocol/types/metadata.rs similarity index 98% rename from bindings/nostr-ffi/src/types/metadata.rs rename to bindings/nostr-sdk-ffi/src/protocol/types/metadata.rs index ea83d5cb0..3c8c0b723 100644 --- a/bindings/nostr-ffi/src/types/metadata.rs +++ b/bindings/nostr-sdk-ffi/src/protocol/types/metadata.rs @@ -10,8 +10,8 @@ use nostr::{JsonUtil, Url}; use uniffi::{Object, Record}; use crate::error::Result; -use crate::helper::unwrap_or_clone_arc; -use crate::JsonValue; +use crate::protocol::helper::unwrap_or_clone_arc; +use crate::protocol::JsonValue; #[derive(Record)] pub struct MetadataRecord { diff --git a/bindings/nostr-ffi/src/types/mod.rs b/bindings/nostr-sdk-ffi/src/protocol/types/mod.rs similarity index 100% rename from bindings/nostr-ffi/src/types/mod.rs rename to bindings/nostr-sdk-ffi/src/protocol/types/mod.rs diff --git a/bindings/nostr-ffi/src/types/time.rs b/bindings/nostr-sdk-ffi/src/protocol/types/time.rs similarity index 100% rename from bindings/nostr-ffi/src/types/time.rs rename to bindings/nostr-sdk-ffi/src/protocol/types/time.rs diff --git a/bindings/nostr-ffi/src/util.rs b/bindings/nostr-sdk-ffi/src/protocol/util.rs similarity index 90% rename from bindings/nostr-ffi/src/util.rs rename to bindings/nostr-sdk-ffi/src/protocol/util.rs index 5a621430b..6206a7e19 100644 --- a/bindings/nostr-ffi/src/util.rs +++ b/bindings/nostr-sdk-ffi/src/protocol/util.rs @@ -9,8 +9,8 @@ use nostr::serde_json::{Number, Value}; use nostr::util; use uniffi::Enum; -use crate::error::Result; -use crate::{NostrError, PublicKey, SecretKey}; +use super::{PublicKey, SecretKey}; +use crate::error::{NostrSdkError, Result}; /// Generate shared key /// @@ -34,7 +34,7 @@ pub enum JsonValue { } impl TryFrom for Value { - type Error = NostrError; + type Error = NostrSdkError; fn try_from(value: JsonValue) -> Result { Ok(match value { @@ -42,9 +42,9 @@ impl TryFrom for Value { JsonValue::NumberPosInt { number } => Self::Number(Number::from(number)), JsonValue::NumberNegInt { number } => Self::Number(Number::from(number)), JsonValue::NumberFloat { number } => { - let float = Number::from_f64(number).ok_or(NostrError::Generic(String::from( - "Impossible to convert finite f64 to number", - )))?; + let float = Number::from_f64(number).ok_or(NostrSdkError::Generic( + String::from("Impossible to convert finite f64 to number"), + ))?; Self::Number(float) } JsonValue::Str { s } => Self::String(s), @@ -65,7 +65,7 @@ impl TryFrom for Value { } impl TryFrom for JsonValue { - type Error = NostrError; + type Error = NostrSdkError; fn try_from(value: Value) -> Result { Ok(match value { @@ -77,7 +77,7 @@ impl TryFrom for JsonValue { None => match number.as_f64() { Some(number) => Self::NumberFloat { number }, None => { - return Err(NostrError::Generic(String::from( + return Err(NostrSdkError::Generic(String::from( "Impossible to convert number", ))) } diff --git a/bindings/nostr-sdk-ffi/src/relay/filtering.rs b/bindings/nostr-sdk-ffi/src/relay/filtering.rs index 6fe2a39b2..07e928522 100644 --- a/bindings/nostr-sdk-ffi/src/relay/filtering.rs +++ b/bindings/nostr-sdk-ffi/src/relay/filtering.rs @@ -5,10 +5,11 @@ use std::ops::Deref; use std::sync::Arc; -use nostr_ffi::{EventId, PublicKey}; use nostr_sdk::pool::relay; use uniffi::{Enum, Object}; +use crate::protocol::{EventId, PublicKey}; + #[derive(Enum)] pub enum RelayFilteringMode { /// Only the matching values will be allowed diff --git a/bindings/nostr-sdk-ffi/src/relay/limits.rs b/bindings/nostr-sdk-ffi/src/relay/limits.rs index 1dbd6ff31..960beef4a 100644 --- a/bindings/nostr-sdk-ffi/src/relay/limits.rs +++ b/bindings/nostr-sdk-ffi/src/relay/limits.rs @@ -5,11 +5,12 @@ use std::ops::Deref; use std::sync::Arc; -use nostr_ffi::helper::unwrap_or_clone_arc; -use nostr_ffi::Kind; use nostr_sdk::pool::relay; use uniffi::Object; +use crate::protocol::helper::unwrap_or_clone_arc; +use crate::protocol::Kind; + /// Relay Limits #[derive(Debug, Clone, PartialEq, Eq, Object)] #[uniffi::export(Debug, Eq)] diff --git a/bindings/nostr-sdk-ffi/src/relay/mod.rs b/bindings/nostr-sdk-ffi/src/relay/mod.rs index 7fb8aedbc..015a0d168 100644 --- a/bindings/nostr-sdk-ffi/src/relay/mod.rs +++ b/bindings/nostr-sdk-ffi/src/relay/mod.rs @@ -7,13 +7,10 @@ use std::ops::Deref; use std::sync::Arc; use std::time::Duration; -use nostr_ffi::{ClientMessage, Event, EventId, Filter, RelayInformationDocument}; use nostr_sdk::database::DynNostrDatabase; use nostr_sdk::{pool, FilterOptions, SubscriptionId, Url}; use uniffi::{Object, Record}; -use crate::database::events::Events; - pub mod filtering; pub mod limits; pub mod options; @@ -26,8 +23,10 @@ use self::options::SyncOptions; pub use self::options::{ConnectionMode, RelayOptions, RelaySendOptions, SubscribeOptions}; pub use self::stats::RelayConnectionStats; pub use self::status::RelayStatus; +use crate::database::events::Events; use crate::error::Result; use crate::negentropy::NegentropyItem; +use crate::protocol::{ClientMessage, Event, EventId, Filter, RelayInformationDocument}; use crate::NostrDatabase; #[derive(Record)] diff --git a/bindings/nostr-sdk-ffi/src/relay/options.rs b/bindings/nostr-sdk-ffi/src/relay/options.rs index 187de6704..2a0de7fcf 100644 --- a/bindings/nostr-sdk-ffi/src/relay/options.rs +++ b/bindings/nostr-sdk-ffi/src/relay/options.rs @@ -7,12 +7,12 @@ use std::path::PathBuf; use std::sync::Arc; use std::time::Duration; -use nostr_ffi::helper::unwrap_or_clone_arc; use nostr_sdk::pool; use uniffi::{Enum, Object}; use super::{RelayFilteringMode, RelayLimits}; use crate::error::{NostrSdkError, Result}; +use crate::protocol::helper::unwrap_or_clone_arc; #[derive(Enum)] pub enum ConnectionMode { diff --git a/bindings/nostr-sdk-ffi/src/relay/stats.rs b/bindings/nostr-sdk-ffi/src/relay/stats.rs index 8ee17aec0..10195eb11 100644 --- a/bindings/nostr-sdk-ffi/src/relay/stats.rs +++ b/bindings/nostr-sdk-ffi/src/relay/stats.rs @@ -4,10 +4,11 @@ use std::time::Duration; -use nostr_ffi::Timestamp; use nostr_sdk::pool; use uniffi::Object; +use crate::protocol::Timestamp; + #[derive(Object)] pub struct RelayConnectionStats { inner: pool::RelayConnectionStats, diff --git a/bindings/nostr-ffi/tests/test_equality.py b/bindings/nostr-sdk-ffi/tests/test_equality.py similarity index 95% rename from bindings/nostr-ffi/tests/test_equality.py rename to bindings/nostr-sdk-ffi/tests/test_equality.py index 8236ac7ef..b8bb08fdc 100644 --- a/bindings/nostr-ffi/tests/test_equality.py +++ b/bindings/nostr-sdk-ffi/tests/test_equality.py @@ -1,4 +1,4 @@ -from nostr_ffi import * +from nostr_sdk_ffi import * # Test PublicKey pk1 = PublicKey.from_hex("b2d670de53b27691c0c3400225b65c35a26d06093bcc41f48ffc71e0907f9d4a") diff --git a/bindings/nostr-ffi/tests/test_generated_bindings.rs b/bindings/nostr-sdk-ffi/tests/test_generated_bindings.rs similarity index 100% rename from bindings/nostr-ffi/tests/test_generated_bindings.rs rename to bindings/nostr-sdk-ffi/tests/test_generated_bindings.rs diff --git a/bindings/nostr-ffi/tests/test_nip05.py b/bindings/nostr-sdk-ffi/tests/test_nip05.py similarity index 94% rename from bindings/nostr-ffi/tests/test_nip05.py rename to bindings/nostr-sdk-ffi/tests/test_nip05.py index 5cfd97cf3..502a5f0f6 100644 --- a/bindings/nostr-ffi/tests/test_nip05.py +++ b/bindings/nostr-sdk-ffi/tests/test_nip05.py @@ -1,5 +1,5 @@ import asyncio -from nostr_ffi import * +from nostr_sdk_ffi import * async def main(): nip_05 = "yuki@yukikishimoto.com" diff --git a/bindings/nostr-ffi/tests/test_to_string.py b/bindings/nostr-sdk-ffi/tests/test_to_string.py similarity index 89% rename from bindings/nostr-ffi/tests/test_to_string.py rename to bindings/nostr-sdk-ffi/tests/test_to_string.py index d0aea341c..e09435f97 100644 --- a/bindings/nostr-ffi/tests/test_to_string.py +++ b/bindings/nostr-sdk-ffi/tests/test_to_string.py @@ -1,4 +1,4 @@ -from nostr_ffi import * +from nostr_sdk_ffi import * addr = "30023:aa4fc8665f5696e33db7e1a572e3b0f5b3d615837b0f362dcb1c8068b098c7b4:ipsum" coordinate = Coordinate.parse(addr) diff --git a/contrib/scripts/check-bindings.sh b/contrib/scripts/check-bindings.sh index 6454cb909..cab157a31 100755 --- a/contrib/scripts/check-bindings.sh +++ b/contrib/scripts/check-bindings.sh @@ -4,7 +4,6 @@ set -euo pipefail # Check bindings buildargs=( - "-p nostr-ffi" "-p nostr-sdk-ffi" "-p nostr-sdk-js --target wasm32-unknown-unknown" )