Skip to content

Commit 909b323

Browse files
fix: swiflint issues in ETHRegistrarController.swift
1 parent e96d426 commit 909b323

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

Sources/web3swift/Utils/ENS/ETHRegistrarController.swift

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ public extension ENS {
1515
public let address: EthereumAddress
1616

1717
lazy var contract: Web3.Contract = {
18+
// swiftlint:disable force_unwrapping
1819
let contract = self.web3.contract(Web3.Utils.ethRegistrarControllerABI, at: self.address, abiVersion: 2)
1920
precondition(contract != nil)
2021
return contract!
22+
// swiftlint:enable force_unwrapping
2123
}()
2224

2325
lazy var defaultTransaction: CodableTransaction = {
@@ -31,28 +33,28 @@ public extension ENS {
3133

3234
public func getRentPrice(name: String, duration: UInt) async throws -> BigUInt {
3335
guard let transaction = self.contract.createReadOperation("rentPrice", parameters: [name, duration]) else { throw Web3Error.transactionSerializationError }
34-
guard let result = try? await transaction.callContractMethod() else {throw Web3Error.processingError(desc: "Can't call transaction")}
36+
guard let result = try? await transaction.callContractMethod() else { throw Web3Error.processingError(desc: "Can't call transaction") }
3537
guard let price = result["0"] as? BigUInt else { throw Web3Error.processingError(desc: "Can't get answer") }
3638
return price
3739
}
3840

3941
public func checkNameValidity(name: String) async throws -> Bool {
4042
guard let transaction = self.contract.createReadOperation("valid", parameters: [name]) else { throw Web3Error.transactionSerializationError }
41-
guard let result = try? await transaction.callContractMethod() else {throw Web3Error.processingError(desc: "Can't call transaction")}
43+
guard let result = try? await transaction.callContractMethod() else { throw Web3Error.processingError(desc: "Can't call transaction") }
4244
guard let valid = result["0"] as? Bool else { throw Web3Error.processingError(desc: "Can't get answer") }
4345
return valid
4446
}
4547

4648
public func isNameAvailable(name: String) async throws -> Bool {
4749
guard let transaction = self.contract.createReadOperation("available", parameters: [name]) else { throw Web3Error.transactionSerializationError }
48-
guard let result = try? await transaction.callContractMethod() else {throw Web3Error.processingError(desc: "Can't call transaction")}
50+
guard let result = try? await transaction.callContractMethod() else { throw Web3Error.processingError(desc: "Can't call transaction") }
4951
guard let available = result["0"] as? Bool else { throw Web3Error.processingError(desc: "Can't get answer") }
5052
return available
5153
}
5254

5355
public func calculateCommitmentHash(name: String, owner: EthereumAddress, secret: String) async throws -> Data {
5456
guard let transaction = self.contract.createReadOperation("makeCommitment", parameters: [name, owner.address, secret]) else { throw Web3Error.transactionSerializationError }
55-
guard let result = try? await transaction.callContractMethod() else {throw Web3Error.processingError(desc: "Can't call transaction")}
57+
guard let result = try? await transaction.callContractMethod() else { throw Web3Error.processingError(desc: "Can't call transaction") }
5658
guard let hash = result["0"] as? Data else { throw Web3Error.processingError(desc: "Can't get answer") }
5759
return hash
5860
}
@@ -65,7 +67,7 @@ public extension ENS {
6567
}
6668

6769
public func registerName(from: EthereumAddress, name: String, owner: EthereumAddress, duration: UInt, secret: String, price: String) throws -> WriteOperation {
68-
guard let amount = Utilities.parseToBigUInt(price, units: .ether) else {throw Web3Error.inputError(desc: "Wrong price: no way for parsing to ether units")}
70+
guard let amount = Utilities.parseToBigUInt(price, units: .ether) else { throw Web3Error.inputError(desc: "Wrong price: no way for parsing to ether units") }
6971
defaultTransaction.value = amount
7072
defaultTransaction.from = from
7173
defaultTransaction.to = self.address
@@ -74,7 +76,7 @@ public extension ENS {
7476
}
7577

7678
public func extendNameRegistration(from: EthereumAddress, name: String, duration: UInt32, price: String) throws -> WriteOperation {
77-
guard let amount = Utilities.parseToBigUInt(price, units: .ether) else {throw Web3Error.inputError(desc: "Wrong price: no way for parsing to ether units")}
79+
guard let amount = Utilities.parseToBigUInt(price, units: .ether) else { throw Web3Error.inputError(desc: "Wrong price: no way for parsing to ether units") }
7880
defaultTransaction.value = amount
7981
defaultTransaction.from = from
8082
defaultTransaction.to = self.address

0 commit comments

Comments
 (0)