@@ -101,7 +101,8 @@ export class Formatter {
101
101
from : Formatter . allowNull ( this . address , null ) ,
102
102
contractAddress : Formatter . allowNull ( address , null ) ,
103
103
transactionIndex : number ,
104
- root : Formatter . allowNull ( hash ) ,
104
+ // should be allowNull(hash), but broken-EIP-658 support is handled in receipt
105
+ root : Formatter . allowNull ( hex ) ,
105
106
gasUsed : bigNumber ,
106
107
logsBloom : Formatter . allowNull ( data ) , // @TODO : should this be data?
107
108
blockHash : hash ,
@@ -383,7 +384,28 @@ export class Formatter {
383
384
receipt ( value : any ) : TransactionReceipt {
384
385
const result : TransactionReceipt = Formatter . check ( this . formats . receipt , value ) ;
385
386
386
- if ( value . status != null ) {
387
+ // RSK incorrectly implemented EIP-658, so we munge things a bit here for it
388
+ if ( result . root != null ) {
389
+ if ( result . root . length <= 4 ) {
390
+ // Could be 0x00, 0x0, 0x01 or 0x1
391
+ const value = BigNumber . from ( result . root ) . toNumber ( ) ;
392
+ if ( value === 0 || value === 1 ) {
393
+ // Make sure if both are specified, they match
394
+ if ( result . status != null && ( result . status !== value ) ) {
395
+ logger . throwArgumentError ( "alt-root-status/status mismatch" , "value" , { root : result . root , status : result . status } ) ;
396
+ }
397
+ result . status = value ;
398
+ delete result . root ;
399
+ } else {
400
+ logger . throwArgumentError ( "invalid alt-root-status" , "value.root" , result . root ) ;
401
+ }
402
+ } else if ( result . root . length !== 66 ) {
403
+ // Must be a valid bytes32
404
+ logger . throwArgumentError ( "invalid root hash" , "value.root" , result . root ) ;
405
+ }
406
+ }
407
+
408
+ if ( result . status != null ) {
387
409
result . byzantium = true ;
388
410
}
389
411
0 commit comments