Skip to content

Commit

Permalink
Use reference in arguments where possible
Browse files Browse the repository at this point in the history
Closes #6
  • Loading branch information
yukibtc committed Jan 16, 2025
1 parent 854b690 commit 60f3250
Show file tree
Hide file tree
Showing 27 changed files with 3,984 additions and 3,077 deletions.
2 changes: 1 addition & 1 deletion lib/nostr_sdk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ 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/nips/nip59.dart';
export 'src/rust/api/protocol/types/filter.dart';
export 'src/rust/api/protocol/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/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import 'client/output.dart';
import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';
import 'protocol/event.dart';
import 'protocol/event/builder.dart';
import 'protocol/filter.dart';
import 'protocol/signer.dart';
import 'protocol/types/filter.dart';
import 'relay/options.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`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

// 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 '../../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`
Expand All @@ -29,8 +29,8 @@ abstract class Filter implements RustOpaqueInterface {
/// Add event IDs (`e` tag)
Filter events({required List<EventId> ids});

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

Filter hashtag({required String hashtag});

Expand All @@ -55,8 +55,7 @@ abstract class Filter implements RustOpaqueInterface {
/// Determine if `Filter` match given `Event`.
bool matchEvent({required Event event});

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

/// Add Public Key (`p` tag)
Filter pubkey({required PublicKey pubkey});
Expand Down Expand Up @@ -112,13 +111,13 @@ abstract class SingleLetterTag implements RustOpaqueInterface {

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

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

enum Alphabet {
Expand Down
4 changes: 3 additions & 1 deletion lib/src/rust/api/protocol/key/public_key.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import '../../../frb_generated.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): `deref`, `from`
// These functions have error during generation (see debug logs or enable `stop_on_error: true` for more details): `to_bytes`

// Rust type: RustOpaqueMoi<flutter_rust_bridge::for_generated::RustAutoOpaqueInner<_PublicKey>>
abstract class PublicKey implements RustOpaqueInterface {
Expand All @@ -23,6 +22,9 @@ abstract class PublicKey implements RustOpaqueInterface {
/// Serialize to bech32
String toBech32();

/// Serialize to bytes
Uint8List toBytes();

/// Serialize to hex
String toHex();

Expand Down
2 changes: 1 addition & 1 deletion lib/src/rust/api/protocol/key/secret_key.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import '../../../frb_generated.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`
// 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 functions have error during generation (see debug logs or enable `stop_on_error: true` for more details): `to_secret_bytes`

// Rust type: RustOpaqueMoi<flutter_rust_bridge::for_generated::RustAutoOpaqueInner<_SecretKey>>
Expand Down
2 changes: 1 addition & 1 deletion lib/src/rust/api/protocol/signer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ abstract class NostrSigner implements RustOpaqueInterface {

/// Decrypt
Future<String> nip44Decrypt(
{required PublicKey publicKey, required String payload});
{required PublicKey publicKey, required String content});

/// Encrypt
Future<String> nip44Encrypt(
Expand Down
Loading

0 comments on commit 60f3250

Please sign in to comment.