Skip to content

Commit

Permalink
Removed is_any_shielded_action_balance_key and related code since tha…
Browse files Browse the repository at this point in the history
…ts no longer used.
  • Loading branch information
murisi committed Jun 19, 2024
1 parent a2854e7 commit 6739f0b
Showing 1 changed file with 0 additions and 41 deletions.
41 changes: 0 additions & 41 deletions crates/trans_token/src/storage_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,44 +192,3 @@ pub fn is_any_minted_balance_key(key: &storage::Key) -> Option<&Address> {
_ => None,
}
}

/// The owner of a shielded action transfer, could be a proper address or the
/// minted subkey
pub enum ShieldedActionOwner<'key> {
/// A proper address
Owner(&'key Address),
/// The mint address
Minted,
}

impl ShieldedActionOwner<'_> {
/// Convert the shielded action owner to an address
pub fn to_address_ref(&self) -> &Address {
match self {
Self::Owner(addr) => addr,
Self::Minted => &Address::Internal(InternalAddress::Ibc),
}
}

/// Get the balance key corresponding to this shielded action owner
pub fn to_balance_key(&self, token: &Address) -> storage::Key {
match self {
ShieldedActionOwner::Owner(addr) => balance_key(token, addr),
ShieldedActionOwner::Minted => minted_balance_key(token),
}
}
}

/// Check if the given storage key is a balance key for a shielded action. If it
/// is, returns the token and the owner addresses.
pub fn is_any_shielded_action_balance_key(
key: &storage::Key,
) -> Option<(&Address, ShieldedActionOwner<'_>)> {
is_any_token_balance_key(key).map_or_else(
|| {
is_any_minted_balance_key(key)
.map(|token| (token, ShieldedActionOwner::Minted))
},
|[token, owner]| Some((token, ShieldedActionOwner::Owner(owner))),
)
}

0 comments on commit 6739f0b

Please sign in to comment.