Skip to content

Commit 662e3bf

Browse files
fix: swiftlint errors in Web3+Instance.swift
1 parent 8b37e6f commit 662e3bf

File tree

1 file changed

+18
-47
lines changed

1 file changed

+18
-47
lines changed

Sources/web3swift/Web3/Web3+Instance.swift

Lines changed: 18 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,9 @@ public class Web3 {
2727

2828
/// Public web3.eth.* namespace.
2929
public var eth: IEth {
30-
if ethInstance != nil {
31-
return ethInstance!
32-
}
33-
ethInstance = Web3.Eth(provider: provider)
34-
return ethInstance!
30+
let ethInstance = ethInstance ?? Web3.Eth(provider: provider)
31+
self.ethInstance = ethInstance
32+
return ethInstance
3533
}
3634

3735
// FIXME: Rewrite this to CodableTransaction
@@ -47,11 +45,9 @@ public class Web3 {
4745

4846
/// Public web3.personal.* namespace.
4947
public var personal: Web3.Personal {
50-
if self.personalInstance != nil {
51-
return self.personalInstance!
52-
}
53-
self.personalInstance = Web3.Personal(provider: self.provider, web3: self)
54-
return self.personalInstance!
48+
let personalInstance = personalInstance ?? Web3.Personal(provider: provider, web3: self)
49+
self.personalInstance = personalInstance
50+
return personalInstance
5551
}
5652

5753
// FIXME: Rewrite this to CodableTransaction
@@ -69,11 +65,9 @@ public class Web3 {
6965

7066
/// Public web3.personal.* namespace.
7167
public var txPool: Web3.TxPool {
72-
if self.txPoolInstance != nil {
73-
return self.txPoolInstance!
74-
}
75-
self.txPoolInstance = Web3.TxPool(provider: self.provider, web3: self)
76-
return self.txPoolInstance!
68+
let txPoolInstance = txPoolInstance ?? Web3.TxPool(provider: provider, web3: self)
69+
self.txPoolInstance = txPoolInstance
70+
return txPoolInstance
7771
}
7872

7973
// FIXME: Rewrite this to CodableTransaction
@@ -91,11 +85,9 @@ public class Web3 {
9185

9286
/// Public web3.wallet.* namespace.
9387
public var wallet: Web3.Web3Wallet {
94-
if self.walletInstance != nil {
95-
return self.walletInstance!
96-
}
97-
self.walletInstance = Web3.Web3Wallet(provider: self.provider, web3: self)
98-
return self.walletInstance!
88+
let walletInstance = walletInstance ?? Web3.Web3Wallet(provider: provider, web3: self)
89+
self.walletInstance = walletInstance
90+
return walletInstance
9991
}
10092

10193
public class Web3Wallet {
@@ -112,11 +104,9 @@ public class Web3 {
112104

113105
/// Public web3.browserFunctions.* namespace.
114106
public var browserFunctions: Web3.BrowserFunctions {
115-
if self.browserFunctionsInstance != nil {
116-
return self.browserFunctionsInstance!
117-
}
118-
self.browserFunctionsInstance = Web3.BrowserFunctions(provider: self.provider, web3: self)
119-
return self.browserFunctionsInstance!
107+
let browserFunctionsInstance = browserFunctionsInstance ?? Web3.BrowserFunctions(provider: provider, web3: self)
108+
self.browserFunctionsInstance = browserFunctionsInstance
109+
return browserFunctionsInstance
120110
}
121111

122112
// FIXME: Rewrite this to CodableTransaction
@@ -134,11 +124,9 @@ public class Web3 {
134124

135125
/// Public web3.browserFunctions.* namespace.
136126
public var eventLoop: Web3.Eventloop {
137-
if self.eventLoopInstance != nil {
138-
return self.eventLoopInstance!
139-
}
140-
self.eventLoopInstance = Web3.Eventloop(provider: self.provider, web3: self)
141-
return self.eventLoopInstance!
127+
let eventLoopInstance = eventLoopInstance ?? Web3.Eventloop(provider: provider, web3: self)
128+
self.eventLoopInstance = eventLoopInstance
129+
return eventLoopInstance
142130
}
143131

144132
// FIXME: Rewrite this to CodableTransaction
@@ -158,36 +146,19 @@ public class Web3 {
158146
var timer: RepeatingTimer?
159147

160148
public var monitoredProperties: [MonitoredProperty] = [MonitoredProperty]()
161-
// public var monitoredContracts: [MonitoredContract] = [MonitoredContract]()
162149
public var monitoredUserFunctions: [EventLoopRunnableProtocol] = [EventLoopRunnableProtocol]()
163150
public init(provider prov: Web3Provider, web3 web3instance: Web3) {
164151
provider = prov
165152
web3 = web3instance
166153
}
167154
}
168155

169-
// public typealias AssemblyHookFunction = ((inout CodableTransaction, EthereumContract)) -> Bool
170-
//
171-
// public typealias SubmissionHookFunction = (inout CodableTransaction) -> Bool
172-
173156
public typealias SubmissionResultHookFunction = (TransactionSendingResult) -> Void
174157

175-
// public struct AssemblyHook {
176-
// public var function: AssemblyHookFunction
177-
// }
178-
179-
// public struct SubmissionHook {
180-
// public var function: SubmissionHookFunction
181-
// }
182-
183158
public struct SubmissionResultHook {
184159
public var function: SubmissionResultHookFunction
185160
}
186161

187-
// public var preAssemblyHooks: [AssemblyHook] = [AssemblyHook]()
188-
// public var postAssemblyHooks: [AssemblyHook] = [AssemblyHook]()
189-
//
190-
// public var preSubmissionHooks: [SubmissionHook] = [SubmissionHook]()
191162
public var postSubmissionHooks: [SubmissionResultHook] = [SubmissionResultHook]()
192163

193164
}

0 commit comments

Comments
 (0)