feature/ethereum-service - #4
Conversation
…/Relayer.swift into feature/ethereum-service
| "method": "eth_getBalance", | ||
| "params": ["0x0F64928EcA02147075c7614A7d67B0C3Cb37D5DA", "latest"], | ||
| "id": 1] | ||
| jsonPayload = try! JSONSerialization.data(withJSONObject: payload) |
There was a problem hiding this comment.
Force tries should be avoided.
| "method": "eth_getBalance", | ||
| "params": [address, "latest"], | ||
| "id": 1] | ||
| let jsonPayload = try! JSONSerialization.data(withJSONObject: payload) |
There was a problem hiding this comment.
Force tries should be avoided.
| "method": "eth_sendRawTransaction", | ||
| "params": [signedTransaction], | ||
| "id": 1] | ||
| let jsonPayload = try! JSONSerialization.data(withJSONObject: payload) |
There was a problem hiding this comment.
Force tries should be avoided.
| "method": "eth_getTransactionCount", | ||
| "params": [address, "latest"], | ||
| "id": 1] | ||
| let jsonPayload = try! JSONSerialization.data(withJSONObject: payload) |
There was a problem hiding this comment.
Force tries should be avoided.
| } | ||
| } | ||
|
|
||
| internal func getTransactionCount(address: String, completion: @escaping (Result<Data, Error>) -> Void) { |
There was a problem hiding this comment.
Similar blocks of code found in 2 locations. Consider refactoring.
|
|
||
| // @todo handle CLI input, repl | ||
|
|
||
| let url = URL(string: "https://rinkeby.infura.io/f7a08ae0242843f1b1cf480454a6bba5")! |
There was a problem hiding this comment.
All of this stuff doesn't belong in main. This is demo code isn't it?
| }.resume() | ||
| } | ||
|
|
||
| internal func getBalance(address: String, completion: @escaping (Result<Data, Error>) -> Void) { |
There was a problem hiding this comment.
Similar blocks of code found in 2 locations. Consider refactoring.
| } | ||
|
|
||
| // handle gets called when an Ethereum service is called. | ||
| public func handle(message: Message, node: Node) { |
There was a problem hiding this comment.
Function handle has 63 lines of code (exceeds 25 allowed). Consider refactoring.
| @@ -0,0 +1,161 @@ | |||
| import Foundation | |||
There was a problem hiding this comment.
Similar blocks of code found in 2 locations. Consider refactoring.
| } | ||
|
|
||
| // handle gets called when an Ethereum service is called. | ||
| public func handle(message: Message, node: Node) { |
There was a problem hiding this comment.
Function handle has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
| } | ||
|
|
||
| // handle gets called when an Ethereum service is called. | ||
| public func handle(message: Message, node: Node) { |
There was a problem hiding this comment.
Function body should span 40 lines or less excluding comments and whitespace: currently spans 53 lines
| ] | ||
|
|
||
| // Grab two characters at a time, map them and turn it into a byte | ||
| for i in stride(from: 0, to: count, by: 2) { |
There was a problem hiding this comment.
Variable name should be between 3 and 40 characters long: 'i'
| } | ||
|
|
||
| // handle gets called when an Ethereum service is called. | ||
| public func handle(message: Message, node: Node) { |
There was a problem hiding this comment.
Function handle has 58 lines of code (exceeds 25 allowed). Consider refactoring.
| let index2 = Int(chars[i + 1] & 0x1F ^ 0x10) | ||
| bytes.append(map[index1] << 4 | map[index2]) | ||
| } | ||
|
|
There was a problem hiding this comment.
Lines should not have trailing whitespace.
| // Keep the bytes in an UInt8 array and later convert it to Data | ||
| var bytes = [UInt8]() | ||
| bytes.reserveCapacity(count / 2) | ||
|
|
There was a problem hiding this comment.
Lines should not have trailing whitespace.
| 0x00, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x00, // @ABCDEFG | ||
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // HIJKLMNO | ||
| ] | ||
|
|
There was a problem hiding this comment.
Lines should not have trailing whitespace.
| let hexDigits = Array("0123456789abcdef".utf16) | ||
| var hexChars = [UTF16.CodeUnit]() | ||
| hexChars.reserveCapacity(count * 2) | ||
|
|
There was a problem hiding this comment.
Lines should not have trailing whitespace.
| hexChars.append(hexDigits[index1]) | ||
| hexChars.append(hexDigits[index2]) | ||
| } | ||
|
|
There was a problem hiding this comment.
Lines should not have trailing whitespace.
| func hexDecodedData() -> Data { | ||
| // Get the UTF8 characters of this string | ||
| let chars = Array(utf8) | ||
|
|
There was a problem hiding this comment.
Lines should not have trailing whitespace.
| // @todo handle CLI input, repl | ||
| let service = EthereumService(url: URL(string: "https://rinkeby.infura.io/f7a08ae0242843f1b1cf480454a6bba5")!) | ||
|
|
||
|
|
There was a problem hiding this comment.
Limit vertical whitespace to a single empty line. Currently 2.
| } | ||
|
|
||
| // handle gets called when an Ethereum service is called. | ||
| public func handle(message: Message, node: Node) { |
There was a problem hiding this comment.
Function body should span 40 lines or less excluding comments and whitespace: currently spans 48 lines
| "params": params, | ||
| "id": 1 | ||
| ] | ||
| let jsonPayload = try! JSONSerialization.data(withJSONObject: payload) |
There was a problem hiding this comment.
Force tries should be avoided.
| ] | ||
| let jsonPayload = try! JSONSerialization.data(withJSONObject: payload) | ||
| request.httpBody = jsonPayload | ||
|
|
There was a problem hiding this comment.
Lines should not have trailing whitespace.
|
Code Climate has analyzed commit 2701f54 and detected 6 issues on this pull request. Here's the issue category breakdown:
View more on Code Climate. |
No description provided.