Skip to content

Commit

Permalink
nostr: remove -Params and -Result suffix from NIP47 structs
Browse files Browse the repository at this point in the history
Signed-off-by: Yuki Kishimoto <[email protected]>
  • Loading branch information
yukibtc committed Nov 27, 2024
1 parent c379401 commit fa54497
Show file tree
Hide file tree
Showing 10 changed files with 318 additions and 414 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
* nostr: remove `UncheckedUrl` struct ([Yuki Kishimoto])
* nostr: update `NostrConnectURI::relays` to return slice ([Yuki Kishimoto])
* nostr: update `NostrConnectURI::secret` to return string slice ([Yuki Kishimoto])
* nostr: remove `-Params` and `-Result` suffix from NIP47 structs ([Yuki Kishimoto])
* pool: switch from async to sync message sending for `Relay` ([Yuki Kishimoto])
* connect: refactor `NostrConnectRemoteSigner` to use distinct keys for signer and user ([Yuki Kishimoto])
* connect: refactor `NostrConnectRemoteSigner` to use synchronous constructors ([Yuki Kishimoto])
Expand Down
32 changes: 11 additions & 21 deletions bindings/nostr-sdk-ffi/src/nwc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ pub mod options;
use self::options::NostrWalletConnectOptions;
use crate::error::Result;
use crate::protocol::nips::nip47::{
GetInfoResponseResult, ListTransactionsRequestParams, LookupInvoiceRequestParams,
LookupInvoiceResponseResult, MakeInvoiceRequestParams, MakeInvoiceResponseResult,
NostrWalletConnectURI, PayInvoiceRequestParams, PayInvoiceResponseResult,
PayKeysendRequestParams, PayKeysendResponseResult,
GetInfoResponse, ListTransactionsRequest, LookupInvoiceRequest, LookupInvoiceResponse,
MakeInvoiceRequest, MakeInvoiceResponse, NostrWalletConnectURI, PayInvoiceRequest,
PayInvoiceResponse, PayKeysendRequest, PayKeysendResponse,
};
use crate::relay::RelayStatus;

Expand Down Expand Up @@ -57,42 +56,33 @@ impl NWC {
}

/// Pay invoice
pub async fn pay_invoice(
&self,
params: PayInvoiceRequestParams,
) -> Result<PayInvoiceResponseResult> {
pub async fn pay_invoice(&self, params: PayInvoiceRequest) -> Result<PayInvoiceResponse> {
Ok(self.inner.pay_invoice(params.into()).await?.into())
}

/// Pay keysend
pub async fn pay_keysend(
&self,
params: PayKeysendRequestParams,
) -> Result<PayKeysendResponseResult> {
pub async fn pay_keysend(&self, params: PayKeysendRequest) -> Result<PayKeysendResponse> {
Ok(self.inner.pay_keysend(params.into()).await?.into())
}

/// Create invoice
pub async fn make_invoice(
&self,
params: MakeInvoiceRequestParams,
) -> Result<MakeInvoiceResponseResult> {
pub async fn make_invoice(&self, params: MakeInvoiceRequest) -> Result<MakeInvoiceResponse> {
Ok(self.inner.make_invoice(params.into()).await?.into())
}

/// Lookup invoice
pub async fn lookup_invoice(
&self,
params: LookupInvoiceRequestParams,
) -> Result<LookupInvoiceResponseResult> {
params: LookupInvoiceRequest,
) -> Result<LookupInvoiceResponse> {
Ok(self.inner.lookup_invoice(params.into()).await?.into())
}

/// List transactions
pub async fn list_transactions(
&self,
params: ListTransactionsRequestParams,
) -> Result<Vec<LookupInvoiceResponseResult>> {
params: ListTransactionsRequest,
) -> Result<Vec<LookupInvoiceResponse>> {
let list = self.inner.list_transactions(params.into()).await?;
Ok(list.into_iter().map(|l| l.into()).collect())
}
Expand All @@ -103,7 +93,7 @@ impl NWC {
}

/// Get info
pub async fn get_info(&self) -> Result<GetInfoResponseResult> {
pub async fn get_info(&self) -> Result<GetInfoResponse> {
Ok(self.inner.get_info().await?.into())
}
}
Loading

0 comments on commit fa54497

Please sign in to comment.