18
18
import warnings
19
19
from datetime import datetime
20
20
from hashlib import blake2b
21
- from typing import Union
21
+ from typing import Union , Optional
22
22
23
23
from scalecodec .constants import TYPE_DECOMP_MAX_RECURSIVE
24
24
from scalecodec .utils .ss58 import ss58_decode_account_index , ss58_decode , ss58_encode , is_valid_ss58_address
@@ -2451,18 +2451,28 @@ def get_identifier(self):
2451
2451
return self .value ['name' ]
2452
2452
2453
2453
@property
2454
- def storage (self ):
2454
+ def storage (self ) -> Optional [list ]:
2455
+
2455
2456
storage_functions = self .value_object ['storage' ].value_object
2456
2457
2457
2458
if storage_functions :
2458
- return storage_functions .value_object ['entries' ].value_object
2459
+ pallet_version_sf = self .runtime_config .create_scale_object ("StorageEntryMetadataV13" )
2460
+ pallet_version_sf .encode ({
2461
+ 'name' : ':__STORAGE_VERSION__:' ,
2462
+ 'modifier' : 'Default' ,
2463
+ 'type' : {'Plain' : "u16" },
2464
+ 'default' : '0x0000' ,
2465
+ 'documentation' : ['Returns the current pallet version from storage' ]
2466
+ })
2467
+
2468
+ return [pallet_version_sf ] + storage_functions ['entries' ].elements
2459
2469
2460
2470
@property
2461
2471
def calls (self ):
2462
2472
return self .value_object ['calls' ].value_object
2463
2473
2464
2474
@property
2465
- def events (self ):
2475
+ def events (self ) -> Optional [ list ] :
2466
2476
events = self .value_object ['events' ].value_object
2467
2477
2468
2478
if events :
@@ -2477,10 +2487,13 @@ def errors(self):
2477
2487
return self .value_object ['errors' ].value_object
2478
2488
2479
2489
def get_storage_function (self , name : str ):
2480
- storage_functions = self .value_object ['storage' ].value_object
2490
+ if self .storage :
2491
+
2492
+ # Convert name for well-known PalletVersion storage entry
2493
+ if name == 'PalletVersion' :
2494
+ name = ':__STORAGE_VERSION__:'
2481
2495
2482
- if storage_functions .value_object :
2483
- for storage_function in storage_functions ['entries' ]:
2496
+ for storage_function in self .storage :
2484
2497
if storage_function .value ['name' ] == name :
2485
2498
return storage_function
2486
2499
0 commit comments