Skip to content

Commit 8098a22

Browse files
Add Protocols method for TzKT
1 parent 66db7e0 commit 8098a22

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

tzkt/api/protocols.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package api
2+
3+
import (
4+
"context"
5+
6+
"github.com/dipdup-net/go-lib/tzkt/data"
7+
)
8+
9+
// Protocols - Returns a list of protocols.
10+
func (tzkt *API) Protocols(ctx context.Context, args map[string]string) (protocols []data.Protocol, err error) {
11+
err = tzkt.json(ctx, "/v1/protocols", args, false, &protocols)
12+
return
13+
}

tzkt/data/general.go

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,62 @@ type Token struct {
7373
Standard string `json:"standard"`
7474
Metadata stdJSON.RawMessage `json:"metadata,omitempty"`
7575
}
76+
77+
// Protocol -
78+
type Protocol struct {
79+
Code int64 `json:"code"`
80+
Hash string `json:"hash"`
81+
FirstLevel uint64 `json:"firstLevel"`
82+
FirstCycle uint64 `json:"firstCycle"`
83+
FirstCycleLevel uint64 `json:"firstCycleLevel"`
84+
LastLevel uint64 `json:"lastLevel,omitempty"`
85+
Constants *ProtocolConstants `json:"constants,omitempty"`
86+
Metadata *ProtocolMetadata `json:"metadata,omitempty"`
87+
}
88+
89+
// ProtocolConstants -
90+
type ProtocolConstants struct {
91+
RampUpCycles int64 `json:"rampUpCycles"`
92+
NoRewardCycles int64 `json:"noRewardCycles"`
93+
PreservedCycles int64 `json:"preservedCycles"`
94+
BlocksPerCycle int64 `json:"blocksPerCycle"`
95+
BlocksPerCommitment int64 `json:"blocksPerCommitment"`
96+
BlocksPerSnapshot int64 `json:"blocksPerSnapshot"`
97+
BlocksPerVoting int64 `json:"blocksPerVoting"`
98+
TimeBetweenBlocks int64 `json:"timeBetweenBlocks"`
99+
EndorsersPerBlock int64 `json:"endorsersPerBlock"`
100+
HardOperationGasLimit int64 `json:"hardOperationGasLimit"`
101+
HardOperationStorageLimit int64 `json:"hardOperationStorageLimit"`
102+
HardBlockGasLimit int64 `json:"hardBlockGasLimit"`
103+
TokensPerRoll int64 `json:"tokensPerRoll"`
104+
RevelationReward int64 `json:"revelationReward"`
105+
BlockDeposit int64 `json:"blockDeposit"`
106+
BlockReward []int64 `json:"blockReward"`
107+
EndorsementDeposit int64 `json:"endorsementDeposit"`
108+
EndorsementReward []int64 `json:"endorsementReward"`
109+
OriginationSize int64 `json:"originationSize"`
110+
ByteCost int64 `json:"byteCost"`
111+
ProposalQuorum int64 `json:"proposalQuorum"`
112+
BallotQuorumMin int64 `json:"ballotQuorumMin"`
113+
BallotQuorumMax int64 `json:"ballotQuorumMax"`
114+
LbSubsidy int64 `json:"lbSubsidy"`
115+
LbSunsetLevel int64 `json:"lbSunsetLevel"`
116+
LbToggleThreshold int64 `json:"lbToggleThreshold"`
117+
ConsensusThreshold int64 `json:"consensusThreshold"`
118+
MinParticipationNumerator int64 `json:"minParticipationNumerator"`
119+
MinParticipationDenominator int64 `json:"minParticipationDenominator"`
120+
MaxSlashingPeriod int64 `json:"maxSlashingPeriod"`
121+
FrozenDepositsPercentage int64 `json:"frozenDepositsPercentage"`
122+
DoubleBakingPunishment int64 `json:"doubleBakingPunishment"`
123+
DoubleEndorsingPunishmentNumerator int64 `json:"doubleEndorsingPunishmentNumerator"`
124+
DoubleEndorsingPunishmentDenominator int64 `json:"doubleEndorsingPunishmentDenominator"`
125+
TxRollupOriginationSize int64 `json:"txRollupOriginationSize"`
126+
TxRollupCommitmentBond int64 `json:"txRollupCommitmentBond"`
127+
LbEscapeThreshold int64 `json:"lbEscapeThreshold"`
128+
}
129+
130+
// ProtocolConstants -
131+
type ProtocolMetadata struct {
132+
Docs string `json:"docs"`
133+
Alias string `json:"alias"`
134+
}

0 commit comments

Comments
 (0)