6
6
import 'api/client.dart' ;
7
7
import 'api/client/builder.dart' ;
8
8
import 'api/client/options.dart' ;
9
+ import 'api/client/output.dart' ;
9
10
import 'api/protocol/event.dart' ;
10
11
import 'api/protocol/event/builder.dart' ;
11
12
import 'api/protocol/event/tag.dart' ;
@@ -92,10 +93,10 @@ abstract class NostrSdkApi extends BaseApi {
92
93
93
94
Client crateApiClientClientNew ();
94
95
95
- Future <String > crateApiClientClientSendEvent (
96
+ Future <SendEventOutput > crateApiClientClientSendEvent (
96
97
{required Client that, required Event event});
97
98
98
- Future <String > crateApiClientClientSendEventBuilder (
99
+ Future <SendEventOutput > crateApiClientClientSendEventBuilder (
99
100
{required Client that, required EventBuilder builder});
100
101
101
102
Client crateApiClientBuilderClientBuilderBuild ({required ClientBuilder that});
@@ -539,7 +540,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi {
539
540
);
540
541
541
542
@override
542
- Future <String > crateApiClientClientSendEvent (
543
+ Future <SendEventOutput > crateApiClientClientSendEvent (
543
544
{required Client that, required Event event}) {
544
545
return handler.executeNormal (NormalTask (
545
546
callFfi: (port_) {
@@ -552,7 +553,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi {
552
553
funcId: 6 , port: port_);
553
554
},
554
555
codec: SseCodec (
555
- decodeSuccessData: sse_decode_String ,
556
+ decodeSuccessData: sse_decode_send_event_output ,
556
557
decodeErrorData: sse_decode_AnyhowException,
557
558
),
558
559
constMeta: kCrateApiClientClientSendEventConstMeta,
@@ -568,7 +569,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi {
568
569
);
569
570
570
571
@override
571
- Future <String > crateApiClientClientSendEventBuilder (
572
+ Future <SendEventOutput > crateApiClientClientSendEventBuilder (
572
573
{required Client that, required EventBuilder builder}) {
573
574
return handler.executeNormal (NormalTask (
574
575
callFfi: (port_) {
@@ -581,7 +582,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi {
581
582
funcId: 7 , port: port_);
582
583
},
583
584
codec: SseCodec (
584
- decodeSuccessData: sse_decode_String ,
585
+ decodeSuccessData: sse_decode_send_event_output ,
585
586
decodeErrorData: sse_decode_AnyhowException,
586
587
),
587
588
constMeta: kCrateApiClientClientSendEventBuilderConstMeta,
@@ -3053,6 +3054,13 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi {
3053
3054
return UnsignedEventImpl .frbInternalDcoDecode (raw as List <dynamic >);
3054
3055
}
3055
3056
3057
+ @protected
3058
+ Map <String , String > dco_decode_Map_String_String (dynamic raw) {
3059
+ // Codec=Dco (DartCObject based), see doc to use other codecs
3060
+ return Map .fromEntries (dco_decode_list_record_string_string (raw)
3061
+ .map ((e) => MapEntry (e.$1, e.$2)));
3062
+ }
3063
+
3056
3064
@protected
3057
3065
Client
3058
3066
dco_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Client (
@@ -3148,6 +3156,12 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi {
3148
3156
return UnsignedEventImpl .frbInternalDcoDecode (raw as List <dynamic >);
3149
3157
}
3150
3158
3159
+ @protected
3160
+ Set <String > dco_decode_Set_String (dynamic raw) {
3161
+ // Codec=Dco (DartCObject based), see doc to use other codecs
3162
+ return Set .from (dco_decode_list_String (raw));
3163
+ }
3164
+
3151
3165
@protected
3152
3166
String dco_decode_String (dynamic raw) {
3153
3167
// Codec=Dco (DartCObject based), see doc to use other codecs
@@ -3226,12 +3240,44 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi {
3226
3240
return raw as Uint8List ;
3227
3241
}
3228
3242
3243
+ @protected
3244
+ List <(String , String )> dco_decode_list_record_string_string (dynamic raw) {
3245
+ // Codec=Dco (DartCObject based), see doc to use other codecs
3246
+ return (raw as List <dynamic >).map (dco_decode_record_string_string).toList ();
3247
+ }
3248
+
3229
3249
@protected
3230
3250
String ? dco_decode_opt_String (dynamic raw) {
3231
3251
// Codec=Dco (DartCObject based), see doc to use other codecs
3232
3252
return raw == null ? null : dco_decode_String (raw);
3233
3253
}
3234
3254
3255
+ @protected
3256
+ (String , String ) dco_decode_record_string_string (dynamic raw) {
3257
+ // Codec=Dco (DartCObject based), see doc to use other codecs
3258
+ final arr = raw as List <dynamic >;
3259
+ if (arr.length != 2 ) {
3260
+ throw Exception ('Expected 2 elements, got ${arr .length }' );
3261
+ }
3262
+ return (
3263
+ dco_decode_String (arr[0 ]),
3264
+ dco_decode_String (arr[1 ]),
3265
+ );
3266
+ }
3267
+
3268
+ @protected
3269
+ SendEventOutput dco_decode_send_event_output (dynamic raw) {
3270
+ // Codec=Dco (DartCObject based), see doc to use other codecs
3271
+ final arr = raw as List <dynamic >;
3272
+ if (arr.length != 3 )
3273
+ throw Exception ('unexpected arr length: expect 3 but see ${arr .length }' );
3274
+ return SendEventOutput (
3275
+ id: dco_decode_String (arr[0 ]),
3276
+ success: dco_decode_Set_String (arr[1 ]),
3277
+ failed: dco_decode_Map_String_String (arr[2 ]),
3278
+ );
3279
+ }
3280
+
3235
3281
@protected
3236
3282
SignerBackend dco_decode_signer_backend (dynamic raw) {
3237
3283
// Codec=Dco (DartCObject based), see doc to use other codecs
@@ -3502,6 +3548,14 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi {
3502
3548
sse_decode_usize (deserializer), sse_decode_i_32 (deserializer));
3503
3549
}
3504
3550
3551
+ @protected
3552
+ Map <String , String > sse_decode_Map_String_String (
3553
+ SseDeserializer deserializer) {
3554
+ // Codec=Sse (Serialization based), see doc to use other codecs
3555
+ var inner = sse_decode_list_record_string_string (deserializer);
3556
+ return Map .fromEntries (inner.map ((e) => MapEntry (e.$1, e.$2)));
3557
+ }
3558
+
3505
3559
@protected
3506
3560
Client
3507
3561
sse_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Client (
@@ -3609,6 +3663,13 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi {
3609
3663
sse_decode_usize (deserializer), sse_decode_i_32 (deserializer));
3610
3664
}
3611
3665
3666
+ @protected
3667
+ Set <String > sse_decode_Set_String (SseDeserializer deserializer) {
3668
+ // Codec=Sse (Serialization based), see doc to use other codecs
3669
+ var inner = sse_decode_list_String (deserializer);
3670
+ return Set .from (inner);
3671
+ }
3672
+
3612
3673
@protected
3613
3674
String sse_decode_String (SseDeserializer deserializer) {
3614
3675
// Codec=Sse (Serialization based), see doc to use other codecs
@@ -3703,6 +3764,19 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi {
3703
3764
return deserializer.buffer.getUint8List (len_);
3704
3765
}
3705
3766
3767
+ @protected
3768
+ List <(String , String )> sse_decode_list_record_string_string (
3769
+ SseDeserializer deserializer) {
3770
+ // Codec=Sse (Serialization based), see doc to use other codecs
3771
+
3772
+ var len_ = sse_decode_i_32 (deserializer);
3773
+ var ans_ = < (String , String )> [];
3774
+ for (var idx_ = 0 ; idx_ < len_; ++ idx_) {
3775
+ ans_.add (sse_decode_record_string_string (deserializer));
3776
+ }
3777
+ return ans_;
3778
+ }
3779
+
3706
3780
@protected
3707
3781
String ? sse_decode_opt_String (SseDeserializer deserializer) {
3708
3782
// Codec=Sse (Serialization based), see doc to use other codecs
@@ -3714,6 +3788,25 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi {
3714
3788
}
3715
3789
}
3716
3790
3791
+ @protected
3792
+ (String , String ) sse_decode_record_string_string (
3793
+ SseDeserializer deserializer) {
3794
+ // Codec=Sse (Serialization based), see doc to use other codecs
3795
+ var var_field0 = sse_decode_String (deserializer);
3796
+ var var_field1 = sse_decode_String (deserializer);
3797
+ return (var_field0, var_field1);
3798
+ }
3799
+
3800
+ @protected
3801
+ SendEventOutput sse_decode_send_event_output (SseDeserializer deserializer) {
3802
+ // Codec=Sse (Serialization based), see doc to use other codecs
3803
+ var var_id = sse_decode_String (deserializer);
3804
+ var var_success = sse_decode_Set_String (deserializer);
3805
+ var var_failed = sse_decode_Map_String_String (deserializer);
3806
+ return SendEventOutput (
3807
+ id: var_id, success: var_success, failed: var_failed);
3808
+ }
3809
+
3717
3810
@protected
3718
3811
SignerBackend sse_decode_signer_backend (SseDeserializer deserializer) {
3719
3812
// Codec=Sse (Serialization based), see doc to use other codecs
@@ -3995,6 +4088,14 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi {
3995
4088
serializer);
3996
4089
}
3997
4090
4091
+ @protected
4092
+ void sse_encode_Map_String_String (
4093
+ Map <String , String > self, SseSerializer serializer) {
4094
+ // Codec=Sse (Serialization based), see doc to use other codecs
4095
+ sse_encode_list_record_string_string (
4096
+ self.entries.map ((e) => (e.key, e.value)).toList (), serializer);
4097
+ }
4098
+
3998
4099
@protected
3999
4100
void
4000
4101
sse_encode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Client (
@@ -4107,6 +4208,12 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi {
4107
4208
serializer);
4108
4209
}
4109
4210
4211
+ @protected
4212
+ void sse_encode_Set_String (Set <String > self, SseSerializer serializer) {
4213
+ // Codec=Sse (Serialization based), see doc to use other codecs
4214
+ sse_encode_list_String (self.toList (), serializer);
4215
+ }
4216
+
4110
4217
@protected
4111
4218
void sse_encode_String (String self, SseSerializer serializer) {
4112
4219
// Codec=Sse (Serialization based), see doc to use other codecs
@@ -4195,6 +4302,16 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi {
4195
4302
serializer.buffer.putUint8List (self);
4196
4303
}
4197
4304
4305
+ @protected
4306
+ void sse_encode_list_record_string_string (
4307
+ List <(String , String )> self, SseSerializer serializer) {
4308
+ // Codec=Sse (Serialization based), see doc to use other codecs
4309
+ sse_encode_i_32 (self.length, serializer);
4310
+ for (final item in self) {
4311
+ sse_encode_record_string_string (item, serializer);
4312
+ }
4313
+ }
4314
+
4198
4315
@protected
4199
4316
void sse_encode_opt_String (String ? self, SseSerializer serializer) {
4200
4317
// Codec=Sse (Serialization based), see doc to use other codecs
@@ -4205,6 +4322,23 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi {
4205
4322
}
4206
4323
}
4207
4324
4325
+ @protected
4326
+ void sse_encode_record_string_string (
4327
+ (String , String ) self, SseSerializer serializer) {
4328
+ // Codec=Sse (Serialization based), see doc to use other codecs
4329
+ sse_encode_String (self.$1, serializer);
4330
+ sse_encode_String (self.$2, serializer);
4331
+ }
4332
+
4333
+ @protected
4334
+ void sse_encode_send_event_output (
4335
+ SendEventOutput self, SseSerializer serializer) {
4336
+ // Codec=Sse (Serialization based), see doc to use other codecs
4337
+ sse_encode_String (self.id, serializer);
4338
+ sse_encode_Set_String (self.success, serializer);
4339
+ sse_encode_Map_String_String (self.failed, serializer);
4340
+ }
4341
+
4208
4342
@protected
4209
4343
void sse_encode_signer_backend (SignerBackend self, SseSerializer serializer) {
4210
4344
// Codec=Sse (Serialization based), see doc to use other codecs
@@ -4327,15 +4461,16 @@ class ClientImpl extends RustOpaque implements Client {
4327
4461
///
4328
4462
/// Send `Event` to all relays with `WRITE` flag.
4329
4463
/// If `gossip` option is enabled, the event will be sent also to NIP65 relays (automatically discovered).
4330
- Future <String > sendEvent ({required Event event}) => NostrSdk .instance.api
4331
- .crateApiClientClientSendEvent (that: this , event: event);
4464
+ Future <SendEventOutput > sendEvent ({required Event event}) =>
4465
+ NostrSdk .instance.api
4466
+ .crateApiClientClientSendEvent (that: this , event: event);
4332
4467
4333
4468
/// Send event
4334
4469
///
4335
4470
/// Take an [`EventBuilder`] , sign it by using the [`NostrSigner`] and broadcast to relays (check [`Client::send_event`] from more details).
4336
4471
///
4337
4472
/// Return an error if the [`NostrSigner`] is not set.
4338
- Future <String > sendEventBuilder ({required EventBuilder builder}) =>
4473
+ Future <SendEventOutput > sendEventBuilder ({required EventBuilder builder}) =>
4339
4474
NostrSdk .instance.api
4340
4475
.crateApiClientClientSendEventBuilder (that: this , builder: builder);
4341
4476
}
0 commit comments