vaa

package
v0.0.0-...-59ef1fd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 15, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CoreModule = []byte{00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 0x43, 0x6f, 0x72, 0x65}

CoreModule is the identifier of the Core module (which is used for governance messages)

Functions

func MustWrite

func MustWrite(w io.Writer, order binary.ByteOrder, data interface{})

MustWrite calls binary.Write and panics on errors

Types

type Action

type Action uint8

Action of a VAA

type Address

type Address [32]byte

Address is a Wormhole protocol address, it contains the native chain's address. If the address data type of a chain is < 32bytes the value is zero-padded on the left.

func (Address) Bytes

func (a Address) Bytes() []byte

func (Address) MarshalJSON

func (a Address) MarshalJSON() ([]byte, error)

func (Address) String

func (a Address) String() string

type BodyContractUpgrade

type BodyContractUpgrade struct {
	ChainID     ChainID
	NewContract Address
}

BodyContractUpgrade is a governance message to perform a contract upgrade of the core module

func (BodyContractUpgrade) Serialize

func (b BodyContractUpgrade) Serialize() []byte

type BodyGuardianSetUpdate

type BodyGuardianSetUpdate struct {
	Keys     []common.Address
	NewIndex uint32
}

BodyGuardianSetUpdate is a governance message to set a new guardian set

func (BodyGuardianSetUpdate) Serialize

func (b BodyGuardianSetUpdate) Serialize() []byte

type BodyTokenBridgeRegisterChain

type BodyTokenBridgeRegisterChain struct {
	Module         string
	ChainID        ChainID
	EmitterAddress Address
}

BodyTokenBridgeRegisterChain is a governance message to register a chain on the token bridge

func (BodyTokenBridgeRegisterChain) Serialize

func (r BodyTokenBridgeRegisterChain) Serialize() []byte

type BodyTokenBridgeUpgradeContract

type BodyTokenBridgeUpgradeContract struct {
	Module        string
	TargetChainID ChainID
	NewContract   Address
}

BodyTokenBridgeUpgradeContract is a governance message to upgrade the token bridge.

func (BodyTokenBridgeUpgradeContract) Serialize

func (r BodyTokenBridgeUpgradeContract) Serialize() []byte

type ChainID

type ChainID uint16

ChainID of a Wormhole chain

const (
	ChainIDUnset ChainID = 0
	// ChainIDSolana is the ChainID of Solana
	ChainIDSolana ChainID = 1
	// ChainIDEthereum is the ChainID of Ethereum
	ChainIDEthereum ChainID = 2
	// ChainIDTerra is the ChainID of Terra
	ChainIDTerra ChainID = 3
	// ChainIDBSC is the ChainID of Binance Smart Chain
	ChainIDBSC ChainID = 4
	// ChainIDPolygon is the ChainID of Polygon
	ChainIDPolygon ChainID = 5
	// ChainIDEthereumRopsten is the ChainID of Ethereum Ropsten
	ChainIDEthereumRopsten ChainID = 10001

	SupportedVAAVersion = 0x01
)

func ChainIDFromString

func ChainIDFromString(s string) (ChainID, error)

func (ChainID) String

func (c ChainID) String() string

type ChainIDNameMap

type ChainIDNameMap map[ChainID]string
var ChainIdNameMatch ChainIDNameMap

type Signature

type Signature struct {
	// Index of the validator
	Index uint8
	// Signature data
	Signature SignatureData
}

Signature of a single guardian

type SignatureData

type SignatureData [65]byte

func (SignatureData) MarshalJSON

func (a SignatureData) MarshalJSON() ([]byte, error)

func (SignatureData) String

func (a SignatureData) String() string

type VAA

type VAA struct {
	// Version of the VAA schema
	Version uint8
	// GuardianSetIndex is the index of the guardian set that signed this VAA
	GuardianSetIndex uint32
	// SignatureData is the signature of the guardian set
	Signatures []*Signature

	// Timestamp when the VAA was created
	Timestamp time.Time
	// Nonce of the VAA
	Nonce uint32
	// Sequence of the VAA
	Sequence uint64
	/// ConsistencyLevel of the VAA
	ConsistencyLevel uint8
	// EmitterChain the VAA was emitted on
	EmitterChain ChainID
	// EmitterAddress of the contract that emitted the Message
	EmitterAddress Address
	// Payload of the message
	Payload []byte
}

VAA is a verifiable action approval of the Wormhole protocol

func CreateGovernanceVAA

func CreateGovernanceVAA(nonce uint32, sequence uint64, guardianSetIndex uint32, payload []byte) *VAA

func Unmarshal

func Unmarshal(data []byte) (*VAA, error)

Unmarshal deserializes the binary representation of a VAA

func (*VAA) AddSignature

func (v *VAA) AddSignature(key *ecdsa.PrivateKey, index uint8)

func (*VAA) HexDigest

func (v *VAA) HexDigest() string

HexDigest returns the hex-encoded digest.

func (*VAA) Marshal

func (v *VAA) Marshal() ([]byte, error)

Marshal returns the binary representation of the VAA

func (*VAA) MessageID

func (v *VAA) MessageID() string

MessageID returns a human-readable emitter_chain/emitter_address/sequence tuple.

func (*VAA) SigningMsg

func (v *VAA) SigningMsg() (common.Hash, error)

SigningMsg returns the hash of the signing body. This is used for signature generation and verification

func (*VAA) VerifySignatures

func (v *VAA) VerifySignatures(addresses []common.Address) bool

VerifySignatures verifies the signature of the VAA given the signer addresses. Returns true if the signatures were verified successfully.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL