Skip to content

Commit

Permalink
Merge pull request #118 from RGB-WG/v0.11
Browse files Browse the repository at this point in the history
Cross-chain secret seals. New network/chain in invoices
  • Loading branch information
dr-orlovsky authored Dec 30, 2023
2 parents 441c9f5 + 099c587 commit 90335fb
Show file tree
Hide file tree
Showing 23 changed files with 478 additions and 451 deletions.
66 changes: 29 additions & 37 deletions Cargo.lock

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

19 changes: 7 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ default-members = [
resolver = "2"

[workspace.package]
version = "0.11.0-beta.3"
version = "0.11.0-beta.4"
authors = ["Dr Maxim Orlovsky <[email protected]>"]
homepage = "https://github.com/RGB-WG"
repository = "https://github.com/RGB-WG/rgb-wallet"
Expand All @@ -24,12 +24,12 @@ license = "Apache-2.0"
[workspace.dependencies]
amplify = "4.5.0"
baid58 = "0.4.4"
strict_encoding = "2.6.1"
strict_encoding = "2.6.2"
strict_types = "1.6.3"
commit_verify = { version = "0.11.0-beta.2", features = ["stl"] }
bp-core = { version = "0.11.0-beta.2", features = ["stl"] }
commit_verify = { version = "0.11.0-beta.3", features = ["stl"] }
bp-core = { version = "0.11.0-beta.3", features = ["stl"] }
bp-invoice = { version = "0.11.0-beta.3" }
rgb-core = { version = "0.11.0-beta.3", features = ["stl"] }
rgb-core = { version = "0.11.0-beta.4", features = ["stl"] }
indexmap = "2.0.2"
serde_crate = { package = "serde", version = "1", features = ["derive"] }

Expand Down Expand Up @@ -58,12 +58,13 @@ strict_types = { workspace = true }
commit_verify = { workspace = true }
bp-core = { workspace = true }
rgb-core = { workspace = true }
rgb-invoice = { version = "0.11.0-beta.3", path = "invoice" }
rgb-invoice = { version = "0.11.0-beta.4", path = "invoice" }
baid58 = { workspace = true }
base85 = "=2.0.0"
chrono = "0.4.31"
indexmap = { workspace = true }
serde_crate = { workspace = true, optional = true }
rand = "0.8.5"

[features]
default = []
Expand All @@ -90,9 +91,3 @@ wasm-bindgen-test = "0.3"

[package.metadata.docs.rs]
features = [ "all" ]

[patch.crates-io]
bp-dbc = { git = "https://github.com/BP-WG/bp-core", branch = "v0.11" }
bp-seals = { git = "https://github.com/BP-WG/bp-core", branch = "v0.11" }
bp-core = { git = "https://github.com/BP-WG/bp-core", branch = "v0.11" }
rgb-core = { git = "https://github.com/RGB-WG/rgb-core", branch = "v0.11" }
29 changes: 12 additions & 17 deletions invoice/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,18 @@

use std::str::FromStr;

use invoice::Network;
use rgb::ContractId;
use strict_encoding::{FieldName, TypeName};

use super::{Beneficiary, InvoiceState, Precision, RgbInvoice, RgbTransport, TransportParseError};
use crate::invoice::XChainNet;

#[derive(Clone, Eq, PartialEq, Debug)]
pub struct RgbInvoiceBuilder(RgbInvoice);

#[allow(clippy::result_large_err)]
impl RgbInvoiceBuilder {
pub fn new(beneficiary: impl Into<Beneficiary>) -> Self {
pub fn new(beneficiary: impl Into<XChainNet<Beneficiary>>) -> Self {
Self(RgbInvoice {
transports: vec![RgbTransport::UnspecifiedMeans],
contract: None,
Expand All @@ -40,21 +41,20 @@ impl RgbInvoiceBuilder {
assignment: None,
beneficiary: beneficiary.into(),
owned_state: InvoiceState::Void,
network: None,
expiry: None,
unknown_query: none!(),
})
}

pub fn with(contract_id: ContractId, beneficiary: impl Into<Beneficiary>) -> Self {
pub fn with(contract_id: ContractId, beneficiary: impl Into<XChainNet<Beneficiary>>) -> Self {
Self::new(beneficiary).set_contract(contract_id)
}

pub fn rgb20(contract_id: ContractId, beneficiary: impl Into<Beneficiary>) -> Self {
pub fn rgb20(contract_id: ContractId, beneficiary: impl Into<XChainNet<Beneficiary>>) -> Self {
Self::with(contract_id, beneficiary).set_interface("RGB20")
}

pub fn rgb20_anything(beneficiary: impl Into<Beneficiary>) -> Self {
pub fn rgb20_anything(beneficiary: impl Into<XChainNet<Beneficiary>>) -> Self {
Self::new(beneficiary).set_interface("RGB20")
}

Expand All @@ -63,18 +63,18 @@ impl RgbInvoiceBuilder {
self
}

pub fn set_interface(mut self, name: &'static str) -> Self {
self.0.iface = Some(tn!(name));
pub fn set_interface(mut self, name: impl Into<TypeName>) -> Self {
self.0.iface = Some(name.into());
self
}

pub fn set_operation(mut self, name: &'static str) -> Self {
self.0.operation = Some(tn!(name));
pub fn set_operation(mut self, name: impl Into<TypeName>) -> Self {
self.0.operation = Some(name.into());
self
}

pub fn set_assignment(mut self, name: &'static str) -> Self {
self.0.assignment = Some(fname!(name));
pub fn set_assignment(mut self, name: impl Into<FieldName>) -> Self {
self.0.assignment = Some(name.into());
self
}

Expand Down Expand Up @@ -119,11 +119,6 @@ impl RgbInvoiceBuilder {
self.set_amount(coins as u64, cents as u64, precision)
}

pub fn set_network(mut self, network: impl Into<Network>) -> Self {
self.0.network = Some(network.into());
self
}

pub fn set_expiry_timestamp(mut self, expiry: i64) -> Self {
self.0.expiry = Some(expiry);
self
Expand Down
Loading

0 comments on commit 90335fb

Please sign in to comment.