feat(addresses): Derive Hash on Address (#235)
authored-by: Turner <mitch@tpfs.io>
This commit is contained in:
parent
7b3708ac46
commit
6ac63a04e2
3 changed files with 10 additions and 10 deletions
|
|
@ -161,7 +161,7 @@ pub struct AddressPayload {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// New type wrapping a Byron address primitive
|
/// New type wrapping a Byron address primitive
|
||||||
#[derive(Debug, Encode, Decode, Clone, PartialEq, Eq, PartialOrd, Ord)]
|
#[derive(Debug, Encode, Decode, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
pub struct ByronAddress {
|
pub struct ByronAddress {
|
||||||
#[n(0)]
|
#[n(0)]
|
||||||
payload: TagWrap<ByteVec, 24>,
|
payload: TagWrap<ByteVec, 24>,
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ pub type TxIdx = u64;
|
||||||
pub type CertIdx = u64;
|
pub type CertIdx = u64;
|
||||||
|
|
||||||
/// An on-chain pointer to a stake key
|
/// An on-chain pointer to a stake key
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
|
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
pub struct Pointer(Slot, TxIdx, CertIdx);
|
pub struct Pointer(Slot, TxIdx, CertIdx);
|
||||||
|
|
||||||
fn slice_to_hash(slice: &[u8]) -> Result<Hash<28>, Error> {
|
fn slice_to_hash(slice: &[u8]) -> Result<Hash<28>, Error> {
|
||||||
|
|
@ -116,7 +116,7 @@ impl Pointer {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The payment part of a Shelley address
|
/// The payment part of a Shelley address
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd)]
|
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Hash)]
|
||||||
pub enum ShelleyPaymentPart {
|
pub enum ShelleyPaymentPart {
|
||||||
Key(PaymentKeyHash),
|
Key(PaymentKeyHash),
|
||||||
Script(ScriptHash),
|
Script(ScriptHash),
|
||||||
|
|
@ -168,7 +168,7 @@ impl ShelleyPaymentPart {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The delegation part of a Shelley address
|
/// The delegation part of a Shelley address
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd)]
|
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Hash)]
|
||||||
pub enum ShelleyDelegationPart {
|
pub enum ShelleyDelegationPart {
|
||||||
Key(StakeKeyHash),
|
Key(StakeKeyHash),
|
||||||
Script(ScriptHash),
|
Script(ScriptHash),
|
||||||
|
|
@ -253,7 +253,7 @@ impl StakePayload {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The network tag of an address
|
/// The network tag of an address
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Hash)]
|
||||||
pub enum Network {
|
pub enum Network {
|
||||||
Testnet,
|
Testnet,
|
||||||
Mainnet,
|
Mainnet,
|
||||||
|
|
@ -271,24 +271,24 @@ impl From<u8> for Network {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A decoded Shelley address
|
/// A decoded Shelley address
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd)]
|
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Hash)]
|
||||||
pub struct ShelleyAddress(Network, ShelleyPaymentPart, ShelleyDelegationPart);
|
pub struct ShelleyAddress(Network, ShelleyPaymentPart, ShelleyDelegationPart);
|
||||||
|
|
||||||
/// The payload of a Stake address
|
/// The payload of a Stake address
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd)]
|
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Hash)]
|
||||||
pub enum StakePayload {
|
pub enum StakePayload {
|
||||||
Stake(StakeKeyHash),
|
Stake(StakeKeyHash),
|
||||||
Script(ScriptHash),
|
Script(ScriptHash),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A decoded Stake address
|
/// A decoded Stake address
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd)]
|
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Hash)]
|
||||||
pub struct StakeAddress(Network, StakePayload);
|
pub struct StakeAddress(Network, StakePayload);
|
||||||
|
|
||||||
pub use byron::ByronAddress;
|
pub use byron::ByronAddress;
|
||||||
|
|
||||||
/// A decoded Cardano address of any type
|
/// A decoded Cardano address of any type
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd)]
|
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Hash)]
|
||||||
pub enum Address {
|
pub enum Address {
|
||||||
Byron(ByronAddress),
|
Byron(ByronAddress),
|
||||||
Shelley(ShelleyAddress),
|
Shelley(ShelleyAddress),
|
||||||
|
|
|
||||||
|
|
@ -337,7 +337,7 @@ impl<T> Deref for CborWrap<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
|
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
pub struct TagWrap<I, const T: u64>(pub I);
|
pub struct TagWrap<I, const T: u64>(pub I);
|
||||||
|
|
||||||
impl<I, const T: u64> TagWrap<I, T> {
|
impl<I, const T: u64> TagWrap<I, T> {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue