webapi

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package webapi SKALE Indexer API

An api for SKALE indexer to retrieve and fetch SKALE network information

Terms Of Service:

there are no TOS at this moment, use at your own risk we take no responsibility

Schemes: http
Host: localhost:8885
BasePath: /
Version: 0.0.1

Consumes:
- application/json

Produces:
- application/json

swagger:meta

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	// Address - account address (Address represents the 20 byte address of an Ethereum account)
	//
	// package: github.com/ethereum/go-ethereum/common
	// format: [20]byte
	Address common.Address `json:"address"`
	// Type - account type
	Type string `json:"type"`
}

Account structure representing ethereum account used in SKALE swagger:model

type AccountParams

type AccountParams struct {
	// Type - type of the account
	//
	Type string `json:"type"`
	// Address - account address i.e. holder
	//
	// format: hexadecimal
	Address string `json:"address"`
	// Limit - Limit of the records per page
	//
	// required: false
	Limit uint64 `json:"limit"`
	// Offset - Offset of the records in pages
	//
	// required: false
	Offset uint64 `json:"offset"`
}

AccountParams a set of fields to be used for accounts search swagger:model

type Accounts

type Accounts []Account

swagger:model

type ApiError

type ApiError struct {
	// Error - error message from api
	Error string `json:"error"`
	// Code - http code
	Code int `json:"code"`
}

ApiError a set of fields to show error swagger:model

type ClientContractor

type ClientContractor interface {
	GetNodes(ctx context.Context, params structs.NodeParams) (nodes []structs.Node, err error)
	GetValidators(ctx context.Context, params structs.ValidatorParams) (validators []structs.Validator, err error)
	GetDelegations(ctx context.Context, params structs.DelegationParams) (delegations []structs.Delegation, err error)
	GetDelegationTimeline(ctx context.Context, params structs.DelegationParams) (delegations []structs.Delegation, err error)

	GetValidatorStatistics(ctx context.Context, params structs.ValidatorStatisticsParams) (validatorStatistics []structs.ValidatorStatistics, err error)
	GetValidatorStatisticsTimeline(ctx context.Context, params structs.ValidatorStatisticsParams) (validatorStatistics []structs.ValidatorStatistics, err error)
	GetAccounts(ctx context.Context, params structs.AccountParams) (accounts []structs.Account, err error)

	GetContractEvents(ctx context.Context, params structs.EventParams) (contractEvents []structs.ContractEvent, err error)
	GetSystemEvents(ctx context.Context, params structs.SystemEventParams) (systemEvents []structs.SystemEvent, err error)

	GetTypesSummaryDelegations(ctx context.Context, params structs.DelegationParams) (delegations []structs.DelegationSummary, err error)
}

ClientContractor - method signatures for Connector

type Connector

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

Connector is main HTTP connector for manager

func NewClientConnector

func NewClientConnector(cli ClientContractor) *Connector

NewClientConnector is connector constructor

func (*Connector) AttachToHandler

func (c *Connector) AttachToHandler(mux *http.ServeMux)

AttachToHandler attaches handlers to http server's mux

func (*Connector) GetAccount

func (c *Connector) GetAccount(w http.ResponseWriter, req *http.Request)

func (*Connector) GetContractEvents

func (c *Connector) GetContractEvents(w http.ResponseWriter, req *http.Request)

GetContractEvents

func (*Connector) GetDelegation

func (c *Connector) GetDelegation(w http.ResponseWriter, req *http.Request)

func (*Connector) GetNode

func (c *Connector) GetNode(w http.ResponseWriter, req *http.Request)

func (*Connector) GetSummary added in v0.0.4

func (c *Connector) GetSummary(w http.ResponseWriter, req *http.Request)

func (*Connector) GetSystemEvents

func (c *Connector) GetSystemEvents(w http.ResponseWriter, req *http.Request)

func (*Connector) GetValidator

func (c *Connector) GetValidator(w http.ResponseWriter, req *http.Request)

func (*Connector) GetValidatorStatistics

func (c *Connector) GetValidatorStatistics(w http.ResponseWriter, req *http.Request)

type ContractEvent

type ContractEvent struct {
	// ID - Identification on database, not the mainnet
	ID uuid.UUID `json:"id"`
	// ContractName - Name of the contract
	//
	// example: delegation_controller
	ContractName string `json:"contract_name"`
	// EventName - name of the event in contract_name
	//
	// example: ValidatorRegistered
	EventName string `json:"event_name"`
	// ContractAddress - Address of the contract (Address represents the 20 byte address of an Ethereum account)
	//
	// package: github.com/ethereum/go-ethereum/common
	ContractAddress common.Address `json:"contract_address"`
	// BlockHeight - Block number at ETH mainnet
	BlockHeight uint64 `json:"block_height"`
	// Time - Event time
	//
	// A Time represents an instant in time with nanosecond precision.
	Time time.Time `json:"time"`
	// TransactionHash - transaction where the event occurred
	//
	// package: github.com/ethereum/go-ethereum/common
	// Hash represents the 32 byte Keccak256 hash of arbitrary data
	// format: string
	TransactionHash common.Hash `json:"transaction_hash"`
	// Removed - indicates whether the event is removed on SKALE
	Removed bool `json:"removed"`
	// Event params
	//
	// bounty id array or address array
	Params map[string]interface{} `json:"params"`
}

ContractEvent a set of fields to show returned events (contract events) by search swagger:model

type ContractEvents

type ContractEvents []ContractEvent

swagger:model

type Delegation

type Delegation struct {
	// DelegationID - the index of delegation in SKALE deployed smart contract
	//
	// package: math/big
	DelegationID *big.Int `json:"id"`
	// Holder - Address of the token holder (Address represents the 20 byte address of an Ethereum account.)
	//
	// package: github.com/ethereum/go-ethereum/common
	// format: [20]byte
	Holder common.Address `json:"holder"`
	// TransactionHash - transaction where delegation updated ( Hash represents the 32 byte Keccak256 hash of arbitrary data)
	//
	// package: github.com/ethereum/go-ethereum/common
	// format: [32]byte
	TransactionHash common.Hash `json:"transaction_hash"`
	// ValidatorID - the index of validator in SKALE deployed smart contract
	//
	// package: math/big
	ValidatorID *big.Int `json:"validator_id"`
	// ValidatorName - validator name
	ValidatorName string `json:"validator_name"`
	// BlockHeight - Block number at ETH mainnet
	BlockHeight uint64 `json:"block_height"`
	// Amount - delegation amount SKL unit
	Amount string `json:"amount"`
	// Period - The duration delegation as chosen by the delegator
	//
	// package: math/big
	Period *big.Int `json:"period"`
	// Created - Creation time at ETH mainnet
	//
	// package: time
	// A Time represents an instant in time with nanosecond precision.
	Created time.Time `json:"created"`
	// Started - started  epoch
	//
	// package: math/big
	Started *big.Int `json:"started"`
	// Finished - finished  epoch
	//
	// package: math/big
	Finished *big.Int `json:"finished"`
	// Info - delegation information
	Info string `json:"info"`
	// State - delegation state
	State string `json:"state"`
}

Delegation a set of fields to show returned delegations by search swagger:model

type DelegationParams

type DelegationParams struct {
	// DelegationID - the index of delegation in SKALE deployed smart contract
	//
	// format: unsigned integer
	DelegationID string `json:"id"`
	// ValidatorID - the index of validator in SKALE deployed smart contract
	//
	// format: unsigned integer
	ValidatorID string `json:"validator_id"`
	// Holder - holder address
	//
	// format: hexadecimal
	Holder string `json:"holder"`
	// TimeAt - point time for that the validation statuses will be returned
	//
	// supposed to be sent with time to
	// time format: RFC3339
	// example: 2021-09-22T12:42:31Z
	TimeAt time.Time `json:"at"`
	// Timeline - returns whether the latest or delegation changes timeline
	//
	// case false to fetch recent info for filtered delegations
	// case true to fetch whole delegations for the filter
	Timeline bool `json:"timeline"`
	// Limit - Limit of the records per page
	//
	// required: false
	Limit uint64 `json:"limit"`
	// Offset - Offset of the records in pages
	//
	// required: false
	Offset uint64 `json:"offset"`
	// State - states to filter by
	//
	// required: false
	State []string `json:"state"`
}

DelegationParams a set of fields to be used for accounts search swagger:model

type DelegationSummary added in v0.0.4

type DelegationSummary struct {
	Count  *big.Int `json:"count"`
	Amount *big.Int `json:"amount"`
	State  string   `json:"state"`
}

type Delegations

type Delegations []Delegation

swagger:model

type EventParams

type EventParams struct {
	// Id - represents the bound id of the event
	//
	// supposed to used together with Type, i.e. required when Type is used
	// format: unsigned integer
	// required: false
	ID uint64 `json:"id,omitempty"`
	// Type - filtering events by event type
	//
	// supposed to used together with Id, i.e. required when Id is used
	// example: validator
	Type string `json:"type"`
	// TimeFrom - the inclusive beginning of the time range for event time
	//
	// supposed to be sent with time to
	// required: true
	// time format: RFC3339
	// example: 2020-09-22T12:42:31Z
	TimeFrom time.Time `json:"from"`
	// TimeTo - the inclusive ending of the time range for event time
	//
	// supposed to be sent with time from
	// required: true
	// time format: RFC3339
	// example: 2021-09-22T12:42:31Z
	TimeTo time.Time `json:"to"`
	// Limit - Limit of the records per page
	//
	// required: false
	Limit uint64 `json:"limit"`
	// Offset - Offset of the records in pages
	//
	// required: false
	Offset uint64 `json:"offset"`
}

EventParams a set of fields to be used for events (contract events) search swagger:model

type LatestDataRequest

type LatestDataRequest struct {
	Network string `json:"network"`
	ChainID string `json:"chain_id"`
	Version string `json:"version"`

	TaskID     string `json:"task_id"`
	LastHeight uint64 `json:"last_height"`
}

type LatestDataResponse

type LatestDataResponse struct {
	LastHeight uint64 `json:"last_height"`
	Error      []byte `json:"error"`
	Processing bool   `json:"processing"`
}

type Node

type Node struct {
	// NodeID - the index of node in SKALE deployed smart contract
	//
	// package: math/big
	NodeID *big.Int `json:"id"`
	// Name - node name
	Name string `json:"name"`
	// IP - node ip
	IP string `json:"ip"`
	// PublicIP - node public ip
	PublicIP string `json:"public_ip"`
	// Port - node port
	Port uint16 `json:"port"`
	// StartBlock - starting block height on ETH mainnet
	//
	// package: math/big
	StartBlock *big.Int `json:"start_block"`
	// NextRewardDate - next reward time
	//
	// package: time
	NextRewardDate time.Time `json:"next_reward_date"`
	// LastRewardDate - last reward time
	//
	// package: time
	LastRewardDate time.Time `json:"last_reward_date"`
	// FinishTime - finish time
	//
	// package: math/big
	FinishTime *big.Int `json:"finish_time"`
	// ValidatorID - validator Id on SKALE network
	//
	// package: math/big
	ValidatorID *big.Int `json:"validator_id"`
	// Status - node status
	Status string `json:"status"`
	// Address - node address on SKALE (Address represents the 20 byte address of an Ethereum account)
	//
	// package: github.com/ethereum/go-ethereum/common
	// format: [20]byte
	Address common.Address `json:"address"`
}

Node a set of fields to show returned nodes by search swagger:model

type NodeParams

type NodeParams struct {
	// NodeID - the index of node in SKALE deployed smart contract
	//
	// format: unsigned integer
	NodeID string `json:"id"`
	// ValidatorID - the index of validator in SKALE deployed smart contract
	//
	// format: unsigned integer
	ValidatorID string `json:"validator_id"`
	// Status - node status
	//
	// example: Active
	Status string `json:"status"`
	// Limit - Limit of the records per page
	//
	// required: false
	Limit uint64 `json:"limit"`
	// Offset - Offset of the records in pages
	//
	// required: false
	Offset uint64 `json:"offset"`
}

NodeParams a set of fields to be used for nodes search swagger:model

type Nodes

type Nodes []Node

swagger:model

type ScrapeConnector

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

ScrapeConnector is main HTTP connector for manager

func NewScrapeConnector

func NewScrapeConnector(l *zap.Logger, sc ScrapeContractor, scrapeLatestTimeout time.Duration) *ScrapeConnector

NewScrapeConnector is Connector constructor

func (*ScrapeConnector) AttachToHandler

func (sc *ScrapeConnector) AttachToHandler(mux *http.ServeMux)

AttachToHandler attaches handlers to http server's mux

func (*ScrapeConnector) GetLatest

func (sc *ScrapeConnector) GetLatest(w http.ResponseWriter, req *http.Request)

* Gets latest entries after certain height

func (*ScrapeConnector) GetLogs

func (sc *ScrapeConnector) GetLogs(w http.ResponseWriter, req *http.Request)

* Gets logs from node endpoint

type ScrapeContractor

type ScrapeContractor interface {
	ParseLogs(ctx context.Context, taskID string, from, to big.Int) error
	GetLatestData(ctx context.Context, taskID string, latest uint64) (lastHeight uint64, isRunning bool, err error)
}

type Summary added in v0.0.4

type Summary struct {
	Delegations []DelegationSummary `json:"delegation_summary"`
}

SystemEvent event information for reporting some activities in chain swagger:model

type SystemEvent

type SystemEvent struct {
	ID          string          `json:"id"`
	Height      uint64          `json:"height"`
	Time        time.Time       `json:"time"`
	Kind        string          `json:"kind"`
	SenderID    uint64          `json:"sender_id"`
	RecipientID uint64          `json:"recipient_id"`
	Sender      common.Address  `json:"sender"`
	Recipient   common.Address  `json:"recipient"`
	Data        SystemEventData `json:"data"`
}

SystemEvent event information for reporting some activities in chain swagger:model

type SystemEventData

type SystemEventData struct {
	Before big.Int   `json:"before"`
	After  big.Int   `json:"after"`
	Change big.Float `json:"change"`
}

SystemEventData value for SystemEvent

type SystemEventParams

type SystemEventParams struct {
	After       uint64 `json:"after"`
	Kind        string `json:"kind"`
	Address     string `json:"address"`
	ValidatorID string `json:"validator_id"`
	ID          string `json:"id"`
	SenderID    uint64 `json:"sender_id"`
	ReceiverID  uint64 `json:"receiver_id"`
	Limit       uint64 `json:"limit"`
	Offset      uint64 `json:"offset"`
}

SystemEventParams a set of fields to be used for system events

type Validator

type Validator struct {
	// ValidatorID - the index of validator in SKALE deployed smart contract
	//
	// package: math/big
	ValidatorID *big.Int `json:"id"`
	// Name - validator name
	Name string `json:"name"`
	// Description - validator description
	Description string `json:"description"`
	// ValidatorAddress - validator address on SKALE (Address represents the 20 byte address of an Ethereum account)
	//
	// package: github.com/ethereum/go-ethereum/common
	// format: [20]byte
	ValidatorAddress common.Address `json:"validator_address"`
	// RequestedAddress - requested address on SKALE (Address represents the 20 byte address of an Ethereum account)
	//
	// package: github.com/ethereum/go-ethereum/common
	// format: [20]byte
	RequestedAddress common.Address `json:"requested_address"`
	// FeeRate - fee rate
	//
	// package: math/big
	FeeRate *big.Int `json:"fee_rate"`
	// RegistrationTime - registration time to network
	//
	// package: time
	RegistrationTime time.Time `json:"registration_time"`
	// MinimumDelegationAmount - minimum delegation amount i.e. MDR
	//
	// package: math/big
	MinimumDelegationAmount *big.Int `json:"minimum_delegation_amount"`
	// AcceptNewRequests - shows whether validator accepts new requests or not
	AcceptNewRequests bool `json:"accept_new_requests"`
	// Authorized - shows whether validator is authorized or not
	Authorized bool `json:"authorized"`
	// ActiveNodes - number of active nodes attached to the validator
	ActiveNodes uint `json:"active_nodes"`
	// LinkedNodes - number of all nodes attached to the validator
	LinkedNodes uint `json:"linked_nodes"`
	// Staked - total stake amount
	Staked string `json:"staked"`
}

Validator a set of fields to show returned validators by search swagger:model

type ValidatorParams

type ValidatorParams struct {
	// ValidatorID - the index of validator in SKALE deployed smart contract
	//
	// format: unsigned integer
	ValidatorID string `json:"id"`
	// TimeFrom - the inclusive beginning of the time range for registration time
	//
	// supposed to be sent with time to
	// time format: RFC3339
	// example: 2020-09-22T12:42:31Z
	TimeFrom time.Time `json:"from"`
	// TimeTo - the inclusive ending of the time range for registration time
	//
	// supposed to be sent with time from
	// time format: RFC3339
	// example: 2021-09-22T12:42:31Z
	TimeTo time.Time `json:"to"`
	// Authorized - get 1 = only authorized, 2 = only not authorized
	//
	// example: 1
	Authorized uint8 `json:"authorized"`
	// Address - validator address
	//
	// format: hexadecimal
	Address string `json:"address"`
	// Limit - Limit of the records per page
	//
	// required: false
	Limit uint64 `json:"limit"`
	// Offset - Offset of the records in pages
	//
	// required: false
	Offset uint64 `json:"offset"`
}

ValidatorParams a set of fields to be used for validators search swagger:model

type ValidatorStatistic

type ValidatorStatistic struct {
	// ValidatorID - the index of validator in SKALE deployed smart contract
	// package: math/big
	ValidatorID *big.Int `json:"id"`
	// Amount - statistics amount
	Amount string `json:"amount"`
	// BlockHeight - block height on ETH mainnet
	BlockHeight uint64 `json:"block_height"`
	// BlockTime - block timestamp on ETH mainnet
	BlockTime time.Time `json:"block_time"`
	// Type - statistics type
	Type string `json:"type"`
}

ValidatorStatistic validator statistic value in given block swagger:model

type ValidatorStatistics

type ValidatorStatistics []ValidatorStatistic

swagger:model

type ValidatorStatisticsParams

type ValidatorStatisticsParams struct {
	// ValidatorID - the index of validator in SKALE deployed smart contract
	//
	// format: unsigned integer
	ValidatorID string `json:"id"`
	// Type - statistics type
	//
	// example: TOTAL_STAKE
	Type string `json:"type"`
	// BlockHeight - Block number at ETH mainnet
	BlockHeight uint64 `json:"height"`
	// TimeFrom - the inclusive beginning of the time range for block time
	//
	// supposed to be sent with time to
	// time format: RFC3339
	// example: 2020-09-22T12:42:31Z
	TimeFrom time.Time `json:"from"`
	// TimeTo - the inclusive ending of the time range for block time
	//
	// supposed to be sent with time to
	// time format: RFC3339
	// example: 2021-09-22T12:42:31Z
	TimeTo time.Time `json:"to"`
	// Timeline - returns whether the latest or statistics changes timeline
	//
	// case false to fetch recent info for filtered statistics
	// case true to fetch whole statistics for the filter
	Timeline bool `json:"timeline"`
	// Limit - Limit of the records per page
	//
	// required: false
	Limit uint64 `json:"limit"`
	// Offset - Offset of the records in pages
	//
	// required: false
	Offset uint64 `json:"offset"`
}

ValidatorStatisticsParams a set of fields to be used for validator statistics search swagger:model

type Validators

type Validators []Validator

swagger:model

Jump to

Keyboard shortcuts

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