mirror of
https://github.com/cerc-io/watcher-ts
synced 2026-09-08 16:54:08 +00:00
Pass provider while instantiating the loader and use block hash while making the eth-calls (#74)
* Pass provider while instantiating the loader * Use custom provider for graph-node tests * Use block hash while making an eth-call
This commit is contained in:
@@ -2,17 +2,27 @@
|
||||
// Copyright 2021 Vulcanize, Inc.
|
||||
//
|
||||
|
||||
import { BaseProvider } from '@ethersproject/providers';
|
||||
import { getCustomProvider } from '@vulcanize/util';
|
||||
|
||||
import { EventData } from '../../src/utils';
|
||||
import { Database } from '../../src/database';
|
||||
import { Indexer } from './indexer';
|
||||
|
||||
const NETWORK_URL = 'http://127.0.0.1:8081';
|
||||
|
||||
export const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
|
||||
export const ZERO_HASH = '0x0000000000000000000000000000000000000000000000000000000000000000';
|
||||
|
||||
export const getDummyEventData = (): EventData => {
|
||||
export const getDummyEventData = async (): Promise<EventData> => {
|
||||
// Get the latest mined block from the chain.
|
||||
const provider = getCustomProvider(NETWORK_URL);
|
||||
const blockNumber = await provider.getBlockNumber();
|
||||
const ethersBlock = await provider.getBlock(blockNumber);
|
||||
|
||||
const block = {
|
||||
blockHash: ZERO_HASH,
|
||||
blockNumber: '0',
|
||||
blockHash: ethersBlock.hash,
|
||||
blockNumber: ethersBlock.number.toString(),
|
||||
timestamp: '0',
|
||||
parentHash: ZERO_HASH,
|
||||
stateRoot: ZERO_HASH,
|
||||
@@ -58,3 +68,9 @@ export const getTestDatabase = (): Database => {
|
||||
export const getTestIndexer = (): Indexer => {
|
||||
return new Indexer();
|
||||
};
|
||||
|
||||
export const getTestProvider = (): BaseProvider => {
|
||||
const provider = getCustomProvider(NETWORK_URL);
|
||||
|
||||
return provider;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user