mirror of
https://github.com/aljazceru/cdk.git
synced 2025-12-22 23:25:22 +01:00
feat(wallet): send returns token instead of string
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
### Summary
|
||||
|
||||
### Changed
|
||||
- cdk(wallet): `fn send` returns `Token` so the user can use the struct of convert it to a v3 or v4 string.
|
||||
|
||||
### Added
|
||||
- cdk(NUT-11): Add `Copy` on `SigFlag` ([thesimplekid]).
|
||||
|
||||
@@ -219,7 +219,8 @@ impl JsWallet {
|
||||
let target = split_target_amount
|
||||
.map(|a| SplitTarget::Value(*a.deref()))
|
||||
.unwrap_or_default();
|
||||
self.inner
|
||||
Ok(self
|
||||
.inner
|
||||
.send(
|
||||
Amount::from(amount),
|
||||
memo,
|
||||
@@ -229,7 +230,8 @@ impl JsWallet {
|
||||
false,
|
||||
)
|
||||
.await
|
||||
.map_err(into_err)
|
||||
.map_err(into_err)?
|
||||
.to_string())
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
|
||||
@@ -5,7 +5,7 @@ use std::str::FromStr;
|
||||
|
||||
use anyhow::{bail, Result};
|
||||
use cdk::amount::SplitTarget;
|
||||
use cdk::nuts::{Conditions, PublicKey, SpendingConditions, Token};
|
||||
use cdk::nuts::{Conditions, PublicKey, SpendingConditions};
|
||||
use cdk::wallet::types::SendKind;
|
||||
use cdk::wallet::Wallet;
|
||||
use cdk::{Amount, UncheckedUrl};
|
||||
@@ -176,7 +176,7 @@ pub async fn send(
|
||||
|
||||
match sub_command_args.v3 {
|
||||
true => {
|
||||
let token = Token::from_str(&token)?;
|
||||
let token = token;
|
||||
|
||||
println!("{}", token.to_v3_string());
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ async fn main() -> Result<(), Error> {
|
||||
println!("{}", token);
|
||||
|
||||
let amount = wallet
|
||||
.receive(&token, SplitTarget::default(), &[secret], &[])
|
||||
.receive(&token.to_string(), SplitTarget::default(), &[secret], &[])
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
|
||||
@@ -965,14 +965,19 @@ impl Wallet {
|
||||
|
||||
/// Send specific proofs
|
||||
#[instrument(skip(self))]
|
||||
pub async fn send_proofs(&self, memo: Option<String>, proofs: Proofs) -> Result<String, Error> {
|
||||
pub async fn send_proofs(&self, memo: Option<String>, proofs: Proofs) -> Result<Token, Error> {
|
||||
for proof in proofs.iter() {
|
||||
self.localstore
|
||||
.set_proof_state(proof.y()?, State::Reserved)
|
||||
.await?;
|
||||
}
|
||||
|
||||
Ok(Token::new(self.mint_url.clone(), proofs, memo, Some(self.unit)).to_string())
|
||||
Ok(Token::new(
|
||||
self.mint_url.clone(),
|
||||
proofs,
|
||||
memo,
|
||||
Some(self.unit),
|
||||
))
|
||||
}
|
||||
|
||||
/// Send
|
||||
@@ -985,7 +990,7 @@ impl Wallet {
|
||||
amount_split_target: &SplitTarget,
|
||||
send_kind: &SendKind,
|
||||
include_fees: bool,
|
||||
) -> Result<String, Error> {
|
||||
) -> Result<Token, Error> {
|
||||
// If online send check mint for current keysets fees
|
||||
if matches!(
|
||||
send_kind,
|
||||
|
||||
@@ -125,7 +125,7 @@ impl MultiMintWallet {
|
||||
conditions: Option<SpendingConditions>,
|
||||
send_kind: SendKind,
|
||||
include_fees: bool,
|
||||
) -> Result<String, Error> {
|
||||
) -> Result<Token, Error> {
|
||||
let wallet = self
|
||||
.get_wallet(wallet_key)
|
||||
.await
|
||||
|
||||
Reference in New Issue
Block a user