mirror of
https://github.com/cerc-io/watcher-ts
synced 2025-01-08 12:28:05 +00:00
Implement lazy watcher mode in erc20-watcher (#275)
This commit is contained in:
parent
3b27177389
commit
f00ea0c1f0
@ -2,6 +2,7 @@
|
||||
host = "127.0.0.1"
|
||||
port = 3001
|
||||
mode = "eth_call"
|
||||
kind = "lazy"
|
||||
|
||||
[database]
|
||||
type = "postgres"
|
||||
|
@ -15,7 +15,7 @@ import { getDefaultProvider } from 'ethers';
|
||||
|
||||
import { getCache } from '@vulcanize/cache';
|
||||
import { EthClient } from '@vulcanize/ipld-eth-client';
|
||||
import { DEFAULT_CONFIG_PATH, getConfig, JobQueue } from '@vulcanize/util';
|
||||
import { DEFAULT_CONFIG_PATH, getConfig, JobQueue, KIND_ACTIVE } from '@vulcanize/util';
|
||||
|
||||
import typeDefs from './schema';
|
||||
|
||||
@ -42,7 +42,7 @@ export const main = async (): Promise<any> => {
|
||||
|
||||
assert(config.server, 'Missing server config');
|
||||
|
||||
const { host, port, mode } = config.server;
|
||||
const { host, port, mode, kind: watcherKind } = config.server;
|
||||
|
||||
const { upstream, database: dbConfig, jobQueue: jobQueueConfig } = config;
|
||||
|
||||
@ -76,10 +76,12 @@ export const main = async (): Promise<any> => {
|
||||
assert(dbConnectionString, 'Missing job queue db connection string');
|
||||
|
||||
const jobQueue = new JobQueue({ dbConnectionString, maxCompletionLag: maxCompletionLagInSecs });
|
||||
await jobQueue.start();
|
||||
|
||||
const eventWatcher = new EventWatcher(ethClient, indexer, pubsub, jobQueue);
|
||||
await eventWatcher.start();
|
||||
|
||||
if (watcherKind === KIND_ACTIVE) {
|
||||
await jobQueue.start();
|
||||
await eventWatcher.start();
|
||||
}
|
||||
|
||||
const resolvers = process.env.MOCK ? await createMockResolvers() : await createResolvers(indexer, eventWatcher);
|
||||
|
||||
|
@ -61,6 +61,7 @@ describe('uni-info-watcher', () => {
|
||||
let config: Config;
|
||||
let uniClient: UniClient;
|
||||
let client: Client;
|
||||
let deadline: number;
|
||||
|
||||
before(async () => {
|
||||
config = await getConfig(CONFIG_FILE);
|
||||
@ -84,6 +85,11 @@ describe('uni-info-watcher', () => {
|
||||
const provider = new ethers.providers.JsonRpcProvider(rpcProviderEndpoint);
|
||||
signer = provider.getSigner();
|
||||
recipient = await signer.getAddress();
|
||||
|
||||
// Deadline set to 2 days from current date.
|
||||
const deadlineDate = new Date();
|
||||
deadlineDate.setDate(deadlineDate.getDate() + 2);
|
||||
deadline = Math.floor(deadlineDate.getTime() / 1000);
|
||||
});
|
||||
|
||||
it('should have a Factory entity', async () => {
|
||||
@ -702,7 +708,6 @@ describe('uni-info-watcher', () => {
|
||||
const amount1Desired = 15;
|
||||
const amount0Min = 0;
|
||||
const amount1Min = 0;
|
||||
const deadline = 1634367993;
|
||||
|
||||
before(async () => {
|
||||
// Get the NFPM contract address.
|
||||
@ -833,7 +838,6 @@ describe('uni-info-watcher', () => {
|
||||
const amount1Desired = 15;
|
||||
const amount0Min = 0;
|
||||
const amount1Min = 0;
|
||||
const deadline = 1634367993;
|
||||
|
||||
before(async () => {
|
||||
// Get initial entity values.
|
||||
@ -908,7 +912,6 @@ describe('uni-info-watcher', () => {
|
||||
const liquidity = 5;
|
||||
const amount0Min = 0;
|
||||
const amount1Min = 0;
|
||||
const deadline = 1634367993;
|
||||
|
||||
before(async () => {
|
||||
// Get initial entity values.
|
||||
|
@ -66,6 +66,7 @@ describe('uni-watcher', () => {
|
||||
let postgraphileClient: EthClient;
|
||||
let signer: Signer;
|
||||
let recipient: string;
|
||||
let deadline: number;
|
||||
|
||||
before(async () => {
|
||||
config = await getConfig(CONFIG_FILE);
|
||||
@ -108,6 +109,11 @@ describe('uni-watcher', () => {
|
||||
const provider = new ethers.providers.JsonRpcProvider(rpcProviderEndpoint);
|
||||
signer = provider.getSigner();
|
||||
recipient = await signer.getAddress();
|
||||
|
||||
// Deadline set to 2 days from current date.
|
||||
const deadlineDate = new Date();
|
||||
deadlineDate.setDate(deadlineDate.getDate() + 2);
|
||||
deadline = Math.floor(deadlineDate.getTime() / 1000);
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
@ -279,7 +285,6 @@ describe('uni-watcher', () => {
|
||||
const amount1Desired = 15;
|
||||
const amount0Min = 0;
|
||||
const amount1Min = 0;
|
||||
const deadline = 1634367993;
|
||||
|
||||
// Approving tokens for NonfungiblePositionManager contract.
|
||||
// https://github.com/Uniswap/uniswap-v3-periphery/blob/main/test/NonfungiblePositionManager.spec.ts#L44
|
||||
@ -344,7 +349,6 @@ describe('uni-watcher', () => {
|
||||
const amount1Desired = 15;
|
||||
const amount0Min = 0;
|
||||
const amount1Min = 0;
|
||||
const deadline = 1634367993;
|
||||
|
||||
// Subscribe using UniClient.
|
||||
const subscription = await uniClient.watchEvents((value: any) => {
|
||||
@ -388,7 +392,6 @@ describe('uni-watcher', () => {
|
||||
const liquidity = 5;
|
||||
const amount0Min = 0;
|
||||
const amount1Min = 0;
|
||||
const deadline = 1634367993;
|
||||
|
||||
// Subscribe using UniClient.
|
||||
const subscription = await uniClient.watchEvents((value: any) => {
|
||||
|
Loading…
Reference in New Issue
Block a user