api

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: May 30, 2023 License: Apache-2.0 Imports: 42 Imported by: 0

Documentation

Overview

---------------------------------------------------------------------------------------------

  • Copyright (c) IBAX. All rights reserved.
  • See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEcosystemNotFound = errors.New("Ecosystem not found")
)

Functions

func InitJwtSecret

func InitJwtSecret(secret []byte)

func SendRawRequest

func SendRawRequest(rtype, url, auth string, form *url.Values) ([]byte, error)

func SendRequest

func SendRequest(rtype, url, auth string, form *url.Values, v any) error

func SetOtherCommonRoutes

func SetOtherCommonRoutes(api *mux.Router, m Mode)

func WithCors

func WithCors(h http.Handler) http.Handler

Types

type BlockDetailedInfo

type BlockDetailedInfo struct {
	Header        BlockHeaderInfo  `json:"header"`
	Hash          []byte           `json:"hash"`
	EcosystemID   int64            `json:"-"`
	NodePosition  int64            `json:"node_position"`
	KeyID         int64            `json:"key_id"`
	Time          int64            `json:"time"`
	Tx            int32            `json:"tx_count"`
	Size          string           `json:"size"`
	RollbacksHash []byte           `json:"rollbacks_hash"`
	MerkleRoot    []byte           `json:"merkle_root"`
	BinData       []byte           `json:"bin_data"`
	SysUpdate     bool             `json:"-"`
	GenBlock      bool             `json:"-"`
	StopCount     int              `json:"stop_count"`
	Transactions  []TxDetailedInfo `json:"transactions"`
}

type BlockHeaderInfo

type BlockHeaderInfo struct {
	BlockID      int64  `json:"block_id"`
	Time         int64  `json:"time"`
	EcosystemID  int64  `json:"-"`
	KeyID        int64  `json:"key_id"`
	NodePosition int64  `json:"node_position"`
	Sign         []byte `json:"-"`
	Hash         []byte `json:"-"`
	Version      int    `json:"version"`
}

type Client

type Client struct {
	KeyID         int64
	AccountID     string
	EcosystemID   int64
	EcosystemName string
	RoleID        int64
}

Client represents data of client

func (*Client) Prefix

func (c *Client) Prefix() string

type Connect

type Connect struct {
	Auth       string
	Root       string
	PrivateKey []byte
	PublicKey  string
}

func (*Connect) Login

func (connect *Connect) Login() error

func (*Connect) PostTxResult

func (connect *Connect) PostTxResult(name string, form *url.Values) (id int64, msg string, err error)

func (*Connect) SendGet

func (connect *Connect) SendGet(url string, form *url.Values, v any) error

func (*Connect) SendMultipart

func (connect *Connect) SendMultipart(url string, files map[string][]byte, v any) error

func (*Connect) SendPost

func (connect *Connect) SendPost(url string, form *url.Values, v any) error

func (*Connect) WaitTx

func (connect *Connect) WaitTx(hash string) (int64, error)

func (*Connect) WaitTxList

func (connect *Connect) WaitTxList(hashes []string) (map[string]WaitResult, error)

type HonorNodeJSON

type HonorNodeJSON struct {
	TCPAddress string `json:"tcp_address"`
	APIAddress string `json:"api_address"`
	PublicKey  string `json:"public_key"`
	UnbanTime  string `json:"unban_time"`
	Stopped    bool   `json:"stopped"`
}

func GetNodesJSON

func GetNodesJSON() []HonorNodeJSON

type JWTClaims

type JWTClaims struct {
	UID         string `json:"uid,omitempty"`
	EcosystemID string `json:"ecosystem_id,omitempty"`
	KeyID       string `json:"key_id,omitempty"`
	AccountID   string `json:"account_id,omitempty"`
	RoleID      string `json:"role_id,omitempty"`
	jwt.RegisteredClaims
}

JWTClaims is storing jwt claims

type Mode

type Mode struct {
	EcosystemGetter   types.EcosystemGetter
	ContractRunner    types.SmartContractRunner
	ClientTxProcessor types.ClientTxPreprocessor
}

func (Mode) GetAppParamHandler

func (m Mode) GetAppParamHandler(w http.ResponseWriter, r *http.Request)

func (Mode) SetBlockchainRoutes

func (m Mode) SetBlockchainRoutes(r Router)

func (Mode) SetCommonRoutes

func (m Mode) SetCommonRoutes(r Router)

Route sets routing pathes

func (Mode) SetSubNodeRoutes

func (m Mode) SetSubNodeRoutes(r Router)

type NetworkResult

type NetworkResult struct {
	NetworkID     string          `json:"network_id"`
	CentrifugoURL string          `json:"centrifugo_url"`
	Test          bool            `json:"test"`
	Private       bool            `json:"private"`
	HonorNodes    []HonorNodeJSON `json:"honor_nodes"`
}

type Router

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

func NewRouter

func NewRouter(m Mode) Router

func (Router) GetAPI

func (r Router) GetAPI() *mux.Router

func (Router) GetAPIVersion

func (r Router) GetAPIVersion(preffix string) *mux.Router

func (Router) NewVersion

func (r Router) NewVersion(preffix string) *mux.Router

type SumWhereForm

type SumWhereForm struct {
	Column string `schema:"column"`
	Where  string `schema:"where"`
}

func (*SumWhereForm) Validate

func (f *SumWhereForm) Validate(r *http.Request) error

type TxDetailedInfo

type TxDetailedInfo struct {
	Hash         []byte         `json:"hash"`
	ContractName string         `json:"contract_name"`
	Params       map[string]any `json:"params"`
	KeyID        int64          `json:"key_id"`
	Time         int64          `json:"time"`
	Type         byte           `json:"type"`
	Size         string         `json:"size"`
}

type TxInfo

type TxInfo struct {
	Hash         []byte         `json:"hash"`
	ContractName string         `json:"contract_name"`
	Params       map[string]any `json:"params"`
	KeyID        int64          `json:"key_id"`
}

type WaitResult

type WaitResult struct {
	BlockID int64
	Msg     string
}

Jump to

Keyboard shortcuts

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