Skip to content

Commit

Permalink
Refactoring OwnedState -> Assignment; Assignments -> AssignmentVec
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Mar 25, 2021
1 parent a1c9a91 commit c181be9
Show file tree
Hide file tree
Showing 12 changed files with 450 additions and 430 deletions.
10 changes: 5 additions & 5 deletions rgb20/src/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,9 @@ impl TryFrom<Genesis> for Asset {
for assignment in
genesis.owned_rights_by_type(*OwnedRightsType::Inflation)
{
for state in assignment.to_custom_state() {
for state in assignment.to_data_assignment_vec() {
match state {
OwnedState::Revealed {
Assignment::Revealed {
seal_definition,
assigned_state,
} => {
Expand All @@ -311,7 +311,7 @@ impl TryFrom<Genesis> for Asset {
.ok_or(schema::Error::NotAllFieldsPresent)?,
);
}
OwnedState::ConfidentialSeal { assigned_state, .. } => {
Assignment::ConfidentialSeal { assigned_state, .. } => {
if issue_limit < core::u64::MAX {
issue_limit += assigned_state
.u64()
Expand All @@ -331,11 +331,11 @@ impl TryFrom<Genesis> for Asset {
for assignment in genesis.owned_rights_by_type(*OwnedRightsType::Assets)
{
assignment
.to_discrete_state()
.to_value_assignment_vec()
.into_iter()
.enumerate()
.for_each(|(index, assign)| {
if let OwnedState::Revealed {
if let Assignment::Revealed {
seal_definition:
seal::Revealed::TxOutpoint(outpoint_reveal),
assigned_state,
Expand Down
4 changes: 2 additions & 2 deletions rgb20/src/supply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ impl Issue {

let inflation_assignments = transition
.owned_rights_by_type(*OwnedRightsType::Inflation)
.map(Assignments::as_revealed_owned_value)
.map(AssignmentVec::as_revealed_owned_value)
.transpose()
.map_err(|_| Error::InflationAssignmentConfidential(id))?
.unwrap_or_default()
Expand Down Expand Up @@ -263,7 +263,7 @@ impl TryFrom<&Genesis> for Issue {

let inflation_assignments = genesis
.owned_rights_by_type(*OwnedRightsType::Inflation)
.map(Assignments::as_revealed_owned_value)
.map(AssignmentVec::as_revealed_owned_value)
.transpose()
.map_err(|_| Error::InflationAssignmentConfidential(id))?
.unwrap_or_default()
Expand Down
12 changes: 6 additions & 6 deletions rgb20/src/transitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl Asset {
let mut owned_rights = BTreeMap::new();
owned_rights.insert(
*OwnedRightsType::Assets,
Assignments::zero_balanced(
AssignmentVec::zero_balanced(
vec![value::Revealed {
value: issued_supply,
blinding: secp256k1zkp::key::ONE_KEY.into(),
Expand All @@ -89,10 +89,10 @@ impl Asset {
if !inflation.is_empty() {
owned_rights.insert(
*OwnedRightsType::Inflation,
Assignments::CustomData(
AssignmentVec::CustomData(
inflation
.into_iter()
.map(|(outpoint, value)| OwnedState::Revealed {
.map(|(outpoint, value)| Assignment::Revealed {
seal_definition: SealDefinition::TxOutpoint(
outpoint.into(),
),
Expand All @@ -106,7 +106,7 @@ impl Asset {
if let Some(outpoint) = renomination {
owned_rights.insert(
*OwnedRightsType::Renomination,
Assignments::Declarative(vec![OwnedState::Revealed {
AssignmentVec::Declarative(vec![Assignment::Revealed {
seal_definition: SealDefinition::TxOutpoint(
outpoint.into(),
),
Expand All @@ -118,7 +118,7 @@ impl Asset {
if let Some(outpoint) = epoch {
owned_rights.insert(
*OwnedRightsType::BurnReplace,
Assignments::Declarative(vec![OwnedState::Revealed {
AssignmentVec::Declarative(vec![Assignment::Revealed {
seal_definition: SealDefinition::TxOutpoint(
outpoint.into(),
),
Expand Down Expand Up @@ -218,7 +218,7 @@ impl Asset {
.collect();
let assignments = type_map! {
OwnedRightsType::Assets =>
Assignments::zero_balanced(input_amounts, allocations_ours, allocations_theirs)
AssignmentVec::zero_balanced(input_amounts, allocations_ours, allocations_theirs)
};

let mut parent = ParentOwnedRights::default();
Expand Down
Loading

0 comments on commit c181be9

Please sign in to comment.