nta

package
v0.6.16 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UpdateNodeStatus

func UpdateNodeStatus(node *schema.Node, newStatus schema.NodeStatus) error

UpdateNodeStatus updates the status of a given node if the transition is valid. It returns a NodeStatusTransitionError when the transition is invalid.

Types

type BatchNodeRequest

type BatchNodeRequest struct {
	Cursor        *string          `query:"cursor"`
	Limit         int              `query:"limit" validate:"min=1,max=50" default:"10"`
	NodeAddresses []common.Address `query:"node_addresses"`
}

type BridgeToken

type BridgeToken struct {
	Address BridgeTokenAddress `json:"address"`
	Value   decimal.Decimal    `json:"value"`
}

type BridgeTokenAddress

type BridgeTokenAddress struct {
	L1 *common.Address `json:"l1,omitempty"`
	L2 *common.Address `json:"l2,omitempty"`
}

type BridgeTransaction

type BridgeTransaction struct {
	ID        common.Hash                 `json:"id"`
	Sender    common.Address              `json:"sender"`
	Receiver  common.Address              `json:"receiver"`
	Token     BridgeToken                 `json:"token"`
	Event     BridgeTransactionEventTypes `json:"event"`
	Finalized bool                        `json:"finalized"`
}

func NewBridgeTransaction

func NewBridgeTransaction(transaction *schema.BridgeTransaction, events []*schema.BridgeEvent) *BridgeTransaction

type BridgeTransactionEvent

type BridgeTransactionEvent struct {
	Block       TransactionEventBlock       `json:"block"`
	Transaction TransactionEventTransaction `json:"transaction"`
}

type BridgeTransactionEventTypeDeposit

type BridgeTransactionEventTypeDeposit struct {
	Initialized *BridgeTransactionEvent `json:"initialized,omitempty"`
	Finalized   *BridgeTransactionEvent `json:"finalized,omitempty"`
}

type BridgeTransactionEventTypeWithdraw

type BridgeTransactionEventTypeWithdraw struct {
	Initialized *BridgeTransactionEvent `json:"initialized,omitempty"`
	Proved      *BridgeTransactionEvent `json:"proved,omitempty"`
	Finalized   *BridgeTransactionEvent `json:"finalized,omitempty"`
}

type BridgeTransactionEventTypes

type BridgeTransactionEventTypes struct {
	Deposit  *BridgeTransactionEventTypeDeposit  `json:"deposit,omitempty"`
	Withdraw *BridgeTransactionEventTypeWithdraw `json:"withdraw,omitempty"`
}

type CountSnapshot

type CountSnapshot struct {
	Date  string `json:"date"`
	Count uint64 `json:"count"`
}

type Epoch

type Epoch struct {
	ID                    uint64          `json:"id"`
	StartTimestamp        int64           `json:"start_timestamp"`
	EndTimestamp          int64           `json:"end_timestamp"`
	TotalOperationRewards decimal.Decimal `json:"total_operation_rewards"`
	TotalStakingRewards   decimal.Decimal `json:"total_staking_rewards"`
	TotalRequestCounts    decimal.Decimal `json:"total_request_counts"`
	TotalRewardedNodes    int             `json:"total_rewarded_nodes"`

	Distributions []*EpochTransaction `json:"distributions"`
}

func NewEpoch

func NewEpoch(id uint64, epochs []*schema.Epoch) *Epoch

type EpochTransaction

type EpochTransaction struct {
	ID                    uint64                      `json:"id"`
	StartTimestamp        int64                       `json:"start_timestamp"`
	EndTimestamp          int64                       `json:"end_timestamp"`
	Transaction           TransactionEventTransaction `json:"transaction"`
	Block                 TransactionEventBlock       `json:"block"`
	TotalOperationRewards decimal.Decimal             `json:"total_operation_rewards"`
	TotalStakingRewards   decimal.Decimal             `json:"total_staking_rewards"`
	TotalRequestCounts    decimal.Decimal             `json:"total_request_counts"`
	TotalRewardedNodes    int                         `json:"total_rewarded_nodes"`
	RewardedNodes         []*schema.RewardedNode      `json:"rewarded_nodes,omitempty"`
	CreatedAt             int64                       `json:"-"`
	UpdatedAt             int64                       `json:"-"`
}

func NewEpochTransaction

func NewEpochTransaction(epoch *schema.Epoch) *EpochTransaction

type GetBridgeTransactionRequest

type GetBridgeTransactionRequest struct {
	TransactionHash *common.Hash `param:"transaction_hash"`
}

type GetBridgeTransactionResponseData

type GetBridgeTransactionResponseData *BridgeTransaction

type GetBridgeTransactionsRequest

type GetBridgeTransactionsRequest struct {
	Cursor   *common.Hash                  `query:"cursor"`
	Sender   *common.Address               `query:"sender"`
	Receiver *common.Address               `query:"receiver"`
	Address  *common.Address               `query:"address"`
	Type     *schema.BridgeTransactionType `query:"type"`
	Limit    int                           `query:"limit" default:"20" min:"1" max:"20"`
}

type GetBridgeTransactionsResponseData

type GetBridgeTransactionsResponseData []*BridgeTransaction

type GetEpochDistributionRequest

type GetEpochDistributionRequest struct {
	TransactionHash common.Hash `param:"transaction_hash" validate:"required"`
	ItemLimit       int         `query:"item_limit" validate:"min=1,max=50" default:"10"`
	Cursor          *string     `query:"cursor"`
}

type GetEpochDistributionResponseData

type GetEpochDistributionResponseData *EpochTransaction

type GetEpochNodeRewardsRequest

type GetEpochNodeRewardsRequest struct {
	NodeAddress common.Address `param:"node_address" validate:"required"`
	Limit       int            `query:"limit" validate:"min=1,max=50" default:"10"`
	Cursor      *string        `query:"cursor"`
}

type GetEpochNodeRewardsResponseData

type GetEpochNodeRewardsResponseData *Epoch

type GetEpochRequest

type GetEpochRequest struct {
	EpochID   uint64  `param:"epoch_id" validate:"required"`
	ItemLimit int     `query:"item_limit" validate:"min=1,max=50" default:"10"`
	Cursor    *string `query:"cursor"`
}

type GetEpochResponseData

type GetEpochResponseData *Epoch

type GetEpochsRequest

type GetEpochsRequest struct {
	Cursor *string `query:"cursor"`
	Limit  int     `query:"limit" validate:"min=1,max=50" default:"10"`
}

type GetEpochsResponseData

type GetEpochsResponseData []*Epoch

func NewEpochs

func NewEpochs(epochs []*schema.Epoch) GetEpochsResponseData

type GetNodeCountSnapshotsResponseData

type GetNodeCountSnapshotsResponseData []*CountSnapshot

func NewNodeCountSnapshots

func NewNodeCountSnapshots(nodeSnapshots []*schema.NodeSnapshot) GetNodeCountSnapshotsResponseData

type GetNodeOperationProfitRequest added in v0.5.0

type GetNodeOperationProfitRequest struct {
	NodeAddress common.Address `param:"node_address" validate:"required"`
}

type GetNodeOperationProfitResponse added in v0.5.0

type GetNodeOperationProfitResponse struct {
	NodeAddress   common.Address          `json:"node_address"`
	OperationPool decimal.Decimal         `json:"operation_pool"`
	OneDay        *NodeProfitChangeDetail `json:"one_day"`
	OneWeek       *NodeProfitChangeDetail `json:"one_week"`
	OneMonth      *NodeProfitChangeDetail `json:"one_month"`
}

type GetNodeOperationProfitSnapshotsRequest added in v0.5.0

type GetNodeOperationProfitSnapshotsRequest struct {
	NodeAddress common.Address `query:"node_address" validate:"required"`
	Limit       *int           `query:"limit"`
	Cursor      *string        `query:"cursor"`
	BeforeDate  *time.Time     `query:"before_date"`
	AfterDate   *time.Time     `query:"after_date"`
}

type GetOperatorProfitsSnapshotsResponseData

type GetOperatorProfitsSnapshotsResponseData []*schema.OperatorProfitSnapshot

type GetStakeChipRequest

type GetStakeChipRequest struct {
	ChipID *big.Int `param:"chip_id"`
}

type GetStakeChipResponseData

type GetStakeChipResponseData *StakeChip

func NewStakeChip

func NewStakeChip(stakeChip *schema.StakeChip, baseURL url.URL) GetStakeChipResponseData

type GetStakeChipsImageRequest

type GetStakeChipsImageRequest struct {
	ChipID *big.Int `param:"chip_id"`
}

type GetStakeChipsRequest

type GetStakeChipsRequest struct {
	Cursor *big.Int        `query:"cursor"`
	IDs    []*big.Int      `query:"id"`
	Node   *common.Address `query:"node"`
	Owner  *common.Address `query:"owner"`
	Limit  int             `query:"limit" default:"10" min:"1" max:"10"`
}

type GetStakeChipsResponseData

type GetStakeChipsResponseData []*StakeChip

func NewStakeChips

func NewStakeChips(stakeChips []*schema.StakeChip, baseURL url.URL) GetStakeChipsResponseData

type GetStakeStakingsRequest

type GetStakeStakingsRequest struct {
	Cursor        *string         `query:"cursor"`
	StakerAddress *common.Address `query:"staker_address"`
	NodeAddress   *common.Address `query:"node_address"`
	Limit         int             `query:"limit" default:"10" min:"1" max:"20"`
}

type GetStakeStakingsResponseData

type GetStakeStakingsResponseData []*StakeStaking

func NewStakeStaking

func NewStakeStaking(stakeStakings []*schema.StakeStaking, baseURL url.URL) GetStakeStakingsResponseData

type GetStakeTransactionRequest

type GetStakeTransactionRequest struct {
	TransactionHash *common.Hash                 `param:"transaction_hash"`
	Type            *schema.StakeTransactionType `query:"type"`
}

type GetStakeTransactionResponseData

type GetStakeTransactionResponseData *StakeTransaction

func NewStakeTransaction

func NewStakeTransaction(transaction *schema.StakeTransaction, events []*schema.StakeEvent, stakeChips []*schema.StakeChip, baseURL url.URL) GetStakeTransactionResponseData

type GetStakeTransactionsRequest

type GetStakeTransactionsRequest struct {
	Cursor  *common.Hash                 `query:"cursor"`
	Staker  *common.Address              `query:"staker"`
	Node    *common.Address              `query:"node"`
	Type    *schema.StakeTransactionType `query:"type"`
	Pending *bool                        `query:"pending"`
	Limit   int                          `query:"limit" default:"20" min:"1" max:"20"`
}

type GetStakeTransactionsResponseData

type GetStakeTransactionsResponseData []*StakeTransaction

type GetStakerCountSnapshotsResponseData added in v0.5.9

type GetStakerCountSnapshotsResponseData []*CountSnapshot

func NewStakerCountSnapshots added in v0.5.9

func NewStakerCountSnapshots(stakeSnapshots []*schema.StakerCountSnapshot) GetStakerCountSnapshotsResponseData

type GetStakerProfitChangesSinceResponseData added in v0.5.18

type GetStakerProfitChangesSinceResponseData struct {
	Date            time.Time       `json:"date"`
	TotalChipAmount decimal.Decimal `json:"total_chip_amount"`
	TotalChipValue  decimal.Decimal `json:"total_chip_value"`
	ProfitAndLoss   decimal.Decimal `json:"profit_and_loss"`
}

type GetStakerProfitRequest added in v0.5.18

type GetStakerProfitRequest struct {
	StakerAddress common.Address `param:"staker_address" validate:"required"`
}

type GetStakerProfitResponseData added in v0.5.18

type GetStakerProfitResponseData struct {
	Owner           common.Address                           `json:"owner"`
	TotalChipAmount decimal.Decimal                          `json:"total_chip_amount"`
	TotalChipValue  decimal.Decimal                          `json:"total_chip_value"`
	OneDay          *GetStakerProfitChangesSinceResponseData `json:"one_day"`
	OneWeek         *GetStakerProfitChangesSinceResponseData `json:"one_week"`
	OneMonth        *GetStakerProfitChangesSinceResponseData `json:"one_month"`
}

type GetStakerProfitSnapshotsRequest

type GetStakerProfitSnapshotsRequest struct {
	StakerAddress common.Address `query:"staker_address" validate:"required"`
	Limit         *int           `query:"limit"`
	Cursor        *string        `query:"cursor"`
	BeforeDate    *time.Time     `query:"before_date"`
	AfterDate     *time.Time     `query:"after_date"`
}

type GetStakingStatRequest added in v0.6.4

type GetStakingStatRequest struct {
	Address common.Address `param:"staker_address" validate:"required"`
}

type NetworkRequest added in v0.4.8

type NetworkRequest struct {
	NetworkName string `param:"network_name" validate:"required"`
}

type NodeChallengeRequest

type NodeChallengeRequest struct {
	NodeAddress common.Address `param:"node_address" validate:"required"`
	Type        string         `query:"type"`
}

type NodeChallengeResponseData

type NodeChallengeResponseData string

type NodeEvent

type NodeEvent struct {
	Transaction TransactionEventTransaction `json:"transaction"`
	Block       TransactionEventBlock       `json:"block"`
	AddressFrom common.Address              `json:"address_from"`
	AddressTo   common.Address              `json:"address_to"`
	NodeID      uint64                      `json:"node_id"`
	Type        schema.NodeEventType        `json:"type"`
	LogIndex    uint                        `json:"log_index"`
	ChainID     uint64                      `json:"chain_id"`
	Metadata    schema.NodeEventMetadata    `json:"metadata"`
	Finalized   bool                        `json:"finalized"`
}

type NodeEventResponseData

type NodeEventResponseData *NodeEvent

func NewNodeEvent

func NewNodeEvent(event *schema.NodeEvent) NodeEventResponseData

type NodeEventsRequest

type NodeEventsRequest struct {
	NodeAddress common.Address `param:"node_address" validate:"required"`
	Cursor      *string        `query:"cursor"`
	Limit       int            `query:"limit" validate:"min=1,max=100" default:"20"`
}

type NodeEventsResponseData

type NodeEventsResponseData []*NodeEvent

func NewNodeEvents

func NewNodeEvents(events []*schema.NodeEvent) NodeEventsResponseData

type NodeHeartbeatRequest

type NodeHeartbeatRequest struct {
	Address   common.Address `json:"address" validate:"required"`
	Signature string         `json:"signature" validate:"required"`
	Endpoint  string         `json:"endpoint" validate:"required"`
	Timestamp int64          `json:"timestamp" validate:"required"`
}

type NodeHideTaxRateRequest

type NodeHideTaxRateRequest struct {
	NodeAddress common.Address `param:"node_address" validate:"required"`
	Signature   string         `json:"signature" validate:"required"`
}

type NodeProfitChangeDetail added in v0.5.0

type NodeProfitChangeDetail struct {
	Date          time.Time       `json:"date"`
	OperationPool decimal.Decimal `json:"operation_pool"`
	ProfitAndLoss decimal.Decimal `json:"profit_and_loss"`
}

type NodeRequest

type NodeRequest struct {
	Address common.Address `param:"node_address" validate:"required"`
}

type NodeResponseData

type NodeResponseData *schema.Node

func NewNode

func NewNode(node *schema.Node, baseURL url.URL) NodeResponseData

type NodeStatusTransitionError

type NodeStatusTransitionError struct {
	From, To schema.NodeStatus
}

NodeStatusTransitionError represents an error when attempting to transition a Node to an invalid status.

func (*NodeStatusTransitionError) Error

func (err *NodeStatusTransitionError) Error() string

Error returns a string representation of the NodeStatusTransitionError. TODO: move to a more appropriate location.

type NodesResponseData

type NodesResponseData []*schema.Node

func NewNodes

func NewNodes(nodes []*schema.Node, baseURL url.URL) NodesResponseData

type RegisterNodeRequest

type RegisterNodeRequest struct {
	Address     common.Address  `json:"address" validate:"required"`
	Signature   string          `json:"signature" validate:"required"`
	Endpoint    string          `json:"endpoint" validate:"required"`
	Stream      json.RawMessage `json:"stream,omitempty"`
	Config      json.RawMessage `json:"config,omitempty"`
	Type        string          `json:"type" validate:"required,oneof=alpha beta production" default:"alpha"`
	AccessToken string          `json:"access_token" validate:"required_if=Type production"`
}

type Response

type Response struct {
	Data   any    `json:"data"`
	Cursor string `json:"cursor,omitempty"`
}

type StakeChip

type StakeChip struct {
	ID          *big.Int        `json:"id"`
	Node        common.Address  `json:"node"`
	Owner       common.Address  `json:"owner"`
	Metadata    json.RawMessage `json:"metadata"`
	Value       decimal.Decimal `json:"value"`
	LatestValue decimal.Decimal `json:"latest_value"`
	Finalized   bool            `json:"finalized"`
}

type StakeStaking

type StakeStaking struct {
	Staker common.Address    `json:"staker,omitempty"`
	Node   common.Address    `json:"node,omitempty"`
	Value  decimal.Decimal   `json:"value"`
	Chips  StakeStakingChips `json:"chips"`
}

func NewStakeAddress

func NewStakeAddress(stakeAddress *schema.StakeStaking, baseURL url.URL) *StakeStaking

type StakeStakingChips

type StakeStakingChips struct {
	Total    uint64       `json:"total"`
	Showcase []*StakeChip `json:"showcase"`
}

type StakeTransaction

type StakeTransaction struct {
	ID        common.Hash                `json:"id"`
	Staker    common.Address             `json:"staker"`
	Node      common.Address             `json:"node"`
	Value     decimal.Decimal            `json:"value"`
	Chips     []*StakeChip               `json:"chips,omitempty"`
	Event     StakeTransactionEventTypes `json:"event"`
	Finalized bool                       `json:"finalized"`
}

type StakeTransactionEvent

type StakeTransactionEvent struct {
	Block       TransactionEventBlock       `json:"block"`
	Transaction TransactionEventTransaction `json:"transaction"`
	Metadata    json.RawMessage             `json:"metadata,omitempty"`
}

type StakeTransactionEventTypeDeposit

type StakeTransactionEventTypeDeposit struct {
	Deposited *StakeTransactionEvent `json:"deposited,omitempty"`
}

type StakeTransactionEventTypeMergeChips added in v0.6.5

type StakeTransactionEventTypeMergeChips struct {
	Merged *StakeTransactionEvent   `json:"merged,omitempty"`
	Burned []*StakeTransactionEvent `json:"burned,omitempty"`
}

type StakeTransactionEventTypeStake

type StakeTransactionEventTypeStake struct {
	Staked *StakeTransactionEvent `json:"staked,omitempty"`
}

type StakeTransactionEventTypeUnstake

type StakeTransactionEventTypeUnstake struct {
	Requested *StakeTransactionEvent `json:"requested,omitempty"`
	Claimed   *StakeTransactionEvent `json:"claimed,omitempty"`
}

type StakeTransactionEventTypeWithdraw

type StakeTransactionEventTypeWithdraw struct {
	Requested *StakeTransactionEvent `json:"requested,omitempty"`
	Claimed   *StakeTransactionEvent `json:"claimed,omitempty"`
}

type StakeTransactionEventTypes

type StakeTransactionEventTypes struct {
	Deposit    *StakeTransactionEventTypeDeposit    `json:"deposit,omitempty"`
	Withdraw   *StakeTransactionEventTypeWithdraw   `json:"withdraw,omitempty"`
	Stake      *StakeTransactionEventTypeStake      `json:"stake,omitempty"`
	Unstake    *StakeTransactionEventTypeUnstake    `json:"unstake,omitempty"`
	MergeChips *StakeTransactionEventTypeMergeChips `json:"merge_chips,omitempty"`
}

type TransactionEventBlock

type TransactionEventBlock struct {
	Hash      common.Hash `json:"hash"`
	Number    *big.Int    `json:"number"`
	Timestamp int64       `json:"timestamp"`
}

type TransactionEventTransaction

type TransactionEventTransaction struct {
	Hash  common.Hash `json:"hash"`
	Index uint        `json:"index"`
}

type WorkerRequest added in v0.4.17

type WorkerRequest struct {
	NetworkRequest

	WorkerName string `param:"worker_name" validate:"required"`
}

Jump to

Keyboard shortcuts

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