Skip to content
423 changes: 228 additions & 195 deletions codec/src/map_parameters.rs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion common/src/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ pub struct AssetDeltasMessage {
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct TxCertificatesMessage {
/// Ordered set of certificates
pub certificates: Vec<TxCertificate>,
pub certificates: Vec<TxCertificateWithPos>,
}

/// Address deltas message
Expand Down
63 changes: 49 additions & 14 deletions common/src/queries/accounts.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::collections::HashMap;

use crate::{DRepChoice, KeyHash, PoolLiveStakeInfo, StakeAddress};
use crate::{DRepChoice, KeyHash, PoolId, PoolLiveStakeInfo, StakeAddress, TxIdentifier};

pub const DEFAULT_ACCOUNTS_QUERY_TOPIC: (&str, &str) =
("accounts-state-query-topic", "cardano.query.accounts");
Expand All @@ -15,10 +15,10 @@ pub enum AccountsStateQuery {
GetAccountInfo { stake_address: StakeAddress },
GetAccountRewardHistory { stake_key: Vec<u8> },
GetAccountHistory { stake_key: Vec<u8> },
GetAccountDelegationHistory { stake_key: Vec<u8> },
GetAccountRegistrationHistory { stake_key: Vec<u8> },
GetAccountRegistrationHistory { account: StakeAddress },
GetAccountDelegationHistory { account: StakeAddress },
GetAccountMIRHistory { account: StakeAddress },
GetAccountWithdrawalHistory { stake_key: Vec<u8> },
GetAccountMIRHistory { stake_key: Vec<u8> },
GetAccountAssociatedAddresses { stake_key: Vec<u8> },
GetAccountAssets { stake_key: Vec<u8> },
GetAccountAssetsTotals { stake_key: Vec<u8> },
Expand Down Expand Up @@ -49,10 +49,10 @@ pub enum AccountsStateQueryResponse {
AccountInfo(AccountInfo),
AccountRewardHistory(AccountRewardHistory),
AccountHistory(AccountHistory),
AccountDelegationHistory(AccountDelegationHistory),
AccountRegistrationHistory(AccountRegistrationHistory),
AccountRegistrationHistory(Vec<RegistrationUpdate>),
AccountDelegationHistory(Vec<DelegationUpdate>),
AccountMIRHistory(Vec<AccountWithdrawal>),
AccountWithdrawalHistory(AccountWithdrawalHistory),
AccountMIRHistory(AccountMIRHistory),
AccountAssociatedAddresses(AccountAssociatedAddresses),
AccountAssets(AccountAssets),
AccountAssetsTotals(AccountAssetsTotals),
Expand Down Expand Up @@ -97,17 +97,52 @@ pub struct AccountRewardHistory {}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct AccountHistory {}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct AccountDelegationHistory {}
#[derive(
Debug, Clone, serde::Serialize, serde::Deserialize, minicbor::Decode, minicbor::Encode,
)]
pub struct DelegationUpdate {
#[n(0)]
pub active_epoch: u32,
#[n(1)]
pub tx_identifier: TxIdentifier,
#[n(2)]
pub amount: u64,
#[n(3)]
pub pool: PoolId,
}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct AccountRegistrationHistory {}
#[derive(
Debug, Clone, serde::Serialize, serde::Deserialize, minicbor::Decode, minicbor::Encode,
)]
pub struct RegistrationUpdate {
#[n(0)]
pub tx_identifier: TxIdentifier,
#[n(1)]
pub status: RegistrationStatus,
}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct AccountWithdrawalHistory {}
#[derive(
Debug, Clone, serde::Serialize, serde::Deserialize, minicbor::Decode, minicbor::Encode,
)]
pub enum RegistrationStatus {
#[n(0)]
Registered,
#[n(1)]
Deregistered,
}

#[derive(
Debug, Clone, serde::Serialize, serde::Deserialize, minicbor::Decode, minicbor::Encode,
)]
pub struct AccountWithdrawal {
#[n(0)]
pub tx_identifier: TxIdentifier,
#[n(1)]
pub amount: u64,
}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct AccountMIRHistory {}
pub struct AccountWithdrawalHistory {}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct AccountAssociatedAddresses {}
Expand Down
6 changes: 3 additions & 3 deletions common/src/queries/governance.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::collections::HashMap;

use crate::{
Anchor, DRepCredential, GovActionId, Lovelace, ProposalProcedure, StakeAddress, TxHash, Vote,
Voter, VotingProcedure,
Anchor, DRepCredential, GovActionId, Lovelace, ProposalProcedure, StakeAddress, TxHash,
TxIdentifier, Vote, Voter, VotingProcedure,
};

pub const DEFAULT_DREPS_QUERY_TOPIC: (&str, &str) =
Expand Down Expand Up @@ -77,7 +77,7 @@ pub struct DRepUpdates {

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct DRepUpdateEvent {
pub tx_hash: TxHash,
pub tx_identifier: TxIdentifier,
pub cert_index: u64,
pub action: DRepActionUpdate,
}
Expand Down
73 changes: 18 additions & 55 deletions common/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -808,14 +808,6 @@ pub struct PoolMetadata {
pub hash: DataHash,
}

/// Pool registration with position
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct PoolRegistrationWithPos {
pub reg: PoolRegistration,
pub tx_hash: TxHash,
pub cert_index: u64,
}

/// Pool registration data
#[serde_as]
#[derive(
Expand Down Expand Up @@ -869,14 +861,6 @@ pub struct PoolRegistration {
pub pool_metadata: Option<PoolMetadata>,
}

// Pool Retirment with position
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct PoolRetirementWithPos {
pub ret: PoolRetirement,
pub tx_hash: TxHash,
pub cert_index: u64,
}

/// Pool retirement data
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct PoolRetirement {
Expand All @@ -897,23 +881,23 @@ pub enum PoolUpdateAction {
/// Pool Update Event
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PoolUpdateEvent {
pub tx_hash: TxHash,
pub tx_identifier: TxIdentifier,
pub cert_index: u64,
pub action: PoolUpdateAction,
}

impl PoolUpdateEvent {
pub fn register_event(tx_hash: TxHash, cert_index: u64) -> Self {
pub fn register_event(tx_identifier: TxIdentifier, cert_index: u64) -> Self {
Self {
tx_hash,
tx_identifier,
cert_index,
action: PoolUpdateAction::Registered,
}
}

pub fn retire_event(tx_hash: TxHash, cert_index: u64) -> Self {
pub fn retire_event(tx_identifier: TxIdentifier, cert_index: u64) -> Self {
Self {
tx_hash,
tx_identifier,
cert_index,
action: PoolUpdateAction::Deregistered,
}
Expand Down Expand Up @@ -1140,13 +1124,6 @@ pub struct DRepRegistration {
pub anchor: Option<Anchor>,
}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct DRepRegistrationWithPos {
pub reg: DRepRegistration,
pub tx_hash: TxHash,
pub cert_index: u64,
}

/// DRep Deregistration = unreg_drep_cert
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct DRepDeregistration {
Expand All @@ -1157,13 +1134,6 @@ pub struct DRepDeregistration {
pub refund: Lovelace,
}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct DRepDeregistrationWithPos {
pub reg: DRepDeregistration,
pub tx_hash: TxHash,
pub cert_index: u64,
}

/// DRep Update = update_drep_cert
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct DRepUpdate {
Expand All @@ -1174,13 +1144,6 @@ pub struct DRepUpdate {
pub anchor: Option<Anchor>,
}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct DRepUpdateWithPos {
pub reg: DRepUpdate,
pub tx_hash: TxHash,
pub cert_index: u64,
}

pub type CommitteeCredential = Credential;

/// Authorise a committee hot credential
Expand Down Expand Up @@ -1794,21 +1757,14 @@ pub struct GovernanceOutcome {
pub action_to_perform: GovernanceOutcomeVariant,
}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct StakeAddressWithPos {
pub stake_address: StakeAddress,
pub tx_index: u64,
pub cert_index: u64,
}

/// Certificate in a transaction
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub enum TxCertificate {
/// Default
None(()),

/// Stake registration
StakeRegistration(StakeAddressWithPos),
StakeRegistration(StakeAddress),

/// Stake de-registration
StakeDeregistration(StakeAddress),
Expand All @@ -1817,10 +1773,10 @@ pub enum TxCertificate {
StakeDelegation(StakeDelegation),

/// Pool registration
PoolRegistrationWithPos(PoolRegistrationWithPos),
PoolRegistration(PoolRegistration),

/// Pool retirement
PoolRetirementWithPos(PoolRetirementWithPos),
PoolRetirement(PoolRetirement),

/// Genesis key delegation
GenesisKeyDelegation(GenesisKeyDelegation),
Expand Down Expand Up @@ -1856,13 +1812,20 @@ pub enum TxCertificate {
ResignCommitteeCold(ResignCommitteeCold),

/// DRep registration
DRepRegistration(DRepRegistrationWithPos),
DRepRegistration(DRepRegistration),

/// DRep deregistration
DRepDeregistration(DRepDeregistrationWithPos),
DRepDeregistration(DRepDeregistration),

/// DRep update
DRepUpdate(DRepUpdateWithPos),
DRepUpdate(DRepUpdate),
}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct TxCertificateWithPos {
pub cert: TxCertificate,
pub tx_identifier: TxIdentifier,
pub cert_index: u64,
}

#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
Expand Down
Loading