@@ -24,6 +24,13 @@ const throwCombinedError = (filename, errors) => {
24
24
)
25
25
}
26
26
27
+ // Define conversions from a 'blockFormat' value in the manifest to its corresponding struct name
28
+ const blockFormatToStructName = immutable . Map ( {
29
+ 'block-only' : 'Block' ,
30
+ 'block-with-transactions' : 'BlockWithTransactions' ,
31
+ 'block-with-receipts' : 'BlockWithReceipts' ,
32
+ } )
33
+
27
34
const buildCombinedWarning = ( filename , warnings ) =>
28
35
warnings . size > 0
29
36
? warnings . reduce (
@@ -343,7 +350,7 @@ ${abiFunctions
343
350
)
344
351
345
352
// Ensure each blockHandler has a corresponding mapping handler
346
- // with a compatible function signature
353
+ // with a compatible function signature and uses a supported `blockFormat` value.
347
354
return errors . concat (
348
355
blockHandlers . reduce (
349
356
( errors , handler , index ) =>
@@ -358,28 +365,43 @@ ${abiFunctions
358
365
functionDeclaration =>
359
366
functionDeclaration . name . text === handler . get ( 'handler' ) &&
360
367
functionDeclaration . signature . parameters . length === 1 &&
361
- functionDeclaration . signature . parameters [ 0 ] . name . text ==
362
- 'block' &&
363
368
functionDeclaration . signature . parameters [ 0 ] . type . name . identifier
364
369
. text === 'ethereum' &&
365
370
functionDeclaration . signature . parameters [ 0 ] . type . name . next
366
- . identifier . text === handler . get ( 'input' , 'Block' ) &&
371
+ . identifier . text ===
372
+ blockFormatToStructName . get (
373
+ handler . get ( 'blockFormat' , 'block-only' ) ,
374
+ ) &&
367
375
functionDeclaration . signature . parameters [ 0 ] . type . name . next
368
376
. next === null &&
369
377
functionDeclaration . signature . returnType . name . identifier . text ===
370
378
'void' ,
371
379
) ,
372
380
)
373
381
? errors
374
- : errors . push (
382
+ : blockFormatToStructName . get ( handler . get ( 'blockFormat' , 'block-only' ) )
383
+ ? errors . push (
375
384
immutable . fromJS ( {
376
385
path : [ ...path , index ] ,
377
386
message : `\
378
387
Matching mapping handler not found in '${ mappingFile } ' for blockHandler: '${ handler . get (
379
388
'handler' ,
380
389
) } '.
381
- Signature:
382
- ${ handler . get ( 'handler' ) } (block: ethereum.${ handler . get ( 'input' , 'Block' ) } ): void` ,
390
+ Signature:
391
+ ${ handler . get ( 'handler' ) } (block: ethereum.${ blockFormatToStructName . get (
392
+ handler . get ( 'blockFormat' , 'block-only' ) ,
393
+ ) } ): void`,
394
+ } ) ,
395
+ )
396
+ : errors . push (
397
+ immutable . fromJS ( {
398
+ path : [ ...path , index ] ,
399
+ message : `Unsupported blockFormat, '${ handler . get (
400
+ 'blockFormat' ,
401
+ ) } ', specified for the '${ handler . get ( 'handler' ) } ' blockHandler.
402
+ Please use one of the supported blockFormats: ${ JSON . stringify (
403
+ blockFormatToStructName . keySeq ( ) ,
404
+ ) } `,
383
405
} ) ,
384
406
) ,
385
407
immutable . List ( ) ,
0 commit comments