graphql: add support for tx types and tx access lists (#22491)
This adds support for EIP-2718 access list transactions in the GraphQL API. Co-authored-by: Amit Shah <amitshah0t7@gmail.com> Co-authored-by: Felix Lange <fjl@twurst.com>
This commit is contained in:
@ -151,6 +151,20 @@ func (l *Log) Data(ctx context.Context) hexutil.Bytes {
|
||||
return l.log.Data
|
||||
}
|
||||
|
||||
// AccessTuple represents EIP-2930
|
||||
type AccessTuple struct {
|
||||
address common.Address
|
||||
storageKeys *[]common.Hash
|
||||
}
|
||||
|
||||
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 {
|
||||
@ -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()
|
||||
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 {
|
||||
|
Reference in New Issue
Block a user