Skip to content

Commit

Permalink
feat: support external layer 1s
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Mar 16, 2024
1 parent 2e01d87 commit b22610a
Show file tree
Hide file tree
Showing 3 changed files with 210 additions and 39 deletions.
1 change: 1 addition & 0 deletions src/contract/anchor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ impl XAnchor<mpc::MerkleBlock> {
pub fn known_bundle_ids(&self) -> impl Iterator<Item = (BundleId, ContractId)> + '_ {
match self {
XAnchor::Bitcoin(anchor) | XAnchor::Liquid(anchor) => anchor.known_bundle_ids(),
_ => unreachable!(),

Check warning on line 74 in src/contract/anchor.rs

View check run for this annotation

Codecov / codecov/patch

src/contract/anchor.rs#L74

Added line #L74 was not covered by tests
}
}

Expand Down
15 changes: 14 additions & 1 deletion src/contract/seal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ use commit_verify::{mpc, Conceal};
use single_use_seals::SealWitness;
use strict_encoding::{StrictDecode, StrictDumb, StrictEncode, StrictType};

use crate::contract::xchain::Impossible;
use crate::{XChain, XOutpoint, LIB_NAME_RGB};

pub type GenesisSeal = SingleBlindSeal<Method>;
Expand Down Expand Up @@ -70,36 +71,42 @@ impl<Seal: TxoSeal> TxoSeal for XChain<Seal> {
fn method(&self) -> CloseMethod {
match self {
XChain::Bitcoin(seal) | XChain::Liquid(seal) => seal.method(),
XChain::Other(_) => unreachable!(),

Check warning on line 74 in src/contract/seal.rs

View check run for this annotation

Codecov / codecov/patch

src/contract/seal.rs#L74

Added line #L74 was not covered by tests
}
}

fn txid(&self) -> Option<Txid> {
match self {
XChain::Bitcoin(seal) | XChain::Liquid(seal) => seal.txid(),
XChain::Other(_) => unreachable!(),

Check warning on line 81 in src/contract/seal.rs

View check run for this annotation

Codecov / codecov/patch

src/contract/seal.rs#L81

Added line #L81 was not covered by tests
}
}

fn vout(&self) -> Vout {
match self {
XChain::Bitcoin(seal) | XChain::Liquid(seal) => seal.vout(),
XChain::Other(_) => unreachable!(),

Check warning on line 88 in src/contract/seal.rs

View check run for this annotation

Codecov / codecov/patch

src/contract/seal.rs#L88

Added line #L88 was not covered by tests
}
}

fn outpoint(&self) -> Option<Outpoint> {
match self {
XChain::Bitcoin(seal) | XChain::Liquid(seal) => seal.outpoint(),
XChain::Other(_) => unreachable!(),

Check warning on line 95 in src/contract/seal.rs

View check run for this annotation

Codecov / codecov/patch

src/contract/seal.rs#L95

Added line #L95 was not covered by tests
}
}

fn txid_or(&self, default_txid: Txid) -> Txid {
match self {
XChain::Bitcoin(seal) | XChain::Liquid(seal) => seal.txid_or(default_txid),
XChain::Other(_) => unreachable!(),

Check warning on line 102 in src/contract/seal.rs

View check run for this annotation

Codecov / codecov/patch

src/contract/seal.rs#L102

Added line #L102 was not covered by tests
}
}

fn outpoint_or(&self, default_txid: Txid) -> Outpoint {
match self {
XChain::Bitcoin(seal) | XChain::Liquid(seal) => seal.outpoint_or(default_txid),
XChain::Other(_) => unreachable!(),

Check warning on line 109 in src/contract/seal.rs

View check run for this annotation

Codecov / codecov/patch

src/contract/seal.rs#L109

Added line #L109 was not covered by tests
}
}
}
Expand Down Expand Up @@ -135,6 +142,7 @@ impl<U: ExposedSeal> XChain<U> {
match self {
XChain::Bitcoin(seal) => seal.method(),
XChain::Liquid(seal) => seal.method(),
XChain::Other(_) => unreachable!(),

Check warning on line 145 in src/contract/seal.rs

View check run for this annotation

Codecov / codecov/patch

src/contract/seal.rs#L145

Added line #L145 was not covered by tests
}
}

Expand All @@ -150,6 +158,7 @@ impl<U: ExposedSeal> XChain<U> {
let outpoint = seal.outpoint()?;
XChain::Liquid(ExplicitSeal::new(seal.method(), outpoint))
}
XChain::Other(_) => unreachable!(),

Check warning on line 161 in src/contract/seal.rs

View check run for this annotation

Codecov / codecov/patch

src/contract/seal.rs#L161

Added line #L161 was not covered by tests
})
}

Expand Down Expand Up @@ -228,7 +237,7 @@ impl WitnessOrd {
}
}

pub type XPubWitness = XChain<Tx>;
pub type XPubWitness<X = Impossible> = XChain<Tx, X>;

pub type XWitness<Dbc> = XChain<Witness<Dbc>>;

Expand All @@ -237,6 +246,7 @@ impl XPubWitness {
match self {
Self::Bitcoin(tx) => WitnessId::Bitcoin(tx.txid()),
Self::Liquid(tx) => WitnessId::Liquid(tx.txid()),
Self::Other(_) => unreachable!(),

Check warning on line 249 in src/contract/seal.rs

View check run for this annotation

Codecov / codecov/patch

src/contract/seal.rs#L249

Added line #L249 was not covered by tests
}
}
}
Expand All @@ -246,6 +256,7 @@ impl<Dbc: dbc::Proof> XWitness<Dbc> {
match self {
Self::Bitcoin(w) => WitnessId::Bitcoin(w.txid),
Self::Liquid(w) => WitnessId::Liquid(w.txid),
Self::Other(_) => unreachable!(),

Check warning on line 259 in src/contract/seal.rs

View check run for this annotation

Codecov / codecov/patch

src/contract/seal.rs#L259

Added line #L259 was not covered by tests
}
}
}
Expand All @@ -257,6 +268,7 @@ impl<Dbc: dbc::Proof, Seal: TxoSeal> SealWitness<Seal> for XWitness<Dbc> {
fn verify_seal(&self, seal: &Seal, msg: &Self::Message) -> Result<(), Self::Error> {
match self {
Self::Bitcoin(witness) | Self::Liquid(witness) => witness.verify_seal(seal, msg),
Self::Other(_) => unreachable!(),

Check warning on line 271 in src/contract/seal.rs

View check run for this annotation

Codecov / codecov/patch

src/contract/seal.rs#L271

Added line #L271 was not covered by tests
}
}

Expand All @@ -270,6 +282,7 @@ impl<Dbc: dbc::Proof, Seal: TxoSeal> SealWitness<Seal> for XWitness<Dbc> {
{
match self {
Self::Bitcoin(witness) | Self::Liquid(witness) => witness.verify_many_seals(seals, msg),
Self::Other(_) => unreachable!(),

Check warning on line 285 in src/contract/seal.rs

View check run for this annotation

Codecov / codecov/patch

src/contract/seal.rs#L285

Added line #L285 was not covered by tests
}
}
}
Expand Down
Loading

0 comments on commit b22610a

Please sign in to comment.