diff --git a/Cargo-minimal.lock b/Cargo-minimal.lock index ea592572f..6255a11c5 100644 --- a/Cargo-minimal.lock +++ b/Cargo-minimal.lock @@ -4056,7 +4056,7 @@ dependencies = [ [[package]] name = "uniffi-dart" version = "0.1.0" -source = "git+https://github.com/Uniffi-Dart/uniffi-dart.git?rev=04f0007#04f00070418dc9c0a116386d2ca01d617a7079e4" +source = "git+https://github.com/Uniffi-Dart/uniffi-dart.git?rev=364b117#364b11767096ccaaa1e6f681fdfc354cb4cd9d5d" dependencies = [ "anyhow", "camino", @@ -4127,14 +4127,13 @@ dependencies = [ [[package]] name = "uniffi_dart_macro" version = "0.1.0" -source = "git+https://github.com/Uniffi-Dart/uniffi-dart.git?rev=04f0007#04f00070418dc9c0a116386d2ca01d617a7079e4" +source = "git+https://github.com/Uniffi-Dart/uniffi-dart.git?rev=364b117#364b11767096ccaaa1e6f681fdfc354cb4cd9d5d" dependencies = [ "futures", "proc-macro2", "quote", "stringcase 0.3.0", "syn 1.0.109", - "tokio", "uniffi", ] diff --git a/Cargo-recent.lock b/Cargo-recent.lock index ea592572f..6255a11c5 100644 --- a/Cargo-recent.lock +++ b/Cargo-recent.lock @@ -4056,7 +4056,7 @@ dependencies = [ [[package]] name = "uniffi-dart" version = "0.1.0" -source = "git+https://github.com/Uniffi-Dart/uniffi-dart.git?rev=04f0007#04f00070418dc9c0a116386d2ca01d617a7079e4" +source = "git+https://github.com/Uniffi-Dart/uniffi-dart.git?rev=364b117#364b11767096ccaaa1e6f681fdfc354cb4cd9d5d" dependencies = [ "anyhow", "camino", @@ -4127,14 +4127,13 @@ dependencies = [ [[package]] name = "uniffi_dart_macro" version = "0.1.0" -source = "git+https://github.com/Uniffi-Dart/uniffi-dart.git?rev=04f0007#04f00070418dc9c0a116386d2ca01d617a7079e4" +source = "git+https://github.com/Uniffi-Dart/uniffi-dart.git?rev=364b117#364b11767096ccaaa1e6f681fdfc354cb4cd9d5d" dependencies = [ "futures", "proc-macro2", "quote", "stringcase 0.3.0", "syn 1.0.109", - "tokio", "uniffi", ] diff --git a/payjoin-ffi/Cargo.toml b/payjoin-ffi/Cargo.toml index 16b413482..aec970723 100644 --- a/payjoin-ffi/Cargo.toml +++ b/payjoin-ffi/Cargo.toml @@ -23,7 +23,7 @@ path = "uniffi-bindgen.rs" [build-dependencies] uniffi = { version = "0.29.4", features = ["build", "cli"] } -uniffi-dart = { git = "https://github.com/Uniffi-Dart/uniffi-dart.git", rev = "04f0007", features = ["build"], optional = true } +uniffi-dart = { git = "https://github.com/Uniffi-Dart/uniffi-dart.git", rev = "364b117", features = ["build"], optional = true } [dependencies] base64 = "0.22.1" @@ -39,7 +39,7 @@ serde_json = "1.0.142" thiserror = "2.0.14" tokio = { version = "1.47.1", features = ["full"], optional = true } uniffi = { version = "0.29.4" } -uniffi-dart = { git = "https://github.com/Uniffi-Dart/uniffi-dart.git", rev = "04f0007", optional = true } +uniffi-dart = { git = "https://github.com/Uniffi-Dart/uniffi-dart.git", rev = "364b117", optional = true } url = "2.5.4" [dev-dependencies] diff --git a/payjoin-ffi/build.rs b/payjoin-ffi/build.rs index 3b7f8ba06..1dc3f82e6 100644 --- a/payjoin-ffi/build.rs +++ b/payjoin-ffi/build.rs @@ -1,5 +1,5 @@ fn main() { - uniffi::generate_scaffolding("src/payjoin_ffi.udl").unwrap(); + uniffi::generate_scaffolding("src/payjoin.udl").unwrap(); #[cfg(feature = "dart")] - uniffi_dart::generate_scaffolding("src/payjoin_ffi.udl".into()).unwrap(); + uniffi_dart::generate_scaffolding("src/payjoin.udl".into()).unwrap(); } diff --git a/payjoin-ffi/dart/.gitignore b/payjoin-ffi/dart/.gitignore index f1e3afbc1..925c8ad57 100644 --- a/payjoin-ffi/dart/.gitignore +++ b/payjoin-ffi/dart/.gitignore @@ -11,5 +11,5 @@ doc/api/ *.dll # Auto-generated bindings -lib/payjoin_ffi.dart +lib/payjoin.dart lib/bitcoin.dart diff --git a/payjoin-ffi/dart/pubspec.yaml b/payjoin-ffi/dart/pubspec.yaml index a8ba208fa..67bc7b8fe 100644 --- a/payjoin-ffi/dart/pubspec.yaml +++ b/payjoin-ffi/dart/pubspec.yaml @@ -1,6 +1,6 @@ -name: payjoin_dart -description: Dart bindings for payjoin -version: 0.24.0 +name: payjoin +description: Dart bindings for payjoin (EXPERIMENTAL) +version: 0.1.0 environment: sdk: '^3.2.0' @@ -9,4 +9,4 @@ dependencies: ffi: ^2.1.4 dev_dependencies: test: ^1.26.2 - http: ^1.4.0 \ No newline at end of file + http: ^1.4.0 diff --git a/payjoin-ffi/dart/test/test_payjoin_integration_test.dart b/payjoin-ffi/dart/test/test_payjoin_integration_test.dart index b296cfd1b..406574c37 100644 --- a/payjoin-ffi/dart/test/test_payjoin_integration_test.dart +++ b/payjoin-ffi/dart/test/test_payjoin_integration_test.dart @@ -5,8 +5,8 @@ import "package:http/http.dart" as http; import 'package:test/test.dart'; import "package:convert/convert.dart"; -import "../lib/payjoin_ffi.dart" as payjoin; -import "../lib/bitcoin.dart" as bitcoin; +import "package:payjoin/payjoin.dart" as payjoin; +import "package:payjoin/bitcoin.dart" as bitcoin; late payjoin.BitcoindEnv env; late payjoin.BitcoindInstance bitcoind; diff --git a/payjoin-ffi/dart/test/test_payjoin_unit_test.dart b/payjoin-ffi/dart/test/test_payjoin_unit_test.dart index edc77830d..1a80431eb 100644 --- a/payjoin-ffi/dart/test/test_payjoin_unit_test.dart +++ b/payjoin-ffi/dart/test/test_payjoin_unit_test.dart @@ -1,8 +1,8 @@ import 'dart:typed_data'; import 'package:convert/convert.dart'; import 'package:test/test.dart'; -import "package:payjoin_dart/payjoin_ffi.dart" as payjoin; -import "package:payjoin_dart/bitcoin.dart" as bitcoin; +import "package:payjoin/payjoin.dart" as payjoin; +import "package:payjoin/bitcoin.dart" as bitcoin; class InMemoryReceiverPersister implements payjoin.JsonReceiverSessionPersister { @@ -108,7 +108,8 @@ void main() { payjoin.ReceiverBuilder( address, "https://example.com", - payjoin.OhttpKeys.decode(Uint8List.fromList(hex.decode("01001604ba48c49c3d4a92a3ad00ecc63a024da10ced02180c73ec12d8a7ad2cc91bb483824fe2bee8d28bfe2eb2fc6453bc4d31cd851e8a6540e86c5382af588d370957000400010003"))), + payjoin.OhttpKeys.decode(Uint8List.fromList(hex.decode( + "01001604ba48c49c3d4a92a3ad00ecc63a024da10ced02180c73ec12d8a7ad2cc91bb483824fe2bee8d28bfe2eb2fc6453bc4d31cd851e8a6540e86c5382af588d370957000400010003"))), ).build().save(persister); final result = payjoin.replayReceiverEventLog(persister); expect(result, isA(), @@ -120,12 +121,11 @@ void main() { var address = bitcoin.Address( "2MuyMrZHkbHbfjudmKUy45dU4P17pjG2szK", bitcoin.Network.testnet); var receiver = payjoin.ReceiverBuilder( - address, - "https://example.com", - payjoin.OhttpKeys.decode(Uint8List.fromList(hex.decode("01001604ba48c49c3d4a92a3ad00ecc63a024da10ced02180c73ec12d8a7ad2cc91bb483824fe2bee8d28bfe2eb2fc6453bc4d31cd851e8a6540e86c5382af588d370957000400010003"))), - ) - .build() - .save(receiver_persister); + address, + "https://example.com", + payjoin.OhttpKeys.decode(Uint8List.fromList(hex.decode( + "01001604ba48c49c3d4a92a3ad00ecc63a024da10ced02180c73ec12d8a7ad2cc91bb483824fe2bee8d28bfe2eb2fc6453bc4d31cd851e8a6540e86c5382af588d370957000400010003"))), + ).build().save(receiver_persister); var uri = receiver.pjUri(); var sender_persister = InMemorySenderPersister("1"); diff --git a/payjoin-ffi/javascript/scripts/fix-imports.js b/payjoin-ffi/javascript/scripts/fix-imports.js index 5464315b0..a78c862d5 100644 --- a/payjoin-ffi/javascript/scripts/fix-imports.js +++ b/payjoin-ffi/javascript/scripts/fix-imports.js @@ -1,9 +1,9 @@ // This script is a dirty hack for Node.JS ESM imports. // TypeScript compiles imports without a `.js` extension, which results in ERR_MODULE_NOT_FOUND when running in Node.JS. // This fixes it by adding the `.js` file extension to the import in the generated files (thankfully there is currently only one such instance). -const fs = require('fs'); +const fs = require("fs"); -const file = 'dist/generated/payjoin_ffi.js'; -let content = fs.readFileSync(file, 'utf8'); +const file = "dist/generated/payjoin.js"; +let content = fs.readFileSync(file, "utf8"); content = content.replace('from "./bitcoin"', 'from "./bitcoin.js"'); fs.writeFileSync(file, content); diff --git a/payjoin-ffi/javascript/src/index.ts b/payjoin-ffi/javascript/src/index.ts index 762084cab..26f0154f5 100644 --- a/payjoin-ffi/javascript/src/index.ts +++ b/payjoin-ffi/javascript/src/index.ts @@ -1,12 +1,12 @@ // Export the generated bindings to the app. -export * as payjoin from "./generated/payjoin_ffi.js"; +export * as payjoin from "./generated/payjoin.js"; export * as bitcoin from "./generated/bitcoin.js"; // Now import the bindings so we can: // - initialize them // - export them as namespaced objects as the default export. import * as bitcoin from "./generated/bitcoin.js"; -import * as payjoin from "./generated/payjoin_ffi.js"; +import * as payjoin from "./generated/payjoin.js"; let initialized = false; diff --git a/payjoin-ffi/python/.gitignore b/payjoin-ffi/python/.gitignore index 94709250b..fc516859b 100644 --- a/payjoin-ffi/python/.gitignore +++ b/payjoin-ffi/python/.gitignore @@ -16,5 +16,5 @@ build/ *.dll # Auto-generated bindings python file -src/payjoin/payjoin_ffi.py +src/payjoin/payjoin.py src/payjoin/bitcoin.py diff --git a/payjoin-ffi/python/src/payjoin/__init__.py b/payjoin-ffi/python/src/payjoin/__init__.py index 8055d1a08..ac4ea9dd2 100644 --- a/payjoin-ffi/python/src/payjoin/__init__.py +++ b/payjoin-ffi/python/src/payjoin/__init__.py @@ -1 +1 @@ -from payjoin.payjoin_ffi import * \ No newline at end of file +from payjoin.payjoin import * diff --git a/payjoin-ffi/python/test/test_payjoin_unit_test.py b/payjoin-ffi/python/test/test_payjoin_unit_test.py index d4ef5999a..1867a4242 100644 --- a/payjoin-ffi/python/test/test_payjoin_unit_test.py +++ b/payjoin-ffi/python/test/test_payjoin_unit_test.py @@ -1,6 +1,6 @@ import unittest -import payjoin as payjoin -import payjoin.bitcoin +import payjoin +import payjoin.bitcoin class TestURIs(unittest.TestCase): def test_todo_url_encoded(self): @@ -31,7 +31,7 @@ def test_valid_uris(self): except Exception as e: self.fail(f"Failed to create a valid Uri for {uri}. Error: {e}") -class InMemoryReceiverPersister(payjoin.payjoin_ffi.JsonReceiverSessionPersister): +class InMemoryReceiverPersister(payjoin.JsonReceiverSessionPersister): def __init__(self, id): self.id = id self.events = [] @@ -50,15 +50,15 @@ class TestReceiverPersistence(unittest.TestCase): def test_receiver_persistence(self): persister = InMemoryReceiverPersister(1) address = payjoin.bitcoin.Address("tb1q6d3a2w975yny0asuvd9a67ner4nks58ff0q8g4", payjoin.bitcoin.Network.SIGNET) - payjoin.payjoin_ffi.ReceiverBuilder( + payjoin.ReceiverBuilder( address, "https://example.com", payjoin.OhttpKeys.decode(bytes.fromhex("01001604ba48c49c3d4a92a3ad00ecc63a024da10ced02180c73ec12d8a7ad2cc91bb483824fe2bee8d28bfe2eb2fc6453bc4d31cd851e8a6540e86c5382af588d370957000400010003")), ).build().save(persister) - result = payjoin.payjoin_ffi.replay_receiver_event_log(persister) + result = payjoin.replay_receiver_event_log(persister) self.assertTrue(result.state().is_INITIALIZED()) -class InMemorySenderPersister(payjoin.payjoin_ffi.JsonSenderSessionPersister): +class InMemorySenderPersister(payjoin.JsonSenderSessionPersister): def __init__(self, id): self.id = id self.events = [] @@ -78,7 +78,7 @@ def test_sender_persistence(self): # Create a receiver to just get the pj uri persister = InMemoryReceiverPersister(1) address = payjoin.bitcoin.Address("2MuyMrZHkbHbfjudmKUy45dU4P17pjG2szK", payjoin.bitcoin.Network.TESTNET) - receiver = payjoin.payjoin_ffi.ReceiverBuilder( + receiver = payjoin.ReceiverBuilder( address, "https://example.com", payjoin.OhttpKeys.decode(bytes.fromhex("01001604ba48c49c3d4a92a3ad00ecc63a024da10ced02180c73ec12d8a7ad2cc91bb483824fe2bee8d28bfe2eb2fc6453bc4d31cd851e8a6540e86c5382af588d370957000400010003")), diff --git a/payjoin-ffi/src/lib.rs b/payjoin-ffi/src/lib.rs index 4bf23f72f..6d23dbd5f 100644 --- a/payjoin-ffi/src/lib.rs +++ b/payjoin-ffi/src/lib.rs @@ -24,4 +24,4 @@ pub use crate::send::*; #[cfg(feature = "_test-utils")] pub use crate::test_utils::*; pub use crate::uri::{PjUri, Uri, Url}; -uniffi::setup_scaffolding!(); +uniffi::setup_scaffolding!("payjoin"); diff --git a/payjoin-ffi/src/payjoin.udl b/payjoin-ffi/src/payjoin.udl new file mode 100644 index 000000000..a5b7a8571 --- /dev/null +++ b/payjoin-ffi/src/payjoin.udl @@ -0,0 +1,3 @@ +namespace payjoin { + +}; diff --git a/payjoin-ffi/src/payjoin_ffi.udl b/payjoin-ffi/src/payjoin_ffi.udl deleted file mode 100644 index 22a40a151..000000000 --- a/payjoin-ffi/src/payjoin_ffi.udl +++ /dev/null @@ -1,3 +0,0 @@ -namespace payjoin_ffi { - -}; diff --git a/payjoin-ffi/uniffi-bindgen.rs b/payjoin-ffi/uniffi-bindgen.rs index 13853bba7..10bc0ec1d 100644 --- a/payjoin-ffi/uniffi-bindgen.rs +++ b/payjoin-ffi/uniffi-bindgen.rs @@ -20,7 +20,7 @@ fn uniffi_bindgen() { .and_then(|idx| args.get(idx + 1)) .expect("--out-dir is required when using --library"); uniffi_dart::gen::generate_dart_bindings( - "src/payjoin_ffi.udl".into(), + "src/payjoin.udl".into(), None, Some(output_dir.as_str().into()), library_path.as_str().into(),