Skip to content

Commit 9e839eb

Browse files
All tests are green.
Remove private setters for TransactionOptions resolvable properties.
1 parent e905007 commit 9e839eb

File tree

6 files changed

+26
-31
lines changed

6 files changed

+26
-31
lines changed

Sources/Core/TransactionOptions.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ public struct TransactionOptions {
5757
case automatic
5858
case manual(BigUInt)
5959
}
60-
public private (set) var maxFeePerGasPolicy: FeePerGasPolicy?
61-
public private (set) var maxPriorityFeePerGasPolicy: FeePerGasPolicy?
60+
public var maxFeePerGasPolicy: FeePerGasPolicy?
61+
public var maxPriorityFeePerGasPolicy: FeePerGasPolicy?
6262

6363
/// The value transferred for the transaction in wei, also the endowment if it’s a contract-creation transaction.
6464
public var value: BigUInt?
@@ -69,7 +69,7 @@ public struct TransactionOptions {
6969
case manual(BigUInt)
7070
}
7171

72-
public private (set) var noncePolicy: NoncePolicy?
72+
public var noncePolicy: NoncePolicy?
7373

7474
public var callOnBlock: BlockNumber?
7575

Sources/web3swift/HookedFunctions/Web3+BrowserFunctions.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,7 @@ extension web3.BrowserFunctions {
140140
guard let _ = options.from else {return (nil, nil)}
141141
let gasPrice = try await self.web3.eth.gasPrice()
142142
transaction.gasPrice = gasPrice
143-
// FIXME: Make this work again
144-
// options.gasPricePolicy = .manual(gasPricePolicy)
143+
options.gasPricePolicy = .manual(gasPrice)
145144
guard let gasEstimate = await self.estimateGas(transaction, transactionOptions: options) else {return (nil, nil)}
146145
transaction.gasLimit = gasEstimate
147146

Sources/web3swift/Utils/Hooks/NonceMiddleware.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ extension Web3.Utils {
6666
// var modifiedTX = tx
6767
// modifiedTX.nonce = newNonce
6868
var newOptions = transactionOptions
69-
// FIXME: Make this wotk again.
70-
// newOptions.nonce = .manual(newNonce)
69+
newOptions.noncePolicy = .manual(newNonce)
7170
return (tx, contract, newOptions, true)
7271
}
7372

Sources/web3swift/Web3/Web3+MutatingTransaction.swift

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -143,24 +143,22 @@ public class WriteTransaction: ReadTransaction {
143143

144144
var finalOptions = TransactionOptions()
145145
finalOptions.type = mergedOptions.type
146-
// FIXME: Make this work again.
147-
// finalOptions.nonce = .manual(nonce)
146+
finalOptions.noncePolicy = .manual(nonce)
148147
finalOptions.gasLimitPolicy = .manual(mergedOptions.resolveGasLimit(gasEstimate))
149148
finalOptions.accessList = mergedOptions.accessList
150149

151150
// set the finalized gas parameters
152-
// FIXME: Make this working again.
153-
// if let gasPrice = finalGasPrice {
154-
// finalOptions.gasPricePolicy = .manual(mergedOptions.resolveGasPrice(gasPrice))
155-
// }
156-
//
157-
// if let tipFee = finalTipFee {
158-
// finalOptions.maxPriorityFeePerGasPolicy = .manual(mergedOptions.resolveMaxPriorityFeePerGas(tipFee))
159-
// }
160-
//
161-
// if let gasFee = finalGasFee {
162-
// finalOptions.maxFeePerGasPolicy = .manual(mergedOptions.resolveMaxFeePerGas(gasFee))
163-
// }
151+
if let gasPrice = finalGasPrice {
152+
finalOptions.gasPricePolicy = .manual(mergedOptions.resolveGasPrice(gasPrice))
153+
}
154+
155+
if let tipFee = finalTipFee {
156+
finalOptions.maxPriorityFeePerGasPolicy = .manual(mergedOptions.resolveMaxPriorityFeePerGas(tipFee))
157+
}
158+
159+
if let gasFee = finalGasFee {
160+
finalOptions.maxFeePerGasPolicy = .manual(mergedOptions.resolveMaxFeePerGas(gasFee))
161+
}
164162

165163
assembledTransaction.applyOptions(finalOptions)
166164

Sources/web3swift/Web3/Web3+ReadingTransaction.swift

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,14 @@ public class ReadTransaction {
7777
optionsForGasEstimation.value = mergedOptions.value
7878

7979
// MARK: - Fixing estimate gas problem: gas price param shouldn't be nil
80-
// FIXME: Make this work again.
81-
// if let gasPricePolicy = mergedOptions.gasPricePolicy {
82-
// switch gasPricePolicy {
83-
// case .manual(_):
84-
// optionsForGasEstimation.gasPricePolicy = gasPricePolicy
85-
// default:
86-
// optionsForGasEstimation.gasPricePolicy = .manual(1) // 1 wei to fix wrong estimating gas problem
87-
// }
88-
// }
80+
if let gasPricePolicy = mergedOptions.gasPricePolicy {
81+
switch gasPricePolicy {
82+
case .manual(_):
83+
optionsForGasEstimation.gasPricePolicy = gasPricePolicy
84+
default:
85+
optionsForGasEstimation.gasPricePolicy = .manual(1) // 1 wei to fix wrong estimating gas problem
86+
}
87+
}
8988

9089
optionsForGasEstimation.callOnBlock = mergedOptions.callOnBlock
9190
if mergedOptions.value != nil {

Tests/web3swiftTests/localTests/LocalTestCase.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import web3swift
99
// while this class does show up in the navigator, it has no associated tests
1010
class LocalTestCase: XCTestCase {
1111

12-
static let url = URL(string: "http://127.0.0.1:8545")!
12+
static let url = URL(string: "http://proxyman.local:8545")!
1313

1414
override func setUp() async throws {
1515
let web3 = try! await Web3.new(LocalTestCase.url)

0 commit comments

Comments
 (0)