Skip to content

Commit

Permalink
Merge branch 'v0.12' into refactor/consensus
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Jan 15, 2025
2 parents 74ce5ce + c6e78a2 commit 9cb78c7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 33 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 4 additions & 31 deletions invoice/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,38 +38,11 @@ use core::fmt::{self, Display, Formatter};
use core::str::FromStr;

use baid64::Baid64ParseError;
use hypersonic::{AuthToken, Consensus, ContractId};
use sonic_callreq::CallRequest;
use hypersonic::AuthToken;
use rgbcore::{SealType, UnknownType};
use sonic_callreq::{CallRequest, CallScope};

pub type RgbInvoice = CallRequest<RgbScope, RgbBeneficiary>;

#[derive(Clone, Eq, PartialEq, Debug, Display)]
pub enum RgbScope {
#[display(inner)]
ContractId(ContractId),

#[display("contract:{0}")]
ContractQuery(ContractQuery),
}

impl FromStr for RgbScope {
type Err = ParseInvoiceError;

fn from_str(s: &str) -> Result<Self, Self::Err> {
if !s.starts_with("contract:") {
return Err(ParseInvoiceError::NoScheme);
}
match ContractId::from_str(s) {
Err(err1) => {
let s = s.trim_start_matches("contract:");
let query = ContractQuery::from_str(s)
.map_err(|_| ParseInvoiceError::Unrecognizable(err1))?;
Ok(Self::ContractQuery(query))
}
Ok(id) => Ok(Self::ContractId(id)),
}
}
}
pub type RgbInvoice = CallRequest<CallScope, RgbBeneficiary>;

#[derive(Clone, Eq, PartialEq, Debug, Display)]
#[display(inner)]
Expand Down

0 comments on commit 9cb78c7

Please sign in to comment.