api

package
v0.0.0-...-412688d Latest Latest
Warning

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

Go to latest
Published: May 4, 2022 License: MIT Imports: 31 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 Config

type Config struct {
	Hostname          string
	Port              uint16
	L1EthRpc          string
	DepositAddress    string
	NumConfirmations  uint64
	PostgresHost      string
	PostgresPort      uint16
	PostgresUser      string
	PostgresPassword  string
	PostgresDBName    string
	PostgresEnableSSL bool
	DisableHTTP2      bool
}

func NewConfig

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

type ContextKey

type ContextKey string
const (
	ContextKeyReqID ContextKey = "req_id"
)

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,
	database *db.Database,
	depositAddr common.Address,
	depositContract *deposit.TeleportrDeposit,
	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 {
	CurrentBalanceWei   string `json:"current_balance_wei"`
	MaximumBalanceWei   string `json:"maximum_balance_wei"`
	MinDepositAmountWei string `json:"min_deposit_amount_wei"`
	MaxDepositAmountWei string `json:"max_deposit_amount_wei"`
	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