Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing operation history #273

Merged
merged 23 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
0fc15c9
contract: derive Hash for OutputAssignment
dr-orlovsky Sep 7, 2024
ef4679f
contract: add ContractStateRead::witness_info allowing wallets to acc…
dr-orlovsky Sep 11, 2024
d1d134d
iface: add contract state accessing methods to IfaceWrapper
dr-orlovsky Sep 11, 2024
427931f
chore: fix clippy lint
dr-orlovsky Sep 11, 2024
3c273cd
Merge branch 'fix/271' into develop
dr-orlovsky Sep 18, 2024
1ba9a8b
iface: remove IfaceOp, which should be handled at RGB wallet
dr-orlovsky Sep 20, 2024
806d735
iface: remove unused methods from ContractIface
dr-orlovsky Sep 20, 2024
e75e07a
contract: doc method OutputAssignment::transmute
dr-orlovsky Sep 20, 2024
8f056b8
iface: refactor OutpointFilter into AssignmentsFilter
dr-orlovsky Sep 20, 2024
aa6be3d
Merge branch 'develop' into fix/rgb-252
dr-orlovsky Sep 20, 2024
0ca8164
iface: refactor contract operation history deduction
dr-orlovsky Sep 20, 2024
b8748b7
iface: remove StateChange to simplify APIs
dr-orlovsky Sep 20, 2024
a3ba340
iface: differentiate fungible and non-fungible operations
dr-orlovsky Sep 20, 2024
53fa9a5
iface: support non-fungible history
dr-orlovsky Sep 20, 2024
d5170f9
iface: remove code duplication for history methods
dr-orlovsky Sep 20, 2024
4edbacf
iface: make history methods free of errors
dr-orlovsky Sep 20, 2024
dbfa80b
iface: simplify contract operations type hierarchy
dr-orlovsky Sep 20, 2024
268a318
iface: impl Display for OpDirection
dr-orlovsky Sep 20, 2024
0a0ed66
iface: make ContractOp fields public
dr-orlovsky Sep 20, 2024
77f6ab8
persistence: add Stock::contract_info method
dr-orlovsky Sep 20, 2024
2c915f8
iface: history - ignore blank transitions, fix spent calculation
dr-orlovsky Sep 20, 2024
24af8a5
contract: export WitnessInfo
dr-orlovsky Sep 20, 2024
94b5ebc
chore: fix clippy lints
dr-orlovsky Sep 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 46 additions & 12 deletions src/contract/assignments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use std::cmp::Ordering;
use std::collections::HashMap;
use std::fmt::Debug;
use std::hash::Hash;

use amplify::confinement::SmallVec;
use commit_verify::Conceal;
Expand All @@ -39,18 +40,50 @@
/// Trait used by contract state. Unlike [`ExposedState`] it doesn't allow
/// concealment of the state, i.e. may contain incomplete data without blinding
/// factors, asset tags etc.
pub trait KnownState: Debug + StrictDumb + StrictEncode + StrictDecode + Eq + Clone {}

impl KnownState for () {}
impl KnownState for VoidState {}
impl KnownState for DataState {}
impl KnownState for Amount {}
impl KnownState for AttachState {}
impl KnownState for RevealedValue {}
impl KnownState for RevealedData {}
impl KnownState for RevealedAttach {}

#[derive(Copy, Clone, Eq, Debug)]
pub trait KnownState: Debug + StrictDumb + StrictEncode + StrictDecode + Eq + Clone + Hash {
const IS_FUNGIBLE: bool;
}

impl KnownState for () {
const IS_FUNGIBLE: bool = false;
}
impl KnownState for VoidState {
const IS_FUNGIBLE: bool = false;
}
impl KnownState for DataState {
const IS_FUNGIBLE: bool = false;
}
impl KnownState for Amount {
const IS_FUNGIBLE: bool = true;
}
impl KnownState for AttachState {
const IS_FUNGIBLE: bool = false;
}
impl KnownState for RevealedValue {
const IS_FUNGIBLE: bool = true;
}
impl KnownState for RevealedData {
const IS_FUNGIBLE: bool = false;
}
impl KnownState for RevealedAttach {
const IS_FUNGIBLE: bool = false;
}

#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
#[derive(StrictType, StrictDumb, StrictEncode, StrictDecode)]

Check warning on line 73 in src/contract/assignments.rs

View check run for this annotation

Codecov / codecov/patch

src/contract/assignments.rs#L73

Added line #L73 was not covered by tests
#[strict_type(lib = LIB_NAME_RGB_STD)]
#[cfg_attr(
feature = "serde",
derive(Serialize, Deserialize),

Check warning on line 77 in src/contract/assignments.rs

View check run for this annotation

Codecov / codecov/patch

src/contract/assignments.rs#L77

Added line #L77 was not covered by tests
serde(crate = "serde_crate", rename_all = "camelCase")
)]
pub struct WitnessInfo {
pub id: XWitnessId,
pub ord: WitnessOrd,
}

#[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 Expand Up @@ -142,6 +175,7 @@
}
}

/// Transmutes output assignment from one form of state to another
pub fn transmute<S: KnownState + From<State>>(self) -> OutputAssignment<S> {
OutputAssignment {
opout: self.opout,
Expand Down
2 changes: 1 addition & 1 deletion src/contract/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ mod assignments;
mod bundle;
mod merge_reveal;

pub use assignments::{KnownState, OutputAssignment, TypedAssignsExt};
pub use assignments::{KnownState, OutputAssignment, TypedAssignsExt, WitnessInfo};
pub use bundle::{BundleExt, RevealError};
pub use merge_reveal::{MergeReveal, MergeRevealError};
use rgb::vm::OrdOpRef;
Expand Down
Loading
Loading