Skip to content

Commit 64af103

Browse files
Fixing review issues.
1 parent 74fd793 commit 64af103

File tree

6 files changed

+8
-13
lines changed

6 files changed

+8
-13
lines changed

Sources/Core/Oracle/GasOracle.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ final public class Oracle {
137137
latestBlockNumber = block
138138
case let .exact(number): latestBlockNumber = number
139139
// Error throws since pending and erliest are unable to be used in this method.
140-
default: throw Web3Error.valueError
140+
default: throw Web3Error.valueError()
141141
}
142142

143143
/// checking if latest block number is greather than number of blocks to take in account

Sources/Core/Transaction/Policies.swift

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,6 @@ public struct Policies {
5454
}
5555

5656
public static var auto: Policies {
57-
Policies(
58-
noncePolicy: .latest,
59-
gasLimitPolicy: .automatic,
60-
gasPricePolicy: .automatic,
61-
maxFeePerGasPolicy: .automatic,
62-
maxPriorityFeePerGasPolicy: .automatic
63-
)
57+
Policies()
6458
}
6559
}

Sources/Core/Web3Error/Web3Error.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public enum Web3Error: Error {
1313

1414
case dataError
1515
case typeError
16-
case valueError
16+
case valueError(desc: String? = nil)
1717
case serverError(code: Int)
1818
case clientError(code: Int)
1919

Sources/web3swift/Operations/ReadOperation.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ public class ReadOperation {
1919
var policyResolver: PolicyResolver
2020
var web3: Web3
2121

22-
public var provider: Web3Provider { web3.provider }
23-
2422
// FIXME: Rewrite this to CodableTransaction
2523
public init(transaction: CodableTransaction = CodableTransaction.emptyTransaction,
2624
web3 web3Instance: Web3,

Sources/web3swift/Utils/Hooks/NonceMiddleware.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ extension Web3.Utils {
1616
public var synchronizationPeriod: TimeInterval = 300.0 // 5 minutes
1717
var lastSyncTime: Date = Date()
1818

19+
public init() { }
20+
1921
public func functionToRun() async {
2022
guard let w3 = self.web3 else { return }
2123
let knownKeys = Array(nonceLookups.keys)
@@ -35,6 +37,5 @@ extension Web3.Utils {
3537
}
3638
}
3739

38-
public init() { }
3940
}
4041
}

Sources/web3swift/Web3/Web3+Resolver.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ public class PolicyResolver {
2222
// Nonce should be resolved first - as this might be needed for some
2323
// tx's gas estimation
2424
tx.nonce = try await resolveNonce(for: tx, with: policies.noncePolicy)
25+
} else {
26+
throw Web3Error.valueError(desc: "Could not be resolved with both from and sender are nil")
2527
}
2628

2729
tx.gasLimit = try await resolveGasEstimate(for: tx, with: policies.gasLimitPolicy)
@@ -83,7 +85,7 @@ public class PolicyResolver {
8385
public func resolveNonce(for tx: CodableTransaction, with policy: NoncePolicy) async throws -> BigUInt {
8486
switch policy {
8587
case .pending, .latest, .earliest:
86-
guard let address = tx.from ?? tx.sender else { throw Web3Error.valueError }
88+
guard let address = tx.from ?? tx.sender else { throw Web3Error.valueError() }
8789
let request: APIRequest = .getTransactionCount(address.address, tx.callOnBlock ?? .latest)
8890
let response: APIResponse<BigUInt> = try await APIRequest.sendRequest(with: provider, for: request)
8991
return response.result

0 commit comments

Comments
 (0)