diff --git a/package.json b/package.json index 495417d..e3e8ca3 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "**/*.{test,spec}.ts": [ "node scripts/check-test-files.js" ], - "{src,frontend/src}/**/*.ts?(x)": [ + "src/**/!(*d).ts": [ "prettier --write", "eslint --fix", "prettier --check", @@ -42,6 +42,13 @@ "pnpm test:related", "pnpm smoke-test:precommit" ], + "frontend/src/**/*.ts?(x)": [ + "prettier --write", + "eslint --fix", + "prettier --check", + "eslint --max-warnings 0", + "tsc --noEmit --skipLibCheck" + ], "*.{json,md}": [ "prettier --write", "prettier --check" diff --git a/src/routes.ts b/src/routes.ts index 74d4302..675d9ea 100644 --- a/src/routes.ts +++ b/src/routes.ts @@ -48,6 +48,15 @@ interface SerializedCompactRecord { createdAt: string; } +interface Balance { + chainId: string; + lockId: string; + allocatableBalance: string; + allocatedBalance: string; + balanceAvailableToAllocate: string; + withdrawalStatus: number; +} + // Authentication middleware function createAuthMiddleware(server: FastifyInstance) { return async function authenticateRequest( @@ -147,7 +156,9 @@ export async function setupRoutes(server: FastifyInstance): Promise { normalizedAddress = getAddress(address); } catch (error) { return reply.code(400).send({ - error: `Invalid Ethereum address format: ${error instanceof Error ? error.message : String(error)}`, + error: `Invalid Ethereum address format: ${ + error instanceof Error ? error.message : String(error) + }`, }); } @@ -359,15 +370,16 @@ export async function setupRoutes(server: FastifyInstance): Promise { } // Filter locks to only include those managed by this allocator - const ourLocks = response.account.resourceLocks.items.filter( - (item) => { - try { - return getAddress(item?.resourceLock?.allocatorAddress) === getAddress(process.env.ALLOCATOR_ADDRESS!); - } catch { - return false; - } + const ourLocks = response.account.resourceLocks.items.filter((item) => { + try { + return ( + getAddress(item?.resourceLock?.allocatorAddress) === + getAddress(process.env.ALLOCATOR_ADDRESS!) + ); + } catch { + return false; } - ); + }); // Get balance details for each lock const balances = ( @@ -427,12 +439,10 @@ export async function setupRoutes(server: FastifyInstance): Promise { balanceAvailableToAllocate: balanceAvailableToAllocate.toString(), withdrawalStatus: resourceLock.withdrawalStatus, - }; + } as Balance; }) ) - ).filter( - (balance): balance is NonNullable => balance !== null - ); + ).filter((balance): balance is Balance => balance !== null); // Filter out any null results and return return {