Skip to content

Commit

Permalink
Expose EventBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
yukibtc committed Dec 23, 2024
1 parent 1b1af0c commit 91a5bdf
Show file tree
Hide file tree
Showing 17 changed files with 1,441 additions and 92 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
* Expose `ClientBuilder` ([Yuki Kishimoto])
* Expose `NostrSigner` ([Yuki Kishimoto])
* Expose `UnsignedEvent` ([Yuki Kishimoto])
* Expose `EventBuilder` ([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 @@ -3,6 +3,7 @@ library nostr_sdk;
export 'src/rust/frb_generated.dart' show NostrSdk;

export 'src/rust/api/protocol/event.dart';
export 'src/rust/api/protocol/event/builder.dart';
export 'src/rust/api/protocol/event/tag.dart';
export 'src/rust/api/protocol/event/unsigned.dart';
export 'src/rust/api/protocol/key.dart';
Expand Down
53 changes: 53 additions & 0 deletions lib/src/rust/api/protocol/event/builder.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// 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 '../key.dart';
import '../key/public_key.dart';
import '../signer.dart';
import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';
import 'tag.dart';
import 'unsigned.dart';

// Rust type: RustOpaqueMoi<flutter_rust_bridge::for_generated::RustAutoOpaqueInner<_EventBuilder>>
abstract class EventBuilder implements RustOpaqueInterface {
/// Build unsigned event
UnsignedEvent build({required PublicKey publicKey});

/// Set a custom `created_at` UNIX timestamp
EventBuilder customCreatedAt({required BigInt createdAt});

/// New event builder
factory EventBuilder({required int kind, required String content}) =>
NostrSdk.instance.api.crateApiProtocolEventBuilderEventBuilderNew(
kind: kind, content: content);

/// Set POW difficulty
///
/// Only values `> 0` are accepted!
EventBuilder pow({required int difficulty});

/// Build, sign and return event
Future<Event> sign({required NostrSigner signer});

/// Build, sign and return event using keys signer
Event signWithKeys({required Keys keys});

/// Add tag
EventBuilder tag({required Tag tag});

/// Add tags
///
/// This method extends the current tags (if any).
EventBuilder tags({required List<Tag> tags});

/// Text note
///
/// <https://github.com/nostr-protocol/nips/blob/master/01.md>
static EventBuilder textNote({required String content}) =>
NostrSdk.instance.api
.crateApiProtocolEventBuilderEventBuilderTextNote(content: content);
}
2 changes: 2 additions & 0 deletions lib/src/rust/api/protocol/key.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import 'key/public_key.dart';
import 'key/secret_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): `deref`

// Rust type: RustOpaqueMoi<flutter_rust_bridge::for_generated::RustAutoOpaqueInner<_Keys>>
abstract class Keys implements RustOpaqueInterface {
/// Generate random keys
Expand Down
Loading

0 comments on commit 91a5bdf

Please sign in to comment.