Skip to content

Commit 09992ec

Browse files
committed
fix code base
1 parent d53a3c2 commit 09992ec

21 files changed

Lines changed: 133 additions & 85 deletions

backend/src/admin/admin-claims-export.service.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { Readable } from 'stream';
77
describe('AdminClaimsExportService', () => {
88
let service: AdminClaimsExportService;
99
let prismaService: PrismaService;
10-
let tenantContextService: TenantContextService;
1110

1211
const mockClaim = {
1312
id: 1,
@@ -49,7 +48,6 @@ describe('AdminClaimsExportService', () => {
4948

5049
service = module.get<AdminClaimsExportService>(AdminClaimsExportService);
5150
prismaService = module.get<PrismaService>(PrismaService);
52-
tenantContextService = module.get<TenantContextService>(TenantContextService);
5351
});
5452

5553
describe('CSV header generation', () => {

backend/src/admin/admin-claims-export.service.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,8 @@ export class AdminClaimsExportService {
5050
*/
5151
createClaimsExportStream(params: ClaimsExportParams): Readable {
5252
const readable = new Readable();
53-
let isFirstRow = true;
5453

55-
this.streamClaimsAsCSV(readable, params, isFirstRow)
54+
this.streamClaimsAsCSV(readable, params)
5655
.catch((err) => {
5756
this.logger.error('Error streaming claims export', { err });
5857
readable.destroy(err);
@@ -64,7 +63,6 @@ export class AdminClaimsExportService {
6463
private async streamClaimsAsCSV(
6564
writable: Readable,
6665
params: ClaimsExportParams,
67-
isFirstRow: boolean,
6866
): Promise<void> {
6967
let cursor: number | undefined;
7068
let hasMore = true;
@@ -142,17 +140,18 @@ export class AdminClaimsExportService {
142140
const where = claimTenantWhere(tenantId, {});
143141

144142
if (params.status) {
145-
where.status = params.status.toUpperCase() as any;
143+
where.status = params.status.toUpperCase() as Prisma.ClaimWhereInput['status'];
146144
}
147145

148146
if (params.from || params.to) {
149-
where.createdAt = {};
147+
const createdAt: Prisma.DateTimeFilter = {};
150148
if (params.from) {
151-
(where.createdAt as any).gte = new Date(params.from);
149+
createdAt.gte = new Date(params.from);
152150
}
153151
if (params.to) {
154-
(where.createdAt as any).lte = new Date(params.to);
152+
createdAt.lte = new Date(params.to);
155153
}
154+
where.createdAt = createdAt;
156155
}
157156

158157
return where;

backend/src/admin/admin.controller.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ describe('Admin Role Guard Enforcement', () => {
496496
});
497497

498498
describe('Admin Role Required', () => {
499-
const makeGuardCtx = (minRole?: string) => ({
499+
const makeGuardCtx = () => ({
500500
getHandler: () => ({}),
501501
getClass: () => ({}),
502502
getType: () => 'http',

backend/src/admin/admin.controller.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ export class AdminController {
255255
@Get('governance/quorum/impact')
256256
@MinAdminRole('viewer')
257257
@ApiOperation({ summary: 'Preview impact of quorum change on active claims' })
258-
async getQuorumImpact(@Query('bps') bps?: string, @Req() req?: AdminRequest) {
258+
async getQuorumImpact(@Query('bps') bps?: string) {
259259
const targetBps = bps ? parseInt(bps, 10) : null;
260260
if (targetBps !== null && (isNaN(targetBps) || targetBps < 1 || targetBps > 10000)) {
261261
throw new BadRequestException('bps must be between 1 and 10000');
@@ -505,11 +505,11 @@ export class AdminController {
505505
@MinAdminRole('viewer')
506506
@ApiOperation({ summary: 'Streaming CSV export of claims with pagination (no memory load)' })
507507
async exportClaims(
508+
@Req() req: AdminRequest,
509+
@Res() res: Response,
508510
@Query('status') status?: string,
509511
@Query('from') from?: string,
510512
@Query('to') to?: string,
511-
@Req() req: AdminRequest,
512-
@Res() res: Response,
513513
) {
514514
const admin = req.user?.walletAddress ?? 'unknown';
515515
const rateLimitKey = `admin_claims_export:${admin}`;
@@ -1021,7 +1021,7 @@ export class AdminController {
10211021
message: 'SOLVENCY_SIMULATION_SOURCE_ACCOUNT is not set.',
10221022
});
10231023
}
1024-
return this.soroban.simulateGetEvidenceLimits({ sourceAccount: source });
1024+
return this.sorobanService.simulateGetEvidenceLimits({ sourceAccount: source });
10251025
}
10261026

10271027
/**
@@ -1048,7 +1048,7 @@ export class AdminController {
10481048
if (min > max) {
10491049
throw new BadRequestException('min must not exceed max');
10501050
}
1051-
const result = await this.soroban.invokeAdminSetEvidenceLimits({ min, max });
1051+
const result = await this.sorobanService.invokeAdminSetEvidenceLimits({ min, max });
10521052
const actor = req.user?.walletAddress ?? 'unknown';
10531053
await this.auditService.write({
10541054
actor,

backend/src/assets/allowed-assets-cache.service.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { Injectable, Logger, Optional } from '@nestjs/common';
22
import { ConfigService } from '@nestjs/config';
33
import { RedisService } from '../cache/redis.service';
44
import { MetricsService } from '../metrics/metrics.service';
5-
import type { AllowedAsset } from '@prisma/client';
65

76
const DEFAULT_TTL_SECONDS = 300; // 5 minutes
87
const KEY_PREFIX = 'assets:allowed';
@@ -27,15 +26,15 @@ export class AllowedAssetsCacheService {
2726
return `${KEY_PREFIX}:list`;
2827
}
2928

30-
async getOrCompute(compute: () => Promise<AllowedAsset[]>): Promise<AllowedAsset[]> {
29+
async getOrCompute<T>(compute: () => Promise<T[]>): Promise<T[]> {
3130
const key = this.getCacheKey();
32-
const cached = await this.redis.get<AllowedAsset[]>(key);
31+
const cached = await this.redis.get<T[]>(key);
3332
if (cached) {
34-
this.metrics?.recordCache('allowed_assets', 'hit');
33+
this.metrics?.recordRedisCache('hit', 'allowed_assets');
3534
return cached;
3635
}
3736

38-
this.metrics?.recordCache('allowed_assets', 'miss');
37+
this.metrics?.recordRedisCache('miss', 'allowed_assets');
3938
const result = await compute();
4039
await this.redis.set(key, result, this.ttlSeconds);
4140
return result;

backend/src/auth/token-blacklist.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class TokenBlacklistService {
1818
}
1919

2020
const key = TOKEN_BLACKLIST_PREFIX + jti;
21-
await this.redis.client.setex(key, ttlSeconds, '1');
21+
await this.redis.getClient().setex(key, ttlSeconds, '1');
2222
}
2323

2424
/**
@@ -27,7 +27,7 @@ export class TokenBlacklistService {
2727
*/
2828
async isBlacklisted(jti: string): Promise<boolean> {
2929
const key = TOKEN_BLACKLIST_PREFIX + jti;
30-
const result = await this.redis.client.exists(key);
30+
const result = await this.redis.getClient().exists(key);
3131
return result === 1;
3232
}
3333

backend/src/auth/wallet-auth.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export class WalletAuthService {
119119
stored.message,
120120
signatureBase64,
121121
);
122-
} catch (err) {
122+
} catch {
123123
throw new UnauthorizedException({
124124
code: 'INVALID_SIGNATURE',
125125
message: 'Signature verification failed.',

backend/src/common/interceptors/transform.interceptor.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ export class TransformInterceptor implements NestInterceptor {
2424

2525
// Handle paginated responses with pagination field
2626
if (response && typeof response === 'object' && 'pagination' in response && 'data' in response) {
27-
const { pagination, data, ...rest } = response as any;
27+
const { pagination, data, ...rest } = response as {
28+
pagination: { total: number; next_cursor?: unknown };
29+
data: unknown;
30+
[key: string]: unknown;
31+
};
2832
return {
2933
data,
3034
meta: {

backend/src/experimental/xdr-decode.controller.spec.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,6 @@ describe('XdrDecodeController', () => {
4040
});
4141

4242
it('should decode valid XDR ScVal', () => {
43-
// Create a simple uint32 ScVal: value 42
44-
const scVal = {
45-
discriminant: 'scValTypeUint32',
46-
uint32: { low: 42, high: 0, unsigned: true },
47-
toXDR: function (encoding: string) {
48-
// Return a buffer representation
49-
return Buffer.from('AAAAAAA=', 'base64');
50-
},
51-
};
52-
5343
// Mock the xdr module behavior
5444
// In a real test, this would use actual stellar-sdk XDR encoding
5545
const mockReq = {

backend/src/indexer/indexer.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ export class IndexerService {
104104
@Optional() private readonly votePubSub?: VotePubSubService,
105105
@Optional() private readonly outboundWebhook?: OutboundWebhookService,
106106
@Optional() private readonly adminAnalytics?: AdminAnalyticsService,
107+
@Optional() private readonly allowedAssetsCache?: AllowedAssetsCacheService,
107108
) {
108109
this.networkId = this.config.get<string>('STELLAR_NETWORK', 'testnet');
109110
this.gapThresholdLedgers = this.config.get<number>('INDEXER_GAP_ALERT_THRESHOLD_LEDGERS', 100);
@@ -622,7 +623,7 @@ export class IndexerService {
622623
await this.allowedAssetsCache?.invalidateAll();
623624
}
624625

625-
private async handleAssetRemoved(tx: IndexerTx, data: EventPayload, event: SorobanEvent) {
626+
private async handleAssetRemoved(tx: IndexerTx, data: EventPayload, _event: SorobanEvent) {
626627
const contractId = getStringValue(data.contract_id);
627628

628629
await tx.allowedAsset.update({

0 commit comments

Comments
 (0)