apiclient

package
v0.0.0-...-499f22c Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultCacheSize = 64
	DefaultCacheTTL  = 60 * 60 * 24 // 1day
	MaxRetrivalLogs  = 256
)
View Source
const (
	LocalImageDownloadClientTimeout = int64(20) // 20s
	DefaultBaseDownloadLocation     = "./static"
	DefaultBaseImageURL             = "http://127.0.0.1:3000/image"
	CommonTag                       = "common"
)

Variables

View Source
var (
	ErrImageNotFound      = errors.New("err image not found")
	ErrImageAlreadyExists = errors.New("err image already exists")
)
View Source
var (
	ErrConnectRefused = errors.New("connection endppint refused")
)

Functions

This section is empty.

Types

type ChainHttpClient

type ChainHttpClient interface {
	FetchTransferLog(ctx context.Context, address common.Address, startHeight uint64, endHeight *uint64) (events []*ierc721.ContractTransfer, nextStart uint64, err error)
	FetchFactoryLog(ctx context.Context, address common.Address, startHeight uint64, endHeight *uint64) (events []*factory.FactoryNFTCreated, nextStart uint64, err error)

	WatchTransferLog(ctx context.Context, addresses []common.Address, callback func(*ierc721.ContractTransfer) error) error
	WatchFactoryLog(ctx context.Context, address common.Address, callback func(*factory.FactoryNFTCreated) error) error

	FetchNFTInfo(ctx context.Context, d *data.NFTContract) (err error)
	GetTokenMeta(ctx context.Context, d *data.Token) (err error)
}

type EthHttpClient

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

TODO: add delay of calling rpc

func NewChainClient

func NewChainClient(ctx context.Context, endpoint string, logger zerolog.Logger) (c EthHttpClient, err error)

func (*EthHttpClient) FetchFactoryLog

func (c *EthHttpClient) FetchFactoryLog(ctx context.Context, address common.Address, startHeight uint64, endHeight *uint64) (events []*factory.FactoryNFTCreated, nextStart uint64, err error)

func (*EthHttpClient) FetchNFTInfo

func (c *EthHttpClient) FetchNFTInfo(ctx context.Context, d *data.NFTContract) (err error)

func (*EthHttpClient) FetchTransferLog

func (c *EthHttpClient) FetchTransferLog(ctx context.Context, address common.Address, startHeight uint64, endHeight *uint64) (events []*ierc721.ContractTransfer, nextStart uint64, err error)

func (*EthHttpClient) GetTokenMeta

func (c *EthHttpClient) GetTokenMeta(ctx context.Context, d *data.Token) (err error)

func (*EthHttpClient) WatchFactoryLog

func (c *EthHttpClient) WatchFactoryLog(ctx context.Context, address common.Address, callback func(*factory.FactoryNFTCreated) error) error

func (*EthHttpClient) WatchTransferLog

func (c *EthHttpClient) WatchTransferLog(ctx context.Context, addresses []common.Address, callback func(*ierc721.ContractTransfer) error) error

type ImageDownloadClient

type ImageDownloadClient interface {
	Download(ctx context.Context, imageURL, tag string, overwrite bool) (location string, err error)
}

type LocalImageDownloadClient

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

func NewLocalImageDownloadClient

func NewLocalImageDownloadClient(ctx context.Context, baseDownloadLocation, baseImageURL string) (c LocalImageDownloadClient, err error)

func (*LocalImageDownloadClient) Download

func (c *LocalImageDownloadClient) Download(ctx context.Context, imageURL, tag string, overwrite bool) (location string, err error)

type MockChainClient

type MockChainClient struct {
	sync.Mutex
	// contains filtered or unexported fields
}

TODO: add delay of calling rpc

func NewMockChainClient

func NewMockChainClient(fe []*factory.FactoryNFTCreated, te []*ierc721.ContractTransfer, endHeight *uint64, delay int) (c MockChainClient)

func (*MockChainClient) EmitErr

func (c *MockChainClient) EmitErr(err error)

func (*MockChainClient) FetchFactoryLog

func (c *MockChainClient) FetchFactoryLog(ctx context.Context, address common.Address, startHeight uint64, endHeight *uint64) (events []*factory.FactoryNFTCreated, nextStart uint64, err error)

func (*MockChainClient) FetchNFTInfo

func (c *MockChainClient) FetchNFTInfo(ctx context.Context, d *data.NFTContract) (err error)

func (*MockChainClient) FetchTransferLog

func (c *MockChainClient) FetchTransferLog(ctx context.Context, address common.Address, startHeight uint64, endHeight *uint64) (events []*ierc721.ContractTransfer, nextStart uint64, err error)

func (*MockChainClient) GetTokenMeta

func (c *MockChainClient) GetTokenMeta(ctx context.Context, d *data.Token) (err error)

func (*MockChainClient) WatchFactoryLog

func (c *MockChainClient) WatchFactoryLog(ctx context.Context, address common.Address, callback func(*factory.FactoryNFTCreated) error) error

func (*MockChainClient) WatchTransferLog

func (c *MockChainClient) WatchTransferLog(ctx context.Context, addresses []common.Address, callback func(*ierc721.ContractTransfer) error) error

type MockImageClient

type MockImageClient struct {
	URLToFilename map[string]string
}

func NewMockImageClient

func NewMockImageClient(URLToFilename map[string]string) (c MockImageClient)

func (*MockImageClient) Download

func (c *MockImageClient) Download(ctx context.Context, imageURL, tag string, overwrite bool) (location string, err error)

Jump to

Keyboard shortcuts

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