Skip to content

Commit c49a838

Browse files
committed
Expose label and messge params on Uri type
Exposing these params means that the lib will expose full bip21 uri parsing functionality Currently many apps have custom bip21 logic and this eliminates the need for that
1 parent efc5de8 commit c49a838

9 files changed

Lines changed: 157 additions & 4 deletions

File tree

ios/Classes/frb_generated.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,10 @@ WireSyncRust2DartDco frbgen_payjoin_flutter_wire__crate__api__uri__ffi_uri_as_st
494494

495495
WireSyncRust2DartDco frbgen_payjoin_flutter_wire__crate__api__uri__ffi_uri_check_pj_supported(struct wire_cst_ffi_uri *that);
496496

497+
WireSyncRust2DartDco frbgen_payjoin_flutter_wire__crate__api__uri__ffi_uri_label(struct wire_cst_ffi_uri *that);
498+
499+
WireSyncRust2DartDco frbgen_payjoin_flutter_wire__crate__api__uri__ffi_uri_message(struct wire_cst_ffi_uri *that);
500+
497501
WireSyncRust2DartDco frbgen_payjoin_flutter_wire__crate__api__uri__ffi_uri_parse(struct wire_cst_list_prim_u_8_strict *uri);
498502

499503
WireSyncRust2DartDco frbgen_payjoin_flutter_wire__crate__api__uri__ffi_url_as_string(struct wire_cst_ffi_url *that);
@@ -790,6 +794,8 @@ static int64_t dummy_method_to_enforce_bundling(void) {
790794
dummy_var ^= ((int64_t) (void*) frbgen_payjoin_flutter_wire__crate__api__uri__ffi_uri_amount_sats);
791795
dummy_var ^= ((int64_t) (void*) frbgen_payjoin_flutter_wire__crate__api__uri__ffi_uri_as_string);
792796
dummy_var ^= ((int64_t) (void*) frbgen_payjoin_flutter_wire__crate__api__uri__ffi_uri_check_pj_supported);
797+
dummy_var ^= ((int64_t) (void*) frbgen_payjoin_flutter_wire__crate__api__uri__ffi_uri_label);
798+
dummy_var ^= ((int64_t) (void*) frbgen_payjoin_flutter_wire__crate__api__uri__ffi_uri_message);
793799
dummy_var ^= ((int64_t) (void*) frbgen_payjoin_flutter_wire__crate__api__uri__ffi_uri_parse);
794800
dummy_var ^= ((int64_t) (void*) frbgen_payjoin_flutter_wire__crate__api__uri__ffi_url_as_string);
795801
dummy_var ^= ((int64_t) (void*) frbgen_payjoin_flutter_wire__crate__api__uri__ffi_url_parse);

lib/src/generated/api/uri.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,14 @@ class FfiUri {
130130
that: this,
131131
);
132132

133+
String? label() => core.instance.api.crateApiUriFfiUriLabel(
134+
that: this,
135+
);
136+
137+
String? message() => core.instance.api.crateApiUriFfiUriMessage(
138+
that: this,
139+
);
140+
133141
static FfiUri parse({required String uri}) =>
134142
core.instance.api.crateApiUriFfiUriParse(uri: uri);
135143

lib/src/generated/frb_generated.dart

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class core extends BaseEntrypoint<coreApi, coreApiImpl, coreWire> {
6262
String get codegenVersion => '2.0.0';
6363

6464
@override
65-
int get rustContentHash => 685157858;
65+
int get rustContentHash => -1997949636;
6666

6767
static const kDefaultExternalLibraryLoaderConfig =
6868
ExternalLibraryLoaderConfig(
@@ -272,6 +272,10 @@ abstract class coreApi extends BaseApi {
272272

273273
FfiPjUri crateApiUriFfiUriCheckPjSupported({required FfiUri that});
274274

275+
String? crateApiUriFfiUriLabel({required FfiUri that});
276+
277+
String? crateApiUriFfiUriMessage({required FfiUri that});
278+
275279
FfiUri crateApiUriFfiUriParse({required String uri});
276280

277281
String crateApiUriFfiUrlAsString({required FfiUrl that});
@@ -2070,6 +2074,50 @@ class coreApiImpl extends coreApiImplPlatform implements coreApi {
20702074
argNames: ["that"],
20712075
);
20722076

2077+
@override
2078+
String? crateApiUriFfiUriLabel({required FfiUri that}) {
2079+
return handler.executeSync(SyncTask(
2080+
callFfi: () {
2081+
var arg0 = cst_encode_box_autoadd_ffi_uri(that);
2082+
return wire.wire__crate__api__uri__ffi_uri_label(arg0);
2083+
},
2084+
codec: DcoCodec(
2085+
decodeSuccessData: dco_decode_opt_String,
2086+
decodeErrorData: null,
2087+
),
2088+
constMeta: kCrateApiUriFfiUriLabelConstMeta,
2089+
argValues: [that],
2090+
apiImpl: this,
2091+
));
2092+
}
2093+
2094+
TaskConstMeta get kCrateApiUriFfiUriLabelConstMeta => const TaskConstMeta(
2095+
debugName: "ffi_uri_label",
2096+
argNames: ["that"],
2097+
);
2098+
2099+
@override
2100+
String? crateApiUriFfiUriMessage({required FfiUri that}) {
2101+
return handler.executeSync(SyncTask(
2102+
callFfi: () {
2103+
var arg0 = cst_encode_box_autoadd_ffi_uri(that);
2104+
return wire.wire__crate__api__uri__ffi_uri_message(arg0);
2105+
},
2106+
codec: DcoCodec(
2107+
decodeSuccessData: dco_decode_opt_String,
2108+
decodeErrorData: null,
2109+
),
2110+
constMeta: kCrateApiUriFfiUriMessageConstMeta,
2111+
argValues: [that],
2112+
apiImpl: this,
2113+
));
2114+
}
2115+
2116+
TaskConstMeta get kCrateApiUriFfiUriMessageConstMeta => const TaskConstMeta(
2117+
debugName: "ffi_uri_message",
2118+
argNames: ["that"],
2119+
);
2120+
20732121
@override
20742122
FfiUri crateApiUriFfiUriParse({required String uri}) {
20752123
return handler.executeSync(SyncTask(

lib/src/generated/frb_generated.io.dart

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3505,6 +3505,38 @@ class coreWire implements BaseWire {
35053505
_wire__crate__api__uri__ffi_uri_check_pj_supportedPtr.asFunction<
35063506
WireSyncRust2DartDco Function(ffi.Pointer<wire_cst_ffi_uri>)>();
35073507

3508+
WireSyncRust2DartDco wire__crate__api__uri__ffi_uri_label(
3509+
ffi.Pointer<wire_cst_ffi_uri> that,
3510+
) {
3511+
return _wire__crate__api__uri__ffi_uri_label(
3512+
that,
3513+
);
3514+
}
3515+
3516+
late final _wire__crate__api__uri__ffi_uri_labelPtr = _lookup<
3517+
ffi.NativeFunction<
3518+
WireSyncRust2DartDco Function(ffi.Pointer<wire_cst_ffi_uri>)>>(
3519+
'frbgen_payjoin_flutter_wire__crate__api__uri__ffi_uri_label');
3520+
late final _wire__crate__api__uri__ffi_uri_label =
3521+
_wire__crate__api__uri__ffi_uri_labelPtr.asFunction<
3522+
WireSyncRust2DartDco Function(ffi.Pointer<wire_cst_ffi_uri>)>();
3523+
3524+
WireSyncRust2DartDco wire__crate__api__uri__ffi_uri_message(
3525+
ffi.Pointer<wire_cst_ffi_uri> that,
3526+
) {
3527+
return _wire__crate__api__uri__ffi_uri_message(
3528+
that,
3529+
);
3530+
}
3531+
3532+
late final _wire__crate__api__uri__ffi_uri_messagePtr = _lookup<
3533+
ffi.NativeFunction<
3534+
WireSyncRust2DartDco Function(ffi.Pointer<wire_cst_ffi_uri>)>>(
3535+
'frbgen_payjoin_flutter_wire__crate__api__uri__ffi_uri_message');
3536+
late final _wire__crate__api__uri__ffi_uri_message =
3537+
_wire__crate__api__uri__ffi_uri_messagePtr.asFunction<
3538+
WireSyncRust2DartDco Function(ffi.Pointer<wire_cst_ffi_uri>)>();
3539+
35083540
WireSyncRust2DartDco wire__crate__api__uri__ffi_uri_parse(
35093541
ffi.Pointer<wire_cst_list_prim_u_8_strict> uri,
35103542
) {

rust/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ bitcoincore-rpc = "0.19.0"
1616
anyhow = "1.0.68"
1717
[dependencies]
1818
bitcoin-ffi = { git = "https://github.com/bitcoindevkit/bitcoin-ffi.git", rev = "4cd8e644dbf4e001d71d5fffb232480fa5ff2246" }
19-
payjoin_ffi = { git = "https://github.com/LtbLightning/payjoin-ffi", tag = "v0.22.0" }
19+
payjoin_ffi = { git = "https://github.com/LtbLightning/payjoin-ffi", rev = "e9af7dc0832866b043e0d6c70f379e40849ae752" }
20+
2021
flutter_rust_bridge = "=2.0.0"
2122
anyhow = "1.0.68"
2223
tokio = "1.36.0"

rust/src/api/uri.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,14 @@ impl FfiUri {
135135
self.0.amount_sats()
136136
}
137137
#[frb(sync)]
138+
pub fn label(&self) -> Option<String> {
139+
self.0.label()
140+
}
141+
#[frb(sync)]
142+
pub fn message(&self) -> Option<String> {
143+
self.0.message()
144+
}
145+
#[frb(sync)]
138146
pub fn as_string(&self) -> String {
139147
self.0.as_string()
140148
}

rust/src/frb_generated.io.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1632,6 +1632,20 @@ pub extern "C" fn frbgen_payjoin_flutter_wire__crate__api__uri__ffi_uri_check_pj
16321632
wire__crate__api__uri__ffi_uri_check_pj_supported_impl(that)
16331633
}
16341634

1635+
#[no_mangle]
1636+
pub extern "C" fn frbgen_payjoin_flutter_wire__crate__api__uri__ffi_uri_label(
1637+
that: *mut wire_cst_ffi_uri,
1638+
) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco {
1639+
wire__crate__api__uri__ffi_uri_label_impl(that)
1640+
}
1641+
1642+
#[no_mangle]
1643+
pub extern "C" fn frbgen_payjoin_flutter_wire__crate__api__uri__ffi_uri_message(
1644+
that: *mut wire_cst_ffi_uri,
1645+
) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco {
1646+
wire__crate__api__uri__ffi_uri_message_impl(that)
1647+
}
1648+
16351649
#[no_mangle]
16361650
pub extern "C" fn frbgen_payjoin_flutter_wire__crate__api__uri__ffi_uri_parse(
16371651
uri: *mut wire_cst_list_prim_u_8_strict,

rust/src/frb_generated.rs

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ flutter_rust_bridge::frb_generated_boilerplate!(
3939
default_rust_auto_opaque = RustAutoOpaqueNom,
4040
);
4141
pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_VERSION: &str = "2.0.0";
42-
pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_CONTENT_HASH: i32 = 685157858;
42+
pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_CONTENT_HASH: i32 = -1997949636;
4343

4444
// Section: executor
4545

@@ -1490,6 +1490,42 @@ fn wire__crate__api__uri__ffi_uri_check_pj_supported_impl(
14901490
},
14911491
)
14921492
}
1493+
fn wire__crate__api__uri__ffi_uri_label_impl(
1494+
that: impl CstDecode<crate::api::uri::FfiUri>,
1495+
) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco {
1496+
FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::<flutter_rust_bridge::for_generated::DcoCodec, _>(
1497+
flutter_rust_bridge::for_generated::TaskInfo {
1498+
debug_name: "ffi_uri_label",
1499+
port: None,
1500+
mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync,
1501+
},
1502+
move || {
1503+
let api_that = that.cst_decode();
1504+
transform_result_dco::<_, _, ()>((move || {
1505+
let output_ok = Result::<_, ()>::Ok(crate::api::uri::FfiUri::label(&api_that))?;
1506+
Ok(output_ok)
1507+
})())
1508+
},
1509+
)
1510+
}
1511+
fn wire__crate__api__uri__ffi_uri_message_impl(
1512+
that: impl CstDecode<crate::api::uri::FfiUri>,
1513+
) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco {
1514+
FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::<flutter_rust_bridge::for_generated::DcoCodec, _>(
1515+
flutter_rust_bridge::for_generated::TaskInfo {
1516+
debug_name: "ffi_uri_message",
1517+
port: None,
1518+
mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync,
1519+
},
1520+
move || {
1521+
let api_that = that.cst_decode();
1522+
transform_result_dco::<_, _, ()>((move || {
1523+
let output_ok = Result::<_, ()>::Ok(crate::api::uri::FfiUri::message(&api_that))?;
1524+
Ok(output_ok)
1525+
})())
1526+
},
1527+
)
1528+
}
14931529
fn wire__crate__api__uri__ffi_uri_parse_impl(
14941530
uri: impl CstDecode<String>,
14951531
) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco {

0 commit comments

Comments
 (0)