Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions Cargo-minimal.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
]

Expand Down
5 changes: 2 additions & 3 deletions Cargo-recent.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
]

Expand Down
4 changes: 2 additions & 2 deletions payjoin-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions payjoin-ffi/build.rs
Original file line number Diff line number Diff line change
@@ -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();
}
2 changes: 1 addition & 1 deletion payjoin-ffi/dart/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ doc/api/
*.dll

# Auto-generated bindings
lib/payjoin_ffi.dart
lib/payjoin.dart
lib/bitcoin.dart
8 changes: 4 additions & 4 deletions payjoin-ffi/dart/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -9,4 +9,4 @@ dependencies:
ffi: ^2.1.4
dev_dependencies:
test: ^1.26.2
http: ^1.4.0
http: ^1.4.0
4 changes: 2 additions & 2 deletions payjoin-ffi/dart/test/test_payjoin_integration_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
18 changes: 9 additions & 9 deletions payjoin-ffi/dart/test/test_payjoin_unit_test.dart
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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<payjoin.ReplayResult>(),
Expand All @@ -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");
Expand Down
6 changes: 3 additions & 3 deletions payjoin-ffi/javascript/scripts/fix-imports.js
Original file line number Diff line number Diff line change
@@ -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);
4 changes: 2 additions & 2 deletions payjoin-ffi/javascript/src/index.ts
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
2 changes: 1 addition & 1 deletion payjoin-ffi/python/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ build/
*.dll

# Auto-generated bindings python file
src/payjoin/payjoin_ffi.py
src/payjoin/payjoin.py
src/payjoin/bitcoin.py
2 changes: 1 addition & 1 deletion payjoin-ffi/python/src/payjoin/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from payjoin.payjoin_ffi import *
from payjoin.payjoin import *
14 changes: 7 additions & 7 deletions payjoin-ffi/python/test/test_payjoin_unit_test.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down Expand Up @@ -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 = []
Expand All @@ -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 = []
Expand All @@ -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")),
Expand Down
2 changes: 1 addition & 1 deletion payjoin-ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
3 changes: 3 additions & 0 deletions payjoin-ffi/src/payjoin.udl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
namespace payjoin {

};
3 changes: 0 additions & 3 deletions payjoin-ffi/src/payjoin_ffi.udl

This file was deleted.

2 changes: 1 addition & 1 deletion payjoin-ffi/uniffi-bindgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down