feat: add optimistic locking and improve type safety
- Implement optimistic locking for deposit balance updates - Prevent race conditions in concurrent deposit requests - Add automatic retry with exponential backoff (max 3 attempts) - Add version column to user_deposits table - Improve type safety across codebase - Add explicit types for Namecheap API responses - Add typed function arguments (ManageDepositArgs, etc.) - Remove `any` types from deposit-agent and tool files - Add reconciliation job for balance integrity verification - Compare user_deposits.balance vs SUM(confirmed transactions) - Alert admin on discrepancy detection - Set up test environment with Vitest + Miniflare - Add 50+ test cases for deposit system - Add helper functions for test data creation - Update documentation - Add migration guide for version columns - Document optimistic locking patterns Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Env } from '../types';
|
||||
import type { Env, KeyboardData } from '../types';
|
||||
import {
|
||||
addToBuffer,
|
||||
processAndSummarize,
|
||||
@@ -9,7 +9,7 @@ import { sendChatAction } from '../telegram';
|
||||
export interface ConversationResult {
|
||||
responseText: string;
|
||||
isProfileUpdated: boolean;
|
||||
keyboardData?: any;
|
||||
keyboardData?: KeyboardData | null;
|
||||
}
|
||||
|
||||
export class ConversationService {
|
||||
@@ -53,13 +53,13 @@ export class ConversationService {
|
||||
);
|
||||
|
||||
// 키보드 데이터 파싱
|
||||
let keyboardData: any = null;
|
||||
let keyboardData: KeyboardData | null = null;
|
||||
const keyboardMatch = responseText.match(/__KEYBOARD__(.+?)__END__\n?/);
|
||||
|
||||
|
||||
if (keyboardMatch) {
|
||||
responseText = responseText.replace(/__KEYBOARD__.+?__END__\n?/, '');
|
||||
try {
|
||||
keyboardData = JSON.parse(keyboardMatch[1]);
|
||||
keyboardData = JSON.parse(keyboardMatch[1]) as KeyboardData;
|
||||
} catch (e) {
|
||||
console.error('[ConversationService] Keyboard parsing error:', e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user