From bb8a711b7071a31b6d5e4ccd4d9e5a22f9300d4d Mon Sep 17 00:00:00 2001 From: Yuki Kishimoto Date: Sat, 16 Nov 2024 13:39:07 +0100 Subject: [PATCH] Revert "ffi: remove arg from `uniffi::setup_scaffolding` macro" Removing the `nostr_sdk` arg from `uniffi::setup_scaffolding` caused issues with Swift Bindings, so revert commit 64c592a2 Fixes https://github.com/rust-nostr/nostr-sdk-swift/issues/3 Signed-off-by: Yuki Kishimoto --- bindings/nostr-sdk-ffi/justfile | 2 +- bindings/nostr-sdk-ffi/python/.gitignore | 2 +- bindings/nostr-sdk-ffi/python/src/nostr-sdk/__init__.py | 4 ++-- bindings/nostr-sdk-ffi/src/lib.rs | 4 +++- bindings/nostr-sdk-ffi/tests/test_equality.py | 2 +- bindings/nostr-sdk-ffi/tests/test_nip05.py | 4 ++-- bindings/nostr-sdk-ffi/tests/test_to_string.py | 2 +- 7 files changed, 11 insertions(+), 9 deletions(-) diff --git a/bindings/nostr-sdk-ffi/justfile b/bindings/nostr-sdk-ffi/justfile index a094d073b..01e632c3b 100755 --- a/bindings/nostr-sdk-ffi/justfile +++ b/bindings/nostr-sdk-ffi/justfile @@ -100,7 +100,7 @@ darwin-universal: swift-deps assemble-swift-package: mkdir -p swift/Sources/NostrSDK cargo run -p uniffi-bindgen generate --library ../../target/aarch64-apple-ios/release/libnostr_sdk_ffi.a --no-format --language swift --out-dir swift/Sources/NostrSDK - mv swift/Sources/NostrSDK/nostr_sdk_ffi.swift swift/Sources/NostrSDK/NostrSDK.swift + mv swift/Sources/NostrSDK/nostr_sdk.swift swift/Sources/NostrSDK/NostrSDK.swift cp swift/Sources/NostrSDK/nostr_sdkFFI.h swift/nostr_sdkFFI.xcframework/ios-arm64/nostr_sdkFFI.framework/Headers cp swift/Sources/NostrSDK/nostr_sdkFFI.h swift/nostr_sdkFFI.xcframework/ios-arm64_x86_64-simulator/nostr_sdkFFI.framework/Headers cp swift/Sources/NostrSDK/nostr_sdkFFI.h swift/nostr_sdkFFI.xcframework/macos-arm64_x86_64/nostr_sdkFFI.framework/Headers diff --git a/bindings/nostr-sdk-ffi/python/.gitignore b/bindings/nostr-sdk-ffi/python/.gitignore index cdc5a57f7..2711ef622 100644 --- a/bindings/nostr-sdk-ffi/python/.gitignore +++ b/bindings/nostr-sdk-ffi/python/.gitignore @@ -8,7 +8,7 @@ libnostr_sdk_ffi.dylib *.swp -src/nostr-sdk/nostr_sdk_ffi.py +src/nostr-sdk/nostr_sdk.py src/nostr-sdk/*.so *.whl build/ diff --git a/bindings/nostr-sdk-ffi/python/src/nostr-sdk/__init__.py b/bindings/nostr-sdk-ffi/python/src/nostr-sdk/__init__.py index 248d8f33e..d2ae9e139 100644 --- a/bindings/nostr-sdk-ffi/python/src/nostr-sdk/__init__.py +++ b/bindings/nostr-sdk-ffi/python/src/nostr-sdk/__init__.py @@ -1,2 +1,2 @@ -from nostr_sdk.nostr_sdk_ffi import * -from nostr_sdk.nostr_sdk_ffi import uniffi_set_event_loop +from nostr_sdk.nostr_sdk import * +from nostr_sdk.nostr_sdk import uniffi_set_event_loop diff --git a/bindings/nostr-sdk-ffi/src/lib.rs b/bindings/nostr-sdk-ffi/src/lib.rs index d5c50da9d..70ab55ffd 100644 --- a/bindings/nostr-sdk-ffi/src/lib.rs +++ b/bindings/nostr-sdk-ffi/src/lib.rs @@ -44,4 +44,6 @@ impl NostrLibrary { } } -uniffi::setup_scaffolding!(); +// Changes to this arg will break binding packages (in particular Swift). +// If this is removed, make sure to update `uniffi.toml` +uniffi::setup_scaffolding!("nostr_sdk"); diff --git a/bindings/nostr-sdk-ffi/tests/test_equality.py b/bindings/nostr-sdk-ffi/tests/test_equality.py index b8bb08fdc..6387fb1b5 100644 --- a/bindings/nostr-sdk-ffi/tests/test_equality.py +++ b/bindings/nostr-sdk-ffi/tests/test_equality.py @@ -1,4 +1,4 @@ -from nostr_sdk_ffi import * +from nostr_sdk import * # Test PublicKey pk1 = PublicKey.from_hex("b2d670de53b27691c0c3400225b65c35a26d06093bcc41f48ffc71e0907f9d4a") diff --git a/bindings/nostr-sdk-ffi/tests/test_nip05.py b/bindings/nostr-sdk-ffi/tests/test_nip05.py index 502a5f0f6..5a7bf239f 100644 --- a/bindings/nostr-sdk-ffi/tests/test_nip05.py +++ b/bindings/nostr-sdk-ffi/tests/test_nip05.py @@ -1,5 +1,5 @@ import asyncio -from nostr_sdk_ffi import * +from nostr_sdk import * async def main(): nip_05 = "yuki@yukikishimoto.com" @@ -11,4 +11,4 @@ async def main(): print(f" Unable to verify NIP05, for {public_key.to_bech32()}") if __name__ == '__main__': - asyncio.run(main()) \ No newline at end of file + asyncio.run(main()) diff --git a/bindings/nostr-sdk-ffi/tests/test_to_string.py b/bindings/nostr-sdk-ffi/tests/test_to_string.py index e09435f97..1036b5ce4 100644 --- a/bindings/nostr-sdk-ffi/tests/test_to_string.py +++ b/bindings/nostr-sdk-ffi/tests/test_to_string.py @@ -1,4 +1,4 @@ -from nostr_sdk_ffi import * +from nostr_sdk import * addr = "30023:aa4fc8665f5696e33db7e1a572e3b0f5b3d615837b0f362dcb1c8068b098c7b4:ipsum" coordinate = Coordinate.parse(addr)