data

package
v0.0.0-...-592465a Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2024 License: MIT Imports: 13 Imported by: 7

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"
	Version3 = "0x3"
)

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"
	StatusReverted     = "REVERTED"
)

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

View Source
var ErrInvalidDAMode = errors.New("not a valid DAMode")

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"`
	ClassVersion      string             `json:"contract_class_version"`
	Abi               abi.Abi            `json:"-"`
	RawAbi            stdJSON.RawMessage `json:"abi"`
}

Class -

func (*Class) GetAbi

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

GetAbi -

type DAMode

type DAMode string

swagger:enum DAMode

ENUM(
	L1,
	L2
)
const (
	// DAModeL1 is a DAMode of type L1.
	DAModeL1 DAMode = "L1"
	// DAModeL2 is a DAMode of type L2.
	DAModeL2 DAMode = "L2"
)

func DAModeValues

func DAModeValues() []DAMode

DAModeValues returns a list of the values for DAMode

func ParseDAMode

func ParseDAMode(name string) (DAMode, error)

ParseDAMode attempts to convert a string to a DAMode.

func (DAMode) IsValid

func (x DAMode) IsValid() bool

IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values

func (DAMode) MarshalText

func (x DAMode) MarshalText() ([]byte, error)

MarshalText implements the text marshaller method.

func (*DAMode) Scan

func (x *DAMode) Scan(value interface{}) (err error)

Scan implements the Scanner interface.

func (DAMode) String

func (x DAMode) String() string

String implements the Stringer interface.

func (*DAMode) UnmarshalJSON

func (x *DAMode) UnmarshalJSON(text []byte) error

func (*DAMode) UnmarshalText

func (x *DAMode) UnmarshalText(text []byte) error

UnmarshalText implements the text unmarshaller method.

func (DAMode) Value

func (x DAMode) Value() (driver.Value, error)

Value implements the driver Valuer interface.

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"`
	CompiledClassHash         Felt     `json:"compiled_class_hash,omitempty"`
	AccountDeploymentData     []Felt   `json:"account_deployment_data"`
	ChainId                   Felt     `json:"chain_id"`
	FeeDataAvailabilityMode   DAMode   `json:"fee_data_availability_mode"`
	NonceDataAvailabilityMode DAMode   `json:"nonce_data_availability_mode"`
	PayMasterData             []Felt   `json:"paymaster_data"`
	Tip                       Felt     `json:"tip"`
}

Declare -

type DeclaredClass

type DeclaredClass struct {
	ClassHash         Felt `json:"class_hash"`
	CompiledClassHash Felt `json:"compiled_class_hash"`
}

DeclaredClass -

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"`
	ChainId                   Felt     `json:"chain_id"`
	FeeDataAvailabilityMode   DAMode   `json:"fee_data_availability_mode"`
	NonceDataAvailabilityMode DAMode   `json:"nonce_data_availability_mode"`
	PayMasterData             []Felt   `json:"paymaster_data"`
	Tip                       Felt     `json:"tip"`
}

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 Event

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

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      uint64 `json:"-"`
	FunctionIdx uint64 `json:"function_idx,omitempty"`
	Selector    string `json:"selector"`
}

Handler -

func (*Handler) UnmarshalJSON

func (h *Handler) UnmarshalJSON(data []byte) error

UnmarshalJSON -

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"`
	ChainId                   Felt            `json:"chain_id"`
	FeeDataAvailabilityMode   DAMode          `json:"fee_data_availability_mode"`
	NonceDataAvailabilityMode DAMode          `json:"nonce_data_availability_mode"`
	ResourceBounds            *ResourceBounds `json:"resource_bounds,omitempty"`
	Tip                       Felt            `json:"tip"`
	Signature                 []string        `json:"signature"`
	Calldata                  []string        `json:"calldata"`
	AccountDeploymentData     []Felt          `json:"account_deployment_data"`
	PayMasterData             []Felt          `json:"paymaster_data"`
}

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     []Felt `json:"payload"`
	Nonce       Felt   `json:"nonce"`
}

Message -

type Nonce

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

Nonce -

type ReplacedClass

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

type ReplacedClassRpc

type ReplacedClassRpc struct {
	Address   Felt `json:"contract_address"`
	ClassHash Felt `json:"class_hash"`
}

type ResourceBound

type ResourceBound struct {
	MaxAmount       Felt `json:"max_amount"`
	MaxPricePerUnit Felt `json:"max_price_per_unit"`
}

type ResourceBounds

type ResourceBounds struct {
	L1Gas ResourceBound `json:"L1_GAS"`
	L2Gas ResourceBound `json:"L2_GAS"`
}

type StateDiff

type StateDiff struct {
	StorageDiffs         map[Felt][]KeyValue `json:"storage_diffs"`
	DeclaredClasses      []DeclaredClass     `json:"declared_classes"`
	ReplacedClasses      []ReplacedClass     `json:"replaced_classes"`
	OldDeclaredContracts []Felt              `json:"old_declared_contracts"`
	DeployedContracts    []DeployedContract  `json:"deployed_contracts"`
	Nonces               map[Felt]Felt       `json:"nonces"`
}

StateDiff -

type StateDiffRpc

type StateDiffRpc struct {
	DeclaredClasses           []DeclaredClass    `json:"declared_classes"`
	DeprecatedDeclaredClasses []Felt             `json:"deprecated_declared_classes"`
	ReplacedClasses           []ReplacedClassRpc `json:"replaced_classes"`
	DeclaredContractHashes    []Felt             `json:"declared_contract_hashes"`
	DeployedContracts         []DeployedContract `json:"deployed_contracts"`
	Nonces                    []Nonce            `json:"nonces"`
	StorageDiffs              []StorageDiff      `json:"storage_diffs"`
}

StateDiffRpc -

func (StateDiffRpc) ToStateDiff

func (sdr StateDiffRpc) ToStateDiff() StateDiff

ToStateDiff -

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 StateUpdateRpc

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

StateUpdateRpc -

func (StateUpdateRpc) ToStateUpdate

func (sur StateUpdateRpc) ToStateUpdate() StateUpdate

ToStateUpdate -

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 {
	Low  Felt `json:"low"`
	High Felt `json:"high"`
}

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