diff --git a/lib/helper.rb b/lib/helper.rb index cedc76b..33b5445 100644 --- a/lib/helper.rb +++ b/lib/helper.rb @@ -55,7 +55,8 @@ def generate_storage_key_from_metadata(metadata, module_name, storage_name, para hasher2, metadata.value.value[:metadata][:version] ) - [storage_key, return_type] + storage_modifier = storage_item[:modifier] + [storage_key, return_type, storage_item] end def generate_storage_key(module_name, storage_name, params = nil, hasher = nil, hasher2 = nil, metadata_version = nil) diff --git a/lib/substrate_client.rb b/lib/substrate_client.rb index c2fe0c5..93392b5 100644 --- a/lib/substrate_client.rb +++ b/lib/substrate_client.rb @@ -144,9 +144,12 @@ def get_block_events(block_hash=nil) def get_storage(module_name, storage_name, params = nil, block_hash = nil) self.init_types_and_metadata(block_hash) - storage_key, return_type = SubstrateClient::Helper.generate_storage_key_from_metadata(@metadata, module_name, storage_name, params) + storage_key, return_type, storage_item = SubstrateClient::Helper.generate_storage_key_from_metadata(@metadata, module_name, storage_name, params) data = self.state_getStorage(storage_key, block_hash) - return unless data + + if data.nil? && storage_item[:modifier] == "Default" && (not storage_item[:fallback].nil?) + data = storage_item[:fallback] + end bytes = Scale::Bytes.new(data) type = Scale::Types.get(return_type)