models

package
v0.0.0-...-58bdd35 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2023 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AVMName = "avm"
	PVMName = "pvm"
	CVMName = "cvm"

	CChainIn     CChainType = 1
	CchainOut    CChainType = 2
	CChainImport CChainType = 1
	CChainExport CChainType = 2

	OutputTypesSECP2556K1Transfer OutputType = 7
	OutputTypesSECP2556K1Mint     OutputType = 6
	OutputTypesNFTMint            OutputType = 10
	OutputTypesNFTTransfer        OutputType = 11
	OutputTypesAtomicExportTx     OutputType = 0xFFFFFFF1
	OutputTypesAtomicImportTx     OutputType = 0xFFFFFFF2

	BlockTypeProposal BlockType = 0x0
	BlockTypeAbort    BlockType = 0x1
	BlockTypeCommit   BlockType = 0x2
	BlockTypeStandard BlockType = 0x3
	BlockTypeAtomic   BlockType = 0x4

	TransactionTypeBase                       TransactionType = 0x0
	TransactionTypeCreateAsset                TransactionType = 0x1
	TransactionTypeOperation                  TransactionType = 0x2
	TransactionTypeAVMImport                  TransactionType = 0x3
	TransactionTypeAVMExport                  TransactionType = 0x4
	TransactionTypeAddValidator               TransactionType = 0xc
	TransactionTypeAddSubnetValidator         TransactionType = 0xd
	TransactionTypeAddDelegator               TransactionType = 0xe
	TransactionTypeCreateChain                TransactionType = 0xf
	TransactionTypeCreateSubnet               TransactionType = 0x10
	TransactionTypePVMImport                  TransactionType = 0x11
	TransactionTypePVMExport                  TransactionType = 0x12
	TransactionTypeAdvanceTime                TransactionType = 0x13
	TransactionTypeRewardValidator            TransactionType = 0x14
	TransactionTypeRemoveSubnetValidator      TransactionType = 0x15
	TransactionTypeTransformSubnet            TransactionType = 0x16
	TransactionTypeAddPermissionlessValidator TransactionType = 0x17
	TransactionTypeAddPermissionlessDelegator TransactionType = 0x18
	TransactionTypeAddDaoProposal             TransactionType = 0x19
	TransactionTypeAddDaoVote                 TransactionType = 0x20

	ResultTypeTransaction SearchResultType = "transaction"
	ResultTypeAsset       SearchResultType = "asset"
	ResultTypeAddress     SearchResultType = "address"
	ResultTypeOutput      SearchResultType = "output"
	ResultTypeCBlock      SearchResultType = "cBlock"
	ResultTypeCTrans      SearchResultType = "cTransaction"
	ResultTypeCAddress    SearchResultType = "cAddress"

	TypeUnknown = "unknown"
)

Bech32HRP is the human-readable part of bech32 addresses. It needs to be available to Address.MarshalJSON is there is no other way to give it this data

Functions

func MergeAggregates

func MergeAggregates(dst, src *AggregateMergeList)

Merges two TxfeeAggregateList, both have to be sorted by Idx

func SetBech32HRP

func SetBech32HRP(networkID uint32)

SetBech32HRP sets the package-wide beck32HRP to use for Address marshaling.

Types

type Address

type Address StringShortID

Address represents an address; a short ID that is shown to users as bech32.

func ToAddress

func ToAddress(id ids.ShortID) Address

ToAddress converts an ids.ShortID into an Address.

func (Address) Equals

func (addr Address) Equals(oAddr2 Address) bool

Equals returns true if and only if the two Addresses represent the same.

func (Address) MarshalJSON

func (addr Address) MarshalJSON() ([]byte, error)

MarshalJSON encodes an Address to JSON by converting it to bech32.

func (Address) MarshalString

func (addr Address) MarshalString() ([]byte, error)

type AddressChainInfo

type AddressChainInfo struct {
	Address   Address   `json:"address"`
	ChainID   StringID  `json:"chainID"`
	CreatedAt time.Time `json:"timestamp"`
}

type AddressChains

type AddressChains struct {
	AddressChains map[string][]StringID `json:"addressChains"`
}

type AddressInfo

type AddressInfo struct {
	ChainID   StringID `json:"chainID"`
	Address   Address  `json:"address"`
	PublicKey []byte   `json:"publicKey"`

	Assets map[StringID]AssetInfo `json:"assets"`

	Score uint64 `json:"-"`
}

type AddressList

type AddressList struct {
	ListMetadata
	Addresses []*AddressInfo `json:"addresses"`
}

type AggregateMerge

type AggregateMerge interface {
	ID() int
	Merge(AggregateMerge)
}

type AggregateMergeList

type AggregateMergeList []AggregateMerge

type Aggregates

type Aggregates struct {
	AggregateMerge
	// IntervalID is used internally when creating a histogram of Aggregates.
	// It is exported only so it can be written to by dbr.
	IntervalID int `json:"-"`

	// StartTime is the calculated start time rounded to the nearest
	// TransactionRoundDuration.
	StartTime time.Time `json:"startTime"`

	// EndTime is the calculated end time rounded to the nearest
	// TransactionRoundDuration.
	EndTime time.Time `json:"endTime"`

	TransactionVolume TokenAmount `json:"transactionVolume"`
	TransactionCount  uint64      `json:"transactionCount"`
	AddressCount      uint64      `json:"addressCount"`
	OutputCount       uint64      `json:"outputCount"`
	AssetCount        uint64      `json:"assetCount"`
}

func (*Aggregates) ID

func (a *Aggregates) ID() int

func (*Aggregates) Merge

func (a *Aggregates) Merge(b AggregateMerge)

type AggregatesHistogram

type AggregatesHistogram struct {
	Aggregates   Aggregates    `json:"aggregates"`
	IntervalSize time.Duration `json:"intervalSize,omitempty"`
	Intervals    []Aggregates  `json:"intervals,omitempty"`

	// StartTime is the calculated start time rounded to the nearest
	// TransactionRoundDuration.
	StartTime time.Time `json:"startTime"`

	// EndTime is the calculated end time rounded to the nearest
	// TransactionRoundDuration.
	EndTime time.Time `json:"endTime"`
}

type AggregatesList

type AggregatesList []Aggregates

func (AggregatesList) MergeList

func (al AggregatesList) MergeList() *AggregateMergeList

type Asset

type Asset struct {
	ID      StringID `json:"id"`
	ChainID StringID `json:"chainID"`

	Name          string      `json:"name"`
	Symbol        string      `json:"symbol"`
	Alias         string      `json:"alias"`
	CurrentSupply TokenAmount `json:"currentSupply"`
	CreatedAt     time.Time   `json:"timestamp"`

	Score uint64 `json:"-"`

	Denomination uint8 `json:"denomination"`
	VariableCap  uint8 `json:"variableCap"`
	Nft          uint8 `json:"nft"`
}

type AssetAggregate

type AssetAggregate struct {
	Asset     ids.ID               `json:"asset"`
	Aggregate *AggregatesHistogram `json:"aggregate"`
}

type AssetInfo

type AssetInfo struct {
	AssetID StringID `json:"id"`

	TransactionCount uint64      `json:"transactionCount"`
	UTXOCount        uint64      `json:"utxoCount"`
	Balance          TokenAmount `json:"balance"`
	TotalReceived    TokenAmount `json:"totalReceived"`
	TotalSent        TokenAmount `json:"totalSent"`
}

type AssetList

type AssetList struct {
	ListMetadata
	Assets []*Asset `json:"assets"`
}

type AssetTokenCounts

type AssetTokenCounts map[StringID]TokenAmount

AssetTokenCounts maps asset IDs to a TokenAmount for that asset.

type Block

type Block struct {
	ID        StringID  `json:"id"`
	ParentID  StringID  `json:"parentID"`
	ChainID   StringID  `json:"chainID"`
	Type      BlockType `json:"type"`
	CreatedAt time.Time `json:"createdAt"`
}

type BlockList

type BlockList struct {
	ListMetadata
	Blocks []*Block `json:"blocks"`
}

type BlockProposal

type BlockProposal struct {
	Proposer  string     `json:"proposer,omitempty"`
	TimeStamp *time.Time `json:"timeStamp,omitempty"`
}

Proposal information P/C

func NewBlockProposal

func NewBlockProposal(b block.Block, t *time.Time) *BlockProposal

type BlockType

type BlockType uint16

BlockType represents a sub class of Block.

type BlockValue

type BlockValue struct {
	Block uint64 `json:"block"`
}

type CBlockHeaderBase

type CBlockHeaderBase struct {
	Hash       string `json:"hash"`
	Coinbase   string `json:"miner"`
	Difficulty string `json:"difficulty"`
	Number     string `json:"number"`
	GasLimit   string `json:"gasLimit"`
	GasUsed    string `json:"gasUsed"`
	Time       string `json:"timestamp"`
	BaseFee    string `json:"baseFeePerGas"`

	ExtDataGasUsed string `json:"extDataGasUsed,omitempty"`
	BlockGasCost   string `json:"blockGasCost,omitempty"`

	EvmTx    int16 `json:"evmTx,omitempty"`
	AtomicTx int16 `json:"atomicTx,omitempty"`
}

type CBlockList

type CBlockList struct {
	Blocks       []*CBlockHeaderBase     `json:"blocks"`
	Transactions []*CTransactionDataBase `json:"transactions"`
}

type CChainType

type CChainType uint16

type CResult

type CResult struct {
	Number uint64 `json:"number"`
	Hash   string `json:"hash"`
}

type CTransactionData

type CTransactionData struct {
	Type      int       `json:"type"`
	Block     string    `json:"block"`
	Hash      string    `json:"hash"`
	CreatedAt time.Time `json:"createdAt"`
	Nonce     uint64    `json:"nonce"`
	GasPrice  *string   `json:"gasPrice,omitempty"`
	GasFeeCap *string   `json:"maxFeePerGas,omitempty"`
	GasTipCap *string   `json:"maxPriorityFeePerGas,omitempty"`
	GasLimit  uint64    `json:"gasLimit"`
	Amount    *string   `json:"value,omitempty"`
	Payload   *string   `json:"input,omitempty"`
	FromAddr  string    `json:"fromAddr"`
	ToAddr    string    `json:"toAddr"`

	// Signature values
	V *string `json:"v,omitempty"`
	R *string `json:"r,omitempty"`
	S *string `json:"s,omitempty"`

	Receipt *modelsc.ExtendedReceipt `json:"receipt"`
}

type CTransactionDataBase

type CTransactionDataBase struct {
	Type      string `json:"type"`
	Block     string `json:"block"`
	Index     string `json:"index"`
	Hash      string `json:"hash"`
	Nonce     string `json:"nonce"`
	GasPrice  string `json:"gasPrice,omitempty"`
	GasFeeCap string `json:"maxFeePerGas,omitempty"`
	GasTipCap string `json:"maxPriorityFeePerGas,omitempty"`
	Gas       string `json:"gas"`
	Amount    string `json:"value"`
	From      string `json:"from"`
	To        string `json:"to,omitempty"`

	CreatedAt         string `json:"timestamp"`
	Status            string `json:"status"`
	GasUsed           string `json:"gasUsed"`
	EffectiveGasPrice string `json:"effectiveGasPrice"`
}

type CTransactionList

type CTransactionList struct {
	Transactions []*CTransactionData
	// StartTime is the calculated start time rounded to the nearest
	// TransactionRoundDuration.
	StartTime time.Time `json:"startTime"`

	// EndTime is the calculated end time rounded to the nearest
	// TransactionRoundDuration.
	EndTime time.Time `json:"endTime"`
}

type ChainCounts

type ChainCounts struct {
	ChainID StringID `json:"chainID"`
	Total   string   `json:"total"`
}

type ChainInfo

type ChainInfo struct {
	ID          StringID `json:"chainID"`
	Alias       string   `json:"chainAlias"`
	VM          string   `json:"vm"`
	DJTXAssetID StringID `json:"djtxAssetID"`
	NetworkID   uint32   `json:"networkID"`
}

ChainInfo represents an overview of data about a given chain

type ControlSignature

type ControlSignature []byte

type CvmOutput

type CvmOutput struct {
	Type            CChainType  `json:"type"`
	TransactionType CChainType  `json:"transactionType"`
	Idx             uint64      `json:"idx"`
	Amount          TokenAmount `json:"amount"`
	Nonce           uint64      `json:"nonce"`
	ID              StringID    `json:"id"`
	TransactionID   StringID    `json:"transactionID"`
	Address         string      `json:"address"`
	AssetID         StringID    `json:"assetID"`
	CreatedAt       time.Time   `json:"timestamp"`
	ChainID         StringID    `json:"chainID"`
	Block           string      `json:"block"`
}

type Input

type Input struct {
	Output *Output            `json:"output"`
	Creds  []InputCredentials `json:"credentials"`
}

type InputCredentials

type InputCredentials struct {
	Address   Address `json:"address"`
	PublicKey []byte  `json:"public_key"`
	Signature []byte  `json:"signature"`
}

type ListMetadata

type ListMetadata struct {
	Count *uint64 `json:"count,omitempty"`
}

type Output

type Output struct {
	ID                     StringID    `json:"id"`
	TransactionID          StringID    `json:"transactionID"`
	OutputIndex            uint64      `json:"outputIndex"`
	AssetID                StringID    `json:"assetID"`
	Stake                  bool        `json:"stake"`
	Frozen                 bool        `json:"frozen"`
	Stakeableout           bool        `json:"stakeableout"`
	Genesisutxo            bool        `json:"genesisutxo"`
	OutputType             OutputType  `json:"outputType"`
	Amount                 TokenAmount `json:"amount"`
	Locktime               uint64      `json:"locktime"`
	StakeLocktime          uint64      `json:"stakeLocktime"`
	Threshold              uint64      `json:"threshold"`
	Addresses              []Address   `json:"addresses"`
	CAddresses             []string    `json:"caddresses"`
	CreatedAt              time.Time   `json:"timestamp"`
	RedeemingTransactionID StringID    `json:"redeemingTransactionID"`
	ChainID                StringID    `json:"chainID"`
	InChainID              StringID    `json:"inChainID"`
	OutChainID             StringID    `json:"outChainID"`
	GroupID                uint64      `json:"groupID"`
	Payload                []byte      `json:"payload"`
	Block                  string      `json:"block"`
	Nonce                  uint64      `json:"nonce"`
	RewardUtxo             bool        `json:"rewardUtxo"`
	Score                  uint64      `json:"-"`
}

type OutputAddress

type OutputAddress struct {
	OutputID  StringID `json:"output_id"`
	Address   Address  `json:"address"`
	Signature []byte   `json:"signature"`
	PublicKey []byte   `json:"-"`
}

type OutputList

type OutputList struct {
	ListMetadata
	Outputs []*Output `json:"outputs"`
}

type OutputType

type OutputType uint32

OutputType represents a sub class of Output.

func (OutputType) String

func (t OutputType) String() string

type SearchResult

type SearchResult struct {
	// SearchResultType is the type of object found
	SearchResultType `json:"type"`

	// Data is the object itself
	Data interface{} `json:"data"`

	// Score is a rank of how well this result matches the query
	Score uint64 `json:"score"`
}

SearchResult represents a single item matching a search query.

type SearchResultSet

type SearchResultSet []SearchResult

func (SearchResultSet) Len

func (s SearchResultSet) Len() int

func (SearchResultSet) Less

func (s SearchResultSet) Less(i, j int) bool

func (SearchResultSet) Swap

func (s SearchResultSet) Swap(i, j int)

type SearchResultType

type SearchResultType string

SearchResultType is the type for an object found from a search query.

type SearchResults

type SearchResults struct {
	// Count is the total number of matching results
	Count uint64 `json:"count"`

	// Results is a list of SearchResult
	Results SearchResultSet `json:"results"`
}

SearchResults represents a set of items returned for a search query.

type StringID

type StringID string

StringID represents a 256bit hash encoded as a base58 string.

func ToStringID

func ToStringID(id ids.ID) StringID

ToStringID converts an ids.ID into a StringID.

func (StringID) Equals

func (rid StringID) Equals(oRID StringID) bool

Equals returns true if and only if the two stringIDs represent the same ID.

type StringShortID

type StringShortID string

StringShortID represents a 160bit hash encoded as a base58 string.

func ToShortStringID

func ToShortStringID(id ids.ShortID) StringShortID

ToShortStringID converts an ids.ShortID into a StringShortID.

func (StringShortID) Equals

func (rid StringShortID) Equals(oRID StringShortID) bool

Equals returns true if and only if the two stringShortIDs represent the same ID.

type TokenAmount

type TokenAmount string

TokenAmount represents some number of tokens as a string.

func TokenAmountForUint64

func TokenAmountForUint64(i uint64) TokenAmount

TokenAmountForUint64 returns an TokenAmount for the given uint64.

type Transaction

type Transaction struct {
	ID      StringID `json:"id"`
	ChainID StringID `json:"chainID"`
	Type    string   `json:"type"`

	Inputs  []*Input  `json:"inputs"`
	Outputs []*Output `json:"outputs"`

	Memo []byte `json:"memo"`

	InputTotals         AssetTokenCounts `json:"inputTotals"`
	OutputTotals        AssetTokenCounts `json:"outputTotals"`
	ReusedAddressTotals AssetTokenCounts `json:"reusedAddressTotals"`

	CanonicalSerialization []byte    `json:"canonicalSerialization,omitempty"`
	CreatedAt              time.Time `json:"timestamp"`

	Txfee uint64 `json:"txFee"`

	Genesis bool `json:"genesis"`

	Rewarded     bool       `json:"rewarded"`
	RewardedTime *time.Time `json:"rewardedTime"`

	Epoch uint64 `json:"epoch"`

	VertexID StringID `json:"vertexId"`

	ValidatorNodeID StringID `json:"validatorNodeID"`
	ValidatorStart  uint64   `json:"validatorStart"`
	ValidatorEnd    uint64   `json:"validatorEnd"`

	TxBlockID StringID `json:"txBlockId"`

	Proposer *BlockProposal `json:"proposer,omitempty"`

	Score uint64 `json:"-"`
}

type TransactionList

type TransactionList struct {
	ListMetadata

	Transactions []*Transaction `json:"transactions"`

	// StartTime is the calculated start time rounded to the nearest
	// TransactionRoundDuration.
	StartTime time.Time `json:"startTime"`

	// EndTime is the calculated end time rounded to the nearest
	// TransactionRoundDuration.
	EndTime time.Time `json:"endTime"`

	Next *string `json:"next,omitempty"`
}

type TransactionType

type TransactionType uint16

TransactionType represents a sub class of Transaction.

func (TransactionType) String

func (t TransactionType) String() string

type TxfeeAggregates

type TxfeeAggregates struct {
	AggregateMerge
	// IntervalID is used internally when creating a histogram of Aggregates.
	// It is exported only so it can be written to by dbr.
	IntervalID int `json:"-"`

	// StartTime is the calculated start time rounded to the nearest
	// TransactionRoundDuration.
	StartTime time.Time `json:"startTime"`

	// EndTime is the calculated end time rounded to the nearest
	// TransactionRoundDuration.
	EndTime time.Time `json:"endTime"`

	Txfee uint64 `json:"txfee"`
}

func (*TxfeeAggregates) ID

func (a *TxfeeAggregates) ID() int

func (*TxfeeAggregates) Merge

func (a *TxfeeAggregates) Merge(b AggregateMerge)

type TxfeeAggregatesHistogram

type TxfeeAggregatesHistogram struct {
	TxfeeAggregates TxfeeAggregates   `json:"aggregates"`
	IntervalSize    time.Duration     `json:"intervalSize,omitempty"`
	Intervals       []TxfeeAggregates `json:"intervals,omitempty"`

	// StartTime is the calculated start time rounded to the nearest
	// TransactionRoundDuration.
	StartTime time.Time `json:"startTime"`

	// EndTime is the calculated end time rounded to the nearest
	// TransactionRoundDuration.
	EndTime time.Time `json:"endTime"`
}

type TxfeeAggregatesList

type TxfeeAggregatesList []TxfeeAggregates

func (TxfeeAggregatesList) MergeList

func (al TxfeeAggregatesList) MergeList() *AggregateMergeList

Jump to

Keyboard shortcuts

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