Skip to content

Commit 27a28e2

Browse files
Update clients code for changes made
1 parent 635009a commit 27a28e2

File tree

7 files changed

+15
-15
lines changed

7 files changed

+15
-15
lines changed

Sources/web3swift/Web3/Web3+EventParser.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ extension web3.web3contract.EventParser {
118118
throw Web3Error.inputError(desc: "Can not mix parsing specific block and using block range filter")
119119
}
120120

121-
let res = try await self.web3.eth.blockBy(number: blockNumber)
121+
let res = try await self.web3.eth.block(by: blockNumber)
122122

123123
return try await self.parseBlockPromise(res)
124124
}

Sources/web3swift/Web3/Web3+GasOracle.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,13 @@ extension Web3 {
138138

139139
// TODO: Make me work with cache
140140
let blocks = try await withThrowingTaskGroup(of: Block.self, returning: [Block].self) { group in
141-
142141
(latestBlockNumber - blockCount ... latestBlockNumber)
143-
.forEach { transaction in
142+
.forEach { block in
144143
group.addTask {
145-
try await self.eth.getBlockByNumber(transaction, fullTransactions: true)
144+
try await self.eth.block(by: .exact(block), fullTransactions: true)
146145
}
147146
}
148147

149-
150148
var collected = [Block]()
151149

152150
for try await value in group {

Sources/web3swift/Web3/Web3+Structures.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,8 @@ extension Block {
291291
}
292292
}
293293

294+
extension Block: APIResultType { }
295+
294296
public struct EventParserResult: EventParserResultProtocol {
295297
public var eventName: String
296298
public var transactionReceipt: TransactionReceipt?

Tests/web3swiftTests/localTests/web3swiftBasicLocalNodeTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ class web3swiftBasicLocalNodeTests: XCTestCase {
6161
sendTx.transactionOptions.value = valueToSend
6262
sendTx.transactionOptions.from = allAddresses[0]
6363

64-
let balanceBeforeTo = try await web3.eth.getBalance(address: sendToAddress)
65-
let balanceBeforeFrom = try await web3.eth.getBalance(address: allAddresses[0])
64+
let balanceBeforeTo = try await web3.eth.getBalance(for: sendToAddress)
65+
let balanceBeforeFrom = try await web3.eth.getBalance(for: allAddresses[0])
6666
print("Balance before to: " + balanceBeforeTo.description)
6767
print("Balance before from: " + balanceBeforeFrom.description)
6868

@@ -86,8 +86,8 @@ class web3swiftBasicLocalNodeTests: XCTestCase {
8686
print(details)
8787

8888

89-
let balanceAfterTo = try await web3.eth.getBalance(address: sendToAddress)
90-
let balanceAfterFrom = try await web3.eth.getBalance(address: allAddresses[0])
89+
let balanceAfterTo = try await web3.eth.getBalance(for: sendToAddress)
90+
let balanceAfterFrom = try await web3.eth.getBalance(for: allAddresses[0])
9191
print("Balance after to: " + balanceAfterTo.description)
9292
print("Balance after from: " + balanceAfterFrom.description)
9393

Tests/web3swiftTests/localTests/web3swiftPromisesTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class web3swiftPromisesTests: XCTestCase {
1818

1919
func testGetBalancePromise() async throws {
2020
let web3 = try await Web3.new(URL.init(string: "http://127.0.0.1:8545")!)
21-
let balance = try await web3.eth.getBalance(address: "0xe22b8979739D724343bd002F9f432F5990879901")
21+
let balance = try await web3.eth.getBalance(for: "0xe22b8979739D724343bd002F9f432F5990879901")
2222
print(balance)
2323
}
2424

Tests/web3swiftTests/localTests/web3swiftUserCases.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class web3swiftUserCases: XCTestCase {
106106
func testNonBatchedRequest() async throws {
107107
let web3 = try await Web3.new(URL.init(string: "http://127.0.0.1:8545")!)
108108
let address = EthereumAddress("0xe22b8979739D724343bd002F9f432F5990879901")!
109-
let balanceResult = try await web3.eth.getBalance(address: address)
109+
let balanceResult = try await web3.eth.getBalance(for: address)
110110
print(balanceResult)
111111
}
112112
}

Tests/web3swiftTests/remoteTests/InfuraTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class InfuraTests: XCTestCase {
1515
do {
1616
let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken)
1717
let address = EthereumAddress("0xd61b5ca425F8C8775882d4defefC68A6979DBbce")!
18-
let balance = try await web3.eth.getBalance(address: address)
18+
let balance = try await web3.eth.getBalance(for: address)
1919
let balString = Web3.Utils.formatToEthereumUnits(balance, toUnits: .eth, decimals: 3)
2020
print(balString!)
2121
} catch {
@@ -32,13 +32,13 @@ class InfuraTests: XCTestCase {
3232

3333
func testGetBlockByNumber1() async throws {
3434
let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken)
35-
let result = try await web3.eth.getBlockByNumber("latest", fullTransactions: false)
35+
let result = try await web3.eth.getBlockByNumber(.latest, fullTransactions: false)
3636
print(result)
3737
}
3838

3939
func testGetBlockByNumber2() async throws {
4040
let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken)
41-
let result = try await web3.eth.getBlockByNumber(UInt(5184323), fullTransactions: true)
41+
let result = try await web3.eth.getBlockByNumber(.exact(5184323), fullTransactions: true)
4242
print(result)
4343
let transactions = result.transactions
4444
for transaction in transactions {
@@ -54,7 +54,7 @@ class InfuraTests: XCTestCase {
5454
func testGetBlockByNumber3() async throws {
5555
do {
5656
let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken)
57-
let _ = try await web3.eth.getBlockByNumber(UInt(1000000000), fullTransactions: true)
57+
let _ = try await web3.eth.getBlockByNumber(.exact(1000000000), fullTransactions: true)
5858
XCTFail()
5959
} catch {
6060

0 commit comments

Comments
 (0)