diff --git a/ios/Classes/frb_generated.h b/ios/Classes/frb_generated.h index ef2dc6a..183ce1a 100644 --- a/ios/Classes/frb_generated.h +++ b/ios/Classes/frb_generated.h @@ -299,7 +299,8 @@ void frbgen_payjoin_flutter_wire__crate__api__receive__ffi_active_session_extrac WireSyncRust2DartDco frbgen_payjoin_flutter_wire__crate__api__receive__ffi_active_session_pj_uri_builder(struct wire_cst_ffi_active_session *that); -WireSyncRust2DartDco frbgen_payjoin_flutter_wire__crate__api__receive__ffi_active_session_pj_url(struct wire_cst_ffi_active_session *that); +void frbgen_payjoin_flutter_wire__crate__api__receive__ffi_active_session_pj_url(int64_t port_, + struct wire_cst_ffi_active_session *that); void frbgen_payjoin_flutter_wire__crate__api__receive__ffi_active_session_process_res(int64_t port_, struct wire_cst_ffi_active_session *that, diff --git a/lib/receive/v2.dart b/lib/receive/v2.dart index bb255ea..d70947c 100644 --- a/lib/receive/v2.dart +++ b/lib/receive/v2.dart @@ -48,7 +48,7 @@ class SessionInitializer extends FfiSessionInitializer { try { final res = await super.extractReq(); final request = Request( - url: Url.fromStr(res.$1.url.asString()), + url: await Url.fromStr(res.$1.url.asString()), body: res.$1.body, ); return (request, res.$2); @@ -66,7 +66,7 @@ class ActiveSession extends FfiActiveSession { try { final res = await super.extractReq(); final request = Request( - url: Url.fromStr(res.$1.url.asString()), + url: await Url.fromStr(res.$1.url.asString()), body: res.$1.body, ); return (request, res.$2); @@ -93,8 +93,8 @@ class ActiveSession extends FfiActiveSession { /// The contents of the `&pj=` query parameter including the base64url-encoded public key receiver subdirectory. /// This identifies a session at the payjoin directory server. @override - Url pjUrl() { - final res = super.pjUrl(); + Future pjUrl() async { + final res = await super.pjUrl(); return Url.fromStr(res.asString()); } @@ -310,7 +310,7 @@ class PayjoinProposal extends FfiV2PayjoinProposal { try { final res = await super.extractV2Req(); final request = Request( - url: Url.fromStr(res.$1.url.asString()), + url: await Url.fromStr(res.$1.url.asString()), body: res.$1.body, ); return (request, res.$2); diff --git a/lib/send.dart b/lib/send.dart index 59b998a..73b6560 100644 --- a/lib/send.dart +++ b/lib/send.dart @@ -81,7 +81,7 @@ class RequestContext extends FfiRequestContext { try { final res = await super.extractV1(); final request = common.Request( - url: Url.fromStr((res.$1.url.asString())), + url: await Url.fromStr((res.$1.url.asString())), body: res.$1.body, ); return (request, ContextV1._(field0: res.$2.field0)); @@ -99,7 +99,7 @@ class RequestContext extends FfiRequestContext { ohttpProxyUrl: ohttpProxyUrl, ); final request = common.Request( - url: Url.fromStr((res.$1.url.asString())), + url: await Url.fromStr((res.$1.url.asString())), body: res.$1.body, ); return (request, ContextV2._(field0: res.$2.field0)); diff --git a/lib/src/generated/api/receive.dart b/lib/src/generated/api/receive.dart index b22e888..185e421 100644 --- a/lib/src/generated/api/receive.dart +++ b/lib/src/generated/api/receive.dart @@ -30,7 +30,8 @@ class FfiActiveSession { that: this, ); - FfiUrl pjUrl() => core.instance.api.crateApiReceiveFfiActiveSessionPjUrl( + Future pjUrl() => + core.instance.api.crateApiReceiveFfiActiveSessionPjUrl( that: this, ); diff --git a/lib/src/generated/frb_generated.dart b/lib/src/generated/frb_generated.dart index 2243c5b..0a7a2d0 100644 --- a/lib/src/generated/frb_generated.dart +++ b/lib/src/generated/frb_generated.dart @@ -81,7 +81,8 @@ abstract class coreApi extends BaseApi { FfiPjUriBuilder crateApiReceiveFfiActiveSessionPjUriBuilder( {required FfiActiveSession that}); - FfiUrl crateApiReceiveFfiActiveSessionPjUrl({required FfiActiveSession that}); + Future crateApiReceiveFfiActiveSessionPjUrl( + {required FfiActiveSession that}); Future crateApiReceiveFfiActiveSessionProcessRes( {required FfiActiveSession that, @@ -650,12 +651,13 @@ class coreApiImpl extends coreApiImplPlatform implements coreApi { ); @override - FfiUrl crateApiReceiveFfiActiveSessionPjUrl( + Future crateApiReceiveFfiActiveSessionPjUrl( {required FfiActiveSession that}) { - return handler.executeSync(SyncTask( - callFfi: () { + return handler.executeNormal(NormalTask( + callFfi: (port_) { var arg0 = cst_encode_box_autoadd_ffi_active_session(that); - return wire.wire__crate__api__receive__ffi_active_session_pj_url(arg0); + return wire.wire__crate__api__receive__ffi_active_session_pj_url( + port_, arg0); }, codec: DcoCodec( decodeSuccessData: dco_decode_ffi_url, diff --git a/lib/src/generated/frb_generated.io.dart b/lib/src/generated/frb_generated.io.dart index 6fb64a4..668e41e 100644 --- a/lib/src/generated/frb_generated.io.dart +++ b/lib/src/generated/frb_generated.io.dart @@ -2689,23 +2689,24 @@ class coreWire implements BaseWire { WireSyncRust2DartDco Function( ffi.Pointer)>(); - WireSyncRust2DartDco wire__crate__api__receive__ffi_active_session_pj_url( + void wire__crate__api__receive__ffi_active_session_pj_url( + int port_, ffi.Pointer that, ) { return _wire__crate__api__receive__ffi_active_session_pj_url( + port_, that, ); } late final _wire__crate__api__receive__ffi_active_session_pj_urlPtr = _lookup< ffi.NativeFunction< - WireSyncRust2DartDco Function( - ffi.Pointer)>>( + ffi.Void Function( + ffi.Int64, ffi.Pointer)>>( 'frbgen_payjoin_flutter_wire__crate__api__receive__ffi_active_session_pj_url'); late final _wire__crate__api__receive__ffi_active_session_pj_url = _wire__crate__api__receive__ffi_active_session_pj_urlPtr.asFunction< - WireSyncRust2DartDco Function( - ffi.Pointer)>(); + void Function(int, ffi.Pointer)>(); void wire__crate__api__receive__ffi_active_session_process_res( int port_, diff --git a/lib/uri.dart b/lib/uri.dart index ea3b416..c16b163 100644 --- a/lib/uri.dart +++ b/lib/uri.dart @@ -146,8 +146,9 @@ class PjUri extends FfiPjUri { class Url extends FfiUrl { Url._({required super.field0}); - static Url fromStr(String uri) { + static Future fromStr(String uri) async { try { + await PConfig.initializeApp(); final res = FfiUrl.fromStr(url: uri); return Url._(field0: res.field0); } on error.PayjoinError catch (e) { diff --git a/rust/src/api/receive.rs b/rust/src/api/receive.rs index 7341e68..3eb7ce1 100644 --- a/rust/src/api/receive.rs +++ b/rust/src/api/receive.rs @@ -300,7 +300,6 @@ impl FfiActiveSession { self.0.public_key() } - #[frb(sync)] pub fn pj_url(&self) -> FfiUrl { self.0.pj_url().into() } diff --git a/rust/src/frb_generated.io.rs b/rust/src/frb_generated.io.rs index bed73db..8b6b84d 100644 --- a/rust/src/frb_generated.io.rs +++ b/rust/src/frb_generated.io.rs @@ -1341,9 +1341,10 @@ pub extern "C" fn frbgen_payjoin_flutter_wire__crate__api__receive__ffi_active_s #[no_mangle] pub extern "C" fn frbgen_payjoin_flutter_wire__crate__api__receive__ffi_active_session_pj_url( + port_: i64, that: *mut wire_cst_ffi_active_session, -) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { - wire__crate__api__receive__ffi_active_session_pj_url_impl(that) +) { + wire__crate__api__receive__ffi_active_session_pj_url_impl(port_, that) } #[no_mangle] diff --git a/rust/src/frb_generated.rs b/rust/src/frb_generated.rs index ef29fc2..ba2b042 100644 --- a/rust/src/frb_generated.rs +++ b/rust/src/frb_generated.rs @@ -119,21 +119,25 @@ fn wire__crate__api__receive__ffi_active_session_pj_uri_builder_impl( ) } fn wire__crate__api__receive__ffi_active_session_pj_url_impl( + port_: flutter_rust_bridge::for_generated::MessagePort, that: impl CstDecode, -) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { - FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::( flutter_rust_bridge::for_generated::TaskInfo { debug_name: "ffi_active_session_pj_url", - port: None, - mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + port: Some(port_), + mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, }, move || { let api_that = that.cst_decode(); - transform_result_dco::<_, _, ()>((move || { - let output_ok = - Result::<_, ()>::Ok(crate::api::receive::FfiActiveSession::pj_url(&api_that))?; - Ok(output_ok) - })()) + move |context| { + transform_result_dco::<_, _, ()>((move || { + let output_ok = Result::<_, ()>::Ok( + crate::api::receive::FfiActiveSession::pj_url(&api_that), + )?; + Ok(output_ok) + })()) + } }, ) }