blockchainapi

package
v0.0.0-...-25c9f67 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2024 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPrKey        = errors.New("cannot get private key")
	ErrTxOpts       = errors.New("failed to get transactOpts")
	ErrNonce        = errors.New("failed to get nonce")
	ErrEstimateGas  = errors.New("failed to estimate gas")
	ErrSignTx       = errors.New("failed to sign transaction")
	ErrSendTx       = errors.New("failed to send transaction")
	ErrWaitMined    = errors.New("failed to wait for transaction to be mined")
	ErrSessionStore = errors.New("failed to store session")

	ErrBid         = errors.New("failed to get bid")
	ErrProvider    = errors.New("failed to get provider")
	ErrTokenSupply = errors.New("failed to parse token supply")
	ErrBudget      = errors.New("failed to parse token budget")
	ErrMyAddress   = errors.New("failed to get my address")
	ErrInitSession = errors.New("failed to initiate session")
	ErrApprove     = errors.New("failed to approve")
	ErrMarshal     = errors.New("failed to marshal open session payload")
)

Functions

This section is empty.

Types

type BlockchainController

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

func NewBlockchainController

func NewBlockchainController(service *BlockchainService, log lib.ILogger) *BlockchainController

func (*BlockchainController) RegisterRoutes

func (c *BlockchainController) RegisterRoutes(r interfaces.Router)

type BlockchainService

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

func NewBlockchainService

func NewBlockchainService(
	ethClient *ethclient.Client,
	diamonContractAddr common.Address,
	morTokenAddr common.Address,
	explorerApiUrl string,
	privateKey interfaces.PrKeyProvider,
	sessionStorage *storages.SessionStorage,
	proxyService *proxyapi.ProxyServiceSender,
	log lib.ILogger,
	legacyTx bool,
) *BlockchainService

func (*BlockchainService) Approve

func (s *BlockchainService) Approve(ctx context.Context, spender common.Address, amount *big.Int) (common.Hash, error)

func (*BlockchainService) ClaimProviderBalance

func (s *BlockchainService) ClaimProviderBalance(ctx context.Context, sessionID [32]byte, to common.Address, amount *big.Int) (common.Hash, error)

func (*BlockchainService) CloseSession

func (s *BlockchainService) CloseSession(ctx context.Context, sessionID common.Hash) (common.Hash, error)

func (*BlockchainService) GetAllModels

func (s *BlockchainService) GetAllModels(ctx context.Context) ([]*structs.Model, error)

func (*BlockchainService) GetAllProviders

func (s *BlockchainService) GetAllProviders(ctx context.Context) ([]*structs.Provider, error)

func (*BlockchainService) GetAllowance

func (s *BlockchainService) GetAllowance(ctx context.Context, spender common.Address) (*big.Int, error)

func (*BlockchainService) GetBalance

func (s *BlockchainService) GetBalance(ctx *gin.Context) (*big.Int, *big.Int, error)

func (*BlockchainService) GetBidByID

func (s *BlockchainService) GetBidByID(ctx context.Context, ID common.Hash) (*structs.Bid, error)

func (*BlockchainService) GetBidsByModelAgent

func (s *BlockchainService) GetBidsByModelAgent(ctx context.Context, modelId [32]byte, offset *big.Int, limit uint8) ([]*structs.Bid, error)

func (*BlockchainService) GetBidsByProvider

func (s *BlockchainService) GetBidsByProvider(ctx context.Context, providerAddr common.Address, offset *big.Int, limit uint8) ([]*structs.Bid, error)

func (*BlockchainService) GetLatestBlock

func (s *BlockchainService) GetLatestBlock(ctx context.Context) (uint64, error)

func (*BlockchainService) GetMyAddress

func (s *BlockchainService) GetMyAddress(ctx context.Context) (common.Address, error)

func (*BlockchainService) GetProviderClaimableBalance

func (s *BlockchainService) GetProviderClaimableBalance(ctx *gin.Context, sessionID common.Hash) (*big.Int, error)

func (*BlockchainService) GetSession

func (s *BlockchainService) GetSession(ctx *gin.Context, sessionID common.Hash) (*sessionrouter.Session, error)

func (*BlockchainService) GetSessions

func (s *BlockchainService) GetSessions(ctx *gin.Context, user, provider common.Address, offset *big.Int, limit uint8) ([]*structs.Session, error)

func (*BlockchainService) GetTodaysBudget

func (s *BlockchainService) GetTodaysBudget(ctx context.Context) (*big.Int, error)

func (*BlockchainService) GetTokenSupply

func (s *BlockchainService) GetTokenSupply(ctx context.Context) (*big.Int, error)

func (*BlockchainService) GetTransactions

func (s *BlockchainService) GetTransactions(ctx context.Context, page uint64, limit uint8) ([]structs.RawTransaction, error)

func (*BlockchainService) OpenSession

func (s *BlockchainService) OpenSession(ctx context.Context, approval, approvalSig []byte, stake *big.Int) (common.Hash, error)

func (*BlockchainService) OpenSessionByModelId

func (s *BlockchainService) OpenSessionByModelId(ctx context.Context, modelID common.Hash, duration *big.Int) (common.Hash, error)

func (*BlockchainService) SendETH

func (s *BlockchainService) SendETH(ctx *gin.Context, to common.Address, amount *big.Int) (common.Hash, error)

func (*BlockchainService) SendMOR

func (s *BlockchainService) SendMOR(ctx context.Context, to common.Address, amount *big.Int) (common.Hash, error)

type EventsListener

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

func NewEventsListener

func NewEventsListener(client *ethclient.Client, store *storages.SessionStorage, sessionRouter *registries.SessionRouter, wallet interfaces.Wallet, log *lib.Logger) *EventsListener

func (*EventsListener) Run

func (e *EventsListener) Run(ctx context.Context) error

type ExplorerClient

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

func NewExplorerClient

func NewExplorerClient(explorerApiUrl string, morTokenAddr string) *ExplorerClient

func (*ExplorerClient) GetEthTransactions

func (e *ExplorerClient) GetEthTransactions(address common.Address, page uint64, limit uint8) ([]structs.RawTransaction, error)

func (*ExplorerClient) GetTokenTransactions

func (e *ExplorerClient) GetTokenTransactions(address common.Address, page uint64, limit uint8) ([]structs.RawTransaction, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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