vaa

package
v0.0.0-...-7be3494 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: Apache-2.0 Imports: 15 Imported by: 70

Documentation

Index

Constants

View Source
const (
	ConsistencyLevelPublishImmediately = uint8(200)
	ConsistencyLevelSafe               = uint8(201)
)

Variables

View Source
var CircleIntegrationModule = [32]byte{
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x43,
	0x69, 0x72, 0x63, 0x6c, 0x65, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e,
}

CircleIntegrationModule is the identifier of the Circle Integration module (which is used for governance messages). It is the hex representation of "CircleIntegration" left padded with zeroes.

View Source
var CircleIntegrationModuleStr = string(CircleIntegrationModule[:])
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 DeltaswapRelayerModule = [32]byte{
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x57, 0x6f, 0x72, 0x6d, 0x68, 0x6f, 0x6c, 0x65, 0x52, 0x65, 0x6c, 0x61, 0x79, 0x65, 0x72,
}

DeltaswapRelayerModule is the identifier of the Deltaswap Relayer module (which is used for governance messages). It is the hex representation of "DeltaswapRelayer" left padded with zeroes.

View Source
var DeltaswapRelayerModuleStr = string(DeltaswapRelayerModule[:])
View Source
var GatewayModule = [32]byte{
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65,
}

GatewayModule is the identifier of the Gateway module (which is used for general Gateway-related governance messages)

View Source
var GatewayModuleStr = string(GatewayModule[:])
View Source
var GovernanceChain = ChainIDSolana
View Source
var GovernanceEmitter = Address{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4}
View Source
var IbcReceiverModule = [32]byte{
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x49, 0x62, 0x63, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x72,
}

IbcReceiverModule is the identifier of the Deltachain ibc_receiver contract module (which is used for governance messages) It is the hex representation of "IbcReceiver" left padded with zeroes.

View Source
var IbcReceiverModuleStr = string(IbcReceiverModule[:])
View Source
var IbcTranslatorModule = [32]byte{
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x49, 0x62, 0x63, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x6c, 0x61, 0x74, 0x6f, 0x72,
}

IbcTranslatorModule is the identifier of the Deltachain ibc_receiver contract module (which is used for governance messages) It is the hex representation of "IbcTranslator" left padded with zeroes.

View Source
var IbcTranslatorModuleStr = string(IbcTranslatorModule[:])
View Source
var WasmdModule = [32]byte{00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 0x57, 0x61, 0x73, 0x6D, 0x64, 0x4D, 0x6F, 0x64, 0x75, 0x6C, 0x65}

WasmdModule is the identifier of the Deltachain Wasmd module (which is used for governance messages)

View Source
var WasmdModuleStr = string(WasmdModule[:])

Functions

func BytesToHash

func BytesToHash(b []byte) (common.Hash, error)

func CalculateQuorum

func CalculateQuorum(numPhylaxs int) int

CalculateQuorum returns the minimum number of phylaxs that need to sign a VAA for a given phylax set.

The canonical source is the calculation in the contracts (solana/bridge/src/processor.rs and ethereum/contracts/Deltaswap.sol), and this needs to match the implementation in the contracts.

func CreateInstatiateCosmwasmContractHash

func CreateInstatiateCosmwasmContractHash(codeId uint64, label string, msg []byte) [32]byte

Compute the hash for cosmwasm contract instatiation params. The hash is keccak256 hash(hash(hash(BigEndian(CodeID)), Label), Msg). We compute the nested hash so there is no chance of bytes leaking between CodeID, Label, and Msg.

func CreateMigrateCosmwasmContractHash

func CreateMigrateCosmwasmContractHash(codeId uint64, contract string, msg []byte) [32]byte

Compute the hash for cosmwasm contract migration params. The hash is keccak256 hash(hash(hash(BigEndian(CodeID)), Contract), Msg). We compute the nested hash so there is no chance of bytes leaking between CodeID, Contract, and Msg.

func DeprecatedSigningDigest

func DeprecatedSigningDigest(bz []byte) common.Hash

This is a temporary method to produce a vaa signing digest on raw bytes. It is error prone and we should use `v.SigningDigest()` instead. whenever possible. This will be removed in a subsequent release.

func DeprecatedVerifySignatures

func DeprecatedVerifySignatures(vaaBody []byte, signatures []*Signature, addresses []common.Address) bool

Operating on bytes directly is error prone. We should use `vaa.VerifyingSignatures()` whenever possible. This function will be removed in a subsequent release.

func EmptyPayloadVaa

func EmptyPayloadVaa(module string, actionId GovernanceAction, chainId ChainID) []byte

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 LeftPadBytes

func LeftPadBytes(payload string, length int) *bytes.Buffer

Prepends 0x00 bytes to the payload buffer, up to a size of `length`

func LeftPadIbcChannelId

func LeftPadIbcChannelId(channelId string) [64]byte

func MessageSigningDigest

func MessageSigningDigest(prefix []byte, data []byte) (common.Hash, error)

MessageSigningDigest returns the hash of the data prepended with it's signing prefix. This is intending to be used for signing messages of different types from VAA's. The message prefix helps protect from message collisions.

func MustWrite

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

MustWrite calls binary.Write and panics on errors

func StringToHash

func StringToHash(value string) (common.Hash, error)

StringToHash converts a hex-encoded string into a common.Hash

func VerifyMessageSignature

func VerifyMessageSignature(prefix []byte, messageBody []byte, signatures *Signature, addresses common.Address) bool

Types

type Action

type Action uint8

Action of a VAA

type Address

type Address [32]byte

Address is a Deltaswap 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 BytesToAddress

func BytesToAddress(b []byte) (Address, error)

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

func (*Address) UnmarshalJSON

func (a *Address) UnmarshalJSON(data []byte) error

Standard marshal stores the Address like this: "[0,0,0,0,0,0,0,0,0,0,0,0,2,144,251,22,114,8,175,69,91,177,55,120,1,99,183,183,169,161,12,22]" The above MarshalJSON stores it like this (66 bytes): ""0000000000000000000000000290fb167208af455bb137780163b7b7a9a10c16""

type Attestation

type Attestation interface {
	encoding.BinaryMarshaler
	encoding.BinaryUnmarshaler

	SigningMsg() common.Hash
	VerifySignatures(addrs []common.Address) bool
	UniqueID() string
	HexDigest() string
	AddSignature(key *ecdsa.PrivateKey, index uint8)
	GetEmitterChain() ChainID
	// contains filtered or unexported methods
}

Attestation interface contains the methods common to all VAA types

type BatchVAA

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

	// EmitterChain the VAAs were emitted on
	EmitterChain ChainID

	// The chain-native identifier of the transaction that created the batch VAA.
	TransactionID common.Hash

	// array of Observation VAA hashes
	Hashes []common.Hash

	// Observations in the batch
	Observations []*Observation
}

func UnmarshalBatch

func UnmarshalBatch(data []byte) (*BatchVAA, error)

UnmarshalBatch deserializes the binary representation of a BatchVAA

func (*BatchVAA) AddSignature

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

creates signature of BatchVAA.Hashes and adds it to BatchVAA.Signatures.

func (*BatchVAA) BatchID

func (v *BatchVAA) BatchID() string

BatchID returns a human-readable emitter_chain/transaction_hex

func (*BatchVAA) GetEmitterChain

func (v *BatchVAA) GetEmitterChain() ChainID

GetEmitterChain implements the processor.Batch interface for *BatchVAA.

func (*BatchVAA) GetTransactionID

func (v *BatchVAA) GetTransactionID() common.Hash

GetTransactionID implements the processor.Batch interface for *BatchVAA.

func (*BatchVAA) HexDigest

func (b *BatchVAA) HexDigest() string

HexDigest returns the hex-encoded digest.

func (*BatchVAA) Marshal

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

Marshal returns the binary representation of the BatchVAA

func (BatchVAA) MarshalBinary

func (b BatchVAA) MarshalBinary() ([]byte, error)

implement encoding.BinaryMarshaler interface for BatchVAA struct

func (*BatchVAA) ObsvHashArray

func (v *BatchVAA) ObsvHashArray() []common.Hash

ObsvHashArray creates an array of hashes of Observation. hashes in the array have the index position of their Observation.Index.

func (*BatchVAA) SigningDigest

func (v *BatchVAA) SigningDigest() common.Hash

BatchSigningDigest returns the hash of the batch vaa hash to be signed directly. This is used for signature generation and verification

func (*BatchVAA) UniqueID

func (b *BatchVAA) UniqueID() string

UniqueID returns the BatchID that uniquely identifies the Attestation

func (*BatchVAA) UnmarshalBinary

func (b *BatchVAA) UnmarshalBinary(data []byte) error

implement encoding.BinaryUnmarshaler interface for BatchVAA struct

func (*BatchVAA) VerifySignatures

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

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

type BodyAccountantModifyBalance

type BodyAccountantModifyBalance struct {
	Module        string
	TargetChainID ChainID
	Sequence      uint64
	ChainId       ChainID
	TokenChain    ChainID
	TokenAddress  Address
	Kind          uint8
	Amount        *uint256.Int
	Reason        string
}

BodyTokenBridgeModifyBalance is a governance message to modify accountant balances for the tokenbridge.

func (BodyAccountantModifyBalance) Serialize

func (r BodyAccountantModifyBalance) Serialize() []byte

type BodyCircleIntegrationRegisterEmitterAndDomain

type BodyCircleIntegrationRegisterEmitterAndDomain struct {
	TargetChainID         ChainID
	ForeignEmitterChainId ChainID
	ForeignEmitterAddress [32]byte
	CircleDomain          uint32
}

BodyCircleIntegrationRegisterEmitterAndDomain is a governance message to register an emitter and domain for Circle Integration.

func (BodyCircleIntegrationRegisterEmitterAndDomain) Serialize

type BodyCircleIntegrationUpdateDeltaswapFinality

type BodyCircleIntegrationUpdateDeltaswapFinality struct {
	TargetChainID ChainID
	Finality      uint8
}

BodyCircleIntegrationUpdateDeltaswapFinality is a governance message to update the deltaswap finality for Circle Integration.

func (BodyCircleIntegrationUpdateDeltaswapFinality) Serialize

type BodyCircleIntegrationUpgradeContractImplementation

type BodyCircleIntegrationUpgradeContractImplementation struct {
	TargetChainID            ChainID
	NewImplementationAddress [32]byte
}

BodyCircleIntegrationUpgradeContractImplementation is a governance message to upgrade the contract implementation for Circle Integration.

func (BodyCircleIntegrationUpgradeContractImplementation) Serialize

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 BodyDeltachainInstantiateContract

type BodyDeltachainInstantiateContract struct {
	InstantiationParamsHash [32]byte
}

BodyDeltachainInstantiateContract is a governance message to instantiate a cosmwasm contract on deltachain

func (BodyDeltachainInstantiateContract) Serialize

func (r BodyDeltachainInstantiateContract) Serialize() []byte

type BodyDeltachainMigrateContract

type BodyDeltachainMigrateContract struct {
	MigrationParamsHash [32]byte
}

BodyDeltachainInstantiateContract is a governance message to migrate a cosmwasm contract on deltachain

func (BodyDeltachainMigrateContract) Serialize

func (r BodyDeltachainMigrateContract) Serialize() []byte

type BodyDeltachainStoreCode

type BodyDeltachainStoreCode struct {
	WasmHash [32]byte
}

BodyDeltachainStoreCode is a governance message to upload a new cosmwasm contract to deltachain

func (BodyDeltachainStoreCode) Serialize

func (r BodyDeltachainStoreCode) Serialize() []byte

type BodyDeltachainWasmAllowlistInstantiate

type BodyDeltachainWasmAllowlistInstantiate struct {
	ContractAddr [32]byte
	CodeId       uint64
}

BodyDeltachainAllowlistInstantiateContract is a governance message to allowlist a specific contract address to instantiate a specific wasm code id.

func (*BodyDeltachainWasmAllowlistInstantiate) Deserialize

func (r *BodyDeltachainWasmAllowlistInstantiate) Deserialize(bz []byte)

func (BodyDeltachainWasmAllowlistInstantiate) Serialize

type BodyDeltaswapRelayerSetDefaultDeliveryProvider

type BodyDeltaswapRelayerSetDefaultDeliveryProvider struct {
	ChainID                           ChainID
	NewDefaultDeliveryProviderAddress Address
}

BodyDeltaswapRelayerSetDefaultDeliveryProvider is a governance message to set the default relay provider for the Deltaswap Relayer.

func (BodyDeltaswapRelayerSetDefaultDeliveryProvider) Serialize

type BodyGatewayIbcComposabilityMwContract

type BodyGatewayIbcComposabilityMwContract struct {
	ContractAddr [32]byte
}

BodyGatewayIbcComposabilityMwContract is a governance message to set a specific contract (i.e. IBC Translator) for the ibc composability middleware to use

func (*BodyGatewayIbcComposabilityMwContract) Deserialize

func (r *BodyGatewayIbcComposabilityMwContract) Deserialize(bz []byte)

func (BodyGatewayIbcComposabilityMwContract) Serialize

type BodyGatewayScheduleUpgrade

type BodyGatewayScheduleUpgrade struct {
	Name   string
	Height uint64
}

BodyGatewayScheduleUpgrade is a governance message to schedule an upgrade on Gateway

func (*BodyGatewayScheduleUpgrade) Deserialize

func (r *BodyGatewayScheduleUpgrade) Deserialize(bz []byte)

func (BodyGatewayScheduleUpgrade) Serialize

func (r BodyGatewayScheduleUpgrade) Serialize() []byte

type BodyIbcUpdateChannelChain

type BodyIbcUpdateChannelChain struct {
	// The chain that this governance VAA should be redeemed on
	TargetChainId ChainID

	// This should follow the IBC channel identifier standard: https://github.com/cosmos/ibc/tree/main/spec/core/ics-024-host-requirements#paths-identifiers-separators
	// If the identifier string is shorter than 64 bytes, the correct number of 0x00 bytes should be prepended.
	ChannelId [64]byte
	ChainId   ChainID
}

BodyIbcUpdateChannelChain is a governance message to update the ibc channel_id -> chain_id mapping in either of the ibc_receiver or ibc_translator contracts

func (BodyIbcUpdateChannelChain) Serialize

func (r BodyIbcUpdateChannelChain) Serialize(module string) []byte

type BodyPhylaxSetUpdate

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

BodyPhylaxSetUpdate is a governance message to set a new phylax set

func (BodyPhylaxSetUpdate) Serialize

func (b BodyPhylaxSetUpdate) Serialize() []byte

type BodySetMessageFee

type BodySetMessageFee struct {
	ChainID    ChainID
	MessageFee *uint256.Int
}

func (BodySetMessageFee) Serialize

func (b BodySetMessageFee) 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 BodyTransferFees

type BodyTransferFees struct {
	ChainID   ChainID
	Amount    *uint256.Int
	Recipient Address
}

func (BodyTransferFees) Serialize

func (b BodyTransferFees) Serialize() []byte

type ChainID

type ChainID uint16

ChainID of a Deltaswap 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
	// ChainIDNear is the ChainID of Near
	ChainIDNear ChainID = 15
	// ChainIDMoonbeam is the ChainID of Moonbeam
	ChainIDMoonbeam ChainID = 16
	// ChainIDNeon is the ChainID of Neon
	ChainIDNeon ChainID = 17
	// ChainIDTerra2 is the ChainID of Terra 2
	ChainIDTerra2 ChainID = 18
	// ChainIDInjective is the ChainID of Injective
	ChainIDInjective ChainID = 19
	// ChainIDSui is the ChainID of Sui
	ChainIDSui ChainID = 21
	// ChainIDAptos is the ChainID of Aptos
	ChainIDAptos ChainID = 22
	// ChainIDArbitrum is the ChainID of Arbitrum
	ChainIDArbitrum ChainID = 23
	// ChainIDOptimism is the ChainID of Optimism
	ChainIDOptimism ChainID = 24
	// ChainIDPythNet is the ChainID of PythNet
	ChainIDPythNet ChainID = 26
	// ChainIDXpla is the ChainID of Xpla
	ChainIDXpla ChainID = 28
	//ChainIDBtc is the ChainID of Bitcoin
	ChainIDBtc ChainID = 29
	// ChainIDBase is the ChainID of Base
	ChainIDBase ChainID = 30
	// ChainIDSei is the ChainID of Sei
	//ChainIDDeltachain is the ChainID of Deltachain
	ChainIDSei        ChainID = 32
	ChainIDScroll     ChainID = 34
	ChainIDTron       ChainID = 100
	ChainIDPlanq      ChainID = 7070
	ChainIDDeltachain ChainID = 7077
	// ChainIDSepolia is the ChainID of Sepolia
	ChainIDSepolia ChainID = 10002

	SupportedVAAVersion = 0x01
	BatchVAAVersion     = 0x02
)

func ChainIDFromString

func ChainIDFromString(s string) (ChainID, error)

func GetAllNetworkIDs

func GetAllNetworkIDs() []ChainID

func (ChainID) String

func (c ChainID) String() string

type GovernanceAction

type GovernanceAction uint8
var (
	// Deltaswap core governance actions
	// See e.g. GovernanceStructs.sol for semantic meaning of these
	ActionContractUpgrade    GovernanceAction = 1
	ActionPhylaxSetUpdate    GovernanceAction = 2
	ActionCoreSetMessageFee  GovernanceAction = 3
	ActionCoreTransferFees   GovernanceAction = 4
	ActionCoreRecoverChainId GovernanceAction = 5

	// Deltachain cosmwasm/middleware governance actions
	ActionStoreCode                      GovernanceAction = 1
	ActionInstantiateContract            GovernanceAction = 2
	ActionMigrateContract                GovernanceAction = 3
	ActionAddWasmInstantiateAllowlist    GovernanceAction = 4
	ActionDeleteWasmInstantiateAllowlist GovernanceAction = 5

	// Gateway governance actions
	ActionScheduleUpgrade               GovernanceAction = 1
	ActionCancelUpgrade                 GovernanceAction = 2
	ActionSetIbcComposabilityMwContract GovernanceAction = 3

	// Accountant goverance actions
	ActionModifyBalance GovernanceAction = 1

	// Deltaswap tokenbridge governance actions
	ActionRegisterChain             GovernanceAction = 1
	ActionUpgradeTokenBridge        GovernanceAction = 2
	ActionTokenBridgeRecoverChainId GovernanceAction = 3

	// Circle Integration governance actions
	CircleIntegrationActionUpdateDeltaswapFinality       GovernanceAction = 1
	CircleIntegrationActionRegisterEmitterAndDomain      GovernanceAction = 2
	CircleIntegrationActionUpgradeContractImplementation GovernanceAction = 3

	// Ibc Receiver governance actions
	IbcReceiverActionUpdateChannelChain GovernanceAction = 1

	// Ibc Translator governance actions
	IbcTranslatorActionUpdateChannelChain GovernanceAction = 1

	// Deltaswap relayer governance actions
	DeltaswapRelayerSetDefaultDeliveryProvider GovernanceAction = 3
)

type Observation

type Observation struct {
	// Index of the observation in a Batch array
	Index uint8
	// Signed Observation data
	Observation *VAA
}

type Signature

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

Signature of a single phylax

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
	TargetChain   ChainID
}

func DecodeTransferPayloadHdr

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

type VAA

type VAA struct {
	// Version of the VAA schema
	Version uint8
	// PhylaxSetIndex is the index of the phylax set that signed this VAA
	PhylaxSetIndex uint32
	// SignatureData is the signature of the phylax 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 Deltaswap protocol

func CreateGovernanceVAA

func CreateGovernanceVAA(timestamp time.Time, nonce uint32, sequence uint64, phylaxSetIndex uint32, payload []byte) *VAA

func Unmarshal

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

Unmarshal deserializes the binary representation of a VAA

func UnmarshalBody

func UnmarshalBody(data []byte, reader *bytes.Reader, v *VAA) (*VAA, error)

UnmarshalBody deserializes the binary representation of a VAA's "BODY" properties The BODY fields are common among multiple types of VAA - v1, v2 (BatchVAA), etc

func (*VAA) AddSignature

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

func (*VAA) GetEmitterChain

func (v *VAA) GetEmitterChain() ChainID

GetEmitterChain implements the processor.Observation interface for *VAA.

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) MarshalBinary

func (v VAA) MarshalBinary() ([]byte, error)

implement encoding.BinaryMarshaler interface for the VAA struct

func (*VAA) MessageID

func (v *VAA) MessageID() string

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

func (*VAA) SigningDigest

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

SigningDigest returns the hash of the vaa hash to be signed directly. This is used for signature generation and verification

func (*VAA) UniqueID

func (v *VAA) UniqueID() string

UniqueID normalizes the ID of the VAA (any type) for the Attestation interface UniqueID returns the MessageID that uniquely identifies the Attestation

func (*VAA) UnmarshalBinary

func (v *VAA) UnmarshalBinary(data []byte) error

implement encoding.BinaryUnmarshaler interface for the VAA struct

func (*VAA) Verify

func (v *VAA) Verify(addresses []common.Address) error

Verify is a function on the VAA that takes a complete set of phylax keys as input and attempts certain checks with respect to this phylax. Verify will return nil if the VAA passes checks. Otherwise, Verify will return an error containing the text of the first check to fail. NOTE: Verify will not work correctly if a subset of the phylax set keys is passed in. The complete phylax set must be passed in. Verify does the following checks: - If the phylax does not have or know its own phylax set keys, then the VAA cannot be verified. - Quorum is calculated on the phylax set passed in and checks if the VAA has enough signatures. - The signatures in the VAA is verified against the phylax set keys.

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