Skip to content

Commit 5fcc592

Browse files
committed
Fixed visibility, added more marks
1 parent cdc0b6f commit 5fcc592

33 files changed

+114
-153
lines changed

SubstrateClientSwift/Classes/Extrinsics/Call.swift

+8-5
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,15 @@
1919
import Foundation
2020

2121
/// An extrinsic call
22-
public class Call<T: Codable> {
23-
let moduleName: String
24-
let name: String
25-
let value: T
22+
open class Call<T: Codable> {
23+
/// Pallet name
24+
public let moduleName: String
25+
/// Call name
26+
public let name: String
27+
/// Call value
28+
public let value: T
2629

27-
init(moduleName: String, name: String, value: T) {
30+
public init(moduleName: String, name: String, value: T) {
2831
self.moduleName = moduleName
2932
self.name = name
3033
self.value = value

SubstrateClientSwift/Classes/Extrinsics/Era.swift

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public enum Era: Equatable, Codable {
2929
case mortal(value: Mortal)
3030
}
3131

32+
/// Mortal era value
3233
public struct Mortal: Equatable, Codable {
3334
public let period: UInt64
3435
public let phase: UInt64

SubstrateClientSwift/Classes/Extrinsics/ExtrinsicAdditional.swift

-42
This file was deleted.

SubstrateClientSwift/Classes/Extrinsics/ExtrinsicError.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import Foundation
2020

2121
/// Extrinsic possible errors
22-
enum ExtrinsicError: Error {
22+
public enum ExtrinsicError: Error {
2323
// used in service
2424
case runtimeVersionNotLoaded
2525
case genesisHashNotLoaded(RpcError?)

SubstrateClientSwift/Classes/Hashers/DefaultHashersProvider.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ struct DefaultHashersProvider: HashersProvider {
2424
/// - Parameters:
2525
/// - storage: Runtime module storage for which storage hashing interface is returned
2626
/// - Returns: Storage hashing interface for a runtime module
27-
func getStorageHasher(storage: RuntimeModuleStorage) -> StorageHashing {
27+
func storageHasher(for storage: RuntimeModuleStorage) -> StorageHashing {
2828
StorageHasher(storage: storage)
2929
}
3030
}

SubstrateClientSwift/Classes/Hashers/HashersProvider.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ protocol HashersProvider {
2424
/// - Parameters:
2525
/// - storage: The module storage which needs to be hashed
2626
/// - Returns: A storage hasher
27-
func getStorageHasher(storage: RuntimeModuleStorage) -> StorageHashing
27+
func storageHasher(for storage: RuntimeModuleStorage) -> StorageHashing
2828
}

SubstrateClientSwift/Classes/Modules/Chain/ChainModule.swift

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import Foundation
2020
import ScaleCodecSwift
2121

22+
// MARK: - Protocol
23+
2224
/// An interface for chain client
2325
public protocol ChainModule: AnyObject {
2426
/// Gets block hash using the provided number as a parameter for `RPC` request
@@ -28,6 +30,8 @@ public protocol ChainModule: AnyObject {
2830
func blockHash(number: UInt) async throws -> String?
2931
}
3032

33+
// MARK: - Implementation
34+
3135
/// Handles chain block hash fetching
3236
final class ChainModuleClient: ChainModule {
3337
private weak var rpcClient: Rpc?

SubstrateClientSwift/Classes/Substrate/Support/Extrinsics/AddMemo.swift renamed to SubstrateClientSwift/Classes/Modules/Crowdloan/Calls/AddMemo.swift

+7-5
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@
1818

1919
import Foundation
2020

21-
struct AddMemo: Codable {
22-
let index: UInt32
23-
let memo: Data
21+
/// crowdloan/addMemo call value
22+
public struct AddMemo: Codable {
23+
public let index: UInt32
24+
public let memo: Data
2425
}
2526

26-
final class AddMemoCall: Call<AddMemo> {
27-
init(value: AddMemo) {
27+
/// crowdloan/addMemo call
28+
public final class AddMemoCall: Call<AddMemo> {
29+
public init(value: AddMemo) {
2830
super.init(moduleName: "crowdloan", name: "add_memo", value: value)
2931
}
3032
}

SubstrateClientSwift/Classes/Modules/DefaultModuleProvider.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ import ScaleCodecSwift
2121

2222
/// Default module provider
2323
final class DefaultModuleProvider: InternalModuleProvider {
24-
weak var constants: SubstrateConstants?
25-
weak var storage: SubstrateStorage?
26-
weak var codec: ScaleCoder?
27-
let rpcClient: Rpc // Holder of rpc client
28-
let hashersProvider: HashersProvider
24+
internal weak var constants: SubstrateConstants?
25+
internal weak var storage: SubstrateStorage?
26+
private weak var codec: ScaleCoder?
27+
private let rpcClient: Rpc // Holder of rpc client
28+
private let hashersProvider: HashersProvider
2929

3030
init(
3131
codec: ScaleCoder,

SubstrateClientSwift/Classes/Modules/Payment/PaymentModule.swift

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import Foundation
2020
import ScaleCodecSwift
2121

22+
// MARK: - Protocol
23+
2224
/// An interface for getting a query fee details response
2325
public protocol PaymentModule {
2426
/// Gets query fee details for a payload
@@ -28,6 +30,8 @@ public protocol PaymentModule {
2830
func queryFeeDetails(payload: Payload) async throws -> QueryFeeDetails?
2931
}
3032

33+
// MARK: - Implementation
34+
3135
/// Handles payment query fee details fetching
3236
final class PaymentModuleClient: PaymentModule {
3337
private weak var rpcClient: Rpc?

SubstrateClientSwift/Classes/Modules/Payment/Types/QueryFeeDetails.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public struct QueryFeeDetails: Decodable {
2727
public let adjustedWeightFee: Balance
2828
}
2929

30-
class QueryFeeDetailsResponse: Codable {
30+
final class QueryFeeDetailsResponse: Codable {
3131
let inclusionFee: InclusionFee
3232

3333
init(inclusionFee: InclusionFee) {

SubstrateClientSwift/Classes/Modules/State/StateModule.swift

+7-3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import Foundation
2020
import ScaleCodecSwift
2121
import CommonSwift
2222

23+
// MARK: - Protocol
24+
2325
/// Interface for getting Runtime metadata and fetching Storage Items
2426
public protocol StateModule: AnyObject {
2527
/// Gets runtime metadata
@@ -58,6 +60,8 @@ public protocol StateModule: AnyObject {
5860
) async throws -> T?
5961
}
6062

63+
// MARK: - Implementation
64+
6165
/// State module client which handles fetching storage item and runtime metadata
6266
final class StateModuleClient: StateModule {
6367
weak var codec: ScaleCoder?
@@ -81,7 +85,7 @@ final class StateModuleClient: StateModule {
8185
item: RuntimeModuleStorageItem,
8286
storage: RuntimeModuleStorage
8387
) 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: [])
8589
return try await fetchStorageItem(key: key)
8690
}
8791

@@ -90,7 +94,7 @@ final class StateModuleClient: StateModule {
9094
key: Data,
9195
storage: RuntimeModuleStorage
9296
) 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])
9498
return try await fetchStorageItem(key: key)
9599
}
96100

@@ -99,7 +103,7 @@ final class StateModuleClient: StateModule {
99103
keys: [Data],
100104
storage: RuntimeModuleStorage
101105
) 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)
103107
return try await fetchStorageItem(key: key)
104108
}
105109

SubstrateClientSwift/Classes/Modules/System/SystemModule.swift

+4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import EncryptingSwift
2020
import Foundation
2121
import HashingSwift
2222

23+
// MARK: - Protocol
24+
2325
/// An interface for fetching runtime version and account
2426
public protocol SystemModule: AnyObject {
2527
/// Gets runtime version
@@ -57,6 +59,8 @@ public protocol SystemModule: AnyObject {
5759
func account(keyPair: KeyPair) async throws -> Account?
5860
}
5961

62+
// MARK: - Implementation
63+
6064
final class SystemModuleClient: SystemModule {
6165
enum Error: Swift.Error {
6266
case hexDecodeFailed

SubstrateClientSwift/Classes/RPC/Nothing.swift

+2-3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,5 @@
1818

1919
import Foundation
2020

21-
/// An "empty" object representing nothing
22-
public struct Nothing: Codable {
23-
}
21+
/// An "empty" object representing nothing, used in RPC client for empty requests or responses
22+
public struct Nothing: Codable {}

SubstrateClientSwift/Classes/RPC/RpcClient.swift

+6
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,17 @@
1818

1919
import Foundation
2020

21+
// MARK: - Error
22+
2123
/// Possible RPC errors
2224
public enum RpcError: Error {
2325
case failedToPrepareRequest
2426
case bodyEncodingFailed(Error)
2527
case responseError(RpcResponseError)
2628
}
2729

30+
// MARK: - Protocol
31+
2832
/// An interface for RPC client that handles sending requests
2933
public protocol Rpc: AnyObject {
3034
/// Sends a ready `RpcRequest`.
@@ -89,6 +93,8 @@ public protocol Rpc: AnyObject {
8993
) async throws -> Response?
9094
}
9195

96+
// MARK: - Implementation
97+
9298
/// RPC client that handles sending requests
9399
public final class RpcClient: Rpc {
94100
private enum Constants {

SubstrateClientSwift/Classes/Scale/DynamicAdapter.swift

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ final class DynamicAdapter<T>: ScaleCodecAdapter<T> {
3131
super.init()
3232
}
3333

34-
// MARK: - ScaleCodecAdapter
3534
/// Decodes data dynamically to a specified generic type `T` using the provided `DataReader`
3635
/// - Parameters:
3736
/// - type: Generic type `T` to which the data should be decoded

SubstrateClientSwift/Classes/Scale/DynamicAdapterError.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import Foundation
2020

2121
/// Dynamic adapter errors
22-
enum DynamicAdapterError: Error {
22+
public enum DynamicAdapterError: Error {
2323
case dynamicAdapterGivenInvalidType
2424
case typeIsNotDynamicException
2525
case typeIsNotFoundInRuntimeMetadataException

0 commit comments

Comments
 (0)