mirror of
https://github.com/aljazceru/cdk.git
synced 2026-02-04 20:55:59 +01:00
check for proofs when creating token
This commit is contained in:
@@ -126,7 +126,7 @@ impl Wallet {
|
||||
let proofs = self.mint(amount, hash).await?;
|
||||
|
||||
let token = Token::new(self.client.mint_url.clone(), proofs, None);
|
||||
Ok(token)
|
||||
Ok(token?)
|
||||
}
|
||||
|
||||
/// Blocking Mint Token
|
||||
@@ -135,7 +135,7 @@ impl Wallet {
|
||||
let proofs = self.mint(amount, hash)?;
|
||||
|
||||
let token = Token::new(self.client.client.mint_url.clone(), proofs, None);
|
||||
Ok(token)
|
||||
Ok(token?)
|
||||
}
|
||||
|
||||
/// Mint Proofs
|
||||
@@ -515,12 +515,12 @@ impl Wallet {
|
||||
|
||||
#[cfg(not(feature = "blocking"))]
|
||||
pub fn proofs_to_token(&self, proofs: Proofs, memo: Option<String>) -> Result<String, Error> {
|
||||
Ok(Token::new(self.client.mint_url.clone(), proofs, memo).convert_to_string()?)
|
||||
Ok(Token::new(self.client.mint_url.clone(), proofs, memo)?.convert_to_string()?)
|
||||
}
|
||||
|
||||
#[cfg(feature = "blocking")]
|
||||
pub fn proofs_to_token(&self, proofs: Proofs, memo: Option<String>) -> Result<String, Error> {
|
||||
Ok(Token::new(self.client.client.mint_url.clone(), proofs, memo).convert_to_string()?)
|
||||
Ok(Token::new(self.client.client.mint_url.clone(), proofs, memo)?.convert_to_string()?)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -92,6 +92,9 @@ pub mod wallet {
|
||||
Base64Error(base64::DecodeError),
|
||||
/// Unsupported Token
|
||||
UnsupportedToken,
|
||||
/// Token Requires proofs
|
||||
ProofsRequired,
|
||||
/// Custom Error message
|
||||
CustomError(String),
|
||||
}
|
||||
|
||||
@@ -107,6 +110,7 @@ pub mod wallet {
|
||||
Error::UnsupportedToken => write!(f, "Unsuppported Token"),
|
||||
Error::EllipticError(err) => write!(f, "{}", err),
|
||||
Error::SerdeJsonError(err) => write!(f, "{}", err),
|
||||
Error::ProofsRequired => write!(f, "Token must have at least one proof",),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,11 +109,19 @@ pub mod wallet {
|
||||
}
|
||||
|
||||
impl Token {
|
||||
pub fn new(mint_url: Url, proofs: Proofs, memo: Option<String>) -> Self {
|
||||
Self {
|
||||
pub fn new(
|
||||
mint_url: Url,
|
||||
proofs: Proofs,
|
||||
memo: Option<String>,
|
||||
) -> Result<Self, wallet::Error> {
|
||||
if proofs.is_empty() {
|
||||
return Err(wallet::Error::ProofsRequired);
|
||||
}
|
||||
|
||||
Ok(Self {
|
||||
token: vec![MintProofs::new(mint_url, proofs)],
|
||||
memo,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub fn token_info(&self) -> (u64, String) {
|
||||
|
||||
Reference in New Issue
Block a user