From d2ba88f1c59c19c468f9e9270c65430ea444f503 Mon Sep 17 00:00:00 2001 From: Huan-Cheng Chang Date: Wed, 18 Sep 2024 10:50:10 +0100 Subject: [PATCH] update --- CHANGELOG.md | 3 ++ rpc/delegates.go | 106 ++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 95 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 58899e8..447537d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## v1.21.0 +* BREAKING CHANGE: Delegate information is remapped due to RPC changes. The full schema can be found at [link]() + ## v1.19.2 * Update Parisnet hash * Update protocol history of ghostnet diff --git a/rpc/delegates.go b/rpc/delegates.go index 2148f98..d9a396d 100644 --- a/rpc/delegates.go +++ b/rpc/delegates.go @@ -11,6 +11,20 @@ import ( "github.com/trilitech/tzgo/tezos" ) +// v021+ +type MisbehaviourKind string +type Vote string + +const ( + MisbehaviourAttestation MisbehaviourKind = "attestation" + MisbehaviourBlock MisbehaviourKind = "block" + MisbehaviourPreattestation MisbehaviourKind = "preattestation" + + VoteNay Vote = "nay" + VoteYay Vote = "yay" + VotePass Vote = "pass" +) + // Delegate holds information about an active delegate type Delegate struct { // extra info @@ -19,23 +33,27 @@ type Delegate struct { Block string `json:"-"` // tezos data - Deactivated bool `json:"deactivated"` - Balance int64 `json:"balance,string"` - DelegatedContracts []tezos.Address `json:"delegated_contracts"` - FrozenBalance int64 `json:"frozen_balance,string"` - FrozenBalanceByCycle []CycleBalance `json:"frozen_balance_by_cycle"` - GracePeriod int64 `json:"grace_period"` - StakingBalance int64 `json:"staking_balance,string"` - DelegatedBalance int64 `json:"delegated_balance,string"` - VotingPower Int64orString `json:"voting_power"` - - // v012+ + Deactivated bool `json:"deactivated"` + GracePeriod int64 `json:"grace_period"` + VotingPower Int64orString `json:"voting_power"` + + // -v011 + FrozenBalanceByCycle []CycleBalance `json:"frozen_balance_by_cycle"` + FrozenBalance int64 `json:"frozen_balance,string"` + Balance int64 `json:"balance,string"` + + // -v020 + StakingBalance int64 `json:"staking_balance,string"` + DelegatedContracts []tezos.Address `json:"delegated_contracts"` + DelegatedBalance int64 `json:"delegated_balance,string"` + + // v012-v020 FullBalance int64 `json:"full_balance,string"` FrozenDeposits int64 `json:"frozen_deposits,string"` CurrentFrozenDeposits int64 `json:"current_frozen_deposits,string"` FrozenDepositsLimit int64 `json:"frozen_deposits_limit,string"` - // v015+ + // v015-v020 ActiveConsensusKey tezos.Address `json:"active_consensus_key"` PendingConsensusKeys []CycleKey `json:"pending_consensus_keys"` @@ -44,14 +62,74 @@ type Delegate struct { Amount int64 `json:"amount,string"` Level LevelInfo `json:"level"` } `json:"min_delegated_in_current_cycle"` + StakingDenominator int64 `json:"staking_denominator,string"` + + // v019-v020 PendingDenunciations bool `json:"pending_denunciations"` - TotalDelegatedStake int64 `json:"total_delegated_stakem,string"` - StakingDenominator int64 `json:"staking_denominator,string"` + TotalDelegatedStake int64 `json:"total_delegated_stake,string"` + + // v021+ + IsForbidden bool `json:"is_forbidden"` + Participation struct { + ExpectedCycleActivity int64 `json:"expected_cycle_activity"` + MinimalCycleActivity int64 `json:"minimal_cycle_activity"` + MissedSlots int64 `json:"missed_slots"` + MissedLevels int64 `json:"missed_levels"` + RemainingAllowedMissedSlots int64 `json:"remaining_allowed_missed_slots"` + ExpectedAttestingRewards uint64 `json:"expected_attesting_rewards,string"` + } `json:"participation"` + ActiveStakingParameters StakingParameters `json:"active_staking_parameters"` + PendingStakingParameters []struct { + Cycle int64 `json:"cycle"` + Parameters StakingParameters `json:"parameters"` + } `json:"pending_staking_parameters"` + BakingPower int64 `json:"baking_power,string"` + TotalStaked uint64 `json:"total_staked,string"` + TotalDelegated uint64 `json:"total_delegated,string"` + OwnFullBalance uint64 `json:"own_full_balance,string"` + OwnStaked uint64 `json:"own_staked,string"` + OwnDelegated uint64 `json:"own_delegated,string"` + ExternalStaked uint64 `json:"external_staked,string"` + ExternalDelegated uint64 `json:"external_delegated,string"` + TotalUnstakedPerCycle struct { + Cycle int64 `json:"cycle"` + Deposit uint64 `json:"deposit,string"` + } `json:"total_unstaked_per_cycle"` + Denunciations []struct { + OperationHash tezos.OpHash `json:"operation_hash"` + Rewarded tezos.Address `json:"rewarded"` + Misbehaviour struct { + Level uint64 `json:"level"` + Round int64 `json:"round"` + Kind MisbehaviourKind `json:"kind,string"` + } `json:"misbehaviour"` + } `json:"denunciations"` + EstimatedSharedPendingSlashedAmount uint64 `json:"estimated_shared_pending_slashed_amount,string"` + CurrentVotingPower uint64 `json:"current_voting_power,string"` + VotingInfo struct { + VotingPower int64 `json:"voting_power"` + CurrentBallot Vote `json:"current_ballot"` + CurrentProposals []tezos.ProtocolHash `json:"current_proposals"` + RemainingProposals int64 `json:"remaining_proposals"` + } `json:"voting_info"` + ConsensusKey struct { + Active struct { + Pkh tezos.Address `json:"pkh"` + Pk tezos.Key `json:"pk"` + } `json:"active"` + Pendings []CycleKey `json:"pendings"` + } `json:"consensus_key"` + Stakers []struct { + Staker tezos.Address `json:"staker"` + FrozenDeposit uint64 `json:"frozen_deposit,string"` + } `json:"stakers"` + Delegators []tezos.Address `json:"delegators"` } type CycleKey struct { Cycle int64 `json:"cycle"` Pkh tezos.Address `json:"pkh"` + Pk tezos.Key `json:"pk"` } type CycleBalance struct {