Skip to content

Commit

Permalink
fix get genesis block
Browse files Browse the repository at this point in the history
  • Loading branch information
shunjizhan committed Nov 6, 2024
1 parent 36f310b commit 4f0fa5a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/eth-providers/src/base-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import {
CACHE_SIZE_WARNING,
DUMMY_BLOCK_NONCE,
DUMMY_LOGS_BLOOM,
DUMMY_SUBSTRATE_ADDR,
EMPTY_HEX_STRING,
EMTPY_UNCLES,
EMTPY_UNCLE_HASH,
Expand Down Expand Up @@ -624,8 +625,8 @@ export abstract class BaseProvider extends AbstractProvider {
this.subql?.getAllReceiptsAtBlock(blockHash),
]);

// blockscout need `toLowerCase`
const author = (await this.getEvmAddress(headerExtended.author.toString(), blockHash)).toLowerCase();
const authorSubstrate = headerExtended.author?.toString() ?? DUMMY_SUBSTRATE_ADDR;
const author = (await this.getEvmAddress(authorSubstrate, blockHash)).toLowerCase(); // blockscout need `toLowerCase`

let receipts: TransactionReceipt[];
if (receiptsFromSubql?.length) {
Expand Down
1 change: 1 addition & 0 deletions packages/eth-providers/src/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const U64MAX = BigNumber.from('0xffffffffffffffff');

export const DUMMY_BLOCK_HASH = '0xdummydummy';
export const DUMMY_ADDRESS = '0x1111111111333333333355555555558888888888';
export const DUMMY_SUBSTRATE_ADDR = '22vb7enW9XTfneQYsBNMdnzg1GDXqgtSMGBJp96C1ge971My';
export const DUMMY_LOGS_BLOOM =
'0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';
export const DUMMY_V = '0x25';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ import { deployErc20, eth_getBlockByHash, eth_getBlockByNumber, testSetup } from
const { wallet, provider } = testSetup;

describe('eth_getBlockByNumber and eth_getBlockByHash', () => {
it('get genesis block info', async () => {
const res = (await eth_getBlockByNumber(['0x0', false])).data.result;
expect(res.number).to.eq('0x0');

const genesisHash = res.hash;
const resByHash = (await eth_getBlockByHash([genesisHash, false])).data.result;
expect(resByHash).to.deep.equal(res);
});

it('get correct block info', async () => {
const token = await deployErc20(wallet);
const txHash = token.deployTransaction.hash;
Expand Down

0 comments on commit 4f0fa5a

Please sign in to comment.