blockchain

package
v0.0.0-...-5955844 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2023 License: MIT Imports: 48 Imported by: 1

Documentation

Overview

Package blockchain provides functionality to interact with different blockchain interfaces.

Index

Constants

View Source
const (
	BIRITA = "bsn-irita"

	DefaultScannerInterval = 5
	ClientTimeout          = 10

	ServiceRequestEventType = "new_batch_request_provider"
)
View Source
const Agoric = "agoric"

Agoric is the identifier of this blockchain integration.

View Source
const BSC = "binance-smart-chain"
View Source
const CFX = "conflux"
View Source
const ETH = "ethereum"
View Source
const HMY = "harmony"
View Source
const (
	IOTX = "iotex"
)
View Source
const (
	Keeper = "keeper"
)
View Source
const Klaytn = "klaytn"
View Source
const (
	// NEAR platform name
	NEAR = "near"
)
View Source
const (
	ONT = "ontology"
)
View Source
const Substrate = "substrate"

Substrate is the identifier of this blockchain integration.

View Source
const UpkeepRegistryInterface = `` /* 1025-byte string literal not displayed */
View Source
const (
	XTZ = "tezos"
)

Variables

View Source
var (
	ErrConnectionType = errors.New("unknown connection type")
	ErrSubscriberType = errors.New("unknown subscriber type")
)
View Source
var ExpectsMock = false

ExpectsMock variable is set when we run in a mock context

Functions

func Cfx2EthResponse

func Cfx2EthResponse(cfx cfxLogResponse) (models.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 GetBlockNumberPayload

func GetBlockNumberPayload() ([]byte, error)

func GetConnectionType

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

func GetValidations

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

func ParseBlocknumberFromNewHeads

func ParseBlocknumberFromNewHeads(msg JsonrpcMessage) (*big.Int, error)

func ParseNEAROracleRequestsMap

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

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

func StringToBytes32

func StringToBytes32(str string) common.Hash

func ValidBlockchain

func ValidBlockchain(name string) bool

Types

type BIritaServiceRequest

type BIritaServiceRequest struct {
	ID          string `json:"id"`
	ServiceName string `json:"service_name"`
	Provider    string `json:"provider"`
	Input       string `json:"input"`
}

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 EventChainlinkOracleAnswer

type EventChainlinkOracleAnswer struct {
	Phase              types.Phase
	OracleAccountID    types.AccountID
	RequestIdentifier  types.U64
	RequesterAccountID types.AccountID
	Bytes              types.Text
	Payment            types.U32
	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_OracleAnswer         []EventChainlinkOracleAnswer         //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"`
	UpkeepID    string   `json:"upkeepId"`
	ServiceName string   `json:"serviceName"`
	From        string   `json:"from"`
}

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

Jump to

Keyboard shortcuts

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