Skip to content

Commit 6611999

Browse files
Rename deleted methods in tests and BrowserFunctions to new one.
Temporary disabled tests that requires temporary deleted methods.
1 parent 16d6f1c commit 6611999

15 files changed

+117
-118
lines changed

Sources/web3swift/API/APIMethod.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public typealias Receipt = Hash
1313
public typealias Address = Hash // 20 bytes (40 chars length without 0x)
1414
public typealias TransactionHash = Hash // 64 chars length without 0x
1515

16+
// FIXME: Add documentation to each method.
1617
/// Ethereum JSON RPC API Calls
1718
public enum APIRequest {
1819
// MARK: - Official API
@@ -91,7 +92,7 @@ public enum APIRequest {
9192
extension Data: APIResultType { }
9293

9394
extension APIRequest {
94-
public var method: REST {
95+
var method: REST {
9596
switch self {
9697
default: return .POST
9798
}
@@ -266,7 +267,7 @@ extension APIRequest {
266267
}
267268
}
268269

269-
public enum REST: String {
270+
enum REST: String {
270271
case POST
271272
case GET
272273
}

Sources/web3swift/API/APIRequestParameter.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import Foundation
1515
/// Please see `RequestParameter` documentation for more details.
1616
protocol APIRequestParameterType: Encodable { }
1717

18-
protocol APIRequestParameterElementType: Encodable { }
1918

2019
extension Int: APIRequestParameterType { }
2120

@@ -29,6 +28,9 @@ extension Bool: APIRequestParameterType { }
2928

3029
extension Array: APIRequestParameterType where Element: APIRequestParameterElementType { }
3130

31+
32+
protocol APIRequestParameterElementType: Encodable { }
33+
3234
extension TransactionParameters: APIRequestParameterType { }
3335

3436
extension EventFilterParameters: APIRequestParameterType { }

Sources/web3swift/API/HexDecodableProtocols.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,6 @@ extension BigInt: LiteralInitiableFromString { }
4646

4747
extension BigUInt: LiteralInitiableFromString { }
4848

49-
// This don't work without each other.
50-
//extension LiteralInitiableFromString {
51-
// public init?(from hexString: String) { return nil }
52-
//}
53-
//extension Array: LiteralInitiableFromString where Element: LiteralInitiableFromString { }
54-
5549
public protocol IntegerInitableWithRadix {
5650
init?<S: StringProtocol>(_ text: S, radix: Int)
5751
}

Sources/web3swift/HookedFunctions/Web3+BrowserFunctions.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ extension web3.BrowserFunctions {
1111

1212
public func getAccounts() async -> [String]? {
1313
do {
14-
let accounts = try await self.web3.eth.getAccounts()
14+
let accounts = try await self.web3.eth.ownedAccounts()
1515
return accounts.compactMap({$0.address})
1616
} catch {
1717
return [String]()
@@ -86,7 +86,7 @@ extension web3.BrowserFunctions {
8686

8787
public func sendTransaction(_ transaction: EthereumTransaction, transactionOptions: TransactionOptions, password: String = "web3swift") async -> [String: Any]? {
8888
do {
89-
let result = try await self.web3.eth.sendTransaction(transaction, transactionOptions: transactionOptions, password: password)
89+
let result = try await self.web3.eth.send(transaction, transactionOptions: transactionOptions, password: password)
9090
return ["txhash": result.hash]
9191
} catch {
9292
return nil
@@ -110,7 +110,7 @@ extension web3.BrowserFunctions {
110110

111111
public func estimateGas(_ transaction: EthereumTransaction, transactionOptions: TransactionOptions) async -> BigUInt? {
112112
do {
113-
let result = try await self.web3.eth.estimateGas(transaction, transactionOptions: transactionOptions)
113+
let result = try await self.web3.eth.estimateGas(for: transaction, transactionOptions: transactionOptions)
114114
return result
115115
} catch {
116116
return nil
@@ -133,7 +133,7 @@ extension web3.BrowserFunctions {
133133
var transaction = trans
134134
var options = opts
135135
guard let _ = options.from else {return (nil, nil)}
136-
let gasPrice = try await self.web3.eth.getGasPrice()
136+
let gasPrice = try await self.web3.eth.gasPrice()
137137
transaction.parameters.gasPrice = gasPrice
138138
options.gasPrice = .manual(gasPrice)
139139
guard let gasEstimate = await self.estimateGas(transaction, transactionOptions: options) else {return (nil, nil)}
@@ -179,15 +179,15 @@ extension web3.BrowserFunctions {
179179
case .manual(let gasPrice):
180180
transaction.parameters.gasPrice = gasPrice
181181
default:
182-
let gasPrice = try await self.web3.eth.getGasPrice()
182+
let gasPrice = try await self.web3.eth.gasPrice()
183183
transaction.parameters.gasPrice = gasPrice
184184
}
185185

186186
switch gasLimitPolicy {
187187
case .manual(let gasLimit):
188188
transaction.parameters.gasLimit = gasLimit
189189
default:
190-
let gasLimit = try await self.web3.eth.estimateGas(transaction, transactionOptions: transactionOptions)
190+
let gasLimit = try await self.web3.eth.estimateGas(for: transaction, transactionOptions: transactionOptions)
191191
transaction.parameters.gasLimit = gasLimit
192192
}
193193

Sources/web3swift/Web3/Web3+GasOracle.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ extension Web3 {
124124
private func suggestGasFeeLegacy() async throws -> [BigUInt] {
125125
var latestBlockNumber: BigUInt = 0
126126
switch block {
127-
case .latest: latestBlockNumber = try await eth.getBlockNumber()
127+
case .latest: latestBlockNumber = try await eth.blockNumber()
128128
case let .exact(number): latestBlockNumber = number
129129
// FIXME: Make real error here
130130
// Error throws since pending and erliest are unable to be used in this method.

Tests/web3swiftTests/localTests/LocalTestCase.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ class LocalTestCase: XCTestCase {
2020

2121
let web3 = try! await Web3.new(LocalTestCase.url)
2222

23-
let block = try! await web3.eth.getBlockNumber()
23+
let block = try! await web3.eth.blockNumber()
2424
if block >= 25 { return }
2525

2626
print("\n ****** Preloading Ganache (\(25 - block) blocks) *****\n")
2727

28-
let allAddresses = try! await web3.eth.getAccounts()
28+
let allAddresses = try! await web3.eth.ownedAccounts()
2929
let sendToAddress = allAddresses[0]
3030
let contract = web3.contract(Web3.Utils.coldWalletABI, at: sendToAddress, abiVersion: 2)
3131
let value = Web3.Utils.parseToBigUInt("1.0", units: .eth)

0 commit comments

Comments
 (0)