Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

graphql: add support for tx types and tx access lists #22491

Merged
merged 7 commits into from
Apr 6, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions graphql/graphql.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,20 @@ func (l *Log) Data(ctx context.Context) hexutil.Bytes {
return l.log.Data
}

// Access Tuple represents EIP-2930
AmitBRD marked this conversation as resolved.
Show resolved Hide resolved
type AccessTuple struct {
address common.Address
storageKeys *[]common.Hash
}
AmitBRD marked this conversation as resolved.
Show resolved Hide resolved

func (at *AccessTuple) Address(ctx context.Context) common.Address {
return at.address
}

func (at *AccessTuple) StorageKeys(ctx context.Context) *[]common.Hash {
return at.storageKeys
}

// Transaction represents an Ethereum transaction.
// backend and hash are mandatory; all others will be fetched when required.
type Transaction struct {
Expand Down Expand Up @@ -342,6 +356,31 @@ func (t *Transaction) Logs(ctx context.Context) (*[]*Log, error) {
return &ret, nil
}

func (t *Transaction) Type(ctx context.Context) (*int32, error) {
tx, err := t.resolve(ctx)
if err != nil {
return nil, err
}
txType := int32(tx.Type())
return &txType, nil
}

func (t *Transaction) AccessList(ctx context.Context) (*[]*AccessTuple, error) {
tx, err := t.resolve(ctx)
if err != nil || tx == nil {
return nil, err
}
accessList := tx.AccessList()
fjl marked this conversation as resolved.
Show resolved Hide resolved
ret := make([]*AccessTuple, 0, len(accessList))
for _, al := range accessList {
ret = append(ret, &AccessTuple{
address: al.Address,
storageKeys: &al.StorageKeys,
})
}
return &ret, nil
}

func (t *Transaction) R(ctx context.Context) (hexutil.Big, error) {
tx, err := t.resolve(ctx)
if err != nil || tx == nil {
Expand Down
9 changes: 9 additions & 0 deletions graphql/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ const schema string = `
transaction: Transaction!
}

#EIP-2718
type AccessTuple{
address: Address!
storageKeys : [Bytes32!]
}

# Transaction is an Ethereum transaction.
type Transaction {
# Hash is the hash of this transaction.
Expand Down Expand Up @@ -118,6 +124,9 @@ const schema string = `
r: BigInt!
s: BigInt!
v: BigInt!
#Envelope transaction support
type: Int
accessList: [AccessTuple!]
}

# BlockFilterCriteria encapsulates log filter criteria for a filter applied
Expand Down