api

package
v0.0.0-...-cbca9c8 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2022 License: MIT Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContentTypeHeader = "Content-Type"
	ContentTypeJSON   = "application/json"
)
View Source
const TeleportrAPINamespace = "teleportr_api"

Variables

This section is empty.

Functions

func GetReqID

func GetReqID(ctx context.Context) string

func HandleHealthz

func HandleHealthz(w http.ResponseWriter, r *http.Request)

func Main

func Main(gitVersion string) func(*cli.Context) error

Types

type ChainData

type ChainData struct {
	MaxBalance             *big.Int
	DisburserBalance       *big.Int
	NextDisbursementID     uint64
	DepositContractBalance *big.Int
	NextDepositID          uint64
	MaxDepositAmount       *big.Int
	MinDepositAmount       *big.Int
}

type ChainDataReader

type ChainDataReader interface {
	Get(ctx context.Context) (*ChainData, error)
}

func NewCachingChainDataReader

func NewCachingChainDataReader(inner ChainDataReader, interval time.Duration) ChainDataReader

func NewChainDataReader

func NewChainDataReader(
	l1Client, l2Client *ethclient.Client,
	depositContractAddr, disburserWalletAddr common.Address,
	depositContract *deposit.TeleportrDeposit,
	disburserContract *disburse.TeleportrDisburser,
) ChainDataReader

type Config

type Config struct {
	Hostname               string
	Port                   uint16
	L1EthRpc               string
	L2EthRpc               string
	DepositAddress         string
	NumConfirmations       uint64
	DisburserWalletAddress string
	DisburserAddress       string
	PostgresHost           string
	PostgresPort           uint16
	PostgresUser           string
	PostgresPassword       string
	PostgresDBName         string
	PostgresEnableSSL      bool
	MetricsServerEnable    bool
	MetricsHostname        string
	MetricsPort            uint64
	DisableHTTP2           bool
}

func NewConfig

func NewConfig(ctx *cli.Context) (Config, error)

type ContextKey

type ContextKey string
const (
	ContextKeyReqID ContextKey = "req_id"

	MaxLagBeforeUnavailable = 10
)

type Error

type Error interface {
	error
	Status() int
}

type EstimateResponse

type EstimateResponse struct {
	BaseFee     string `json:"base_fee"`
	GasTipCap   string `json:"gas_tip_cap"`
	GasFeeCap   string `json:"gas_fee_cap"`
	GasEstimate string `json:"gas_estimate"`
}

type HistoryResponse

type HistoryResponse struct {
	Teleports []RPCTeleport `json:"teleports"`
}

type RPCDisbursement

type RPCDisbursement struct {
	TxHash         string `json:"tx_hash"`
	BlockNumber    string `json:"block_number"`
	BlockTimestamp string `json:"block_timestamp_unix"`
	Success        bool   `json:"success"`
}

type RPCTeleport

type RPCTeleport struct {
	ID             string           `json:"id"`
	Address        string           `json:"address"`
	AmountWei      string           `json:"amount_wei"`
	TxHash         string           `json:"tx_hash"`
	BlockNumber    string           `json:"block_number"`
	BlockTimestamp string           `json:"block_timestamp_unix"`
	Disbursement   *RPCDisbursement `json:"disbursement"`
}

type Server

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

func NewServer

func NewServer(
	ctx context.Context,
	l1Client *ethclient.Client,
	l2Client *ethclient.Client,
	database *db.Database,
	chainDataReader ChainDataReader,
	depositAddr common.Address,
	numConfirmations uint64,
) *Server

func (*Server) HandleEstimate

func (s *Server) HandleEstimate(
	ctx context.Context,
	w http.ResponseWriter,
	r *http.Request,
) error

func (*Server) HandleHistory

func (s *Server) HandleHistory(
	ctx context.Context,
	w http.ResponseWriter,
	r *http.Request,
) error

func (*Server) HandleStatus

func (s *Server) HandleStatus(
	ctx context.Context,
	w http.ResponseWriter,
	r *http.Request,
) error

func (*Server) HandleTrack

func (s *Server) HandleTrack(
	ctx context.Context,
	w http.ResponseWriter,
	r *http.Request,
) error

func (*Server) ListenAndServe

func (s *Server) ListenAndServe(host string, port uint16) error

type StatusError

type StatusError struct {
	Code int
	Err  error
}

func (StatusError) Error

func (se StatusError) Error() string

func (StatusError) Status

func (se StatusError) Status() int

type StatusResponse

type StatusResponse struct {
	DisburserWalletBalanceWei string `json:"disburser_wallet_balance_wei"`
	DepositContractBalanceWei string `json:"deposit_contract_balance_wei"`
	MaximumBalanceWei         string `json:"maximum_balance_wei"`
	MinDepositAmountWei       string `json:"min_deposit_amount_wei"`
	MaxDepositAmountWei       string `json:"max_deposit_amount_wei"`
	DisbursementLag           uint64 `json:"disbursement_lag"`
	IsAvailable               bool   `json:"is_available"`
}

type TrackResponse

type TrackResponse struct {
	CurrentBlockNumber     string      `json:"current_block_number"`
	ConfirmationsRequired  string      `json:"confirmations_required"`
	ConfirmationsRemaining string      `json:"confirmations_remaining"`
	Teleport               RPCTeleport `json:"teleport"`
}

Jump to

Keyboard shortcuts

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