Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
huancheng-trili committed Oct 3, 2024
1 parent 3e0a708 commit d2ba88f
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 14 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
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"`
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

0 comments on commit d2ba88f

Please sign in to comment.