@@ -176,11 +176,35 @@ const numberToHexLC = (num: number): string => {
176
176
return numberToHex ( num ) . toLowerCase ( )
177
177
}
178
178
179
+ const ZEROED_HEX_256 =
180
+ '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
179
181
const ZEROED_HEX_32 = '0x0000000000000000000000000000000000000000000000000000000000000000'
180
182
const ZEROED_HEX_20 = '0x0000000000000000000000000000000000000000'
181
183
const ZEROED_HEX_8 = '0x0000000000000000'
182
184
const ZEROED_HEX = '0x0'
183
185
186
+ const BLOCK_ZERO : IEthBlock = {
187
+ number : ZEROED_HEX ,
188
+ hash : '0x0000000000000000000000000000000000000000000000000000000000000001' ,
189
+ parentHash : ZEROED_HEX_32 ,
190
+ nonce : ZEROED_HEX_8 ,
191
+ sha3Uncles : ZEROED_HEX_32 ,
192
+ logsBloom : ZEROED_HEX_256 ,
193
+ transactionsRoot : ZEROED_HEX_32 ,
194
+ stateRoot : ZEROED_HEX_32 ,
195
+ receiptsRoot : ZEROED_HEX_32 ,
196
+ miner : ZEROED_HEX_20 ,
197
+ difficulty : ZEROED_HEX ,
198
+ totalDifficulty : ZEROED_HEX ,
199
+ extraData : ZEROED_HEX ,
200
+ size : ZEROED_HEX ,
201
+ gasLimit : ZEROED_HEX ,
202
+ gasUsed : ZEROED_HEX ,
203
+ timestamp : '0x5af97a40' ,
204
+ transactions : [ ] ,
205
+ uncles : [ ]
206
+ }
207
+
184
208
/**
185
209
* Web3 provider that interacts with EVM contracts deployed on Loom DAppChains.
186
210
*/
@@ -502,6 +526,10 @@ export class LoomProvider {
502
526
const blockHash = payload . params [ 0 ]
503
527
const isFull = payload . params [ 1 ] || true
504
528
529
+ if ( blockHash === ZEROED_HEX_32 ) {
530
+ return Promise . resolve ( BLOCK_ZERO )
531
+ }
532
+
505
533
const result = await this . _client . getEvmBlockByHashAsync ( blockHash , isFull )
506
534
507
535
if ( ! result ) {
@@ -515,6 +543,11 @@ export class LoomProvider {
515
543
const blockNumberToSearch =
516
544
payload . params [ 0 ] === 'latest' ? payload . params [ 0 ] : hexToNumber ( payload . params [ 0 ] )
517
545
const isFull = payload . params [ 1 ] || true
546
+
547
+ if ( blockNumberToSearch === 0 ) {
548
+ return Promise . resolve ( BLOCK_ZERO )
549
+ }
550
+
518
551
const result = await this . _client . getEvmBlockByNumberAsync ( `${ blockNumberToSearch } ` , isFull )
519
552
520
553
if ( ! result ) {
@@ -770,10 +803,9 @@ export class LoomProvider {
770
803
}
771
804
} )
772
805
773
- // TODO: Should be on backed
774
- // Ugly fix, since block 0x1 has a parent hash block ZEROED_HEX_32
806
+ // Parent hash is empty for the block 0x1 so this fix it
775
807
if ( parentHash === '0x' && number === '0x1' ) {
776
- parentHash = ZEROED_HEX_32
808
+ parentHash = '0x0000000000000000000000000000000000000000000000000000000000000001'
777
809
}
778
810
779
811
// Some ZEROED values aren't at the moment
0 commit comments