graphql

package
v0.0.0-...-e3af8be Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: GPL-3.0 Imports: 26 Imported by: 0

Documentation

Overview

Package graphql provides a GraphQL interface to Ethereum node data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(stack *node.Node, backend ethapi.Backend, filterSystem *filters.FilterSystem, cors, vhosts []string) error

New constructs a new GraphQL service instance.

Types

type AccessTuple

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

AccessTuple represents EIP-2930

func (*AccessTuple) Address

func (at *AccessTuple) Address(ctx context.Context) common.Address

func (*AccessTuple) StorageKeys

func (at *AccessTuple) StorageKeys(ctx context.Context) []common.Hash

type Account

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

Account represents an Ethereum account at a particular block.

func (*Account) Address

func (a *Account) Address(ctx context.Context) (common.Address, error)

func (*Account) Balance

func (a *Account) Balance(ctx context.Context) (hexutil.Big, error)

func (*Account) Code

func (a *Account) Code(ctx context.Context) (hexutil.Bytes, error)

func (*Account) Storage

func (a *Account) Storage(ctx context.Context, args struct{ Slot common.Hash }) (common.Hash, error)

func (*Account) TransactionCount

func (a *Account) TransactionCount(ctx context.Context) (hexutil.Uint64, error)

type Block

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

Block represents an Ethereum block. backend, and numberOrHash are mandatory. All other fields are lazily fetched when required.

func (*Block) Account

func (b *Block) Account(ctx context.Context, args struct {
	Address common.Address
}) (*Account, error)

func (*Block) BaseFeePerGas

func (b *Block) BaseFeePerGas(ctx context.Context) (*hexutil.Big, error)

func (*Block) Call

func (b *Block) Call(ctx context.Context, args struct {
	Data ethapi.TransactionArgs
}) (*CallResult, error)

func (*Block) Difficulty

func (b *Block) Difficulty(ctx context.Context) (hexutil.Big, error)

func (*Block) EstimateGas

func (b *Block) EstimateGas(ctx context.Context, args struct {
	Data ethapi.TransactionArgs
}) (Long, error)

func (*Block) ExtraData

func (b *Block) ExtraData(ctx context.Context) (hexutil.Bytes, error)

func (*Block) GasLimit

func (b *Block) GasLimit(ctx context.Context) (Long, error)

func (*Block) GasUsed

func (b *Block) GasUsed(ctx context.Context) (Long, error)

func (*Block) Hash

func (b *Block) Hash(ctx context.Context) (common.Hash, error)

func (*Block) Logs

func (b *Block) Logs(ctx context.Context, args struct{ Filter BlockFilterCriteria }) ([]*Log, error)

func (*Block) LogsBloom

func (b *Block) LogsBloom(ctx context.Context) (hexutil.Bytes, error)

func (*Block) Miner

func (b *Block) Miner(ctx context.Context, args BlockNumberArgs) (*Account, error)

func (*Block) MixHash

func (b *Block) MixHash(ctx context.Context) (common.Hash, error)

func (*Block) NextBaseFeePerGas

func (b *Block) NextBaseFeePerGas(ctx context.Context) (*hexutil.Big, error)

func (*Block) Nonce

func (b *Block) Nonce(ctx context.Context) (hexutil.Bytes, error)

func (*Block) Number

func (b *Block) Number(ctx context.Context) (Long, error)

func (*Block) OmmerAt

func (b *Block) OmmerAt(ctx context.Context, args struct{ Index int32 }) (*Block, error)

func (*Block) OmmerCount

func (b *Block) OmmerCount(ctx context.Context) (*int32, error)

func (*Block) OmmerHash

func (b *Block) OmmerHash(ctx context.Context) (common.Hash, error)

func (*Block) Ommers

func (b *Block) Ommers(ctx context.Context) (*[]*Block, error)

func (*Block) Parent

func (b *Block) Parent(ctx context.Context) (*Block, error)

func (*Block) Raw

func (b *Block) Raw(ctx context.Context) (hexutil.Bytes, error)

func (*Block) RawHeader

func (b *Block) RawHeader(ctx context.Context) (hexutil.Bytes, error)

func (*Block) ReceiptsRoot

func (b *Block) ReceiptsRoot(ctx context.Context) (common.Hash, error)

func (*Block) StateRoot

func (b *Block) StateRoot(ctx context.Context) (common.Hash, error)

func (*Block) Timestamp

func (b *Block) Timestamp(ctx context.Context) (hexutil.Uint64, error)

func (*Block) TotalDifficulty

func (b *Block) TotalDifficulty(ctx context.Context) (hexutil.Big, error)

func (*Block) TransactionAt

func (b *Block) TransactionAt(ctx context.Context, args struct{ Index int32 }) (*Transaction, error)

func (*Block) TransactionCount

func (b *Block) TransactionCount(ctx context.Context) (*int32, error)

func (*Block) Transactions

func (b *Block) Transactions(ctx context.Context) (*[]*Transaction, error)

func (*Block) TransactionsRoot

func (b *Block) TransactionsRoot(ctx context.Context) (common.Hash, error)

type BlockFilterCriteria

type BlockFilterCriteria struct {
	Addresses *[]common.Address // restricts matches to events created by specific contracts

	// The Topic list restricts matches to particular event topics. Each event has a list
	// of topics. Topics matches a prefix of that list. An empty element slice matches any
	// topic. Non-empty elements represent an alternative that matches any of the
	// contained topics.
	//
	// Examples:
	// {} or nil          matches any topic list
	// {{A}}              matches topic A in first position
	// {{}, {B}}          matches any topic in first position, B in second position
	// {{A}, {B}}         matches topic A in first position, B in second position
	// {{A, B}}, {C, D}}  matches topic (A OR B) in first position, (C OR D) in second position
	Topics *[][]common.Hash
}

BlockFilterCriteria encapsulates criteria passed to a `logs` accessor inside a block.

type BlockNumberArgs

type BlockNumberArgs struct {
	// TODO: Ideally we could use input unions to allow the query to specify the
	// block parameter by hash, block number, or tag but input unions aren't part of the
	// standard GraphQL schema SDL yet, see: https://github.com/graphql/graphql-spec/issues/488
	Block *hexutil.Uint64
}

BlockNumberArgs encapsulates arguments to accessors that specify a block number.

func (BlockNumberArgs) NumberOr

NumberOr returns the provided block number argument, or the "current" block number or hash if none was provided.

func (BlockNumberArgs) NumberOrLatest

func (a BlockNumberArgs) NumberOrLatest() rpc.BlockNumberOrHash

NumberOrLatest returns the provided block number argument, or the "latest" block number if none was provided.

type BlockType

type BlockType int

type CallData

type CallData struct {
	From                 *common.Address // The Ethereum address the call is from.
	To                   *common.Address // The Ethereum address the call is to.
	Gas                  *hexutil.Uint64 // The amount of gas provided for the call.
	GasPrice             *hexutil.Big    // The price of each unit of gas, in wei.
	MaxFeePerGas         *hexutil.Big    // The max price of each unit of gas, in wei (1559).
	MaxPriorityFeePerGas *hexutil.Big    // The max tip of each unit of gas, in wei (1559).
	Value                *hexutil.Big    // The value sent along with the call.
	Data                 *hexutil.Bytes  // Any data sent with the call.
}

CallData encapsulates arguments to `call` or `estimateGas`. All arguments are optional.

type CallResult

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

CallResult encapsulates the result of an invocation of the `call` accessor.

func (*CallResult) Data

func (c *CallResult) Data() hexutil.Bytes

func (*CallResult) GasUsed

func (c *CallResult) GasUsed() Long

func (*CallResult) Status

func (c *CallResult) Status() Long

type FilterCriteria

type FilterCriteria struct {
	FromBlock *hexutil.Uint64   // beginning of the queried range, nil means genesis block
	ToBlock   *hexutil.Uint64   // end of the range, nil means latest block
	Addresses *[]common.Address // restricts matches to events created by specific contracts

	// The Topic list restricts matches to particular event topics. Each event has a list
	// of topics. Topics matches a prefix of that list. An empty element slice matches any
	// topic. Non-empty elements represent an alternative that matches any of the
	// contained topics.
	//
	// Examples:
	// {} or nil          matches any topic list
	// {{A}}              matches topic A in first position
	// {{}, {B}}          matches any topic in first position, B in second position
	// {{A}, {B}}         matches topic A in first position, B in second position
	// {{A, B}}, {C, D}}  matches topic (A OR B) in first position, (C OR D) in second position
	Topics *[][]common.Hash
}

FilterCriteria encapsulates the arguments to `logs` on the root resolver object.

type GraphiQL

type GraphiQL struct{}

GraphiQL is an in-browser IDE for exploring GraphiQL APIs. This handler returns GraphiQL when requested.

For more information, see https://github.com/graphql/graphiql.

func (GraphiQL) ServeHTTP

func (h GraphiQL) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Log

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

Log represents an individual log message. All arguments are mandatory.

func (*Log) Account

func (l *Log) Account(ctx context.Context, args BlockNumberArgs) *Account

func (*Log) Data

func (l *Log) Data(ctx context.Context) hexutil.Bytes

func (*Log) Index

func (l *Log) Index(ctx context.Context) int32

func (*Log) Topics

func (l *Log) Topics(ctx context.Context) []common.Hash

func (*Log) Transaction

func (l *Log) Transaction(ctx context.Context) *Transaction

type Long

type Long int64

func (Long) ImplementsGraphQLType

func (b Long) ImplementsGraphQLType(name string) bool

ImplementsGraphQLType returns true if Long implements the provided GraphQL type.

func (*Long) UnmarshalGraphQL

func (b *Long) UnmarshalGraphQL(input interface{}) error

UnmarshalGraphQL unmarshals the provided GraphQL query data.

type Pending

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

func (*Pending) Account

func (p *Pending) Account(ctx context.Context, args struct {
	Address common.Address
}) *Account

func (*Pending) Call

func (p *Pending) Call(ctx context.Context, args struct {
	Data ethapi.TransactionArgs
}) (*CallResult, error)

func (*Pending) EstimateGas

func (p *Pending) EstimateGas(ctx context.Context, args struct {
	Data ethapi.TransactionArgs
}) (Long, error)

func (*Pending) TransactionCount

func (p *Pending) TransactionCount(ctx context.Context) (int32, error)

func (*Pending) Transactions

func (p *Pending) Transactions(ctx context.Context) (*[]*Transaction, error)

type Resolver

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

Resolver is the top-level object in the GraphQL hierarchy.

func (*Resolver) Block

func (r *Resolver) Block(ctx context.Context, args struct {
	Number *Long
	Hash   *common.Hash
}) (*Block, error)

func (*Resolver) Blocks

func (r *Resolver) Blocks(ctx context.Context, args struct {
	From *Long
	To   *Long
}) ([]*Block, error)

func (*Resolver) ChainID

func (r *Resolver) ChainID(ctx context.Context) (hexutil.Big, error)

func (*Resolver) GasPrice

func (r *Resolver) GasPrice(ctx context.Context) (hexutil.Big, error)

func (*Resolver) Logs

func (r *Resolver) Logs(ctx context.Context, args struct{ Filter FilterCriteria }) ([]*Log, error)

func (*Resolver) MaxPriorityFeePerGas

func (r *Resolver) MaxPriorityFeePerGas(ctx context.Context) (hexutil.Big, error)

func (*Resolver) Pending

func (r *Resolver) Pending(ctx context.Context) *Pending

func (*Resolver) SendRawTransaction

func (r *Resolver) SendRawTransaction(ctx context.Context, args struct{ Data hexutil.Bytes }) (common.Hash, error)

func (*Resolver) Syncing

func (r *Resolver) Syncing() (*SyncState, error)

Syncing returns false in case the node is currently not syncing with the network. It can be up to date or has not yet received the latest block headers from its pears. In case it is synchronizing: - startingBlock: block number this node started to synchronise from - currentBlock: block number this node is currently importing - highestBlock: block number of the highest block header this node has received from peers - syncedAccounts: number of accounts downloaded - syncedAccountBytes: number of account trie bytes persisted to disk - syncedBytecodes: number of bytecodes downloaded - syncedBytecodeBytes: number of bytecode bytes downloaded - syncedStorage: number of storage slots downloaded - syncedStorageBytes: number of storage trie bytes persisted to disk - healedTrienodes: number of state trie nodes downloaded - healedTrienodeBytes: number of state trie bytes persisted to disk - healedBytecodes: number of bytecodes downloaded - healedBytecodeBytes: number of bytecodes persisted to disk - healingTrienodes: number of state trie nodes pending - healingBytecode: number of bytecodes pending

func (*Resolver) Transaction

func (r *Resolver) Transaction(ctx context.Context, args struct{ Hash common.Hash }) (*Transaction, error)

type SyncState

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

SyncState represents the synchronisation status returned from the `syncing` accessor.

func (*SyncState) CurrentBlock

func (s *SyncState) CurrentBlock() hexutil.Uint64

func (*SyncState) HealedBytecodeBytes

func (s *SyncState) HealedBytecodeBytes() hexutil.Uint64

func (*SyncState) HealedBytecodes

func (s *SyncState) HealedBytecodes() hexutil.Uint64

func (*SyncState) HealedTrienodeBytes

func (s *SyncState) HealedTrienodeBytes() hexutil.Uint64

func (*SyncState) HealedTrienodes

func (s *SyncState) HealedTrienodes() hexutil.Uint64

func (*SyncState) HealingBytecode

func (s *SyncState) HealingBytecode() hexutil.Uint64

func (*SyncState) HealingTrienodes

func (s *SyncState) HealingTrienodes() hexutil.Uint64

func (*SyncState) HighestBlock

func (s *SyncState) HighestBlock() hexutil.Uint64

func (*SyncState) StartingBlock

func (s *SyncState) StartingBlock() hexutil.Uint64

func (*SyncState) SyncedAccountBytes

func (s *SyncState) SyncedAccountBytes() hexutil.Uint64

func (*SyncState) SyncedAccounts

func (s *SyncState) SyncedAccounts() hexutil.Uint64

func (*SyncState) SyncedBytecodeBytes

func (s *SyncState) SyncedBytecodeBytes() hexutil.Uint64

func (*SyncState) SyncedBytecodes

func (s *SyncState) SyncedBytecodes() hexutil.Uint64

func (*SyncState) SyncedStorage

func (s *SyncState) SyncedStorage() hexutil.Uint64

func (*SyncState) SyncedStorageBytes

func (s *SyncState) SyncedStorageBytes() hexutil.Uint64

type Transaction

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

Transaction represents an Ethereum transaction. backend and hash are mandatory; all others will be fetched when required.

func (*Transaction) AccessList

func (t *Transaction) AccessList(ctx context.Context) (*[]*AccessTuple, error)

func (*Transaction) Block

func (t *Transaction) Block(ctx context.Context) (*Block, error)

func (*Transaction) CreatedContract

func (t *Transaction) CreatedContract(ctx context.Context, args BlockNumberArgs) (*Account, error)

func (*Transaction) CumulativeGasUsed

func (t *Transaction) CumulativeGasUsed(ctx context.Context) (*Long, error)

func (*Transaction) EffectiveGasPrice

func (t *Transaction) EffectiveGasPrice(ctx context.Context) (*hexutil.Big, error)

func (*Transaction) EffectiveTip

func (t *Transaction) EffectiveTip(ctx context.Context) (*hexutil.Big, error)

func (*Transaction) From

func (t *Transaction) From(ctx context.Context, args BlockNumberArgs) (*Account, error)

func (*Transaction) Gas

func (t *Transaction) Gas(ctx context.Context) (hexutil.Uint64, error)

func (*Transaction) GasPrice

func (t *Transaction) GasPrice(ctx context.Context) (hexutil.Big, error)

func (*Transaction) GasUsed

func (t *Transaction) GasUsed(ctx context.Context) (*Long, error)

func (*Transaction) Hash

func (t *Transaction) Hash(ctx context.Context) common.Hash

func (*Transaction) Index

func (t *Transaction) Index(ctx context.Context) (*int32, error)

func (*Transaction) InputData

func (t *Transaction) InputData(ctx context.Context) (hexutil.Bytes, error)

func (*Transaction) Logs

func (t *Transaction) Logs(ctx context.Context) (*[]*Log, error)

func (*Transaction) MaxFeePerGas

func (t *Transaction) MaxFeePerGas(ctx context.Context) (*hexutil.Big, error)

func (*Transaction) MaxPriorityFeePerGas

func (t *Transaction) MaxPriorityFeePerGas(ctx context.Context) (*hexutil.Big, error)

func (*Transaction) Nonce

func (t *Transaction) Nonce(ctx context.Context) (hexutil.Uint64, error)

func (*Transaction) R

func (t *Transaction) R(ctx context.Context) (hexutil.Big, error)

func (*Transaction) Raw

func (t *Transaction) Raw(ctx context.Context) (hexutil.Bytes, error)

func (*Transaction) RawReceipt

func (t *Transaction) RawReceipt(ctx context.Context) (hexutil.Bytes, error)

func (*Transaction) S

func (t *Transaction) S(ctx context.Context) (hexutil.Big, error)

func (*Transaction) Status

func (t *Transaction) Status(ctx context.Context) (*Long, error)

func (*Transaction) To

func (t *Transaction) To(ctx context.Context, args BlockNumberArgs) (*Account, error)

func (*Transaction) Type

func (t *Transaction) Type(ctx context.Context) (*int32, error)

func (*Transaction) V

func (t *Transaction) V(ctx context.Context) (hexutil.Big, error)

func (*Transaction) Value

func (t *Transaction) Value(ctx context.Context) (hexutil.Big, error)

Jump to

Keyboard shortcuts

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