Skip to content

Commit

Permalink
Expose Alphabet, SingleLetterTag and Filter
Browse files Browse the repository at this point in the history
  • Loading branch information
yukibtc committed Jan 2, 2025
1 parent 324e809 commit c50a411
Show file tree
Hide file tree
Showing 14 changed files with 5,782 additions and 229 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
### Added

* Expose `EventId` ([Yuki Kishimoto])
* Expose `Alphabet`, `SingleLetterTag` and `Filter` ([Yuki Kishimoto])

### Fixed

Expand Down
1 change: 1 addition & 0 deletions lib/nostr_sdk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export 'src/rust/api/protocol/event/unsigned.dart';
export 'src/rust/api/protocol/key.dart';
export 'src/rust/api/protocol/key/public_key.dart';
export 'src/rust/api/protocol/key/secret_key.dart';
export 'src/rust/api/protocol/types/filter.dart';
export 'src/rust/api/protocol/signer.dart';
export 'src/rust/api/relay/options.dart';
export 'src/rust/api/client.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/src/rust/api/protocol/event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import 'event/tag.dart';
import 'key/public_key.dart';
import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.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`
// These function are ignored because they are on traits that is not defined in current crate (put an empty `#[frb]` on it to unignore): `deref`, `from`

// Rust type: RustOpaqueMoi<flutter_rust_bridge::for_generated::RustAutoOpaqueInner<_Event>>
abstract class Event implements RustOpaqueInterface {
Expand Down
152 changes: 152 additions & 0 deletions lib/src/rust/api/protocol/types/filter.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
// This file is automatically generated, so please do not edit it.
// Generated by `flutter_rust_bridge`@ 2.0.0.

// ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import

import '../../../frb_generated.dart';
import '../event.dart';
import '../event/id.dart';
import '../key/public_key.dart';
import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.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`, `from`, `from`

// Rust type: RustOpaqueMoi<flutter_rust_bridge::for_generated::RustAutoOpaqueInner<_Filter>>
abstract class Filter implements RustOpaqueInterface {
String asJson();

/// Add event author Public Key
Filter author({required PublicKey author});

Filter authors({required List<PublicKey> authors});

Filter customTag(
{required SingleLetterTag tag, required List<String> content});

/// Add event ID (`e` tag)
Filter event({required EventId id});

/// Add event IDs (`e` tag)
Filter events({required List<EventId> ids});

static Filter fromJson({required String json}) => NostrSdk.instance.api
.crateApiProtocolTypesFilterFilterFromJson(json: json);

Filter hashtag({required String hashtag});

Filter hashtags({required List<String> hashtags});

Filter id({required EventId id});

Filter identifier({required String identifier});

Filter identifiers({required List<String> identifiers});

Filter ids({required List<EventId> ids});

bool isEmpty();

Filter kind({required int kind});

Filter kinds({required List<int> kinds});

Filter limit({required BigInt limit});

/// Determine if `Filter` match given `Event`.
bool matchEvent({required Event event});

factory Filter() =>
NostrSdk.instance.api.crateApiProtocolTypesFilterFilterNew();

/// Add Public Key (`p` tag)
Filter pubkey({required PublicKey pubkey});

/// Add Public Keys (`p` tag)
Filter pubkeys({required List<PublicKey> pubkeys});

Filter reference({required String reference});

Filter references({required List<String> references});

Filter removeAuthors({required List<PublicKey> authors});

Filter removeCustomTag(
{required SingleLetterTag tag, required List<String> content});

Filter removeEvents({required List<EventId> ids});

Filter removeHashtags({required List<String> hashtags});

Filter removeIdentifiers({required List<String> identifiers});

Filter removeIds({required List<EventId> ids});

Filter removeKinds({required List<int> kinds});

Filter removeLimit();

Filter removePubkeys({required List<PublicKey> pubkeys});

Filter removeReferences({required List<String> references});

Filter removeSearch();

Filter removeSince();

Filter removeUntil();

Filter search({required String text});

Filter since({required BigInt timestamp});

Filter until({required BigInt timestamp});
}

// Rust type: RustOpaqueMoi<flutter_rust_bridge::for_generated::RustAutoOpaqueInner<_SingleLetterTag>>
abstract class SingleLetterTag implements RustOpaqueInterface {
/// Check if it's lowercase
bool isLowercase();

/// Check if it's uppercase
bool isUppercase();

/// New lowercase single-letter tag
static SingleLetterTag lowercase({required Alphabet character}) =>
NostrSdk.instance.api.crateApiProtocolTypesFilterSingleLetterTagLowercase(
character: character);

/// New uppercase single-letter tag
static SingleLetterTag uppercase({required Alphabet character}) =>
NostrSdk.instance.api.crateApiProtocolTypesFilterSingleLetterTagUppercase(
character: character);
}

enum Alphabet {
a,
b,
c,
d,
e,
f,
g,
h,
i,
j,
k,
l,
m,
n,
o,
p,
q,
r,
s,
t,
u,
v,
w,
x,
y,
z,
;
}
Loading

0 comments on commit c50a411

Please sign in to comment.