diff --git a/packages/erc20-watcher/environments/local.toml b/packages/erc20-watcher/environments/local.toml index e718d9b8..caa36115 100644 --- a/packages/erc20-watcher/environments/local.toml +++ b/packages/erc20-watcher/environments/local.toml @@ -2,6 +2,7 @@ host = "127.0.0.1" port = 3001 mode = "eth_call" + kind = "lazy" [database] type = "postgres" diff --git a/packages/erc20-watcher/src/server.ts b/packages/erc20-watcher/src/server.ts index 45d81673..9c9a992e 100644 --- a/packages/erc20-watcher/src/server.ts +++ b/packages/erc20-watcher/src/server.ts @@ -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 => { 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 => { 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); diff --git a/packages/uni-info-watcher/src/smoke.test.ts b/packages/uni-info-watcher/src/smoke.test.ts index 68996159..4ec37da8 100644 --- a/packages/uni-info-watcher/src/smoke.test.ts +++ b/packages/uni-info-watcher/src/smoke.test.ts @@ -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. diff --git a/packages/uni-watcher/src/smoke.test.ts b/packages/uni-watcher/src/smoke.test.ts index ca997181..e81a977a 100644 --- a/packages/uni-watcher/src/smoke.test.ts +++ b/packages/uni-watcher/src/smoke.test.ts @@ -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) => {