vaa

package
v0.0.0-...-efbd42f Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ChainIDPythNet vaa.ChainID = 26
)

chanID constants.

Variables

This section is empty.

Functions

This section is empty.

Types

type FindAllParams

type FindAllParams struct {
	Pagination           *pagination.Pagination
	TxHash               *types.TxHash
	IncludeParsedPayload bool
	AppId                string
}

FindAllParams passes input data to the function `FindAll`.

type FindByEmitterParams

type FindByEmitterParams struct {
	EmitterChain         sdk.ChainID
	EmitterAddress       *types.Address
	ToChain              *sdk.ChainID
	IncludeParsedPayload bool
	Pagination           *pagination.Pagination
}

FindByEmitterParams contains the input parameters for the function `FindByEmitter`.

type Repository

type Repository struct {
	// contains filtered or unexported fields
}

Repository definition

func NewRepository

func NewRepository(db *mongo.Database, logger *zap.Logger) *Repository

NewRepository create a new Repository.

func (*Repository) FindVaas

func (r *Repository) FindVaas(
	ctx context.Context,
	q *VaaQuery,
) ([]*VaaDoc, error)

FindVaas searches the database for VAAs matching the given filters.

When the `q.txHash` field is set, this function will look up transaction hashes in the `vaas` collection.

Take into consideration that multiple VAAs could share the same transaction ID.

func (*Repository) FindVaasByEmitterAndToChain

func (r *Repository) FindVaasByEmitterAndToChain(
	ctx context.Context,
	query *VaaQuery,
	toChain sdk.ChainID,
) ([]*VaaDoc, error)

FindVaasByEmitterAndToChain searches the database for VAAs that match a given emitter chain, address and toChain.

func (*Repository) FindVaasByTxHashWorkaround

func (r *Repository) FindVaasByTxHashWorkaround(
	ctx context.Context,
	query *VaaQuery,
) ([]*VaaDoc, error)

FindVaasByTxHashWorkaround searches the database for VAAs that match a given transaction hash.

This function exists to work around the issue that for Aptos and Solana, the real transaction hashes are stored in a different collection from other chains.

When the `q.txHash` field is set, this function will look up transaction hashes in the `globalTransactions` collection. Then, if the transaction hash is not found, it will fall back to searching in the `vaas` collection.

Take into consideration that multiple VAAs could share the same transaction ID.

func (*Repository) GetVaaCount

func (r *Repository) GetVaaCount(ctx context.Context, q *VaaQuery) ([]*VaaStats, error)

GetVaaCount get a count of vaa by chainID.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service definition.

func NewService

func NewService(r *Repository, getCacheFunc cache.CacheGetFunc, parseVaaFunc vaaPayloadParser.ParseVaaFunc, logger *zap.Logger) *Service

NewService creates a new VAA Service.

func (*Service) FindAll

func (s *Service) FindAll(
	ctx context.Context,
	params *FindAllParams,
) (*response.Response[[]*VaaDoc], error)

FindAll returns all VAAs.

func (*Service) FindByChain

func (s *Service) FindByChain(
	ctx context.Context,
	chain sdk.ChainID,
	p *pagination.Pagination,
) (*response.Response[[]*VaaDoc], error)

FindByChain get all the vaa by chainID.

func (*Service) FindByEmitter

func (s *Service) FindByEmitter(
	ctx context.Context,
	params *FindByEmitterParams,
) (*response.Response[[]*VaaDoc], error)

FindByEmitter get all the vaa by chainID and emitter address.

func (*Service) FindById

func (s *Service) FindById(
	ctx context.Context,
	chain sdk.ChainID,
	emitter *types.Address,
	seq string,
	includeParsedPayload bool,
) (*response.Response[*VaaDoc], error)

If the parameter [payload] is true, the parse payload is added in the response.

func (*Service) GetVaaCount

func (s *Service) GetVaaCount(ctx context.Context) (*response.Response[[]*VaaStats], error)

GetVaaCount get a list a list of vaa count grouped by chainID.

func (*Service) ParseVaa

ParseVaa parse a vaa payload.

type VaaDoc

type VaaDoc struct {
	ID                string      `bson:"_id" json:"id"`
	Version           uint8       `bson:"version" json:"version"`
	EmitterChain      vaa.ChainID `bson:"emitterChain" json:"emitterChain"`
	EmitterAddr       string      `bson:"emitterAddr" json:"emitterAddr"`
	EmitterNativeAddr string      `json:"emitterNativeAddr,omitempty"`
	Sequence          string      `bson:"sequence" json:"-"`
	PhylaxSetIndex    uint32      `bson:"phylaxSetIndex" json:"phylaxSetIndex"`
	Vaa               []byte      `bson:"vaas" json:"vaa"`
	Timestamp         *time.Time  `bson:"timestamp" json:"timestamp"`
	UpdatedAt         *time.Time  `bson:"updatedAt" json:"updatedAt"`
	IndexedAt         *time.Time  `bson:"indexedAt" json:"indexedAt"`
	// TxHash is an extension field - it is not present in the phylax API.
	TxHash *string `bson:"txHash" json:"txHash,omitempty"`
	// AppId is an extension field - it is not present in the phylax API.
	AppId string `bson:"appId" json:"appId,omitempty"`
	// Payload is an extension field - it is not present in the phylax API.
	Payload map[string]interface{} `bson:"payload" json:"payload,omitempty"`

	// NativeTxHash is an internal field.
	//
	// It is not intended to be accessed by consumers of this package.
	NativeTxHash string `bson:"nativeTxHash" json:"-"`
}

VaaDoc defines the JSON model for VAA objects in the REST API.

func (*VaaDoc) MarshalJSON

func (v *VaaDoc) MarshalJSON() ([]byte, error)

MarshalJSON interface implementation.

type VaaQuery

type VaaQuery struct {
	pagination.Pagination
	// contains filtered or unexported fields
}

VaaQuery respresent a query for the vaa mongodb document.

func Query

func Query() *VaaQuery

Query create a new VaaQuery with default pagination vaues.

func (*VaaQuery) IncludeParsedPayload

func (q *VaaQuery) IncludeParsedPayload(val bool) *VaaQuery

func (*VaaQuery) SetAppId

func (q *VaaQuery) SetAppId(appId string) *VaaQuery

func (*VaaQuery) SetChain

func (q *VaaQuery) SetChain(chainID sdk.ChainID) *VaaQuery

SetChain set the chainId field of the VaaQuery struct.

func (*VaaQuery) SetEmitter

func (q *VaaQuery) SetEmitter(emitter string) *VaaQuery

SetEmitter set the emitter field of the VaaQuery struct.

func (*VaaQuery) SetIDs

func (q *VaaQuery) SetIDs(ids []string) *VaaQuery

func (*VaaQuery) SetPagination

func (q *VaaQuery) SetPagination(p *pagination.Pagination) *VaaQuery

SetPagination set the pagination field of the VaaQuery struct.

func (*VaaQuery) SetSequence

func (q *VaaQuery) SetSequence(seq string) *VaaQuery

SetSequence set the sequence field of the VaaQuery struct.

func (*VaaQuery) SetTxHash

func (q *VaaQuery) SetTxHash(txHash string) *VaaQuery

SetTxHash set the txHash field of the VaaQuery struct.

type VaaStats

type VaaStats struct {
	ChainID vaa.ChainID `bson:"_id" json:"chainId"`
	Count   int64       `bson:"count" json:"count"`
}

VaaStats definition.

Jump to

Keyboard shortcuts

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