diff --git a/CHANGELOG.md b/CHANGELOG.md index f697ff8..61c300b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,7 @@ * Expose `NostrSigner` ([Yuki Kishimoto]) * Expose `UnsignedEvent` ([Yuki Kishimoto]) * Expose `EventBuilder` ([Yuki Kishimoto]) +* Expose `Client::send_event_builder` ([Yuki Kishimoto]) ### Fixed diff --git a/lib/src/rust/api/client.dart b/lib/src/rust/api/client.dart index 803aa2a..3b94491 100644 --- a/lib/src/rust/api/client.dart +++ b/lib/src/rust/api/client.dart @@ -7,6 +7,7 @@ import '../frb_generated.dart'; import 'client/builder.dart'; import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; import 'protocol/event.dart'; +import 'protocol/event/builder.dart'; // These function are ignored because they are on traits that is not defined in current crate (put an empty `#[frb]` on it to unignore): `from` @@ -37,4 +38,11 @@ abstract class Client implements RustOpaqueInterface { /// Send `Event` to all relays with `WRITE` flag. /// If `gossip` option is enabled, the event will be sent also to NIP65 relays (automatically discovered). Future sendEvent({required Event event}); + + /// Send event + /// + /// Take an [`EventBuilder`], sign it by using the [`NostrSigner`] and broadcast to relays (check [`Client::send_event`] from more details). + /// + /// Return an error if the [`NostrSigner`] is not set. + Future sendEventBuilder({required EventBuilder builder}); } diff --git a/lib/src/rust/frb_generated.dart b/lib/src/rust/frb_generated.dart index 6450833..478ba94 100644 --- a/lib/src/rust/frb_generated.dart +++ b/lib/src/rust/frb_generated.dart @@ -70,7 +70,7 @@ class NostrSdk String get codegenVersion => '2.0.0'; @override - int get rustContentHash => -54195377; + int get rustContentHash => -258841678; static const kDefaultExternalLibraryLoaderConfig = ExternalLibraryLoaderConfig( @@ -95,6 +95,9 @@ abstract class NostrSdkApi extends BaseApi { Future crateApiClientClientSendEvent( {required Client that, required Event event}); + Future crateApiClientClientSendEventBuilder( + {required Client that, required EventBuilder builder}); + Client crateApiClientBuilderClientBuilderBuild({required ClientBuilder that}); ClientBuilder crateApiClientBuilderClientBuilderNew(); @@ -564,6 +567,35 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { argNames: ["that", "event"], ); + @override + Future crateApiClientClientSendEventBuilder( + {required Client that, required EventBuilder builder}) { + return handler.executeNormal(NormalTask( + callFfi: (port_) { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Client( + that, serializer); + sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder( + builder, serializer); + pdeCallFfi(generalizedFrbRustBinding, serializer, + funcId: 7, port: port_); + }, + codec: SseCodec( + decodeSuccessData: sse_decode_String, + decodeErrorData: sse_decode_AnyhowException, + ), + constMeta: kCrateApiClientClientSendEventBuilderConstMeta, + argValues: [that, builder], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiClientClientSendEventBuilderConstMeta => + const TaskConstMeta( + debugName: "Client_send_event_builder", + argNames: ["that", "builder"], + ); + @override Client crateApiClientBuilderClientBuilderBuild( {required ClientBuilder that}) { @@ -572,7 +604,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_ClientBuilder( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 7)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 8)!; }, codec: SseCodec( decodeSuccessData: @@ -596,7 +628,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { return handler.executeSync(SyncTask( callFfi: () { final serializer = SseSerializer(generalizedFrbRustBinding); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 8)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 9)!; }, codec: SseCodec( decodeSuccessData: @@ -625,7 +657,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { that, serializer); sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_ClientOptions( opts, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 9)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 10)!; }, codec: SseCodec( decodeSuccessData: @@ -654,7 +686,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { that, serializer); sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_NostrSigner( signer, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 10)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 11)!; }, codec: SseCodec( decodeSuccessData: @@ -682,7 +714,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_ClientOptions( that, serializer); sse_encode_bool(val, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 11)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 12)!; }, codec: SseCodec( decodeSuccessData: @@ -710,7 +742,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_ClientOptions( that, serializer); sse_encode_bool(enabled, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 12)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 13)!; }, codec: SseCodec( decodeSuccessData: @@ -741,7 +773,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { that, serializer); sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Connection( connection, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 13)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 14)!; }, codec: SseCodec( decodeSuccessData: @@ -769,7 +801,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_ClientOptions( that, serializer); sse_encode_bool(enabled, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 14)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 15)!; }, codec: SseCodec( decodeSuccessData: @@ -797,7 +829,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_ClientOptions( that, serializer); sse_encode_u_8(difficulty, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 15)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 16)!; }, codec: SseCodec( decodeSuccessData: @@ -821,7 +853,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { return handler.executeSync(SyncTask( callFfi: () { final serializer = SseSerializer(generalizedFrbRustBinding); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 16)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 17)!; }, codec: SseCodec( decodeSuccessData: @@ -849,7 +881,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Connection( that, serializer); sse_encode_String(addr, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 17)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 18)!; }, codec: SseCodec( decodeSuccessData: @@ -876,7 +908,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Connection( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 18)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 19)!; }, codec: SseCodec( decodeSuccessData: @@ -904,7 +936,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Connection( that, serializer); sse_encode_String(dataPath, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 19)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 20)!; }, codec: SseCodec( decodeSuccessData: @@ -933,7 +965,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Connection( that, serializer); sse_encode_box_autoadd_connection_mode(mode, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 20)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 21)!; }, codec: SseCodec( decodeSuccessData: @@ -957,7 +989,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { return handler.executeSync(SyncTask( callFfi: () { final serializer = SseSerializer(generalizedFrbRustBinding); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 21)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 22)!; }, codec: SseCodec( decodeSuccessData: @@ -985,7 +1017,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Connection( that, serializer); sse_encode_connection_target(target, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 22)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 23)!; }, codec: SseCodec( decodeSuccessData: @@ -1011,7 +1043,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Event( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 23)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 24)!; }, codec: SseCodec( decodeSuccessData: sse_decode_String, @@ -1036,7 +1068,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Event( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 24)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 25)!; }, codec: SseCodec( decodeSuccessData: sse_decode_String, @@ -1061,7 +1093,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Event( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 25)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 26)!; }, codec: SseCodec( decodeSuccessData: @@ -1087,7 +1119,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Event( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 26)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 27)!; }, codec: SseCodec( decodeSuccessData: sse_decode_String, @@ -1112,7 +1144,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Event( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 27)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 28)!; }, codec: SseCodec( decodeSuccessData: sse_decode_u_64, @@ -1136,7 +1168,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { callFfi: () { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_String(json, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 28)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 29)!; }, codec: SseCodec( decodeSuccessData: @@ -1162,7 +1194,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Event( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 29)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 30)!; }, codec: SseCodec( decodeSuccessData: sse_decode_String, @@ -1187,7 +1219,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Event( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 30)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 31)!; }, codec: SseCodec( decodeSuccessData: sse_decode_bool, @@ -1212,7 +1244,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Event( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 31)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 32)!; }, codec: SseCodec( decodeSuccessData: sse_decode_bool, @@ -1237,7 +1269,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Event( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 32)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 33)!; }, codec: SseCodec( decodeSuccessData: sse_decode_u_16, @@ -1262,7 +1294,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Event( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 33)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 34)!; }, codec: SseCodec( decodeSuccessData: sse_decode_String, @@ -1287,7 +1319,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Event( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 34)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 35)!; }, codec: SseCodec( decodeSuccessData: @@ -1313,7 +1345,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Event( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 35)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 36)!; }, codec: SseCodec( decodeSuccessData: sse_decode_unit, @@ -1338,7 +1370,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Event( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 36)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 37)!; }, codec: SseCodec( decodeSuccessData: sse_decode_bool, @@ -1363,7 +1395,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Event( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 37)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 38)!; }, codec: SseCodec( decodeSuccessData: sse_decode_bool, @@ -1391,7 +1423,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { that, serializer); sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_PublicKey( publicKey, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 38)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 39)!; }, codec: SseCodec( decodeSuccessData: @@ -1419,7 +1451,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder( that, serializer); sse_encode_u_64(createdAt, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 39)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 40)!; }, codec: SseCodec( decodeSuccessData: @@ -1448,7 +1480,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_u_16(kind, serializer); sse_encode_String(content, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 40)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 41)!; }, codec: SseCodec( decodeSuccessData: @@ -1476,7 +1508,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder( that, serializer); sse_encode_u_8(difficulty, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 41)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 42)!; }, codec: SseCodec( decodeSuccessData: @@ -1506,7 +1538,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_NostrSigner( signer, serializer); pdeCallFfi(generalizedFrbRustBinding, serializer, - funcId: 42, port: port_); + funcId: 43, port: port_); }, codec: SseCodec( decodeSuccessData: @@ -1535,7 +1567,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { that, serializer); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Keys( keys, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 43)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 44)!; }, codec: SseCodec( decodeSuccessData: @@ -1565,7 +1597,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { that, serializer); sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Tag( tag, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 44)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 45)!; }, codec: SseCodec( decodeSuccessData: @@ -1594,7 +1626,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { that, serializer); sse_encode_list_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Tag( tags, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 45)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 46)!; }, codec: SseCodec( decodeSuccessData: @@ -1620,7 +1652,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { callFfi: () { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_String(content, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 46)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 47)!; }, codec: SseCodec( decodeSuccessData: @@ -1647,7 +1679,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Tag( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 47)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 48)!; }, codec: SseCodec( decodeSuccessData: sse_decode_list_String, @@ -1672,7 +1704,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Tag( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 48)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 49)!; }, codec: SseCodec( decodeSuccessData: sse_decode_opt_String, @@ -1697,7 +1729,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Tag( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 49)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 50)!; }, codec: SseCodec( decodeSuccessData: sse_decode_bool, @@ -1722,7 +1754,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Tag( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 50)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 51)!; }, codec: SseCodec( decodeSuccessData: sse_decode_bool, @@ -1747,7 +1779,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Tag( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 51)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 52)!; }, codec: SseCodec( decodeSuccessData: sse_decode_bool, @@ -1772,7 +1804,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Tag( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 52)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 53)!; }, codec: SseCodec( decodeSuccessData: sse_decode_String, @@ -1796,7 +1828,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { callFfi: () { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_list_String(tag, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 53)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 54)!; }, codec: SseCodec( decodeSuccessData: @@ -1822,7 +1854,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Tag( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 54)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 55)!; }, codec: SseCodec( decodeSuccessData: sse_decode_list_String, @@ -1849,7 +1881,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_UnsignedEvent( that, serializer); sse_encode_String(sig, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 55)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 56)!; }, codec: SseCodec( decodeSuccessData: @@ -1878,7 +1910,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_UnsignedEvent( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 56)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 57)!; }, codec: SseCodec( decodeSuccessData: sse_decode_String, @@ -1905,7 +1937,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_UnsignedEvent( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 57)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 58)!; }, codec: SseCodec( decodeSuccessData: sse_decode_String, @@ -1933,7 +1965,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_UnsignedEvent( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 58)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 59)!; }, codec: SseCodec( decodeSuccessData: @@ -1961,7 +1993,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_UnsignedEvent( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 59)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 60)!; }, codec: SseCodec( decodeSuccessData: sse_decode_String, @@ -1988,7 +2020,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_UnsignedEvent( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 60)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 61)!; }, codec: SseCodec( decodeSuccessData: sse_decode_u_64, @@ -2014,7 +2046,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { callFfi: () { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_String(json, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 61)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 62)!; }, codec: SseCodec( decodeSuccessData: @@ -2042,7 +2074,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_UnsignedEvent( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 62)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 63)!; }, codec: SseCodec( decodeSuccessData: sse_decode_opt_String, @@ -2068,7 +2100,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_UnsignedEvent( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 63)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 64)!; }, codec: SseCodec( decodeSuccessData: sse_decode_u_16, @@ -2094,7 +2126,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_UnsignedEvent( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 64)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 65)!; }, codec: SseCodec( decodeSuccessData: @@ -2118,7 +2150,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { return handler.executeSync(SyncTask( callFfi: () { final serializer = SseSerializer(generalizedFrbRustBinding); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 65)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 66)!; }, codec: SseCodec( decodeSuccessData: @@ -2144,7 +2176,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_SecretKey( secretKey, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 66)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 67)!; }, codec: SseCodec( decodeSuccessData: @@ -2168,7 +2200,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { callFfi: () { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_String(secretKey, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 67)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 68)!; }, codec: SseCodec( decodeSuccessData: @@ -2194,7 +2226,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Keys( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 68)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 69)!; }, codec: SseCodec( decodeSuccessData: @@ -2220,7 +2252,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Keys( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 69)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 70)!; }, codec: SseCodec( decodeSuccessData: @@ -2246,7 +2278,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { callFfi: () { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_list_prim_u_8_loose(publicKey, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 70)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 71)!; }, codec: SseCodec( decodeSuccessData: @@ -2272,7 +2304,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { callFfi: () { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_String(publicKey, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 71)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 72)!; }, codec: SseCodec( decodeSuccessData: @@ -2299,7 +2331,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_PublicKey( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 72)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 73)!; }, codec: SseCodec( decodeSuccessData: sse_decode_String, @@ -2324,7 +2356,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_PublicKey( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 73)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 74)!; }, codec: SseCodec( decodeSuccessData: sse_decode_String, @@ -2350,7 +2382,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_PublicKey( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 74)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 75)!; }, codec: SseCodec( decodeSuccessData: sse_decode_String, @@ -2375,7 +2407,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { callFfi: () { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_list_prim_u_8_loose(secretKey, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 75)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 76)!; }, codec: SseCodec( decodeSuccessData: @@ -2399,7 +2431,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { return handler.executeSync(SyncTask( callFfi: () { final serializer = SseSerializer(generalizedFrbRustBinding); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 76)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 77)!; }, codec: SseCodec( decodeSuccessData: @@ -2425,7 +2457,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { callFfi: () { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_String(secretKey, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 77)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 78)!; }, codec: SseCodec( decodeSuccessData: @@ -2452,7 +2484,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_SecretKey( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 78)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 79)!; }, codec: SseCodec( decodeSuccessData: sse_decode_String, @@ -2478,7 +2510,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_SecretKey( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 79)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 80)!; }, codec: SseCodec( decodeSuccessData: sse_decode_String, @@ -2505,7 +2537,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_NostrSigner( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 80)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 81)!; }, codec: SseCodec( decodeSuccessData: sse_decode_signer_backend, @@ -2532,7 +2564,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_NostrSigner( that, serializer); pdeCallFfi(generalizedFrbRustBinding, serializer, - funcId: 81, port: port_); + funcId: 82, port: port_); }, codec: SseCodec( decodeSuccessData: @@ -2558,7 +2590,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Keys( keys, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 82)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 83)!; }, codec: SseCodec( decodeSuccessData: @@ -2591,7 +2623,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { publicKey, serializer); sse_encode_String(encryptedContent, serializer); pdeCallFfi(generalizedFrbRustBinding, serializer, - funcId: 83, port: port_); + funcId: 84, port: port_); }, codec: SseCodec( decodeSuccessData: sse_decode_String, @@ -2623,7 +2655,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { publicKey, serializer); sse_encode_String(content, serializer); pdeCallFfi(generalizedFrbRustBinding, serializer, - funcId: 84, port: port_); + funcId: 85, port: port_); }, codec: SseCodec( decodeSuccessData: sse_decode_String, @@ -2655,7 +2687,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { publicKey, serializer); sse_encode_String(payload, serializer); pdeCallFfi(generalizedFrbRustBinding, serializer, - funcId: 85, port: port_); + funcId: 86, port: port_); }, codec: SseCodec( decodeSuccessData: sse_decode_String, @@ -2687,7 +2719,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { publicKey, serializer); sse_encode_String(content, serializer); pdeCallFfi(generalizedFrbRustBinding, serializer, - funcId: 86, port: port_); + funcId: 87, port: port_); }, codec: SseCodec( decodeSuccessData: sse_decode_String, @@ -2716,7 +2748,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_UnsignedEvent( unsignedEvent, serializer); pdeCallFfi(generalizedFrbRustBinding, serializer, - funcId: 87, port: port_); + funcId: 88, port: port_); }, codec: SseCodec( decodeSuccessData: @@ -4297,6 +4329,15 @@ class ClientImpl extends RustOpaque implements Client { /// If `gossip` option is enabled, the event will be sent also to NIP65 relays (automatically discovered). Future sendEvent({required Event event}) => NostrSdk.instance.api .crateApiClientClientSendEvent(that: this, event: event); + + /// Send event + /// + /// Take an [`EventBuilder`], sign it by using the [`NostrSigner`] and broadcast to relays (check [`Client::send_event`] from more details). + /// + /// Return an error if the [`NostrSigner`] is not set. + Future sendEventBuilder({required EventBuilder builder}) => + NostrSdk.instance.api + .crateApiClientClientSendEventBuilder(that: this, builder: builder); } @sealed diff --git a/rust/src/api/client/mod.rs b/rust/src/api/client/mod.rs index 537eef9..74f4c78 100644 --- a/rust/src/api/client/mod.rs +++ b/rust/src/api/client/mod.rs @@ -11,6 +11,7 @@ pub mod options; use self::builder::_ClientBuilder; use super::protocol::event::_Event; +use super::protocol::event::builder::_EventBuilder; #[frb(name = "Client")] pub struct _Client { @@ -63,4 +64,14 @@ impl _Client { let output = self.inner.send_event(event.inner).await?; Ok(output.id().to_string()) } + + /// Send event + /// + /// Take an [`EventBuilder`], sign it by using the [`NostrSigner`] and broadcast to relays (check [`Client::send_event`] from more details). + /// + /// Return an error if the [`NostrSigner`] is not set. + pub async fn send_event_builder(&self, builder: _EventBuilder) -> Result { + let output = self.inner.send_event_builder(builder.inner).await?; + Ok(output.id().to_string()) + } } diff --git a/rust/src/frb_generated.rs b/rust/src/frb_generated.rs index b0b3562..522c898 100644 --- a/rust/src/frb_generated.rs +++ b/rust/src/frb_generated.rs @@ -48,7 +48,7 @@ flutter_rust_bridge::frb_generated_boilerplate!( default_rust_auto_opaque = RustAutoOpaqueMoi, ); pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_VERSION: &str = "2.0.0"; -pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_CONTENT_HASH: i32 = -54195377; +pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_CONTENT_HASH: i32 = -258841678; // Section: executor @@ -321,6 +321,66 @@ fn wire__crate__api__client__Client_send_event_impl( }, ) } +fn wire__crate__api__client__Client_send_event_builder_impl( + port_: flutter_rust_bridge::for_generated::MessagePort, + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "Client_send_event_builder", + port: Some(port_), + mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_that = , + >>::sse_decode(&mut deserializer); + let api_builder = <_EventBuilder>::sse_decode(&mut deserializer); + deserializer.end(); + move |context| async move { + transform_result_sse::<_, flutter_rust_bridge::for_generated::anyhow::Error>( + (move || async move { + let mut api_that_guard = None; + let decode_indices_ = + flutter_rust_bridge::for_generated::lockable_compute_decode_order( + vec![flutter_rust_bridge::for_generated::LockableOrderInfo::new( + &api_that, 0, false, + )], + ); + for i in decode_indices_ { + match i { + 0 => { + api_that_guard = + Some(api_that.lockable_decode_async_ref().await) + } + _ => unreachable!(), + } + } + let api_that_guard = api_that_guard.unwrap(); + let output_ok = crate::api::client::_Client::send_event_builder( + &*api_that_guard, + api_builder, + ) + .await?; + Ok(output_ok) + })() + .await, + ) + } + }, + ) +} fn wire__crate__api__client__builder__ClientBuilder_build_impl( ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, rust_vec_len_: i32, @@ -4612,43 +4672,49 @@ fn pde_ffi_dispatcher_primary_impl( 2 => wire__crate__api__client__Client_add_relay_impl(port, ptr, rust_vec_len, data_len), 4 => wire__crate__api__client__Client_connect_impl(port, ptr, rust_vec_len, data_len), 6 => wire__crate__api__client__Client_send_event_impl(port, ptr, rust_vec_len, data_len), - 42 => wire__crate__api__protocol__event__builder__EventBuilder_sign_impl( + 7 => wire__crate__api__client__Client_send_event_builder_impl( + port, + ptr, + rust_vec_len, + data_len, + ), + 43 => wire__crate__api__protocol__event__builder__EventBuilder_sign_impl( port, ptr, rust_vec_len, data_len, ), - 81 => wire__crate__api__protocol__signer__NostrSigner_get_public_key_impl( + 82 => wire__crate__api__protocol__signer__NostrSigner_get_public_key_impl( port, ptr, rust_vec_len, data_len, ), - 83 => wire__crate__api__protocol__signer__NostrSigner_nip04_decrypt_impl( + 84 => wire__crate__api__protocol__signer__NostrSigner_nip04_decrypt_impl( port, ptr, rust_vec_len, data_len, ), - 84 => wire__crate__api__protocol__signer__NostrSigner_nip04_encrypt_impl( + 85 => wire__crate__api__protocol__signer__NostrSigner_nip04_encrypt_impl( port, ptr, rust_vec_len, data_len, ), - 85 => wire__crate__api__protocol__signer__NostrSigner_nip44_decrypt_impl( + 86 => wire__crate__api__protocol__signer__NostrSigner_nip44_decrypt_impl( port, ptr, rust_vec_len, data_len, ), - 86 => wire__crate__api__protocol__signer__NostrSigner_nip44_encrypt_impl( + 87 => wire__crate__api__protocol__signer__NostrSigner_nip44_encrypt_impl( port, ptr, rust_vec_len, data_len, ), - 87 => wire__crate__api__protocol__signer__NostrSigner_sign_event_impl( + 88 => wire__crate__api__protocol__signer__NostrSigner_sign_event_impl( port, ptr, rust_vec_len, @@ -4668,252 +4734,252 @@ fn pde_ffi_dispatcher_sync_impl( match func_id { 3 => wire__crate__api__client__Client_builder_impl(ptr, rust_vec_len, data_len), 5 => wire__crate__api__client__Client_new_impl(ptr, rust_vec_len, data_len), - 7 => { + 8 => { wire__crate__api__client__builder__ClientBuilder_build_impl(ptr, rust_vec_len, data_len) } - 8 => wire__crate__api__client__builder__ClientBuilder_new_impl(ptr, rust_vec_len, data_len), - 9 => { + 9 => wire__crate__api__client__builder__ClientBuilder_new_impl(ptr, rust_vec_len, data_len), + 10 => { wire__crate__api__client__builder__ClientBuilder_opts_impl(ptr, rust_vec_len, data_len) } - 10 => wire__crate__api__client__builder__ClientBuilder_signer_impl( + 11 => wire__crate__api__client__builder__ClientBuilder_signer_impl( ptr, rust_vec_len, data_len, ), - 11 => wire__crate__api__client__options__ClientOptions_autoconnect_impl( + 12 => wire__crate__api__client__options__ClientOptions_autoconnect_impl( ptr, rust_vec_len, data_len, ), - 12 => wire__crate__api__client__options__ClientOptions_automatic_authentication_impl( + 13 => wire__crate__api__client__options__ClientOptions_automatic_authentication_impl( ptr, rust_vec_len, data_len, ), - 13 => wire__crate__api__client__options__ClientOptions_connection_impl( + 14 => wire__crate__api__client__options__ClientOptions_connection_impl( ptr, rust_vec_len, data_len, ), - 14 => wire__crate__api__client__options__ClientOptions_gossip_impl( + 15 => wire__crate__api__client__options__ClientOptions_gossip_impl( ptr, rust_vec_len, data_len, ), - 15 => wire__crate__api__client__options__ClientOptions_min_pow_impl( + 16 => wire__crate__api__client__options__ClientOptions_min_pow_impl( ptr, rust_vec_len, data_len, ), - 16 => { + 17 => { wire__crate__api__client__options__ClientOptions_new_impl(ptr, rust_vec_len, data_len) } - 17 => wire__crate__api__client__options__Connection_addr_impl(ptr, rust_vec_len, data_len), - 18 => wire__crate__api__client__options__Connection_embedded_tor_impl( + 18 => wire__crate__api__client__options__Connection_addr_impl(ptr, rust_vec_len, data_len), + 19 => wire__crate__api__client__options__Connection_embedded_tor_impl( ptr, rust_vec_len, data_len, ), - 19 => wire__crate__api__client__options__Connection_embedded_tor_with_path_impl( + 20 => wire__crate__api__client__options__Connection_embedded_tor_with_path_impl( ptr, rust_vec_len, data_len, ), - 20 => wire__crate__api__client__options__Connection_mode_impl(ptr, rust_vec_len, data_len), - 21 => wire__crate__api__client__options__Connection_new_impl(ptr, rust_vec_len, data_len), - 22 => { + 21 => wire__crate__api__client__options__Connection_mode_impl(ptr, rust_vec_len, data_len), + 22 => wire__crate__api__client__options__Connection_new_impl(ptr, rust_vec_len, data_len), + 23 => { wire__crate__api__client__options__Connection_target_impl(ptr, rust_vec_len, data_len) } - 23 => wire__crate__api__protocol__event__Event_as_json_impl(ptr, rust_vec_len, data_len), - 24 => wire__crate__api__protocol__event__Event_as_pretty_json_impl( + 24 => wire__crate__api__protocol__event__Event_as_json_impl(ptr, rust_vec_len, data_len), + 25 => wire__crate__api__protocol__event__Event_as_pretty_json_impl( ptr, rust_vec_len, data_len, ), - 25 => wire__crate__api__protocol__event__Event_author_impl(ptr, rust_vec_len, data_len), - 26 => wire__crate__api__protocol__event__Event_content_impl(ptr, rust_vec_len, data_len), - 27 => wire__crate__api__protocol__event__Event_created_at_impl(ptr, rust_vec_len, data_len), - 28 => wire__crate__api__protocol__event__Event_from_json_impl(ptr, rust_vec_len, data_len), - 29 => wire__crate__api__protocol__event__Event_id_impl(ptr, rust_vec_len, data_len), - 30 => wire__crate__api__protocol__event__Event_is_expired_impl(ptr, rust_vec_len, data_len), - 31 => { + 26 => wire__crate__api__protocol__event__Event_author_impl(ptr, rust_vec_len, data_len), + 27 => wire__crate__api__protocol__event__Event_content_impl(ptr, rust_vec_len, data_len), + 28 => wire__crate__api__protocol__event__Event_created_at_impl(ptr, rust_vec_len, data_len), + 29 => wire__crate__api__protocol__event__Event_from_json_impl(ptr, rust_vec_len, data_len), + 30 => wire__crate__api__protocol__event__Event_id_impl(ptr, rust_vec_len, data_len), + 31 => wire__crate__api__protocol__event__Event_is_expired_impl(ptr, rust_vec_len, data_len), + 32 => { wire__crate__api__protocol__event__Event_is_protected_impl(ptr, rust_vec_len, data_len) } - 32 => wire__crate__api__protocol__event__Event_kind_impl(ptr, rust_vec_len, data_len), - 33 => wire__crate__api__protocol__event__Event_signature_impl(ptr, rust_vec_len, data_len), - 34 => wire__crate__api__protocol__event__Event_tags_impl(ptr, rust_vec_len, data_len), - 35 => wire__crate__api__protocol__event__Event_verify_impl(ptr, rust_vec_len, data_len), - 36 => wire__crate__api__protocol__event__Event_verify_id_impl(ptr, rust_vec_len, data_len), - 37 => wire__crate__api__protocol__event__Event_verify_signature_impl( + 33 => wire__crate__api__protocol__event__Event_kind_impl(ptr, rust_vec_len, data_len), + 34 => wire__crate__api__protocol__event__Event_signature_impl(ptr, rust_vec_len, data_len), + 35 => wire__crate__api__protocol__event__Event_tags_impl(ptr, rust_vec_len, data_len), + 36 => wire__crate__api__protocol__event__Event_verify_impl(ptr, rust_vec_len, data_len), + 37 => wire__crate__api__protocol__event__Event_verify_id_impl(ptr, rust_vec_len, data_len), + 38 => wire__crate__api__protocol__event__Event_verify_signature_impl( ptr, rust_vec_len, data_len, ), - 38 => wire__crate__api__protocol__event__builder__EventBuilder_build_impl( + 39 => wire__crate__api__protocol__event__builder__EventBuilder_build_impl( ptr, rust_vec_len, data_len, ), - 39 => wire__crate__api__protocol__event__builder__EventBuilder_custom_created_at_impl( + 40 => wire__crate__api__protocol__event__builder__EventBuilder_custom_created_at_impl( ptr, rust_vec_len, data_len, ), - 40 => wire__crate__api__protocol__event__builder__EventBuilder_new_impl( + 41 => wire__crate__api__protocol__event__builder__EventBuilder_new_impl( ptr, rust_vec_len, data_len, ), - 41 => wire__crate__api__protocol__event__builder__EventBuilder_pow_impl( + 42 => wire__crate__api__protocol__event__builder__EventBuilder_pow_impl( ptr, rust_vec_len, data_len, ), - 43 => wire__crate__api__protocol__event__builder__EventBuilder_sign_with_keys_impl( + 44 => wire__crate__api__protocol__event__builder__EventBuilder_sign_with_keys_impl( ptr, rust_vec_len, data_len, ), - 44 => wire__crate__api__protocol__event__builder__EventBuilder_tag_impl( + 45 => wire__crate__api__protocol__event__builder__EventBuilder_tag_impl( ptr, rust_vec_len, data_len, ), - 45 => wire__crate__api__protocol__event__builder__EventBuilder_tags_impl( + 46 => wire__crate__api__protocol__event__builder__EventBuilder_tags_impl( ptr, rust_vec_len, data_len, ), - 46 => wire__crate__api__protocol__event__builder__EventBuilder_text_note_impl( + 47 => wire__crate__api__protocol__event__builder__EventBuilder_text_note_impl( ptr, rust_vec_len, data_len, ), - 47 => wire__crate__api__protocol__event__tag__Tag_as_vec_impl(ptr, rust_vec_len, data_len), - 48 => wire__crate__api__protocol__event__tag__Tag_content_impl(ptr, rust_vec_len, data_len), - 49 => wire__crate__api__protocol__event__tag__Tag_is_protected_impl( + 48 => wire__crate__api__protocol__event__tag__Tag_as_vec_impl(ptr, rust_vec_len, data_len), + 49 => wire__crate__api__protocol__event__tag__Tag_content_impl(ptr, rust_vec_len, data_len), + 50 => wire__crate__api__protocol__event__tag__Tag_is_protected_impl( ptr, rust_vec_len, data_len, ), - 50 => { + 51 => { wire__crate__api__protocol__event__tag__Tag_is_reply_impl(ptr, rust_vec_len, data_len) } - 51 => wire__crate__api__protocol__event__tag__Tag_is_root_impl(ptr, rust_vec_len, data_len), - 52 => wire__crate__api__protocol__event__tag__Tag_kind_impl(ptr, rust_vec_len, data_len), - 53 => wire__crate__api__protocol__event__tag__Tag_parse_impl(ptr, rust_vec_len, data_len), - 54 => wire__crate__api__protocol__event__tag__Tag_to_vec_impl(ptr, rust_vec_len, data_len), - 55 => wire__crate__api__protocol__event__unsigned__UnsignedEvent_add_signature_impl( + 52 => wire__crate__api__protocol__event__tag__Tag_is_root_impl(ptr, rust_vec_len, data_len), + 53 => wire__crate__api__protocol__event__tag__Tag_kind_impl(ptr, rust_vec_len, data_len), + 54 => wire__crate__api__protocol__event__tag__Tag_parse_impl(ptr, rust_vec_len, data_len), + 55 => wire__crate__api__protocol__event__tag__Tag_to_vec_impl(ptr, rust_vec_len, data_len), + 56 => wire__crate__api__protocol__event__unsigned__UnsignedEvent_add_signature_impl( ptr, rust_vec_len, data_len, ), - 56 => wire__crate__api__protocol__event__unsigned__UnsignedEvent_as_json_impl( + 57 => wire__crate__api__protocol__event__unsigned__UnsignedEvent_as_json_impl( ptr, rust_vec_len, data_len, ), - 57 => wire__crate__api__protocol__event__unsigned__UnsignedEvent_as_pretty_json_impl( + 58 => wire__crate__api__protocol__event__unsigned__UnsignedEvent_as_pretty_json_impl( ptr, rust_vec_len, data_len, ), - 58 => wire__crate__api__protocol__event__unsigned__UnsignedEvent_author_impl( + 59 => wire__crate__api__protocol__event__unsigned__UnsignedEvent_author_impl( ptr, rust_vec_len, data_len, ), - 59 => wire__crate__api__protocol__event__unsigned__UnsignedEvent_content_impl( + 60 => wire__crate__api__protocol__event__unsigned__UnsignedEvent_content_impl( ptr, rust_vec_len, data_len, ), - 60 => wire__crate__api__protocol__event__unsigned__UnsignedEvent_created_at_impl( + 61 => wire__crate__api__protocol__event__unsigned__UnsignedEvent_created_at_impl( ptr, rust_vec_len, data_len, ), - 61 => wire__crate__api__protocol__event__unsigned__UnsignedEvent_from_json_impl( + 62 => wire__crate__api__protocol__event__unsigned__UnsignedEvent_from_json_impl( ptr, rust_vec_len, data_len, ), - 62 => wire__crate__api__protocol__event__unsigned__UnsignedEvent_id_impl( + 63 => wire__crate__api__protocol__event__unsigned__UnsignedEvent_id_impl( ptr, rust_vec_len, data_len, ), - 63 => wire__crate__api__protocol__event__unsigned__UnsignedEvent_kind_impl( + 64 => wire__crate__api__protocol__event__unsigned__UnsignedEvent_kind_impl( ptr, rust_vec_len, data_len, ), - 64 => wire__crate__api__protocol__event__unsigned__UnsignedEvent_tags_impl( + 65 => wire__crate__api__protocol__event__unsigned__UnsignedEvent_tags_impl( ptr, rust_vec_len, data_len, ), - 65 => wire__crate__api__protocol__key__Keys_generate_impl(ptr, rust_vec_len, data_len), - 66 => wire__crate__api__protocol__key__Keys_new_impl(ptr, rust_vec_len, data_len), - 67 => wire__crate__api__protocol__key__Keys_parse_impl(ptr, rust_vec_len, data_len), - 68 => wire__crate__api__protocol__key__Keys_public_key_impl(ptr, rust_vec_len, data_len), - 69 => wire__crate__api__protocol__key__Keys_secret_key_impl(ptr, rust_vec_len, data_len), - 70 => wire__crate__api__protocol__key__public_key__PublicKey_from_slice_impl( + 66 => wire__crate__api__protocol__key__Keys_generate_impl(ptr, rust_vec_len, data_len), + 67 => wire__crate__api__protocol__key__Keys_new_impl(ptr, rust_vec_len, data_len), + 68 => wire__crate__api__protocol__key__Keys_parse_impl(ptr, rust_vec_len, data_len), + 69 => wire__crate__api__protocol__key__Keys_public_key_impl(ptr, rust_vec_len, data_len), + 70 => wire__crate__api__protocol__key__Keys_secret_key_impl(ptr, rust_vec_len, data_len), + 71 => wire__crate__api__protocol__key__public_key__PublicKey_from_slice_impl( ptr, rust_vec_len, data_len, ), - 71 => wire__crate__api__protocol__key__public_key__PublicKey_parse_impl( + 72 => wire__crate__api__protocol__key__public_key__PublicKey_parse_impl( ptr, rust_vec_len, data_len, ), - 72 => wire__crate__api__protocol__key__public_key__PublicKey_to_bech32_impl( + 73 => wire__crate__api__protocol__key__public_key__PublicKey_to_bech32_impl( ptr, rust_vec_len, data_len, ), - 73 => wire__crate__api__protocol__key__public_key__PublicKey_to_hex_impl( + 74 => wire__crate__api__protocol__key__public_key__PublicKey_to_hex_impl( ptr, rust_vec_len, data_len, ), - 74 => wire__crate__api__protocol__key__public_key__PublicKey_to_nostr_uri_impl( + 75 => wire__crate__api__protocol__key__public_key__PublicKey_to_nostr_uri_impl( ptr, rust_vec_len, data_len, ), - 75 => wire__crate__api__protocol__key__secret_key__SecretKey_from_slice_impl( + 76 => wire__crate__api__protocol__key__secret_key__SecretKey_from_slice_impl( ptr, rust_vec_len, data_len, ), - 76 => wire__crate__api__protocol__key__secret_key__SecretKey_generate_impl( + 77 => wire__crate__api__protocol__key__secret_key__SecretKey_generate_impl( ptr, rust_vec_len, data_len, ), - 77 => wire__crate__api__protocol__key__secret_key__SecretKey_parse_impl( + 78 => wire__crate__api__protocol__key__secret_key__SecretKey_parse_impl( ptr, rust_vec_len, data_len, ), - 78 => wire__crate__api__protocol__key__secret_key__SecretKey_to_bech32_impl( + 79 => wire__crate__api__protocol__key__secret_key__SecretKey_to_bech32_impl( ptr, rust_vec_len, data_len, ), - 79 => wire__crate__api__protocol__key__secret_key__SecretKey_to_secret_hex_impl( + 80 => wire__crate__api__protocol__key__secret_key__SecretKey_to_secret_hex_impl( ptr, rust_vec_len, data_len, ), - 80 => wire__crate__api__protocol__signer__NostrSigner_backend_impl( + 81 => wire__crate__api__protocol__signer__NostrSigner_backend_impl( ptr, rust_vec_len, data_len, ), - 82 => { + 83 => { wire__crate__api__protocol__signer__NostrSigner_keys_impl(ptr, rust_vec_len, data_len) } _ => unreachable!(),