From 0d29b6bc973a52570a62de7f51b682a0c05f5822 Mon Sep 17 00:00:00 2001 From: Nafeh Shoaib Date: Tue, 1 Nov 2022 16:44:59 -0400 Subject: [PATCH] Removed unwrapped optional --- Sources/Core/Transaction/CodableTransaction.swift | 13 ++++++------- Sources/web3swift/Operations/ReadTransaction.swift | 2 +- Sources/web3swift/Operations/WriteOperation.swift | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Sources/Core/Transaction/CodableTransaction.swift b/Sources/Core/Transaction/CodableTransaction.swift index 288a82d5d..b7b002643 100644 --- a/Sources/Core/Transaction/CodableTransaction.swift +++ b/Sources/Core/Transaction/CodableTransaction.swift @@ -188,18 +188,17 @@ public struct CodableTransaction { return self.envelope.encode(for: type) } - public mutating func resolve(provider: Web3Provider) async { - // FIXME: Delete force try - self.gasLimit = try! await self.gasLimitPolicy.resolve(provider: provider, transaction: self) + public mutating func resolve(provider: Web3Provider) async throws { + self.gasLimit = try await self.gasLimitPolicy.resolve(provider: provider, transaction: self) if from != nil || sender != nil { - self.nonce = try! await self.resolveNonce(provider: provider) + self.nonce = try await self.resolveNonce(provider: provider) } if case .eip1559 = type { - self.maxFeePerGas = try! await self.maxFeePerGasPolicy.resolve(provider: provider) - self.maxPriorityFeePerGas = try! await self.maxPriorityFeePerGasPolicy.resolve(provider: provider) + self.maxFeePerGas = try await self.maxFeePerGasPolicy.resolve(provider: provider) + self.maxPriorityFeePerGas = try await self.maxPriorityFeePerGasPolicy.resolve(provider: provider) } else { - self.gasPrice = try! await self.gasPricePolicy.resolve(provider: provider) + self.gasPrice = try await self.gasPricePolicy.resolve(provider: provider) } } diff --git a/Sources/web3swift/Operations/ReadTransaction.swift b/Sources/web3swift/Operations/ReadTransaction.swift index 5c721db19..a5b38f436 100755 --- a/Sources/web3swift/Operations/ReadTransaction.swift +++ b/Sources/web3swift/Operations/ReadTransaction.swift @@ -34,7 +34,7 @@ public class ReadOperation { // TODO: Remove type erasing here, some broad wide protocol should be added instead public func callContractMethod() async throws -> [String: Any] { - await transaction.resolve(provider: web3.provider) + try await transaction.resolve(provider: web3.provider) // MARK: Read data from ABI flow // FIXME: This should be dropped, and after `execute()` call, just to decode raw data. let data: Data = try await self.web3.eth.callTransaction(transaction) diff --git a/Sources/web3swift/Operations/WriteOperation.swift b/Sources/web3swift/Operations/WriteOperation.swift index 89f7f3a72..9ef64b885 100755 --- a/Sources/web3swift/Operations/WriteOperation.swift +++ b/Sources/web3swift/Operations/WriteOperation.swift @@ -12,7 +12,7 @@ public class WriteOperation: ReadOperation { // FIXME: Rewrite this to CodableTransaction public func writeToChain(password: String) async throws -> TransactionSendingResult { - await transaction.resolve(provider: web3.provider) + try await transaction.resolve(provider: web3.provider) if let attachedKeystoreManager = self.web3.provider.attachedKeystoreManager { do { try Web3Signer.signTX(transaction: &transaction,