Skip to content

Commit 1edf2f6

Browse files
committed
more nil coalescing to clean up the original code
1 parent 529d9ec commit 1edf2f6

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

Sources/web3swift/HookedFunctions/Web3+BrowserFunctions.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ extension web3.BrowserFunctions {
8282
transactionOptions.from = options.from
8383
transactionOptions.to = options.to
8484
transactionOptions.value = options.value ?? 0
85-
transactionOptions.gasLimit = options.gasLimit != nil ? options.gasLimit! : .automatic
86-
transactionOptions.gasPrice = options.gasPrice != nil ? options.gasPrice! : .automatic
85+
transactionOptions.gasLimit = options.gasLimit ?? .automatic
86+
transactionOptions.gasPrice = options.gasPrice ?? .automatic
8787
return self.sendTransaction(transaction, transactionOptions: transactionOptions, password: password)
8888
} catch { return nil }
8989
}
@@ -105,9 +105,9 @@ extension web3.BrowserFunctions {
105105
var transactionOptions = TransactionOptions()
106106
transactionOptions.from = options.from
107107
transactionOptions.to = options.to
108-
transactionOptions.value = options.value != nil ? options.value! : BigUInt(0)
108+
transactionOptions.value = options.value ?? 0
109109
transactionOptions.gasLimit = .automatic
110-
transactionOptions.gasPrice = options.gasPrice != nil ? options.gasPrice! : .automatic
110+
transactionOptions.gasPrice = options.gasPrice ?? .automatic
111111
return self.estimateGas(transaction, transactionOptions: transactionOptions)
112112
} catch { return nil }
113113
}
@@ -158,9 +158,9 @@ extension web3.BrowserFunctions {
158158
var transactionOptions = TransactionOptions()
159159
transactionOptions.from = options.from
160160
transactionOptions.to = options.to
161-
transactionOptions.value = options.value != nil ? options.value! : BigUInt(0)
162-
transactionOptions.gasLimit = options.gasLimit != nil ? options.gasLimit! : .automatic
163-
transactionOptions.gasPrice = options.gasPrice != nil ? options.gasPrice! : .automatic
161+
transactionOptions.value = options.value ?? 0
162+
transactionOptions.gasLimit = options.gasLimit ?? .automatic
163+
transactionOptions.gasPrice = options.gasPrice ?? .automatic
164164
if let nonceString = transactionJSON["nonce"] as? String, let nonce = BigUInt(nonceString.stripHexPrefix(), radix: 16) {
165165
transactionOptions.nonce = .manual(nonce)
166166
} else {

0 commit comments

Comments
 (0)