Skip to content

Commit

Permalink
chore: update to RGB Core v0.11. Part 1: seal definitions and asset tags
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Nov 5, 2023
1 parent 6414c20 commit b54e775
Show file tree
Hide file tree
Showing 17 changed files with 227 additions and 134 deletions.
68 changes: 44 additions & 24 deletions Cargo.lock

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

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

[workspace.package]
version = "0.11.0-beta.1"
authors = ["Dr Maxim Orlovsky <orlovsky@lnp-bp.org>"]
homepage = "https://github.com/RGB-WG"
repository = "https://github.com/RGB-WG/rgb-wallet"
Expand All @@ -21,14 +22,14 @@ amplify = "4.5.0"
baid58 = "0.4.4"
strict_encoding = "2.6.1"
strict_types = "1.6.3"
commit_verify = { version = "0.10.6", features = ["stl"] }
bp-core = { version = "0.10.11", features = ["stl"] }
rgb-core = { version = "0.10.8", features = ["stl"] }
commit_verify = { version = "0.11.0-beta.1", features = ["stl"] }
bp-core = { version = "0.11.0-beta.1", features = ["stl"] }
rgb-core = { version = "0.11.0-beta.1", features = ["stl"] }
serde_crate = { package = "serde", version = "1", features = ["derive"] }

[package]
name = "rgb-std"
version = "0.10.10"
version = { workspace = true }
description = "RGB standard library for working with smart contracts on Bitcoin & Lightning"
keywords = ["bitcoin", "lightning", "rgb", "smart-contracts", "lnp-bp"]
categories = ["cryptography::cryptocurrencies"]
Expand Down Expand Up @@ -81,3 +82,6 @@ wasm-bindgen-test = "0.3"

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

[patch.crates-io]
rgb-core = { git = "https://github.com/RGB-WG/rgb-core", branch = "v0.11" }
13 changes: 7 additions & 6 deletions src/accessors/assignments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,23 @@
// limitations under the License.

use amplify::confinement::SmallVec;
use commit_verify::Conceal;
use rgb::{
Assign, AssignAttach, AssignData, AssignFungible, AssignRights, ExposedSeal, ExposedState,
TypedAssigns,
SealDefinition, TypedAssigns,
};

pub trait TypedAssignsExt<Seal: ExposedSeal> {
fn reveal_seal(&mut self, seal: Seal);
fn reveal_seal(&mut self, seal: SealDefinition<Seal>);

fn filter_revealed_seals(&self) -> Vec<Seal>;
fn filter_revealed_seals(&self) -> Vec<SealDefinition<Seal>>;
}

impl<Seal: ExposedSeal> TypedAssignsExt<Seal> for TypedAssigns<Seal> {
fn reveal_seal(&mut self, seal: Seal) {
fn reveal_seal(&mut self, seal: SealDefinition<Seal>) {
fn reveal<State: ExposedState, Seal: ExposedSeal>(
vec: &mut SmallVec<Assign<State, Seal>>,
revealed: Seal,
revealed: SealDefinition<Seal>,
) {
for assign in vec.iter_mut() {
match assign {
Expand Down Expand Up @@ -64,7 +65,7 @@ impl<Seal: ExposedSeal> TypedAssignsExt<Seal> for TypedAssigns<Seal> {
}
}

fn filter_revealed_seals(&self) -> Vec<Seal> {
fn filter_revealed_seals(&self) -> Vec<SealDefinition<Seal>> {
match self {
TypedAssigns::Declarative(s) => {
s.iter().filter_map(AssignRights::revealed_seal).collect()
Expand Down
6 changes: 3 additions & 3 deletions src/accessors/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use rgb::{GraphSeal, OpId, Operation, Transition, TransitionBundle};
use rgb::{GraphSeal, OpId, Operation, SealDefinition, Transition, TransitionBundle};

use crate::accessors::TypedAssignsExt;

Expand All @@ -32,7 +32,7 @@ pub enum RevealError {

pub trait BundleExt {
/// Ensures that the seal is revealed inside the bundle.
fn reveal_seal(&mut self, seal: GraphSeal);
fn reveal_seal(&mut self, seal: SealDefinition<GraphSeal>);

/// Ensures that the transition is revealed inside the bundle.
///
Expand All @@ -44,7 +44,7 @@ pub trait BundleExt {
}

impl BundleExt for TransitionBundle {
fn reveal_seal(&mut self, seal: GraphSeal) {
fn reveal_seal(&mut self, seal: SealDefinition<GraphSeal>) {
for (_, item) in self.keyed_values_mut() {
if let Some(transition) = &mut item.transition {
for (_, assign) in transition.assignments.keyed_values_mut() {
Expand Down
4 changes: 2 additions & 2 deletions src/accessors/merge_reveal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use std::collections::BTreeMap;
use amplify::confinement::Confined;
use amplify::Wrapper;
use bp::dbc::anchor::MergeError;
use commit_verify::{mpc, CommitmentId};
use commit_verify::CommitmentId;
use rgb::{
Anchor, AnchoredBundle, Assign, Assignments, BundleItem, ExposedSeal, ExposedState, Extension,
Genesis, OpId, Transition, TransitionBundle, TypedAssigns,
Expand Down Expand Up @@ -64,7 +64,7 @@ pub trait MergeReveal: Sized {
fn merge_reveal(self, other: Self) -> Result<Self, MergeRevealError>;
}

impl MergeReveal for Anchor<mpc::MerkleBlock> {
impl MergeReveal for Anchor {
fn merge_reveal(self, other: Self) -> Result<Self, MergeRevealError> {
self.merge_reveal(other).map_err(MergeRevealError::from)
}
Expand Down
18 changes: 13 additions & 5 deletions src/containers/consignment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ use amplify::confinement::{LargeVec, MediumBlob, SmallOrdMap, TinyOrdMap, TinyOr
use commit_verify::Conceal;
use rgb::validation::{AnchoredBundle, ConsignmentApi};
use rgb::{
validation, AttachId, BundleId, ContractHistory, ContractId, Extension, Genesis, GraphSeal,
OpId, OpRef, Operation, Schema, SchemaId, SecretSeal, SubSchema, Transition, TransitionBundle,
WitnessAnchor,
validation, AssetTag, AssignmentType, AttachId, BundleId, ContractHistory, ContractId,
Extension, Genesis, GraphSeal, OpId, OpRef, Operation, Schema, SchemaId, SealDefinition,
SecretSeal, SubSchema, Transition, TransitionBundle, WitnessAnchor,
};
use strict_encoding::{StrictDeserialize, StrictDumb, StrictSerialize};

Expand Down Expand Up @@ -87,6 +87,9 @@ pub struct Consignment<const TYPE: bool> {
/// Known supplements.
pub supplements: TinyOrdSet<ContractSuppl>,

/// Confidential asset tags.
pub asset_tags: SmallOrdMap<AssignmentType, AssetTag>,

/// Genesis data.
pub genesis: Genesis,

Expand Down Expand Up @@ -120,11 +123,12 @@ impl<const TYPE: bool> Consignment<TYPE> {
assert_eq!(schema.schema_id(), genesis.schema_id);
Consignment {
validation_status: None,
version: ContainerVer::V1,
version: ContainerVer::V2,
transfer: TYPE,
schema,
ifaces: none!(),
supplements: none!(),
asset_tags: none!(),
genesis,
terminals: none!(),
bundles: none!(),
Expand Down Expand Up @@ -214,7 +218,7 @@ impl<const TYPE: bool> Consignment<TYPE> {
Ok(history)
}

pub fn reveal_bundle_seal(&mut self, bundle_id: BundleId, revealed: GraphSeal) {
pub fn reveal_bundle_seal(&mut self, bundle_id: BundleId, revealed: SealDefinition<GraphSeal>) {
for anchored_bundle in &mut self.bundles {
if anchored_bundle.bundle.bundle_id() == bundle_id {
anchored_bundle.bundle.reveal_seal(revealed);
Expand All @@ -230,6 +234,7 @@ impl<const TYPE: bool> Consignment<TYPE> {
schema: self.schema,
ifaces: self.ifaces,
supplements: self.supplements,
asset_tags: self.asset_tags,
genesis: self.genesis,
terminals: self.terminals,
bundles: self.bundles,
Expand All @@ -246,6 +251,9 @@ impl<const TYPE: bool> ConsignmentApi for Consignment<TYPE> {

fn schema(&self) -> &SubSchema { &self.schema }

#[inline]
fn asset_tags(&self) -> &BTreeMap<AssignmentType, AssetTag> { self.asset_tags.as_inner() }

fn operation(&self, opid: OpId) -> Option<OpRef> {
if opid == self.genesis.id() {
return Some(OpRef::Genesis(&self.genesis));
Expand Down
Loading

0 comments on commit b54e775

Please sign in to comment.