Skip to content

Commit 7f79cbf

Browse files
committed
Add get_transaction_receipt method to Chain API
1 parent e3e4d1f commit 7f79cbf

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

eth/chains/base.py

+15
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,10 @@ def create_unsigned_transaction(cls,
272272
def get_canonical_transaction(self, transaction_hash: Hash32) -> BaseTransaction:
273273
raise NotImplementedError("Chain classes must implement this method")
274274

275+
@abstractmethod
276+
def get_transaction_receipt(self, transaction_hash: Hash32) -> Receipt:
277+
raise NotImplementedError("Chain classes must implement this method")
278+
275279
#
276280
# Execution API
277281
#
@@ -653,6 +657,17 @@ def create_unsigned_transaction(self,
653657
data=data,
654658
)
655659

660+
def get_transaction_receipt(self, transaction_hash: Hash32) -> Receipt:
661+
transaction_block_number, transaction_index = self.chaindb.get_transaction_index(
662+
transaction_hash,
663+
)
664+
receipt = self.chaindb.get_receipt_by_index(
665+
block_number=transaction_block_number,
666+
receipt_index=transaction_index,
667+
)
668+
669+
return receipt
670+
656671
#
657672
# Execution API
658673
#

eth/db/chain.py

+6
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@ def get_block_transactions(
125125
def get_block_transaction_hashes(self, block_header: BlockHeader) -> Iterable[Hash32]:
126126
raise NotImplementedError("ChainDB classes must implement this method")
127127

128+
@abstractmethod
129+
def get_receipt_by_index(self,
130+
block_number: BlockNumber,
131+
receipt_index: int) -> Receipt:
132+
raise NotImplementedError("ChainDB classes must implement this method")
133+
128134
@abstractmethod
129135
def get_receipts(self,
130136
header: BlockHeader,

0 commit comments

Comments
 (0)