Documentation

Overview

Package blockchain provides functionality to interact with different blockchain interfaces.

Index

Constants

const BSC = "binance-smart-chain"

const CFX = "conflux"

const ETH = "ethereum"

const (
	ETH_CALL = "eth-call"
)

const HMY = "harmony"

const (
	IOTX = "iotex"
)

const (
	// NEAR platform name
	NEAR = "near"
)

const (
	ONT = "ontology"
)

const Substrate = "substrate"

Substrate is the identifier of this blockchain integration.


const (
	XTZ = "tezos"
)

Variables

var ExpectsMock = false

ExpectsMock variable is set when we run in a mock context


Functions

func Cfx2EthResponse

func Cfx2EthResponse(cfx cfxLogResponse) (eth.Log, error)

convert cfxLogResponse type to eth.Log type

func CreateClientManager

func CreateClientManager(sub store.Subscription) (subscriber.ISubscriber, error)

CreateClientManager creates a new instance of a subscriber.ISubscriber with the provided connection type and store.Subscription config.

func CreateJsonManager

func CreateJsonManager(t subscriber.Type, sub store.Subscription) (subscriber.JsonManager, error)

CreateJsonManager creates a new instance of a JSON blockchain manager with the provided connection type and store.Subscription config.

func CreateSubscription

func CreateSubscription(sub *store.Subscription, params Params)

func GetConnectionType

func GetConnectionType(endpoint store.Endpoint) (subscriber.Type, error)

func GetValidations

func GetValidations(t string, params Params) []int

func ParseNEAROracleRequestsMap

func ParseNEAROracleRequestsMap(msg JsonrpcMessage) (map[string][]NEAROracleRequest, error)

ParseNEAROracleRequestsMap will unmarshal JsonrpcMessage result.result as map[string][]NEAROracleRequest

func StringToBytes32

func StringToBytes32(jobid string) string

func ValidBlockchain

func ValidBlockchain(name string) bool

Types

type EventChainlinkKillRequest

type EventChainlinkKillRequest struct {
	Phase             types.Phase
	RequestIdentifier types.U64
	Topics            []types.Hash
}

type EventChainlinkOperatorRegistered

type EventChainlinkOperatorRegistered struct {
	Phase     types.Phase
	AccountID types.AccountID
	Topics    []types.Hash
}

type EventChainlinkOperatorUnregistered

type EventChainlinkOperatorUnregistered struct {
	Phase     types.Phase
	AccountID types.AccountID
	Topics    []types.Hash
}

type EventChainlinkOracleRequest

type EventChainlinkOracleRequest struct {
	Phase              types.Phase
	OracleAccountID    types.AccountID
	SpecIndex          types.Text
	RequestIdentifier  types.U64
	RequesterAccountID types.AccountID
	DataVersion        types.U64
	Bytes              SubstrateRequestParams
	Callback           types.Text
	Payment            types.U32
	Topics             []types.Hash
}

EventChainlinkOracleRequest is the event structure we expect to be emitted from the Chainlink pallet

type EventRecords

type EventRecords struct {
	types.EventRecords
	Chainlink_OracleRequest        []EventChainlinkOracleRequest        //nolint:stylecheck,golint
	Chainlink_OperatorRegistered   []EventChainlinkOperatorRegistered   //nolint:stylecheck,golint
	Chainlink_OperatorUnregistered []EventChainlinkOperatorUnregistered //nolint:stylecheck,golint
	Chainlink_KillRequest          []EventChainlinkKillRequest          //nolint:stylecheck,golint
}

type JsonrpcMessage

type JsonrpcMessage struct {
	Version string          `json:"jsonrpc"`
	ID      json.RawMessage `json:"id,omitempty"`
	Method  string          `json:"method,omitempty"`
	Params  json.RawMessage `json:"params,omitempty"`
	Error   *interface{}    `json:"error,omitempty"`
	Result  json.RawMessage `json:"result,omitempty"`
}

JsonrpcMessage declares JSON-RPC message type

type NEAROracleFnGetAllRequestsArgs

type NEAROracleFnGetAllRequestsArgs struct {
	MaxNumAccounts string `json:"max_num_accounts"` // uint64 string
	MaxRequests    string `json:"max_requests"`     // uint64 string
}

NEAROracleFnGetAllRequestsArgs represents function arguments for NEAR oracle 'get_all_requests' function

type NEAROracleNonces

type NEAROracleNonces = map[string]string

NEAROracleNonces maps accounts to its latest nonce TODO: user *big.Int for nonces (u128)

func ParseNEARNEAROracleNonces

func ParseNEARNEAROracleNonces(msg JsonrpcMessage) (NEAROracleNonces, error)

ParseNEARNEAROracleNonces will unmarshal JsonrpcMessage result.result as NEAROracleNonces map

type NEAROracleRequest

type NEAROracleRequest struct {
	Nonce   string                `json:"nonce"`
	Request NEAROracleRequestArgs `json:"request"`
}

NEAROracleRequest is the request returned by the oracle 'get_requests' or 'get_all_requests' function

type NEAROracleRequestArgs

type NEAROracleRequestArgs struct {
	CallerAccount   string `json:"caller_account"`
	RequestSpec     string `json:"request_spec"` // base64-encoded
	CallbackAddress string `json:"callback_address"`
	CallbackMethod  string `json:"callback_method"`
	Data            string `json:"data"`       // base64-encoded
	Payment         uint64 `json:"payment"`    // in LINK tokens
	Expiration      uint64 `json:"expiration"` // in nanoseconds
}

NEAROracleRequestArgs contains the oracle request arguments

type NEAROracleRequestFulfillmentArgs

type NEAROracleRequestFulfillmentArgs struct {
	Account string `json:"account"`
	Nonce   string `json:"nonce"`
}

NEAROracleRequestFulfillmentArgs contains the arguments for oracle 'fulfill_request' function

type NEARQueryCallFunction

type NEARQueryCallFunction struct {
	RequestType string `json:"request_type"`
	Finality    string `json:"finality"`
	AccountID   string `json:"account_id"`
	MethodName  string `json:"method_name"`
	ArgsBase64  string `json:"args_base64"` // base64-encoded
}

NEARQueryCallFunction is a JSON-RPC Params struct for NEAR JSON-RPC query Method where "request_type": "call_function".

NEAR "call_function" request type, calls method_name in contract account_id as view function with data as parameters.

type NEARQueryResult

type NEARQueryResult struct {
	Result      []byte `json:"result"`
	Logs        []byte `json:"logs"`
	BlockHeight uint64 `json:"block_height"`
	BlockHash   string `json:"block_hash"`
}

NEARQueryResult is a result struct for NEAR JSON-RPC NEARQueryCallFunction response

func ParseNEARQueryResult

func ParseNEARQueryResult(msg JsonrpcMessage) (*NEARQueryResult, error)

ParseNEARQueryResult will unmarshal JsonrpcMessage as a NEAR standard NEARQueryResult

type NEARStatus

type NEARStatus struct {
	ChainID               string          `json:"chain_id"`
	LatestProtocolVersion uint16          `json:"latest_protocol_version"`
	ProtocolVersion       uint16          `json:"protocol_version"`
	RPCAddr               string          `json:"rpc_addr"`
	SyncInfo              NEARSyncInfo    `json:"sync_info"`
	Validators            []NEARValidator `json:"validators"`
}

NEARStatus is a result type for NEAR JSON-RPC status response, contains NEAR network status info

type NEARSyncInfo

type NEARSyncInfo struct {
	LatestBlockHash   string `json:"latest_block_hash"`
	LatestBlockHeight uint64 `json:"latest_block_height"`
	LatestBlockTime   string `json:"latest_block_time"`
	LatestStateRoot   string `json:"latest_state_root"`
	Syncing           bool   `json:"syncing"`
}

NEARSyncInfo type contains NEAR sync info

type NEARValidator

type NEARValidator struct {
	AccountID string `json:"account_id"`
	IsSlashed bool   `json:"is_slashed"`
}

NEARValidator type contains NEAR validator info

type NEARVersion

type NEARVersion struct {
	Build   string `json:"build"`
	Version string `json:"version"`
}

NEARVersion type contains NEAR build & version info

type Params

type Params struct {
	Endpoint    string          `json:"endpoint"`
	Addresses   []string        `json:"addresses"`
	Topics      []string        `json:"topics"`
	AccountIds  []string        `json:"accountIds"`
	Address     string          `json:"address"`
	ABI         json.RawMessage `json:"abi"`
	MethodName  string          `json:"methodName"`
	ResponseKey string          `json:"responseKey"`
}

type SubstrateRequestParams

type SubstrateRequestParams []string

SubstrateRequestParams allows for decoding a scale hex string into a byte array, which is then encoded back to a scale encoded byte array, to be decoded into a string array. This solves issues where decoding directly into a string array would read past the end of the array.

func (*SubstrateRequestParams) Decode

func (a *SubstrateRequestParams) Decode(decoder scale.Decoder) error

func (SubstrateRequestParams) Encode

func (a SubstrateRequestParams) Encode(_ scale.Encoder) error