rpc

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPendingNotSupported = errors.New("pending block is not supported yet")

	ErrBlockNotFound   = &jsonrpc.Error{Code: 24, Message: "Block not found"}
	ErrTxnHashNotFound = &jsonrpc.Error{Code: 25, Message: "Transaction hash not found"}
	ErrNoBlock         = &jsonrpc.Error{Code: 32, Message: "There are no blocks"}
	ErrInvalidTxIndex  = &jsonrpc.Error{Code: 27, Message: "Invalid transaction index in a block"}
)

Functions

This section is empty.

Types

type BlockHeader

type BlockHeader struct {
	Hash             *felt.Felt `json:"block_hash"`
	ParentHash       *felt.Felt `json:"parent_hash"`
	Number           uint64     `json:"block_number"`
	NewRoot          *felt.Felt `json:"new_root"`
	Timestamp        uint64     `json:"timestamp"`
	SequencerAddress *felt.Felt `json:"sequencer_address,omitempty"`
}

https://github.com/starkware-libs/starknet-specs/blob/a789ccc3432c57777beceaa53a34a7ae2f25fda0/api/starknet_api_openrpc.json#L1072

type DeployedContract

type DeployedContract struct {
	Address   *felt.Felt `json:"address"`
	ClassHash *felt.Felt `json:"class_hash"`
}

type Entry

type Entry struct {
	Key   *felt.Felt `json:"key"`
	Value *felt.Felt `json:"value"`
}

type Event

type Event struct {
	From *felt.Felt   `json:"from_address"`
	Keys []*felt.Felt `json:"keys"`
	Data []*felt.Felt `json:"data"`
}

type Handler

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

func New

func New(bcReader blockchain.Reader, n utils.Network) *Handler

func (*Handler) BlockNumber

func (h *Handler) BlockNumber() (uint64, *jsonrpc.Error)

func (*Handler) BlockNumberAndHash

func (h *Handler) BlockNumberAndHash() (*BlockNumberAndHash, *jsonrpc.Error)

func (*Handler) ChainId

func (h *Handler) ChainId() (*felt.Felt, *jsonrpc.Error)

func (*Handler) GetBlockWithTxHashes

func (h *Handler) GetBlockWithTxHashes(id *BlockId) (*BlockWithTxHashes, *jsonrpc.Error)

func (*Handler) GetBlockWithTxs

func (h *Handler) GetBlockWithTxs(id *BlockId) (*BlockWithTxs, *jsonrpc.Error)

func (*Handler) GetTransactionByBlockIdAndIndex

func (h *Handler) GetTransactionByBlockIdAndIndex(id *BlockId, txIndex int) (*Transaction, *jsonrpc.Error)

GetTransactionByBlockIdAndIndex https://github.com/starkware-libs/starknet-specs/blob/master/api/starknet_api_openrpc.json#L184

type MsgToL1

type MsgToL1 struct {
	To      common.Address `json:"to_address"`
	Payload []*felt.Felt   `json:"payload"`
}

type Nonce

type Nonce struct {
	ContractAddress *felt.Felt `json:"contract_address"`
	Nonce           *felt.Felt `json:"nonce"`
}

type StateDiff

type StateDiff struct {
	StorageDiffs      []StorageDiff      `json:"storage_diffs"`
	Nonces            []Nonce            `json:"nonces"`
	DeployedContracts []DeployedContract `json:"deployed_contracts"`
	DeclaredClasses   []*felt.Felt       `json:"declared_contract_hashes"`
}

type StateUpdate

type StateUpdate struct {
	BlockHash *felt.Felt `json:"block_hash"`
	NewRoot   *felt.Felt `json:"new_root"`
	OldRoot   *felt.Felt `json:"old_root"`
	StateDiff *StateDiff `json:"state_diff"`
}

https://github.com/starkware-libs/starknet-specs/blob/ed85de6a701c966ec7395b0df4c8bd62f3cddbcd/api/starknet_api_openrpc.json#L844

type Status

type Status uint8

https://github.com/starkware-libs/starknet-specs/blob/a789ccc3432c57777beceaa53a34a7ae2f25fda0/api/starknet_api_openrpc.json#L1999-L2008

const (
	StatusPending Status = iota
	StatusAcceptedL2
	StatusAcceptedL1
	StatusRejected
)

func (Status) MarshalJSON

func (s Status) MarshalJSON() ([]byte, error)

type StorageDiff

type StorageDiff struct {
	Address        *felt.Felt `json:"address"`
	StorageEntries []Entry    `json:"storage_entries"`
}

type Transaction

type Transaction struct {
	Hash                *felt.Felt      `json:"transaction_hash,omitempty"`
	Type                TransactionType `json:"type"`
	Version             *felt.Felt      `json:"version,omitempty"`
	Nonce               *felt.Felt      `json:"nonce,omitempty"`
	MaxFee              *felt.Felt      `json:"max_fee,omitempty"`
	ContractAddress     *felt.Felt      `json:"contract_address,omitempty"`
	ContractAddressSalt *felt.Felt      `json:"contract_address_salt,omitempty"`
	ClassHash           *felt.Felt      `json:"class_hash,omitempty"`
	ConstructorCalldata []*felt.Felt    `json:"constructor_calldata,omitempty"`
	SenderAddress       *felt.Felt      `json:"sender_address,omitempty"`
	Signature           *[]*felt.Felt   `json:"signature,omitempty"`
	Calldata            *[]*felt.Felt   `json:"calldata,omitempty"`
	EntryPointSelector  *felt.Felt      `json:"entry_point_selector,omitempty"`
	CompiledClassHash   *felt.Felt      `json:"compiled_class_hash,omitempty"`
}

https://github.com/starkware-libs/starknet-specs/blob/a789ccc3432c57777beceaa53a34a7ae2f25fda0/api/starknet_api_openrpc.json#L1252

type TransactionReceipt

type TransactionReceipt struct {
	Type            TransactionType `json:"type"`
	Hash            *felt.Felt      `json:"transaction_hash"`
	ActualFee       *felt.Felt      `json:"actual_fee"`
	Status          Status          `json:"status"`
	BlockHash       *felt.Felt      `json:"block_hash"`
	BlockNumber     uint64          `json:"block_number"`
	MessagesSent    []*MsgToL1      `json:"messages_sent"`
	Events          []*Event        `json:"events"`
	ContractAddress *felt.Felt      `json:"contract_address,omitempty"`
}

https://github.com/starkware-libs/starknet-specs/blob/master/api/starknet_api_openrpc.json#L1871

type TransactionType

type TransactionType uint8
const (
	TxnDeclare TransactionType = iota
	TxnDeploy
	TxnDeployAccount
	TxnInvoke
	TxnL1Handler
)

func (TransactionType) MarshalJSON

func (t TransactionType) MarshalJSON() ([]byte, error)

Jump to

Keyboard shortcuts

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