From cecebe5a544b511349e9912f9f5475ef0034b87f Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Sun, 7 Apr 2024 13:38:37 +0200 Subject: [PATCH 01/20] chore: update to new anchors --- Cargo.lock | 42 +++++++++++-------------------- Cargo.toml | 15 +++++++++++ cli/src/command.rs | 17 ++++++++++--- psbt/src/lib.rs | 5 ++-- src/pay.rs | 16 ++---------- src/resolvers/any.rs | 16 ++++++------ src/resolvers/electrum.rs | 42 +++++++++++++++---------------- src/resolvers/esplora_blocking.rs | 42 ++++++++++++++----------------- src/runtime.rs | 6 ++--- 9 files changed, 97 insertions(+), 104 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2ecc34b..dc7157c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -323,8 +323,7 @@ dependencies = [ [[package]] name = "bp-consensus" version = "0.11.0-beta.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "966395ea17fa99b33a9093355924b0f79312b410e2c8a85ca8ebb8333098fb9a" +source = "git+https://github.com/BP-WG/bp-core?branch=v0.11#c014bad013c99e4eb828eabc37c1c5ccc30acf75" dependencies = [ "amplify", "chrono", @@ -338,8 +337,7 @@ dependencies = [ [[package]] name = "bp-core" version = "0.11.0-beta.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27581dae64d76a00fe4015eb7d710d262192ca6f18c1e798f75c4f5477f52d3c" +source = "git+https://github.com/BP-WG/bp-core?branch=v0.11#c014bad013c99e4eb828eabc37c1c5ccc30acf75" dependencies = [ "amplify", "bp-consensus", @@ -357,8 +355,7 @@ dependencies = [ [[package]] name = "bp-dbc" version = "0.11.0-beta.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4d21f5af26b145f7f73c7a338dc7bfe44d2b0f943c3ec6e3447d11d1fc3d6e0" +source = "git+https://github.com/BP-WG/bp-core?branch=v0.11#c014bad013c99e4eb828eabc37c1c5ccc30acf75" dependencies = [ "amplify", "base85", @@ -372,8 +369,7 @@ dependencies = [ [[package]] name = "bp-derive" version = "0.11.0-beta.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "259436bf0c49fa1fd0648cdde09d2d9bdc183dd4d2dfb3934902ef27faa9f14d" +source = "git+https://github.com/BP-WG/bp-std?branch=v0.11#79cee6874bf037a276b08d2ad0aa0206417bb52b" dependencies = [ "amplify", "bitcoin_hashes", @@ -422,8 +418,7 @@ dependencies = [ [[package]] name = "bp-invoice" version = "0.11.0-beta.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48ee0387fa924bd002b51713c42daf3cb7c3b669509523607445a99c90491788" +source = "git+https://github.com/BP-WG/bp-std?branch=v0.11#79cee6874bf037a276b08d2ad0aa0206417bb52b" dependencies = [ "amplify", "bech32", @@ -435,8 +430,7 @@ dependencies = [ [[package]] name = "bp-seals" version = "0.11.0-beta.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "131f371c9d605d5ed07cb0f5b07f3f261f6b3f6a146b6e890ecdb37802c51f6a" +source = "git+https://github.com/BP-WG/bp-core?branch=v0.11#c014bad013c99e4eb828eabc37c1c5ccc30acf75" dependencies = [ "amplify", "baid58", @@ -452,8 +446,7 @@ dependencies = [ [[package]] name = "bp-std" version = "0.11.0-beta.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84413a3ce10b304ce52c7a1604fccf78634f3a27df47b239be381b76ceb1bdea" +source = "git+https://github.com/BP-WG/bp-std?branch=v0.11#79cee6874bf037a276b08d2ad0aa0206417bb52b" dependencies = [ "amplify", "bp-consensus", @@ -491,8 +484,7 @@ dependencies = [ [[package]] name = "bp-wallet" version = "0.11.0-beta.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4552e90fad2ed01b091b499b891e7a5d9e03f3c74e718e0e4801b01056fc247" +source = "git+https://github.com/BP-WG/bp-wallet?branch=v0.11#f217eb141dbb51df6f15cde351aef76c6366f53c" dependencies = [ "amplify", "bp-electrum", @@ -754,8 +746,7 @@ dependencies = [ [[package]] name = "descriptors" version = "0.11.0-beta.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08e46bb50018748f38bad98647589f2bef433faa5d8ed233c1e472c51275bd0d" +source = "git+https://github.com/BP-WG/bp-std?branch=v0.11#79cee6874bf037a276b08d2ad0aa0206417bb52b" dependencies = [ "amplify", "bp-derive", @@ -1424,8 +1415,7 @@ dependencies = [ [[package]] name = "psbt" version = "0.11.0-beta.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a572f23bb63e0826d4540a6b925f152c64a47e0871d63dc06553aa7fcd045e5a" +source = "git+https://github.com/BP-WG/bp-std?branch=v0.11#79cee6874bf037a276b08d2ad0aa0206417bb52b" dependencies = [ "amplify", "base64", @@ -1571,8 +1561,7 @@ dependencies = [ [[package]] name = "rgb-core" version = "0.11.0-beta.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "377bc5d01d9b22fef51da1ab83cfc743bf29827ce11fc4a2616894282a95c6a8" +source = "git+https://github.com/RGB-WG/rgb-core?branch=v0.11#12a2e2b3d2af160301fb04d0423051c4ad0888a0" dependencies = [ "aluvm", "amplify", @@ -1594,8 +1583,7 @@ dependencies = [ [[package]] name = "rgb-invoice" version = "0.11.0-beta.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb83cdef397b7e8d84bd46f3f61620d89436e139cbab1cb929fd1c29aae24376" +source = "git+https://github.com/RGB-WG/rgb-std?branch=v0.11#c9712b858a5ec461756d6c2d17c8f5a09fbd3921" dependencies = [ "amplify", "baid58", @@ -1665,8 +1653,7 @@ dependencies = [ [[package]] name = "rgb-std" version = "0.11.0-beta.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a52e61cff03f205c5f4782bbe714d3a9a065086ec6c896ca39f3618aea5434d2" +source = "git+https://github.com/RGB-WG/rgb-std?branch=v0.11#c9712b858a5ec461756d6c2d17c8f5a09fbd3921" dependencies = [ "amplify", "ascii-armor", @@ -2111,8 +2098,7 @@ dependencies = [ [[package]] name = "strict_types" version = "2.7.0-beta.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78c32716de4b99b0e8fb0c114e99b6929613e8d7302999c6b8c77251783923ad" +source = "git+https://github.com/strict-types/strict-types?branch=master#2350162c6a6fda6a7f74373e0a08d8e3a70c37b4" dependencies = [ "amplify", "ascii-armor", diff --git a/Cargo.toml b/Cargo.toml index f7bc07d..ef37942 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -94,3 +94,18 @@ serde = ["serde_crate", "serde_with", "serde_yaml", "bp-std/serde", "bp-wallet/s [package.metadata.docs.rs] features = ["all"] + +[patch.crates-io] +strict_types = { git = "https://github.com/strict-types/strict-types", branch = "master" } +bp-consensus = { git = "https://github.com/BP-WG/bp-core", branch = "v0.11" } +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" } +bp-invoice = { git = "https://github.com/BP-WG/bp-std", branch = "v0.11" } +bp-std = { git = "https://github.com/BP-WG/bp-std", branch = "v0.11" } +psbt = { git = "https://github.com/BP-WG/bp-std", branch = "v0.11" } +descriptors = { git = "https://github.com/BP-WG/bp-std", branch = "v0.11" } +bp-wallet = { git = "https://github.com/BP-WG/bp-wallet", branch = "v0.11" } +rgb-core = { git = "https://github.com/RGB-WG/rgb-core", branch = "v0.11" } +rgb-std = { git = "https://github.com/RGB-WG/rgb-std", branch = "v0.11" } +rgb-invoice = { git = "https://github.com/RGB-WG/rgb-std", branch = "v0.11" } diff --git a/cli/src/command.rs b/cli/src/command.rs index 2978a31..9e3787b 100644 --- a/cli/src/command.rs +++ b/cli/src/command.rs @@ -890,6 +890,7 @@ impl Exec for RgbArgs { fs::create_dir_all(format!("{root_dir}/stash/ifaces"))?; fs::create_dir_all(format!("{root_dir}/stash/geneses"))?; fs::create_dir_all(format!("{root_dir}/stash/bundles"))?; + fs::create_dir_all(format!("{root_dir}/stash/witnesses"))?; fs::create_dir_all(format!("{root_dir}/stash/anchors"))?; fs::create_dir_all(format!("{root_dir}/stash/extensions"))?; fs::create_dir_all(format!("{root_dir}/state"))?; @@ -935,11 +936,15 @@ impl Exec for RgbArgs { format!("{root_dir}/stash/bundles/{id}.yaml"), serde_yaml::to_string(runtime.bundle(id)?)?, )?; + fs::write( + format!("{root_dir}/stash/witnesses/{id}.yaml"), + serde_yaml::to_string(&runtime.bundled_witness(id)?.pub_witness)?, + )?; } for id in runtime.witness_ids()? { fs::write( format!("{root_dir}/stash/anchors/{id}.yaml"), - serde_yaml::to_string(runtime.anchor(id)?)?, + serde_yaml::to_string(&runtime.anchor(id)?)?, )?; } for id in runtime.extension_ids()? { @@ -961,11 +966,15 @@ impl Exec for RgbArgs { // Index fs::write( format!("{root_dir}/index/op-to-bundle.yaml"), - serde_yaml::to_string(runtime.debug_bundle_op_index())?, + serde_yaml::to_string(runtime.debug_op_bundle_index())?, + )?; + fs::write( + format!("{root_dir}/index/bundle-to-contract.yaml"), + serde_yaml::to_string(runtime.debug_bundle_contract_index())?, )?; fs::write( - format!("{root_dir}/index/bundle-to-anchor.yaml"), - serde_yaml::to_string(runtime.debug_anchor_bundle_index())?, + format!("{root_dir}/index/bundle-to-witness.yaml"), + serde_yaml::to_string(runtime.debug_bundle_witness_index())?, )?; fs::write( format!("{root_dir}/index/contracts.yaml"), diff --git a/psbt/src/lib.rs b/psbt/src/lib.rs index 33547d4..bebe42f 100644 --- a/psbt/src/lib.rs +++ b/psbt/src/lib.rs @@ -29,7 +29,7 @@ use bp::dbc::tapret::TapretProof; pub use psbt::*; pub use rgb::*; use rgbstd::containers::{Batch, Fascia}; -use rgbstd::{AnchorSet, XAnchor, XChain}; +use rgbstd::{AnchorSet, XChain, XWitnessId}; pub use self::rgb::{ ProprietaryKeyRgb, RgbExt, RgbInExt, RgbOutExt, RgbPsbtError, PSBT_GLOBAL_RGB_TRANSITION, @@ -106,7 +106,8 @@ impl RgbPsbt for Psbt { let anchor = AnchorSet::from_split(tapret_anchor, opret_anchor) .expect("at least one of DBC are present due to CloseMethodSet type guarantees"); Ok(Fascia { - anchor: XAnchor::Bitcoin(anchor), + witness_id: XWitnessId::Bitcoin(self.txid()), + anchor, bundles, }) } diff --git a/src/pay.rs b/src/pay.rs index c6f8af0..e6bc2ca 100644 --- a/src/pay.rs +++ b/src/pay.rs @@ -22,7 +22,6 @@ use std::collections::{BTreeMap, BTreeSet}; use std::convert::Infallible; -use amplify::confinement::Confined; use bp::dbc::tapret::TapretProof; use bp::seals::txout::{CloseMethod, ExplicitSeal}; use bp::{Outpoint, Sats, ScriptPubkey, Vout}; @@ -35,7 +34,7 @@ use rgbstd::invoice::{Amount, Beneficiary, InvoiceState, RgbInvoice}; use rgbstd::persistence::{ ComposeError, ConsignerError, Inventory, InventoryError, Stash, StashError, }; -use rgbstd::{WitnessId, XChain}; +use rgbstd::XChain; use crate::{ ContractOutpointsFilter, DescriptorRgb, RgbKeychain, Runtime, TapTweakAlreadyAssigned, @@ -342,20 +341,9 @@ impl Runtime { }; self.stock_mut().consume(fascia)?; - let mut transfer = self + let transfer = self .stock() .transfer(contract_id, beneficiary2, beneficiary1)?; - let mut terminals = transfer.terminals.to_inner(); - for (bundle_id, terminal) in terminals.iter_mut() { - let Some(ab) = transfer.anchored_bundle(*bundle_id) else { - continue; - }; - if ab.anchor.witness_id_unchecked() == WitnessId::Bitcoin(witness_txid) { - // TODO: Use unsigned tx - terminal.witness_tx = Some(XChain::Bitcoin(psbt.to_unsigned_tx().into())); - } - } - transfer.terminals = Confined::from_collection_unsafe(terminals); Ok(transfer) } diff --git a/src/resolvers/any.rs b/src/resolvers/any.rs index 08f69d2..e3da7a8 100644 --- a/src/resolvers/any.rs +++ b/src/resolvers/any.rs @@ -22,7 +22,7 @@ use rgbstd::containers::Consignment; use rgbstd::resolvers::ResolveHeight; use rgbstd::validation::{ResolveWitness, WitnessResolverError}; -use rgbstd::{WitnessAnchor, WitnessId, XAnchor, XPubWitness}; +use rgbstd::{WitnessAnchor, XWitnessId, XWitnessTx}; #[cfg(feature = "electrum")] use crate::electrum; @@ -73,9 +73,9 @@ impl AnyResolver { pub fn add_terminals(&mut self, consignment: &Consignment) { match self { #[cfg(feature = "electrum")] - AnyResolver::Electrum(inner) => inner.add_terminals(consignment), + AnyResolver::Electrum(inner) => inner.add_witnesses(consignment), #[cfg(feature = "esplora_blocking")] - AnyResolver::Esplora(inner) => inner.add_terminals(consignment), + AnyResolver::Esplora(inner) => inner.add_witnesses(consignment), } } } @@ -83,12 +83,12 @@ impl AnyResolver { impl ResolveHeight for AnyResolver { type Error = AnyAnchorResolverError; - fn resolve_anchor(&mut self, anchor: &XAnchor) -> Result { + fn resolve_height(&mut self, witness_id: XWitnessId) -> Result { match self { #[cfg(feature = "electrum")] - AnyResolver::Electrum(inner) => inner.resolve_anchor(anchor).map_err(|e| e.into()), + AnyResolver::Electrum(inner) => inner.resolve_height(witness_id).map_err(|e| e.into()), #[cfg(feature = "esplora_blocking")] - AnyResolver::Esplora(inner) => inner.resolve_anchor(anchor).map_err(|e| e.into()), + AnyResolver::Esplora(inner) => inner.resolve_height(witness_id).map_err(|e| e.into()), } } } @@ -96,8 +96,8 @@ impl ResolveHeight for AnyResolver { impl ResolveWitness for AnyResolver { fn resolve_pub_witness( &self, - witness_id: WitnessId, - ) -> Result { + witness_id: XWitnessId, + ) -> Result { match self { #[cfg(feature = "electrum")] AnyResolver::Electrum(inner) => inner.resolve_pub_witness(witness_id), diff --git a/src/resolvers/electrum.rs b/src/resolvers/electrum.rs index f67a45e..af72748 100644 --- a/src/resolvers/electrum.rs +++ b/src/resolvers/electrum.rs @@ -27,7 +27,7 @@ use electrum::{Client, ElectrumApi, Error, Param}; use rgbstd::containers::Consignment; use rgbstd::resolvers::ResolveHeight; use rgbstd::validation::{ResolveWitness, WitnessResolverError}; -use rgbstd::{Layer1, WitnessAnchor, WitnessId, WitnessOrd, WitnessPos, XAnchor, XPubWitness}; +use rgbstd::{Layer1, WitnessAnchor, WitnessOrd, WitnessPos, XChain, XWitnessId, XWitnessTx}; pub struct Resolver { electrum_client: Client, @@ -45,9 +45,6 @@ pub enum AnchorResolverError { /// impossible conversion ImpossibleConversion, - /// invalid anchor {0} - InvalidAnchor(String), - /// unsupported layer 1 {0} UnsupportedLayer1(Layer1), } @@ -62,13 +59,17 @@ impl Resolver { }) } - pub fn add_terminals(&mut self, consignment: &Consignment) { + pub fn add_witnesses(&mut self, consignment: &Consignment) { self.terminal_txes.extend( consignment - .terminals - .values() - .filter_map(|t| t.witness_tx.as_ref().map(XPubWitness::as_reduced_unsafe)) - .map(|tx| (tx.txid(), tx.clone())), + .bundles + .iter() + .filter_map(|bw| bw.pub_witness.maybe_map_ref(|w| w.tx.clone())) + .filter_map(|tx| match tx { + XChain::Bitcoin(tx) => Some(tx), + XChain::Liquid(_) | XChain::Other(_) => None, + }) + .map(|tx| (tx.txid(), tx)), ); } } @@ -76,18 +77,15 @@ impl Resolver { impl ResolveHeight for Resolver { type Error = AnchorResolverError; - fn resolve_anchor(&mut self, anchor: &XAnchor) -> Result { - let XAnchor::Bitcoin(anchor) = anchor else { - return Err(AnchorResolverError::UnsupportedLayer1(anchor.layer1())); + fn resolve_height(&mut self, witness_id: XWitnessId) -> Result { + let XWitnessId::Bitcoin(txid) = witness_id else { + return Err(AnchorResolverError::UnsupportedLayer1(witness_id.layer1())); }; - let txid = anchor - .txid() - .ok_or(AnchorResolverError::InvalidAnchor(format!("{:#?}", anchor)))?; if self.terminal_txes.contains_key(&txid) { return Ok(WitnessAnchor { witness_ord: WitnessOrd::OffChain, - witness_id: WitnessId::Bitcoin(txid), + witness_id, }); } @@ -154,7 +152,7 @@ impl ResolveHeight for Resolver { Ok(WitnessAnchor { witness_ord, - witness_id: WitnessId::Bitcoin(txid), + witness_id, }) } } @@ -162,9 +160,9 @@ impl ResolveHeight for Resolver { impl ResolveWitness for Resolver { fn resolve_pub_witness( &self, - witness_id: WitnessId, - ) -> Result { - let WitnessId::Bitcoin(txid) = witness_id else { + witness_id: XWitnessId, + ) -> Result { + let XWitnessId::Bitcoin(txid) = witness_id else { return Err(WitnessResolverError::Other( witness_id, AnchorResolverError::UnsupportedLayer1(witness_id.layer1()).to_string(), @@ -172,7 +170,7 @@ impl ResolveWitness for Resolver { }; if let Some(tx) = self.terminal_txes.get(&txid) { - return Ok(XPubWitness::Bitcoin(tx.clone())); + return Ok(XWitnessTx::Bitcoin(tx.clone())); } match self.electrum_client.transaction_get_raw(&txid) { @@ -180,7 +178,7 @@ impl ResolveWitness for Resolver { let tx = Tx::consensus_deserialize(raw_tx).map_err(|_| { WitnessResolverError::Other(witness_id, s!("cannot deserialize raw TX")) })?; - Ok(XPubWitness::Bitcoin(tx)) + Ok(XWitnessTx::Bitcoin(tx)) } Err(e) if e.to_string() diff --git a/src/resolvers/esplora_blocking.rs b/src/resolvers/esplora_blocking.rs index 944a673..b167751 100644 --- a/src/resolvers/esplora_blocking.rs +++ b/src/resolvers/esplora_blocking.rs @@ -26,9 +26,7 @@ pub use esplora::Error as ResolverError; use rgbstd::containers::Consignment; use rgbstd::resolvers::ResolveHeight; use rgbstd::validation::{ResolveWitness, WitnessResolverError}; -use rgbstd::{ - Layer1, WitnessAnchor, WitnessId, WitnessOrd, WitnessPos, XAnchor, XChain, XPubWitness, -}; +use rgbstd::{Layer1, WitnessAnchor, WitnessOrd, WitnessPos, XChain, XWitnessId, XWitnessTx}; pub struct Resolver { esplora_client: esplora::BlockingClient, @@ -43,9 +41,6 @@ pub enum AnchorResolverError { #[display(inner)] Error(esplora::Error), - /// invalid anchor {0} - InvalidAnchor(String), - /// unsupported layer 1 {0} UnsupportedLayer1(Layer1), } @@ -60,13 +55,17 @@ impl Resolver { }) } - pub fn add_terminals(&mut self, consignment: &Consignment) { + pub fn add_witnesses(&mut self, consignment: &Consignment) { self.terminal_txes.extend( consignment - .terminals - .values() - .filter_map(|t| t.witness_tx.as_ref().map(XPubWitness::as_reduced_unsafe)) - .map(|tx| (tx.txid(), tx.clone())), + .bundles + .iter() + .filter_map(|bw| bw.pub_witness.maybe_map_ref(|w| w.tx.clone())) + .filter_map(|tx| match tx { + XChain::Bitcoin(tx) => Some(tx), + XChain::Liquid(_) | XChain::Other(_) => None, + }) + .map(|tx| (tx.txid(), tx)), ); } } @@ -74,18 +73,15 @@ impl Resolver { impl ResolveHeight for Resolver { type Error = AnchorResolverError; - fn resolve_anchor(&mut self, anchor: &XAnchor) -> Result { - let XAnchor::Bitcoin(anchor) = anchor else { - return Err(AnchorResolverError::UnsupportedLayer1(anchor.layer1())); + fn resolve_height(&mut self, witness_id: XWitnessId) -> Result { + let XWitnessId::Bitcoin(txid) = witness_id else { + return Err(AnchorResolverError::UnsupportedLayer1(witness_id.layer1())); }; - let txid = anchor - .txid() - .ok_or(AnchorResolverError::InvalidAnchor(format!("{:#?}", anchor)))?; if self.terminal_txes.contains_key(&txid) { return Ok(WitnessAnchor { witness_ord: WitnessOrd::OffChain, - witness_id: WitnessId::Bitcoin(txid), + witness_id, }); } @@ -101,7 +97,7 @@ impl ResolveHeight for Resolver { }; Ok(WitnessAnchor { witness_ord: ord, - witness_id: WitnessId::Bitcoin(txid), + witness_id, }) } } @@ -109,9 +105,9 @@ impl ResolveHeight for Resolver { impl ResolveWitness for Resolver { fn resolve_pub_witness( &self, - witness_id: WitnessId, - ) -> Result { - let WitnessId::Bitcoin(txid) = witness_id else { + witness_id: XWitnessId, + ) -> Result { + let XWitnessId::Bitcoin(txid) = witness_id else { return Err(WitnessResolverError::Other( witness_id, AnchorResolverError::UnsupportedLayer1(witness_id.layer1()).to_string(), @@ -119,7 +115,7 @@ impl ResolveWitness for Resolver { }; if let Some(tx) = self.terminal_txes.get(&txid) { - return Ok(XPubWitness::Bitcoin(tx.clone())); + return Ok(XWitnessTx::Bitcoin(tx.clone())); } self.esplora_client diff --git a/src/runtime.rs b/src/runtime.rs index ef4040e..61f814c 100644 --- a/src/runtime.rs +++ b/src/runtime.rs @@ -42,7 +42,7 @@ use rgbstd::persistence::{ }; use rgbstd::resolvers::ResolveHeight; use rgbstd::validation::{self, ResolveWitness}; -use rgbstd::{AssignmentWitness, ContractId, WitnessId, XChain, XOutpoint}; +use rgbstd::{AssignmentWitness, ContractId, XChain, XOutpoint, XWitnessId}; use strict_types::encoding::{DecodeError, DeserializeError, Ident, SerializeError, TypeName}; use crate::{DescriptorRgb, RgbDescr}; @@ -156,7 +156,7 @@ impl, K> WitnessFilter for Runtime { self.wallet() .transactions() .keys() - .any(|txid| AssignmentWitness::Present(WitnessId::Bitcoin(*txid)) == witness) + .any(|txid| AssignmentWitness::Present(XWitnessId::Bitcoin(*txid)) == witness) } } @@ -267,7 +267,7 @@ impl, K> Runtime { &self, contract_id: ContractId, iface_name: impl Into, - ) -> Result>, RuntimeError> { + ) -> Result>, RuntimeError> { let iface_name = iface_name.into(); let iface = self.stock.iface_by_name(&iface_name)?; let default_op = iface From ad18a861dbf9e726a18f012474b305060da59117 Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Thu, 11 Apr 2024 08:27:47 +0200 Subject: [PATCH 02/20] chore: update for asset tags --- Cargo.lock | 6 +++--- Cargo.toml | 6 +++--- cli/src/command.rs | 9 +-------- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dc7157c..62f7815 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1561,7 +1561,7 @@ dependencies = [ [[package]] name = "rgb-core" version = "0.11.0-beta.5" -source = "git+https://github.com/RGB-WG/rgb-core?branch=v0.11#12a2e2b3d2af160301fb04d0423051c4ad0888a0" +source = "git+https://github.com/RGB-WG/rgb-core?branch=asset_tags#9d193fbfc676fee6496c025f395606eea45704d6" dependencies = [ "aluvm", "amplify", @@ -1583,7 +1583,7 @@ dependencies = [ [[package]] name = "rgb-invoice" version = "0.11.0-beta.5" -source = "git+https://github.com/RGB-WG/rgb-std?branch=v0.11#c9712b858a5ec461756d6c2d17c8f5a09fbd3921" +source = "git+https://github.com/RGB-WG/rgb-std?branch=asset_tags#dbf0df4d5c8457b5d298b0a69ecb0e58b04257c1" dependencies = [ "amplify", "baid58", @@ -1653,7 +1653,7 @@ dependencies = [ [[package]] name = "rgb-std" version = "0.11.0-beta.5" -source = "git+https://github.com/RGB-WG/rgb-std?branch=v0.11#c9712b858a5ec461756d6c2d17c8f5a09fbd3921" +source = "git+https://github.com/RGB-WG/rgb-std?branch=asset_tags#dbf0df4d5c8457b5d298b0a69ecb0e58b04257c1" dependencies = [ "amplify", "ascii-armor", diff --git a/Cargo.toml b/Cargo.toml index ef37942..4115404 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -106,6 +106,6 @@ bp-std = { git = "https://github.com/BP-WG/bp-std", branch = "v0.11" } psbt = { git = "https://github.com/BP-WG/bp-std", branch = "v0.11" } descriptors = { git = "https://github.com/BP-WG/bp-std", branch = "v0.11" } bp-wallet = { git = "https://github.com/BP-WG/bp-wallet", branch = "v0.11" } -rgb-core = { git = "https://github.com/RGB-WG/rgb-core", branch = "v0.11" } -rgb-std = { git = "https://github.com/RGB-WG/rgb-std", branch = "v0.11" } -rgb-invoice = { git = "https://github.com/RGB-WG/rgb-std", branch = "v0.11" } +rgb-core = { git = "https://github.com/RGB-WG/rgb-core", branch = "asset_tags" } +rgb-std = { git = "https://github.com/RGB-WG/rgb-std", branch = "asset_tags" } +rgb-invoice = { git = "https://github.com/RGB-WG/rgb-std", branch = "asset_tags" } diff --git a/cli/src/command.rs b/cli/src/command.rs index 9e3787b..60c63fb 100644 --- a/cli/src/command.rs +++ b/cli/src/command.rs @@ -43,7 +43,7 @@ use rgbstd::persistence::{Inventory, Stash}; use rgbstd::schema::SchemaId; use rgbstd::validation::Validity; use rgbstd::vm::RgbIsa; -use rgbstd::{AssetTag, AssignmentType, BundleId, OutputSeal, XChain, XOutputSeal}; +use rgbstd::{BundleId, OutputSeal, XChain, XOutputSeal}; use seals::txout::CloseMethod; use serde_crate::{Deserialize, Serialize}; use strict_types::encoding::{FieldName, TypeName}; @@ -784,7 +784,6 @@ impl Exec for RgbArgs { pub struct ConsignmentInspection { version: ContainerVer, transfer: bool, - asset_tags: TinyOrdMap, terminals: SmallOrdMap, supplements: TinyOrdSet, signatures: TinyOrdMap, @@ -838,7 +837,6 @@ impl Exec for RgbArgs { let contract = ConsignmentInspection { version: contract.version, transfer: contract.transfer, - asset_tags: contract.asset_tags, terminals: contract.terminals, supplements: contract.supplements, signatures: contract.signatures, @@ -925,11 +923,6 @@ impl Exec for RgbArgs { serde_yaml::to_string(suppl)?, )?; } - let tags = runtime.contract_asset_tags(id)?; - fs::write( - format!("{root_dir}/stash/geneses/{id}.tags.yaml"), - serde_yaml::to_string(tags)?, - )?; } for id in runtime.bundle_ids()? { fs::write( From a4865361de2194d32b0c54054062edae83257c3e Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Sun, 7 Apr 2024 20:23:07 +0200 Subject: [PATCH 03/20] psbt: support up to two bundles per witness PSBT --- Cargo.lock | 6 +-- Cargo.toml | 6 +-- cli/src/command.rs | 2 +- psbt/src/lib.rs | 22 ++++++--- psbt/src/rgb.rs | 108 +++++++++++++++++++++++---------------------- 5 files changed, 79 insertions(+), 65 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 62f7815..61e3bf6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1561,7 +1561,7 @@ dependencies = [ [[package]] name = "rgb-core" version = "0.11.0-beta.5" -source = "git+https://github.com/RGB-WG/rgb-core?branch=asset_tags#9d193fbfc676fee6496c025f395606eea45704d6" +source = "git+https://github.com/RGB-WG/rgb-core?branch=single-commit#9ea69c018d95fe7a3a0d991609145cabe41b9eda" dependencies = [ "aluvm", "amplify", @@ -1583,7 +1583,7 @@ dependencies = [ [[package]] name = "rgb-invoice" version = "0.11.0-beta.5" -source = "git+https://github.com/RGB-WG/rgb-std?branch=asset_tags#dbf0df4d5c8457b5d298b0a69ecb0e58b04257c1" +source = "git+https://github.com/RGB-WG/rgb-std?branch=single-commit#c72159cc3d407696b66b559705c9c03da295663e" dependencies = [ "amplify", "baid58", @@ -1653,7 +1653,7 @@ dependencies = [ [[package]] name = "rgb-std" version = "0.11.0-beta.5" -source = "git+https://github.com/RGB-WG/rgb-std?branch=asset_tags#dbf0df4d5c8457b5d298b0a69ecb0e58b04257c1" +source = "git+https://github.com/RGB-WG/rgb-std?branch=single-commit#c72159cc3d407696b66b559705c9c03da295663e" dependencies = [ "amplify", "ascii-armor", diff --git a/Cargo.toml b/Cargo.toml index 4115404..2a5ae1b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -106,6 +106,6 @@ bp-std = { git = "https://github.com/BP-WG/bp-std", branch = "v0.11" } psbt = { git = "https://github.com/BP-WG/bp-std", branch = "v0.11" } descriptors = { git = "https://github.com/BP-WG/bp-std", branch = "v0.11" } bp-wallet = { git = "https://github.com/BP-WG/bp-wallet", branch = "v0.11" } -rgb-core = { git = "https://github.com/RGB-WG/rgb-core", branch = "asset_tags" } -rgb-std = { git = "https://github.com/RGB-WG/rgb-std", branch = "asset_tags" } -rgb-invoice = { git = "https://github.com/RGB-WG/rgb-std", branch = "asset_tags" } +rgb-core = { git = "https://github.com/RGB-WG/rgb-core", branch = "single-commit" } +rgb-std = { git = "https://github.com/RGB-WG/rgb-std", branch = "single-commit" } +rgb-invoice = { git = "https://github.com/RGB-WG/rgb-std", branch = "single-commit" } diff --git a/cli/src/command.rs b/cli/src/command.rs index 60c63fb..1565e1b 100644 --- a/cli/src/command.rs +++ b/cli/src/command.rs @@ -937,7 +937,7 @@ impl Exec for RgbArgs { for id in runtime.witness_ids()? { fs::write( format!("{root_dir}/stash/anchors/{id}.yaml"), - serde_yaml::to_string(&runtime.anchor(id)?)?, + serde_yaml::to_string(&runtime.anchors(id)?)?, )?; } for id in runtime.extension_ids()? { diff --git a/psbt/src/lib.rs b/psbt/src/lib.rs index bebe42f..9806976 100644 --- a/psbt/src/lib.rs +++ b/psbt/src/lib.rs @@ -28,8 +28,8 @@ use bp::dbc::opret::OpretProof; use bp::dbc::tapret::TapretProof; pub use psbt::*; pub use rgb::*; -use rgbstd::containers::{Batch, Fascia}; -use rgbstd::{AnchorSet, XChain, XWitnessId}; +use rgbstd::containers::{AnchorSet, Batch, CloseMethodSet, Fascia}; +use rgbstd::{XChain, XWitnessId}; pub use self::rgb::{ ProprietaryKeyRgb, RgbExt, RgbInExt, RgbOutExt, RgbPsbtError, PSBT_GLOBAL_RGB_TRANSITION, @@ -85,7 +85,7 @@ impl RgbPsbt for Psbt { if !inputs.is_empty() { return Err(EmbedError::AbsentInputs); } - self.push_rgb_transition(info.transition, info.methods) + self.push_rgb_transition(info.transition, info.method) .expect("transitions are unique since they are in BTreeMap indexed by opid"); } Ok(()) @@ -94,8 +94,14 @@ impl RgbPsbt for Psbt { fn rgb_commit(&mut self) -> Result { // Convert RGB data to MPCs? Or should we do it at the moment we add them... No, // since we may require more DBC methods with each additional state transition - let (bundles, methods) = self.rgb_bundles_to_mpc()?; + let bundles = self.rgb_bundles_to_mpc()?; // DBC commitment for the required methods + let methods = bundles + .values() + .flat_map(|b| b.iter()) + .map(|b| CloseMethodSet::from(b.close_method)) + .reduce(|methods, method| methods | method) + .ok_or(RgbPsbtError::NoContracts)?; let (mut tapret_anchor, mut opret_anchor) = (None, None); if methods.has_tapret_first() { tapret_anchor = Some(self.dbc_commit::()?); @@ -103,8 +109,12 @@ impl RgbPsbt for Psbt { if methods.has_opret_first() { opret_anchor = Some(self.dbc_commit::()?); } - let anchor = AnchorSet::from_split(tapret_anchor, opret_anchor) - .expect("at least one of DBC are present due to CloseMethodSet type guarantees"); + let anchor = match (tapret_anchor, opret_anchor) { + (None, None) => return Err(RgbPsbtError::NoContracts.into()), + (Some(tapret), None) => AnchorSet::Tapret(tapret), + (None, Some(opret)) => AnchorSet::Opret(opret), + (Some(tapret), Some(opret)) => AnchorSet::Double { tapret, opret }, + }; Ok(Fascia { witness_id: XWitnessId::Bitcoin(self.txid()), anchor, diff --git a/psbt/src/rgb.rs b/psbt/src/rgb.rs index 0f056eb..f8fb8af 100644 --- a/psbt/src/rgb.rs +++ b/psbt/src/rgb.rs @@ -19,15 +19,16 @@ // See the License for the specific language governing permissions and // limitations under the License. -use std::collections::{BTreeMap, BTreeSet}; +use std::collections::{BTreeMap, BTreeSet, HashMap}; -use amplify::confinement::{Confined, MediumOrdMap, SmallOrdMap, U24}; +use amplify::confinement::{Confined, SmallOrdMap, U24}; use amplify::{confinement, FromSliceError}; use bp::dbc::Method; +use bp::seals::txout::CloseMethod; use commit_verify::mpc; use psbt::{KeyAlreadyPresent, KeyMap, MpcPsbtError, PropKey, Psbt}; use rgbstd::accessors::{MergeReveal, MergeRevealError}; -use rgbstd::containers::CloseMethodSet; +use rgbstd::containers::BundleDichotomy; use rgbstd::interface::VelocityHint; use rgbstd::{ContractId, InputMap, OpId, Operation, Transition, TransitionBundle, Vin}; use strict_encoding::{DeserializeError, StrictDeserialize, StrictSerialize}; @@ -157,50 +158,58 @@ pub trait RgbExt { fn rgb_transition(&self, opid: OpId) -> Result, RgbPsbtError>; - fn rgb_close_methods(&self, opid: OpId) -> Result, RgbPsbtError>; + fn rgb_close_method(&self, opid: OpId) -> Result, RgbPsbtError>; fn push_rgb_transition( &mut self, transition: Transition, - methods: CloseMethodSet, + method: CloseMethod, ) -> Result; - fn rgb_bundles( - &self, - ) -> Result, RgbPsbtError> { + fn rgb_bundles(&self) -> Result, RgbPsbtError> { let mut map = BTreeMap::new(); for contract_id in self.rgb_contract_ids()? { - let mut input_map = SmallOrdMap::::new(); - let mut known_transitions = SmallOrdMap::::new(); - let mut method_set = None::; + let mut input_map = HashMap::>::new(); + let mut known_transitions = + HashMap::>::new(); for (opid, vin) in self.rgb_contract_consumers(contract_id)? { - let (transition, methods) = ( + let (transition, method) = ( self.rgb_transition(opid)?, - self.rgb_close_methods(opid)? + self.rgb_close_method(opid)? .ok_or(RgbPsbtError::NoCloseMethod(opid))?, ); - method_set |= methods; - input_map.insert(vin, opid)?; + input_map.entry(method).or_default().insert(vin, opid)?; if let Some(transition) = transition { - known_transitions.insert(opid, transition)?; + known_transitions + .entry(method) + .or_default() + .insert(opid, transition)?; } } - let bundle = TransitionBundle { - input_map: InputMap::from(Confined::from_collection_unsafe(input_map.into_inner())), - known_transitions: Confined::try_from(known_transitions.into_inner()) - .map_err(|_| RgbPsbtError::NoTransitions(contract_id))?, - }; - map.insert(contract_id, (bundle, method_set.expect("type guarantees"))); + let mut bundles = vec![]; + for (method, input_map) in input_map { + let known_transitions = known_transitions.remove(&method).unwrap_or_default(); + bundles.push(TransitionBundle { + close_method: method, + input_map: InputMap::from(Confined::from_collection_unsafe( + input_map.into_inner(), + )), + known_transitions: Confined::try_from(known_transitions.into_inner()) + .map_err(|_| RgbPsbtError::NoTransitions(contract_id))?, + }); + } + let mut bundles = bundles.into_iter(); + let first = bundles + .next() + .ok_or(RgbPsbtError::NoTransitions(contract_id))?; + map.insert(contract_id, BundleDichotomy::with(first, bundles.next())); } Ok(map) } fn rgb_bundles_to_mpc( &mut self, - ) -> Result< - (Confined, 1, U24>, CloseMethodSet), - RgbPsbtError, - >; + ) -> Result, 1, U24>, RgbPsbtError>; } impl RgbExt for Psbt { @@ -248,12 +257,12 @@ impl RgbExt for Psbt { Ok(Some(transition)) } - fn rgb_close_methods(&self, opid: OpId) -> Result, RgbPsbtError> { + fn rgb_close_method(&self, opid: OpId) -> Result, RgbPsbtError> { let Some(m) = self.proprietary(&PropKey::rgb_closing_methods(opid)) else { return Ok(None); }; if m.len() == 1 { - if let Ok(method) = CloseMethodSet::try_from(m[0]) { + if let Ok(method) = CloseMethod::try_from(m[0]) { return Ok(Some(method)); } } @@ -263,10 +272,15 @@ impl RgbExt for Psbt { fn push_rgb_transition( &mut self, mut transition: Transition, - mut methods: CloseMethodSet, + method: CloseMethod, ) -> Result { let opid = transition.id(); - let prev_methods = self.rgb_close_methods(opid)?; + + let prev_method = self.rgb_close_method(opid)?; + if Some(method) != prev_method { + return Err(RgbPsbtError::InvalidCloseMethod(opid)); + } + let prev_transition = self.rgb_transition(opid)?; if let Some(ref prev_transition) = prev_transition { transition = transition @@ -278,37 +292,34 @@ impl RgbExt for Psbt { let serialized_transition = transition .to_strict_serialized::() .map_err(|_| RgbPsbtError::TransitionTooBig(opid))?; + // Since we update transition it's ok to ignore the fact that it previously // existed let _ = self .push_proprietary(PropKey::rgb_transition(opid), serialized_transition.into_inner()); - methods |= prev_methods; - let _ = self.push_proprietary(PropKey::rgb_closing_methods(opid), vec![methods as u8]); + let _ = self.push_proprietary(PropKey::rgb_closing_methods(opid), vec![method as u8]); Ok(prev_transition.is_none()) } fn rgb_bundles_to_mpc( &mut self, - ) -> Result< - (Confined, 1, U24>, CloseMethodSet), - RgbPsbtError, - > { + ) -> Result, 1, U24>, RgbPsbtError> { let bundles = self.rgb_bundles()?; - let mut map = MediumOrdMap::new(); - let mut close_methods = None::; - for (contract_id, (bundle, methods)) in bundles { - let protocol_id = mpc::ProtocolId::from(contract_id); + for (contract_id, bundle) in bundles + .iter() + .flat_map(|(id, b)| b.iter().map(move |b| (id, b))) + { + let protocol_id = mpc::ProtocolId::from(*contract_id); let message = mpc::Message::from(bundle.bundle_id()); - if methods.has_tapret_first() { + if bundle.close_method == CloseMethod::TapretFirst { // We need to do it each time due to Rust borrow checker let tapret_host = self .outputs_mut() .find(|output| output.is_tapret_host()) .ok_or(RgbPsbtError::NoHostOutput(Method::TapretFirst))?; tapret_host.set_mpc_message(protocol_id, message)?; - } - if methods.has_opret_first() { + } else if bundle.close_method == CloseMethod::OpretFirst { // We need to do it each time due to Rust borrow checker let opret_host = self .outputs_mut() @@ -316,18 +327,11 @@ impl RgbExt for Psbt { .ok_or(RgbPsbtError::NoHostOutput(Method::OpretFirst))?; opret_host.set_mpc_message(protocol_id, message)?; } - map.insert(contract_id, bundle) - .map_err(|_| RgbPsbtError::TooManyContracts)?; - close_methods |= methods; } - let Some(close_methods) = close_methods else { - return Err(RgbPsbtError::NoContracts); - }; + let map = Confined::try_from(bundles).map_err(|_| RgbPsbtError::NoContracts)?; - let map = Confined::try_from(map.into_inner()).map_err(|_| RgbPsbtError::NoContracts)?; - - Ok((map, close_methods)) + Ok(map) } } From 1ea9a620d4a87a3753bf60796ac8df2601356924 Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Thu, 11 Apr 2024 15:28:42 +0200 Subject: [PATCH 04/20] chore: update dependencies --- Cargo.lock | 6 +++--- Cargo.toml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 61e3bf6..2abb9e4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1561,7 +1561,7 @@ dependencies = [ [[package]] name = "rgb-core" version = "0.11.0-beta.5" -source = "git+https://github.com/RGB-WG/rgb-core?branch=single-commit#9ea69c018d95fe7a3a0d991609145cabe41b9eda" +source = "git+https://github.com/RGB-WG/rgb-core?branch=v0.11#6aa78851e1d7d474590124f45e4b819b05f24a09" dependencies = [ "aluvm", "amplify", @@ -1583,7 +1583,7 @@ dependencies = [ [[package]] name = "rgb-invoice" version = "0.11.0-beta.5" -source = "git+https://github.com/RGB-WG/rgb-std?branch=single-commit#c72159cc3d407696b66b559705c9c03da295663e" +source = "git+https://github.com/RGB-WG/rgb-std?branch=v0.11#468200b74c2adfac054d6d15b08973a4af634d26" dependencies = [ "amplify", "baid58", @@ -1653,7 +1653,7 @@ dependencies = [ [[package]] name = "rgb-std" version = "0.11.0-beta.5" -source = "git+https://github.com/RGB-WG/rgb-std?branch=single-commit#c72159cc3d407696b66b559705c9c03da295663e" +source = "git+https://github.com/RGB-WG/rgb-std?branch=v0.11#468200b74c2adfac054d6d15b08973a4af634d26" dependencies = [ "amplify", "ascii-armor", diff --git a/Cargo.toml b/Cargo.toml index 2a5ae1b..ef37942 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -106,6 +106,6 @@ bp-std = { git = "https://github.com/BP-WG/bp-std", branch = "v0.11" } psbt = { git = "https://github.com/BP-WG/bp-std", branch = "v0.11" } descriptors = { git = "https://github.com/BP-WG/bp-std", branch = "v0.11" } bp-wallet = { git = "https://github.com/BP-WG/bp-wallet", branch = "v0.11" } -rgb-core = { git = "https://github.com/RGB-WG/rgb-core", branch = "single-commit" } -rgb-std = { git = "https://github.com/RGB-WG/rgb-std", branch = "single-commit" } -rgb-invoice = { git = "https://github.com/RGB-WG/rgb-std", branch = "single-commit" } +rgb-core = { git = "https://github.com/RGB-WG/rgb-core", branch = "v0.11" } +rgb-std = { git = "https://github.com/RGB-WG/rgb-std", branch = "v0.11" } +rgb-invoice = { git = "https://github.com/RGB-WG/rgb-std", branch = "v0.11" } From ac110985ee746e903b9d42a226495f5b1a657239 Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Thu, 11 Apr 2024 17:43:53 +0200 Subject: [PATCH 05/20] chore: update dependencies --- Cargo.lock | 338 +++++++++++++++++++++++++++-------------------------- Cargo.toml | 2 +- 2 files changed, 176 insertions(+), 164 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2abb9e4..5d4c900 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,9 +19,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "aho-corasick" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ "memchr", ] @@ -70,7 +70,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72e23f5ede99065fa6957a633498d2728d51016d61dae23b69c866112b7c61ee" dependencies = [ "amplify_num", - "bitflags 2.4.2", + "bitflags 2.5.0", "wasm-bindgen", ] @@ -206,15 +206,15 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" [[package]] name = "backtrace" -version = "0.3.69" +version = "0.3.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" dependencies = [ "addr2line", "cc", @@ -294,15 +294,15 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.2" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" [[package]] name = "blake3" -version = "1.5.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0231f06152bf547e9c2b5194f247cd97aacf6dcd8b15d8e5ec0663f64580da87" +checksum = "30cca6d3674597c30ddf2c587bf8d9d65c9a84d2326d941cc79c9842dfe0ef52" dependencies = [ "arrayref", "arrayvec", @@ -323,12 +323,12 @@ dependencies = [ [[package]] name = "bp-consensus" version = "0.11.0-beta.5" -source = "git+https://github.com/BP-WG/bp-core?branch=v0.11#c014bad013c99e4eb828eabc37c1c5ccc30acf75" +source = "git+https://github.com/BP-WG/bp-core?branch=v0.11#40d155151b57325ad82edf838196b52ad27af188" dependencies = [ "amplify", "chrono", "commit_verify", - "secp256k1", + "secp256k1 0.29.0", "serde", "strict_encoding", "strict_types", @@ -337,7 +337,7 @@ dependencies = [ [[package]] name = "bp-core" version = "0.11.0-beta.5" -source = "git+https://github.com/BP-WG/bp-core?branch=v0.11#c014bad013c99e4eb828eabc37c1c5ccc30acf75" +source = "git+https://github.com/BP-WG/bp-core?branch=v0.11#40d155151b57325ad82edf838196b52ad27af188" dependencies = [ "amplify", "bp-consensus", @@ -355,13 +355,13 @@ dependencies = [ [[package]] name = "bp-dbc" version = "0.11.0-beta.5" -source = "git+https://github.com/BP-WG/bp-core?branch=v0.11#c014bad013c99e4eb828eabc37c1c5ccc30acf75" +source = "git+https://github.com/BP-WG/bp-core?branch=v0.11#40d155151b57325ad82edf838196b52ad27af188" dependencies = [ "amplify", "base85", "bp-consensus", "commit_verify", - "secp256k1", + "secp256k1 0.29.0", "serde", "strict_encoding", ] @@ -369,14 +369,14 @@ dependencies = [ [[package]] name = "bp-derive" version = "0.11.0-beta.5" -source = "git+https://github.com/BP-WG/bp-std?branch=v0.11#79cee6874bf037a276b08d2ad0aa0206417bb52b" +source = "git+https://github.com/BP-WG/bp-std?branch=v0.11#5cd19126c7acbe96586573fd8d00baf2273887df" dependencies = [ "amplify", "bitcoin_hashes", "bp-consensus", "bp-invoice", "commit_verify", - "indexmap 2.2.5", + "indexmap 2.2.6", "serde", ] @@ -418,7 +418,7 @@ dependencies = [ [[package]] name = "bp-invoice" version = "0.11.0-beta.5" -source = "git+https://github.com/BP-WG/bp-std?branch=v0.11#79cee6874bf037a276b08d2ad0aa0206417bb52b" +source = "git+https://github.com/BP-WG/bp-std?branch=v0.11#5cd19126c7acbe96586573fd8d00baf2273887df" dependencies = [ "amplify", "bech32", @@ -430,7 +430,7 @@ dependencies = [ [[package]] name = "bp-seals" version = "0.11.0-beta.5" -source = "git+https://github.com/BP-WG/bp-core?branch=v0.11#c014bad013c99e4eb828eabc37c1c5ccc30acf75" +source = "git+https://github.com/BP-WG/bp-core?branch=v0.11#40d155151b57325ad82edf838196b52ad27af188" dependencies = [ "amplify", "baid58", @@ -446,7 +446,7 @@ dependencies = [ [[package]] name = "bp-std" version = "0.11.0-beta.5" -source = "git+https://github.com/BP-WG/bp-std?branch=v0.11#79cee6874bf037a276b08d2ad0aa0206417bb52b" +source = "git+https://github.com/BP-WG/bp-std?branch=v0.11#5cd19126c7acbe96586573fd8d00baf2273887df" dependencies = [ "amplify", "bp-consensus", @@ -502,9 +502,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.15.4" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ff69b9dd49fd426c69a0db9fc04dd934cdb6645ff000864d98f7e2af8830eaa" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "byteorder" @@ -514,15 +514,15 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.5.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" +checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" [[package]] name = "cc" -version = "1.0.90" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" +checksum = "2678b2e3449475e95b0aa6f9b506a28e61b3dc8996592b983695e8ebb58a8b41" [[package]] name = "cfg-if" @@ -538,14 +538,14 @@ checksum = "45565fc9416b9896014f5732ac776f810ee53a66730c17e4020c3ec064a8f88f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] name = "chrono" -version = "0.4.35" +version = "0.4.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8eaf5903dcbc0a39312feb77df2ff4c76387d591b9fc7b04a238dcf8bb62639a" +checksum = "8a0d04d43504c61aa6c7531f1871dd0d418d91130162063b789da00fd7057a5e" dependencies = [ "android-tzdata", "iana-time-zone", @@ -558,9 +558,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.2" +version = "4.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b230ab84b0ffdf890d5a10abdbc8b83ae1c4918275daea1ab8801f71536b2651" +checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0" dependencies = [ "clap_builder", "clap_derive", @@ -575,19 +575,19 @@ dependencies = [ "anstream", "anstyle", "clap_lex", - "strsim 0.11.0", + "strsim 0.11.1", ] [[package]] name = "clap_derive" -version = "4.5.0" +version = "4.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "307bc0538d5f0f83b8248db3087aa92fe504e4691294d0c96c0eabc33f47ba47" +checksum = "528131438037fd55894f62d6e9f068b8f45ac57ffa77517819645d10aed04f64" dependencies = [ - "heck", + "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -719,7 +719,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.10.0", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -730,7 +730,7 @@ checksum = "a668eda54683121533a393014d8692171709ff57a7d61f187b6e782719f8933f" dependencies = [ "darling_core", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -746,11 +746,11 @@ dependencies = [ [[package]] name = "descriptors" version = "0.11.0-beta.5" -source = "git+https://github.com/BP-WG/bp-std?branch=v0.11#79cee6874bf037a276b08d2ad0aa0206417bb52b" +source = "git+https://github.com/BP-WG/bp-std?branch=v0.11#5cd19126c7acbe96586573fd8d00baf2273887df" dependencies = [ "amplify", "bp-derive", - "indexmap 2.2.5", + "indexmap 2.2.6", "serde", ] @@ -793,9 +793,9 @@ checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" [[package]] name = "encoding_rs" -version = "0.8.33" +version = "0.8.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" +checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" dependencies = [ "cfg-if", ] @@ -831,9 +831,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.0.1" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" +checksum = "658bd65b1cf4c852a3cc96f18a8ce7b5640f6b703f905c7d74532294c2a63984" [[package]] name = "flate2" @@ -935,9 +935,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.12" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" +checksum = "94b22e06ecb0110981051723910cbf0b5f5e09a2062dd7663334ee79a9d1286c" dependencies = [ "cfg-if", "js-sys", @@ -954,9 +954,9 @@ checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" [[package]] name = "h2" -version = "0.3.24" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb2c4422095b67ee78da96fbb51a4cc413b3b25883c7717ff7ca1ab31022c9c9" +checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" dependencies = [ "bytes", "fnv", @@ -964,7 +964,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap 2.2.5", + "indexmap 2.2.6", "slab", "tokio", "tokio-util", @@ -998,6 +998,12 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + [[package]] name = "hermit-abi" version = "0.3.9" @@ -1145,9 +1151,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.5" +version = "2.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b0b929d511467233429c45a44ac1dcaa21ba0f5ba11e4879e6ed28ddb4f9df4" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", "hashbrown 0.14.3", @@ -1173,9 +1179,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "js-sys" @@ -1200,13 +1206,12 @@ checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "libredox" -version = "0.0.1" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "libc", - "redox_syscall", ] [[package]] @@ -1223,9 +1228,9 @@ checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "memchr" -version = "2.7.1" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" +checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" [[package]] name = "mime" @@ -1255,13 +1260,9 @@ dependencies = [ [[package]] name = "mnemonic" -version = "1.0.1" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29fae0e4c0b155d3b019a7cbc27abe4a90e15c06814d27889ce9f5f44e2faf77" -dependencies = [ - "byteorder", - "lazy_static", -] +checksum = "f2b8f3a258db515d5e91a904ce4ae3f73e091149b90cadbdb93d210bee07f63b" [[package]] name = "native-tls" @@ -1317,7 +1318,7 @@ version = "0.10.64" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "cfg-if", "foreign-types", "libc", @@ -1334,7 +1335,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -1345,9 +1346,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.101" +version = "0.9.102" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dda2b0f344e78efc2facf7d195d098df0dd72151b26ab98da807afc26c198dff" +checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2" dependencies = [ "cc", "libc", @@ -1375,9 +1376,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pin-project-lite" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "pin-utils" @@ -1405,9 +1406,9 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" -version = "1.0.78" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" dependencies = [ "unicode-ident", ] @@ -1415,7 +1416,7 @@ dependencies = [ [[package]] name = "psbt" version = "0.11.0-beta.5" -source = "git+https://github.com/BP-WG/bp-std?branch=v0.11#79cee6874bf037a276b08d2ad0aa0206417bb52b" +source = "git+https://github.com/BP-WG/bp-std?branch=v0.11#5cd19126c7acbe96586573fd8d00baf2273887df" dependencies = [ "amplify", "base64", @@ -1424,16 +1425,16 @@ dependencies = [ "chrono", "commit_verify", "descriptors", - "indexmap 2.2.5", + "indexmap 2.2.6", "serde", "strict_encoding", ] [[package]] name = "quote" -version = "1.0.35" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] @@ -1468,20 +1469,11 @@ dependencies = [ "getrandom", ] -[[package]] -name = "redox_syscall" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" -dependencies = [ - "bitflags 1.3.2", -] - [[package]] name = "redox_users" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4" +checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" dependencies = [ "getrandom", "libredox", @@ -1490,9 +1482,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.3" +version = "1.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" +checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" dependencies = [ "aho-corasick", "memchr", @@ -1513,15 +1505,15 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" [[package]] name = "reqwest" -version = "0.11.25" +version = "0.11.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eea5a9eb898d3783f17c6407670e3592fd174cb81a10e51d4c37f49450b9946" +checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" dependencies = [ "base64", "bytes", @@ -1561,7 +1553,7 @@ dependencies = [ [[package]] name = "rgb-core" version = "0.11.0-beta.5" -source = "git+https://github.com/RGB-WG/rgb-core?branch=v0.11#6aa78851e1d7d474590124f45e4b819b05f24a09" +source = "git+https://github.com/RGB-WG/rgb-core?branch=v0.11#967f833d261e87913f7addc7cc2cdcced611be0e" dependencies = [ "aluvm", "amplify", @@ -1583,14 +1575,14 @@ dependencies = [ [[package]] name = "rgb-invoice" version = "0.11.0-beta.5" -source = "git+https://github.com/RGB-WG/rgb-std?branch=v0.11#468200b74c2adfac054d6d15b08973a4af634d26" +source = "git+https://github.com/RGB-WG/rgb-std?branch=v0.11#f9d909a99c266d9a538fd9d981c15390bf2fbe04" dependencies = [ "amplify", "baid58", "bp-core", "bp-invoice", "fluent-uri", - "indexmap 2.2.5", + "indexmap 2.2.6", "percent-encoding", "rgb-core", "serde", @@ -1639,7 +1631,7 @@ dependencies = [ "chrono", "commit_verify", "descriptors", - "indexmap 2.2.5", + "indexmap 2.2.6", "log", "rgb-persist-fs", "rgb-psbt", @@ -1653,7 +1645,7 @@ dependencies = [ [[package]] name = "rgb-std" version = "0.11.0-beta.5" -source = "git+https://github.com/RGB-WG/rgb-std?branch=v0.11#468200b74c2adfac054d6d15b08973a4af634d26" +source = "git+https://github.com/RGB-WG/rgb-std?branch=v0.11#f9d909a99c266d9a538fd9d981c15390bf2fbe04" dependencies = [ "amplify", "ascii-armor", @@ -1663,7 +1655,7 @@ dependencies = [ "chrono", "commit_verify", "getrandom", - "indexmap 2.2.5", + "indexmap 2.2.6", "rand", "rgb-core", "rgb-invoice", @@ -1730,11 +1722,11 @@ checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" [[package]] name = "rustix" -version = "0.38.31" +version = "0.38.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" +checksum = "65e04861e65f21776e67888bfbea442b3642beaa0138fdb1dd7a84a52dffdb89" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "errno", "libc", "linux-raw-sys", @@ -1755,9 +1747,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.22.2" +version = "0.22.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e87c9956bd9807afa1f77e0f7594af32566e830e088a5576d27c5b6f30f49d41" +checksum = "99008d7ad0bbbea527ec27bddbc0e432c5b87d8175178cee68d2eec9c4a1813c" dependencies = [ "log", "ring", @@ -1778,9 +1770,9 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.3.1" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ede67b28608b4c60685c7d54122d4400d90f62b40caee7700e700380a390fa8" +checksum = "ecd36cc4259e3e4514335c4a138c6b43171a8d61d8f5c9348f9fc7529416f247" [[package]] name = "rustls-webpki" @@ -1841,7 +1833,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d24b59d129cdadea20aea4fb2352fa053712e5d713eee47d700cd4b2bc002f10" dependencies = [ "rand", - "secp256k1-sys", + "secp256k1-sys 0.9.2", + "serde", +] + +[[package]] +name = "secp256k1" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e0cc0f1cf93f4969faf3ea1c7d8a9faed25918d96affa959720823dfe86d4f3" +dependencies = [ + "rand", + "secp256k1-sys 0.10.0", "serde", ] @@ -1854,6 +1857,15 @@ dependencies = [ "cc", ] +[[package]] +name = "secp256k1-sys" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1433bd67156263443f14d603720b082dd3121779323fce20cba2aa07b874bc1b" +dependencies = [ + "cc", +] + [[package]] name = "secp256k1-zkp" version = "0.10.1" @@ -1862,7 +1874,7 @@ checksum = "c4e48ef9c98bfbcb98bd15693ffa19676cb3e29426b75eda8b73c05cdd7959f8" dependencies = [ "bitcoin-private", "rand", - "secp256k1", + "secp256k1 0.28.2", "secp256k1-zkp-sys", "serde", ] @@ -1874,14 +1886,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4ead52f43074bae2ddbd1e0e66e6b170135e76117f5ea9916f33d7bd0b36e29" dependencies = [ "cc", - "secp256k1-sys", + "secp256k1-sys 0.9.2", ] [[package]] name = "security-framework" -version = "2.9.2" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" +checksum = "770452e37cad93e0a50d5abc3990d2bc351c36d0328f86cefec2f2fb206eaef6" dependencies = [ "bitflags 1.3.2", "core-foundation", @@ -1892,9 +1904,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.9.1" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a" +checksum = "41f3cc463c0ef97e11c3461a9d3787412d30e8e7eb907c79180c4a57bf7c04ef" dependencies = [ "core-foundation-sys", "libc", @@ -1917,14 +1929,14 @@ checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] name = "serde_json" -version = "1.0.114" +version = "1.0.115" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" +checksum = "12dc5c46daa8e9fdf4f5e71b6cf9a53f2487da0e86e55808e2d35539666497dd" dependencies = [ "itoa", "ryu", @@ -1964,15 +1976,15 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.6.1" +version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15d167997bd841ec232f5b2b8e0e26606df2e7caa4c31b95ea9ca52b200bd270" +checksum = "ee80b0e361bbf88fd2f6e242ccd19cfda072cb0faa6ae694ecee08199938569a" dependencies = [ "base64", "chrono", "hex", "indexmap 1.9.3", - "indexmap 2.2.5", + "indexmap 2.2.6", "serde", "serde_derive", "serde_json", @@ -1982,23 +1994,23 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.6.1" +version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "865f9743393e638991566a8b7a479043c2c8da94a33e0a31f18214c9cae0a64d" +checksum = "6561dc161a9224638a31d876ccdfefbc1df91d3f3a8342eddb35f055d48c7655" dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] name = "serde_yaml" -version = "0.9.32" +version = "0.9.34+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fd075d994154d4a774f95b51fb96bdc2832b0ea48425c92546073816cda1f2f" +checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" dependencies = [ - "indexmap 2.2.5", + "indexmap 2.2.6", "itoa", "ryu", "serde", @@ -2089,7 +2101,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b1b064a62618a785e6d8f4df13d905dc335b56400d48f9b4f8b12dcba82b260" dependencies = [ "amplify_syn", - "heck", + "heck 0.4.1", "proc-macro2", "quote", "syn 1.0.109", @@ -2098,13 +2110,13 @@ dependencies = [ [[package]] name = "strict_types" version = "2.7.0-beta.2" -source = "git+https://github.com/strict-types/strict-types?branch=master#2350162c6a6fda6a7f74373e0a08d8e3a70c37b4" +source = "git+https://github.com/strict-types/strict-types?branch=reconstruct#fe26fa0b071cdfe7abc53262ff83c1c3999333b4" dependencies = [ "amplify", "ascii-armor", "baid58", "half", - "indexmap 2.2.5", + "indexmap 2.2.6", "serde", "serde_json", "serde_yaml", @@ -2132,9 +2144,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "strsim" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "subtle" @@ -2155,9 +2167,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.52" +version = "2.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" +checksum = "44cfb93f38070beee36b3fef7d4f5a16f27751d94b187b666a5cc5e9b0d30687" dependencies = [ "proc-macro2", "quote", @@ -2172,20 +2184,20 @@ checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" [[package]] name = "system-configuration" -version = "0.6.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "658bc6ee10a9b4fcf576e9b0819d95ec16f4d2c02d39fd83ac1c8789785c4a42" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" dependencies = [ - "bitflags 2.4.2", + "bitflags 1.3.2", "core-foundation", "system-configuration-sys", ] [[package]] name = "system-configuration-sys" -version = "0.6.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" dependencies = [ "core-foundation-sys", "libc", @@ -2214,29 +2226,29 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.57" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e45bcbe8ed29775f228095caf2cd67af7a4ccf756ebff23a306bf3e8b47b24b" +checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.57" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" +checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] name = "time" -version = "0.3.34" +version = "0.3.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8248b6521bb14bc45b4067159b9b6ad792e2d6d754d6c41fb50e29fefe38749" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ "deranged", "itoa", @@ -2255,9 +2267,9 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.17" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ba3a3ef41e6672a2f0f001392bb5dcd3ff0a9992d618ca761a11c3121547774" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" dependencies = [ "num-conv", "time-core", @@ -2280,9 +2292,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.36.0" +version = "1.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931" +checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" dependencies = [ "backtrace", "bytes", @@ -2331,9 +2343,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.11" +version = "0.8.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af06656561d28735e9c1cd63dfd57132c8155426aa6af24f36a00a351f88c48e" +checksum = "e9dd1545e8208b4a5af1aa9bbd0b4cf7e9ea08fabc5d0a5c67fcaafa17433aa3" dependencies = [ "serde", "serde_spanned", @@ -2352,11 +2364,11 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.7" +version = "0.22.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18769cd1cec395d70860ceb4d932812a0b4d06b1a4bb336745a4d21b9496e992" +checksum = "8e40bb779c5187258fd7aad0eb68cb8706a0a81fa712fbea808ab43c4b8374c4" dependencies = [ - "indexmap 2.2.5", + "indexmap 2.2.6", "serde", "serde_spanned", "toml_datetime", @@ -2423,9 +2435,9 @@ dependencies = [ [[package]] name = "unsafe-libyaml" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab4c90930b95a82d00dc9e9ac071b4991924390d46cbd0dfe566148667605e4b" +checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861" [[package]] name = "untrusted" @@ -2443,7 +2455,7 @@ dependencies = [ "flate2", "log", "once_cell", - "rustls 0.22.2", + "rustls 0.22.3", "rustls-pki-types", "rustls-webpki 0.102.2", "serde", @@ -2528,7 +2540,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", "wasm-bindgen-shared", ] @@ -2562,7 +2574,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -2595,7 +2607,7 @@ checksum = "b7f89739351a2e03cb94beb799d47fb2cac01759b40ec441f7de39b00cbf7ef0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -2797,9 +2809,9 @@ checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" [[package]] name = "winnow" -version = "0.6.5" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dffa400e67ed5a4dd237983829e66475f0a4a26938c4b04c21baede6262215b8" +checksum = "f0c976aaaa0e1f90dbb21e9587cdaf1d9679a1cde8875c0d6bd83ab96a208352" dependencies = [ "memchr", ] diff --git a/Cargo.toml b/Cargo.toml index ef37942..6435fe1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -96,7 +96,7 @@ serde = ["serde_crate", "serde_with", "serde_yaml", "bp-std/serde", "bp-wallet/s features = ["all"] [patch.crates-io] -strict_types = { git = "https://github.com/strict-types/strict-types", branch = "master" } +strict_types = { git = "https://github.com/strict-types/strict-types", branch = "reconstruct" } bp-consensus = { git = "https://github.com/BP-WG/bp-core", branch = "v0.11" } 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" } From a9f1d334b2ab45022de3792b1b0cec0f145ffbcf Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Fri, 12 Apr 2024 20:13:35 +0200 Subject: [PATCH 06/20] complete runtime update for refactored standard lib --- Cargo.lock | 101 ++++++++++++++++++++++-------------------------- Cargo.toml | 18 +++++---- fs/Cargo.toml | 27 ------------- fs/src/lib.rs | 24 ------------ fs/src/stock.rs | 41 -------------------- src/pay.rs | 36 +++++++---------- src/runtime.rs | 67 +++++++++++++++----------------- 7 files changed, 103 insertions(+), 211 deletions(-) delete mode 100644 fs/Cargo.toml delete mode 100644 fs/src/lib.rs delete mode 100644 fs/src/stock.rs diff --git a/Cargo.lock b/Cargo.lock index 5d4c900..a8ad9cc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -29,12 +29,12 @@ dependencies = [ [[package]] name = "aluvm" version = "0.11.0-beta.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2032d213fd6b80b26217efb9846b273671acff3f696ada7e0314c6af2b4c3275" +source = "git+https://github.com/AluVM/rust-aluvm?branch=v0.11#472920854cd92b65f44d7b9e299a8a3df4afa6ce" dependencies = [ "amplify", "ascii-armor", "baid58", + "blake3", "getrandom", "half", "paste", @@ -553,7 +553,7 @@ dependencies = [ "num-traits", "serde", "wasm-bindgen", - "windows-targets 0.52.4", + "windows-targets 0.52.5", ] [[package]] @@ -605,8 +605,7 @@ checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" [[package]] name = "commit_encoding_derive" version = "0.11.0-beta.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d660fdac917fb67edd1707bc9481e51ed9062ab4ba1c4e56ed7856977fff9f3" +source = "git+https://github.com/LNP-BP/client_side_validation?branch=v0.11#503e5da35642f52b090f7e232a8aeaccb05463cc" dependencies = [ "amplify", "amplify_syn", @@ -618,8 +617,7 @@ dependencies = [ [[package]] name = "commit_verify" version = "0.11.0-beta.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77b78d8453b82136eb9743a8da9a94e265146e5c48668f0e0e71859aa726fa67" +source = "git+https://github.com/LNP-BP/client_side_validation?branch=v0.11#503e5da35642f52b090f7e232a8aeaccb05463cc" dependencies = [ "amplify", "commit_encoding_derive", @@ -787,9 +785,9 @@ dependencies = [ [[package]] name = "either" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" +checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2" [[package]] name = "encoding_rs" @@ -1553,7 +1551,7 @@ dependencies = [ [[package]] name = "rgb-core" version = "0.11.0-beta.5" -source = "git+https://github.com/RGB-WG/rgb-core?branch=v0.11#967f833d261e87913f7addc7cc2cdcced611be0e" +source = "git+https://github.com/RGB-WG/rgb-core?branch=script-refactor#8392d42e0e21be8ec4ec2641a249b6682137b4a6" dependencies = [ "aluvm", "amplify", @@ -1575,7 +1573,7 @@ dependencies = [ [[package]] name = "rgb-invoice" version = "0.11.0-beta.5" -source = "git+https://github.com/RGB-WG/rgb-std?branch=v0.11#f9d909a99c266d9a538fd9d981c15390bf2fbe04" +source = "git+https://github.com/RGB-WG/rgb-std?branch=script-refactor#5159f8013b6e0896da91d514181c9c623195bf47" dependencies = [ "amplify", "baid58", @@ -1590,15 +1588,6 @@ dependencies = [ "strict_types", ] -[[package]] -name = "rgb-persist-fs" -version = "0.11.1" -dependencies = [ - "amplify", - "rgb-std", - "strict_encoding", -] - [[package]] name = "rgb-psbt" version = "0.11.0-beta.5" @@ -1633,7 +1622,6 @@ dependencies = [ "descriptors", "indexmap 2.2.6", "log", - "rgb-persist-fs", "rgb-psbt", "rgb-std", "serde", @@ -1645,8 +1633,9 @@ dependencies = [ [[package]] name = "rgb-std" version = "0.11.0-beta.5" -source = "git+https://github.com/RGB-WG/rgb-std?branch=v0.11#f9d909a99c266d9a538fd9d981c15390bf2fbe04" +source = "git+https://github.com/RGB-WG/rgb-std?branch=script-refactor#5159f8013b6e0896da91d514181c9c623195bf47" dependencies = [ + "aluvm", "amplify", "ascii-armor", "baid58", @@ -2040,8 +2029,7 @@ dependencies = [ [[package]] name = "single_use_seals" version = "0.11.0-beta.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8893da91eab5290895bb7913a786e26b2e170c568542451c12bf00cf1812035a" +source = "git+https://github.com/LNP-BP/client_side_validation?branch=v0.11#503e5da35642f52b090f7e232a8aeaccb05463cc" dependencies = [ "amplify_derive", ] @@ -2085,8 +2073,7 @@ checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" [[package]] name = "strict_encoding" version = "2.7.0-beta.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a12eaa6985afa31deacc86cdc4935a36960ae09131a1f4e1db430127ebc4f05d" +source = "git+https://github.com/strict-types/strict-encoding?branch=rstring#5e93109453243366f18defde30aa7191f7f3218e" dependencies = [ "amplify", "half", @@ -2097,8 +2084,7 @@ dependencies = [ [[package]] name = "strict_encoding_derive" version = "2.7.0-beta.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b1b064a62618a785e6d8f4df13d905dc335b56400d48f9b4f8b12dcba82b260" +source = "git+https://github.com/strict-types/strict-encoding?branch=rstring#5e93109453243366f18defde30aa7191f7f3218e" dependencies = [ "amplify_syn", "heck 0.4.1", @@ -2110,7 +2096,7 @@ dependencies = [ [[package]] name = "strict_types" version = "2.7.0-beta.2" -source = "git+https://github.com/strict-types/strict-types?branch=reconstruct#fe26fa0b071cdfe7abc53262ff83c1c3999333b4" +source = "git+https://github.com/strict-types/strict-types?branch=develop#2e6b57b7b46efe9b6db430b56ba4a83f2c7776be" dependencies = [ "amplify", "ascii-armor", @@ -2672,7 +2658,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.52.4", + "windows-targets 0.52.5", ] [[package]] @@ -2690,7 +2676,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.4", + "windows-targets 0.52.5", ] [[package]] @@ -2710,17 +2696,18 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" dependencies = [ - "windows_aarch64_gnullvm 0.52.4", - "windows_aarch64_msvc 0.52.4", - "windows_i686_gnu 0.52.4", - "windows_i686_msvc 0.52.4", - "windows_x86_64_gnu 0.52.4", - "windows_x86_64_gnullvm 0.52.4", - "windows_x86_64_msvc 0.52.4", + "windows_aarch64_gnullvm 0.52.5", + "windows_aarch64_msvc 0.52.5", + "windows_i686_gnu 0.52.5", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.5", + "windows_x86_64_gnu 0.52.5", + "windows_x86_64_gnullvm 0.52.5", + "windows_x86_64_msvc 0.52.5", ] [[package]] @@ -2731,9 +2718,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" [[package]] name = "windows_aarch64_msvc" @@ -2743,9 +2730,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" [[package]] name = "windows_i686_gnu" @@ -2755,9 +2742,15 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.4" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" [[package]] name = "windows_i686_msvc" @@ -2767,9 +2760,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" [[package]] name = "windows_x86_64_gnu" @@ -2779,9 +2772,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" [[package]] name = "windows_x86_64_gnullvm" @@ -2791,9 +2784,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" [[package]] name = "windows_x86_64_msvc" @@ -2803,9 +2796,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" [[package]] name = "winnow" diff --git a/Cargo.toml b/Cargo.toml index 6435fe1..abfd279 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,12 +2,10 @@ members = [ "psbt", "cli", - "fs", "." ] default-members = [ "psbt", - "fs", "." ] @@ -77,7 +75,6 @@ bp-esplora = { workspace = true, optional = true } descriptors = { workspace = true } rgb-std = { workspace = true } rgb-psbt = { workspace = true } -rgb-persist-fs = { version = "0.11.1", path = "fs" } indexmap = { workspace = true } chrono = { workspace = true } serde_crate = { workspace = true, optional = true } @@ -96,16 +93,21 @@ serde = ["serde_crate", "serde_with", "serde_yaml", "bp-std/serde", "bp-wallet/s features = ["all"] [patch.crates-io] -strict_types = { git = "https://github.com/strict-types/strict-types", branch = "reconstruct" } +strict_encoding_derive = { git = "https://github.com/strict-types/strict-encoding", branch = "rstring" } +strict_encoding = { git = "https://github.com/strict-types/strict-encoding", branch = "rstring" } +strict_types = { git = "https://github.com/strict-types/strict-types", branch = "develop" } +commit_verify = { git = "https://github.com/LNP-BP/client_side_validation", branch = "v0.11" } +single_use_seals = { git = "https://github.com/LNP-BP/client_side_validation", branch = "v0.11" } bp-consensus = { git = "https://github.com/BP-WG/bp-core", branch = "v0.11" } 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" } bp-invoice = { git = "https://github.com/BP-WG/bp-std", branch = "v0.11" } bp-std = { git = "https://github.com/BP-WG/bp-std", branch = "v0.11" } +bp-wallet = { git = "https://github.com/BP-WG/bp-wallet", branch = "v0.11" } psbt = { git = "https://github.com/BP-WG/bp-std", branch = "v0.11" } descriptors = { git = "https://github.com/BP-WG/bp-std", branch = "v0.11" } -bp-wallet = { git = "https://github.com/BP-WG/bp-wallet", branch = "v0.11" } -rgb-core = { git = "https://github.com/RGB-WG/rgb-core", branch = "v0.11" } -rgb-std = { git = "https://github.com/RGB-WG/rgb-std", branch = "v0.11" } -rgb-invoice = { git = "https://github.com/RGB-WG/rgb-std", branch = "v0.11" } +aluvm = { git = "https://github.com/AluVM/rust-aluvm", branch = "v0.11" } +rgb-core = { git = "https://github.com/RGB-WG/rgb-core", branch = "script-refactor" } +rgb-std = { git = "https://github.com/RGB-WG/rgb-std", branch = "script-refactor" } +rgb-invoice = { git = "https://github.com/RGB-WG/rgb-std", branch = "script-refactor" } diff --git a/fs/Cargo.toml b/fs/Cargo.toml deleted file mode 100644 index c438a96..0000000 --- a/fs/Cargo.toml +++ /dev/null @@ -1,27 +0,0 @@ -[package] -name = "rgb-persist-fs" -version = "0.11.1" -description = "RGB persistence drivers for file storage" -keywords = ["bitcoin", "lightning", "rgb", "smart-contracts", "lnp-bp"] -categories = ["cryptography::cryptocurrencies"] -authors = { workspace = true } -repository = { workspace = true } -homepage = { workspace = true } -edition = { workspace = true } -license = { workspace = true } -rust-version = { workspace = true } -readme = "../README.md" - -[lib] -name = "rgbfs" - -[dependencies] -amplify = { workspace = true } -strict_encoding = { workspace = true } -rgb-std = { workspace = true } - -[features] -default = [] - -[package.metadata.docs.rs] -features = ["all"] diff --git a/fs/src/lib.rs b/fs/src/lib.rs deleted file mode 100644 index 35014c4..0000000 --- a/fs/src/lib.rs +++ /dev/null @@ -1,24 +0,0 @@ -// RGB smart contracts for Bitcoin & Lightning -// -// SPDX-License-Identifier: Apache-2.0 -// -// Written in 2019-2023 by -// Dr Maxim Orlovsky -// -// Copyright (C) 2019-2023 LNP/BP Standards Association. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -mod stock; - -pub use stock::StockFs; diff --git a/fs/src/stock.rs b/fs/src/stock.rs deleted file mode 100644 index 46416e1..0000000 --- a/fs/src/stock.rs +++ /dev/null @@ -1,41 +0,0 @@ -// RGB smart contracts for Bitcoin & Lightning -// -// SPDX-License-Identifier: Apache-2.0 -// -// Written in 2019-2023 by -// Dr Maxim Orlovsky -// -// Copyright (C) 2019-2023 LNP/BP Standards Association. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use std::path::Path; - -use amplify::confinement::U32; -use rgbstd::persistence::Stock; -use strict_encoding::{DeserializeError, SerializeError, StrictDeserialize, StrictSerialize}; - -pub trait StockFs: Sized { - fn load(path: impl AsRef) -> Result; - fn store(&self, path: impl AsRef) -> Result<(), SerializeError>; -} - -impl StockFs for Stock { - fn load(file: impl AsRef) -> Result { - Stock::strict_deserialize_from_file::(file) - } - - fn store(&self, file: impl AsRef) -> Result<(), SerializeError> { - self.strict_serialize_to_file::(file) - } -} diff --git a/src/pay.rs b/src/pay.rs index e6bc2ca..4d955b6 100644 --- a/src/pay.rs +++ b/src/pay.rs @@ -20,7 +20,6 @@ // limitations under the License. use std::collections::{BTreeMap, BTreeSet}; -use std::convert::Infallible; use bp::dbc::tapret::TapretProof; use bp::seals::txout::{CloseMethod, ExplicitSeal}; @@ -32,7 +31,8 @@ use rgbstd::containers::Transfer; use rgbstd::interface::ContractError; use rgbstd::invoice::{Amount, Beneficiary, InvoiceState, RgbInvoice}; use rgbstd::persistence::{ - ComposeError, ConsignerError, Inventory, InventoryError, Stash, StashError, + ComposeError, ConsignError, ContractIfaceError, FasciaError, StockError, StockErrorAll, + StockErrorMem, }; use rgbstd::XChain; @@ -92,19 +92,14 @@ pub enum CompositionError { #[from] #[display(inner)] - Inventory(InventoryError), - - #[from] - #[display(inner)] - Stash(StashError), - - #[from] - #[display(inner)] - Compose(ComposeError), + Embed(EmbedError), #[from] + #[from(StockError)] + #[from(StockErrorMem)] + #[from(StockErrorMem)] #[display(inner)] - Embed(EmbedError), + Stock(StockErrorAll), } #[derive(Debug, Display, Error, From)] @@ -129,15 +124,12 @@ pub enum CompletionError { #[from] #[display(inner)] - Inventory(InventoryError), - - #[from] - #[display(inner)] - Consigner(ConsignerError), + Commit(CommitError), - #[from] + #[from(StockErrorMem)] + #[from(StockErrorMem)] #[display(inner)] - Commit(CommitError), + Stock(StockErrorAll), } #[derive(Clone, PartialEq, Debug)] @@ -179,8 +171,8 @@ impl Runtime { let contract_id = invoice.contract.ok_or(CompositionError::NoContract)?; let iface_name = invoice.iface.clone().ok_or(CompositionError::NoIface)?; - let iface = self.stock().iface_by_name(&iface_name)?; - let contract = self.contract_iface_named(contract_id, iface_name)?; + let iface = self.stock().iface(iface_name.clone())?; + let contract = self.contract_iface(contract_id, iface_name)?; let operation = invoice .operation .as_ref() @@ -340,7 +332,7 @@ impl Runtime { Beneficiary::BlindedSeal(seal) => (vec![XChain::Bitcoin(seal)], vec![]), }; - self.stock_mut().consume(fascia)?; + self.stock_mut().consume_fascia(fascia)?; let transfer = self .stock() .transfer(contract_id, beneficiary2, beneficiary1)?; diff --git a/src/runtime.rs b/src/runtime.rs index 61f814c..e13ca07 100644 --- a/src/runtime.rs +++ b/src/runtime.rs @@ -31,19 +31,15 @@ use std::path::PathBuf; use amplify::IoError; use bpstd::{Network, XpubDerivable}; use bpwallet::Wallet; -use rgbfs::StockFs; -use rgbstd::containers::{Contract, LoadError, Transfer}; +use rgbstd::containers::{Contract, LoadError, Transfer, ValidConsignment}; use rgbstd::interface::{ - AmountChange, BuilderError, ContractError, IfaceOp, OutpointFilter, WitnessFilter, - WrongImplementation, -}; -use rgbstd::persistence::{ - Inventory, InventoryDataError, InventoryError, Stash, StashError, Stock, + AmountChange, BuilderError, ContractError, IfaceOp, IfaceRef, OutpointFilter, WitnessFilter, }; +use rgbstd::persistence::{ContractIfaceError, Stock, StockError, StockErrorAll, StockErrorMem}; use rgbstd::resolvers::ResolveHeight; use rgbstd::validation::{self, ResolveWitness}; use rgbstd::{AssignmentWitness, ContractId, XChain, XOutpoint, XWitnessId}; -use strict_types::encoding::{DecodeError, DeserializeError, Ident, SerializeError, TypeName}; +use strict_types::encoding::{DecodeError, DeserializeError, Ident, SerializeError}; use crate::{DescriptorRgb, RgbDescr}; @@ -64,14 +60,6 @@ pub enum RuntimeError { Load(LoadError), #[from] - Stash(StashError), - - #[from] - #[from(InventoryDataError)] - Inventory(InventoryError), - - #[from] - #[from(WrongImplementation)] Builder(BuilderError), #[from] @@ -111,6 +99,12 @@ pub enum RuntimeError { #[display(doc_comments)] ResolverError(crate::AnyResolverError), + #[from] + #[from(StockError)] + #[from(StockErrorMem)] + #[display(inner)] + Stock(StockErrorAll), + #[from] Yaml(serde_yaml::Error), @@ -171,7 +165,7 @@ impl<'runtime, D: DescriptorRgb, K> OutpointFilter for ContractOutpointsFilte if !self.filter.include_outpoint(output) { return false; } - matches!(self.filter.stock.state_for_outpoints(self.contract_id, [output]), Ok(list) if !list.is_empty()) + matches!(self.filter.stock.contract_state_for_outpoints(self.contract_id, [output]), Ok(list) if !list.is_empty()) } } @@ -224,7 +218,7 @@ impl, K> Runtime { pub fn network(&self) -> Network { self.bprt.network() } - pub fn import_contract( + pub fn import_contract( &mut self, contract: Contract, resolver: &mut R, @@ -232,44 +226,47 @@ impl, K> Runtime { where R::Error: 'static, { - self.stock - .import_contract(contract, resolver) - .map_err(RuntimeError::from) + let valid = contract + .validate(resolver, self.network().is_testnet()) + .map_err(|(status, _)| status)?; + let status = self.stock.consume_consignment(valid, resolver)?; + Ok(status) } pub fn validate_transfer( &mut self, transfer: Transfer, resolver: &mut impl ResolveWitness, - ) -> Result { - transfer - .validate(resolver, self.network().is_testnet()) - .map_err(|invalid| invalid.validation_status().expect("just validated").clone()) - .map_err(RuntimeError::from) + ) -> Result, RuntimeError> { + match transfer.validate(resolver, self.network().is_testnet()) { + Ok(valid) => return Ok(valid), + Err((status, _)) => return Err(status.into()), + } } - pub fn accept_transfer( + pub fn accept_transfer( &mut self, transfer: Transfer, resolver: &mut R, - force: bool, ) -> Result where R::Error: 'static, { - self.stock - .accept_transfer(transfer, resolver, force) - .map_err(RuntimeError::from) + let valid = transfer + .validate(resolver, self.network().is_testnet()) + .map_err(|(status, _)| status)?; + let status = self.stock.consume_consignment(valid, resolver)?; + Ok(status) } // TODO: Integrate into BP Wallet `TxRow` as L2 and provide transactional info pub fn fungible_history( &self, contract_id: ContractId, - iface_name: impl Into, + iface: impl Into, ) -> Result>, RuntimeError> { - let iface_name = iface_name.into(); - let iface = self.stock.iface_by_name(&iface_name)?; + let iref = iface.into(); + let iface = self.stock.iface(iref.clone())?; let default_op = iface .default_operation .as_ref() @@ -282,7 +279,7 @@ impl, K> Runtime { .as_ref() .ok_or(HistoryError::NoDefaultAssignment)? .clone(); - let contract = self.stock.contract_iface_named(contract_id, iface_name)?; + let contract = self.stock.contract_iface(contract_id, iref)?; contract .fungible_ops::(state_name, self, self) .map_err(RuntimeError::from) From 32bc276b7b0f22e5e730ec2bb7ade1aedc303d1b Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Sat, 13 Apr 2024 18:22:59 +0200 Subject: [PATCH 07/20] cli: update for refactored standard lib --- Cargo.lock | 8 +- cli/src/command.rs | 227 ++++++++++++++++++--------------------------- src/runtime.rs | 14 +-- 3 files changed, 98 insertions(+), 151 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a8ad9cc..fb6d585 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -520,9 +520,9 @@ checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" [[package]] name = "cc" -version = "1.0.92" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2678b2e3449475e95b0aa6f9b506a28e61b3dc8996592b983695e8ebb58a8b41" +checksum = "17f6e324229dc011159fcc089755d1e2e216a90d43a7dea6853ca740b84f35e7" [[package]] name = "cfg-if" @@ -1573,7 +1573,7 @@ dependencies = [ [[package]] name = "rgb-invoice" version = "0.11.0-beta.5" -source = "git+https://github.com/RGB-WG/rgb-std?branch=script-refactor#5159f8013b6e0896da91d514181c9c623195bf47" +source = "git+https://github.com/RGB-WG/rgb-std?branch=script-refactor#8904684d9d91230a14288908ca34db30c0d667a1" dependencies = [ "amplify", "baid58", @@ -1633,7 +1633,7 @@ dependencies = [ [[package]] name = "rgb-std" version = "0.11.0-beta.5" -source = "git+https://github.com/RGB-WG/rgb-std?branch=script-refactor#5159f8013b6e0896da91d514181c9c623195bf47" +source = "git+https://github.com/RGB-WG/rgb-std?branch=script-refactor#8904684d9d91230a14288908ca34db30c0d667a1" dependencies = [ "aluvm", "amplify", diff --git a/cli/src/command.rs b/cli/src/command.rs index 1565e1b..be9041c 100644 --- a/cli/src/command.rs +++ b/cli/src/command.rs @@ -35,11 +35,9 @@ use rgbstd::containers::{ UniversalFile, }; use rgbstd::contract::{ContractId, GenesisSeal, GraphSeal, StateType}; -use rgbstd::interface::{ - AmountChange, ContractBuilder, ContractSuppl, FilterExclude, IfaceId, SchemaIfaces, -}; +use rgbstd::interface::{AmountChange, ContractSuppl, FilterExclude, IfaceId}; use rgbstd::invoice::{Beneficiary, RgbInvoice, RgbInvoiceBuilder, XChainNet}; -use rgbstd::persistence::{Inventory, Stash}; +use rgbstd::persistence::{SchemaIfaces, StashReadProvider}; use rgbstd::schema::SchemaId; use rgbstd::validation::Validity; use rgbstd::vm::RgbIsa; @@ -309,17 +307,17 @@ impl Exec for RgbArgs { } Command::Debug(DebugCommand::Taprets) => { let runtime = self.rgb_runtime(&config)?; - for (witness_id, tapret) in runtime.taprets()? { + for (witness_id, tapret) in runtime.as_stash_provider().taprets()? { println!("{witness_id}\t{tapret}"); } None } Command::Schemata => { let runtime = self.rgb_runtime(&config)?; - for id in runtime.schema_ids()? { - print!("{id} "); - for iimpl in runtime.schema(id)?.iimpls.values() { - let iface = runtime.iface_by_id(iimpl.iface_id)?; + for schema_iface in runtime.schemata()? { + print!("{} ", schema_iface.schema.schema_id()); + for iimpl in schema_iface.iimpls.values() { + let iface = runtime.iface(iimpl.iface_id)?; print!("{} ", iface.name); } println!(); @@ -386,35 +384,13 @@ impl Exec for RgbArgs { } else { let content = UniversalFile::load_file(file)?; match content { - UniversalFile::Iface(iface) => { - let id = iface.iface_id(); - let name = iface.name.clone(); - runtime.import_iface(iface)?; - eprintln!("Interface {id} with name {name} imported to the stash"); - } - UniversalFile::Schema(schema) => { - let id = schema.schema_id(); - runtime.import_schema(schema)?; - eprintln!("Schema {id} imported to the stash"); - } - UniversalFile::Impl(iimpl) => { - let iface_id = iimpl.iface_id; - let schema_id = iimpl.schema_id; - let id = iimpl.impl_id(); - runtime.import_iface_impl(iimpl)?; - eprintln!( - "Implementation {id} of interface {iface_id} for schema \ - {schema_id} imported to the stash" - ); - } + UniversalFile::Kit(_) => todo!(), UniversalFile::Contract(contract) => { let mut resolver = self.resolver()?; let id = contract.consignment_id(); let contract = contract .validate(&mut resolver, self.general.network.is_testnet()) - .map_err(|c| { - c.validation_status().expect("just validated").to_string() - })?; + .map_err(|(status, _)| status.to_string())?; runtime.import_contract(contract, &mut resolver)?; eprintln!("Contract {id} imported to the stash"); } @@ -423,9 +399,6 @@ impl Exec for RgbArgs { transfer consignments") .into()); } - UniversalFile::Suppl(_suppl) => { - todo!() - } }; } Some(runtime) @@ -436,15 +409,15 @@ impl Exec for RgbArgs { file, } => { let runtime = self.rgb_runtime(&config)?; - let bindle = runtime + let contract = runtime .export_contract(*contract) .map_err(|err| err.to_string())?; if let Some(file) = file { // TODO: handle armored flag - bindle.save_file(file)?; + contract.save_file(file)?; eprintln!("Contract {contract} exported to '{}'", file.display()); } else { - println!("{bindle}"); + println!("{contract}"); } None } @@ -462,8 +435,8 @@ impl Exec for RgbArgs { } => { let runtime = self.rgb_runtime(&config)?; - let iface = runtime.iface_by_name(&tn!(iface.to_owned()))?.clone(); - let contract = runtime.contract_iface_id(*contract_id, iface.iface_id())?; + let iface = runtime.iface(tn!(iface.to_owned()))?.clone(); + let contract = runtime.contract_iface(*contract_id, iface.iface_id())?; println!("Global:"); for global in &contract.iface.global_state { @@ -501,7 +474,10 @@ impl Exec for RgbArgs { } None } - Command::Issue { schema, contract } => { + Command::Issue { + schema: schema_id, + contract, + } => { let mut runtime = self.rgb_runtime(&config)?; let file = fs::File::open(contract)?; @@ -520,13 +496,13 @@ impl Exec for RgbArgs { let SchemaIfaces { ref schema, ref iimpls, - } = runtime.schema(*schema)?; + } = runtime.schema(*schema_id)?; let iface_name = tn!(iface_name.to_owned()); let iface = runtime - .iface_by_name(&iface_name) + .iface(iface_name.clone()) .or_else(|_| { let id = IfaceId::from_str(iface_name.as_str())?; - runtime.iface_by_id(id).map_err(RuntimeError::from) + runtime.iface(id).map_err(RuntimeError::from) })? .clone(); let iface_id = iface.iface_id(); @@ -535,14 +511,9 @@ impl Exec for RgbArgs { "no known interface implementation for {iface_name}" )) })?; - let types = &schema.types; - let mut builder = ContractBuilder::with( - iface.clone(), - schema.clone(), - iface_impl.clone(), - self.general.network.is_testnet(), - )?; + let mut builder = runtime.contract_builder(*schema_id, iface_id)?; + let types = builder.type_system().clone(); if let Some(globals) = code.get("globals") { for (name, val) in globals @@ -630,21 +601,10 @@ impl Exec for RgbArgs { } } - let contract = builder.issue_contract().expect("failure issuing contract"); + let contract = builder.issue_contract()?; let id = contract.contract_id(); let mut resolver = self.resolver()?; - let validated_contract = contract - .validate(&mut resolver, self.general.network.is_testnet()) - .map_err(|consignment| { - RuntimeError::IncompleteContract( - consignment - .into_validation_status() - .expect("just validated"), - ) - })?; - runtime - .import_contract(validated_contract, &mut resolver) - .expect("failure importing issued contract"); + runtime.import_contract(contract, &mut resolver)?; eprintln!( "A new contract {id} is issued and added to the stash.\nUse `export` command \ to export the contract." @@ -688,7 +648,7 @@ impl Exec for RgbArgs { outpoint.txid, outpoint.vout, )); - runtime.store_seal_secret(seal)?; + runtime.store_secret_seal(seal)?; Beneficiary::BlindedSeal(*seal.to_secret_seal().as_reduced_unsafe()) } }; @@ -790,7 +750,7 @@ impl Exec for RgbArgs { } let content = UniversalFile::load_file(file)?; - let contract = match content { + let consignment = match content { UniversalFile::Contract(contract) if *dir => Some(contract), UniversalFile::Transfer(transfer) if *dir => Some(transfer.into_contract()), content => { @@ -802,44 +762,37 @@ impl Exec for RgbArgs { None } }; - if let Some(contract) = contract { + if let Some(consignment) = consignment { let mut map = map![ - s!("genesis.yaml") => serde_yaml::to_string(&contract.genesis)?, - s!("schema.yaml") => serde_yaml::to_string(&contract.schema)?, - s!("bundles.yaml") => serde_yaml::to_string(&contract.bundles)?, - s!("extensions.yaml") => serde_yaml::to_string(&contract.extensions)?, - s!("schema-types.sty") => contract.schema.types.to_string(), + s!("genesis.yaml") => serde_yaml::to_string(&consignment.genesis)?, + s!("schema.yaml") => serde_yaml::to_string(&consignment.schema)?, + s!("bundles.yaml") => serde_yaml::to_string(&consignment.bundles)?, + s!("extensions.yaml") => serde_yaml::to_string(&consignment.extensions)?, + s!("types.sty") => consignment.types.to_string(), ]; - for (id, lib) in &contract.schema.script.as_alu_script().libs { + for lib in consignment.scripts { let mut buf = Vec::new(); lib.print_disassemble::(&mut buf)?; - map.insert(format!("{}.aluasm", id.to_baid58().mnemonic()), unsafe { + map.insert(format!("{}.aluasm", lib.id().to_baid58().mnemonic()), unsafe { String::from_utf8_unchecked(buf) }); } - for (_, pair) in contract.ifaces { + for (iface, iimpl) in consignment.ifaces { map.insert( - format!("iface-{}.yaml", pair.iface.name), - serde_yaml::to_string(&pair)?, + format!("iface-{}.yaml", iface.name), + serde_yaml::to_string(&iface)?, ); map.insert( - format!("iface-{}.sty", pair.iface.name), - pair.iface.types.to_string(), + format!("impl-{}.yaml", iface.name), + serde_yaml::to_string(&iimpl)?, ); - for (id, lib) in &pair.iimpl.script.as_alu_script().libs { - let mut buf = Vec::new(); - lib.print_disassemble::(&mut buf)?; - map.insert(format!("{}.aluasm", id.to_baid58().mnemonic()), unsafe { - String::from_utf8_unchecked(buf) - }); - } } let contract = ConsignmentInspection { - version: contract.version, - transfer: contract.transfer, - terminals: contract.terminals, - supplements: contract.supplements, - signatures: contract.signatures, + version: consignment.version, + transfer: consignment.transfer, + terminals: consignment.terminals, + supplements: consignment.supplements, + signatures: consignment.signatures, }; map.insert(s!("consignment-meta.yaml"), serde_yaml::to_string(&contract)?); let path = path.as_ref().expect("required by clap"); @@ -889,67 +842,69 @@ impl Exec for RgbArgs { fs::create_dir_all(format!("{root_dir}/stash/geneses"))?; fs::create_dir_all(format!("{root_dir}/stash/bundles"))?; fs::create_dir_all(format!("{root_dir}/stash/witnesses"))?; - fs::create_dir_all(format!("{root_dir}/stash/anchors"))?; fs::create_dir_all(format!("{root_dir}/stash/extensions"))?; fs::create_dir_all(format!("{root_dir}/state"))?; fs::create_dir_all(format!("{root_dir}/index"))?; // Stash - for id in runtime.schema_ids()? { + for schema_ifaces in runtime.schemata()? { fs::write( - format!("{root_dir}/stash/schemata/{id}.yaml"), - serde_yaml::to_string(runtime.schema(id)?)?, + format!( + "{root_dir}/stash/schemata/{}.yaml", + schema_ifaces.schema.schema_id() + ), + serde_yaml::to_string(&schema_ifaces)?, )?; } for (id, name) in runtime.ifaces()? { fs::write( format!("{root_dir}/stash/ifaces/{id}.{name}.yaml"), - serde_yaml::to_string(runtime.iface_by_id(id)?)?, + serde_yaml::to_string(runtime.iface(id)?)?, )?; } - for id in runtime.contract_ids()? { + for (id, genesis) in runtime.as_stash_provider().debug_geneses() { fs::write( format!("{root_dir}/stash/geneses/{id}.yaml"), - serde_yaml::to_string(runtime.genesis(id)?)?, + serde_yaml::to_string(genesis)?, )?; - for (no, suppl) in runtime - .contract_suppl_all(id) - .into_iter() - .flatten() - .enumerate() - { + } + for (id, list) in runtime.as_stash_provider().debug_suppl() { + for suppl in list { fs::write( - format!("{root_dir}/stash/geneses/{id}.suppl.{no:03}.yaml"), + format!( + "{root_dir}/stash/geneses/{id}.suppl.{}.yaml", + suppl.suppl_id() + ), serde_yaml::to_string(suppl)?, )?; } } - for id in runtime.bundle_ids()? { + for (id, bundle) in runtime.as_stash_provider().debug_bundles() { fs::write( format!("{root_dir}/stash/bundles/{id}.yaml"), - serde_yaml::to_string(runtime.bundle(id)?)?, - )?; - fs::write( - format!("{root_dir}/stash/witnesses/{id}.yaml"), - serde_yaml::to_string(&runtime.bundled_witness(id)?.pub_witness)?, + serde_yaml::to_string(bundle)?, )?; } - for id in runtime.witness_ids()? { + for (id, witness) in runtime.as_stash_provider().debug_witnesses() { fs::write( - format!("{root_dir}/stash/anchors/{id}.yaml"), - serde_yaml::to_string(&runtime.anchors(id)?)?, + format!("{root_dir}/stash/witnesses/{id}.yaml"), + serde_yaml::to_string(witness)?, )?; } - for id in runtime.extension_ids()? { + for (id, extension) in runtime.as_stash_provider().debug_extensions() { fs::write( format!("{root_dir}/stash/extensions/{id}.yaml"), - serde_yaml::to_string(runtime.extension(id)?)?, + serde_yaml::to_string(extension)?, )?; } + fs::write( + format!("{root_dir}/seal-secret.yaml"), + serde_yaml::to_string(runtime.as_stash_provider().debug_secret_seals())?, + )?; // TODO: Add sigs debugging // State - for (id, history) in runtime.debug_history() { + for (id, history) in runtime.as_state_provider().debug_history() { fs::write( format!("{root_dir}/state/{id}.yaml"), serde_yaml::to_string(history)?, @@ -959,27 +914,27 @@ impl Exec for RgbArgs { // Index fs::write( format!("{root_dir}/index/op-to-bundle.yaml"), - serde_yaml::to_string(runtime.debug_op_bundle_index())?, + serde_yaml::to_string(runtime.as_index_provider().debug_op_bundle_index())?, )?; fs::write( format!("{root_dir}/index/bundle-to-contract.yaml"), - serde_yaml::to_string(runtime.debug_bundle_contract_index())?, + serde_yaml::to_string( + runtime.as_index_provider().debug_bundle_contract_index(), + )?, )?; fs::write( format!("{root_dir}/index/bundle-to-witness.yaml"), - serde_yaml::to_string(runtime.debug_bundle_witness_index())?, + serde_yaml::to_string( + runtime.as_index_provider().debug_bundle_witness_index(), + )?, )?; fs::write( format!("{root_dir}/index/contracts.yaml"), - serde_yaml::to_string(runtime.debug_contract_index())?, + serde_yaml::to_string(runtime.as_index_provider().debug_contract_index())?, )?; fs::write( format!("{root_dir}/index/terminals.yaml"), - serde_yaml::to_string(runtime.debug_terminal_index())?, - )?; - fs::write( - format!("{root_dir}/seal-secret.yaml"), - serde_yaml::to_string(runtime.debug_seal_secrets())?, + serde_yaml::to_string(runtime.as_index_provider().debug_terminal_index())?, )?; eprintln!("Dump is successfully generated and saved to '{root_dir}'"); None @@ -991,9 +946,8 @@ impl Exec for RgbArgs { let status = match consignment.validate(&mut resolver, self.general.network.is_testnet()) { Ok(consignment) => consignment.into_validation_status(), - Err(consignment) => consignment.into_validation_status(), - } - .expect("just validated"); + Err((status, _)) => status, + }; if status.validity() == Validity::Valid { eprintln!("The provided consignment is valid") } else { @@ -1001,16 +955,13 @@ impl Exec for RgbArgs { } None } - Command::Accept { force, file } => { + Command::Accept { force: _, file } => { + // TODO: Ensure we properly handle unmined terminal transactions let mut runtime = self.rgb_runtime(&config)?; let mut resolver = self.resolver()?; - let consignment = Transfer::load_file(file)?; - resolver.add_terminals(&consignment); - let transfer = consignment - .validate(&mut resolver, self.general.network.is_testnet()) - .unwrap_or_else(|c| c); - eprintln!("{}", transfer.validation_status().expect("just validated")); - runtime.accept_transfer(transfer, &mut resolver, *force)?; + let transfer = Transfer::load_file(file)?; + resolver.add_terminals(&transfer); + runtime.accept_transfer(transfer, &mut resolver)?; eprintln!("Transfer accepted into the stash"); Some(runtime) } diff --git a/src/runtime.rs b/src/runtime.rs index e13ca07..26d043e 100644 --- a/src/runtime.rs +++ b/src/runtime.rs @@ -31,10 +31,11 @@ use std::path::PathBuf; use amplify::IoError; use bpstd::{Network, XpubDerivable}; use bpwallet::Wallet; -use rgbstd::containers::{Contract, LoadError, Transfer, ValidConsignment}; +use rgbstd::containers::{LoadError, Transfer, ValidConsignment}; use rgbstd::interface::{ AmountChange, BuilderError, ContractError, IfaceOp, IfaceRef, OutpointFilter, WitnessFilter, }; +use rgbstd::persistence::fs::{LoadFs, StoreFs}; use rgbstd::persistence::{ContractIfaceError, Stock, StockError, StockErrorAll, StockErrorMem}; use rgbstd::resolvers::ResolveHeight; use rgbstd::validation::{self, ResolveWitness}; @@ -176,11 +177,9 @@ where for<'de> bpwallet::WalletDescr: serde::Serialize + serde::Deserialize<'de>, { pub fn load_attach( - mut stock_path: PathBuf, + stock_path: PathBuf, bprt: bpwallet::Runtime, ) -> Result { - stock_path.push("stock.dat"); - let stock = Stock::load(&stock_path).or_else(|err| { if matches!(err, DeserializeError::Decode(DecodeError::Io(ref err)) if err.kind() == ErrorKind::NotFound) { #[cfg(feature = "log")] @@ -220,16 +219,13 @@ impl, K> Runtime { pub fn import_contract( &mut self, - contract: Contract, + contract: ValidConsignment, resolver: &mut R, ) -> Result where R::Error: 'static, { - let valid = contract - .validate(resolver, self.network().is_testnet()) - .map_err(|(status, _)| status)?; - let status = self.stock.consume_consignment(valid, resolver)?; + let status = self.stock.consume_consignment(contract, resolver)?; Ok(status) } From b7f3375f03d1407b7cd2044b2c30266c21b4a7b1 Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Sun, 14 Apr 2024 00:53:21 +0200 Subject: [PATCH 08/20] runtime: fix consignment import names --- Cargo.lock | 4 ++-- src/runtime.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fb6d585..08b0641 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1573,7 +1573,7 @@ dependencies = [ [[package]] name = "rgb-invoice" version = "0.11.0-beta.5" -source = "git+https://github.com/RGB-WG/rgb-std?branch=script-refactor#8904684d9d91230a14288908ca34db30c0d667a1" +source = "git+https://github.com/RGB-WG/rgb-std?branch=script-refactor#7b0acfde419a27196cf26f317d816ece1071b41d" dependencies = [ "amplify", "baid58", @@ -1633,7 +1633,7 @@ dependencies = [ [[package]] name = "rgb-std" version = "0.11.0-beta.5" -source = "git+https://github.com/RGB-WG/rgb-std?branch=script-refactor#8904684d9d91230a14288908ca34db30c0d667a1" +source = "git+https://github.com/RGB-WG/rgb-std?branch=script-refactor#7b0acfde419a27196cf26f317d816ece1071b41d" dependencies = [ "aluvm", "amplify", diff --git a/src/runtime.rs b/src/runtime.rs index 26d043e..8dc0dc0 100644 --- a/src/runtime.rs +++ b/src/runtime.rs @@ -225,7 +225,7 @@ impl, K> Runtime { where R::Error: 'static, { - let status = self.stock.consume_consignment(contract, resolver)?; + let status = self.stock.import_contract(contract, resolver)?; Ok(status) } @@ -251,7 +251,7 @@ impl, K> Runtime { let valid = transfer .validate(resolver, self.network().is_testnet()) .map_err(|(status, _)| status)?; - let status = self.stock.consume_consignment(valid, resolver)?; + let status = self.stock.accept_transfer(valid, resolver)?; Ok(status) } From 0f35bc5d01cc4b193793c0694cb765dd250e0ce0 Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Sun, 14 Apr 2024 03:09:24 +0200 Subject: [PATCH 09/20] cli: support kit import --- Cargo.lock | 12 ++++++------ cli/src/command.rs | 37 +++++++++++++++++++++++++++++++++++-- 2 files changed, 41 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 08b0641..6cb2458 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -29,7 +29,7 @@ dependencies = [ [[package]] name = "aluvm" version = "0.11.0-beta.5" -source = "git+https://github.com/AluVM/rust-aluvm?branch=v0.11#472920854cd92b65f44d7b9e299a8a3df4afa6ce" +source = "git+https://github.com/AluVM/rust-aluvm?branch=v0.11#a08387f744f6679b6ee308e70f99099c318824db" dependencies = [ "amplify", "ascii-armor", @@ -1551,7 +1551,7 @@ dependencies = [ [[package]] name = "rgb-core" version = "0.11.0-beta.5" -source = "git+https://github.com/RGB-WG/rgb-core?branch=script-refactor#8392d42e0e21be8ec4ec2641a249b6682137b4a6" +source = "git+https://github.com/RGB-WG/rgb-core?branch=script-refactor#e0b0181b019ed5c59e4bf4dcf77402358a57fcb1" dependencies = [ "aluvm", "amplify", @@ -1573,7 +1573,7 @@ dependencies = [ [[package]] name = "rgb-invoice" version = "0.11.0-beta.5" -source = "git+https://github.com/RGB-WG/rgb-std?branch=script-refactor#7b0acfde419a27196cf26f317d816ece1071b41d" +source = "git+https://github.com/RGB-WG/rgb-std?branch=script-refactor#f95c39f5a74717e486bf6f8b82f25e5f4c088c26" dependencies = [ "amplify", "baid58", @@ -1633,7 +1633,7 @@ dependencies = [ [[package]] name = "rgb-std" version = "0.11.0-beta.5" -source = "git+https://github.com/RGB-WG/rgb-std?branch=script-refactor#7b0acfde419a27196cf26f317d816ece1071b41d" +source = "git+https://github.com/RGB-WG/rgb-std?branch=script-refactor#f95c39f5a74717e486bf6f8b82f25e5f4c088c26" dependencies = [ "aluvm", "amplify", @@ -2073,7 +2073,7 @@ checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" [[package]] name = "strict_encoding" version = "2.7.0-beta.1" -source = "git+https://github.com/strict-types/strict-encoding?branch=rstring#5e93109453243366f18defde30aa7191f7f3218e" +source = "git+https://github.com/strict-types/strict-encoding?branch=rstring#561f0070344f4f2c2f5fcb062b4e2e62d3ab12dd" dependencies = [ "amplify", "half", @@ -2084,7 +2084,7 @@ dependencies = [ [[package]] name = "strict_encoding_derive" version = "2.7.0-beta.1" -source = "git+https://github.com/strict-types/strict-encoding?branch=rstring#5e93109453243366f18defde30aa7191f7f3218e" +source = "git+https://github.com/strict-types/strict-encoding?branch=rstring#561f0070344f4f2c2f5fcb062b4e2e62d3ab12dd" dependencies = [ "amplify_syn", "heck 0.4.1", diff --git a/cli/src/command.rs b/cli/src/command.rs index be9041c..0ae1a83 100644 --- a/cli/src/command.rs +++ b/cli/src/command.rs @@ -384,7 +384,40 @@ impl Exec for RgbArgs { } else { let content = UniversalFile::load_file(file)?; match content { - UniversalFile::Kit(_) => todo!(), + UniversalFile::Kit(kit) => { + let id = kit.kit_id(); + eprintln!("Importing kit {id}"); + let mut iface_names = map![]; + let mut schema_names = map![]; + for iface in &kit.ifaces { + let iface_id = iface.iface_id(); + iface_names.insert(iface_id, &iface.name); + eprintln!("- Interface {} {}", iface.name, iface_id); + } + for schema in &kit.schemata { + let schema_id = schema.schema_id(); + schema_names.insert(schema_id, &schema.name); + eprintln!("- Schema {} {}", schema.name, schema_id); + } + for iimpl in &kit.iimpls { + let iface = iface_names + .get(&iimpl.iface_id) + .map(|name| name.to_string()) + .unwrap_or_else(|| iimpl.iface_id.to_string()); + let schema = schema_names + .get(&iimpl.schema_id) + .map(|name| name.to_string()) + .unwrap_or_else(|| iimpl.schema_id.to_string()); + eprintln!("- Implementation of {iface} for {schema}",); + } + for lib in &kit.scripts { + eprintln!("- AluVM library {}", lib.id()); + } + eprintln!("- Strict types: {} definitions", kit.types.len()); + let kit = kit.validate().map_err(|(status, _)| status.to_string())?; + runtime.import_kit(kit)?; + eprintln!("Kit is imported"); + } UniversalFile::Contract(contract) => { let mut resolver = self.resolver()?; let id = contract.consignment_id(); @@ -392,7 +425,7 @@ impl Exec for RgbArgs { .validate(&mut resolver, self.general.network.is_testnet()) .map_err(|(status, _)| status.to_string())?; runtime.import_contract(contract, &mut resolver)?; - eprintln!("Contract {id} imported to the stash"); + eprintln!("Contract {id} is imported"); } UniversalFile::Transfer(_) => { return Err(s!("use `validate` and `accept` commands to work with \ From 39e9ed3cbdf3b5c7a970f040644af1566d4da6e4 Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Sun, 14 Apr 2024 19:24:40 +0200 Subject: [PATCH 10/20] chore: update dependencies --- Cargo.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6cb2458..3652bab 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1551,7 +1551,7 @@ dependencies = [ [[package]] name = "rgb-core" version = "0.11.0-beta.5" -source = "git+https://github.com/RGB-WG/rgb-core?branch=script-refactor#e0b0181b019ed5c59e4bf4dcf77402358a57fcb1" +source = "git+https://github.com/RGB-WG/rgb-core?branch=script-refactor#2135079e66fedd460563025d46ffd0efce8b1377" dependencies = [ "aluvm", "amplify", @@ -1573,7 +1573,7 @@ dependencies = [ [[package]] name = "rgb-invoice" version = "0.11.0-beta.5" -source = "git+https://github.com/RGB-WG/rgb-std?branch=script-refactor#f95c39f5a74717e486bf6f8b82f25e5f4c088c26" +source = "git+https://github.com/RGB-WG/rgb-std?branch=script-refactor#2e4f284e9f66c52d7bfdba6555b27aa2c6179be8" dependencies = [ "amplify", "baid58", @@ -1633,7 +1633,7 @@ dependencies = [ [[package]] name = "rgb-std" version = "0.11.0-beta.5" -source = "git+https://github.com/RGB-WG/rgb-std?branch=script-refactor#f95c39f5a74717e486bf6f8b82f25e5f4c088c26" +source = "git+https://github.com/RGB-WG/rgb-std?branch=script-refactor#2e4f284e9f66c52d7bfdba6555b27aa2c6179be8" dependencies = [ "aluvm", "amplify", @@ -2073,7 +2073,7 @@ checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" [[package]] name = "strict_encoding" version = "2.7.0-beta.1" -source = "git+https://github.com/strict-types/strict-encoding?branch=rstring#561f0070344f4f2c2f5fcb062b4e2e62d3ab12dd" +source = "git+https://github.com/strict-types/strict-encoding?branch=rstring#89ea1c2f02402cbda8bbe78ae9a629446f84e474" dependencies = [ "amplify", "half", @@ -2084,7 +2084,7 @@ dependencies = [ [[package]] name = "strict_encoding_derive" version = "2.7.0-beta.1" -source = "git+https://github.com/strict-types/strict-encoding?branch=rstring#561f0070344f4f2c2f5fcb062b4e2e62d3ab12dd" +source = "git+https://github.com/strict-types/strict-encoding?branch=rstring#89ea1c2f02402cbda8bbe78ae9a629446f84e474" dependencies = [ "amplify_syn", "heck 0.4.1", From 201be839262db94acff2bf1cf3e8b41036d272af Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Sun, 14 Apr 2024 20:06:32 +0200 Subject: [PATCH 11/20] runtime: remove requirement to always use BP wallet --- cli/src/args.rs | 9 ++ cli/src/command.rs | 200 ++++++++++++++++++++++----------------------- src/runtime.rs | 68 ++++----------- 3 files changed, 126 insertions(+), 151 deletions(-) diff --git a/cli/src/args.rs b/cli/src/args.rs index eccdc16..edc6a83 100644 --- a/cli/src/args.rs +++ b/cli/src/args.rs @@ -27,6 +27,7 @@ use rgb_rt::{ electrum, esplora_blocking, AnyResolver, AnyResolverError, RgbDescr, Runtime, RuntimeError, TapretKey, }; +use rgbstd::persistence::Stock; use crate::Command; @@ -72,6 +73,14 @@ impl Default for RgbArgs { } impl RgbArgs { + pub fn rgb_stock(&self) -> Result { + eprint!("Loading stock ... "); + let runtime = Runtime::::load_walletless(&self.general.base_dir())?; + eprintln!("success"); + + Ok(runtime) + } + pub fn rgb_runtime(&self, config: &Config) -> Result { let bprt = self.inner.bp_runtime::(config)?; eprint!("Loading stock ... "); diff --git a/cli/src/command.rs b/cli/src/command.rs index 0ae1a83..c81e442 100644 --- a/cli/src/command.rs +++ b/cli/src/command.rs @@ -37,6 +37,7 @@ use rgbstd::containers::{ use rgbstd::contract::{ContractId, GenesisSeal, GraphSeal, StateType}; use rgbstd::interface::{AmountChange, ContractSuppl, FilterExclude, IfaceId}; use rgbstd::invoice::{Beneficiary, RgbInvoice, RgbInvoiceBuilder, XChainNet}; +use rgbstd::persistence::fs::StoreFs; use rgbstd::persistence::{SchemaIfaces, StashReadProvider}; use rgbstd::schema::SchemaId; use rgbstd::validation::Validity; @@ -300,24 +301,24 @@ impl Exec for RgbArgs { const CONF_FILE_NAME: &'static str = "rgb.toml"; fn exec(self, config: Config, _name: &'static str) -> Result<(), RuntimeError> { - if let Some(mut runtime) = match &self.command { + if let Some(stock) = match &self.command { Command::General(cmd) => { self.inner.translate(cmd).exec(config, "rgb")?; None } Command::Debug(DebugCommand::Taprets) => { - let runtime = self.rgb_runtime(&config)?; - for (witness_id, tapret) in runtime.as_stash_provider().taprets()? { + let stock = self.rgb_stock()?; + for (witness_id, tapret) in stock.as_stash_provider().taprets()? { println!("{witness_id}\t{tapret}"); } None } Command::Schemata => { - let runtime = self.rgb_runtime(&config)?; - for schema_iface in runtime.schemata()? { + let stock = self.rgb_stock()?; + for schema_iface in stock.schemata()? { print!("{} ", schema_iface.schema.schema_id()); for iimpl in schema_iface.iimpls.values() { - let iface = runtime.iface(iimpl.iface_id)?; + let iface = stock.iface(iimpl.iface_id)?; print!("{} ", iface.name); } println!(); @@ -325,15 +326,15 @@ impl Exec for RgbArgs { None } Command::Interfaces => { - let runtime = self.rgb_runtime(&config)?; - for (id, name) in runtime.ifaces()? { + let stock = self.rgb_stock()?; + for (id, name) in stock.ifaces()? { println!("{} {id}", name); } None } Command::Contracts => { - let runtime = self.rgb_runtime(&config)?; - for id in runtime.contract_ids()? { + let stock = self.rgb_stock()?; + for id in stock.contract_ids()? { println!("{id}"); } None @@ -378,71 +379,69 @@ impl Exec for RgbArgs { } Command::Import { armored, file } => { - let mut runtime = self.rgb_runtime(&config)?; - if *armored { - todo!() - } else { - let content = UniversalFile::load_file(file)?; - match content { - UniversalFile::Kit(kit) => { - let id = kit.kit_id(); - eprintln!("Importing kit {id}"); - let mut iface_names = map![]; - let mut schema_names = map![]; - for iface in &kit.ifaces { - let iface_id = iface.iface_id(); - iface_names.insert(iface_id, &iface.name); - eprintln!("- Interface {} {}", iface.name, iface_id); - } - for schema in &kit.schemata { - let schema_id = schema.schema_id(); - schema_names.insert(schema_id, &schema.name); - eprintln!("- Schema {} {}", schema.name, schema_id); - } - for iimpl in &kit.iimpls { - let iface = iface_names - .get(&iimpl.iface_id) - .map(|name| name.to_string()) - .unwrap_or_else(|| iimpl.iface_id.to_string()); - let schema = schema_names - .get(&iimpl.schema_id) - .map(|name| name.to_string()) - .unwrap_or_else(|| iimpl.schema_id.to_string()); - eprintln!("- Implementation of {iface} for {schema}",); - } - for lib in &kit.scripts { - eprintln!("- AluVM library {}", lib.id()); - } - eprintln!("- Strict types: {} definitions", kit.types.len()); - let kit = kit.validate().map_err(|(status, _)| status.to_string())?; - runtime.import_kit(kit)?; - eprintln!("Kit is imported"); + let mut stock = self.rgb_stock()?; + assert!(!armored, "importing armored files is not yet supported"); + // TODO: Support armored files + let content = UniversalFile::load_file(file)?; + match content { + UniversalFile::Kit(kit) => { + let id = kit.kit_id(); + eprintln!("Importing kit {id}"); + let mut iface_names = map![]; + let mut schema_names = map![]; + for iface in &kit.ifaces { + let iface_id = iface.iface_id(); + iface_names.insert(iface_id, &iface.name); + eprintln!("- Interface {} {}", iface.name, iface_id); } - UniversalFile::Contract(contract) => { - let mut resolver = self.resolver()?; - let id = contract.consignment_id(); - let contract = contract - .validate(&mut resolver, self.general.network.is_testnet()) - .map_err(|(status, _)| status.to_string())?; - runtime.import_contract(contract, &mut resolver)?; - eprintln!("Contract {id} is imported"); + for schema in &kit.schemata { + let schema_id = schema.schema_id(); + schema_names.insert(schema_id, &schema.name); + eprintln!("- Schema {} {}", schema.name, schema_id); } - UniversalFile::Transfer(_) => { - return Err(s!("use `validate` and `accept` commands to work with \ - transfer consignments") - .into()); + for iimpl in &kit.iimpls { + let iface = iface_names + .get(&iimpl.iface_id) + .map(|name| name.to_string()) + .unwrap_or_else(|| iimpl.iface_id.to_string()); + let schema = schema_names + .get(&iimpl.schema_id) + .map(|name| name.to_string()) + .unwrap_or_else(|| iimpl.schema_id.to_string()); + eprintln!("- Implementation of {iface} for {schema}",); } - }; + for lib in &kit.scripts { + eprintln!("- AluVM library {}", lib.id()); + } + eprintln!("- Strict types: {} definitions", kit.types.len()); + let kit = kit.validate().map_err(|(status, _)| status.to_string())?; + stock.import_kit(kit)?; + eprintln!("Kit is imported"); + } + UniversalFile::Contract(contract) => { + let mut resolver = self.resolver()?; + let id = contract.consignment_id(); + let contract = contract + .validate(&mut resolver, self.general.network.is_testnet()) + .map_err(|(status, _)| status.to_string())?; + stock.import_contract(contract, &mut resolver)?; + eprintln!("Contract {id} is imported"); + } + UniversalFile::Transfer(_) => { + return Err(s!("use `validate` and `accept` commands to work with \ + transfer consignments") + .into()); + } } - Some(runtime) + Some(stock) } Command::Export { armored: _, contract, file, } => { - let runtime = self.rgb_runtime(&config)?; - let contract = runtime + let stock = self.rgb_stock()?; + let contract = stock .export_contract(*contract) .map_err(|err| err.to_string())?; if let Some(file) = file { @@ -511,7 +510,7 @@ impl Exec for RgbArgs { schema: schema_id, contract, } => { - let mut runtime = self.rgb_runtime(&config)?; + let mut stock = self.rgb_stock()?; let file = fs::File::open(contract)?; @@ -529,13 +528,13 @@ impl Exec for RgbArgs { let SchemaIfaces { ref schema, ref iimpls, - } = runtime.schema(*schema_id)?; + } = stock.schema(*schema_id)?; let iface_name = tn!(iface_name.to_owned()); - let iface = runtime + let iface = stock .iface(iface_name.clone()) .or_else(|_| { let id = IfaceId::from_str(iface_name.as_str())?; - runtime.iface(id).map_err(RuntimeError::from) + stock.iface(id).map_err(RuntimeError::from) })? .clone(); let iface_id = iface.iface_id(); @@ -545,7 +544,7 @@ impl Exec for RgbArgs { )) })?; - let mut builder = runtime.contract_builder(*schema_id, iface_id)?; + let mut builder = stock.contract_builder(*schema_id, iface_id)?; let types = builder.type_system().clone(); if let Some(globals) = code.get("globals") { @@ -637,12 +636,12 @@ impl Exec for RgbArgs { let contract = builder.issue_contract()?; let id = contract.contract_id(); let mut resolver = self.resolver()?; - runtime.import_contract(contract, &mut resolver)?; + stock.import_contract(contract, &mut resolver)?; eprintln!( "A new contract {id} is issued and added to the stash.\nUse `export` command \ to export the contract." ); - Some(runtime) + Some(stock) } Command::Invoice { address_based, @@ -691,7 +690,7 @@ impl Exec for RgbArgs { .set_amount_raw(*value) .finish(); println!("{invoice}"); - Some(runtime) + Some(runtime.into_stock()) } Command::Prepare { v2, @@ -720,7 +719,7 @@ impl Exec for RgbArgs { PsbtVer::V2 => println!("{psbt:#}"), }, } - Some(runtime) + Some(runtime.into_stock()) } Command::Consign { invoice, @@ -736,7 +735,7 @@ impl Exec for RgbArgs { let mut psbt_file = File::create(psbt_name)?; psbt.encode(psbt.version, &mut psbt_file)?; transfer.save_file(out_file)?; - Some(runtime) + Some(runtime.into_stock()) } Command::Transfer { v2, @@ -768,7 +767,7 @@ impl Exec for RgbArgs { PsbtVer::V2 => println!("{psbt:#}"), }, } - Some(runtime) + Some(runtime.into_stock()) } Command::Inspect { file, dir, path } => { #[derive(Clone, Debug)] @@ -867,7 +866,7 @@ impl Exec for RgbArgs { None } Command::Dump { root_dir } => { - let runtime = self.rgb_runtime(&config)?; + let stock = self.rgb_stock()?; fs::remove_dir_all(root_dir).ok(); fs::create_dir_all(format!("{root_dir}/stash/schemata"))?; @@ -880,7 +879,7 @@ impl Exec for RgbArgs { fs::create_dir_all(format!("{root_dir}/index"))?; // Stash - for schema_ifaces in runtime.schemata()? { + for schema_ifaces in stock.schemata()? { fs::write( format!( "{root_dir}/stash/schemata/{}.yaml", @@ -889,19 +888,19 @@ impl Exec for RgbArgs { serde_yaml::to_string(&schema_ifaces)?, )?; } - for (id, name) in runtime.ifaces()? { + for (id, name) in stock.ifaces()? { fs::write( format!("{root_dir}/stash/ifaces/{id}.{name}.yaml"), - serde_yaml::to_string(runtime.iface(id)?)?, + serde_yaml::to_string(stock.iface(id)?)?, )?; } - for (id, genesis) in runtime.as_stash_provider().debug_geneses() { + for (id, genesis) in stock.as_stash_provider().debug_geneses() { fs::write( format!("{root_dir}/stash/geneses/{id}.yaml"), serde_yaml::to_string(genesis)?, )?; } - for (id, list) in runtime.as_stash_provider().debug_suppl() { + for (id, list) in stock.as_stash_provider().debug_suppl() { for suppl in list { fs::write( format!( @@ -912,19 +911,19 @@ impl Exec for RgbArgs { )?; } } - for (id, bundle) in runtime.as_stash_provider().debug_bundles() { + for (id, bundle) in stock.as_stash_provider().debug_bundles() { fs::write( format!("{root_dir}/stash/bundles/{id}.yaml"), serde_yaml::to_string(bundle)?, )?; } - for (id, witness) in runtime.as_stash_provider().debug_witnesses() { + for (id, witness) in stock.as_stash_provider().debug_witnesses() { fs::write( format!("{root_dir}/stash/witnesses/{id}.yaml"), serde_yaml::to_string(witness)?, )?; } - for (id, extension) in runtime.as_stash_provider().debug_extensions() { + for (id, extension) in stock.as_stash_provider().debug_extensions() { fs::write( format!("{root_dir}/stash/extensions/{id}.yaml"), serde_yaml::to_string(extension)?, @@ -932,12 +931,12 @@ impl Exec for RgbArgs { } fs::write( format!("{root_dir}/seal-secret.yaml"), - serde_yaml::to_string(runtime.as_stash_provider().debug_secret_seals())?, + serde_yaml::to_string(stock.as_stash_provider().debug_secret_seals())?, )?; // TODO: Add sigs debugging // State - for (id, history) in runtime.as_state_provider().debug_history() { + for (id, history) in stock.as_state_provider().debug_history() { fs::write( format!("{root_dir}/state/{id}.yaml"), serde_yaml::to_string(history)?, @@ -947,27 +946,23 @@ impl Exec for RgbArgs { // Index fs::write( format!("{root_dir}/index/op-to-bundle.yaml"), - serde_yaml::to_string(runtime.as_index_provider().debug_op_bundle_index())?, + serde_yaml::to_string(stock.as_index_provider().debug_op_bundle_index())?, )?; fs::write( format!("{root_dir}/index/bundle-to-contract.yaml"), - serde_yaml::to_string( - runtime.as_index_provider().debug_bundle_contract_index(), - )?, + serde_yaml::to_string(stock.as_index_provider().debug_bundle_contract_index())?, )?; fs::write( format!("{root_dir}/index/bundle-to-witness.yaml"), - serde_yaml::to_string( - runtime.as_index_provider().debug_bundle_witness_index(), - )?, + serde_yaml::to_string(stock.as_index_provider().debug_bundle_witness_index())?, )?; fs::write( format!("{root_dir}/index/contracts.yaml"), - serde_yaml::to_string(runtime.as_index_provider().debug_contract_index())?, + serde_yaml::to_string(stock.as_index_provider().debug_contract_index())?, )?; fs::write( format!("{root_dir}/index/terminals.yaml"), - serde_yaml::to_string(runtime.as_index_provider().debug_terminal_index())?, + serde_yaml::to_string(stock.as_index_provider().debug_terminal_index())?, )?; eprintln!("Dump is successfully generated and saved to '{root_dir}'"); None @@ -990,16 +985,21 @@ impl Exec for RgbArgs { } Command::Accept { force: _, file } => { // TODO: Ensure we properly handle unmined terminal transactions - let mut runtime = self.rgb_runtime(&config)?; + let mut stock = self.rgb_stock()?; let mut resolver = self.resolver()?; let transfer = Transfer::load_file(file)?; resolver.add_terminals(&transfer); - runtime.accept_transfer(transfer, &mut resolver)?; + let valid = transfer + .validate(&mut resolver, self.general.network.is_testnet()) + .map_err(|(status, _)| status)?; + stock.accept_transfer(valid, &mut resolver)?; eprintln!("Transfer accepted into the stash"); - Some(runtime) + Some(stock) } } { - runtime.store() + stock + .store(&self.general.base_dir()) + .expect("unable to save stock"); } println!(); diff --git a/src/runtime.rs b/src/runtime.rs index 8dc0dc0..8e908f6 100644 --- a/src/runtime.rs +++ b/src/runtime.rs @@ -23,22 +23,21 @@ use std::collections::HashMap; use std::convert::Infallible; -use std::io; use std::io::ErrorKind; use std::ops::{Deref, DerefMut}; use std::path::PathBuf; +use std::{fs, io}; use amplify::IoError; use bpstd::{Network, XpubDerivable}; use bpwallet::Wallet; -use rgbstd::containers::{LoadError, Transfer, ValidConsignment}; +use rgbstd::containers::LoadError; use rgbstd::interface::{ AmountChange, BuilderError, ContractError, IfaceOp, IfaceRef, OutpointFilter, WitnessFilter, }; use rgbstd::persistence::fs::{LoadFs, StoreFs}; use rgbstd::persistence::{ContractIfaceError, Stock, StockError, StockErrorAll, StockErrorMem}; -use rgbstd::resolvers::ResolveHeight; -use rgbstd::validation::{self, ResolveWitness}; +use rgbstd::validation::{self}; use rgbstd::{AssignmentWitness, ContractId, XChain, XOutpoint, XWitnessId}; use strict_types::encoding::{DecodeError, DeserializeError, Ident, SerializeError}; @@ -176,21 +175,26 @@ where for<'de> D: serde::Serialize + serde::Deserialize<'de>, for<'de> bpwallet::WalletDescr: serde::Serialize + serde::Deserialize<'de>, { - pub fn load_attach( - stock_path: PathBuf, - bprt: bpwallet::Runtime, - ) -> Result { - let stock = Stock::load(&stock_path).or_else(|err| { - if matches!(err, DeserializeError::Decode(DecodeError::Io(ref err)) if err.kind() == ErrorKind::NotFound) { + pub fn load_walletless(stock_path: &PathBuf) -> Result { + Stock::load(stock_path).map_err(RuntimeError::from).or_else(|err| { + if matches!(err, RuntimeError::Deserialize(DeserializeError::Decode(DecodeError::Io(ref err))) if err.kind() == ErrorKind::NotFound) { #[cfg(feature = "log")] eprint!("stock file is absent, creating a new one ... "); let stock = Stock::default(); + fs::create_dir_all(stock_path)?; + stock.store(stock_path)?; return Ok(stock) } eprintln!("stock file is damaged"); Err(err) - })?; + }) + } + pub fn load_attach( + stock_path: PathBuf, + bprt: bpwallet::Runtime, + ) -> Result { + let stock = Self::load_walletless(&stock_path)?; Ok(Self { stock_path, stock, @@ -204,6 +208,8 @@ where .expect("unable to save stock"); self.bprt.try_store().expect("unable to save wallet data"); } + + pub fn into_stock(self) -> Stock { self.stock } } impl, K> Runtime { @@ -213,48 +219,8 @@ impl, K> Runtime { pub fn attach(&mut self, bprt: bpwallet::Runtime) { self.bprt = bprt } - pub fn unload(self) {} - pub fn network(&self) -> Network { self.bprt.network() } - pub fn import_contract( - &mut self, - contract: ValidConsignment, - resolver: &mut R, - ) -> Result - where - R::Error: 'static, - { - let status = self.stock.import_contract(contract, resolver)?; - Ok(status) - } - - pub fn validate_transfer( - &mut self, - transfer: Transfer, - resolver: &mut impl ResolveWitness, - ) -> Result, RuntimeError> { - match transfer.validate(resolver, self.network().is_testnet()) { - Ok(valid) => return Ok(valid), - Err((status, _)) => return Err(status.into()), - } - } - - pub fn accept_transfer( - &mut self, - transfer: Transfer, - resolver: &mut R, - ) -> Result - where - R::Error: 'static, - { - let valid = transfer - .validate(resolver, self.network().is_testnet()) - .map_err(|(status, _)| status)?; - let status = self.stock.accept_transfer(valid, resolver)?; - Ok(status) - } - // TODO: Integrate into BP Wallet `TxRow` as L2 and provide transactional info pub fn fungible_history( &self, From 51f0afc6d370e4fbcd6b0e63d9df3689a4bfb137 Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Mon, 15 Apr 2024 11:22:14 +0200 Subject: [PATCH 12/20] chore: update dependencies --- Cargo.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3652bab..a231269 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1551,7 +1551,7 @@ dependencies = [ [[package]] name = "rgb-core" version = "0.11.0-beta.5" -source = "git+https://github.com/RGB-WG/rgb-core?branch=script-refactor#2135079e66fedd460563025d46ffd0efce8b1377" +source = "git+https://github.com/RGB-WG/rgb-core?branch=script-refactor#0fbabb559a06e8bb883d1013fa2ff4ddb30c7fcc" dependencies = [ "aluvm", "amplify", @@ -1573,7 +1573,7 @@ dependencies = [ [[package]] name = "rgb-invoice" version = "0.11.0-beta.5" -source = "git+https://github.com/RGB-WG/rgb-std?branch=script-refactor#2e4f284e9f66c52d7bfdba6555b27aa2c6179be8" +source = "git+https://github.com/RGB-WG/rgb-std?branch=script-refactor#e675527dcf3776d61bf66bffbdb0f370c13fa38c" dependencies = [ "amplify", "baid58", @@ -1633,7 +1633,7 @@ dependencies = [ [[package]] name = "rgb-std" version = "0.11.0-beta.5" -source = "git+https://github.com/RGB-WG/rgb-std?branch=script-refactor#2e4f284e9f66c52d7bfdba6555b27aa2c6179be8" +source = "git+https://github.com/RGB-WG/rgb-std?branch=script-refactor#e675527dcf3776d61bf66bffbdb0f370c13fa38c" dependencies = [ "aluvm", "amplify", From 0e7858f0434089cf6d41563fa2a4de19d5bc4cf9 Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Mon, 15 Apr 2024 21:47:12 +0200 Subject: [PATCH 13/20] psbt: fix detection of close method in push_rgb_transition Closes #168 --- psbt/src/rgb.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/psbt/src/rgb.rs b/psbt/src/rgb.rs index f8fb8af..49ef4d2 100644 --- a/psbt/src/rgb.rs +++ b/psbt/src/rgb.rs @@ -277,7 +277,7 @@ impl RgbExt for Psbt { let opid = transition.id(); let prev_method = self.rgb_close_method(opid)?; - if Some(method) != prev_method { + if matches!(prev_method, Some(prev_method) if prev_method != method) { return Err(RgbPsbtError::InvalidCloseMethod(opid)); } From 004980bc5c93f1fdf02a8ae718a923c228d4fc90 Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Mon, 15 Apr 2024 21:47:12 +0200 Subject: [PATCH 14/20] psbt: fix detection of close method in push_rgb_transition Closes #168 --- psbt/src/rgb.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/psbt/src/rgb.rs b/psbt/src/rgb.rs index f8fb8af..49ef4d2 100644 --- a/psbt/src/rgb.rs +++ b/psbt/src/rgb.rs @@ -277,7 +277,7 @@ impl RgbExt for Psbt { let opid = transition.id(); let prev_method = self.rgb_close_method(opid)?; - if Some(method) != prev_method { + if matches!(prev_method, Some(prev_method) if prev_method != method) { return Err(RgbPsbtError::InvalidCloseMethod(opid)); } From a2980e4655bca2c59dc9bf31325e3c743355e878 Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Wed, 17 Apr 2024 10:46:28 +0200 Subject: [PATCH 15/20] chore: update dependencies --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a231269..723967f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1573,7 +1573,7 @@ dependencies = [ [[package]] name = "rgb-invoice" version = "0.11.0-beta.5" -source = "git+https://github.com/RGB-WG/rgb-std?branch=script-refactor#e675527dcf3776d61bf66bffbdb0f370c13fa38c" +source = "git+https://github.com/RGB-WG/rgb-std?branch=script-refactor#dd2246cf27531706ae6d97f0de53109f8c92ef31" dependencies = [ "amplify", "baid58", @@ -1633,7 +1633,7 @@ dependencies = [ [[package]] name = "rgb-std" version = "0.11.0-beta.5" -source = "git+https://github.com/RGB-WG/rgb-std?branch=script-refactor#e675527dcf3776d61bf66bffbdb0f370c13fa38c" +source = "git+https://github.com/RGB-WG/rgb-std?branch=script-refactor#dd2246cf27531706ae6d97f0de53109f8c92ef31" dependencies = [ "aluvm", "amplify", From b1e1122ab28f4412262b5cd66295c1afff9f0a91 Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Wed, 17 Apr 2024 11:45:13 +0200 Subject: [PATCH 16/20] chore: add debug to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 55993b2..653cfce 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # Generated by Cargo # will have compiled files and executables /target +/debug # These are backup files generated by rustfmt **/*.rs.bk From 9340c02858cd9f783db2bf9769ca55afb88a6d8d Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Wed, 17 Apr 2024 11:48:17 +0200 Subject: [PATCH 17/20] chore: add debug to gitignore a2980e --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 55993b2..653cfce 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # Generated by Cargo # will have compiled files and executables /target +/debug # These are backup files generated by rustfmt **/*.rs.bk From f96f1e8947826da00c9695f21b3e3033bebd243e Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Thu, 18 Apr 2024 15:15:05 +0200 Subject: [PATCH 18/20] chore: update dependencies --- Cargo.lock | 95 ++++++++++++++++++++++++++------------------------ Cargo.toml | 13 +++---- src/runtime.rs | 2 +- 3 files changed, 55 insertions(+), 55 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 723967f..25deeda 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -29,7 +29,7 @@ dependencies = [ [[package]] name = "aluvm" version = "0.11.0-beta.5" -source = "git+https://github.com/AluVM/rust-aluvm?branch=v0.11#a08387f744f6679b6ee308e70f99099c318824db" +source = "git+https://github.com/AluVM/rust-aluvm?branch=v0.11#d18ea84836a8a96f3dfe61c99b94f2eab1417819" dependencies = [ "amplify", "ascii-armor", @@ -323,7 +323,7 @@ dependencies = [ [[package]] name = "bp-consensus" version = "0.11.0-beta.5" -source = "git+https://github.com/BP-WG/bp-core?branch=v0.11#40d155151b57325ad82edf838196b52ad27af188" +source = "git+https://github.com/BP-WG/bp-core?branch=v0.11#27a4b711613f88276b5b7da0c2a3b27164b431e8" dependencies = [ "amplify", "chrono", @@ -337,7 +337,7 @@ dependencies = [ [[package]] name = "bp-core" version = "0.11.0-beta.5" -source = "git+https://github.com/BP-WG/bp-core?branch=v0.11#40d155151b57325ad82edf838196b52ad27af188" +source = "git+https://github.com/BP-WG/bp-core?branch=v0.11#27a4b711613f88276b5b7da0c2a3b27164b431e8" dependencies = [ "amplify", "bp-consensus", @@ -355,7 +355,7 @@ dependencies = [ [[package]] name = "bp-dbc" version = "0.11.0-beta.5" -source = "git+https://github.com/BP-WG/bp-core?branch=v0.11#40d155151b57325ad82edf838196b52ad27af188" +source = "git+https://github.com/BP-WG/bp-core?branch=v0.11#27a4b711613f88276b5b7da0c2a3b27164b431e8" dependencies = [ "amplify", "base85", @@ -369,7 +369,7 @@ dependencies = [ [[package]] name = "bp-derive" version = "0.11.0-beta.5" -source = "git+https://github.com/BP-WG/bp-std?branch=v0.11#5cd19126c7acbe96586573fd8d00baf2273887df" +source = "git+https://github.com/BP-WG/bp-std?branch=v0.11#7dd16a84edc8c308856155d990d9df4311c35bfc" dependencies = [ "amplify", "bitcoin_hashes", @@ -418,7 +418,7 @@ dependencies = [ [[package]] name = "bp-invoice" version = "0.11.0-beta.5" -source = "git+https://github.com/BP-WG/bp-std?branch=v0.11#5cd19126c7acbe96586573fd8d00baf2273887df" +source = "git+https://github.com/BP-WG/bp-std?branch=v0.11#7dd16a84edc8c308856155d990d9df4311c35bfc" dependencies = [ "amplify", "bech32", @@ -430,7 +430,7 @@ dependencies = [ [[package]] name = "bp-seals" version = "0.11.0-beta.5" -source = "git+https://github.com/BP-WG/bp-core?branch=v0.11#40d155151b57325ad82edf838196b52ad27af188" +source = "git+https://github.com/BP-WG/bp-core?branch=v0.11#27a4b711613f88276b5b7da0c2a3b27164b431e8" dependencies = [ "amplify", "baid58", @@ -446,7 +446,7 @@ dependencies = [ [[package]] name = "bp-std" version = "0.11.0-beta.5" -source = "git+https://github.com/BP-WG/bp-std?branch=v0.11#5cd19126c7acbe96586573fd8d00baf2273887df" +source = "git+https://github.com/BP-WG/bp-std?branch=v0.11#7dd16a84edc8c308856155d990d9df4311c35bfc" dependencies = [ "amplify", "bp-consensus", @@ -484,7 +484,7 @@ dependencies = [ [[package]] name = "bp-wallet" version = "0.11.0-beta.5" -source = "git+https://github.com/BP-WG/bp-wallet?branch=v0.11#f217eb141dbb51df6f15cde351aef76c6366f53c" +source = "git+https://github.com/BP-WG/bp-wallet?branch=v0.11#5d07f271605395a0d7e4d10c87283fbcb4203e1b" dependencies = [ "amplify", "bp-electrum", @@ -538,14 +538,14 @@ checksum = "45565fc9416b9896014f5732ac776f810ee53a66730c17e4020c3ec064a8f88f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] name = "chrono" -version = "0.4.37" +version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a0d04d43504c61aa6c7531f1871dd0d418d91130162063b789da00fd7057a5e" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" dependencies = [ "android-tzdata", "iana-time-zone", @@ -587,7 +587,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -605,7 +605,7 @@ checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" [[package]] name = "commit_encoding_derive" version = "0.11.0-beta.5" -source = "git+https://github.com/LNP-BP/client_side_validation?branch=v0.11#503e5da35642f52b090f7e232a8aeaccb05463cc" +source = "git+https://github.com/LNP-BP/client_side_validation?branch=v0.11#d32e1af11a599643b235706efd51d0097347f082" dependencies = [ "amplify", "amplify_syn", @@ -617,7 +617,7 @@ dependencies = [ [[package]] name = "commit_verify" version = "0.11.0-beta.5" -source = "git+https://github.com/LNP-BP/client_side_validation?branch=v0.11#503e5da35642f52b090f7e232a8aeaccb05463cc" +source = "git+https://github.com/LNP-BP/client_side_validation?branch=v0.11#d32e1af11a599643b235706efd51d0097347f082" dependencies = [ "amplify", "commit_encoding_derive", @@ -717,7 +717,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.10.0", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -728,7 +728,7 @@ checksum = "a668eda54683121533a393014d8692171709ff57a7d61f187b6e782719f8933f" dependencies = [ "darling_core", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -744,7 +744,7 @@ dependencies = [ [[package]] name = "descriptors" version = "0.11.0-beta.5" -source = "git+https://github.com/BP-WG/bp-std?branch=v0.11#5cd19126c7acbe96586573fd8d00baf2273887df" +source = "git+https://github.com/BP-WG/bp-std?branch=v0.11#7dd16a84edc8c308856155d990d9df4311c35bfc" dependencies = [ "amplify", "bp-derive", @@ -1333,7 +1333,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -1404,9 +1404,9 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" -version = "1.0.79" +version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" +checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba" dependencies = [ "unicode-ident", ] @@ -1414,7 +1414,7 @@ dependencies = [ [[package]] name = "psbt" version = "0.11.0-beta.5" -source = "git+https://github.com/BP-WG/bp-std?branch=v0.11#5cd19126c7acbe96586573fd8d00baf2273887df" +source = "git+https://github.com/BP-WG/bp-std?branch=v0.11#7dd16a84edc8c308856155d990d9df4311c35bfc" dependencies = [ "amplify", "base64", @@ -1551,7 +1551,7 @@ dependencies = [ [[package]] name = "rgb-core" version = "0.11.0-beta.5" -source = "git+https://github.com/RGB-WG/rgb-core?branch=script-refactor#0fbabb559a06e8bb883d1013fa2ff4ddb30c7fcc" +source = "git+https://github.com/RGB-WG/rgb-core?branch=v0.11#551d6d6fc3c7bf10119b20145ddae852fba6446d" dependencies = [ "aluvm", "amplify", @@ -1573,7 +1573,7 @@ dependencies = [ [[package]] name = "rgb-invoice" version = "0.11.0-beta.5" -source = "git+https://github.com/RGB-WG/rgb-std?branch=script-refactor#dd2246cf27531706ae6d97f0de53109f8c92ef31" +source = "git+https://github.com/RGB-WG/rgb-std?branch=v0.11#58fbbc417835a829f5f9325bfed35e5a18310d13" dependencies = [ "amplify", "baid58", @@ -1633,7 +1633,7 @@ dependencies = [ [[package]] name = "rgb-std" version = "0.11.0-beta.5" -source = "git+https://github.com/RGB-WG/rgb-std?branch=script-refactor#dd2246cf27531706ae6d97f0de53109f8c92ef31" +source = "git+https://github.com/RGB-WG/rgb-std?branch=v0.11#58fbbc417835a829f5f9325bfed35e5a18310d13" dependencies = [ "aluvm", "amplify", @@ -1903,29 +1903,29 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.197" +version = "1.0.198" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" +checksum = "9846a40c979031340571da2545a4e5b7c4163bdae79b301d5f86d03979451fcc" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.197" +version = "1.0.198" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" +checksum = "e88edab869b01783ba905e7d0153f9fc1a6505a96e4ad3018011eedb838566d9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] name = "serde_json" -version = "1.0.115" +version = "1.0.116" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12dc5c46daa8e9fdf4f5e71b6cf9a53f2487da0e86e55808e2d35539666497dd" +checksum = "3e17db7126d17feb94eb3fad46bf1a96b034e8aacbc2e775fe81505f8b0b2813" dependencies = [ "itoa", "ryu", @@ -1990,7 +1990,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -2029,7 +2029,7 @@ dependencies = [ [[package]] name = "single_use_seals" version = "0.11.0-beta.5" -source = "git+https://github.com/LNP-BP/client_side_validation?branch=v0.11#503e5da35642f52b090f7e232a8aeaccb05463cc" +source = "git+https://github.com/LNP-BP/client_side_validation?branch=v0.11#d32e1af11a599643b235706efd51d0097347f082" dependencies = [ "amplify_derive", ] @@ -2072,8 +2072,9 @@ checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" [[package]] name = "strict_encoding" -version = "2.7.0-beta.1" -source = "git+https://github.com/strict-types/strict-encoding?branch=rstring#89ea1c2f02402cbda8bbe78ae9a629446f84e474" +version = "2.7.0-beta.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c463f8ea993e323740d78544473e791adb91ac659f5bf2c1a59db64a34f99fc" dependencies = [ "amplify", "half", @@ -2083,8 +2084,9 @@ dependencies = [ [[package]] name = "strict_encoding_derive" -version = "2.7.0-beta.1" -source = "git+https://github.com/strict-types/strict-encoding?branch=rstring#89ea1c2f02402cbda8bbe78ae9a629446f84e474" +version = "2.7.0-beta.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "475fa6f1fdde6e0555422b5111ad34bde30a1459af3599f920c3af9829772c0e" dependencies = [ "amplify_syn", "heck 0.4.1", @@ -2095,8 +2097,9 @@ dependencies = [ [[package]] name = "strict_types" -version = "2.7.0-beta.2" -source = "git+https://github.com/strict-types/strict-types?branch=develop#2e6b57b7b46efe9b6db430b56ba4a83f2c7776be" +version = "2.7.0-beta.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "152bd04284e9093f23a911d0d89b7dd950a461af1ed5e243f6215fbcd45e9445" dependencies = [ "amplify", "ascii-armor", @@ -2153,9 +2156,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.58" +version = "2.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44cfb93f38070beee36b3fef7d4f5a16f27751d94b187b666a5cc5e9b0d30687" +checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3" dependencies = [ "proc-macro2", "quote", @@ -2227,7 +2230,7 @@ checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -2526,7 +2529,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", "wasm-bindgen-shared", ] @@ -2560,7 +2563,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -2593,7 +2596,7 @@ checksum = "b7f89739351a2e03cb94beb799d47fb2cac01759b40ec441f7de39b00cbf7ef0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index abfd279..ccf6c2d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,8 +24,8 @@ license = "Apache-2.0" amplify = "4.6.0" baid58 = "0.4.4" commit_verify = "0.11.0-beta.5" -strict_encoding = "2.7.0-beta.1" -strict_types = "2.7.0-beta.2" +strict_encoding = "2.7.0-beta.3" +strict_types = "2.7.0-beta.3" bp-core = "0.11.0-beta.5" bp-seals = "0.11.0-beta.5" bp-std = "0.11.0-beta.5" @@ -93,9 +93,6 @@ serde = ["serde_crate", "serde_with", "serde_yaml", "bp-std/serde", "bp-wallet/s features = ["all"] [patch.crates-io] -strict_encoding_derive = { git = "https://github.com/strict-types/strict-encoding", branch = "rstring" } -strict_encoding = { git = "https://github.com/strict-types/strict-encoding", branch = "rstring" } -strict_types = { git = "https://github.com/strict-types/strict-types", branch = "develop" } commit_verify = { git = "https://github.com/LNP-BP/client_side_validation", branch = "v0.11" } single_use_seals = { git = "https://github.com/LNP-BP/client_side_validation", branch = "v0.11" } bp-consensus = { git = "https://github.com/BP-WG/bp-core", branch = "v0.11" } @@ -108,6 +105,6 @@ bp-wallet = { git = "https://github.com/BP-WG/bp-wallet", branch = "v0.11" } psbt = { git = "https://github.com/BP-WG/bp-std", branch = "v0.11" } descriptors = { git = "https://github.com/BP-WG/bp-std", branch = "v0.11" } aluvm = { git = "https://github.com/AluVM/rust-aluvm", branch = "v0.11" } -rgb-core = { git = "https://github.com/RGB-WG/rgb-core", branch = "script-refactor" } -rgb-std = { git = "https://github.com/RGB-WG/rgb-std", branch = "script-refactor" } -rgb-invoice = { git = "https://github.com/RGB-WG/rgb-std", branch = "script-refactor" } +rgb-core = { git = "https://github.com/RGB-WG/rgb-core", branch = "v0.11" } +rgb-std = { git = "https://github.com/RGB-WG/rgb-std", branch = "v0.11" } +rgb-invoice = { git = "https://github.com/RGB-WG/rgb-std", branch = "v0.11" } diff --git a/src/runtime.rs b/src/runtime.rs index 8e908f6..e0a6d03 100644 --- a/src/runtime.rs +++ b/src/runtime.rs @@ -165,7 +165,7 @@ impl<'runtime, D: DescriptorRgb, K> OutpointFilter for ContractOutpointsFilte if !self.filter.include_outpoint(output) { return false; } - matches!(self.filter.stock.contract_state_for_outpoints(self.contract_id, [output]), Ok(list) if !list.is_empty()) + matches!(self.filter.stock.contract_assignments_for(self.contract_id, [output]), Ok(list) if !list.is_empty()) } } From 24048a6c71c564c2a3f20886bdcb640e4c75f456 Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Thu, 18 Apr 2024 15:17:01 +0200 Subject: [PATCH 19/20] chore: fix clippy lints --- cli/src/command.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/src/command.rs b/cli/src/command.rs index c81e442..7a176c2 100644 --- a/cli/src/command.rs +++ b/cli/src/command.rs @@ -998,7 +998,7 @@ impl Exec for RgbArgs { } } { stock - .store(&self.general.base_dir()) + .store(self.general.base_dir()) .expect("unable to save stock"); } From ec20fc1bd144a0a7a1080d6ecae19c298d2179de Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Thu, 18 Apr 2024 15:25:30 +0200 Subject: [PATCH 20/20] chore: fix feature-specific build errors --- src/descriptor.rs | 38 +++++++++++++++++++++++++------------- src/runtime.rs | 12 ++++++++---- 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/src/descriptor.rs b/src/descriptor.rs index 75107e2..2c1c02f 100644 --- a/src/descriptor.rs +++ b/src/descriptor.rs @@ -50,8 +50,11 @@ pub trait DescriptorRgb: Descriptor { } #[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Debug, Display)] -#[derive(Serialize, Deserialize)] -#[serde(crate = "serde_crate", rename_all = "camelCase")] +#[cfg_attr( + feature = "serde", + derive(Serialize, Deserialize), + serde(crate = "serde_crate", rename_all = "camelCase") +)] #[repr(u8)] pub enum RgbKeychain { #[display("0", alt = "0")] @@ -106,15 +109,21 @@ impl From for Keychain { fn from(keychain: RgbKeychain) -> Self { Keychain::from(keychain as u8) } } -#[serde_as] +#[cfg_attr(feature = "serde", serde_as)] #[derive(Clone, Eq, PartialEq, Debug)] -#[derive(Serialize, Deserialize)] -#[serde(crate = "serde_crate", rename_all = "camelCase")] +#[cfg_attr( + feature = "serde", + derive(Serialize, Deserialize), + serde(crate = "serde_crate", rename_all = "camelCase") +)] pub struct TapretKey { pub internal_key: K, // TODO: Allow multiple tweaks per index by introducing derivation using new Terminal trait // TODO: Change serde implementation for both Terminal and TapretCommitment - #[serde_as(as = "HashMap")] + #[cfg_attr( + feature = "serde", + serde_as(as = "HashMap") + )] pub tweaks: HashMap, } @@ -224,13 +233,16 @@ impl DescriptorRgb for TapretKey { } #[derive(Clone, Eq, PartialEq, Debug, From)] -#[derive(Serialize, Deserialize)] -#[serde( - crate = "serde_crate", - rename_all = "camelCase", - bound( - serialize = "S::Compr: serde::Serialize, S::XOnly: serde::Serialize", - deserialize = "S::Compr: serde::Deserialize<'de>, S::XOnly: serde::Deserialize<'de>" +#[cfg_attr( + feature = "serde", + derive(Serialize, Deserialize), + serde( + crate = "serde_crate", + rename_all = "camelCase", + bound( + serialize = "S::Compr: serde::Serialize, S::XOnly: serde::Serialize", + deserialize = "S::Compr: serde::Deserialize<'de>, S::XOnly: serde::Deserialize<'de>" + ) ) )] #[non_exhaustive] diff --git a/src/runtime.rs b/src/runtime.rs index e0a6d03..c4b3092 100644 --- a/src/runtime.rs +++ b/src/runtime.rs @@ -23,10 +23,9 @@ use std::collections::HashMap; use std::convert::Infallible; -use std::io::ErrorKind; +use std::io; use std::ops::{Deref, DerefMut}; use std::path::PathBuf; -use std::{fs, io}; use amplify::IoError; use bpstd::{Network, XpubDerivable}; @@ -39,7 +38,7 @@ use rgbstd::persistence::fs::{LoadFs, StoreFs}; use rgbstd::persistence::{ContractIfaceError, Stock, StockError, StockErrorAll, StockErrorMem}; use rgbstd::validation::{self}; use rgbstd::{AssignmentWitness, ContractId, XChain, XOutpoint, XWitnessId}; -use strict_types::encoding::{DecodeError, DeserializeError, Ident, SerializeError}; +use strict_types::encoding::{DeserializeError, Ident, SerializeError}; use crate::{DescriptorRgb, RgbDescr}; @@ -105,6 +104,7 @@ pub enum RuntimeError { #[display(inner)] Stock(StockErrorAll), + #[cfg(feature = "serde_yaml")] #[from] Yaml(serde_yaml::Error), @@ -176,12 +176,16 @@ where for<'de> bpwallet::WalletDescr: serde::Serialize + serde::Deserialize<'de>, { pub fn load_walletless(stock_path: &PathBuf) -> Result { + use std::io::ErrorKind; + + use strict_types::encoding::DecodeError; + Stock::load(stock_path).map_err(RuntimeError::from).or_else(|err| { if matches!(err, RuntimeError::Deserialize(DeserializeError::Decode(DecodeError::Io(ref err))) if err.kind() == ErrorKind::NotFound) { #[cfg(feature = "log")] eprint!("stock file is absent, creating a new one ... "); let stock = Stock::default(); - fs::create_dir_all(stock_path)?; + std::fs::create_dir_all(stock_path)?; stock.store(stock_path)?; return Ok(stock) }