From 30ba701d4ecdd9cf5cef6499a33b4321470004bf Mon Sep 17 00:00:00 2001 From: Kevin Burton Date: Wed, 7 Aug 2024 17:08:36 -0700 Subject: [PATCH] Fixed more errors. --- libs/model/src/chain-events/ChainEventCreated.command.ts | 2 +- libs/model/src/contest/Contests.projection.ts | 2 ++ libs/model/src/globalActivityCache.ts | 1 + libs/model/src/middleware/authorization.ts | 2 ++ libs/model/src/models/index.ts | 2 ++ libs/model/src/services/commonProtocol/contestHelper.ts | 1 + libs/model/src/tester/bootstrap.ts | 1 + libs/model/src/thread/GetBulkThread.query.ts | 2 +- libs/sitemaps/src/createDatabasePaginator.ts | 3 +++ 9 files changed, 14 insertions(+), 2 deletions(-) diff --git a/libs/model/src/chain-events/ChainEventCreated.command.ts b/libs/model/src/chain-events/ChainEventCreated.command.ts index f00e2799eca..5f4b2e75cc8 100644 --- a/libs/model/src/chain-events/ChainEventCreated.command.ts +++ b/libs/model/src/chain-events/ChainEventCreated.command.ts @@ -61,7 +61,7 @@ export function ChainEventCreated(): Command { return { ...schemas.ChainEventCreated, auth: [], - // eslint-disable-next-line @typescript-eslint/no-unused-vars + // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/require-await body: async ({ payload }) => { // The name of the chain e.g. BaseSepolia (ex webhook url: /v1/rest/chainevent/ChainEventCreated/BaseSepolia) // let chain = id!; diff --git a/libs/model/src/contest/Contests.projection.ts b/libs/model/src/contest/Contests.projection.ts index fcaa4520c49..edc100c4187 100644 --- a/libs/model/src/contest/Contests.projection.ts +++ b/libs/model/src/contest/Contests.projection.ts @@ -301,6 +301,8 @@ export function Contests(): Projection { thread_id: add_action!.thread_id, created_at: new Date(), }); + + // eslint-disable-next-line @typescript-eslint/no-misused-promises setImmediate(() => updateScore(payload.contest_address, contest_id)); }, }, diff --git a/libs/model/src/globalActivityCache.ts b/libs/model/src/globalActivityCache.ts index 4271eeeae53..cc9a1839c78 100644 --- a/libs/model/src/globalActivityCache.ts +++ b/libs/model/src/globalActivityCache.ts @@ -125,6 +125,7 @@ export class GlobalActivityCache { public async start() { await this.refreshGlobalActivity(); + // eslint-disable-next-line @typescript-eslint/no-misused-promises setInterval(this.refreshGlobalActivity.bind(this), this._cacheTTL * 1000); } diff --git a/libs/model/src/middleware/authorization.ts b/libs/model/src/middleware/authorization.ts index 511011c9f47..dbbccea9d18 100644 --- a/libs/model/src/middleware/authorization.ts +++ b/libs/model/src/middleware/authorization.ts @@ -96,6 +96,7 @@ export const loadThread: ThreadMiddleware = async ({ payload }) => { return thread; }; +// eslint-disable-next-line @typescript-eslint/require-await export const isThreadAuthor: ThreadMiddleware = async ({ actor }, state) => { // super admin is always allowed if (actor.user.isAdmin) return; @@ -125,6 +126,7 @@ export const loadComment: CommentMiddleware = async ({ payload }) => { return comment; }; +// eslint-disable-next-line @typescript-eslint/require-await export const isCommentAuthor: CommentMiddleware = async ({ actor }, state) => { // super admin is always allowed if (actor.user.isAdmin) return; diff --git a/libs/model/src/models/index.ts b/libs/model/src/models/index.ts index 2c26d8dbae3..3bc965b8a3f 100644 --- a/libs/model/src/models/index.ts +++ b/libs/model/src/models/index.ts @@ -12,11 +12,13 @@ export const syncDb = async (db: DB, log = false) => { const fks = Object.keys(Factories).flatMap( (k) => db[k as keyof typeof Factories]._fks, ); + // eslint-disable-next-line @typescript-eslint/no-misused-promises fks.forEach((fk) => dropFk(db.sequelize, fk)); await db.sequelize.sync({ force: true, logging: log ? console.log : false, }); + // eslint-disable-next-line @typescript-eslint/no-misused-promises fks.forEach((fk) => createFk(db.sequelize, fk)); }; diff --git a/libs/model/src/services/commonProtocol/contestHelper.ts b/libs/model/src/services/commonProtocol/contestHelper.ts index e949fb2e8f6..ab854a99edd 100644 --- a/libs/model/src/services/commonProtocol/contestHelper.ts +++ b/libs/model/src/services/commonProtocol/contestHelper.ts @@ -35,6 +35,7 @@ export type ContestScores = { * @param rpc the rpc of the network to use helper with * @returns */ +// eslint-disable-next-line @typescript-eslint/require-await const createWeb3Provider = async (rpc: string): Promise => { if (!config.WEB3.PRIVATE_KEY) throw new AppError('WEB3 private key not set!'); const web3 = new Web3(rpc); diff --git a/libs/model/src/tester/bootstrap.ts b/libs/model/src/tester/bootstrap.ts index 188675cdc03..2f7dfe28d47 100644 --- a/libs/model/src/tester/bootstrap.ts +++ b/libs/model/src/tester/bootstrap.ts @@ -34,6 +34,7 @@ export const verify_db = async (name: string): Promise => { console.error(`Error verifying db [${name}]:`, error); throw error; } finally { + // eslint-disable-next-line @typescript-eslint/no-floating-promises pg && pg.close(); } }; diff --git a/libs/model/src/thread/GetBulkThread.query.ts b/libs/model/src/thread/GetBulkThread.query.ts index e9f76b33cad..7f6004bf867 100644 --- a/libs/model/src/thread/GetBulkThread.query.ts +++ b/libs/model/src/thread/GetBulkThread.query.ts @@ -189,7 +189,7 @@ export function GetBulkThreads(): Query { } // transform thread response - let threads = responseThreads.map(async (t: any) => { + let threads = responseThreads.map((t: any) => { const collaborators = JSON.parse(t.collaborators[0]).address?.length ? t.collaborators.map((c: any) => JSON.parse(c)) : []; diff --git a/libs/sitemaps/src/createDatabasePaginator.ts b/libs/sitemaps/src/createDatabasePaginator.ts index 8419626565b..4009e2cdc2f 100644 --- a/libs/sitemaps/src/createDatabasePaginator.ts +++ b/libs/sitemaps/src/createDatabasePaginator.ts @@ -134,6 +134,7 @@ export function createDatabasePaginatorWithAdapter( let records: ReadonlyArray = []; + // eslint-disable-next-line @typescript-eslint/require-await async function hasNext() { return idx === 0 || records.length !== 0; } @@ -187,10 +188,12 @@ export function createDatabasePaginatorMockForTable( let idx = 0; + // eslint-disable-next-line @typescript-eslint/require-await async function hasNext() { return pageIdx <= maxPages; } + // eslint-disable-next-line @typescript-eslint/require-await async function next(): Promise { ++pageIdx; const links = [