api

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2025 License: MIT Imports: 41 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetUserID

func GetUserID(c *gin.Context) (int, error)

GetUserID gets the user ID from the context

Types

type ContractHandler

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

ContractHandler handles contract-related API requests

func NewContractHandler

func NewContractHandler(contractService *blockchain.ContractService, logger *logger.Logger) *ContractHandler

NewContractHandler creates a new contract handler

func (*ContractHandler) DeployContract

func (h *ContractHandler) DeployContract(w http.ResponseWriter, r *http.Request)

DeployContract handles the contract deployment request

func (*ContractHandler) GetContract

func (h *ContractHandler) GetContract(w http.ResponseWriter, r *http.Request)

GetContract handles the contract retrieval request

func (*ContractHandler) GetUserContracts

func (h *ContractHandler) GetUserContracts(w http.ResponseWriter, r *http.Request)

GetUserContracts handles the user contracts retrieval request

func (*ContractHandler) RegisterRoutes

func (h *ContractHandler) RegisterRoutes(r chi.Router)

RegisterRoutes registers the contract routes

func (*ContractHandler) VerifyContract

func (h *ContractHandler) VerifyContract(w http.ResponseWriter, r *http.Request)

VerifyContract handles the contract verification request

type CreateFunctionRequest

type CreateFunctionRequest struct {
	Name        string   `json:"name" binding:"required"`
	Description string   `json:"description"`
	SourceCode  string   `json:"source_code" binding:"required"`
	Timeout     int      `json:"timeout,omitempty"`
	Memory      int      `json:"memory,omitempty"`
	Secrets     []string `json:"secrets,omitempty"`
}

CreateFunctionRequest represents a request to create a function

type CreateSecretRequest

type CreateSecretRequest struct {
	Name  string `json:"name" binding:"required"`
	Value string `json:"value" binding:"required"`
}

CreateSecretRequest represents a request to create a secret

type CreateTriggerRequest

type CreateTriggerRequest struct {
	Name          string          `json:"name" binding:"required"`
	Description   string          `json:"description"`
	FunctionID    int             `json:"function_id" binding:"required"`
	TriggerType   string          `json:"trigger_type" binding:"required"`
	TriggerConfig json.RawMessage `json:"trigger_config" binding:"required"`
}

CreateTriggerRequest represents a request to create a trigger

type EventHandler

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

EventHandler handles event-related API requests

func NewEventHandler

func NewEventHandler(
	eventRepo *database.EventRepository,
	eventMonitor *blockchain.EventMonitor,
	logger *logger.Logger,
) *EventHandler

NewEventHandler creates a new event handler

func (*EventHandler) CreateSubscription

func (h *EventHandler) CreateSubscription(w http.ResponseWriter, r *http.Request)

CreateSubscription handles the subscription creation request

func (*EventHandler) DeleteSubscription

func (h *EventHandler) DeleteSubscription(w http.ResponseWriter, r *http.Request)

DeleteSubscription handles the subscription deletion request

func (*EventHandler) GetEvents

func (h *EventHandler) GetEvents(w http.ResponseWriter, r *http.Request)

GetEvents handles the events retrieval request

func (*EventHandler) GetSubscription

func (h *EventHandler) GetSubscription(w http.ResponseWriter, r *http.Request)

GetSubscription handles the subscription retrieval request

func (*EventHandler) GetSubscriptions

func (h *EventHandler) GetSubscriptions(w http.ResponseWriter, r *http.Request)

GetSubscriptions handles the subscriptions retrieval request

func (*EventHandler) RegisterRoutes

func (h *EventHandler) RegisterRoutes(r chi.Router)

RegisterRoutes registers the event routes

func (*EventHandler) UpdateSubscription

func (h *EventHandler) UpdateSubscription(w http.ResponseWriter, r *http.Request)

UpdateSubscription handles the subscription update request

type ExecuteFunctionRequest

type ExecuteFunctionRequest struct {
	Params interface{} `json:"params"`
	Async  bool        `json:"async"`
}

ExecuteFunctionRequest represents a request to execute a function

type GasBankHandler

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

GasBankHandler handles Gas Bank API requests

func NewGasBankHandler

func NewGasBankHandler(logger *logger.Logger, gasBankService *gasbank.Service) *GasBankHandler

NewGasBankHandler creates a new gas bank handler

func (*GasBankHandler) DepositGas

func (h *GasBankHandler) DepositGas(w http.ResponseWriter, r *http.Request)

DepositGas handles gas deposits

func (*GasBankHandler) EstimateGas

func (h *GasBankHandler) EstimateGas(w http.ResponseWriter, r *http.Request)

EstimateGas estimates gas for an operation

func (*GasBankHandler) GetAccount

func (h *GasBankHandler) GetAccount(w http.ResponseWriter, r *http.Request)

GetAccount returns a specific gas account

func (*GasBankHandler) GetAccountTransactions

func (h *GasBankHandler) GetAccountTransactions(w http.ResponseWriter, r *http.Request)

GetAccountTransactions returns transactions for a specific account

func (*GasBankHandler) GetAccounts

func (h *GasBankHandler) GetAccounts(w http.ResponseWriter, r *http.Request)

GetAccounts returns all gas accounts for a user

func (*GasBankHandler) GetTransactions

func (h *GasBankHandler) GetTransactions(w http.ResponseWriter, r *http.Request)

GetTransactions returns all gas transactions for a user

func (*GasBankHandler) RegisterRoutes

func (h *GasBankHandler) RegisterRoutes(router *mux.Router)

RegisterRoutes registers the gas bank routes

func (*GasBankHandler) WithdrawGas

func (h *GasBankHandler) WithdrawGas(w http.ResponseWriter, r *http.Request)

WithdrawGas handles gas withdrawals

type LoginRequest

type LoginRequest struct {
	UsernameOrEmail string `json:"username_or_email" binding:"required"`
	Password        string `json:"password" binding:"required"`
}

LoginRequest represents a login request

type OracleHandler

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

OracleHandler handles Oracle API requests

func NewOracleHandler

func NewOracleHandler(logger *logger.Logger, oracleService *oracle.Service) *OracleHandler

NewOracleHandler creates a new oracle handler

func (*OracleHandler) CheckRequestStatus

func (h *OracleHandler) CheckRequestStatus(w http.ResponseWriter, r *http.Request)

CheckRequestStatus checks the status of an oracle request

func (*OracleHandler) CreateOracle

func (h *OracleHandler) CreateOracle(w http.ResponseWriter, r *http.Request)

CreateOracle creates a new oracle

func (*OracleHandler) CreateOracleRequest

func (h *OracleHandler) CreateOracleRequest(w http.ResponseWriter, r *http.Request)

CreateOracleRequest creates a new oracle data request

func (*OracleHandler) DeleteOracle

func (h *OracleHandler) DeleteOracle(w http.ResponseWriter, r *http.Request)

DeleteOracle deletes an oracle

func (*OracleHandler) GetHistoricalData

func (h *OracleHandler) GetHistoricalData(w http.ResponseWriter, r *http.Request)

GetHistoricalData returns historical oracle data

func (*OracleHandler) GetOracle

func (h *OracleHandler) GetOracle(w http.ResponseWriter, r *http.Request)

GetOracle returns a specific oracle

func (*OracleHandler) GetOracleRequest

func (h *OracleHandler) GetOracleRequest(w http.ResponseWriter, r *http.Request)

GetOracleRequest returns a specific oracle request

func (*OracleHandler) GetOracleStatistics

func (h *OracleHandler) GetOracleStatistics(w http.ResponseWriter, r *http.Request)

GetOracleStatistics returns statistics about the oracle service

func (*OracleHandler) ListOracleRequests

func (h *OracleHandler) ListOracleRequests(w http.ResponseWriter, r *http.Request)

ListOracleRequests returns a list of oracle requests for a specific oracle

func (*OracleHandler) ListOracles

func (h *OracleHandler) ListOracles(w http.ResponseWriter, r *http.Request)

ListOracles returns a list of oracles

func (*OracleHandler) RegisterRoutes

func (h *OracleHandler) RegisterRoutes(router *mux.Router)

RegisterRoutes registers the oracle routes

func (*OracleHandler) UpdateOracle

func (h *OracleHandler) UpdateOracle(w http.ResponseWriter, r *http.Request)

UpdateOracle updates an existing oracle

type RefreshTokenRequest

type RefreshTokenRequest struct {
	RefreshToken string `json:"refresh_token" binding:"required"`
}

RefreshTokenRequest represents a token refresh request

type RegisterRequest

type RegisterRequest struct {
	Username string `json:"username" binding:"required,min=3,max=50"`
	Email    string `json:"email" binding:"required,email"`
	Password string `json:"password" binding:"required,min=6"`
}

RegisterRequest represents a registration request

type Server

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

Server represents the HTTP server

func NewServer

func NewServer(cfg *config.Config, log *logger.Logger) (*Server, error)

NewServer creates a new HTTP server

func (*Server) RegisterHealthRoutes

func (s *Server) RegisterHealthRoutes(router *gin.RouterGroup)

RegisterHealthRoutes registers health check endpoints

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

Shutdown gracefully shuts down the HTTP server

func (*Server) Start

func (s *Server) Start(address string) error

Start starts the HTTP server

type TransactionHandlers

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

TransactionHandlers contains handlers for transaction-related endpoints

func NewTransactionHandlers

func NewTransactionHandlers(txService *blockchain.TransactionService) *TransactionHandlers

NewTransactionHandlers creates a new TransactionHandlers

func (*TransactionHandlers) CancelTransaction

func (h *TransactionHandlers) CancelTransaction(w http.ResponseWriter, r *http.Request)

CancelTransaction cancels a pending transaction @Summary Cancel a pending transaction @Description Cancel a transaction that is pending and has not yet been confirmed @Tags transactions @Produce json @Param id path string true "Transaction ID" @Success 200 {object} models.Transaction @Failure 400 {object} common.ErrorResponse @Failure 404 {object} common.ErrorResponse @Failure 500 {object} common.ErrorResponse @Router /api/v1/transactions/{id}/cancel [post]

func (*TransactionHandlers) CreateServiceWallet

func (h *TransactionHandlers) CreateServiceWallet(w http.ResponseWriter, r *http.Request)

CreateServiceWallet creates a new wallet for a service @Summary Create a new wallet for a service @Description Create a new wallet for a specific service @Tags transactions,wallets @Accept json @Produce json @Param service body struct{Service string `json:"service"`} true "Service identifier" @Success 201 {object} models.WalletAccount @Failure 400 {object} common.ErrorResponse @Failure 500 {object} common.ErrorResponse @Router /api/v1/transactions/wallets [post]

func (*TransactionHandlers) CreateTransaction

func (h *TransactionHandlers) CreateTransaction(w http.ResponseWriter, r *http.Request)

CreateTransaction creates a new transaction @Summary Create a new transaction @Description Create a new transaction and submit it to the blockchain @Tags transactions @Accept json @Produce json @Param transaction body models.CreateTransactionRequest true "Transaction request" @Success 201 {object} models.Transaction @Failure 400 {object} common.ErrorResponse @Failure 500 {object} common.ErrorResponse @Router /api/v1/transactions [post]

func (*TransactionHandlers) GetServiceWallet

func (h *TransactionHandlers) GetServiceWallet(w http.ResponseWriter, r *http.Request)

GetServiceWallet gets a wallet for a service @Summary Get a wallet for a service @Description Get the wallet for a specific service @Tags transactions,wallets @Produce json @Param service path string true "Service identifier" @Success 200 {object} models.WalletAccount @Failure 404 {object} common.ErrorResponse @Failure 500 {object} common.ErrorResponse @Router /api/v1/transactions/wallets/{service} [get]

func (*TransactionHandlers) GetTransaction

func (h *TransactionHandlers) GetTransaction(w http.ResponseWriter, r *http.Request)

GetTransaction gets a transaction by ID @Summary Get a transaction by ID @Description Get a transaction by its unique identifier @Tags transactions @Produce json @Param id path string true "Transaction ID" @Success 200 {object} models.Transaction @Failure 404 {object} common.ErrorResponse @Failure 500 {object} common.ErrorResponse @Router /api/v1/transactions/{id} [get]

func (*TransactionHandlers) GetTransactionEvents

func (h *TransactionHandlers) GetTransactionEvents(w http.ResponseWriter, r *http.Request)

GetTransactionEvents gets events for a transaction @Summary Get events for a transaction @Description Get the history of events for a transaction @Tags transactions @Produce json @Param id path string true "Transaction ID" @Success 200 {array} models.TransactionEvent @Failure 400 {object} common.ErrorResponse @Failure 404 {object} common.ErrorResponse @Failure 500 {object} common.ErrorResponse @Router /api/v1/transactions/{id}/events [get]

func (*TransactionHandlers) ListServiceWallets

func (h *TransactionHandlers) ListServiceWallets(w http.ResponseWriter, r *http.Request)

ListServiceWallets lists all wallets for a service @Summary List all wallets for a service @Description List all wallets for a specific service @Tags transactions,wallets @Produce json @Param service path string true "Service identifier" @Success 200 {array} models.WalletAccount @Failure 500 {object} common.ErrorResponse @Router /api/v1/transactions/wallets/{service}/all [get]

func (*TransactionHandlers) ListTransactions

func (h *TransactionHandlers) ListTransactions(w http.ResponseWriter, r *http.Request)

ListTransactions lists transactions with filtering @Summary List transactions @Description List transactions with optional filtering @Tags transactions @Produce json @Param service query string false "Service filter" @Param status query string false "Status filter" @Param entityId query string false "Entity ID filter" @Param page query int false "Page number (default: 1)" @Param limit query int false "Items per page (default: 20)" @Success 200 {object} models.TransactionListResponse @Failure 400 {object} common.ErrorResponse @Failure 500 {object} common.ErrorResponse @Router /api/v1/transactions [get]

func (*TransactionHandlers) RegisterRoutes

func (h *TransactionHandlers) RegisterRoutes(r chi.Router)

RegisterRoutes registers transaction routes

func (*TransactionHandlers) RetryTransaction

func (h *TransactionHandlers) RetryTransaction(w http.ResponseWriter, r *http.Request)

RetryTransaction retries a failed transaction @Summary Retry a failed transaction @Description Retry a transaction that previously failed @Tags transactions @Produce json @Param id path string true "Transaction ID" @Success 200 {object} models.Transaction @Failure 400 {object} common.ErrorResponse @Failure 404 {object} common.ErrorResponse @Failure 500 {object} common.ErrorResponse @Router /api/v1/transactions/{id}/retry [post]

type UpdateFunctionRequest

type UpdateFunctionRequest struct {
	Name        string   `json:"name" binding:"required"`
	Description string   `json:"description"`
	SourceCode  string   `json:"source_code" binding:"required"`
	Timeout     int      `json:"timeout,omitempty"`
	Memory      int      `json:"memory,omitempty"`
	Secrets     []string `json:"secrets,omitempty"`
}

UpdateFunctionRequest represents a request to update a function

type UpdateSecretRequest

type UpdateSecretRequest struct {
	Value string `json:"value" binding:"required"`
}

UpdateSecretRequest represents a request to update a secret

type UpdateTriggerRequest

type UpdateTriggerRequest struct {
	Name          string          `json:"name" binding:"required"`
	Description   string          `json:"description"`
	FunctionID    int             `json:"function_id" binding:"required"`
	TriggerType   string          `json:"trigger_type" binding:"required"`
	TriggerConfig json.RawMessage `json:"trigger_config" binding:"required"`
}

UpdateTriggerRequest represents a request to update a trigger

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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