Documentation ¶
Index ¶
- Constants
- type FindAllParams
- type FindByEmitterParams
- type Repository
- func (r *Repository) FindVaas(ctx context.Context, q *VaaQuery) ([]*VaaDoc, error)
- func (r *Repository) FindVaasByEmitterAndToChain(ctx context.Context, query *VaaQuery, toChain sdk.ChainID) ([]*VaaDoc, error)
- func (r *Repository) FindVaasByTxHashWorkaround(ctx context.Context, query *VaaQuery) ([]*VaaDoc, error)
- func (r *Repository) GetVaaCount(ctx context.Context, q *VaaQuery) ([]*VaaStats, error)
- type Service
- func (s *Service) FindAll(ctx context.Context, params *FindAllParams) (*response.Response[[]*VaaDoc], error)
- func (s *Service) FindByChain(ctx context.Context, chain sdk.ChainID, p *pagination.Pagination) (*response.Response[[]*VaaDoc], error)
- func (s *Service) FindByEmitter(ctx context.Context, params *FindByEmitterParams) (*response.Response[[]*VaaDoc], error)
- func (s *Service) FindById(ctx context.Context, chain sdk.ChainID, emitter *types.Address, seq string, ...) (*response.Response[*VaaDoc], error)
- func (s *Service) GetVaaCount(ctx context.Context) (*response.Response[[]*VaaStats], error)
- func (s *Service) ParseVaa(ctx context.Context, vaaByte []byte) (vaaPayloadParser.ParseVaaWithStandarizedPropertiesdResponse, error)
- type VaaDoc
- type VaaQuery
- func (q *VaaQuery) IncludeParsedPayload(val bool) *VaaQuery
- func (q *VaaQuery) SetAppId(appId string) *VaaQuery
- func (q *VaaQuery) SetChain(chainID sdk.ChainID) *VaaQuery
- func (q *VaaQuery) SetEmitter(emitter string) *VaaQuery
- func (q *VaaQuery) SetIDs(ids []string) *VaaQuery
- func (q *VaaQuery) SetPagination(p *pagination.Pagination) *VaaQuery
- func (q *VaaQuery) SetSequence(seq string) *VaaQuery
- func (q *VaaQuery) SetTxHash(txHash string) *VaaQuery
- type VaaStats
Constants ¶
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 ¶
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 ¶
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 ¶
GetVaaCount get a list a list of vaa count grouped by chainID.
func (*Service) ParseVaa ¶
func (s *Service) ParseVaa(ctx context.Context, vaaByte []byte) (vaaPayloadParser.ParseVaaWithStandarizedPropertiesdResponse, error)
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 ¶
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 (*VaaQuery) IncludeParsedPayload ¶
func (*VaaQuery) SetEmitter ¶
SetEmitter set the emitter field of the VaaQuery struct.
func (*VaaQuery) SetPagination ¶
func (q *VaaQuery) SetPagination(p *pagination.Pagination) *VaaQuery
SetPagination set the pagination field of the VaaQuery struct.
func (*VaaQuery) SetSequence ¶
SetSequence set the sequence field of the VaaQuery struct.