@@ -22,15 +22,14 @@ public enum APIRequest {
22
22
case getNetwork
23
23
case getAccounts
24
24
// ??
25
- case estimateGas
26
-
25
+ case estimateGas( TransactionParameters , BlockNumber )
27
26
case sendRawTransaction( Hash )
28
- case sendTransaction( TransactionParameters )
27
+ case sendTransaction( TransactionParameters , BlockNumber )
29
28
case getTransactionByHash( Hash )
30
29
case getTransactionReceipt( Hash )
31
30
case getLogs( EventFilterParameters )
32
- case personalSign( Address , Data )
33
- case call( TransactionParameters )
31
+ case personalSign( Address , String )
32
+ case call( TransactionParameters , BlockNumber )
34
33
case getTransactionCount( Address , BlockNumber )
35
34
case getBalance( Address , BlockNumber )
36
35
@@ -88,6 +87,9 @@ public enum APIRequest {
88
87
case getTxPoolInspect // No in Eth API
89
88
}
90
89
90
+ // FIXME: This conformance should be changed to `LiteralInitiableFromString`
91
+ extension Data : APIResultType { }
92
+
91
93
extension APIRequest {
92
94
public var method : REST {
93
95
switch self {
@@ -109,7 +111,21 @@ extension APIRequest {
109
111
case . getTransactionReceipt: return TransactionReceipt . self
110
112
case . createAccount: return EthereumAddress . self
111
113
case . unlockAccount: return Bool . self
112
- default : return String . self
114
+ case . getTransactionByHash: return TransactionDetails . self
115
+ case . sendTransaction: return Hash . self
116
+ case . sendRawTransaction: return Hash . self
117
+ case . estimateGas: return BigUInt . self
118
+ case . call: return Data . self
119
+ // FIXME: Not checked
120
+ case . getNetwork: return UInt . self
121
+ case . personalSign: return Data . self
122
+
123
+ // FIXME: Not implemented
124
+ case . getLogs: return String . self
125
+ case . getStorageAt: return String . self
126
+ case . getTxPoolStatus: return String . self
127
+ case . getTxPoolContent: return String . self
128
+ case . getTxPoolInspect: return String . self
113
129
}
114
130
}
115
131
@@ -122,14 +138,17 @@ extension APIRequest {
122
138
123
139
var parameters : [ RequestParameter ] {
124
140
switch self {
125
- case . gasPrice, . blockNumber, . getNetwork, . getAccounts, . estimateGas :
141
+ case . gasPrice, . blockNumber, . getNetwork, . getAccounts:
126
142
return [ RequestParameter] ( )
127
143
144
+ case . estimateGas( let transactionParameters, let blockNumber) :
145
+ return [ RequestParameter . transaction ( transactionParameters) , RequestParameter . string ( blockNumber. stringValue) ]
146
+
128
147
case let . sendRawTransaction( hash) :
129
148
return [ RequestParameter . string ( hash) ]
130
149
131
- case . sendTransaction( let transactionParameters) :
132
- return [ RequestParameter . transaction ( transactionParameters) ]
150
+ case . sendTransaction( let transactionParameters, let blockNumber ) :
151
+ return [ RequestParameter . transaction ( transactionParameters) , RequestParameter . string ( blockNumber . stringValue ) ]
133
152
134
153
case . getTransactionByHash( let hash) :
135
154
return [ RequestParameter . string ( hash) ]
@@ -140,12 +159,12 @@ extension APIRequest {
140
159
case . getLogs( let eventFilterParameters) :
141
160
return [ RequestParameter . eventFilter ( eventFilterParameters) ]
142
161
143
- case . personalSign( let address, let data ) :
162
+ case . personalSign( let address, let string ) :
144
163
// FIXME: Add second parameter
145
- return [ RequestParameter . string ( address) ]
164
+ return [ RequestParameter . string ( address) , RequestParameter . string ( string ) ]
146
165
147
- case . call( let transactionParameters) :
148
- return [ RequestParameter . transaction ( transactionParameters) ]
166
+ case . call( let transactionParameters, let blockNumber ) :
167
+ return [ RequestParameter . transaction ( transactionParameters) , RequestParameter . string ( blockNumber . stringValue ) ]
149
168
150
169
case . getTransactionCount( let address, let blockNumber) :
151
170
return [ RequestParameter . string ( address) , RequestParameter . string ( blockNumber. stringValue) ]
@@ -169,10 +188,10 @@ extension APIRequest {
169
188
return [ RequestParameter . string ( uInt. hexString) , RequestParameter . string ( blockNumber. stringValue) , RequestParameter . doubleArray ( array) ]
170
189
171
190
case . createAccount( let string) :
172
- return [ RequestParameter] ( )
191
+ return [ RequestParameter . string ( string ) ]
173
192
174
- case . unlockAccount( let address, let string, let optional ) :
175
- return [ RequestParameter] ( )
193
+ case . unlockAccount( let address, let string, let uInt ) :
194
+ return [ RequestParameter . string ( address ) , RequestParameter . string ( string ) , RequestParameter . uint ( uInt ?? 0 ) ]
176
195
177
196
case . getTxPoolStatus:
178
197
return [ RequestParameter] ( )
0 commit comments