Skip to content

Commit

Permalink
Add metadata and withdraw mappings
Browse files Browse the repository at this point in the history
  • Loading branch information
d0cd committed Jun 14, 2024
1 parent 7e31e10 commit 8e8fd2b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
12 changes: 12 additions & 0 deletions synthesizer/src/vm/finalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1268,12 +1268,24 @@ impl<N: Network, C: ConsensusStorage<N>> VM<N, C> {

// Write the delegated mapping as JSON.
history.store_mapping(state.block_height(), MappingName::Delegated, &next_delegated_map)?;

// Write the bonded mapping as JSON.
history.store_mapping(state.block_height(), MappingName::Bonded, &next_bonded_map)?;

// Write the metadata mapping as JSON.
let metadata_mapping = Identifier::from_str("metadata")?;
let metadata_map = store.get_mapping_speculative(program_id, metadata_mapping)?;
history.store_mapping(state.block_height(), MappingName::Metadata, &metadata_map)?;

// Write the unbonding mapping as JSON.
let unbonding_mapping = Identifier::from_str("unbonding")?;
let unbonding_map = store.get_mapping_speculative(program_id, unbonding_mapping)?;
history.store_mapping(state.block_height(), MappingName::Unbonding, &unbonding_map)?;

// Write the withdraw mapping as JSON.
let withdraw_mapping = Identifier::from_str("withdraw")?;
let withdraw_map = store.get_mapping_speculative(program_id, withdraw_mapping)?;
history.store_mapping(state.block_height(), MappingName::Withdraw, &withdraw_map)?;
}
}

Expand Down
6 changes: 6 additions & 0 deletions synthesizer/src/vm/helpers/history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,22 @@ pub enum MappingName {
Bonded,
/// The `delegated` mapping.
Delegated,
/// The `metadata` mapping.
Metadata,
/// The `unbonding` mapping.
Unbonding,
/// The `withdraw` mapping.
Withdraw,
}

impl Display for MappingName {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
Self::Bonded => write!(f, "bonded"),
Self::Delegated => write!(f, "delegated"),
Self::Metadata => write!(f, "metadata"),
Self::Unbonding => write!(f, "unbonding"),
Self::Withdraw => write!(f, "withdraw"),
}
}
}
Expand Down

0 comments on commit 8e8fd2b

Please sign in to comment.