types

package
v0.1.5 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	Created  string = "created"
	Pending  string = "pending"
	Attested string = "attested"
	Complete string = "complete"
	Failed   string = "failed"
	Filtered string = "filtered"

	Mint    string = "mint"
	Forward string = "forward"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	Type          string `json:"@type"`
	Address       string `json:"address"`
	AccountNumber string `json:"account_number"`
	Sequence      string `json:"sequence"`
}

type AccountResp

type AccountResp struct {
	Account `json:"account"`
}

type AttestationResponse

type AttestationResponse struct {
	Attestation string `json:"attestation"`
	Status      string `json:"status"`
}

AttestationResponse is the response received from Circle's iris api Example: https://iris-api-sandbox.circle.com/attestations/0x85bbf7e65a5992e6317a61f005e06d9972a033d71b514be183b179e1b47723fe

type Attribute

type Attribute struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type BlockResponse

type BlockResponse struct {
	Result struct {
		Block struct {
			Header struct {
				Height string `json:"height"`
			} `json:"header"`
		} `json:"block"`
	} `json:"result"`
}

type BlockResultsResponse

type BlockResultsResponse struct {
	Result struct {
		Txs []Tx `json:"txs"`
	} `json:"result"`
}

type BurnMessage

type BurnMessage struct {
	Version       uint32
	BurnToken     []byte
	MintRecipient []byte
	Amount        *big.Int
	MessageSender []byte
}

BurnMessage defines ... https://github.com/circlefin/evm-cctp-contracts/blob/d53f0e1937a0a5c5158d356b6767b77dc32dcc90/src/messages/BurnMessage.sol#L24-L29

func (*BurnMessage) Parse

func (c *BurnMessage) Parse(bz []byte) (*BurnMessage, error)

type Chain added in v0.1.1

type Chain interface {
	// Name returns the name of the chain.
	Name() string

	// Domain returns the domain ID of the chain.
	Domain() Domain

	// LatestBlockain returns the last queired height of the chain
	LatestBlock() uint64

	// SetLatestBlock sets the latest block
	SetLatestBlock(block uint64)

	// LastFlushedBlock returns the last block included in a flush. In the rare situation of a crash,
	// this block is a good block to start at to catch up on any missed transactions.
	LastFlushedBlock() uint64

	// IsDestinationCaller returns true if the specified destination caller is the minter for the specified domain OR
	// if destination caller is a zero byte array(left empty in deposit for burn message). It also returns a human readable
	// version of the destination caller address provided in the message.
	IsDestinationCaller(destinationCaller []byte) (isCaller bool, readableAddress string)

	// InitializeClients initializes the rpc and or websocket clients.
	InitializeClients(
		ctx context.Context,
		logger log.Logger,
	) error

	// CloseClients is a cleanup function to close any open clients
	CloseClients() error

	// InitializeBroadcaster initializes the minter account info for the chain.
	InitializeBroadcaster(
		ctx context.Context,
		logger log.Logger,
		sequenceMap *SequenceMap,
	) error

	// StartListener starts a listener for observing new CCTP burn messages.
	StartListener(
		ctx context.Context,
		logger log.Logger,
		processingQueue chan *TxState,
		flushInterval time.Duration,
	)

	// Broadcast broadcasts CCTP mint messages to the chain.
	Broadcast(
		ctx context.Context,
		logger log.Logger,
		msgs []*MessageState,
		sequenceMap *SequenceMap,
		metrics *relayer.PromMetrics,
	) error

	TrackLatestBlockHeight(
		ctx context.Context,
		logger log.Logger,
		metrics *relayer.PromMetrics,
	)

	WalletBalanceMetric(
		ctx context.Context,
		logger log.Logger,
		metrics *relayer.PromMetrics,
	)
}

Chain is an interface for common CCTP source and destination chain operations.

type ChainConfig added in v0.1.1

type ChainConfig interface {
	Chain(name string) (Chain, error)
}

type CircleSettings added in v0.1.2

type CircleSettings struct {
	AttestationBaseURL string `yaml:"attestation-base-url"`
	FetchRetries       int    `yaml:"fetch-retries"`
	FetchRetryInterval int    `yaml:"fetch-retry-interval"`
}

type Config added in v0.1.1

type Config struct {
	Chains        map[string]ChainConfig `yaml:"chains"`
	EnabledRoutes map[Domain][]Domain    `yaml:"enabled-routes"`
	Circle        CircleSettings         `yaml:"circle"`

	ProcessorWorkerCount uint32 `yaml:"processor-worker-count"`
	API                  struct {
		TrustedProxies []string `yaml:"trusted-proxies"`
	} `yaml:"api"`
}

type ConfigWrapper added in v0.1.1

type ConfigWrapper struct {
	Chains        map[string]map[string]any `yaml:"chains"`
	EnabledRoutes map[Domain][]Domain       `yaml:"enabled-routes"`
	Circle        CircleSettings            `yaml:"circle"`

	ProcessorWorkerCount uint32 `yaml:"processor-worker-count"`
	API                  struct {
		TrustedProxies []string `yaml:"trusted-proxies"`
	} `yaml:"api"`
}

type Domain added in v0.1.1

type Domain uint32

type Event

type Event struct {
	Type       string      `json:"type"`
	Attributes []Attribute `json:"attributes"`
}

type Message

type Message struct {
	Version           uint32
	SourceDomain      uint32
	DestinationDomain uint32
	Nonce             uint64
	Sender            []byte
	Recipient         []byte
	DestinationCaller []byte
	MessageBody       []byte
}

Message defines ... https://github.com/circlefin/evm-cctp-contracts/blob/d53f0e1937a0a5c5158d356b6767b77dc32dcc90/src/messages/Message.sol#L29-L37

func (*Message) Parse

func (msg *Message) Parse(bz []byte) (*Message, error)

type MessageState

type MessageState struct {
	IrisLookupID      string // hex encoded MessageSent bytes
	Status            string // created, pending, attested, complete, failed, filtered
	Attestation       string // hex encoded attestation
	SourceDomain      Domain // uint32 source domain id
	DestDomain        Domain // uint32 destination domain id
	SourceTxHash      string
	DestTxHash        string
	MsgSentBytes      []byte // bytes of the MessageSent message transmitter event
	MsgBody           []byte // bytes of the MessageBody
	DestinationCaller []byte // address authorized to call transaction
	Channel           string // "channel-%d" if a forward, empty if not a forward
	Created           time.Time
	Updated           time.Time
	Nonce             uint64
}

func EvmLogToMessageState

func EvmLogToMessageState(abi abi.ABI, messageSent abi.Event, log *ethtypes.Log) (messageState *MessageState, err error)

EvmLogToMessageState transforms an evm log into a messageState given an ABI

func (*MessageState) Equal added in v0.1.1

func (m *MessageState) Equal(other *MessageState) bool

Equal checks if two MessageState instances are equal

type MetadataMessage

type MetadataMessage struct {
	Nonce     uint64
	Sender    []byte
	Channel   uint64
	Prefix    string
	Recipient []byte
	Memo      string
}

MetadataMessage defines ...

func (*MetadataMessage) Parse

func (c *MetadataMessage) Parse(bz []byte) (*MetadataMessage, error)

type SequenceMap

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

SequenceMap holds a minter account's txn count to avoid account sequence mismatch errors

func NewSequenceMap

func NewSequenceMap() *SequenceMap

func (*SequenceMap) Next

func (m *SequenceMap) Next(destDomain Domain) uint64

func (*SequenceMap) Put

func (m *SequenceMap) Put(destDomain Domain, val uint64)

type StateMap

type StateMap struct {
	Mu sync.Mutex
	// contains filtered or unexported fields
}

StateMap wraps sync.Map with type safety maps source tx hash -> TxState

func NewStateMap

func NewStateMap() *StateMap

func (*StateMap) Delete

func (sm *StateMap) Delete(key string)

func (*StateMap) Load

func (sm *StateMap) Load(key string) (value *TxState, ok bool)

load loads the message states tied to a specific transaction hash

func (*StateMap) Store

func (sm *StateMap) Store(key string, value *TxState)

store stores the message states tied to a specific transaction hash

type Tx

type Tx struct {
	Hash     string `json:"hash"`
	TxResult struct {
		Code int    `json:"code"`
		Log  string `json:"log"`
	} `json:"tx_result"`
}

type TxState added in v0.1.1

type TxState struct {
	TxHash       string
	Msgs         []*MessageState
	RetryAttempt int
}

Jump to

Keyboard shortcuts

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