starknet

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ContractNotFound = StarkNetError{
		Code:    20,
		Message: "Contract not found",
	}
	InvalidMessageSelector = StarkNetError{
		Code:    21,
		Message: "Invalid message selector",
	}
	InvalidCallData = StarkNetError{
		Code:    22,
		Message: "Invalid call data",
	}
	InvalidBlockId = StarkNetError{
		Code:    24,
		Message: "Invalid block id",
	}
	InvalidTxnHash = StarkNetError{
		Code:    25,
		Message: "Invalid txn hash",
	}
	InvalidTxnIndex = StarkNetError{
		Code:    27,
		Message: "Invalid transaction index in a block",
	}
	InvalidContractClassHash = StarkNetError{
		Code:    28,
		Message: "The supplied contract class hash is invalid or unknown",
	}
	NoBlocks = StarkNetError{
		Code:    32,
		Message: "There are no blocks",
	}
)
View Source
var ErrInvalidBlockId = errors.New("invalid block id")

Functions

This section is empty.

Types

type BlockBodyWithTxHashes

type BlockBodyWithTxHashes struct {
	Transactions []string `json:"transactions"`
}

type BlockBodyWithTxs

type BlockBodyWithTxs struct {
	Transactions []Txn `json:"transactions"`
}

type BlockHeader

type BlockHeader struct {
	BlockHash   string `json:"block_hash"`
	ParentHash  string `json:"parent_hash"`
	BlockNumber uint64 `json:"block_number"`
	NewRoot     string `json:"new_root"`
	Timestamp   int64  `json:"timestamp"`
	Sequencer   string `json:"sequencer_address"`
}

type BlockId

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

func (*BlockId) UnmarshalJSON

func (id *BlockId) UnmarshalJSON(data []byte) error

type BlockIdType

type BlockIdType int

type BlockWithTxHashes

type BlockWithTxHashes struct {
	BlockStatus string `json:"status"`
	BlockHeader
	BlockBodyWithTxHashes
}

func NewBlockWithTxHashes

func NewBlockWithTxHashes(block *types.Block) *BlockWithTxHashes

type BlockWithTxs

type BlockWithTxs struct {
	Status string `json:"status"`
	BlockHeader
	BlockBodyWithTxs
}

func NewBlockWithTxs

func NewBlockWithTxs(block *types.Block, txnManager *transaction.Manager) (*BlockWithTxs, error)

type CommonReceiptProperties

type CommonReceiptProperties struct {
	TransactionHash string  `json:"transaction_hash"`
	ActualFee       string  `json:"actual_fee"`
	Status          string  `json:"status"`
	BlockHash       string  `json:"block_hash"`
	BlockNumber     uint64  `json:"block_number"`
	Type            TxnType `json:"type"`
}

type CommonTxnProperties

type CommonTxnProperties struct {
	TxnHash   string   `json:"txn_hash"`
	MaxFee    string   `json:"max_fee"`
	Version   string   `json:"version"`
	Signature []string `json:"signature"`
	Nonce     string   `json:"nonce"`
	Type      string   `json:"type"`
}

type ContractClass

type ContractClass struct {
	Program           string `json:"program"`
	EntryPointsByType struct {
		Constructor []*ContractEntryPoint `json:"CONSTRUCTOR"`
		External    []*ContractEntryPoint `json:"EXTERNAL"`
		L1Handler   []*ContractEntryPoint `json:"L1_HANDLER"`
	}
}

type ContractEntryPoint

type ContractEntryPoint struct {
	Offset   string `json:"offset"`
	Selector string `json:"selector"`
}

type DeclareTxReceipt

type DeclareTxReceipt struct {
	CommonReceiptProperties
}

type DeclareTxn

type DeclareTxn struct {
	CommonTxnProperties
	ClassHash     string `json:"class_hash"`
	SenderAddress string `json:"sender_address"`
}

func NewDeclareTxn

func NewDeclareTxn(txn *types.TransactionDeclare) *DeclareTxn

type DeclatedContractItem

type DeclatedContractItem struct {
	ClassHash string `json:"class_hash"`
}

type DeployTxReceipt

type DeployTxReceipt struct {
	CommonReceiptProperties
}

type DeployTxn

type DeployTxn struct {
	TxnHash             string   `json:"txn_hash"`
	ClassHash           string   `json:"class_hash"`
	Version             string   `json:"version"`
	Type                string   `json:"type"`
	ContractAddress     string   `json:"contract_address"`
	ContractAddressSalt string   `json:"contract_address_salt"`
	ConstructorCalldata []string `json:"constructor_calldata"`
}

func NewDeployTxn

func NewDeployTxn(txn *types.TransactionDeploy) *DeployTxn

type DeployedContractItem

type DeployedContractItem struct {
	Address   string `json:"address"`
	ClassHash string `json:"class_hash"`
}

type Event

type Event struct {
	FromAddress string   `json:"from_address"`
	Keys        []string `json:"keys"`
	Data        []string `json:"data"`
}

func NewEvent

func NewEvent(event *types.Event) *Event

type FeeEstimate

type FeeEstimate struct {
	GasConsumed string `json:"gas_consumed"`
	GasPrice    string `json:"gas_price"`
	OverallFee  string `json:"overall_fee"`
}

type FunctionCall

type FunctionCall struct {
	ContractAddress    string   `json:"contract_address"`
	EntryPointSelector string   `json:"entry_point_selector"`
	Calldata           []string `json:"calldata"`
}

type InvokeTxReceipt

type InvokeTxReceipt struct {
	CommonReceiptProperties
	MessagesSent    []*MsgToL1 `json:"messages_sent"`
	L1OriginMessage *MsgToL2   `json:"l1_origin_message,omitempty"`
	Events          []*Event   `json:"events"`
}

type InvokeTxn

type InvokeTxn struct {
	CommonTxnProperties
	FunctionCall
}

func NewInvokeTxn

func NewInvokeTxn(txn *types.TransactionInvoke) *InvokeTxn

type MsgToL1

type MsgToL1 struct {
	ToAddress types.EthAddress `json:"to_address"`
	Payload   []string         `json:"payload"`
}

func NewMsgToL1

func NewMsgToL1(msg *types.MsgToL1) *MsgToL1

type MsgToL2

type MsgToL2 struct {
	FromAddress types.EthAddress `json:"from_address"`
	Payload     []string         `json:"payload"`
}

func NewMsgToL2

func NewMsgToL2(msg *types.MsgToL2) *MsgToL2

type Receipt

type Receipt interface {
	// contains filtered or unexported methods
}

func NewReceipt

func NewReceipt(receipt types.TxnReceipt) (Receipt, error)

type RpcFelt

type RpcFelt string

func (*RpcFelt) Felt

func (r *RpcFelt) Felt() *felt.Felt

func (*RpcFelt) UnmarshalJSON

func (r *RpcFelt) UnmarshalJSON(data []byte) error

type StarkNetError

type StarkNetError struct {
	Code    int
	Message string
}

func (StarkNetError) Error

func (s StarkNetError) Error() string

type StarkNetRpc

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

func New

func New(stateManager state.StateManager, blockManager *block.Manager, txnManager *transaction.Manager,
	synchronizer *sync2.Synchronizer, vm *cairovm.VirtualMachine,
) *StarkNetRpc

func (*StarkNetRpc) BlockHashAndNumber

func (s *StarkNetRpc) BlockHashAndNumber() (any, error)

func (*StarkNetRpc) BlockNumber

func (s *StarkNetRpc) BlockNumber() (any, error)

func (*StarkNetRpc) Call

func (s *StarkNetRpc) Call(blockId *BlockId, request *FunctionCall) (any, error)

func (*StarkNetRpc) ChainId

func (s *StarkNetRpc) ChainId() (any, error)

func (*StarkNetRpc) EstimateFee

func (s *StarkNetRpc) EstimateFee(request *InvokeTxn, blockId *BlockId) (any, error)

notest

func (*StarkNetRpc) GetBlockTransactionCount

func (s *StarkNetRpc) GetBlockTransactionCount(blockId *BlockId) (any, error)

func (*StarkNetRpc) GetBlockWithTxHashes

func (s *StarkNetRpc) GetBlockWithTxHashes(blockId *BlockId) (any, error)

func (*StarkNetRpc) GetBlockWithTxs

func (s *StarkNetRpc) GetBlockWithTxs(blockId *BlockId) (any, error)

func (*StarkNetRpc) GetClass

func (s *StarkNetRpc) GetClass(classHash *RpcFelt) (any, error)

func (*StarkNetRpc) GetClassHashAt

func (s *StarkNetRpc) GetClassHashAt(blockId *BlockId, address *RpcFelt) (any, error)

func (*StarkNetRpc) GetStateUpdate

func (s *StarkNetRpc) GetStateUpdate(blockId *BlockId) (any, error)

func (*StarkNetRpc) GetStorageAt

func (s *StarkNetRpc) GetStorageAt(address *RpcFelt, key *StorageKey, blockId *BlockId) (any, error)

func (*StarkNetRpc) GetTransactionByBlockIdAndIndex

func (s *StarkNetRpc) GetTransactionByBlockIdAndIndex(blockId *BlockId, index *uint64) (any, error)

func (*StarkNetRpc) GetTransactionByHash

func (s *StarkNetRpc) GetTransactionByHash(transactionHash *RpcFelt) (any, error)

func (*StarkNetRpc) GetTransactionReceipt

func (s *StarkNetRpc) GetTransactionReceipt(transactionHash *RpcFelt) (any, error)

func (*StarkNetRpc) HealthCheck

func (s *StarkNetRpc) HealthCheck() (any, error)

func (*StarkNetRpc) PendingTransactions

func (s *StarkNetRpc) PendingTransactions() (any, error)

func (*StarkNetRpc) ProtocolVersion

func (s *StarkNetRpc) ProtocolVersion() (any, error)

func (*StarkNetRpc) Syncing

func (s *StarkNetRpc) Syncing() (any, error)

type StateDiff

type StateDiff struct {
	StorageDiffs      []*StorageDiffItem      `json:"storage_diffs"`
	DeployedContracts []*DeployedContractItem `json:"deployed_contracts"`
	DeclaredContracts []*DeclatedContractItem `json:"declared_contracts"`
}

type StateUpdate

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

func NewStateUpdate

func NewStateUpdate(s *types.StateUpdate) *StateUpdate

type Status

type Status struct {
	Available bool `json:"available"`
}

type StorageDiffItem

type StorageDiffItem struct {
	Address string `json:"address"`
	Key     string `json:"key"`
	Value   string `json:"value"`
}

type StorageKey

type StorageKey string

func (*StorageKey) Felt

func (s *StorageKey) Felt() *felt.Felt

func (*StorageKey) UnmarshalJSON

func (s *StorageKey) UnmarshalJSON(data []byte) error

type SyncStatus

type SyncStatus struct {
	StartingBlockHash   string `json:"starting_block_hash"`
	StartingBlockNumber string `json:"starting_block_number"`
	CurrentBlockHash    string `json:"current_block_hash"`
	CurrentBlockNumber  string `json:"current_block_number"`
	HighestBlockHash    string `json:"highest_block_hash"`
	HighestBlockNumber  string `json:"highest_block_number"`
}

type Txn

type Txn interface {
	// contains filtered or unexported methods
}

func NewTxn

func NewTxn(tx types.IsTransaction) (Txn, error)

type TxnType

type TxnType string
const (
	TxnDeclare   TxnType = "DECLARE"
	TxnDeploy    TxnType = "DEPLOY"
	TxnInvoke    TxnType = "INVOKE"
	TxnL1Handler TxnType = "L1_HANDLER"
)

Jump to

Keyboard shortcuts

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