balance

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidParameter = errors.New("invalid parameter")
	ErrNotFound         = errors.New("not found")
)

Predefined package errors

Functions

func MakeGetAssetsEndpoint

func MakeGetAssetsEndpoint(s Service) endpoint.Endpoint

MakeGetAssetsEndpoint returns an endpoint function for the GetAssets method.

func MakeGetBalanceEndpoint

func MakeGetBalanceEndpoint(s Service) endpoint.Endpoint

MakeGetBalanceEndpoint returns an endpoint function for the GetBalance method.

func MakeGetNFTsEndpoint

func MakeGetNFTsEndpoint(s Service) endpoint.Endpoint

MakeGetNFTsEndpoint returns an endpoint function for the GetNFTs method.

func MakeGetTokenBalanceEndpoint

func MakeGetTokenBalanceEndpoint(s Service) endpoint.Endpoint

MakeGetTokenBalanceEndpoint returns an endpoint function for the GetTokenBalance method.

func MakeHTTPHandler

func MakeHTTPHandler(e Endpoints, log logger) http.Handler

MakeHTTPHandler ...

Types

type Balance

type Balance struct {
	Pubkey   string
	Mint     string
	IsNative bool
	Balance  types.TokenAmount
	Metadata *metadata.Metadata
}

Balance is a type that represents a token/SOL balance of a wallet. It includes the token metadata.

type BalanceResponse

type BalanceResponse struct {
	Balances []Balance `json:"balances"`
}

type Endpoints

type Endpoints struct {
	GetBalance      endpoint.Endpoint
	GetAssets       endpoint.Endpoint
	GetNFTs         endpoint.Endpoint
	GetTokenBalance endpoint.Endpoint
}

Endpoints collection of profile service

func MakeEndpoints

func MakeEndpoints(s Service, m ...endpoint.Middleware) Endpoints

Init endpoints

type GetTokenBalanceRequest

type GetTokenBalanceRequest struct {
	WalletAddr string `json:"wallet_addr"`
	TokenMint  string `json:"mint"`
}

GetTokenBalanceRequest is a request payload for the GetTokenBalance method.

type NFTsResponse

type NFTsResponse struct {
	NFTs []token_metadata.Metadata `json:"nfts"`
}

NFTsResponse is a response for the GetNFTs method.

type Service

type Service interface {
	// GetSOLBalance returns the SOL balance of a wallet
	GetSOLBalance(ctx context.Context, walletAddr string) (Balance, error)
	// Get balance for specified token
	GetTokenBalance(ctx context.Context, walletAddr, tokenMint string) (types.TokenAmount, error)
	// Get balance for all fungible tokens
	GetFungibleTokens(ctx context.Context, walletAddr string) ([]Balance, error)
	// Get balance for all fungible assets
	GetFungibleAssets(ctx context.Context, walletAddr string) ([]Balance, error)
	// Get all non-fungible tokens
	GetNonFungibleTokens(ctx context.Context, walletAddr string) ([]token_metadata.Metadata, error)
}

Service interface

func NewService

func NewService(solana solanaClient) Service

NewService is a factory function, returns a new instance of the Service interface implementation

type TokenBalanceResponse

type TokenBalanceResponse struct {
	Balance types.TokenAmount `json:"balance"`
}

Jump to

Keyboard shortcuts

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