Documentation ¶
Overview ¶
---------------------------------------------------------------------------------------------
- Copyright (c) IBAX. All rights reserved.
- See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
- Copyright (c) IBAX. All rights reserved.
- See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
- Copyright (c) IBAX. All rights reserved.
- See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
- Copyright (c) IBAX. All rights reserved.
- See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
- Copyright (c) IBAX. All rights reserved.
- See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
- Copyright (c) IBAX. All rights reserved.
- See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
- Copyright (c) IBAX. All rights reserved.
- See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
- Copyright (c) IBAX. All rights reserved.
- See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
- Copyright (c) IBAX. All rights reserved.
- See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
- Copyright (c) IBAX. All rights reserved.
- See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
- Copyright (c) IBAX. All rights reserved.
- See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
- Copyright (c) IBAX. All rights reserved.
- See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
- Copyright (c) IBAX. All rights reserved.
- See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
- Copyright (c) IBAX. All rights reserved.
- See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
- Copyright (c) IBAX. All rights reserved.
- See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
- Copyright (c) IBAX. All rights reserved.
- See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
- Copyright (c) IBAX. All rights reserved.
- See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
- Copyright (c) IBAX. All rights reserved.
- See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
- Copyright (c) IBAX. All rights reserved.
- See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
- Copyright (c) IBAX. All rights reserved.
- See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
- Copyright (c) IBAX. All rights reserved.
- See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------
Index ¶
- Constants
- func ContextRequestTimeout(ctx context.Context) (time.Duration, bool)
- func GetNamespace(name space) string
- func GetStructValue(structObject any) reflect.Value
- func InitJwtSecret(secret []byte)
- func NewAccountsApi(m Mode) *accountsApi
- func NewAuthApi(mode Mode) *authApi
- func NewBlockChainApi() *blockChainApi
- func NewCommonApi(m Mode) *commonApi
- func NewDataApi() *dataApi
- func NewMiddlewares(srv http.Handler, m Mode) http.Handler
- func NewNetworkApi() *networkApi
- func NewTransactionApi() *transactionApi
- func RequestHandlerFunc(fn requestHandlerFunc) *requestHandlerFunc
- func WriteBatchResponse(w http.ResponseWriter, resp any)
- func WriteResponse(w http.ResponseWriter, request *Request, result any, e *Error)
- type AccountOrKeyId
- type AppContentResult
- type AppParamsForm
- type AppParamsResult
- type Auth
- type AuthStatusResponse
- type BalanceResult
- type BatchRequest
- type BatchResponse
- type BlockDetailedInfo
- type BlockHeaderInfo
- type BlockIdOrHash
- type BlockInfoResult
- type ContentResult
- type DebugApi
- type EcosystemInfo
- type Error
- func DefaultError(message string) *Error
- func InternalError(message string, data ...map[string]any) *Error
- func InvalidInput(message string, data ...map[string]any) *Error
- func InvalidParamsError(message string, data ...map[string]any) *Error
- func InvalidRequest(message string, data ...map[string]any) *Error
- func LimitExceeded(message string, data ...map[string]any) *Error
- func MethodNotFound(method string, data ...map[string]any) *Error
- func MethodNotSupported(method string, data ...map[string]any) *Error
- func NewError(code ErrorCode, message string, data ...map[string]any) *Error
- func NotFoundError() *Error
- func ParseError(message string) *Error
- func ResourceNotFound(message string, data ...map[string]any) *Error
- func ResourceUnavailable(message string, data ...map[string]any) *Error
- func TransactionRejected(message string, data ...map[string]any) *Error
- func UnUnknownUIDError() *Error
- func UnauthorizedError() *Error
- type ErrorCode
- type GetContractResult
- type GetUIDResult
- type HistoryResult
- type HonorNodeJSON
- type ID
- type IbaxApi
- type JWTClaims
- type KeyInfoResult
- type ListForm
- type ListResult
- type ListWhereForm
- type LoginResult
- type MemberInfo
- type Method
- type Mode
- type MultiTxInfoResult
- type NetApi
- type NetworkResult
- type NewApiService
- type NotSingle
- type Param
- type ParamResult
- type Params
- type ParamsResult
- type PartModel
- type RawResponse
- type Request
- type RequestContext
- type RequestWithNetwork
- type Response
- type RowResult
- type RpcApis
- type RpcServers
- type SectionsForm
- type Server
- type TableCountResult
- type TableResult
- type TxDetailResult
- type TxDetailedInfo
- type TxInfo
- type TxInfoResult
- type UserClient
Constants ¶
const ( ErrCodeDefault = -32000 ErrCodeInvalidInput = -32001 ErrCodeResourceNotFound = -32002 ErrCodeTransactionRejected = -32004 ErrCodeMethodNotSupported = -32005 ErrCodeLimitExceeded = -32006 ErrCodeParseError = -32007 ErrCodeInvalidRequest = -32008 ErrCodeMethodNotFound = -32009 ErrCodeInvalidParams = -32010 ErrCodeInternalError = -32011 ErrCodeNotFound = -32012 ErrCodeUnknownUID = -32013 ErrCodeParamsInvalid = -32015 )
const ( NamespaceDebug space = "debug" NamespaceIBAX space = "ibax" NamespaceAdmin space = "admin" NamespaceNet space = "net" )
const JsonRPCVersion = "2.0"
Variables ¶
This section is empty.
Functions ¶
func GetNamespace ¶
func GetNamespace(name space) string
func GetStructValue ¶
func InitJwtSecret ¶
func InitJwtSecret(secret []byte)
func NewAccountsApi ¶
func NewAccountsApi(m Mode) *accountsApi
func NewAuthApi ¶
func NewAuthApi(mode Mode) *authApi
func NewBlockChainApi ¶
func NewBlockChainApi() *blockChainApi
func NewCommonApi ¶
func NewCommonApi(m Mode) *commonApi
func NewDataApi ¶
func NewDataApi() *dataApi
func NewNetworkApi ¶
func NewNetworkApi() *networkApi
func NewTransactionApi ¶
func NewTransactionApi() *transactionApi
func RequestHandlerFunc ¶
func RequestHandlerFunc(fn requestHandlerFunc) *requestHandlerFunc
RequestHandlerFunc is a helper for handling JSONRPC Requests over HTTP It can be used by microservices to handle JSONRPC methods. For example:
http.Handle("/", RequestHandlerFunc(func(ctx context.Context, r *Request) (interface{}, *Error) { if r.Method != "eth_blockNumber" { return nil, MethodNotSupported(fmt.Sprintf("unsupported method %s", r.Method)) } return "0x123456", nil }))
func WriteBatchResponse ¶
func WriteBatchResponse(w http.ResponseWriter, resp any)
func WriteResponse ¶
func WriteResponse(w http.ResponseWriter, request *Request, result any, e *Error)
Types ¶
type AccountOrKeyId ¶
type AccountOrKeyId struct { KeyId int64 `json:"key_id,omitempty"` Account string `json:"account,omitempty"` }
func (*AccountOrKeyId) UnmarshalJSON ¶
func (bh *AccountOrKeyId) UnmarshalJSON(data []byte) error
UnmarshalJSON verify input, keyId is preferred
type AppContentResult ¶
type AppParamsForm ¶
type AppParamsForm struct {
// contains filtered or unexported fields
}
func (*AppParamsForm) AcceptNames ¶
func (f *AppParamsForm) AcceptNames(names string)
type AppParamsResult ¶
type AppParamsResult struct { App int64 `json:"app_id"` List []ParamResult `json:"list"` }
type AuthStatusResponse ¶
type BalanceResult ¶
type BatchRequest ¶
type BatchRequest []*Request
type BatchResponse ¶
type BatchResponse []*Response
type BlockDetailedInfo ¶
type BlockDetailedInfo struct { Header BlockHeaderInfo `json:"header"` Hash string `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 string `json:"rollbacks_hash"` MerkleRoot string `json:"merkle_root"` BinData string `json:"bin_data"` SysUpdate bool `json:"-"` GenBlock bool `json:"-"` StopCount int `json:"stop_count"` Transactions []TxDetailedInfo `json:"transactions"` }
type BlockHeaderInfo ¶
type BlockIdOrHash ¶
type BlockIdOrHash struct { Id int64 `json:"id,omitempty"` Hash string `json:"hash,omitempty"` // contains filtered or unexported fields }
func (*BlockIdOrHash) GetBlock ¶
func (bh *BlockIdOrHash) GetBlock() (int64, bool)
func (*BlockIdOrHash) GetHash ¶
func (bh *BlockIdOrHash) GetHash() ([]byte, bool)
func (*BlockIdOrHash) UnmarshalJSON ¶
func (bh *BlockIdOrHash) UnmarshalJSON(data []byte) error
type BlockInfoResult ¶
type BlockInfoResult struct { Hash string `json:"hash"` EcosystemID int64 `json:"ecosystem_id"` KeyID int64 `json:"key_id"` Time int64 `json:"time"` Tx int32 `json:"tx_count"` RollbacksHash string `json:"rollbacks_hash"` NodePosition int64 `json:"node_position"` ConsensusMode int32 `json:"consensus_mode"` }
type ContentResult ¶
type ContentResult struct { Menu string `json:"menu,omitempty"` MenuTree json.RawMessage `json:"menutree,omitempty"` Title string `json:"title,omitempty"` Tree json.RawMessage `json:"tree"` NodesCount int64 `json:"nodesCount,omitempty"` }
type DebugApi ¶
type DebugApi struct {
// contains filtered or unexported fields
}
func NewDebugApi ¶
func NewDebugApi() *DebugApi
type EcosystemInfo ¶
type EcosystemInfo struct { Id int64 `json:"id"` Name string `json:"name"` Digits int64 `json:"digits"` TokenSymbol string `json:"token_symbol"` TokenName string `json:"token_name"` TotalAmount string `json:"total_amount"` IsWithdraw bool `json:"is_withdraw"` Withdraw string `json:"withdraw"` IsEmission bool `json:"is_emission"` Emission string `json:"emission"` Introduction string `json:"introduction"` Logo int64 `json:"logo"` Creator string `json:"creator"` }
type Error ¶
type Error struct { Code ErrorCode `json:"code"` Message string `json:"message"` Data map[string]any `json:"data,omitempty"` }
func DefaultError ¶
func NotFoundError ¶
func NotFoundError() *Error
func ParseError ¶
func UnUnknownUIDError ¶
func UnUnknownUIDError() *Error
func UnauthorizedError ¶
func UnauthorizedError() *Error
type GetContractResult ¶
type GetContractResult struct { ID uint32 `json:"id"` StateID uint32 `json:"state"` TableID string `json:"tableid"` WalletID string `json:"walletid"` TokenID string `json:"tokenid"` Address string `json:"address"` Fields []contractField `json:"fields"` Name string `json:"name"` AppId uint32 `json:"app_id"` Ecosystem uint32 `json:"ecosystem"` Conditions string `json:"conditions"` }
type GetUIDResult ¶
type GetUIDResult struct { UID string `json:"uid,omitempty"` Token string `json:"token,omitempty"` Expire string `json:"expire,omitempty"` EcosystemID string `json:"ecosystem_id,omitempty"` KeyID string `json:"key_id,omitempty"` Address string `json:"address,omitempty"` NetworkID string `json:"network_id,omitempty"` Cryptoer string `json:"cryptoer"` Hasher string `json:"hasher"` }
type HistoryResult ¶
type HonorNodeJSON ¶
type ID ¶
type ID struct { // At most one of Num or Str may be nonzero. If both are zero // valued, then IsNum specifies which field's value is to be used // as the ID. Num uint64 Str string // IsString controls whether the Num or Str field's value should be // used as the ID, when both are zero valued. It must always be // set to true if the request ID is a string. IsString bool }
ID represents a JSON-RPC 2.0 request ID, which may be either a string or number (or null, which is unsupported).
func (ID) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (*ID) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
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 KeyInfoResult ¶
type KeyInfoResult struct { Account string `json:"account"` Ecosystems []*keyEcosystemInfo `json:"ecosystems"` }
type ListForm ¶
type ListForm struct { Name string `json:"name"` //table name // contains filtered or unexported fields }
type ListResult ¶
type ListWhereForm ¶
type LoginResult ¶
type LoginResult struct { Token string `json:"token,omitempty"` EcosystemID string `json:"ecosystem_id,omitempty"` KeyID string `json:"key_id,omitempty"` Account string `json:"account,omitempty"` NotifyKey string `json:"notify_key,omitempty"` IsNode bool `json:"isnode"` IsOwner bool `json:"isowner"` IsCLB bool `json:"clb"` Timestamp string `json:"timestamp,omitempty"` Roles []rolesResult `json:"roles,omitempty"` }
type MemberInfo ¶
type Mode ¶
type Mode struct { EcosystemGetter types.EcosystemGetter ContractRunner types.SmartContractRunner ClientTxProcessor types.ClientTxPreprocessor }
type MultiTxInfoResult ¶
type MultiTxInfoResult struct {
Results map[string]*TxInfoResult `json:"results"`
}
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 NewApiService ¶
type Param ¶
type Param json.RawMessage
Params is an ARRAY of json.RawMessages. This is because *Ethereum* RPCs always use arrays is their input parameter; this differs from the official JSONRPC spec, which allows parameters of any type. But, this assumption makes handling Params in our Ethereum API use-cases *so* much easier.
func (Param) MarshalJSON ¶
MarshalJSON returns m as the JSON encoding of m.
func (*Param) UnmarshalJSON ¶
UnmarshalJSON sets *m to a copy of data.
type ParamResult ¶
type Params ¶
type Params []Param
func MakeParams ¶
MakeParams generates JSONRPC parameters from its inputs, and should be used for complex dynamic data which may fail to marshal, in which case the error is propagated to the caller.
Examples:
params, err := jsonrpc.MakeParams(someComplexObject, "string", true)
func MustParams ¶
MakeParams can be used to generate JSONRPC Params field from well-known data, which should not fail.
Examples:
request.Params = jsonrpc.MustParams("latest", true)
func (Params) UnmarshalInto ¶
UnmarshalInto will decode Params into the passed in values, which must be pointer receivers. The type of the passed in value is used to Unmarshal the data. UnmarshalInto will fail if the parameters cannot be converted to the passed-in types.
Example:
var blockNum string var fullBlock bool err := request.Params.UnmarshalInto(&blockNum, &fullBlock)
IMPORTANT: While Go will compile with non-pointer receivers, the Unmarshal attempt will *always* fail with an error.
func (Params) UnmarshalSingleParam ¶
UnmarshalSingleParam can be used in the (rare) case where only one of the Request.Params is needed. For example we use this in Smart Routing to extract the blockNum value from RPCs without decoding the entire Params array.
Example:
err := request.Params.UnmarshalSingleParam(pos, &blockNum)
type ParamsResult ¶
type ParamsResult struct {
List []ParamResult `json:"list"`
}
type RawResponse ¶
type RawResponse struct { JSONRPC string `json:"jsonrpc"` ID ID `json:"id"` Result json.RawMessage `json:"result,omitempty"` Error *json.RawMessage `json:"error,omitempty"` }
RawResponse keeps Result and Error as unparsed JSON It is meant to be used to deserialize JSONPRC responses from downstream components while Response is meant to be used to craft our own responses to clients.
func (RawResponse) MarshalJSON ¶
func (r RawResponse) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler and adds the "jsonrpc":"2.0" property.
func (*RawResponse) UnmarshalJSON ¶
func (r *RawResponse) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler.
type Request ¶
type Request struct { JSONRPC string `json:"jsonrpc"` Method string `json:"method"` ID ID `json:"id"` Params Params `json:"params"` }
func MakeRequest ¶
MakeRequest builds a Request from all its parts, but returns an error if the params cannot be marshalled.
func MustRequest ¶
MustRequest builds a request from all its parts but panics if the params cannot be marshaled, so should only be used with well-known parameter data.
func NewRequest ¶
func NewRequest() *Request
func (Request) MarshalJSON ¶
MarshalJSON implements json.Marshaler and adds the "jsonrpc":"2.0" property.
func (*Request) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
type RequestContext ¶
func (*RequestContext) HTTPRequest ¶
func (rc *RequestContext) HTTPRequest() *http.Request
func (*RequestContext) HTTPResponseWriter ¶
func (rc *RequestContext) HTTPResponseWriter() http.ResponseWriter
func (*RequestContext) RawJSON ¶
func (rc *RequestContext) RawJSON() json.RawMessage
type RequestWithNetwork ¶
func (RequestWithNetwork) MarshalJSON ¶
func (r RequestWithNetwork) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler and adds the "jsonrpc":"2.0" property.
func (*RequestWithNetwork) UnmarshalJSON ¶
func (r *RequestWithNetwork) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler.
type Response ¶
type Response struct { JSONRPC string `json:"jsonrpc"` ID ID `json:"id"` Result any `json:"result,omitempty"` Error any `json:"error,omitempty"` }
func NewResponse ¶
func NewResponse() *Response
func (Response) MarshalJSON ¶
MarshalJSON implements json.Marshaler and adds the "jsonrpc":"2.0" property.
func (*Response) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
type RpcServers ¶
type RpcServers struct {
// contains filtered or unexported fields
}
func (*RpcServers) Modules ¶
func (r *RpcServers) Modules() ([]string, *Error)
type SectionsForm ¶
type SectionsForm struct { Lang string `schema:"lang"` // contains filtered or unexported fields }
type TableCountResult ¶
type TableCountResult struct { Count int64 `json:"count"` List []tableInfo `json:"list"` }
type TableResult ¶
type TableResult struct { Name string `json:"name"` Insert string `json:"insert"` NewColumn string `json:"new_column"` Update string `json:"update"` Read string `json:"read,omitempty"` Filter string `json:"filter,omitempty"` Conditions string `json:"conditions"` AppID string `json:"app_id"` Columns []columnInfo `json:"columns"` }
type TxDetailResult ¶
type TxDetailResult struct { }
type TxDetailedInfo ¶
type TxInfoResult ¶
Source Files ¶
- accounts.go
- api.go
- auth.go
- block.go
- callback.go
- common.go
- common_forms.go
- context.go
- data.go
- debug.go
- ecosystem_params.go
- errors.go
- handlers.go
- history.go
- http.go
- id.go
- jwt.go
- middlewares.go
- namespace.go
- namespace_debug.go
- namespace_ibax.go
- namespace_net.go
- params.go
- raw_response.go
- request.go
- response.go
- server.go
- service.go
- transaction.go
- txinfo.go