operations

package
v0.0.0-...-3f71ca0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildPipelineSearchByChainAndAppID

func BuildPipelineSearchByChainAndAppID(query OperationQuery) mongo.Pipeline

Types

type AttributeDoc

type AttributeDoc struct {
	Type  string         `bson:"type" json:"type"`
	Value map[string]any `bson:"value" json:"value"`
}

AttributeDoc represents a custom attribute for a origin transaction.

type DestinationTx

type DestinationTx struct {
	ChainID     sdk.ChainID `bson:"chainId" json:"chainId"`
	Status      string      `bson:"status" json:"status"`
	Method      string      `bson:"method" json:"method"`
	TxHash      string      `bson:"txHash" json:"txHash"`
	From        string      `bson:"from" json:"from"`
	To          string      `bson:"to" json:"to"`
	BlockNumber string      `bson:"blockNumber" json:"blockNumber"`
	Timestamp   *time.Time  `bson:"timestamp" json:"timestamp"`
	UpdatedAt   *time.Time  `bson:"updatedAt" json:"updatedAt"`
}

DestinationTx represents a destination transaction.

type GlobalTransactionDoc

type GlobalTransactionDoc struct {
	ID            string         `bson:"_id" json:"id"`
	OriginTx      *OriginTx      `bson:"originTx" json:"originTx"`
	DestinationTx *DestinationTx `bson:"destinationTx" json:"destinationTx"`
}

GlobalTransactionDoc definitions.

type OperationDto

type OperationDto struct {
	ID                     string                  `bson:"_id"`
	TxHash                 string                  `bson:"txHash"`
	Symbol                 string                  `bson:"symbol"`
	UsdAmount              string                  `bson:"usdAmount"`
	TokenAmount            string                  `bson:"tokenAmount"`
	Vaa                    *VaaDto                 `bson:"vaa"`
	SourceTx               *OriginTx               `bson:"originTx" json:"originTx"`
	DestinationTx          *DestinationTx          `bson:"destinationTx" json:"destinationTx"`
	Payload                map[string]any          `bson:"payload"`
	StandardizedProperties *StandardizedProperties `bson:"standardizedProperties"`
}

OperationDto operation data transfer object.

type OperationFilter

type OperationFilter struct {
	TxHash         *types.TxHash
	Address        string
	SourceChainIDs []vaa.ChainID
	TargetChainIDs []vaa.ChainID
	AppIDs         []string
	ExclusiveAppId bool
	Pagination     pagination.Pagination
}

type OperationQuery

type OperationQuery struct {
	Pagination     pagination.Pagination
	TxHash         string
	Address        string
	SourceChainIDs []vaa.ChainID
	TargetChainIDs []vaa.ChainID
	AppIDs         []string
	ExclusiveAppId bool
}

type OriginTx

type OriginTx struct {
	TxHash    string        `bson:"nativeTxHash" json:"txHash"`
	From      string        `bson:"from" json:"from"`
	Status    string        `bson:"status" json:"status"`
	Timestamp *time.Time    `bson:"timestamp" json:"timestamp"`
	Attribute *AttributeDoc `bson:"attribute" json:"attribute"`
}

OriginTx represents a origin transaction.

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

func (r *Repository) FindAll(ctx context.Context, query OperationQuery) ([]*OperationDto, error)

FindAll returns all operations filtered by q.

func (*Repository) FindByChainAndAppId

func (r *Repository) FindByChainAndAppId(ctx context.Context, query OperationQuery) ([]*OperationDto, error)

func (*Repository) FindById

func (r *Repository) FindById(ctx context.Context, id string) (*OperationDto, error)

FindById returns the operations for the given chainID/emitter/seq.

type Service

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

func NewService

func NewService(repo *Repository, logger *zap.Logger) *Service

NewService create a new Service.

func (*Service) FindAll

func (s *Service) FindAll(ctx context.Context, filter OperationFilter) ([]*OperationDto, error)

FindAll returns all operations filtered by q.

func (*Service) FindById

func (s *Service) FindById(ctx context.Context, chainID vaa.ChainID,
	emitter *types.Address, seq string) (*OperationDto, error)

FindById returns the operations for the given chainID/emitter/seq.

type StandardizedProperties

type StandardizedProperties struct {
	AppIds       []string    `json:"appIds" bson:"appIds"`
	FromChain    sdk.ChainID `json:"fromChain" bson:"fromChain"`
	FromAddress  string      `json:"fromAddress" bson:"fromAddress"`
	ToChain      sdk.ChainID `json:"toChain" bson:"toChain"`
	ToAddress    string      `json:"toAddress" bson:"toAddress"`
	TokenChain   sdk.ChainID `json:"tokenChain" bson:"tokenChain"`
	TokenAddress string      `json:"tokenAddress" bson:"tokenAddress"`
	Amount       string      `json:"amount" bson:"amount"`
	FeeAddress   string      `json:"feeAddress" bson:"feeAddress"`
	FeeChain     sdk.ChainID `json:"feeChain" bson:"feeChain"`
	Fee          string      `json:"fee" bson:"fee"`
}

StandardizedProperties represents the standardized properties of a operation.

type VaaDto

type VaaDto struct {
	ID                string      `bson:"_id" json:"id"`
	Version           uint8       `bson:"version" json:"version"`
	EmitterChain      sdk.ChainID `bson:"emitterChain" json:"emitterChain"`
	EmitterAddr       string      `bson:"emitterAddr" json:"emitterAddr"`
	EmitterNativeAddr string      `json:"emitterNativeAddr,omitempty"`
	Sequence          string      `bson:"sequence" json:"-"`
	GuardianSetIndex  uint32      `bson:"guardianSetIndex" json:"guardianSetIndex"`
	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"`
	Hash              []byte      `bson:"hash" json:"hash"`
	IsDuplicated      bool        `bson:"isDuplicated" json:"isDuplicated"`
}

VaaDto vaa data transfer object.

Jump to

Keyboard shortcuts

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