Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
0age committed Dec 9, 2024
1 parent cb369ab commit 14dffec
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 17 deletions.
8 changes: 4 additions & 4 deletions frontend/src/components/Transfer.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -80,7 +80,7 @@ export function Transfer({
});

// Validate amount
const validateAmount = () => {
const validateAmount = useCallback(() => {
if (!formData.amount) return null;

try {
Expand All @@ -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(() => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
6 changes: 1 addition & 5 deletions src/__tests__/routes/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
AccountDeltasResponse,
AccountResponse,
} from '../../graphql';
import { Variables } from 'graphql-request';

describe('Integration Tests', () => {
let server: FastifyInstance;
Expand All @@ -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: {
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/validation/compact-validation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('Compact Basic Validation', () => {

beforeEach((): void => {
originalRequest = graphqlClient.request;
mockGraphQLResponse(originalRequest);
mockGraphQLResponse();
});

afterEach((): void => {
Expand Down
6 changes: 2 additions & 4 deletions src/__tests__/validation/utils/compact-test-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ export function cleanupCompactTestDb(db: PGlite): Promise<void> {
]).then(() => undefined);
}

export function mockGraphQLResponse(
originalRequest: typeof graphqlClient.request
): void {
export function mockGraphQLResponse(): void {
graphqlClient.request = async (): Promise<
AllocatorResponse & AccountDeltasResponse & AccountResponse
> => ({
Expand Down Expand Up @@ -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, {
Expand Down
1 change: 0 additions & 1 deletion src/compact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/validation/structure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 14dffec

Please sign in to comment.