@@ -48,6 +48,11 @@ function rpc(PORT, client, transactionHandler, stateDB, blockDB) {
48
48
49
49
break ;
50
50
51
+ case "mining" :
52
+ respond ( { mining : client . mining } ) ;
53
+
54
+ break ;
55
+
51
56
default :
52
57
throwError ( "Invalid option." , 404 ) ;
53
58
}
@@ -158,7 +163,7 @@ function rpc(PORT, client, transactionHandler, stateDB, blockDB) {
158
163
throwError ( "Invalid request." , 400 ) ;
159
164
} else {
160
165
const dataFromTarget = await stateDB . get ( req . body . params . address ) ; // Fetch target's state object
161
- const targetBalance = dataFromTarget . balance ; // Get target's balance
166
+ const targetBalance = dataFromTarget . balance ; // Get target's balance
162
167
163
168
respond ( { balance : targetBalance } ) ;
164
169
}
@@ -169,18 +174,34 @@ function rpc(PORT, client, transactionHandler, stateDB, blockDB) {
169
174
if (
170
175
typeof req . body . params !== "object" ||
171
176
typeof req . body . params . address !== "string" ||
172
- ! ( await stateDB . keys ( ) . all ( ) ) . includes ( tx . sender )
177
+ ! ( await stateDB . keys ( ) . all ( ) ) . includes ( req . body . params . address )
173
178
) {
174
179
throwError ( "Invalid request." , 400 ) ;
175
180
} else {
176
- const dataFromTarget = await stateDB . get ( tx . sender ) ; // Fetch target's state object
177
- const targetBody = dataFromTarget . body ; // Get target's code body
181
+ const dataFromTarget = await stateDB . get ( req . body . params . address ) ; // Fetch target's state object
182
+ const targetBody = dataFromTarget . body ; // Get target's code body
178
183
179
184
respond ( { code : targetBody } ) ;
180
185
}
181
186
182
187
break ;
183
188
189
+ case "get_storage" :
190
+ if (
191
+ typeof req . body . params !== "object" ||
192
+ typeof req . body . params . address !== "string" ||
193
+ ! ( await stateDB . keys ( ) . all ( ) ) . includes ( req . body . params . address )
194
+ ) {
195
+ throwError ( "Invalid request." , 400 ) ;
196
+ } else {
197
+ const dataFromTarget = await stateDB . get ( req . body . params . address ) ; // Fetch target's state object
198
+ const targetStorage = dataFromTarget . body ; // Get target's storage object
199
+
200
+ respond ( { storage : targetStorage } ) ;
201
+ }
202
+
203
+ break ;
204
+
184
205
case "get_transactionByBlockNumberAndIndex" :
185
206
if (
186
207
typeof req . body . params !== "object" ||
0 commit comments