Skip to content

Commit

Permalink
fix: Remove queryInterface refference
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosvdr committed Jul 10, 2024
1 parent 0abd643 commit f0168e8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 16 deletions.
1 change: 0 additions & 1 deletion packages/indexer-agent/src/commands/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,6 @@ export async function run(
queryFeeModels,
graphNode,
metrics,
sequelize.getQueryInterface(),
),
)

Expand Down
13 changes: 4 additions & 9 deletions packages/indexer-common/src/allocations/query-fees.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,11 @@ import {
} from '..'
import { DHeap } from '@thi.ng/heaps'
import { BigNumber, BigNumberish, Contract } from 'ethers'
import { Op } from 'sequelize'
import { Op, Sequelize } from 'sequelize';
import pReduce from 'p-reduce'
import { TAPSubgraph } from '../tap-subgraph'
import { NetworkSubgraph } from '../network-subgraph'
import gql from 'graphql-tag'
import { QueryInterface } from 'sequelize'

// Receipts are collected with a delay of 20 minutes after
// the corresponding allocation was closed
Expand Down Expand Up @@ -89,7 +88,6 @@ export interface AllocationReceiptCollectorOptions {
networkSpecification: spec.NetworkSpecification
tapSubgraph: TAPSubgraph | undefined
networkSubgraph: NetworkSubgraph
queryInterface: QueryInterface
}

export interface ReceiptCollector {
Expand Down Expand Up @@ -127,7 +125,6 @@ export class AllocationReceiptCollector implements ReceiptCollector {
declare tapSubgraph: TAPSubgraph | undefined
declare networkSubgraph: NetworkSubgraph
declare finalityTime: number
declare queryInterface: QueryInterface

// eslint-disable-next-line @typescript-eslint/no-empty-function -- Private constructor to prevent direct instantiation
private constructor() {}
Expand All @@ -143,7 +140,6 @@ export class AllocationReceiptCollector implements ReceiptCollector {
networkSpecification,
tapSubgraph,
networkSubgraph,
queryInterface,
}: AllocationReceiptCollectorOptions): Promise<AllocationReceiptCollector> {
const collector = new AllocationReceiptCollector()
collector.logger = logger.child({ component: 'AllocationReceiptCollector' })
Expand All @@ -159,7 +155,6 @@ export class AllocationReceiptCollector implements ReceiptCollector {
collector.protocolNetwork = networkSpecification.networkIdentifier
collector.tapSubgraph = tapSubgraph
collector.networkSubgraph = networkSubgraph
collector.queryInterface = queryInterface

// Process Gateway routes
const gatewayUrls = processGatewayRoutes(networkSpecification.gateway.url)
Expand Down Expand Up @@ -619,7 +614,7 @@ export class AllocationReceiptCollector implements ReceiptCollector {
SET redeemed_at = NULL
WHERE allocation_id IN ('${nonRedeemedAllocationIDsTrunc.join("', '")}')
`
await this.queryInterface.sequelize.query(query)
await this.models.receiptAggregateVouchers.sequelize?.query(query)

// // Update those that redeemed_at is older than 60 minutes and mark as final
query = `
Expand All @@ -629,7 +624,7 @@ export class AllocationReceiptCollector implements ReceiptCollector {
AND redeemed_at < NOW() - INTERVAL '${this.finalityTime} second'
AND redeemed_at IS NOT NULL
`
await this.queryInterface.sequelize.query(query)
await this.models.receiptAggregateVouchers.sequelize?.query(query)

return await this.models.receiptAggregateVouchers.findAll({
where: { redeemedAt: null, final: false, last: true },
Expand Down Expand Up @@ -955,7 +950,7 @@ export class AllocationReceiptCollector implements ReceiptCollector {
SET redeemed_at = NOW()
WHERE allocation_id = '${addressWithoutPrefix}'
`
await this.queryInterface.sequelize.query(query)
await this.models.receiptAggregateVouchers.sequelize?.query(query)

logger.info(
`Updated receipt aggregate vouchers table with redeemed_at for allocation ${addressWithoutPrefix}`,
Expand Down
6 changes: 0 additions & 6 deletions packages/indexer-common/src/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import { QueryFeeModels } from './query-fees'
import { readFileSync } from 'fs'

import { TAPSubgraph } from './tap-subgraph'
import { QueryInterface } from 'sequelize'

export class Network {
logger: Logger
Expand All @@ -48,7 +47,6 @@ export class Network {
specification: spec.NetworkSpecification
paused: Eventual<boolean>
isOperator: Eventual<boolean>
queryInterface: QueryInterface | undefined

private constructor(
logger: Logger,
Expand All @@ -62,7 +60,6 @@ export class Network {
specification: spec.NetworkSpecification,
paused: Eventual<boolean>,
isOperator: Eventual<boolean>,
queryInterface?: QueryInterface,
) {
this.logger = logger
this.contracts = contracts
Expand All @@ -75,7 +72,6 @@ export class Network {
this.specification = specification
this.paused = paused
this.isOperator = isOperator
this.queryInterface = queryInterface
}

static async create(
Expand All @@ -84,7 +80,6 @@ export class Network {
queryFeeModels: QueryFeeModels,
graphNode: GraphNode,
metrics: Metrics,
queryInterface?: QueryInterface,
): Promise<Network> {
// Incomplete logger for initial operations, will be replaced as new labels emerge.
let logger = parentLogger.child({
Expand Down Expand Up @@ -280,7 +275,6 @@ export class Network {
networkSpecification: specification,
tapSubgraph,
networkSubgraph,
queryInterface: queryInterface!,
})

// --------------------------------------------------------------------------------
Expand Down

0 comments on commit f0168e8

Please sign in to comment.