Skip to content

Commit 402caac

Browse files
committed
EIP7702 update
1 parent b98cb72 commit 402caac

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed

examples/eip7702.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
## NOTE : not all hypersync sources have this data, if no data returned and you're expecting it to - please let the team know in discord.
2+
3+
import hypersync
4+
import asyncio
5+
from hypersync import BlockField, JoinMode, TransactionField, LogField, ClientConfig
6+
7+
async def main():
8+
client = hypersync.HypersyncClient(ClientConfig())
9+
10+
# The query to run
11+
query = hypersync.Query(
12+
# only get block 20224332
13+
from_block=22490287,
14+
to_block=22490287,
15+
include_all_blocks=True,
16+
join_mode=JoinMode.JOIN_ALL,
17+
field_selection=hypersync.FieldSelection(
18+
block=[BlockField.NUMBER, BlockField.TIMESTAMP, BlockField.HASH],
19+
transaction=[
20+
TransactionField.HASH,
21+
TransactionField.AUTHORIZATION_LIST,
22+
]
23+
),
24+
25+
)
26+
27+
print("Running the query...")
28+
29+
# Run the query once, the query is automatically paginated so it will return when it reaches some limit (time, response size etc.)
30+
# there is a next_block field on the response object so we can set the from_block of our query to this value and continue our query until
31+
# res.next_block is equal to res.archive_height or query.to_block in case we specified an end block.
32+
res = await client.get(query)
33+
34+
print(f"Ran the query once. Next block to query is {res.next_block}")
35+
36+
print(len(res.data.blocks))
37+
print(len(res.data.transactions))
38+
39+
for transaction in res.data.transactions:
40+
print(transaction.authorization_list)
41+
42+
print(len(res.data.logs))
43+
44+
asyncio.run(main())

hypersync/__init__.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,25 @@ class AccessList(object):
3131
storage_keys: Optional[list[str]]
3232

3333

34+
class Authorization(object):
35+
"""Evm authorization object
36+
37+
See ethereum rpc spec for the meaning of fields
38+
"""
39+
# uint256
40+
chain_id: Optional[str]
41+
# 20-byte hex
42+
address: Optional[str]
43+
# uint64
44+
nonce: Optional[int]
45+
# 0 | 1
46+
y_parity: Optional[int]
47+
# 32-byte hex
48+
r: Optional[str]
49+
# 32-byte hex
50+
s: Optional[str]
51+
52+
3453
class Transaction(object):
3554
block_hash: Optional[str]
3655
block_number: Optional[int]
@@ -51,6 +70,7 @@ class Transaction(object):
5170
max_fee_per_gas: Optional[str]
5271
chain_id: Optional[int]
5372
access_list: Optional[list[AccessList]]
73+
authorization_list: Optional[list[Authorization]]
5474
max_fee_per_blob_gas: Optional[str]
5575
blob_versioned_hashes: Optional[list[str]]
5676
cumulative_gas_used: Optional[str]
@@ -369,6 +389,9 @@ class TransactionField(StrEnum):
369389
# and `accessed_storage_keys` global sets (introduced in EIP-2929).
370390
# A gas cost is charged, though at a discount relative to the cost of accessing outside the list.
371391
ACCESS_LIST = "access_list"
392+
# The authorization list specifies a list of addresses and their associated authorization data
393+
# for EIP-3074 transactions.
394+
AUTHORIZATION_LIST = "authorization_list"
372395
# Max fee per data gas aka BlobFeeCap or blobGasFeeCap
373396
MAX_FEE_PER_BLOB_GAS = "max_fee_per_blob_gas"
374397
# It contains a list of fixed size hash(32 bytes)
@@ -518,6 +541,15 @@ class LogSelection:
518541
topics: Optional[list[list[str]]] = None
519542

520543

544+
@dataclass
545+
class AuthorizationSelection:
546+
"""Selection criteria for authorization list filtering."""
547+
# List of chain ids to match in the transaction authorizationList
548+
chain_id: Optional[list[int]] = None
549+
# List of addresses to match in the transaction authorizationList
550+
address: Optional[list[str]] = None
551+
552+
521553
@dataclass
522554
class TransactionSelection:
523555
# Address the transaction should originate from. If transaction.from matches any of these, the transaction
@@ -539,6 +571,8 @@ class TransactionSelection:
539571
# If transaction.hash matches any of these values the transaction will be returned.
540572
# empty means match all.
541573
hash: Optional[list[str]] = None
574+
# If transaction.authorization_list matches any of these values, the transaction will be returned.
575+
authorization_list: Optional[list[AuthorizationSelection]] = None
542576

543577

544578
@dataclass

0 commit comments

Comments
 (0)