Skip to content

Commit

Permalink
Merge branch 'develop' into fix/rgb-252
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Sep 20, 2024
2 parents 8f056b8 + 3c273cd commit aa6be3d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/contract/assignments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ impl KnownState for RevealedValue {}
impl KnownState for RevealedData {}
impl KnownState for RevealedAttach {}

#[derive(Copy, Clone, Eq, Debug)]
#[allow(clippy::derived_hash_with_manual_eq)]
#[derive(Copy, Clone, Eq, Hash, Debug)]
#[derive(StrictType, StrictDumb, StrictEncode, StrictDecode)]
#[strict_type(lib = LIB_NAME_RGB_STD)]
#[cfg_attr(
Expand Down
12 changes: 11 additions & 1 deletion src/interface/iface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ use amplify::{ByteArray, Bytes32};
use baid64::{Baid64ParseError, DisplayBaid64, FromBaid64Str};
use chrono::{DateTime, TimeZone, Utc};
use commit_verify::{CommitId, CommitmentId, DigestExt, Sha256};
use rgb::{Identity, Occurrences};
use rgb::vm::WitnessOrd;
use rgb::{ContractId, Identity, Occurrences, SchemaId, XWitnessId};
use strict_encoding::{
FieldName, StrictDecode, StrictDeserialize, StrictDumb, StrictEncode, StrictSerialize,
StrictType, TypeName, VariantName,
Expand Down Expand Up @@ -355,6 +356,15 @@ pub trait IfaceWrapper<S: ContractStateRead> {
/// Constructs information object describing a specific class in terms of
/// the interface class.
fn info(&self) -> Self::Info;

/// Returns contract id.
fn contract_id(&self) -> ContractId;

/// Returns schema id of the contract.
fn schema_id(&self) -> SchemaId;

/// Returns information about a witness, if it is known to the contract state.
fn witness_info(&self, witness_id: XWitnessId) -> Option<WitnessOrd>;
}

/// Interface definition.
Expand Down
5 changes: 5 additions & 0 deletions src/persistence/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1082,6 +1082,11 @@ impl<M: Borrow<MemContractState>> ContractStateRead for MemContract<M> {
#[inline]
fn schema_id(&self) -> SchemaId { self.unfiltered.borrow().schema_id }

#[inline]
fn witness_info(&self, witness_id: XWitnessId) -> Option<WitnessOrd> {
self.filter.get(&witness_id).copied()
}

Check warning on line 1088 in src/persistence/memory.rs

View check run for this annotation

Codecov / codecov/patch

src/persistence/memory.rs#L1086-L1088

Added lines #L1086 - L1088 were not covered by tests

#[inline]
fn rights_all(&self) -> impl Iterator<Item = &OutputAssignment<VoidState>> {
self.unfiltered
Expand Down
1 change: 1 addition & 0 deletions src/persistence/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ pub trait StateWriteProvider: StoreTransaction<TransactionErr = Self::Error> {
pub trait ContractStateRead: ContractStateAccess {
fn contract_id(&self) -> ContractId;
fn schema_id(&self) -> SchemaId;
fn witness_info(&self, witness_id: XWitnessId) -> Option<WitnessOrd>;
fn rights_all(&self) -> impl Iterator<Item = &OutputAssignment<VoidState>>;
fn fungible_all(&self) -> impl Iterator<Item = &OutputAssignment<RevealedValue>>;
fn data_all(&self) -> impl Iterator<Item = &OutputAssignment<RevealedData>>;
Expand Down

0 comments on commit aa6be3d

Please sign in to comment.