Skip to content

Commit

Permalink
js(nostr): add JsZapType
Browse files Browse the repository at this point in the history
  • Loading branch information
yukibtc committed Jan 20, 2024
1 parent cde1069 commit 67c6b4a
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bindings/nostr-js/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ crate-type = ["lib", "cdylib"]
[dependencies]
console_error_panic_hook = "0.1"
js-sys.workspace = true
nostr = { workspace = true, features = ["std", "nip04", "nip05", "nip06", "nip07", "nip11", "nip44", "nip46"] }
nostr = { workspace = true, features = ["std", "all-nips"] }
wasm-bindgen = { workspace = true, features = ["std"] }
wasm-bindgen-futures.workspace = true

Expand Down
1 change: 1 addition & 0 deletions bindings/nostr-js/src/nips/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ pub mod nip19;
pub mod nip26;
pub mod nip44;
pub mod nip46;
pub mod nip57;
36 changes: 36 additions & 0 deletions bindings/nostr-js/src/nips/nip57.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright (c) 2022-2023 Yuki Kishimoto
// Copyright (c) 2023-2024 Rust Nostr Developers
// Distributed under the MIT software license

use nostr::nips::nip57::ZapType;
use wasm_bindgen::prelude::*;

#[wasm_bindgen(js_name = ZapType)]
pub enum JsZapType {
/// Public
Public,
/// Private
Private,
/// Anonymous
Anonymous,
}

impl From<JsZapType> for ZapType {
fn from(value: JsZapType) -> Self {
match value {
JsZapType::Public => Self::Public,
JsZapType::Private => Self::Private,
JsZapType::Anonymous => Self::Anonymous,
}
}
}

impl From<ZapType> for JsZapType {
fn from(value: ZapType) -> Self {
match value {
ZapType::Public => Self::Public,
ZapType::Private => Self::Private,
ZapType::Anonymous => Self::Anonymous,
}
}
}

0 comments on commit 67c6b4a

Please sign in to comment.