vaa

package
v0.0.0-...-e8e2c10 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: Apache-2.0 Imports: 13 Imported by: 20

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)

View Source
var TokenBridgeModule = []byte{00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x42, 0x72, 0x69, 0x64, 0x67, 0x65}

000000000000000000000000000000000000000000546f6b656e427269646765

Functions

func IsTransfer

func IsTransfer(payload []byte) bool

NOTE: This function assumes that the caller has verified that the VAA is from the token bridge.

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 StringToAddress

func StringToAddress(value string) (Address, error)

StringToAddress converts a hex-encoded address into a vaa.Address

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 {
	Payload []byte
}

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

func (BodyContractUpgrade) Serialize

func (b BodyContractUpgrade) Serialize() []byte

type BodyGuardianSetUpgrade

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

BodyGuardianSetUpgrade is a governance message to set a new guardian set

func (BodyGuardianSetUpgrade) Serialize

func (b BodyGuardianSetUpgrade) Serialize() []byte

type BodyTokenBridgeDestroyContracts

type BodyTokenBridgeDestroyContracts struct {
	EmitterChain ChainID
	Sequences    []uint64
}

func (BodyTokenBridgeDestroyContracts) Serialize

func (b BodyTokenBridgeDestroyContracts) 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 BodyTokenBridgeUpdateMinimalConsistencyLevel

type BodyTokenBridgeUpdateMinimalConsistencyLevel struct {
	NewConsistencyLevel uint8
}

func (BodyTokenBridgeUpdateMinimalConsistencyLevel) Serialize

type BodyTokenBridgeUpdateRefundAddress

type BodyTokenBridgeUpdateRefundAddress struct {
	NewRefundAddress []byte
}

func (BodyTokenBridgeUpdateRefundAddress) Serialize

func (b BodyTokenBridgeUpdateRefundAddress) Serialize() []byte

type BodyTokenBridgeUpgradeContract

type BodyTokenBridgeUpgradeContract struct {
	Module  string
	Payload []byte
}

BodyTokenBridgeUpgradeContract is a governance message to upgrade the token bridge.

func (BodyTokenBridgeUpgradeContract) Serialize

func (r BodyTokenBridgeUpgradeContract) Serialize() []byte

type BodyTransferFee

type BodyTransferFee struct {
	Amount    []byte
	Recipient []byte
}

func (BodyTransferFee) Serialize

func (b BodyTransferFee) Serialize() []byte

type BodyUpdateMessageFee

type BodyUpdateMessageFee struct {
	NewMessageFee []byte
}

BodyUpdateMessageFee is a governance message to perform update message fee of the core module

func (BodyUpdateMessageFee) Serialize

func (b BodyUpdateMessageFee) 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
	// ChainIDAvalanche is the ChainID of Avalanche
	ChainIDAvalanche ChainID = 6
	// ChainIDOasis is the ChainID of Oasis
	ChainIDOasis ChainID = 7
	// ChainIDAlgorand is the ChainID of Algorand
	ChainIDAlgorand ChainID = 8
	// ChainIDAurora is the ChainID of Aurora
	ChainIDAurora ChainID = 9
	// ChainIDFantom is the ChainID of Fantom
	ChainIDFantom ChainID = 10
	// ChainIDKarura is the ChainID of Karura
	ChainIDKarura ChainID = 11
	// ChainIDAcala is the ChainID of Acala
	ChainIDAcala ChainID = 12
	// ChainIDKlaytn is the ChainID of Klaytn
	ChainIDKlaytn ChainID = 13
	// ChainIDCelo is the ChainID of Celo
	ChainIDCelo ChainID = 14
	// ChainIDMoonbeam is the ChainID of Moonbeam
	ChainIDMoonbeam ChainID = 16
	// ChainIDNeon is the ChainID of Neon
	ChainIDNeon ChainID = 17
	// ChainIDAlephium is the ChainID of Alephium
	ChainIDAlephium ChainID = 255

	// 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 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 TransferPayloadHdr

type TransferPayloadHdr struct {
	Type          uint8
	Amount        *big.Int
	OriginAddress Address
	OriginChain   ChainID
	TargetAddress Address
}

func DecodeTransferPayloadHdr

func DecodeTransferPayloadHdr(payload []byte) (*TransferPayloadHdr, error)

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
	// The target chain of the VAA
	TargetChain 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(
	governanceChainId ChainID,
	governanceEmitterAddress Address,
	timestamp time.Time,
	nonce uint32,
	sequence uint64,
	targetChain ChainID,
	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/target_chain/sequence tuple.

func (*VAA) SerializeBody

func (v *VAA) SerializeBody() []byte

func (*VAA) SigningMsg

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

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.

type VAAID

type VAAID struct {
	EmitterChain   ChainID
	EmitterAddress Address
	TargetChain    ChainID
	Sequence       uint64
}

func VaaIDFromString

func VaaIDFromString(s string) (*VAAID, error)

VaaIDFromString parses a <emitter_chain>/<address>/<target_chain>/<sequence> string into a VAAID.

func (*VAAID) Bytes

func (i *VAAID) Bytes() []byte

func (*VAAID) EmitterPrefixBytes

func (i *VAAID) EmitterPrefixBytes() []byte

func (*VAAID) GovernanceEmitterPrefixBytes

func (i *VAAID) GovernanceEmitterPrefixBytes() []byte

func (*VAAID) ToString

func (i *VAAID) ToString() string

Jump to

Keyboard shortcuts

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