Skip to content

Commit 275d2cd

Browse files
fix: ERC721 swiftlint
1 parent 3ad9a6b commit 275d2cd

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

Sources/web3swift/Tokens/ERC721/Web3+ERC721.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,11 @@ public class ERC721: IERC721 {
6363
public var address: EthereumAddress
6464

6565
lazy var contract: Web3.Contract = {
66+
// swiftlint:disable force_unwrapping
6667
let contract = self.web3.contract(Web3.Utils.erc721ABI, at: self.address, abiVersion: 2)
6768
precondition(contract != nil)
6869
return contract!
70+
// swiftlint:enable force_unwrapping
6971
}()
7072

7173
public init(web3: Web3, provider: Web3Provider, address: EthereumAddress, transaction: CodableTransaction = .emptyTransaction) {
@@ -88,12 +90,12 @@ public class ERC721: IERC721 {
8890
if self._hasReadProperties {
8991
return
9092
}
91-
guard contract.contract.address != nil else {return}
93+
guard contract.contract.address != nil else { return }
9294

9395
async let tokenIdPromise = contract.createReadOperation("tokenId")?.callContractMethod()
9496

95-
guard let tokenIdResult = try await tokenIdPromise else {return}
96-
guard let tokenId = tokenIdResult["0"] as? BigUInt else {return}
97+
guard let tokenIdResult = try await tokenIdPromise else { return }
98+
guard let tokenId = tokenIdResult["0"] as? BigUInt else { return }
9799
self._tokenId = tokenId
98100

99101
self._hasReadProperties = true

Sources/web3swift/Tokens/ERC721x/Web3+ERC721x.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,11 @@ public class ERC721x: IERC721x {
4747
public var abi: String
4848

4949
lazy var contract: Web3.Contract = {
50+
// swiftlint:disable force_unwrapping
5051
let contract = self.web3.contract(self.abi, at: self.address, abiVersion: 2)
5152
precondition(contract != nil)
5253
return contract!
54+
// swiftlint:enable force_unwrapping
5355
}()
5456

5557
public init(web3: Web3, provider: Web3Provider, address: EthereumAddress, abi: String = Web3.Utils.erc721xABI, transaction: CodableTransaction = .emptyTransaction) {
@@ -73,12 +75,12 @@ public class ERC721x: IERC721x {
7375
if self._hasReadProperties {
7476
return
7577
}
76-
guard contract.contract.address != nil else {return}
78+
guard contract.contract.address != nil else { return }
7779
transaction.callOnBlock = .latest
7880

79-
guard let tokenIdPromise = try await contract.createReadOperation("tokenId")?.callContractMethod() else {return}
81+
guard let tokenIdPromise = try await contract.createReadOperation("tokenId")?.callContractMethod() else { return }
8082

81-
guard let tokenId = tokenIdPromise["0"] as? BigUInt else {return}
83+
guard let tokenId = tokenIdPromise["0"] as? BigUInt else { return }
8284
self._tokenId = tokenId
8385

8486
self._hasReadProperties = true

0 commit comments

Comments
 (0)