data

package
v0.0.0-...-9345ff8 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2023 License: MIT Imports: 12 Imported by: 0

README

Data

Package contains general structures.

BlockID

The most usable filter is BlockID. It has the following definition:

// BlockID -
type BlockID struct {
	Hash   string
	Number uint64
	String string
}

You can set Hash or Number of block or set String to latest or pending value to filter by them. But you should set only one field of BlockID structure. If you set 2 fields you'll receive validation error. For example:

// for hash
api.GetBlockWithTxs(ctx, BlockID{Hash: "some_hash"})
// for number
api.GetBlockWithTxs(ctx, BlockID{Number: 100})
// for latest
api.GetBlockWithTxs(ctx, BlockID{String: Latest})
// for pending
api.GetBlockWithTxs(ctx, BlockID{String: Pending})

// wrong call
api.GetBlockWithTxs(ctx, BlockID{Hash: "some_hash", Number: 100})

Documentation

Index

Constants

View Source
const (
	Latest  = "latest"
	Pending = "pending"
)

default block string names

View Source
const (
	Version0 = "0x0"
	Version1 = "0x1"
	Version2 = "0x2"
)

versions

View Source
const (
	CallTypeCall     = "CALL"
	CallTypeDelegate = "DELEGATE"
)

call types

View Source
const (
	EntrypointTypeExternal    = "EXTERNAL"
	EntrypointTypeConstructor = "CONSTRUCTOR"
	EntrypointTypeL1Handler   = "L1_HANDLER"
)

entrypoint types

View Source
const (
	StatusNotReceived  = "NOT_RECEIVED"
	StatusReceived     = "RECEIVED"
	StatusPending      = "PENDING"
	StatusRejected     = "REJECTED"
	StatusAcceptedOnL2 = "ACCEPTED_ON_L2"
	StatusAcceptedOnL1 = "ACCEPTED_ON_L1"
)

statuses

View Source
const (
	TransactionTypeInvoke         = "INVOKE"
	TransactionTypeInvokeFunction = "INVOKE_FUNCTION"
	TransactionTypeDeclare        = "DECLARE"
	TransactionTypeDeploy         = "DEPLOY"
	TransactionTypeDeployAccount  = "DEPLOY_ACCOUNT"
	TransactionTypeL1Handler      = "L1_HANDLER"
)
View Source
const (
	AddressBytesLength = 32
)

length

View Source
const DefaultJSONRPC = "2.0"

Variables

View Source
var (
	ErrInvalidBlockFilter = errors.New("Only one field of Hash, Number or String in BlockFilter should be set")
	ErrEmptyBlockFilter   = errors.New("empty BlockFilter")
)

errors

Functions

This section is empty.

Types

type BlockID

type BlockID struct {
	Hash   string
	Number *uint64
	String string
}

BlockID -

func (BlockID) GetArg

func (bf BlockID) GetArg() (string, string)

GetArg -

func (BlockID) MarshalJSON

func (bf BlockID) MarshalJSON() ([]byte, error)

MarshalJSON -

func (BlockID) Validate

func (bf BlockID) Validate() error

Validate -

type Class

type Class struct {
	EntryPointsByType EntrypointsByType  `json:"entry_points_by_type"`
	Abi               abi.Abi            `json:"-"`
	RawAbi            stdJSON.RawMessage `json:"abi"`
}

Class -

func (*Class) GetAbi

func (c *Class) GetAbi() (abi.Abi, error)

GetAbi -

type Declare

type Declare struct {
	MaxFee          Felt     `json:"max_fee"`
	Nonce           Felt     `json:"nonce"`
	SenderAddress   Felt     `json:"sender_address"`
	ContractAddress Felt     `json:"contract_address"`
	Signature       []string `json:"signature"`
	ContractClass   Class    `json:"contract_class,omitempty"`
	ClassHash       Felt     `json:"class_hash,omitempty"`
}

Declare -

type Deploy

type Deploy struct {
	ContractAddressSalt string   `json:"contract_address_salt"`
	ConstructorCalldata []string `json:"constructor_calldata"`
	ClassHash           Felt     `json:"class_hash,omitempty"`
	ContractClass       Class    `json:"contract_class,omitempty"`
	ContractAddress     Felt     `json:"contract_address"`
}

Deploy -

type DeployAccount

type DeployAccount struct {
	MaxFee              Felt     `json:"max_fee"`
	Nonce               Felt     `json:"nonce"`
	ContractAddress     Felt     `json:"contract_address"`
	ContractAddressSalt string   `json:"contract_address_salt"`
	ClassHash           Felt     `json:"class_hash"`
	ConstructorCalldata []string `json:"constructor_calldata"`
	Signature           []string `json:"signature"`
}

DeployAccount -

type DeployedContract

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

DeployedContract -

type EntrypointsByType

type EntrypointsByType struct {
	CONSTRUCTOR []Handler `json:"CONSTRUCTOR"`
	EXTERNAL    []Handler `json:"EXTERNAL"`
	L1HANDLER   []Handler `json:"L1_HANDLER"`
}

EntrypointsByType -

type Error

type Error struct {
	Code    int64              `json:"code"`
	Message string             `json:"message"`
	Data    stdJSON.RawMessage `json:"data"`
}

Error -

type Event

type Event struct {
	Order           uint64   `json:"order"`
	FromAddress     string   `json:"from_address"`
	Keys            []string `json:"keys"`
	Data            []string `json:"data"`
	BlockHash       string   `json:"block_hash"`
	BlockNumber     uint64   `json:"block_number"`
	TransactionHash string   `json:"transaction_hash"`
}

Event -

type Felt

type Felt string

Felt -

func NewFeltFromBytes

func NewFeltFromBytes(hash []byte) Felt

NewFeltFromBytes -

func NewFromAsciiString

func NewFromAsciiString(s string) Felt

NewFromAsciiString -

func (Felt) Bytes

func (f Felt) Bytes() []byte

Bytes -

func (Felt) Decimal

func (f Felt) Decimal() decimal.Decimal

Decimal -

func (Felt) Length

func (f Felt) Length() int

Length -

func (Felt) String

func (f Felt) String() string

String -

func (Felt) ToAsciiString

func (f Felt) ToAsciiString() string

ToAsciiString -

func (Felt) Uint64

func (f Felt) Uint64() (uint64, error)

Uint64 -

type Handler

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

Handler -

type Invoke

type Invoke struct {
	MaxFee             Felt     `json:"max_fee"`
	Nonce              Felt     `json:"nonce"`
	ContractAddress    Felt     `json:"contract_address"`
	EntrypointSelector Felt     `json:"entry_point_selector"`
	SenderAddress      Felt     `json:"sender_address"`
	Signature          []string `json:"signature"`
	Calldata           []string `json:"calldata"`
}

Invoke -

type KeyValue

type KeyValue struct {
	Key   Felt `json:"key"`
	Value Felt `json:"value"`
}

KeyValue -

type L1Handler

type L1Handler struct {
	Nonce              Felt     `json:"nonce"`
	ContractAddress    Felt     `json:"contract_address"`
	EntrypointSelector Felt     `json:"entry_point_selector"`
	Calldata           []string `json:"calldata"`
}

L1Handler -

type Message

type Message struct {
	Order       uint64   `json:"order"`
	FromAddress string   `json:"from_address"`
	ToAddress   string   `json:"to_address"`
	Selector    Felt     `json:"selector"`
	Payload     []string `json:"payload"`
	Nonce       Felt     `json:"nonce"`
}

Message -

type Nonce

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

Nonce -

type StateDiff

type StateDiff struct {
	StorageDiffs      map[Felt][]KeyValue `json:"storage_diffs"`
	DeclaredContracts []Felt              `json:"declared_contracts"`
	DeployedContracts []DeployedContract  `json:"deployed_contracts"`
	Nonces            map[Felt]Felt       `json:"nonces"`
}

StateDiff -

type StateUpdate

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

StateUpdate -

type StorageDiff

type StorageDiff struct {
	Address        Felt       `json:"address"`
	StorageEntries []KeyValue `json:"storage_entries"`
}

StorageDiff -

type Transaction

type Transaction struct {
	Type            string `json:"type"`
	Version         Felt   `json:"version"`
	TransactionHash Felt   `json:"transaction_hash,omitempty"`

	Body any `json:"-"`
}

Transaction -

func (*Transaction) MarshalJSON

func (t *Transaction) MarshalJSON() ([]byte, error)

MarshalJSON -

func (*Transaction) UnmarshalJSON

func (t *Transaction) UnmarshalJSON(raw []byte) error

UnmarshalJSON -

type TransactionType

type TransactionType string

TransactionType -

type Uint256

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

Uint256 -

func NewUint256

func NewUint256(low, high Felt) Uint256

NewUint256 -

func NewUint256FromInt

func NewUint256FromInt(value int) Uint256

NewUint256FromInt -

func NewUint256FromString

func NewUint256FromString(value string) (Uint256, error)

NewUint256FromString -

func NewUint256FromStrings

func NewUint256FromStrings(low, high string) Uint256

NewUint256FromStrings -

func (Uint256) Calldata

func (uint256 Uint256) Calldata() []string

Calldata -

func (Uint256) Decimal

func (uint256 Uint256) Decimal() (decimal.Decimal, error)

Decimal -

func (Uint256) String

func (uint256 Uint256) String() string

String -

Jump to

Keyboard shortcuts

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