File tree Expand file tree Collapse file tree 6 files changed +8
-13
lines changed Expand file tree Collapse file tree 6 files changed +8
-13
lines changed Original file line number Diff line number Diff line change @@ -137,7 +137,7 @@ final public class Oracle {
137
137
latestBlockNumber = block
138
138
case let . exact( number) : latestBlockNumber = number
139
139
// Error throws since pending and erliest are unable to be used in this method.
140
- default : throw Web3Error . valueError
140
+ default : throw Web3Error . valueError ( )
141
141
}
142
142
143
143
/// checking if latest block number is greather than number of blocks to take in account
Original file line number Diff line number Diff line change @@ -54,12 +54,6 @@ public struct Policies {
54
54
}
55
55
56
56
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 ( )
64
58
}
65
59
}
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ public enum Web3Error: Error {
13
13
14
14
case dataError
15
15
case typeError
16
- case valueError
16
+ case valueError( desc : String ? = nil )
17
17
case serverError( code: Int )
18
18
case clientError( code: Int )
19
19
Original file line number Diff line number Diff line change @@ -19,8 +19,6 @@ public class ReadOperation {
19
19
var policyResolver : PolicyResolver
20
20
var web3 : Web3
21
21
22
- public var provider : Web3Provider { web3. provider }
23
-
24
22
// FIXME: Rewrite this to CodableTransaction
25
23
public init ( transaction: CodableTransaction = CodableTransaction . emptyTransaction,
26
24
web3 web3Instance: Web3 ,
Original file line number Diff line number Diff line change @@ -16,6 +16,8 @@ extension Web3.Utils {
16
16
public var synchronizationPeriod : TimeInterval = 300.0 // 5 minutes
17
17
var lastSyncTime : Date = Date ( )
18
18
19
+ public init ( ) { }
20
+
19
21
public func functionToRun( ) async {
20
22
guard let w3 = self . web3 else { return }
21
23
let knownKeys = Array ( nonceLookups. keys)
@@ -35,6 +37,5 @@ extension Web3.Utils {
35
37
}
36
38
}
37
39
38
- public init ( ) { }
39
40
}
40
41
}
Original file line number Diff line number Diff line change @@ -22,6 +22,8 @@ public class PolicyResolver {
22
22
// Nonce should be resolved first - as this might be needed for some
23
23
// tx's gas estimation
24
24
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 " )
25
27
}
26
28
27
29
tx. gasLimit = try await resolveGasEstimate ( for: tx, with: policies. gasLimitPolicy)
@@ -83,7 +85,7 @@ public class PolicyResolver {
83
85
public func resolveNonce( for tx: CodableTransaction , with policy: NoncePolicy ) async throws -> BigUInt {
84
86
switch policy {
85
87
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 ( ) }
87
89
let request : APIRequest = . getTransactionCount( address. address, tx. callOnBlock ?? . latest)
88
90
let response : APIResponse < BigUInt > = try await APIRequest . sendRequest ( with: provider, for: request)
89
91
return response. result
You can’t perform that action at this time.
0 commit comments