interfaces

package
v0.0.0-...-1329066 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package interfaces provides interfaces for clients and signers for the chain to interact with

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BTCRPCClient

type BTCRPCClient interface {
	GetNetworkInfo() (*btcjson.GetNetworkInfoResult, error)
	CreateWallet(name string, opts ...rpcclient.CreateWalletOpt) (*btcjson.CreateWalletResult, error)
	GetNewAddress(account string) (btcutil.Address, error)
	GenerateToAddress(numBlocks int64, address btcutil.Address, maxTries *int64) ([]*chainhash.Hash, error)
	GetBalance(account string) (btcutil.Amount, error)
	SendRawTransaction(tx *wire.MsgTx, allowHighFees bool) (*chainhash.Hash, error)
	ListUnspent() ([]btcjson.ListUnspentResult, error)
	ListUnspentMinMaxAddresses(minConf int, maxConf int, addrs []btcutil.Address) ([]btcjson.ListUnspentResult, error)
	EstimateSmartFee(confTarget int64, mode *btcjson.EstimateSmartFeeMode) (*btcjson.EstimateSmartFeeResult, error)
	GetTransaction(txHash *chainhash.Hash) (*btcjson.GetTransactionResult, error)
	GetRawTransaction(txHash *chainhash.Hash) (*btcutil.Tx, error)
	GetRawTransactionVerbose(txHash *chainhash.Hash) (*btcjson.TxRawResult, error)
	GetBlockCount() (int64, error)
	GetBlockHash(blockHeight int64) (*chainhash.Hash, error)
	GetBlockVerbose(blockHash *chainhash.Hash) (*btcjson.GetBlockVerboseResult, error)
	GetBlockVerboseTx(blockHash *chainhash.Hash) (*btcjson.GetBlockVerboseTxResult, error)
	GetBlockHeader(blockHash *chainhash.Hash) (*wire.BlockHeader, error)
}

BTCRPCClient is the interface for BTC RPC client

WARN: you must add any RPCs used on mainnet/testnet to the whitelist in https://github.com/zeta-chain/bitcoin-core-docker

type ChainObserver

type ChainObserver interface {
	// Start starts the observer
	Start(ctx context.Context)

	// Stop stops the observer
	Stop()

	// ChainParams returns observer chain params (might be out of date with zetacore)
	ChainParams() observertypes.ChainParams

	// SetChainParams sets observer chain params
	SetChainParams(observertypes.ChainParams)

	// VoteOutboundIfConfirmed checks outbound status and returns (continueKeySign, error)
	// todo we should make this simpler.
	VoteOutboundIfConfirmed(ctx context.Context, cctx *crosschaintypes.CrossChainTx) (bool, error)
}

ChainObserver is the interface for chain observer

type ChainSigner

type ChainSigner interface {
	TryProcessOutbound(
		ctx context.Context,
		cctx *crosschaintypes.CrossChainTx,
		outboundProc *outboundprocessor.Processor,
		outboundID string,
		observer ChainObserver,
		zetacoreClient ZetacoreClient,
		height uint64,
	)
	SetZetaConnectorAddress(address ethcommon.Address)
	SetERC20CustodyAddress(address ethcommon.Address)
	GetZetaConnectorAddress() ethcommon.Address
	GetERC20CustodyAddress() ethcommon.Address
	SetGatewayAddress(address string)
	GetGatewayAddress() string
}

ChainSigner is the interface to sign transactions for a chain

type EVMJSONRPCClient

type EVMJSONRPCClient interface {
	EthGetBlockByNumber(number int, withTransactions bool) (*ethrpc.Block, error)
	EthGetTransactionByHash(hash string) (*ethrpc.Transaction, error)
}

EVMJSONRPCClient is the interface for EVM JSON RPC client

type EVMRPCClient

type EVMRPCClient interface {
	bind.ContractBackend
	SendTransaction(ctx context.Context, tx *ethtypes.Transaction) error
	SuggestGasPrice(ctx context.Context) (*big.Int, error)
	BlockNumber(ctx context.Context) (uint64, error)
	BlockByNumber(ctx context.Context, number *big.Int) (*ethtypes.Block, error)
	HeaderByNumber(ctx context.Context, number *big.Int) (*ethtypes.Header, error)
	TransactionByHash(ctx context.Context, hash ethcommon.Hash) (tx *ethtypes.Transaction, isPending bool, err error)
	TransactionReceipt(ctx context.Context, txHash ethcommon.Hash) (*ethtypes.Receipt, error)
	TransactionSender(
		ctx context.Context,
		tx *ethtypes.Transaction,
		block ethcommon.Hash,
		index uint,
	) (ethcommon.Address, error)
}

EVMRPCClient is the interface for EVM RPC client

type Order

type Order string
const (
	NoOrder    Order = ""
	Ascending  Order = "ASC"
	Descending Order = "DESC"
)

type SolanaRPCClient

type SolanaRPCClient interface {
	GetVersion(ctx context.Context) (*solrpc.GetVersionResult, error)
	GetHealth(ctx context.Context) (string, error)
	GetSlot(ctx context.Context, commitment solrpc.CommitmentType) (uint64, error)
	GetBlockTime(ctx context.Context, block uint64) (*solana.UnixTimeSeconds, error)
	GetAccountInfo(ctx context.Context, account solana.PublicKey) (*solrpc.GetAccountInfoResult, error)
	GetBalance(
		ctx context.Context,
		account solana.PublicKey,
		commitment solrpc.CommitmentType,
	) (*solrpc.GetBalanceResult, error)
	GetLatestBlockhash(ctx context.Context, commitment solrpc.CommitmentType) (*solrpc.GetLatestBlockhashResult, error)
	GetRecentPrioritizationFees(
		ctx context.Context,
		accounts solana.PublicKeySlice,
	) ([]solrpc.PriorizationFeeResult, error)
	GetTransaction(
		ctx context.Context,
		txSig solana.Signature,
		opts *solrpc.GetTransactionOpts,
	) (*solrpc.GetTransactionResult, error)
	GetConfirmedTransactionWithOpts(
		ctx context.Context,
		signature solana.Signature,
		opts *solrpc.GetTransactionOpts,
	) (*solrpc.TransactionWithMeta, error)
	GetSignaturesForAddressWithOpts(
		ctx context.Context,
		account solana.PublicKey,
		opts *solrpc.GetSignaturesForAddressOpts,
	) ([]*solrpc.TransactionSignature, error)
	SendTransactionWithOpts(
		ctx context.Context,
		transaction *solana.Transaction,
		opts solrpc.TransactionOpts,
	) (solana.Signature, error)
}

SolanaRPCClient is the interface for Solana RPC client

type TSSSigner

type TSSSigner interface {
	PubKey() tss.PubKey
	Sign(ctx context.Context, data []byte, height, nonce uint64, chainID int64) ([65]byte, error)
	SignBatch(ctx context.Context, digests [][]byte, height, nonce uint64, chainID int64) ([][65]byte, error)
}

TSSSigner is the interface for TSS signer

type ZetacoreClient

type ZetacoreClient interface {
	ZetacoreVoter

	Chain() chains.Chain
	GetLogger() *zerolog.Logger
	GetKeys() keyinterfaces.ObserverKeys

	GetSupportedChains(ctx context.Context) ([]chains.Chain, error)
	GetAdditionalChains(ctx context.Context) ([]chains.Chain, error)
	GetChainParams(ctx context.Context) ([]*observertypes.ChainParams, error)

	GetKeyGen(ctx context.Context) (observertypes.Keygen, error)
	GetTSS(ctx context.Context) (observertypes.TSS, error)
	GetTSSHistory(ctx context.Context) ([]observertypes.TSS, error)
	PostVoteTSS(
		ctx context.Context,
		tssPubKey string,
		keyGenZetaHeight int64,
		status chains.ReceiveStatus,
	) (string, error)

	GetBlockHeight(ctx context.Context) (int64, error)

	ListPendingCCTX(ctx context.Context, chainID int64) ([]*crosschaintypes.CrossChainTx, uint64, error)
	ListPendingCCTXWithinRateLimit(
		ctx context.Context,
	) (*crosschaintypes.QueryListPendingCctxWithinRateLimitResponse, error)

	GetRateLimiterInput(ctx context.Context, window int64) (*crosschaintypes.QueryRateLimiterInputResponse, error)
	GetPendingNoncesByChain(ctx context.Context, chainID int64) (observertypes.PendingNonces, error)

	GetCctxByNonce(ctx context.Context, chainID int64, nonce uint64) (*crosschaintypes.CrossChainTx, error)
	GetOutboundTracker(ctx context.Context, chain chains.Chain, nonce uint64) (*crosschaintypes.OutboundTracker, error)
	GetAllOutboundTrackerByChain(
		ctx context.Context,
		chainID int64,
		order Order,
	) ([]crosschaintypes.OutboundTracker, error)
	GetCrosschainFlags(ctx context.Context) (observertypes.CrosschainFlags, error)
	GetRateLimiterFlags(ctx context.Context) (crosschaintypes.RateLimiterFlags, error)
	GetObserverList(ctx context.Context) ([]string, error)
	GetBTCTSSAddress(ctx context.Context, chainID int64) (string, error)
	GetZetaHotKeyBalance(ctx context.Context) (sdkmath.Int, error)
	GetInboundTrackersForChain(ctx context.Context, chainID int64) ([]crosschaintypes.InboundTracker, error)

	GetUpgradePlan(ctx context.Context) (*upgradetypes.Plan, error)

	PostOutboundTracker(ctx context.Context, chainID int64, nonce uint64, txHash string) (string, error)
}

ZetacoreClient is the client interface to interact with zetacore

type ZetacoreVoter

type ZetacoreVoter interface {
	PostVoteGasPrice(
		ctx context.Context,
		chain chains.Chain,
		gasPrice, priorityFee, blockNum uint64,
	) (string, error)
	PostVoteInbound(
		ctx context.Context,
		gasLimit, retryGasLimit uint64,
		msg *crosschaintypes.MsgVoteInbound,
	) (string, string, error)
	PostVoteOutbound(
		ctx context.Context,
		gasLimit, retryGasLimit uint64,
		msg *crosschaintypes.MsgVoteOutbound,
	) (string, string, error)
	PostVoteBlameData(ctx context.Context, blame *blame.Blame, chainID int64, index string) (string, error)
}

Jump to

Keyboard shortcuts

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