Documentation
¶
Overview ¶
Package proto implements the narrow subset of the Cosmos SDK and Heimdall v2 protobuf wire format that polycli's heimdall tx builder needs. See README.md for the rationale — we encode/decode by hand rather than pull in cosmos-sdk's fork-pinned go module.
Index ¶
- Constants
- func ConsumeField(b []byte) (protowire.Number, protowire.Type, []byte, int, error)
- func Decode(typeURL string, value []byte) (any, error)
- func KnownTypeURLs() []string
- func Register(typeURL string, decoder Decoder)
- func Varint(b []byte) (uint64, error)
- type Any
- type AuthInfo
- type BlockIDFlag
- type BlockRange
- type Coin
- type Decoder
- type ExtValidator
- type ExtendedCommitInfo
- type ExtendedVoteInfo
- type Fee
- type MilestoneProposition
- type ModeInfo
- type ModeInfoSingle
- type MsgBackfillSpans
- type MsgCheckpoint
- type MsgCpAck
- type MsgCpNoAck
- type MsgEventRecord
- type MsgProposeSpan
- type MsgSetProducerDowntime
- type MsgSignerUpdate
- type MsgStakeUpdate
- type MsgTopupTx
- type MsgValidatorExit
- type MsgValidatorJoin
- type MsgVoteProducers
- type MsgWithdrawFeeTx
- type ProducerVotes
- type SideTxResponse
- type SignDoc
- type SignerInfo
- type TxBody
- type TxRaw
- type Vote
- type VoteExtension
Constants ¶
const ( SignModeDirect int32 = 1 SignModeAminoJSON int32 = 127 SignModeUnspecif int32 = 0 )
SignModeDirect and SignModeAminoJSON are the two values of cosmos.tx.signing.v1beta1.SignMode that polycli supports.
const ( MsgValidatorJoinTypeURL = "/heimdallv2.stake.MsgValidatorJoin" MsgStakeUpdateTypeURL = "/heimdallv2.stake.MsgStakeUpdate" MsgSignerUpdateTypeURL = "/heimdallv2.stake.MsgSignerUpdate" MsgValidatorExitTypeURL = "/heimdallv2.stake.MsgValidatorExit" )
Stake module Msg type URLs.
const MsgBackfillSpansTypeURL = "/heimdallv2.bor.MsgBackfillSpans"
MsgBackfillSpansTypeURL is the Any type URL for MsgBackfillSpans.
const MsgCheckpointTypeURL = "/heimdallv2.checkpoint.MsgCheckpoint"
MsgCheckpointTypeURL is the Any type URL for MsgCheckpoint (heimdallv2/proto/heimdallv2/checkpoint/tx.proto).
const MsgCpAckTypeURL = "/heimdallv2.checkpoint.MsgCpAck"
MsgCpAckTypeURL is the Any type URL for MsgCpAck.
const MsgCpNoAckTypeURL = "/heimdallv2.checkpoint.MsgCpNoAck"
MsgCpNoAckTypeURL is the Any type URL for MsgCpNoAck.
const MsgEventRecordTypeURL = "/heimdallv2.clerk.MsgEventRecord"
MsgEventRecordTypeURL is the Any type URL for MsgEventRecord (heimdallv2/proto/heimdallv2/clerk/tx.proto).
const MsgProposeSpanTypeURL = "/heimdallv2.bor.MsgProposeSpan"
MsgProposeSpanTypeURL is the Any type URL for MsgProposeSpan (heimdallv2/proto/heimdallv2/bor/tx.proto).
const MsgSetProducerDowntimeTypeURL = "/heimdallv2.bor.MsgSetProducerDowntime"
MsgSetProducerDowntimeTypeURL is the Any type URL for MsgSetProducerDowntime.
const MsgTopupTxTypeURL = "/heimdallv2.topup.MsgTopupTx"
MsgTopupTxTypeURL is the Any type URL for MsgTopupTx (heimdallv2/proto/heimdallv2/topup/tx.proto).
const MsgVoteProducersTypeURL = "/heimdallv2.bor.MsgVoteProducers"
MsgVoteProducersTypeURL is the Any type URL for MsgVoteProducers.
const MsgWithdrawFeeTxTypeURL = "/heimdallv2.topup.MsgWithdrawFeeTx"
MsgWithdrawFeeTxTypeURL is the Any type URL for the withdraw fee message as registered in heimdall-v2.
const PubKeyTypeURL = "/cosmos.crypto.secp256k1.PubKey"
PubKeyTypeURL is the Any type URL for a Heimdall / Cosmos SDK secp256k1 public key. heimdall-v2 registers this concrete type with the Ethereum-style 65-byte uncompressed key; the proto shape is identical to the upstream cosmos-sdk type.
const VoteExtensionTypeURL = "/heimdallv2.sidetxs.VoteExtension"
VoteExtensionTypeURL is informational; VoteExtension is not wrapped in Any on the wire (it arrives as plain bytes on CometBFT's ExtendVote interface). Retained so the decode family can surface a consistent label.
Variables ¶
This section is empty.
Functions ¶
func ConsumeField ¶
ConsumeField exposes consumeField for sibling packages (e.g. the heimdall decode command) so they don't carry their own copy of the wire-format record parser.
func Decode ¶
Decode resolves typeURL in the registry and invokes its decoder. If typeURL is unknown, Decode returns an error including the type URL so callers can forward it to the user verbatim.
func KnownTypeURLs ¶
func KnownTypeURLs() []string
KnownTypeURLs returns a sorted list of every registered type URL. Useful for diagnostics and for `decode msg` help text.
Types ¶
type Any ¶
Any mirrors google.protobuf.Any — a polymorphic envelope carrying a type_url and a proto-encoded value. We use this for both tx messages and pubkeys.
func PubKeyAny ¶
PubKeyAny returns an Any wrapping a cosmos.crypto.secp256k1.PubKey whose single `bytes key = 1` field is keyBytes. keyBytes should be the 65-byte uncompressed secp256k1 pubkey (0x04 || X || Y) for PubKeySecp256k1eth.
func UnmarshalAny ¶
UnmarshalAny parses a length-prefixed Any from b and returns it. Unknown fields are skipped.
type AuthInfo ¶
type AuthInfo struct {
SignerInfos []*SignerInfo
Fee *Fee
}
AuthInfo mirrors cosmos.tx.v1beta1.AuthInfo.
type BlockIDFlag ¶
type BlockIDFlag int32
BlockIDFlag mirrors tendermint.types.BlockIDFlag.
const ( BlockIDFlagUnknown BlockIDFlag = 0 BlockIDFlagAbsent BlockIDFlag = 1 BlockIDFlagCommit BlockIDFlag = 2 BlockIDFlagNil BlockIDFlag = 3 )
BlockIDFlag values. UNKNOWN is encoded as 0 and omitted when unset.
func (BlockIDFlag) String ¶
func (f BlockIDFlag) String() string
String returns the short enum name (without the BLOCK_ID_FLAG_ prefix used in the .proto source) for compact table rendering.
type BlockRange ¶
BlockRange mirrors heimdallv2.bor.BlockRange.
type Decoder ¶
Decoder takes an Any.value byte slice and returns a decoded Go value (typically a typed *Msg or a map[string]any) along with an error.
The registry is populated by package init() functions in this file. Additional Msg types added in the future should register their decoder alongside their Marshal/Unmarshal helpers.
type ExtValidator ¶
type ExtValidator struct {
Address []byte // 20-byte CometBFT address == heimdall signer address
Power int64
}
ExtValidator mirrors tendermint.abci.Validator. Field 2 is reserved in the .proto source (it once held a pub_key).
type ExtendedCommitInfo ¶
type ExtendedCommitInfo struct {
Round int32
Votes []ExtendedVoteInfo
}
ExtendedCommitInfo mirrors tendermint.abci.ExtendedCommitInfo. On heimdall-v2 chains the proposer injects the previous height's extended commit (all validators' vote extensions) as the special transaction at index 0 of every block; decoding block.data.txs[0] with this function recovers each validator's vote extension bytes. Unknown fields are skipped for forward compatibility with fork drift.
func UnmarshalExtendedCommitInfo ¶
func UnmarshalExtendedCommitInfo(b []byte) (*ExtendedCommitInfo, error)
UnmarshalExtendedCommitInfo parses the marshaled ExtendedCommitInfo bytes found at block.data.txs[0].
func (*ExtendedCommitInfo) Marshal ¶
func (e *ExtendedCommitInfo) Marshal() []byte
Marshal encodes ExtendedCommitInfo.
type ExtendedVoteInfo ¶
type ExtendedVoteInfo struct {
Validator ExtValidator
VoteExtension []byte
ExtensionSignature []byte
BlockIDFlag BlockIDFlag
NonRpVoteExtension []byte
NonRpExtensionSignature []byte
}
ExtendedVoteInfo mirrors tendermint.abci.ExtendedVoteInfo as defined by the 0xPolygon cometbft fork (v0.3.6-polygon), which adds the non-RP extension fields 6 and 7 on top of the upstream message. Field 2 is reserved in the .proto source.
func (ExtendedVoteInfo) Marshal ¶
func (v ExtendedVoteInfo) Marshal() []byte
Marshal encodes ExtendedVoteInfo.
type MilestoneProposition ¶
type MilestoneProposition struct {
BlockHashes [][]byte
StartBlockNumber uint64
ParentHash []byte
BlockTDs []uint64
}
MilestoneProposition mirrors heimdallv2.milestone.MilestoneProposition. Repeated uint64 fields are decoded tolerantly: both packed and unpacked wire forms are accepted.
func UnmarshalMilestoneProposition ¶
func UnmarshalMilestoneProposition(b []byte) (*MilestoneProposition, error)
UnmarshalMilestoneProposition parses the message bytes.
The block_tds field is a repeated uint64. Proto3 defaults repeated scalars to the packed wire format; heimdalld's gogoproto descriptors use packed encoding. We accept both: consumeField normalizes the value to a raw byte-slice regardless of the tag wire type.
func (*MilestoneProposition) Marshal ¶
func (m *MilestoneProposition) Marshal() []byte
Marshal encodes MilestoneProposition (block_tds as packed varints).
type ModeInfo ¶
type ModeInfo struct {
Single *ModeInfoSingle
}
ModeInfo represents the ModeInfo oneof; only Single is supported.
type ModeInfoSingle ¶
type ModeInfoSingle struct {
Mode int32
}
ModeInfoSingle is the ModeInfo.Single sub-message.
func (ModeInfoSingle) Marshal ¶
func (m ModeInfoSingle) Marshal() []byte
Marshal encodes ModeInfo.Single.
type MsgBackfillSpans ¶
type MsgBackfillSpans struct {
Proposer string
ChainID string
LatestSpanID uint64
LatestBorSpanID uint64
}
MsgBackfillSpans mirrors heimdallv2.bor.MsgBackfillSpans.
func UnmarshalMsgBackfillSpans ¶
func UnmarshalMsgBackfillSpans(b []byte) (*MsgBackfillSpans, error)
UnmarshalMsgBackfillSpans parses the message bytes.
func (*MsgBackfillSpans) Marshal ¶
func (m *MsgBackfillSpans) Marshal() []byte
Marshal encodes MsgBackfillSpans.
type MsgCheckpoint ¶
type MsgCheckpoint struct {
Proposer string
StartBlock uint64
EndBlock uint64
RootHash []byte
AccountRootHash []byte
BorChainID string
}
MsgCheckpoint mirrors heimdallv2.checkpoint.MsgCheckpoint. Fields are ordered to match the .proto source; the Marshal emits them in field number order regardless.
func UnmarshalMsgCheckpoint ¶
func UnmarshalMsgCheckpoint(b []byte) (*MsgCheckpoint, error)
UnmarshalMsgCheckpoint parses a MsgCheckpoint from its proto bytes.
func (*MsgCheckpoint) AsAny ¶
func (m *MsgCheckpoint) AsAny() *Any
AsAny wraps the message as a google.protobuf.Any.
func (*MsgCheckpoint) Marshal ¶
func (m *MsgCheckpoint) Marshal() []byte
Marshal encodes MsgCheckpoint.
type MsgCpAck ¶
type MsgCpAck struct {
From string
Number uint64
Proposer string
StartBlock uint64
EndBlock uint64
RootHash []byte
}
MsgCpAck mirrors heimdallv2.checkpoint.MsgCpAck.
func UnmarshalMsgCpAck ¶
UnmarshalMsgCpAck parses MsgCpAck bytes.
type MsgCpNoAck ¶
type MsgCpNoAck struct {
From string
}
MsgCpNoAck mirrors heimdallv2.checkpoint.MsgCpNoAck (single field).
func UnmarshalMsgCpNoAck ¶
func UnmarshalMsgCpNoAck(b []byte) (*MsgCpNoAck, error)
UnmarshalMsgCpNoAck parses MsgCpNoAck bytes.
type MsgEventRecord ¶
type MsgEventRecord struct {
From string
TxHash string
LogIndex uint64
BlockNumber uint64
ContractAddress string
Data []byte
ID uint64
ChainID string
}
MsgEventRecord mirrors heimdallv2.clerk.MsgEventRecord.
func UnmarshalMsgEventRecord ¶
func UnmarshalMsgEventRecord(b []byte) (*MsgEventRecord, error)
UnmarshalMsgEventRecord parses the message bytes.
func (*MsgEventRecord) Marshal ¶
func (m *MsgEventRecord) Marshal() []byte
Marshal encodes MsgEventRecord.
type MsgProposeSpan ¶
type MsgProposeSpan struct {
SpanID uint64
Proposer string
StartBlock uint64
EndBlock uint64
ChainID string
Seed []byte
SeedAuthor string
}
MsgProposeSpan mirrors heimdallv2.bor.MsgProposeSpan.
func UnmarshalMsgProposeSpan ¶
func UnmarshalMsgProposeSpan(b []byte) (*MsgProposeSpan, error)
UnmarshalMsgProposeSpan parses the message bytes.
func (*MsgProposeSpan) Marshal ¶
func (m *MsgProposeSpan) Marshal() []byte
Marshal encodes MsgProposeSpan.
type MsgSetProducerDowntime ¶
type MsgSetProducerDowntime struct {
Producer string
DowntimeRange BlockRange
}
MsgSetProducerDowntime mirrors heimdallv2.bor.MsgSetProducerDowntime.
func UnmarshalMsgSetProducerDowntime ¶
func UnmarshalMsgSetProducerDowntime(b []byte) (*MsgSetProducerDowntime, error)
UnmarshalMsgSetProducerDowntime parses the message bytes.
func (*MsgSetProducerDowntime) AsAny ¶
func (m *MsgSetProducerDowntime) AsAny() *Any
AsAny wraps the message.
func (*MsgSetProducerDowntime) Marshal ¶
func (m *MsgSetProducerDowntime) Marshal() []byte
Marshal encodes MsgSetProducerDowntime.
type MsgSignerUpdate ¶
type MsgSignerUpdate struct {
From string
ValID uint64
NewSignerPubKey []byte
TxHash []byte
LogIndex uint64
BlockNumber uint64
Nonce uint64
}
MsgSignerUpdate mirrors heimdallv2.stake.MsgSignerUpdate.
func UnmarshalMsgSignerUpdate ¶
func UnmarshalMsgSignerUpdate(b []byte) (*MsgSignerUpdate, error)
UnmarshalMsgSignerUpdate parses the message bytes.
func (*MsgSignerUpdate) Marshal ¶
func (m *MsgSignerUpdate) Marshal() []byte
Marshal encodes MsgSignerUpdate.
type MsgStakeUpdate ¶
type MsgStakeUpdate struct {
From string
ValID uint64
NewAmount string
TxHash []byte
LogIndex uint64
BlockNumber uint64
Nonce uint64
}
MsgStakeUpdate mirrors heimdallv2.stake.MsgStakeUpdate.
func UnmarshalMsgStakeUpdate ¶
func UnmarshalMsgStakeUpdate(b []byte) (*MsgStakeUpdate, error)
UnmarshalMsgStakeUpdate parses the message bytes.
func (*MsgStakeUpdate) Marshal ¶
func (m *MsgStakeUpdate) Marshal() []byte
Marshal encodes MsgStakeUpdate.
type MsgTopupTx ¶
type MsgTopupTx struct {
Proposer string
User string
Fee string
TxHash []byte
LogIndex uint64
BlockNumber uint64
}
MsgTopupTx mirrors heimdallv2.topup.MsgTopupTx. Fee is carried as a decimal string (math.Int) identical to MsgWithdrawFeeTx.
func UnmarshalMsgTopupTx ¶
func UnmarshalMsgTopupTx(b []byte) (*MsgTopupTx, error)
UnmarshalMsgTopupTx parses the message bytes.
type MsgValidatorExit ¶
type MsgValidatorExit struct {
From string
ValID uint64
DeactivationEpoch uint64
TxHash []byte
LogIndex uint64
BlockNumber uint64
Nonce uint64
}
MsgValidatorExit mirrors heimdallv2.stake.MsgValidatorExit.
func UnmarshalMsgValidatorExit ¶
func UnmarshalMsgValidatorExit(b []byte) (*MsgValidatorExit, error)
UnmarshalMsgValidatorExit parses the message bytes.
func (*MsgValidatorExit) Marshal ¶
func (m *MsgValidatorExit) Marshal() []byte
Marshal encodes MsgValidatorExit.
type MsgValidatorJoin ¶
type MsgValidatorJoin struct {
From string
ValID uint64
ActivationEpoch uint64
Amount string
SignerPubKey []byte
TxHash []byte
LogIndex uint64
BlockNumber uint64
Nonce uint64
}
MsgValidatorJoin mirrors heimdallv2.stake.MsgValidatorJoin.
func UnmarshalMsgValidatorJoin ¶
func UnmarshalMsgValidatorJoin(b []byte) (*MsgValidatorJoin, error)
UnmarshalMsgValidatorJoin parses the message bytes.
func (*MsgValidatorJoin) Marshal ¶
func (m *MsgValidatorJoin) Marshal() []byte
Marshal encodes MsgValidatorJoin.
type MsgVoteProducers ¶
type MsgVoteProducers struct {
Voter string
VoterID uint64
Votes ProducerVotes
}
MsgVoteProducers mirrors heimdallv2.bor.MsgVoteProducers.
func UnmarshalMsgVoteProducers ¶
func UnmarshalMsgVoteProducers(b []byte) (*MsgVoteProducers, error)
UnmarshalMsgVoteProducers parses the message bytes. Votes may arrive either packed or unpacked per proto3 rules.
func (*MsgVoteProducers) Marshal ¶
func (m *MsgVoteProducers) Marshal() []byte
Marshal encodes MsgVoteProducers.
type MsgWithdrawFeeTx ¶
type MsgWithdrawFeeTx struct {
Proposer string
// Amount is carried as a string because cosmossdk.io/math.Int is
// encoded as its decimal string representation on the wire.
Amount string
}
MsgWithdrawFeeTx is the starter Msg we exercise end-to-end in W2. Matches heimdall-v2/proto/heimdallv2/topup/tx.proto. Additional message types are added in W3/W4 with the same pattern.
func UnmarshalMsgWithdrawFeeTx ¶
func UnmarshalMsgWithdrawFeeTx(b []byte) (*MsgWithdrawFeeTx, error)
UnmarshalMsgWithdrawFeeTx parses a MsgWithdrawFeeTx from bytes.
func (*MsgWithdrawFeeTx) AsAny ¶
func (m *MsgWithdrawFeeTx) AsAny() *Any
AsAny wraps the withdraw-fee message as a google.protobuf.Any for inclusion in TxBody.messages.
func (*MsgWithdrawFeeTx) Marshal ¶
func (m *MsgWithdrawFeeTx) Marshal() []byte
Marshal encodes MsgWithdrawFeeTx.
type ProducerVotes ¶
type ProducerVotes struct {
Votes []uint64
}
ProducerVotes mirrors heimdallv2.bor.ProducerVotes (repeated uint64 field `votes`, encoded packed or repeated per proto3).
func (ProducerVotes) Marshal ¶
func (p ProducerVotes) Marshal() []byte
Marshal encodes ProducerVotes with packed varints (the proto3 default for repeated scalar fields). Accepts either packed or unpacked on the wire when unmarshalling.
type SideTxResponse ¶
SideTxResponse mirrors heimdallv2.sidetxs.SideTxResponse.
func UnmarshalSideTxResponse ¶
func UnmarshalSideTxResponse(b []byte) (SideTxResponse, error)
UnmarshalSideTxResponse parses the message bytes.
func (SideTxResponse) Marshal ¶
func (s SideTxResponse) Marshal() []byte
Marshal encodes SideTxResponse.
type SignDoc ¶
SignDoc mirrors cosmos.tx.v1beta1.SignDoc — the pre-image signed in SIGN_MODE_DIRECT.
type SignerInfo ¶
SignerInfo mirrors cosmos.tx.v1beta1.SignerInfo.
type TxBody ¶
type TxBody struct {
Messages []*Any
Memo string
TimeoutHeight uint64
ExtensionOptions []*Any
NonCriticalExtensionOptions []*Any
}
TxBody mirrors cosmos.tx.v1beta1.TxBody.
type TxRaw ¶
TxRaw mirrors cosmos.tx.v1beta1.TxRaw — the canonical signed tx.
func UnmarshalTxRaw ¶
UnmarshalTxRaw parses a TxRaw from bytes.
type Vote ¶
type Vote int32
Vote mirrors heimdallv2.sidetxs.Vote.
Vote values. UNSPECIFIED is encoded as 0 and omitted when unset.
type VoteExtension ¶
type VoteExtension struct {
BlockHash []byte
Height int64
SideTxResponses []SideTxResponse
MilestoneProposition *MilestoneProposition
}
VoteExtension mirrors heimdallv2.sidetxs.VoteExtension.
func UnmarshalVoteExtension ¶
func UnmarshalVoteExtension(b []byte) (*VoteExtension, error)
UnmarshalVoteExtension parses raw vote-extension bytes as emitted by heimdall-v2's ExtendVote handler.
func (*VoteExtension) Marshal ¶
func (v *VoteExtension) Marshal() []byte
Marshal encodes VoteExtension.