Skip to content

Commit 35ba700

Browse files
Tests passing
1 parent 749829f commit 35ba700

File tree

9 files changed

+29
-30
lines changed

9 files changed

+29
-30
lines changed

Sources/Core/Convenience/BigUInt+Extensions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import Foundation
99
import struct BigInt.BigUInt
1010

11-
extension BigUInt {
11+
public extension BigUInt {
1212
init?(_ naturalUnits: String, _ ethereumUnits: Utilities.Units) {
1313
guard let value = Utilities.parseToBigUInt(naturalUnits, units: ethereumUnits) else {return nil}
1414
self = value

Sources/Core/KeystoreManager/BIP32Keystore.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public class BIP32Keystore: AbstractKeystore {
6464

6565
private static let KeystoreParamsBIP32Version = 4
6666

67-
private (set) var addressStorage: PathAddressStorage
67+
public private (set) var addressStorage: PathAddressStorage
6868

6969
public convenience init?(_ jsonString: String) {
7070
let lowercaseJSON = jsonString.lowercased()

Sources/Core/KeystoreManager/PathAddressStorage.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
import Foundation
1010

1111
public struct PathAddressStorage {
12-
private(set) var addresses: [EthereumAddress]
13-
private(set) var paths: [String]
12+
public private(set) var addresses: [EthereumAddress]
13+
public private(set) var paths: [String]
1414

1515
init() {
1616
addresses = []

Sources/Core/Transaction/Web3+Options.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,21 @@ public struct TransactionOptions {
8282
opts.callOnBlock = .pending
8383
return opts
8484
}
85+
86+
public init(type: TransactionType? = nil, to: EthereumAddress? = nil, from: EthereumAddress? = nil, chainID: BigUInt? = nil, gasLimit: GasLimitPolicy? = nil, gasPrice: GasPricePolicy? = nil, maxFeePerGas: FeePerGasPolicy? = nil, maxPriorityFeePerGas: FeePerGasPolicy? = nil, value: BigUInt? = nil, nonce: NoncePolicy? = nil, callOnBlock: BlockNumber? = nil, accessList: [AccessListEntry]? = nil) {
87+
self.type = type
88+
self.to = to
89+
self.from = from
90+
self.chainID = chainID
91+
self.gasLimit = gasLimit
92+
self.gasPrice = gasPrice
93+
self.maxFeePerGas = maxFeePerGas
94+
self.maxPriorityFeePerGas = maxPriorityFeePerGas
95+
self.value = value
96+
self.nonce = nonce
97+
self.callOnBlock = callOnBlock
98+
self.accessList = accessList
99+
}
85100

86101
public func resolveNonce(_ suggestedByNode: BigUInt) -> BigUInt {
87102
guard let noncePolicy = self.nonce else { return suggestedByNode }

Sources/web3swift/Web3/Web3+GasOracle.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@ extension Web3 {
9292

9393
/// We're explicitly checking that feeHistory is not nil before force unwrapping it.
9494
// swiftlint: disable force_unwrapping
95-
guard feeHistory == nil, forceDropCache, feeHistory!.timestamp.distance(to: Date()) > cacheTimeout else { return feeHistory! }
96-
97-
feeHistory = try await eth.feeHistory(blockCount: blockCount, block: block, percentiles: percentiles)
95+
guard let feeHistory, !forceDropCache, feeHistory.timestamp.distance(to: Date()) < cacheTimeout else {
96+
return try await eth.feeHistory(blockCount: blockCount, block: block, percentiles: percentiles)
97+
}
9898

9999
/// We're assigning this value the line very above, so it's free to force unwrapping here
100-
return feeHistory!
100+
return feeHistory
101101
// swiftlint: enable force_unwrapping
102102
}
103103

Sources/web3swift/Web3/Web3+MutatingTransaction.swift

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -218,21 +218,3 @@ public class WriteTransaction: ReadTransaction {
218218
}
219219
}
220220
}
221-
222-
extension TransactionOptions {
223-
init() {
224-
self.init()
225-
// self.from = nil
226-
// self.to = nil
227-
// self.accessList = nil
228-
// self.callOnBlock = nil
229-
// self.chainID = nil
230-
// self.gasLimit = nil
231-
// self.gasPrice = nil
232-
// self.maxFeePerGas = nil
233-
// self.maxPriorityFeePerGas = nil
234-
// self.nonce = nil
235-
// self.type = nil
236-
// self.value = nil
237-
}
238-
}

Tests/web3swiftTests/localTests/EIP1559BlockTests.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import XCTest
22
import BigInt
3-
import Core
43

54
@testable
65
import web3swift
76

7+
@testable
8+
import Core
9+
810
class EIP1559BlockTests: LocalTestCase {
911
let uselessBlockPart = (
1012
number: BigUInt(12_965_000),

Tests/web3swiftTests/localTests/web3swiftKeystoresTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ class web3swiftKeystoresTests: LocalTestCase {
132132
XCTAssertNotNil(keystore)
133133
let account = keystore!.addresses![0]
134134
let key = try! keystore!.UNSAFE_getPrivateKeyData(password: "", account: account)
135-
let pubKey = Web3.Utils.privateToPublic(key, compressed: true)
135+
let pubKey = Utilities.privateToPublic(key, compressed: true)
136136
XCTAssert(pubKey?.toHexString() == "027160bd3a4d938cac609ff3a11fe9233de7b76c22a80d2b575e202cbf26631659")
137137
}
138138

@@ -148,7 +148,7 @@ class web3swiftKeystoresTests: LocalTestCase {
148148
XCTAssertNotNil(keystore)
149149
let account = keystore!.addresses![0]
150150
let key = try! keystore!.UNSAFE_getPrivateKeyData(password: "", account: account)
151-
let pubKey = Web3.Utils.privateToPublic(key, compressed: true)
151+
let pubKey = Utilities.privateToPublic(key, compressed: true)
152152
XCTAssert(pubKey?.toHexString() == "027160bd3a4d938cac609ff3a11fe9233de7b76c22a80d2b575e202cbf26631659")
153153
}
154154

Tests/web3swiftTests/localTests/web3swiftPromisesTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class web3swiftPromisesTests: XCTestCase {
4545
let contract = web3.contract(Web3.Utils.coldWalletABI, at: sendToAddress, abiVersion: 2)
4646
guard let writeTX = contract?.write("fallback") else {return XCTFail()}
4747
writeTX.transactionOptions.from = tempKeystore!.addresses?.first
48-
writeTX.transactionOptions.value = BigUInt("1.0", Web3.Utils.eth)
48+
writeTX.transactionOptions.value = BigUInt("1.0", Utilities.Units.eth)
4949
let estimate = try await writeTX.estimateGas(with: nil)
5050
print(estimate)
5151
XCTAssert(estimate == 21000)

0 commit comments

Comments
 (0)