Documentation
¶
Index ¶
Constants ¶
const AddressLength = 20
AddressLength is the expected length of the address.
const HashLength = 32
HashLength is the expected length of the hash.
Variables ¶
var ErrNotFound = errors.New("not found")
ErrNotFound is returned when a requested resource (block, receipt, ...) does not exist on the remote endpoint. Replaces ethereum.NotFound.
Functions ¶
This section is empty.
Types ¶
type Address ¶
type Address [AddressLength]byte
Address represents the 20 byte address of an Ethereum account.
func AddressFromBytes ¶
AddressFromBytes returns Address with value b. If b is larger than AddressLength, b will be cropped from the left.
func AddressFromString ¶
AddressFromString returns Address with byte values parsed from s. The 0x prefix is optional; if s is larger than 2*AddressLength hex chars, it will be cropped from the left.
func (Address) MarshalText ¶
MarshalText returns the hex representation of a (0x-prefixed lowercase). Mirrors go-ethereum's common.Address.MarshalText.
func (*Address) SetBytes ¶
SetBytes sets the address to the value of b. If b is larger than AddressLength, b will be cropped from the left; if shorter, left-padded with zeros. TODO: Once migrated, panic/error if b is larger than address
func (*Address) UnmarshalJSON ¶
UnmarshalJSON parses an address from a JSON string. Matches go-ethereum's common.Address.UnmarshalJSON: requires a quoted "0x"-prefixed hex string of exactly AddressLength bytes; case-insensitive.
func (*Address) UnmarshalText ¶
UnmarshalText parses an address from its hex representation. Matches go-ethereum's common.Address.UnmarshalText: requires "0x"-prefixed hex of exactly AddressLength bytes; case-insensitive.
type DataBytes ¶
type DataBytes []byte
DataBytes is a []byte that JSON-decodes from a 0x-prefixed hex string, matching the Ethereum JSON-RPC "data" wire format. An empty payload ("0x") is allowed. Unbounded — log/call data is capped by the L1 block gas limit (~3.75Mb at 30M max block gas)
func (*DataBytes) UnmarshalJSON ¶
type Hash ¶
type Hash [HashLength]byte
Hash represents the 32 byte Keccak256 hash of arbitrary data.
func HashFromBytes ¶
HashFromBytes returns Hash with value b. If b is larger than HashLength, b will be cropped from the left.
func HashFromString ¶
HashFromString returns Hash with byte values parsed from s. The 0x prefix is optional; if s is larger than 2*HashLength hex chars, it will be cropped from the left.
func (Hash) MarshalText ¶
MarshalText returns the hex representation of h (0x-prefixed lowercase). Mirrors go-ethereum's common.Hash.MarshalText.
func (*Hash) SetBytes ¶
SetBytes sets the hash to the value of b. If b is larger than HashLength, b will be cropped from the left; if shorter, left-padded with zeros. TODO: Once migrated, panic/error if b is larger than hash
func (*Hash) UnmarshalJSON ¶
UnmarshalJSON parses a hash from a JSON string. Matches go-ethereum's common.Hash.UnmarshalJSON: requires a quoted "0x"-prefixed hex string of exactly HashLength bytes; case-insensitive.
func (*Hash) UnmarshalText ¶
UnmarshalText parses a hash from its hex representation. Matches go-ethereum's common.Hash.UnmarshalText: requires "0x"-prefixed hex of exactly HashLength bytes; case-insensitive.
type Header ¶
type Header struct {
Number HexU64 `json:"number"`
}
Header is the trimmed-down view of an Ethereum block header that juno needs. Only Number is read in production (l1/eth_subscriber.go). The HexU64 field type lets eth_getBlockByNumber responses unmarshal directly without any per-struct codec boilerplate.
type HexU64 ¶
type HexU64 uint64
HexU64 is a uint64 that JSON-decodes from a 0x-prefixed hex string, matching the Ethereum JSON-RPC "quantity" wire format. Used as a field type on structs that consume RPC responses (Header, Log).
func (*HexU64) UnmarshalJSON ¶
type Log ¶
type Log struct {
Topics []Hash `json:"topics"`
Data DataBytes `json:"data"`
BlockNumber HexU64 `json:"blockNumber"`
Removed bool `json:"removed"`
}
Log represents a contract log event as juno consumes it. Only the fields actually read today are declared; other fields in an eth_getLogs response are silently dropped during unmarshal.
type Receipt ¶
type Receipt struct {
Logs []Log `json:"logs"`
}
Receipt is the trimmed-down view of an Ethereum transaction receipt. Only Logs is read in juno. All other fields in the eth_getTransactionReceipt JSON response are ignored.
type Subscription ¶
type Subscription interface {
Err() <-chan error
Unsubscribe()
}
Subscription mirrors go-ethereum's event.Subscription surface as consumed by juno's l1 package: a channel signalling failure, and an Unsubscribe method to release resources.