swap

package
v0.28.1 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2025 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BzzTokenAddress       = "0x6aab14fe9cccd64a502d23842d916eb5321c26e7"
	EthAccount            = "0x62cab2b3b55f341f10348720ca18063cdb779ad5"
	GasPrice        int64 = 10000000000
	BzzGasLimit           = 100000
	EthGasLimit           = 21000
)

Variables

View Source
var (
	ErrEmptyTimestamp   = errors.New("empty timestamp, offset too large")
	ErrInvalidTimestamp = errors.New("invalid timestamp")
	ErrEmptyResult      = errors.New("empty result")
	ErrInvalidResult    = errors.New("invalid result")
)
View Source
var (
	ErrUnauthorized        = errors.New("unauthorized")
	ErrForbidden           = errors.New("forbidden")
	ErrNotFound            = errors.New("not found")
	ErrMethodNotAllowed    = errors.New("method not allowed")
	ErrTooManyRequests     = errors.New("too many requests")
	ErrInternalServerError = errors.New("internal server error")
	ErrServiceUnavailable  = errors.New("service unavailable")
)

Errors that are returned by the API.

View Source
var ErrNotSet = errors.New("swap client not initialized because geth-url is missing")

ErrNotSet represents error when Swap client is not set

Functions

This section is empty.

Types

type BadRequestError

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

BadRequestError holds list of errors from http response that represent invalid data submitted by the user.

func NewBadRequestError

func NewBadRequestError(errors ...string) (err *BadRequestError)

NewBadRequestError constructs a new BadRequestError with provided errors.

func (*BadRequestError) Error

func (e *BadRequestError) Error() (s string)

func (*BadRequestError) Errors

func (e *BadRequestError) Errors() (errs []string)

Errors returns a list of error messages.

type BlockTimeFetcher added in v0.27.0

type BlockTimeFetcher interface {
	FetchBlockTime(ctx context.Context, opts ...Option) (blockTime int64, err error)
}

type Client

type Client interface {
	SendETH(ctx context.Context, to string, amount float64) (tx string, err error)
	SendBZZ(ctx context.Context, to string, amount float64) (tx string, err error)
	SendGBZZ(ctx context.Context, to string, amount float64) (tx string, err error)
	AttestOverlayEthAddress(ctx context.Context, ethAddr string) (tx string, err error)
	BlockTimeFetcher
}

Client defines Client interface

type GethClient

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

GethClient manages communication with the Geth node

func NewGethClient

func NewGethClient(baseURL *url.URL, o *GethClientOptions, logger logging.Logger) *GethClient

NewClient constructs a new Client.

func (*GethClient) AttestOverlayEthAddress added in v0.9.0

func (g *GethClient) AttestOverlayEthAddress(ctx context.Context, ethAddr string) (tx string, err error)

func (*GethClient) FetchBlockTime added in v0.25.0

func (g *GethClient) FetchBlockTime(ctx context.Context, opts ...Option) (int64, error)

FetchBlockTime estimates the average block time by comparing timestamps of the latest block and an earlier block, adjusting the offset if needed. The block time is cached and reused until forced to refresh.

func (*GethClient) SendBZZ

func (g *GethClient) SendBZZ(ctx context.Context, to string, amount float64) (tx string, err error)

SendBZZ makes BZZ token deposit

func (*GethClient) SendETH

func (g *GethClient) SendETH(ctx context.Context, to string, amount float64) (tx string, err error)

SendETH makes ETH deposit

func (*GethClient) SendGBZZ added in v0.8.3

func (g *GethClient) SendGBZZ(ctx context.Context, to string, amount float64) (tx string, err error)

SendGBZZ makes gBZZ token deposit

type GethClientOptions

type GethClientOptions struct {
	BzzTokenAddress string
	EthAccount      string
	HTTPClient      *http.Client
}

GethClientOptions holds optional parameters for the GethClient

type NotSet

type NotSet struct{}

func (*NotSet) AttestOverlayEthAddress added in v0.9.0

func (n *NotSet) AttestOverlayEthAddress(ctx context.Context, ethAddr string) (tx string, err error)

func (*NotSet) FetchBlockTime added in v0.25.0

func (n *NotSet) FetchBlockTime(ctx context.Context, opts ...Option) (blockTime int64, err error)

FetchBlockTime(ctx context.Context) (blockTime int64, err error)

func (*NotSet) SendBZZ

func (n *NotSet) SendBZZ(ctx context.Context, to string, amount float64) (tx string, err error)

SendBZZ makes BZZ token deposit

func (*NotSet) SendETH

func (n *NotSet) SendETH(ctx context.Context, to string, amount float64) (tx string, err error)

SendETH makes ETH deposit

func (*NotSet) SendGBZZ added in v0.8.3

func (n *NotSet) SendGBZZ(ctx context.Context, to string, amount float64) (tx string, err error)

SendGBZZ makes gBZZ token deposit

type Option added in v0.26.0

type Option func(*options)

func WithOffset added in v0.26.0

func WithOffset(offset int64) Option

WithOffset sets the number of blocks to use for block time estimation.

func WithRefresh added in v0.27.0

func WithRefresh() Option

WithRefresh forces the block time to be recalculated.

Jump to

Keyboard shortcuts

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