@@ -41,9 +41,11 @@ public class ERC1155: IERC1155 {
4141 public var abi : String
4242
4343 lazy var contract : Web3 . Contract = {
44+ // swiftlint:disable force_unwrapping
4445 let contract = self . web3. contract ( self . abi, at: self . address, abiVersion: 2 )
4546 precondition ( contract != nil )
4647 return contract!
48+ // swiftlint:enable force_unwrapping
4749 } ( )
4850
4951 public init ( web3: Web3 , provider: Web3Provider , address: EthereumAddress , abi: String = Web3 . Utils. erc1155ABI, transaction: CodableTransaction = . emptyTransaction) {
@@ -67,11 +69,11 @@ public class ERC1155: IERC1155 {
6769 if self . _hasReadProperties {
6870 return
6971 }
70- guard contract. contract. address != nil else { return }
72+ guard contract. contract. address != nil else { return }
7173
72- guard let tokenIdPromise = try await contract. createReadOperation ( " id " ) ? . callContractMethod ( ) else { return }
74+ guard let tokenIdPromise = try await contract. createReadOperation ( " id " ) ? . callContractMethod ( ) else { return }
7375
74- guard let tokenId = tokenIdPromise [ " 0 " ] as? BigUInt else { return }
76+ guard let tokenId = tokenIdPromise [ " 0 " ] as? BigUInt else { return }
7577 self . _tokenId = tokenId
7678
7779 self . _hasReadProperties = true
@@ -94,7 +96,7 @@ public class ERC1155: IERC1155 {
9496 let result = try await contract
9597 . createReadOperation ( " balanceOf " , parameters: [ account, id] ) !
9698 . callContractMethod ( )
97- guard let res = result [ " 0 " ] as? BigUInt else { throw Web3Error . processingError ( desc: " Failed to get result of expected type from the Ethereum node " ) }
99+ guard let res = result [ " 0 " ] as? BigUInt else { throw Web3Error . processingError ( desc: " Failed to get result of expected type from the Ethereum node " ) }
98100 return res
99101 }
100102
@@ -107,14 +109,14 @@ public class ERC1155: IERC1155 {
107109 public func isApprovedForAll( owner: EthereumAddress , operator user: EthereumAddress , scope: Data ) async throws -> Bool {
108110 let result = try await contract. createReadOperation ( " isApprovedForAll " , parameters: [ owner, user, scope] ) !. callContractMethod ( )
109111
110- guard let res = result [ " 0 " ] as? Bool else { throw Web3Error . processingError ( desc: " Failed to get result of expected type from the Ethereum node " ) }
112+ guard let res = result [ " 0 " ] as? Bool else { throw Web3Error . processingError ( desc: " Failed to get result of expected type from the Ethereum node " ) }
111113 return res
112114 }
113115
114116 public func supportsInterface( interfaceID: String ) async throws -> Bool {
115117 let result = try await contract. createReadOperation ( " supportsInterface " , parameters: [ interfaceID] ) !. callContractMethod ( )
116118
117- guard let res = result [ " 0 " ] as? Bool else { throw Web3Error . processingError ( desc: " Failed to get result of expected type from the Ethereum node " ) }
119+ guard let res = result [ " 0 " ] as? Bool else { throw Web3Error . processingError ( desc: " Failed to get result of expected type from the Ethereum node " ) }
118120 return res
119121 }
120122}
0 commit comments