@@ -103,7 +103,7 @@ export class Eth {
103
103
104
104
/**
105
105
* Executes a new message call immediately without creating a transaction on the block chain.
106
- * Currently only "latest" block number is supported.
106
+ * Currently only "latest" block is supported.
107
107
* @param params An array of two parameters:
108
108
* 1. The transaction object
109
109
* * from (optional) - The address the transaction is sent from
@@ -118,12 +118,13 @@ export class Eth {
118
118
async call ( params : [ RpcCallTx , string ] ) {
119
119
const [ transaction , blockOpt ] = params
120
120
121
- const latestBlockNumber = await this . blockNumber ( )
122
- if ( blockOpt !== 'latest' && blockOpt !== latestBlockNumber ) {
123
- // todo: this can be resolved with some kind of functionality of stateAt(blockNumber)
124
- return {
125
- code : INVALID_PARAMS ,
126
- message : `Currently only block option "latest" supported` ,
121
+ if ( blockOpt !== 'latest' ) {
122
+ const latest = await this . blockNumber ( )
123
+ if ( blockOpt !== latest ) {
124
+ return {
125
+ code : INVALID_PARAMS ,
126
+ message : `Currently only "latest" block supported` ,
127
+ }
127
128
}
128
129
}
129
130
@@ -156,7 +157,7 @@ export class Eth {
156
157
* The transaction will not be added to the blockchain.
157
158
* Note that the estimate may be significantly more than the amount of gas actually used by the transaction,
158
159
* for a variety of reasons including EVM mechanics and node performance.
159
- * Currently only "latest" block number is supported.
160
+ * Currently only "latest" block is supported.
160
161
* @param params An array of two parameters:
161
162
* 1. The transaction object
162
163
* * from (optional) - The address the transaction is sent from
@@ -171,12 +172,13 @@ export class Eth {
171
172
async estimateGas ( params : [ RpcCallTx , string ] ) {
172
173
const [ transaction , blockOpt ] = params
173
174
174
- const latestBlockNumber = await this . blockNumber ( )
175
- if ( blockOpt !== 'latest' && blockOpt !== latestBlockNumber ) {
176
- // todo: this can be resolved with some kind of functionality of stateAt(blockNumber)
177
- return {
178
- code : INVALID_PARAMS ,
179
- message : `Currently only block option "latest" supported` ,
175
+ if ( blockOpt !== 'latest' ) {
176
+ const latest = await this . blockNumber ( )
177
+ if ( blockOpt !== latest ) {
178
+ return {
179
+ code : INVALID_PARAMS ,
180
+ message : `Currently only "latest" block supported` ,
181
+ }
180
182
}
181
183
}
182
184
@@ -211,20 +213,21 @@ export class Eth {
211
213
212
214
/**
213
215
* Returns the balance of the account at the given address.
214
- * Currently only "latest" block number is supported.
216
+ * Currently only "latest" block is supported.
215
217
* @param params An array of two parameters:
216
218
* 1. address of the account
217
219
* 2. integer block number, or the string "latest", "earliest" or "pending"
218
220
*/
219
221
async getBalance ( params : [ string , string ] ) {
220
222
const [ addressHex , blockOpt ] = params
221
223
222
- const latestBlockNumber = await this . blockNumber ( )
223
- if ( blockOpt !== 'latest' && blockOpt !== latestBlockNumber ) {
224
- // todo: this can be resolved with some kind of functionality of stateAt(blockNumber)
225
- return {
226
- code : INVALID_PARAMS ,
227
- message : `Currently only block option "latest" supported` ,
224
+ if ( blockOpt !== 'latest' ) {
225
+ const latest = await this . blockNumber ( )
226
+ if ( blockOpt !== latest ) {
227
+ return {
228
+ code : INVALID_PARAMS ,
229
+ message : `Currently only "latest" block supported` ,
230
+ }
228
231
}
229
232
}
230
233
@@ -284,20 +287,21 @@ export class Eth {
284
287
285
288
/**
286
289
* Returns code of the account at the given address.
287
- * Currently only "latest" block number is supported.
290
+ * Currently only "latest" block is supported.
288
291
* @param params An array of two parameters:
289
292
* 1. address of the account
290
293
* 2. integer block number, or the string "latest", "earliest" or "pending"
291
294
*/
292
295
async getCode ( params : [ string , string ] ) {
293
296
const [ addressHex , blockOpt ] = params
294
297
295
- const latestBlockNumber = await this . blockNumber ( )
296
- if ( blockOpt !== 'latest' && blockOpt !== latestBlockNumber ) {
297
- // todo: this can be resolved with some kind of functionality of stateAt(blockNumber)
298
- return {
299
- code : INVALID_PARAMS ,
300
- message : `Currently only block option "latest" supported` ,
298
+ if ( blockOpt !== 'latest' ) {
299
+ const latest = await this . blockNumber ( )
300
+ if ( blockOpt !== latest ) {
301
+ return {
302
+ code : INVALID_PARAMS ,
303
+ message : `Currently only "latest" block supported` ,
304
+ }
301
305
}
302
306
}
303
307
@@ -311,7 +315,7 @@ export class Eth {
311
315
312
316
/**
313
317
* Returns the value from a storage position at a given address.
314
- * Currently only "latest" block number is supported.
318
+ * Currently only "latest" block is supported.
315
319
* @param params An array of three parameters:
316
320
* 1. address of the storage
317
321
* 2. integer of the position in the storage
@@ -320,12 +324,13 @@ export class Eth {
320
324
async getStorageAt ( params : [ string , string , string ] ) {
321
325
const [ addressHex , positionHex , blockOpt ] = params
322
326
323
- const latestBlockNumber = await this . blockNumber ( )
324
- if ( blockOpt !== 'latest' && blockOpt !== latestBlockNumber ) {
325
- // todo: this can be resolved with some kind of functionality of stateAt(blockNumber)
326
- return {
327
- code : INVALID_PARAMS ,
328
- message : `Currently only block option "latest" supported` ,
327
+ if ( blockOpt !== 'latest' ) {
328
+ const latest = await this . blockNumber ( )
329
+ if ( blockOpt !== latest ) {
330
+ return {
331
+ code : INVALID_PARAMS ,
332
+ message : `Currently only "latest" block supported` ,
333
+ }
329
334
}
330
335
}
331
336
@@ -342,20 +347,21 @@ export class Eth {
342
347
343
348
/**
344
349
* Returns the number of transactions sent from an address.
345
- * Currently only "latest" block number is supported.
350
+ * Currently only "latest" block is supported.
346
351
* @param params An array of two parameters:
347
352
* 1. address of the account
348
353
* 2. integer block number, or the string "latest", "earliest" or "pending"
349
354
*/
350
355
async getTransactionCount ( params : [ string , string ] ) {
351
356
const [ addressHex , blockOpt ] = params
352
357
353
- const latestBlockNumber = await this . blockNumber ( )
354
- if ( blockOpt !== 'latest' && blockOpt !== latestBlockNumber ) {
355
- // todo: this can be resolved with some kind of functionality of stateAt(blockNumber)
356
- return {
357
- code : INVALID_PARAMS ,
358
- message : `Currently only block option "latest" supported` ,
358
+ if ( blockOpt !== 'latest' ) {
359
+ const latest = await this . blockNumber ( )
360
+ if ( blockOpt !== latest ) {
361
+ return {
362
+ code : INVALID_PARAMS ,
363
+ message : `Currently only "latest" block supported` ,
364
+ }
359
365
}
360
366
}
361
367
0 commit comments