Skip to content

Commit b61a8aa

Browse files
authored
Merge pull request #3099 from opentensor/fix/thewhaleking/add-patched-process-method
Adds temporary patch for scalecodec
2 parents e565517 + ba92a10 commit b61a8aa

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

bittensor/__init__.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from .core.settings import __version__, version_split, DEFAULTS, DEFAULT_NETWORK
44
from .utils.btlogging import logging
55
from .utils.easy_imports import *
6+
import scalecodec.types
67

78

89
def __getattr__(name):
@@ -13,3 +14,21 @@ def __getattr__(name):
1314
)
1415
return version_split
1516
raise AttributeError(f"module {__name__} has no attribute {name}")
17+
18+
19+
# the following patches the `scalecodec.types.Option.process` that allows for decoding certain extrinsics (specifically
20+
# the ones used by crowdloan using Option<scale_info::227>. There is a PR up for this: https://github.com/JAMdotTech/py-scale-codec/pull/134
21+
# and this patch will be removed when this is applied/released.
22+
23+
24+
def patched_process(self):
25+
option_byte = self.get_next_bytes(1)
26+
27+
if self.sub_type and option_byte != b"\x00":
28+
self.value_object = self.process_type(self.sub_type, metadata=self.metadata)
29+
return self.value_object.value
30+
31+
return None
32+
33+
34+
scalecodec.types.Option.process = patched_process

0 commit comments

Comments
 (0)