Skip to content

Commit

Permalink
Merge pull request #136 from davesque/custom-stream-class
Browse files Browse the repository at this point in the history
Add ABIDecoder.stream_class property
  • Loading branch information
davesque committed Dec 10, 2019
2 parents e043f73 + 6b6137a commit 610f38a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions eth_abi/codec.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ class ABIDecoder(BaseABICoder):
"""
Wraps a registry to provide last-mile decoding functionality.
"""
stream_class = ContextFramesBytesIO

def decode_single(self, typ: TypeStr, data: Decodable) -> Any:
"""
Decodes the binary value ``data`` of the ABI type ``typ`` into its
Expand All @@ -148,7 +150,7 @@ def decode_single(self, typ: TypeStr, data: Decodable) -> Any:
raise TypeError("The `data` value must be of bytes type. Got {0}".format(type(data)))

decoder = self._registry.get_decoder(typ)
stream = ContextFramesBytesIO(data)
stream = self.stream_class(data)

return decoder(stream)

Expand All @@ -174,7 +176,7 @@ def decode_abi(self, types: Iterable[TypeStr], data: Decodable) -> Tuple[Any, ..
]

decoder = TupleDecoder(decoders=decoders)
stream = ContextFramesBytesIO(data)
stream = self.stream_class(data)

return decoder(stream)

Expand Down

0 comments on commit 610f38a

Please sign in to comment.