domain

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: 9 Imported by: 20

Documentation

Index

Constants

View Source
const (
	P2pMainNet = "mainnet"
	P2pTestNet = "testnet"
	P2pDevNet  = "devnet"
)

p2p network constants.

View Source
const (
	AppIdUnkonwn           = "UNKONWN"
	AppIdPortalTokenBridge = "PORTAL_TOKEN_BRIDGE"
)
View Source
const (
	DstTxStatusFailedToProcess = "failed"
	DstTxStatusConfirmed       = "completed"
	DstTxStatusUnkonwn         = "unknown"
)
View Source
const (
	SignedVaaType           = "signed-vaa"
	PublishedLogMessageType = "published-log-message"
)

Variables

This section is empty.

Functions

func ChainIdIsValid

func ChainIdIsValid(id sdk.ChainID) bool

ChainIdIsValid returns true if and only if the given chain ID exists.

func DecodeNativeAddressToHex

func DecodeNativeAddressToHex(chainID sdk.ChainID, address string) (string, error)

DecodeNativeAddressToHex decodes a native address to hex.

func EncodeTrxHashByChainID

func EncodeTrxHashByChainID(chainID sdk.ChainID, txHash []byte) (string, error)

EncodeTrxHashByChainID encodes the transaction hash by chain id with different encoding methods.

func GetAllCoingeckoIDs

func GetAllCoingeckoIDs() []string

GetAllCoingeckoIDs returns a list of all coingecko IDs that exist in the database.

func GetEventPayload

func GetEventPayload[T EventPayload](e *NotificationEvent) (T, error)

func GetSupportedChainIDs

func GetSupportedChainIDs() map[sdk.ChainID]string

GetSupportedChainIDs returns a map of all supported chain IDs to their respective names.

func TranslateEmitterAddress

func TranslateEmitterAddress(chainID sdk.ChainID, address string) (string, error)

TranslateEmitterAddress converts an emitter address into the corresponding native address for the given chain.

Types

type EventPayload

type EventPayload interface {
	SignedVaa | PublishedLogMessage
}

type NotificationEvent

type NotificationEvent struct {
	TrackID string          `json:"trackId"`
	Source  string          `json:"source"`
	Type    string          `json:"type"`
	Payload json.RawMessage `json:"payload"`
}

func NewNotificationEvent

func NewNotificationEvent[T EventPayload](trackID, source, _type string, payload T) (*NotificationEvent, error)

type PublishedLogMessage

type PublishedLogMessage struct {
	ID           string    `json:"id"`
	EmitterChain uint16    `json:"emitterChain"`
	EmitterAddr  string    `json:"emitterAddr"`
	Sequence     uint64    `json:"sequence"`
	Timestamp    time.Time `json:"timestamp"`
	Vaa          []byte    `json:"vaa"`
	TxHash       string    `json:"txHash"`
}

type SignedVaa

type SignedVaa struct {
	ID             string    `json:"id"`
	EmitterChain   uint16    `json:"emitterChain"`
	EmitterAddr    string    `json:"emitterAddr"`
	Sequence       uint64    `json:"sequence"`
	PhylaxSetIndex uint32    `json:"phylaxSetIndex"`
	Timestamp      time.Time `json:"timestamp"`
	Vaa            []byte    `json:"vaa"`
	TxHash         string    `json:"txHash"`
	Version        int       `json:"version"`
}

type SourceTxStatus

type SourceTxStatus string

SourceTxStatus is meant to be a user-facing enum that describes the status of the source transaction.

const (
	// SourceTxStatusChainNotSupported indicates that the processing failed due to the chain ID not being supported.
	//
	// (i.e.: there is no adapter for that chain yet)
	SourceTxStatusChainNotSupported SourceTxStatus = "chainNotSupported"

	// SourceTxStatusInternalError represents an internal, unspecified error.
	SourceTxStatusInternalError SourceTxStatus = "internalError"

	// SourceTxStatusConfirmed indicates that the transaciton has been processed successfully.
	SourceTxStatusConfirmed SourceTxStatus = "confirmed"
)

type Symbol

type Symbol string

Symbol identifies a publicly traded token (i.e. "ETH" for Ethereum, "ALGO" for Algorand, etc.)

func (Symbol) String

func (s Symbol) String() string

type TokenMetadata

type TokenMetadata struct {
	TokenChain   sdk.ChainID
	TokenAddress string
	// Symbol is the name that crypto exchanges use to list the underlying asset represented by this token.
	// For example, the underlying symbol of the token "USDCso (USDC minted on Solana)" is "USDC".
	Symbol      Symbol
	CoingeckoID string
	Decimals    int64
}

TokenMetadata contains information about a token supported by Portal Token Bridge.

func GetAllTokens

func GetAllTokens() []TokenMetadata

GetAllTokens returns a list of all tokens that exist in the database.

The caller must not modify the `[]TokenMetadata` returned.

func GetTokenByAddress

func GetTokenByAddress(tokenChain sdk.ChainID, tokenAddress string) (*TokenMetadata, bool)

GetTokenByAddress returns information about a token identified by its original mint address.

The caller must not modify the `*TokenMetadata` returned.

func GetTokenByCoingeckoID

func GetTokenByCoingeckoID(coingeckoID string) (*TokenMetadata, bool)

GetTokenByCoingeckoID returns information about a token identified by its coingecko ID.

The caller must not modify the `*TokenMetadata` returned.

func (*TokenMetadata) GetTokenID

func (t *TokenMetadata) GetTokenID() string

Jump to

Keyboard shortcuts

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