Skip to content

Commit 95a6ea6

Browse files
Fixups
- Update percentile arrays method. - fix JSONRPCmethod validation bug -
1 parent 73985d7 commit 95a6ea6

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

Sources/web3swift/Convenience/Array+Extension.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ extension Array where Element: BinaryInteger {
4444

4545
let normalizedValue = value / 100 * Double(self.count)
4646
let index = Int(ceil(normalizedValue))
47-
guard index < self.count else { return nil }
4847

4948
let sorted_data = self.sorted()
49+
guard index < self.count else { return sorted_data[sorted_data.endIndex] }
5050
return sorted_data[index]
5151
}
5252
}

Sources/web3swift/Web3/Web3+Methods.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ public enum JSONRPCmethod: String, Encodable {
4848
.getAccounts,
4949
.getTxPoolStatus,
5050
.getTxPoolContent,
51-
.getTxPoolInspect,
52-
.estimateGas:
51+
.getTxPoolInspect:
5352
return 0
5453
case .sendRawTransaction,
5554
.sendTransaction,
@@ -58,7 +57,8 @@ public enum JSONRPCmethod: String, Encodable {
5857
.personalSign,
5958
.unlockAccount,
6059
.createAccount,
61-
.getLogs:
60+
.getLogs,
61+
.estimateGas:
6262
return 1
6363
case .call,
6464
.getTransactionCount,

Sources/web3swift/Web3/Web3+ReadingTransaction.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ public class ReadTransaction {
9090
let promise = self.web3.eth.estimateGasPromise(assembledTransaction, transactionOptions: optionsForGasEstimation)
9191
promise.done(on: queue) {(estimate: BigUInt) in
9292
seal.fulfill(estimate)
93-
}.catch(on: queue) {err in
94-
seal.reject(err)
93+
}.catch(on: queue) {err in
94+
seal.reject(err)
9595
}
9696
}
9797
return returnPromise

Tests/web3swiftTests/localTests/web3swiftBasicLocalNodeTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class web3swiftBasicLocalNodeTests: XCTestCase {
6464
let balanceBeforeFrom = try web3.eth.getBalancePromise(address: allAddresses[0]).wait()
6565
print("Balance before to: " + balanceBeforeTo.description)
6666
print("Balance before from: " + balanceBeforeFrom.description)
67-
67+
6868
let result = try sendTx.sendPromise().wait()
6969
let txHash = result.hash
7070
print("Transaction with hash " + txHash)

Tests/web3swiftTests/localTests/web3swiftPromisesTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class web3swiftPromisesTests: XCTestCase {
9494
options.from = fromAddress
9595

9696
let amount1 = Web3.Utils.parseToBigUInt("0.000000000000000001", units: .eth) // 1 wei
97-
97+
9898
guard let tx1 = contract.write("test",
9999
parameters: [amount1] as [AnyObject],
100100
extraData: Data(),

0 commit comments

Comments
 (0)