From c06aa32da4a371d756a6b268407315c40ae36736 Mon Sep 17 00:00:00 2001 From: bdhimes Date: Wed, 15 Oct 2025 22:58:29 +0200 Subject: [PATCH 1/2] Adds temporary patch for scalecodec --- bittensor/__init__.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/bittensor/__init__.py b/bittensor/__init__.py index 57b009ece9..561d6afdee 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,20 @@ 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 From d8fc624fbf3cde823b9ab28d7be691dc6c672d07 Mon Sep 17 00:00:00 2001 From: bdhimes Date: Wed, 15 Oct 2025 23:00:21 +0200 Subject: [PATCH 2/2] Ruff --- bittensor/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bittensor/__init__.py b/bittensor/__init__.py index 561d6afdee..117aad5c4c 100644 --- a/bittensor/__init__.py +++ b/bittensor/__init__.py @@ -20,14 +20,15 @@ def __getattr__(name): # 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): +def patched_process(self): option_byte = self.get_next_bytes(1) - if self.sub_type and option_byte != b'\x00': + 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