diff --git a/packages/core/src/api.ts b/packages/core/src/api.ts index 085d388a..0af67388 100644 --- a/packages/core/src/api.ts +++ b/packages/core/src/api.ts @@ -106,6 +106,10 @@ export class Api { return this.send
('chain_getHeader', hash ? [hash] : [], !!hash) } + async getFinalizedHead() { + return this.send('chain_getFinalizedHead', []) + } + async getBlock(hash?: string) { return this.send('chain_getBlock', hash ? [hash] : [], !!hash) } diff --git a/packages/core/src/genesis-provider.ts b/packages/core/src/genesis-provider.ts index fbb7deba..24114d2a 100644 --- a/packages/core/src/genesis-provider.ts +++ b/packages/core/src/genesis-provider.ts @@ -158,6 +158,7 @@ export class GenesisProvider implements ProviderInterface { case 'chain_getBlock': return this.getBlock() case 'chain_getBlockHash': + case 'chain_getFinalizedHead': return this.blockHash case 'state_getKeysPaged': case 'state_getKeysPagedAt': { diff --git a/packages/core/src/setup.ts b/packages/core/src/setup.ts index ba81dc1c..b1b6e4af 100644 --- a/packages/core/src/setup.ts +++ b/packages/core/src/setup.ts @@ -50,7 +50,7 @@ export const processOptions = async (options: SetupOptions) => { let blockHash: string if (options.block == null) { - blockHash = await api.getBlockHash().then((hash) => { + blockHash = await api.getFinalizedHead().then((hash) => { if (!hash) { // should not happen, but just in case throw new Error('Cannot find block hash') diff --git a/packages/e2e/src/connect-horizontal.test.ts b/packages/e2e/src/connect-horizontal.test.ts index caab6ab0..7ad22211 100644 --- a/packages/e2e/src/connect-horizontal.test.ts +++ b/packages/e2e/src/connect-horizontal.test.ts @@ -14,7 +14,7 @@ describe('connectHorizontal', () => { }, }) const zeitgeist = await setupContext({ - endpoint: ['wss://main.rpc.zeitgeist.pm/ws', 'wss://zeitgeist.api.onfinality.io/public-ws'], + endpoint: ['wss://zeitgeist.api.onfinality.io/public-ws'], blockNumber: 5084336, db: !process.env.RUN_TESTS_WITHOUT_DB ? 'e2e-tests-db.sqlite' : undefined, })