Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Update RPC struct Delegate #21

Merged
merged 20 commits into from
Jan 13, 2025
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## v1.21.0
* Quebec protocol support
* BREAKING CHANGE: Delegate information is remapped due to RPC changes. The full schema can be found at [link](https://gitlab.com/tezos/tezos/-/blob/882112a1978d5774f34a1700c6f5584e650a086b/docs/api/quebec-openapi.json)

## v1.19.2
* Update Parisnet hash
Expand Down
106 changes: 92 additions & 14 deletions rpc/delegates.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"`

Expand All @@ -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,string"`
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 {
Expand Down
Loading