diff --git a/frontend/src/components/Transfer.tsx b/frontend/src/components/Transfer.tsx index 926a128..6428bb5 100644 --- a/frontend/src/components/Transfer.tsx +++ b/frontend/src/components/Transfer.tsx @@ -1,4 +1,4 @@ -import { useState, useMemo, useEffect } from 'react'; +import { useState, useMemo, useEffect, useCallback } from 'react'; import { useAccount, useChainId, useReadContract } from 'wagmi'; import { parseUnits, formatUnits } from 'viem'; import { useNotification } from '../hooks/useNotification'; @@ -80,7 +80,7 @@ export function Transfer({ }); // Validate amount - const validateAmount = () => { + const validateAmount = useCallback(() => { if (!formData.amount) return null; try { @@ -104,10 +104,10 @@ export function Transfer({ } return null; - } catch (e) { + } catch { return { type: 'error', message: 'Invalid amount format' }; } - }; + }, [formData.amount, decimals, resourceLockBalance]); // Update error message when nonce consumption status changes const nonceError = useMemo(() => { diff --git a/package.json b/package.json index 2d3626f..d773ade 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "prepare": "husky", "check-test-files": "node scripts/check-test-files.js", "lint-staged": "lint-staged", - "check:all": "pnpm build:all || true && pnpm lint || true && cd frontend && pnpm lint || true && cd - && pnpm format:check || true && cd frontend && prettier --check \"src/**/*.{ts,tsx}\" || true && cd - && pnpm type-check || true && cd frontend && pnpm tsc --noEmit -p tsconfig.app.json || true && cd - && pnpm test || true && pnpm smoke-test || true" + "check:all": "pnpm build:all || true && pnpm lint || true && cd frontend && pnpm lint || true && cd - && pnpm format:check || true && cd frontend && prettier --check \"src/**/*.{ts,tsx}\" || true && cd - && pnpm type-check || true && cd frontend && pnpm tsc --noEmit -p tsconfig.app.json || true && cd - && pnpm test:parallel || true && pnpm smoke-test || true" }, "lint-staged": { "**/*.{test,spec}.ts": [ diff --git a/src/__tests__/routes/integration.test.ts b/src/__tests__/routes/integration.test.ts index b09869d..c1fbfdf 100644 --- a/src/__tests__/routes/integration.test.ts +++ b/src/__tests__/routes/integration.test.ts @@ -13,7 +13,6 @@ import { AccountDeltasResponse, AccountResponse, } from '../../graphql'; -import { Variables } from 'graphql-request'; describe('Integration Tests', () => { let server: FastifyInstance; @@ -32,10 +31,7 @@ describe('Integration Tests', () => { describe('Allocation Flow', () => { it('should handle complete allocation flow: session -> compact -> balance -> nonce', async () => { // Mock GraphQL response with zero allocated balance - graphqlClient.request = async < - V extends Variables = Variables, - T = AllocatorResponse & AccountDeltasResponse & AccountResponse, - >(): Promise< + graphqlClient.request = async (): Promise< AllocatorResponse & AccountDeltasResponse & AccountResponse > => ({ allocator: { diff --git a/src/__tests__/validation/compact-validation.test.ts b/src/__tests__/validation/compact-validation.test.ts index c4b087a..c4ad5f1 100644 --- a/src/__tests__/validation/compact-validation.test.ts +++ b/src/__tests__/validation/compact-validation.test.ts @@ -22,7 +22,7 @@ describe('Compact Basic Validation', () => { beforeEach((): void => { originalRequest = graphqlClient.request; - mockGraphQLResponse(originalRequest); + mockGraphQLResponse(); }); afterEach((): void => { diff --git a/src/__tests__/validation/utils/compact-test-setup.ts b/src/__tests__/validation/utils/compact-test-setup.ts index 7505b3a..92e033e 100644 --- a/src/__tests__/validation/utils/compact-test-setup.ts +++ b/src/__tests__/validation/utils/compact-test-setup.ts @@ -52,9 +52,7 @@ export function cleanupCompactTestDb(db: PGlite): Promise { ]).then(() => undefined); } -export function mockGraphQLResponse( - originalRequest: typeof graphqlClient.request -): void { +export function mockGraphQLResponse(): void { graphqlClient.request = async (): Promise< AllocatorResponse & AccountDeltasResponse & AccountResponse > => ({ @@ -104,7 +102,7 @@ describe('Compact Test Setup', () => { it('should mock GraphQL response with expected structure', async () => { // Setup mock - mockGraphQLResponse(originalRequest); + mockGraphQLResponse(); // Make request with required variables const response = await graphqlClient.request(GET_COMPACT_DETAILS, { diff --git a/src/compact.ts b/src/compact.ts index cbe92e7..ee9d43c 100644 --- a/src/compact.ts +++ b/src/compact.ts @@ -11,7 +11,6 @@ import { import { generateClaimHash, signCompact } from './crypto'; import { randomUUID } from 'crypto'; import { PGlite } from '@electric-sql/pglite'; -import { toBigInt } from './utils/encoding'; export interface CompactSubmission { chainId: string; diff --git a/src/validation/structure.ts b/src/validation/structure.ts index 9fc2c18..73c939a 100644 --- a/src/validation/structure.ts +++ b/src/validation/structure.ts @@ -4,7 +4,7 @@ import { CompactMessage, ValidatedCompactMessage, } from './types'; -import { toBigInt, toPositiveBigInt } from '../utils/encoding'; +import { toPositiveBigInt } from '../utils/encoding'; export async function validateStructure( compact: CompactMessage