Skip to content

Commit

Permalink
Add Protocols method for TzKT
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky committed Jul 19, 2022
1 parent 66db7e0 commit 8098a22
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tzkt/api/protocols.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package api

import (
"context"

"github.com/dipdup-net/go-lib/tzkt/data"
)

// Protocols - Returns a list of protocols.
func (tzkt *API) Protocols(ctx context.Context, args map[string]string) (protocols []data.Protocol, err error) {
err = tzkt.json(ctx, "/v1/protocols", args, false, &protocols)
return
}
59 changes: 59 additions & 0 deletions tzkt/data/general.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,62 @@ type Token struct {
Standard string `json:"standard"`
Metadata stdJSON.RawMessage `json:"metadata,omitempty"`
}

// Protocol -
type Protocol struct {
Code int64 `json:"code"`
Hash string `json:"hash"`
FirstLevel uint64 `json:"firstLevel"`
FirstCycle uint64 `json:"firstCycle"`
FirstCycleLevel uint64 `json:"firstCycleLevel"`
LastLevel uint64 `json:"lastLevel,omitempty"`
Constants *ProtocolConstants `json:"constants,omitempty"`
Metadata *ProtocolMetadata `json:"metadata,omitempty"`
}

// ProtocolConstants -
type ProtocolConstants struct {
RampUpCycles int64 `json:"rampUpCycles"`
NoRewardCycles int64 `json:"noRewardCycles"`
PreservedCycles int64 `json:"preservedCycles"`
BlocksPerCycle int64 `json:"blocksPerCycle"`
BlocksPerCommitment int64 `json:"blocksPerCommitment"`
BlocksPerSnapshot int64 `json:"blocksPerSnapshot"`
BlocksPerVoting int64 `json:"blocksPerVoting"`
TimeBetweenBlocks int64 `json:"timeBetweenBlocks"`
EndorsersPerBlock int64 `json:"endorsersPerBlock"`
HardOperationGasLimit int64 `json:"hardOperationGasLimit"`
HardOperationStorageLimit int64 `json:"hardOperationStorageLimit"`
HardBlockGasLimit int64 `json:"hardBlockGasLimit"`
TokensPerRoll int64 `json:"tokensPerRoll"`
RevelationReward int64 `json:"revelationReward"`
BlockDeposit int64 `json:"blockDeposit"`
BlockReward []int64 `json:"blockReward"`
EndorsementDeposit int64 `json:"endorsementDeposit"`
EndorsementReward []int64 `json:"endorsementReward"`
OriginationSize int64 `json:"originationSize"`
ByteCost int64 `json:"byteCost"`
ProposalQuorum int64 `json:"proposalQuorum"`
BallotQuorumMin int64 `json:"ballotQuorumMin"`
BallotQuorumMax int64 `json:"ballotQuorumMax"`
LbSubsidy int64 `json:"lbSubsidy"`
LbSunsetLevel int64 `json:"lbSunsetLevel"`
LbToggleThreshold int64 `json:"lbToggleThreshold"`
ConsensusThreshold int64 `json:"consensusThreshold"`
MinParticipationNumerator int64 `json:"minParticipationNumerator"`
MinParticipationDenominator int64 `json:"minParticipationDenominator"`
MaxSlashingPeriod int64 `json:"maxSlashingPeriod"`
FrozenDepositsPercentage int64 `json:"frozenDepositsPercentage"`
DoubleBakingPunishment int64 `json:"doubleBakingPunishment"`
DoubleEndorsingPunishmentNumerator int64 `json:"doubleEndorsingPunishmentNumerator"`
DoubleEndorsingPunishmentDenominator int64 `json:"doubleEndorsingPunishmentDenominator"`
TxRollupOriginationSize int64 `json:"txRollupOriginationSize"`
TxRollupCommitmentBond int64 `json:"txRollupCommitmentBond"`
LbEscapeThreshold int64 `json:"lbEscapeThreshold"`
}

// ProtocolConstants -
type ProtocolMetadata struct {
Docs string `json:"docs"`
Alias string `json:"alias"`
}

0 comments on commit 8098a22

Please sign in to comment.