Skip to content

Commit 0b71c1c

Browse files
Cleaning code during PR.
1 parent bdc3695 commit 0b71c1c

38 files changed

+90
-192
lines changed

Sources/Core/EthereumNetwork/Request/APIrequest+Methods.swift renamed to Sources/Core/EthereumNetwork/Request/APIRequest+Methods.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// APIrequest+Methods.swift
2+
// APIRequest+Methods.swift
33
//
44
//
55
// Created by Yaroslav Yashin on 12.07.2022.

Sources/Core/EthereumNetwork/Request/APIRequest+UtilityTypes.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// File.swift
2+
// APIRequest+UtilityTypes.swift
33
//
44
//
55
// Created by Yaroslav Yashin on 12.07.2022.

Sources/Core/EthereumNetwork/RequestParameter/APIRequestParameterType.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
2-
// Web3+APIRequestParameter.swift
3-
// Web3swift
2+
// APIRequestParameter.swift
3+
//
44
//
55
// Created by Yaroslav on 24.05.2022.
66
//

Sources/Core/EthereumNetwork/RequestParameter/RequestParameter+RawRepresentable.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ import Foundation
99

1010
extension RequestParameter: RawRepresentable {
1111
/**
12-
This init required by ``RawRepresentable`` protocol, which is requred to encode mixed type values array in JSON.
12+
This init is required by ``RawRepresentable`` protocol, which is required to encode mixed type values array in JSON.
1313

14-
This protocol used to implement custom `encode` method for that enum,
15-
which is encodes array of self into array of self assotiated values.
14+
This protocol is used to implement custom `encode` method for that enum,
15+
which encodes an array of self-assosiated values.
1616

1717
You're totally free to use explicit and more convenience member init as `RequestParameter.int(12)` in your code.
1818
*/
@@ -46,7 +46,7 @@ extension RequestParameter: RawRepresentable {
4646

4747
/// Returning associated value of the enum case.
4848
var rawValue: APIRequestParameterType {
49-
// cases can't be merged, coz it cause compiler error since it couldn't predict what exact type on exact case will be returned.
49+
// cases can't be merged, coz it causes compile error since it couldn't predict exact type that will be returned.
5050
switch self {
5151
case let .int(value): return value
5252
case let .intArray(value): return value

Sources/Core/EthereumNetwork/RequestParameter/RequestParameter.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,16 @@ import Foundation
1010
/**
1111
Enum to compose request to the node params.
1212

13-
In most cases request params are passed to Ethereum JSON RPC request as array of mixed type values, such as `[12,"this",true]`,
14-
thus this is not appropriate API design we have what we have.
13+
In most cases request params are passed to Ethereum JSON RPC request as array of mixed type values, such as `[12,"this",true]`.
1514

1615
Meanwhile swift don't provide strict way to compose such array it gives some hacks to solve this task
1716
and one of them is using `RawRepresentable` protocol.
1817

19-
Conforming this protocol gives designated type ability to represent itself in `String` representation in any way.
18+
This protocol allows the designated type to represent itself in `String` representation.
2019

21-
So in our case we're using such to implement custom `encode` method to any used in node request params types.
20+
So in our case we're using it to implement custom `encode` method for all possible types used as request params.
2221

23-
Latter is required to encode array of `RequestParameter` to not to `[RequestParameter.int(1)]`, but to `[1]`.
22+
This `encode` method is required to encode array of `RequestParameter` to not to `[RequestParameter.int(1)]`, but to `[1]`.
2423

2524
Here's an example of using this enum in field.
2625
```swift

Sources/Core/Structure/Block/Block.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
2-
1+
//
2+
// Block.swift
3+
//
4+
//
5+
// Created by Yaroslav Yashin on 12.07.2022.
6+
//
37

48
import Foundation
59
import BigInt

Sources/Core/Structure/Block/BlockNumber.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// File.swift
2+
// BlockNumber.swift
33
//
44
//
55
// Created by Yaroslav Yashin on 11.07.2022.

Sources/Core/Structure/Event+Protocol.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,23 @@ public protocol EventParserResultProtocol {
1616
var eventLog: EventLog? {get}
1717
}
1818

19+
public struct EventParserResult: EventParserResultProtocol {
20+
public var eventName: String
21+
public var transactionReceipt: TransactionReceipt?
22+
public var contractAddress: EthereumAddress
23+
public var decodedResult: [String: Any]
24+
public var eventLog: EventLog? = nil
25+
26+
public init(eventName: String, transactionReceipt: TransactionReceipt? = nil, contractAddress: EthereumAddress, decodedResult: [String : Any], eventLog: EventLog? = nil) {
27+
self.eventName = eventName
28+
self.transactionReceipt = transactionReceipt
29+
self.contractAddress = contractAddress
30+
self.decodedResult = decodedResult
31+
self.eventLog = eventLog
32+
}
33+
}
34+
35+
1936
/// Protocol for generic Ethereum event parser
2037
public protocol EventParserProtocol {
2138
func parseTransaction(_ transaction: EthereumTransaction) async throws -> [EventParserResultProtocol]

Sources/Core/Structure/Transaction/TransactionDetails.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
2-
1+
//
2+
// TransactionDetails.swift
3+
//
4+
//
5+
// Created by Yaroslav Yashin on 12.07.2022.
6+
//
37

48
import Foundation
59
import BigInt

Sources/Core/Structure/Transaction/TransactionInBlock.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
1+
//
2+
// TransactionInBlock.swift
3+
//
4+
//
5+
// Created by Yaroslav Yashin on 12.07.2022.
6+
//
27

38
import Foundation
49

0 commit comments

Comments
 (0)