프로젝트

일반

사용자정보

Actions

이슈 #435

진행중
JL HP

[Go backport] AGX 회계 user_id 종속 전환 — Phase 2

이슈 #435: [Go backport] AGX 회계 user_id 종속 전환 — Phase 2

James Lee이(가) 약 7시간 전에 추가함.

상태:
해결
우선순위:
높음
담당자:
목표버전:
시작일:
2026/05/12
완료일:
2026/05/12 (약 6달 지연)
진척도:

0%

추정시간:

설명

배경

GoTrue 인증 전환 (#434 Phase 1, commit:server|03c6c64) 의 후속. 식별 권한을 user_id 기반으로 옮겼으나, AGX 잔액 / 수익 / 집계 는 여전히 wallet_address 키 기반이다. Rust 측 #421 을 Go 원본으로 백포트해 AGX 회계의 단일 키를 GoTrue user_id 로 통일한다.

작업 범위

DB 스키마 v13 (마이그레이션, clean rewrite)

  • wallets 재설계: 기존 (account_id, balance, total_earned) 1:1 → (user_id UUID, wallet_address TEXT, label TEXT, created_at) 1:N. UNIQUE(user_id, wallet_address)
  • job_receipts.user_id UUID 컬럼 추가 + 인덱스 (user_id, completed_at DESC)
  • aggregated_earnings.user_id UUID 컬럼 추가 + UNIQUE(user_id, period_date, period_type)
  • wallet_adjustments 신규 테이블: (id, user_id UUID, delta_agx DOUBLE PRECISION, reason TEXT, ref_code TEXT, created_at). redeem / admin credit·debit 결제를 기록
  • 잔액 공식: Σ job_receipts.reward_agx WHERE user_id=$1 + Σ wallet_adjustments.delta_agx WHERE user_id=$1
  • clean rewrite: receipts / aggregated_earnings / wallets dev 데이터 DROP

Store 계층

  • store/wallets.go (신규 모듈): AddWallet(userID, wallet), RemoveWallet, ListWalletsByUser, GetUserIDByWallet
  • store/wallet_adjustments.go (신규): InsertAdjustment, SumByUser, ListByUser
  • store/wallet_queries.go 재작성: 수익/잔액 조회를 user_id 기반으로 교체. 기존 wallet_address 기반 함수는 deprecated
  • store/receipts.go: ListByUser, CountByUser, SummaryForUser, TodayForUser, EntriesByRange user_id 기반으로. 삽입 시 user_id 함께 저장
  • store/edge_node.go::UpsertAggregatedEarning: user_id 인자 추가

Proto

  • wallet.proto 에서 다음 요청 메시지의 wallet_address 제거: WalletJobsRequest, WalletNodesRequest, WalletEarningsRequest, WalletEarningsTodayRequest, WalletReceiptsRequest, WalletNodesDetailRequest, WalletEarningsByRangeRequest, WalletEarningsSummaryRequest, ClaimVirtualNodesRequest. 서버는 caller user_id 로 조회

Handler

  • handler/wallet_auth.go::requireAuthenticatedWallet → requireAuthenticatedUser (caller user_id 만 검증. wallet 권한 검사가 필요한 곳은 별도 헬퍼)
  • handler/wallet.go: 6개 RPC user_id 기반으로 재작성. Wallet 조회 계산 공식 적용
  • handler/wallet_vip.go: 3개 RPC. 관리자도 caller user_id 기반으로 (admin proxy 는 user_id 로 우회)

본 phase 에서 다루지 않는 것

  • FriendsService 테이블 user_id 전환 (Phase 3 이슈 예정)
  • virtual_node_assignments / virtual_node_credits / virtual_node_packages 스키마를 user_id 기반으로 (이는 그대로 유지하고 user→wallet 매핑으로 우회)
  • Admin Dev Console GoTrue UI (#424 백포트— 별도 phase)

마이그레이션 전략

Clean rewrite. dev/qa DB 는 reset 필요. Phase 1 과 동일한 정책 (scripts/ec2/reset-db.sh).

DoD

  • make build, make test 통과
  • WalletService 9개 RPC 가 GoTrue user JWT 없으면 Unauthenticated 거부
  • Wallet 잔액 = Σ receipts (user_id) + Σ adjustments (user_id) 로 계산
  • wallet_adjustments 으로 admin credit/debit 가능 (store 계층 귀니)

관련 이슈

  • 다른 phase: #434 (Phase 1, 해결), 이속 이슈 (Phase 3 Admin UI #424 백포트)
  • Rust 원본: #421
  • DB: #254 (스키마 변경 — refs 라인 동반)

연결된 일감 4 (4 건 진행 중 — 모두 미완료)

다음 일감과 관련됨: 이슈 #421: AGX 잔액을 Wallet 종속 → Account(GoTrue user_id) 종속으로 전환해결James Lee2026/04/27

Actions
다음 일감과 관련됨: 이슈 #254: 8-2. 데이터베이스 스키마 설계 (사용자. 앱. 일정)진행James Lee2026/04/282026/04/29

Actions
다음 일감을 우선 진행: 이슈 #434: [Go backport] Supabase GoTrue 인증 전환 — Phase 1: 인프라 + 인증 코어해결Henry Park2026/05/11

Actions
다음에 진행할 일감: 이슈 #436: [Go backport] Admin Dev Console GoTrue UI — Phase 3해결Henry Park2026/05/132026/05/13

Actions
Actions

내보내기 PDF Atom