server

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2021 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Whitelist for smart contract functions that never need protection.

OFAC banned addresses

Request represents an incoming client request

Index

Constants

This section is empty.

Variables

View Source
var DebugDontSendTx = os.Getenv("DEBUG_DONT_SEND_RAWTX") != ""
View Source
var Now = time.Now // used to mock time in tests
View Source
var ProtectTxApiHost = "https://protect.flashbots.net"
View Source
var State = NewGlobalState()

Metamask fix helper

Functions

func GetIP

func GetIP(r *http.Request) string

func GetSenderFromRawTx

func GetSenderFromRawTx(tx *types.Transaction) (string, error)

func GetSenderFromTx

func GetSenderFromTx(tx *types.Transaction) (string, error)

func GetTx

func GetTx(rawTxHex string) (*types.Transaction, error)

func IsBlacklisted

func IsBlacklisted(ip string) bool

func IsMetamask

func IsMetamask(r *http.Request) bool

CHROME_ID: nkbihfbeogaeaoehlefnkodbefgpgknn

func IsMetamaskMoz

func IsMetamaskMoz(r *http.Request) bool

FIREFOX_ID: webextension@metamask.io

func NewNonceFix added in v1.3.0

func NewNonceFix(txHash string) *nonceFix

func ProxyRequest

func ProxyRequest(proxyUrl string, body []byte) (*http.Response, error)

func ShouldSendTxToRelay added in v1.3.0

func ShouldSendTxToRelay(txHash string) bool

func TruncateText

func TruncateText(s string, max int) string

Types

type GetBundleStatusByTransactionHashResponse

type GetBundleStatusByTransactionHashResponse struct {
	TxHash            string `json:"txHash"`            // "0x0aeb9c61b342f7fc94a10d41c5d30a049a9cfa9ab764c6dd02204a19960ee567"
	Status            string `json:"status"`            // "FAILED_BUNDLE"
	Message           string `json:"message"`           // "Expired - The base fee was to low to execute this transaction, please try again"
	Error             string `json:"error"`             // "max fee per gas less than block base fee"
	BlocksCount       int    `json:"blocksCount"`       // 2
	ReceivedTimestamp int    `json:"receivedTimestamp"` // 1634568851003
	StatusTimestamp   int    `json:"statusTimestamp"`   // 1634568873862
}

type GlobalState added in v1.3.0

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

todo: put into redis

func NewGlobalState added in v1.3.0

func NewGlobalState() *GlobalState

type HealthResponse added in v1.2.0

type HealthResponse struct {
	Now       time.Time `json:"time"`
	StartTime time.Time `json:"startTime"`
	Version   string    `json:"version"`
}

type JsonRpcError

type JsonRpcError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

RpcError: https://www.jsonrpc.org/specification#error_object

func (JsonRpcError) Error

func (err JsonRpcError) Error() string

type JsonRpcRequest

type JsonRpcRequest struct {
	Id      interface{}   `json:"id"`
	Method  string        `json:"method"`
	Params  []interface{} `json:"params"`
	Version string        `json:"jsonrpc,omitempty"`
}

func NewJsonRpcRequest

func NewJsonRpcRequest(id interface{}, method string, params []interface{}) *JsonRpcRequest

func NewJsonRpcRequest1

func NewJsonRpcRequest1(id interface{}, method string, param interface{}) *JsonRpcRequest

type JsonRpcResponse

type JsonRpcResponse struct {
	Id      interface{}     `json:"id"`
	Result  json.RawMessage `json:"result"`
	Error   *JsonRpcError   `json:"error,omitempty"`
	Version string          `json:"jsonrpc"`
}

func NewJsonRpcResponse

func NewJsonRpcResponse(id interface{}, result json.RawMessage) *JsonRpcResponse

func SendRpcAndParseResponseTo

func SendRpcAndParseResponseTo(url string, req *JsonRpcRequest) (*JsonRpcResponse, error)

func SendRpcWithSignatureAndParseResponse added in v1.1.0

func SendRpcWithSignatureAndParseResponse(url string, privKey *ecdsa.PrivateKey, jsonRpcReq *JsonRpcRequest) (jsonRpcResponse *JsonRpcResponse, responseBytes *[]byte, err error)

type PrivateTxApiResponse added in v1.1.0

type PrivateTxApiResponse struct {
	Status         string `json:"status"`
	Hash           string `json:"hash"`
	MaxBlockNumber int    `json:"maxBlockNumber"`
}

func GetTxStatus added in v1.3.0

func GetTxStatus(txHash string) (*PrivateTxApiResponse, error)

type RelayErrorResponse added in v1.3.0

type RelayErrorResponse struct {
	Error string `json:"error"`
}

type RpcEndPointServer

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

func NewRpcEndPointServer

func NewRpcEndPointServer(version string, listenAddress, proxyUrl, relayUrl string, relaySigningKey *ecdsa.PrivateKey) *RpcEndPointServer

func (*RpcEndPointServer) HandleHttpRequest

func (s *RpcEndPointServer) HandleHttpRequest(respw http.ResponseWriter, req *http.Request)

func (*RpcEndPointServer) Start

func (s *RpcEndPointServer) Start()

type RpcRequest

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

RPC request for a single client JSON-RPC request

func NewRpcRequest

func NewRpcRequest(respw *http.ResponseWriter, req *http.Request, proxyUrl string, relayUrl string, relaySigningKey *ecdsa.PrivateKey) *RpcRequest

type StringWithTime added in v1.3.0

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

func NewStringWithTime added in v1.3.0

func NewStringWithTime(s string) StringWithTime

Jump to

Keyboard shortcuts

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