repo

package
v0.0.0-...-65d01b3 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2024 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

The NFTAssetRepo package provides a set of functions for interacting with a remote IPFS repository custom built to exclusively host NFT assets for the ComicCoin blockchain. It allows users to retrieve the version of the NFT store service, pin files, and retrieve files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewNFTAssetRepo

NewNFTAssetRepo initializes a new NFTAssetRepo instance with the provided configuration and logger.

func NewNFTAssetRepoWithConfiguration

func NewNFTAssetRepoWithConfiguration(logger *slog.Logger, remoteAddress string, apiKey string) domain.NFTAssetRepository

NewNFTAssetRepoWithConfiguration initializes a new NFTAssetRepo instance directly with address and API key.

Types

type LastestTokenIDRepo

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

func NewLastestTokenIDRepo

func NewLastestTokenIDRepo(logger *slog.Logger, db disk.Storage) *LastestTokenIDRepo

func (*LastestTokenIDRepo) CommitTransaction

func (r *LastestTokenIDRepo) CommitTransaction() error

func (*LastestTokenIDRepo) DiscardTransaction

func (r *LastestTokenIDRepo) DiscardTransaction()

func (*LastestTokenIDRepo) Get

func (r *LastestTokenIDRepo) Get() (uint64, error)

func (*LastestTokenIDRepo) OpenTransaction

func (r *LastestTokenIDRepo) OpenTransaction() error

func (*LastestTokenIDRepo) Set

func (r *LastestTokenIDRepo) Set(tokenID uint64) error

type NFTAssetRepo

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

NFTAssetRepo handles interactions with a remote IPFS service.

func (*NFTAssetRepo) Get

func (r *NFTAssetRepo) Get(ctx context.Context, cidString string) (*domain.NFTAsset, error)

Get retrieves content from the IPFS service by a given CID. This method constructs the URL for the IPFS gateway and fetches the content.

func (*NFTAssetRepo) PinAddViaFilepath

func (r *NFTAssetRepo) PinAddViaFilepath(ctx context.Context, fullFilePath string) (string, error)

PinAddViaFilepath uploads a file to IPFS via the specified file path and pins it. The function prepares a multipart form request with the file content and metadata, and sends it.

func (*NFTAssetRepo) Version

func (r *NFTAssetRepo) Version(ctx context.Context) (string, error)

Version fetches the version of the remote IPFS service. It makes a GET request to the version endpoint and parses the JSON response.

type NFTAssetRepoConfigurationProvider

type NFTAssetRepoConfigurationProvider interface {
	GetNFTAssetNodeAddress() string // Retrieves the remote IPFS service address
	GetNFTAssetNodeAPIKey() string  // Retrieves the API key for authentication
}

NFTAssetRepoConfigurationProvider is an interface for configuration providers that provide remote address and API key needed for IPFS interaction.

func NewNFTAssetRepoConfigurationProvider

func NewNFTAssetRepoConfigurationProvider(remoteAddress string, apiKey string) NFTAssetRepoConfigurationProvider

NewNFTAssetRepoConfigurationProvider constructs a new configuration provider for IPFS connections with the specified remote address and API key.

type NFTAssetRepoConfigurationProviderImpl

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

NFTAssetRepoConfigurationProviderImpl is a struct that implements NFTAssetRepoConfigurationProvider for storing IPFS connection details.

func (*NFTAssetRepoConfigurationProviderImpl) GetNFTAssetNodeAPIKey

func (impl *NFTAssetRepoConfigurationProviderImpl) GetNFTAssetNodeAPIKey() string

GetNFTAssetNodeAPIKey retrieves the API key for IPFS service authentication.

func (*NFTAssetRepoConfigurationProviderImpl) GetNFTAssetNodeAddress

func (impl *NFTAssetRepoConfigurationProviderImpl) GetNFTAssetNodeAddress() string

GetNFTAssetNodeAddress retrieves the remote IPFS service address.

type TokenRepo

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

func NewTokenRepo

func NewTokenRepo(logger *slog.Logger, dbByTokenIDClient disk.Storage, dbByMetadataURIIDClient disk.Storage) *TokenRepo

func (*TokenRepo) CommitTransaction

func (r *TokenRepo) CommitTransaction() error

func (*TokenRepo) DeleteByTokenID

func (r *TokenRepo) DeleteByTokenID(tokenID uint64) error

func (*TokenRepo) DiscardTransaction

func (r *TokenRepo) DiscardTransaction()

func (*TokenRepo) GetByTokenID

func (r *TokenRepo) GetByTokenID(tokenID uint64) (*domain.Token, error)

func (*TokenRepo) ListAll

func (r *TokenRepo) ListAll() ([]*domain.Token, error)

func (*TokenRepo) OpenTransaction

func (r *TokenRepo) OpenTransaction() error

func (*TokenRepo) Upsert

func (r *TokenRepo) Upsert(token *domain.Token) error

Jump to

Keyboard shortcuts

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