Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
193 changes: 119 additions & 74 deletions codec/src/map_parameters.rs

Large diffs are not rendered by default.

53 changes: 39 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,42 @@ 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 deregistered: bool,
}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct AccountWithdrawalHistory {}
#[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
99 changes: 75 additions & 24 deletions common/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -782,8 +782,8 @@ pub struct PoolMetadata {
/// Pool registration with position
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct PoolRegistrationWithPos {
pub reg: PoolRegistration,
pub tx_hash: TxHash,
pub cert: PoolRegistration,
pub tx_identifier: TxIdentifier,
pub cert_index: u64,
}

Expand Down Expand Up @@ -843,8 +843,8 @@ pub struct PoolRegistration {
// Pool Retirment with position
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct PoolRetirementWithPos {
pub ret: PoolRetirement,
pub tx_hash: TxHash,
pub cert: PoolRetirement,
pub tx_identifier: TxIdentifier,
pub cert_index: u64,
}

Expand All @@ -868,23 +868,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 @@ -921,6 +921,12 @@ pub struct StakeDelegation {
pub operator: KeyHash,
}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct StakeDelegationWithPos {
pub cert: StakeDelegation,
pub tx_identifier: TxIdentifier,
}

/// SPO total delegation data (for SPDD)
#[derive(Debug, Clone, Copy, serde::Serialize, serde::Deserialize, PartialEq)]
pub struct DelegatedStake {
Expand Down Expand Up @@ -981,6 +987,12 @@ pub struct MoveInstantaneousReward {
pub target: InstantaneousRewardTarget,
}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct MoveInstantaneousRewardWithPos {
pub cert: MoveInstantaneousReward,
pub tx_identifier: TxIdentifier,
}

/// Register stake (Conway version) = 'reg_cert'
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct Registration {
Expand All @@ -991,6 +1003,13 @@ pub struct Registration {
pub deposit: Lovelace,
}

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

/// Deregister stake (Conway version) = 'unreg_cert'
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct Deregistration {
Expand All @@ -1001,6 +1020,13 @@ pub struct Deregistration {
pub refund: Lovelace,
}

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

/// DRepChoice (=CDDL drep, badly named)
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize)]
pub enum DRepChoice {
Expand Down Expand Up @@ -1040,6 +1066,12 @@ pub struct StakeAndVoteDelegation {
pub drep: DRepChoice,
}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct StakeAndVoteDelegationWithPos {
pub cert: StakeAndVoteDelegation,
pub tx_identifier: TxIdentifier,
}

/// Stake delegation to SPO + registration = stake_reg_deleg_cert
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct StakeRegistrationAndDelegation {
Expand All @@ -1053,6 +1085,12 @@ pub struct StakeRegistrationAndDelegation {
pub deposit: Lovelace,
}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct StakeRegistrationAndDelegationWithPos {
pub cert: StakeRegistrationAndDelegation,
pub tx_identifier: TxIdentifier,
}

/// Vote delegation to DRep + registration = vote_reg_deleg_cert
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct StakeRegistrationAndVoteDelegation {
Expand All @@ -1066,6 +1104,12 @@ pub struct StakeRegistrationAndVoteDelegation {
pub deposit: Lovelace,
}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct StakeRegistrationAndVoteDelegationWithPos {
pub cert: StakeRegistrationAndVoteDelegation,
pub tx_identifier: TxIdentifier,
}

/// All the trimmings:
/// Vote delegation to DRep + Stake delegation to SPO + registration
/// = stake_vote_reg_deleg_cert
Expand All @@ -1084,6 +1128,12 @@ pub struct StakeRegistrationAndStakeAndVoteDelegation {
pub deposit: Lovelace,
}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct StakeRegistrationAndStakeAndVoteDelegationWithPos {
pub cert: StakeRegistrationAndStakeAndVoteDelegation,
pub tx_identifier: TxIdentifier,
}

/// Anchor
#[serde_as]
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize)]
Expand Down Expand Up @@ -1113,8 +1163,8 @@ pub struct DRepRegistration {

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

Expand All @@ -1130,8 +1180,8 @@ pub struct DRepDeregistration {

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

Expand All @@ -1147,8 +1197,8 @@ pub struct DRepUpdate {

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

Expand Down Expand Up @@ -1768,6 +1818,7 @@ pub struct GovernanceOutcome {
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct StakeAddressWithPos {
pub stake_address: StakeAddress,
pub tx_identifier: TxIdentifier,
pub tx_index: u64,
pub cert_index: u64,
}
Expand All @@ -1782,10 +1833,10 @@ pub enum TxCertificate {
StakeRegistration(StakeAddressWithPos),

/// Stake de-registration
StakeDeregistration(StakeAddress),
StakeDeregistration(StakeAddressWithPos),

/// Stake Delegation to a pool
StakeDelegation(StakeDelegation),
StakeDelegation(StakeDelegationWithPos),

/// Pool registration
PoolRegistrationWithPos(PoolRegistrationWithPos),
Expand All @@ -1797,28 +1848,28 @@ pub enum TxCertificate {
GenesisKeyDelegation(GenesisKeyDelegation),

/// Move instantaneous rewards
MoveInstantaneousReward(MoveInstantaneousReward),
MoveInstantaneousReward(MoveInstantaneousRewardWithPos),

/// New stake registration
Registration(Registration),
Registration(RegistrationWithPos),

/// Stake deregistration
Deregistration(Deregistration),
Deregistration(DeregistrationWithPos),

/// Vote delegation
VoteDelegation(VoteDelegation),

/// Combined stake and vote delegation
StakeAndVoteDelegation(StakeAndVoteDelegation),
StakeAndVoteDelegation(StakeAndVoteDelegationWithPos),

/// Stake registration and SPO delegation
StakeRegistrationAndDelegation(StakeRegistrationAndDelegation),
StakeRegistrationAndDelegation(StakeRegistrationAndDelegationWithPos),

/// Stake registration and vote delegation
StakeRegistrationAndVoteDelegation(StakeRegistrationAndVoteDelegation),
StakeRegistrationAndVoteDelegation(StakeRegistrationAndVoteDelegationWithPos),

/// Stake registration and combined SPO and vote delegation
StakeRegistrationAndStakeAndVoteDelegation(StakeRegistrationAndStakeAndVoteDelegation),
StakeRegistrationAndStakeAndVoteDelegation(StakeRegistrationAndStakeAndVoteDelegationWithPos),

/// Authorise a committee hot credential
AuthCommitteeHot(AuthCommitteeHot),
Expand Down
Loading