@@ -20,6 +20,8 @@ import Foundation
20
20
import ScaleCodecSwift
21
21
import CommonSwift
22
22
23
+ // MARK: - Protocol
24
+
23
25
/// Interface for getting Runtime metadata and fetching Storage Items
24
26
public protocol StateModule : AnyObject {
25
27
/// Gets runtime metadata
@@ -58,6 +60,8 @@ public protocol StateModule: AnyObject {
58
60
) async throws -> T ?
59
61
}
60
62
63
+ // MARK: - Implementation
64
+
61
65
/// State module client which handles fetching storage item and runtime metadata
62
66
final class StateModuleClient : StateModule {
63
67
weak var codec : ScaleCoder ?
@@ -81,7 +85,7 @@ final class StateModuleClient: StateModule {
81
85
item: RuntimeModuleStorageItem ,
82
86
storage: RuntimeModuleStorage
83
87
) async throws -> T ? {
84
- let key = try hashersProvider. getStorageHasher ( storage : storage) . hash ( storageItem: item, keys: [ ] )
88
+ let key = try hashersProvider. storageHasher ( for : storage) . hash ( storageItem: item, keys: [ ] )
85
89
return try await fetchStorageItem ( key: key)
86
90
}
87
91
@@ -90,7 +94,7 @@ final class StateModuleClient: StateModule {
90
94
key: Data ,
91
95
storage: RuntimeModuleStorage
92
96
) async throws -> T ? {
93
- let key = try hashersProvider. getStorageHasher ( storage : storage) . hash ( storageItem: item, keys: [ key] )
97
+ let key = try hashersProvider. storageHasher ( for : storage) . hash ( storageItem: item, keys: [ key] )
94
98
return try await fetchStorageItem ( key: key)
95
99
}
96
100
@@ -99,7 +103,7 @@ final class StateModuleClient: StateModule {
99
103
keys: [ Data ] ,
100
104
storage: RuntimeModuleStorage
101
105
) async throws -> T ? {
102
- let key = try hashersProvider. getStorageHasher ( storage : storage) . hash ( storageItem: item, keys: keys)
106
+ let key = try hashersProvider. storageHasher ( for : storage) . hash ( storageItem: item, keys: keys)
103
107
return try await fetchStorageItem ( key: key)
104
108
}
105
109
0 commit comments