@@ -41,9 +41,11 @@ public class ERC1155: IERC1155 {
41
41
public var abi : String
42
42
43
43
lazy var contract : Web3 . Contract = {
44
+ // swiftlint:disable force_unwrapping
44
45
let contract = self . web3. contract ( self . abi, at: self . address, abiVersion: 2 )
45
46
precondition ( contract != nil )
46
47
return contract!
48
+ // swiftlint:enable force_unwrapping
47
49
} ( )
48
50
49
51
public init ( web3: Web3 , provider: Web3Provider , address: EthereumAddress , abi: String = Web3 . Utils. erc1155ABI, transaction: CodableTransaction = . emptyTransaction) {
@@ -67,11 +69,11 @@ public class ERC1155: IERC1155 {
67
69
if self . _hasReadProperties {
68
70
return
69
71
}
70
- guard contract. contract. address != nil else { return }
72
+ guard contract. contract. address != nil else { return }
71
73
72
- guard let tokenIdPromise = try await contract. createReadOperation ( " id " ) ? . callContractMethod ( ) else { return }
74
+ guard let tokenIdPromise = try await contract. createReadOperation ( " id " ) ? . callContractMethod ( ) else { return }
73
75
74
- guard let tokenId = tokenIdPromise [ " 0 " ] as? BigUInt else { return }
76
+ guard let tokenId = tokenIdPromise [ " 0 " ] as? BigUInt else { return }
75
77
self . _tokenId = tokenId
76
78
77
79
self . _hasReadProperties = true
@@ -94,7 +96,7 @@ public class ERC1155: IERC1155 {
94
96
let result = try await contract
95
97
. createReadOperation ( " balanceOf " , parameters: [ account, id] ) !
96
98
. 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 " ) }
98
100
return res
99
101
}
100
102
@@ -107,14 +109,14 @@ public class ERC1155: IERC1155 {
107
109
public func isApprovedForAll( owner: EthereumAddress , operator user: EthereumAddress , scope: Data ) async throws -> Bool {
108
110
let result = try await contract. createReadOperation ( " isApprovedForAll " , parameters: [ owner, user, scope] ) !. callContractMethod ( )
109
111
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 " ) }
111
113
return res
112
114
}
113
115
114
116
public func supportsInterface( interfaceID: String ) async throws -> Bool {
115
117
let result = try await contract. createReadOperation ( " supportsInterface " , parameters: [ interfaceID] ) !. callContractMethod ( )
116
118
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 " ) }
118
120
return res
119
121
}
120
122
}
0 commit comments