Skip to content

Commit

Permalink
epic on state unification and new API
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Oct 17, 2024
1 parent a42b9f8 commit 82f55ec
Show file tree
Hide file tree
Showing 14 changed files with 2,333 additions and 854 deletions.
256 changes: 117 additions & 139 deletions Cargo.lock

Large diffs are not rendered by default.

23 changes: 14 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ name = "schemata"
[dependencies]
amplify = "4.7.0"
strict_encoding = "2.7.0"
strict_types = "2.7.0"
aluvm = "0.11.0-beta.8"
bp-core = "0.11.0-beta.8"
rgb-std = { version = "0.11.0-beta.8", features = ["serde", "fs"] }
rgb-interfaces = "0.11.0-beta.8"
strict_types = "2.7.1"
aluvm = "0.11.0-beta.9"
bp-core = "0.11.0-beta.9"
rgb-std = { version = "0.11.0-beta.9", features = ["serde", "fs"] }
rgb-interfaces = { version = "0.11.0-beta.8", features = ["serde", "rand", "fs"] }
chrono = "0.4.38"
serde = "1.0"
serde_json = "1.0"
Expand All @@ -43,11 +43,16 @@ log = ["aluvm/log"]
fs = ["rgb-std/fs"]

[patch.crates-io]
commit_verify = { git = "https://github.com/LNP-BP/client_side_validation", branch = "develop" }
single_use_seals = { git = "https://github.com/LNP-BP/client_side_validation", branch = "develop" }
strict_types = { git = "https://github.com/strict-types/strict-types", branch = "develop" }
aluvm = { git = "https://github.com/AluVM/rust-aluvm", branch = "develop" }
bp-consensus = { git = "https://github.com/BP-WG/bp-core", branch = "develop" }
bp-dbc = { git = "https://github.com/BP-WG/bp-core", branch = "develop" }
bp-seals = { git = "https://github.com/BP-WG/bp-core", branch = "develop" }
bp-core = { git = "https://github.com/BP-WG/bp-core", branch = "develop" }
rgb-core = { git = "https://github.com/RGB-WG/rgb-core", branch = "develop" }
rgb-invoice = { git = "https://github.com/RGB-WG/rgb-std", branch = "develop" }
rgb-std = { git = "https://github.com/RGB-WG/rgb-std", branch = "develop" }
rgb-interfaces = { git = "https://github.com/RGB-WG/rgb-interfaces", branch = "develop" }
bp-invoice = { git = "https://github.com/BP-WG/bp-std", branch = "develop" }
rgb-core = { git = "https://github.com/RGB-WG/rgb-core", branch = "feat/fungible-nonconf" }
rgb-invoice = { git = "https://github.com/RGB-WG/rgb-std", branch = "feat/fungible-nonconf" }
rgb-std = { git = "https://github.com/RGB-WG/rgb-std", branch = "feat/fungible-nonconf" }
rgb-interfaces = { git = "https://github.com/RGB-WG/rgb-interfaces", branch = "feat/fungible-nonconf" }
12 changes: 6 additions & 6 deletions examples/rgb20.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ use amplify::hex::FromHex;
use bp::dbc::Method;
use bp::{Outpoint, Txid};
use ifaces::Rgb20;
use ifaces::stl::Precision;
use rgbstd::XWitnessId;
use rgbstd::containers::{ConsignmentExt, FileContent};
use rgbstd::interface::{FilterIncludeAll, FungibleAllocation};
use rgbstd::invoice::Precision;
use rgbstd::interface::{FilterIncludeAll, Output};
use rgbstd::persistence::Stock;
use rgbstd::XWitnessId;
use schemata::dumb::NoResolver;
use schemata::NonInflatableAsset;
use schemata::dumb::NoResolver;

#[rustfmt::skip]
fn main() {
Expand Down Expand Up @@ -36,9 +36,9 @@ fn main() {
eprintln!("\nThe issued contract data:");
eprintln!("{}", serde_json::to_string(&contract.spec()).unwrap());

for FungibleAllocation { seal, state, witness, .. } in allocations {
for Output { seal, state, witness, .. } in allocations {
let witness = witness.as_ref().map(XWitnessId::to_string).unwrap_or("~".to_owned());
eprintln!("amount={state}, owner={seal}, witness={witness}");
eprintln!("amount {state}, owner {seal}, witness {witness}");
}
eprintln!("totalSupply={}", contract.total_supply());
}
19 changes: 9 additions & 10 deletions examples/rgb21.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ use amplify::confinement::SmallBlob;
use amplify::hex::FromHex;
use amplify::{Bytes, Wrapper};
use bp::Txid;
use ifaces::rgb21::{EmbeddedMedia, TokenData};
use ifaces::rgb21::{EmbeddedMedia, NftAllocation, TokenData, TokenIndex};
use ifaces::stl::*;
use ifaces::{IssuerWrapper, Rgb21};
use rgbstd::containers::{ConsignmentExt, FileContent, Kit};
use rgbstd::invoice::Precision;
use rgbstd::persistence::Stock;
use rgbstd::stl::{AssetSpec, Attachment, ContractTerms, MediaType, RicardianContract};
use rgbstd::{Allocation, GenesisSeal, TokenIndex, XChain};
use schemata::dumb::NoResolver;
use rgbstd::{GenesisSeal, XChain};
use schemata::UniqueDigitalAsset;
use schemata::dumb::NoResolver;
use sha2::{Digest, Sha256};

#[rustfmt::skip]
Expand Down Expand Up @@ -41,7 +40,7 @@ fn main() {
};

let token_data = TokenData { index, preview: Some(preview), ..Default::default() };
let allocation = Allocation::with(index, 1);
let allocation = NftAllocation::with(index, 1);

// Let's create some stock - an in-memory stash and inventory around it:
let kit = Kit::load_file("schemata/UniqueDigitalAsset.rgb").unwrap().validate().unwrap();
Expand All @@ -53,16 +52,16 @@ fn main() {
"RGB21Unique",
).expect("schema fails to implement RGB21 interface")

.add_global_state("tokens", token_data)
.serialize_global_state("tokens", &token_data)
.expect("invalid token data")

.add_global_state("spec", spec)
.serialize_global_state("spec", &spec)
.expect("invalid nominal")

.add_global_state("terms", terms)
.serialize_global_state("terms", &terms)
.expect("invalid contract text")

.add_data("assetOwner", beneficiary, allocation)
.serialize_owned_state("assetOwner", beneficiary, &allocation, None)
.expect("invalid asset blob")

.issue_contract()
Expand Down
12 changes: 6 additions & 6 deletions examples/rgb25.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use amplify::hex::FromHex;
use bp::dbc::Method;
use bp::{Outpoint, Txid};
use ifaces::stl::Precision;
use ifaces::{Rgb25, Rgb25Wrapper};
use rgbstd::XWitnessId;
use rgbstd::containers::{ConsignmentExt, FileContent, Kit};
use rgbstd::interface::{FilterIncludeAll, FungibleAllocation};
use rgbstd::invoice::Precision;
use rgbstd::interface::{FilterIncludeAll, Output};
use rgbstd::persistence::{MemContract, Stock};
use rgbstd::XWitnessId;
use schemata::dumb::NoResolver;
use schemata::CollectibleFungibleAsset;
use schemata::dumb::NoResolver;

#[rustfmt::skip]
fn main() {
Expand Down Expand Up @@ -44,9 +44,9 @@ fn main() {
eprintln!("\nThe issued contract data:");
eprintln!("{}", contract.name());

for FungibleAllocation { seal, state, witness, .. } in allocations {
for Output { seal, state, witness, .. } in allocations {
let witness = witness.as_ref().map(XWitnessId::to_string).unwrap_or("~".to_owned());
eprintln!("amount={state}, owner={seal}, witness={witness}");
eprintln!("amount {state}, owner {seal}, witness {witness}");
}
eprintln!("totalSupply={}", contract.total_issued_supply());
}
Binary file modified schemata/CollectibleFungibleAsset.rgb
Binary file not shown.
Loading

0 comments on commit 82f55ec

Please sign in to comment.