diff --git a/bittensor/__init__.py b/bittensor/__init__.py index 57b009ece9..117aad5c4c 100644 --- a/bittensor/__init__.py +++ b/bittensor/__init__.py @@ -3,6 +3,7 @@ from .core.settings import __version__, version_split, DEFAULTS, DEFAULT_NETWORK from .utils.btlogging import logging from .utils.easy_imports import * +import scalecodec.types def __getattr__(name): @@ -13,3 +14,21 @@ def __getattr__(name): ) return version_split raise AttributeError(f"module {__name__} has no attribute {name}") + + +# the following patches the `scalecodec.types.Option.process` that allows for decoding certain extrinsics (specifically +# the ones used by crowdloan using Option. There is a PR up for this: https://github.com/JAMdotTech/py-scale-codec/pull/134 +# and this patch will be removed when this is applied/released. + + +def patched_process(self): + option_byte = self.get_next_bytes(1) + + if self.sub_type and option_byte != b"\x00": + self.value_object = self.process_type(self.sub_type, metadata=self.metadata) + return self.value_object.value + + return None + + +scalecodec.types.Option.process = patched_process