Skip to content

Commit

Permalink
chore: split IfaceClass and IfaceWrapper following stdlib changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Jul 31, 2024
1 parent ccf17da commit e7b8efc
Show file tree
Hide file tree
Showing 17 changed files with 258 additions and 354 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.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ fs = ["rgb-std/fs"]
bp-consensus = { git = "https://github.com/BP-WG/bp-core", branch = "master" }
bp-invoice = { git = "https://github.com/BP-WG/bp-std", branch = "master" }
rgb-core = { git = "https://github.com/RGB-WG/rgb-core", branch = "mining" }
rgb-invoice = { git = "https://github.com/RGB-WG/rgb-std", branch = "mining" }
rgb-std = { git = "https://github.com/RGB-WG/rgb-std", branch = "mining" }
rgb-invoice = { git = "https://github.com/RGB-WG/rgb-std", branch = "iface-generics" }
rgb-std = { git = "https://github.com/RGB-WG/rgb-std", branch = "iface-generics" }
105 changes: 0 additions & 105 deletions src/dumb.rs

This file was deleted.

8 changes: 3 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,10 @@ mod traits;
pub mod rgb20;
pub mod rgb21;
pub mod rgb25;
mod dumb;

pub use dumb::Dumb;
pub use rgb20::Rgb20;
pub use rgb21::Rgb21;
pub use rgb25::Rgb25;
pub use rgb20::{Rgb20, Rgb20Info, Rgb20Wrapper};
pub use rgb21::{Rgb21, Rgb21Wrapper};
pub use rgb25::{Rgb25, Rgb25Info, Rgb25Wrapper};
pub use traits::{IssuerWrapper, SchemaIssuer};

pub const LNPBP_IDENTITY: &str = "ssi:LZS1ux-gjD9nXPF-OcetUUkW-6r3uSCS6-aQhs9W5f-8JE7w";
Expand Down
25 changes: 10 additions & 15 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use std::path::PathBuf;
use std::str::FromStr;
use std::{fs, io};

use ifaces::{rgb20, rgb21, rgb25, Dumb, Rgb20, Rgb21, Rgb25, LNPBP_IDENTITY};
use ifaces::{rgb20, rgb21, rgb25, Rgb20, Rgb21, LNPBP_IDENTITY};
use rgbstd::containers::{
FileContent, Kit, Supplement, SUPPL_ANNOT_IFACE_CLASS, SUPPL_ANNOT_IFACE_FEATURES,
};
Expand All @@ -37,7 +37,7 @@ use strict_types::{StlFormat, SystemBuilder};

fn main() -> io::Result<()> {
let ifsys = SystemBuilder::new()
.import(Rgb21::<Dumb>::stl())
.import(Rgb21::ALL.stl())
.unwrap()
.import(rgb_contract_stl())
.unwrap()
Expand Down Expand Up @@ -75,8 +75,8 @@ fn main() -> io::Result<()> {
kit.save_armored("interfaces/RGBStd.rgba")?;

let mut kit = Kit::default();
for features in rgb20::Features::ENUMERATE {
let iface = Rgb20::<Dumb>::iface(*features);
for features in rgb20::Rgb20::ENUMERATE {
let iface = features.iface();
let types = typesys.extract(iface.types()).unwrap();
let mut suppl = Supplement::new(iface.iface_id(), LNPBP_IDENTITY);
suppl
Expand All @@ -93,8 +93,8 @@ fn main() -> io::Result<()> {
kit.save_armored("interfaces/RGB20.rgba")?;

let mut kit = Kit::default();
for features in rgb21::Features::ENUMERATE {
let iface = Rgb21::<Dumb>::iface(*features);
for features in rgb21::Rgb21::ENUMERATE {
let iface = features.iface();
let types = typesys.extract(iface.types()).unwrap();
let mut suppl = Supplement::new(iface.iface_id(), LNPBP_IDENTITY);
suppl
Expand All @@ -111,8 +111,8 @@ fn main() -> io::Result<()> {
kit.save_armored("interfaces/RGB21.rgba")?;

let mut kit = Kit::default();
for features in rgb25::Features::ENUMERATE {
let iface = Rgb25::<Dumb>::iface(*features);
for features in rgb25::Rgb25::ENUMERATE {
let iface = features.iface();
let types = typesys.extract(iface.types()).unwrap();
let mut suppl = Supplement::new(iface.iface_id(), LNPBP_IDENTITY);
suppl
Expand All @@ -129,7 +129,7 @@ fn main() -> io::Result<()> {
kit.save_armored("interfaces/RGB25.rgba")?;

let dir = PathBuf::from_str("interfaces").unwrap();
let stl = Rgb21::<Dumb>::stl();
let stl = Rgb21::ALL.stl();
stl.serialize(StlFormat::Binary, Some(&dir), "0.11.0", None)
.expect("unable to write to the file");
stl.serialize(StlFormat::Armored, Some(&dir), "0.11.0", None)
Expand Down Expand Up @@ -165,12 +165,7 @@ fn main() -> io::Result<()> {
}

let mut ifaces = vec![rgb20::iface::rgb20_base(), rgb20::iface::rgb20_renamable()];
ifaces.extend(
rgb20::Features::ENUMERATE
.iter()
.copied()
.map(Rgb20::<Dumb>::iface),
);
ifaces.extend(rgb20::Rgb20::ENUMERATE.iter().map(Rgb20::iface));

map.extend(
ifaces
Expand Down
4 changes: 2 additions & 2 deletions src/rgb20/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use rgbstd::info::ContractInfo;
use rgbstd::stl::Attachment;
use rgbstd::{Amount, Precision, XOutpoint, XWitnessId};

use crate::rgb20::Features;
use crate::rgb20::Rgb20;

#[derive(Clone, PartialEq, Eq, Hash, Debug)]
#[cfg_attr(
Expand All @@ -44,7 +44,7 @@ pub struct Rgb20Info {
pub terms: String,
pub attach: Option<Attachment>,
pub precision: Precision,
pub features: Features,
pub features: Rgb20,

pub issued: Amount, // TODO: Replace with SupplyInfo
pub burned: Amount, // TODO: Replace with SupplyInfo
Expand Down
17 changes: 8 additions & 9 deletions src/rgb20/issuer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ use bp::dbc::Method;
use rgbstd::containers::ValidContract;
use rgbstd::interface::{BuilderError, ContractBuilder, IfaceClass, TxOutpoint};
use rgbstd::invoice::{Amount, Precision};
use rgbstd::persistence::ContractStateRead;
use rgbstd::stl::{AssetSpec, Attachment, ContractTerms, RicardianContract};
use rgbstd::{AltLayer1, AssetTag, BlindingFactor, GenesisSeal, Identity};
use strict_encoding::InvalidRString;
Expand Down Expand Up @@ -62,8 +61,8 @@ pub struct PrimaryIssue {
}

impl PrimaryIssue {
pub fn testnet_with<S: ContractStateRead>(
issuer: SchemaIssuer<Rgb20<S>>,
pub fn testnet_with(
issuer: SchemaIssuer<Rgb20>,
by: &str,
ticker: &str,
name: &str,
Expand All @@ -73,7 +72,7 @@ impl PrimaryIssue {
Self::testnet_int(issuer, by, ticker, name, details, precision, false)
}

pub fn testnet<C: IssuerWrapper<IssuingIface = Rgb20<S>>, S: ContractStateRead>(
pub fn testnet<C: IssuerWrapper<IssuingIface = Rgb20>>(
by: &str,
ticker: &str,
name: &str,
Expand All @@ -83,7 +82,7 @@ impl PrimaryIssue {
Self::testnet_int(C::issuer(), by, ticker, name, details, precision, false)
}

pub fn testnet_det<C: IssuerWrapper<IssuingIface = Rgb20<S>>, S: ContractStateRead>(
pub fn testnet_det<C: IssuerWrapper<IssuingIface = Rgb20>>(
by: &str,
ticker: &str,
name: &str,
Expand All @@ -99,8 +98,8 @@ impl PrimaryIssue {
Ok(me)
}

fn testnet_int<S: ContractStateRead>(
issuer: SchemaIssuer<Rgb20<S>>,
fn testnet_int(
issuer: SchemaIssuer<Rgb20>,
by: &str,
ticker: &str,
name: &str,
Expand All @@ -118,15 +117,15 @@ impl PrimaryIssue {
let mut builder = match deterministic {
false => ContractBuilder::with(
Identity::from_str(by).expect("invalid issuer identity string"),
Rgb20::<S>::iface(features),
features.iface(),
schema,
main_iface_impl,
types,
scripts,
),
true => ContractBuilder::deterministic(
Identity::from_str(by).expect("invalid issuer identity string"),
Rgb20::<S>::iface(features),
features.iface(),
schema,
main_iface_impl,
types,
Expand Down
Loading

0 comments on commit e7b8efc

Please sign in to comment.