Use cached auth state from AuthNotifier instead of ref.read() to avoid
"Cannot use ref functions after provider changed" exception during rebuild.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Changed `record.finalContribution` to `record.amount` for getting final contribution value
- Added optional chaining to prevent undefined errors
- Added default values for safety
The ContributionRecordAggregate uses `amount` property, not `finalContribution`.
This was causing "Cannot read properties of undefined (reading 'value')" errors.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add ContributionStats entity and model for network-wide statistics
- Add /api/v2/contribution/stats endpoint
- Implement estimatedEarningsProvider to calculate daily earnings
- Formula: (user contribution / total contribution) × daily allocation
- Update contribution page to display real estimated earnings
- Add debug logs for contribution records API
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Asset page now uses trading-service /asset/my endpoint
- Profile page integrates auth-service /user/profile and contribution-service
- Add new entities: AssetDisplay, PriceInfo, MarketOverview, TradingAccount
- Add corresponding models with JSON parsing
- Create asset_providers and profile_providers for state management
- Update trading_providers with real API integration
- Extend UserState and UserInfo with additional profile fields
- Remove obsolete buy_shares and sell_shares use cases
- Fix compilation errors in get_current_price and trading_page
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add trading burn system with black hole, share pool, and price calculation
- Implement per-minute auto burn and sell burn with multiplier
- Add Kafka event publishing via outbox pattern (order, trade, burn events)
- Add user.registered consumer to auto-create trading accounts
- Implement Redis + DB dual idempotency for event processing
- Add price, burn, and asset API controllers
- Add migrations for burn tables and processed events
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Publish UserWalletCreated when a new wallet is created
- Publish UserWalletUpdated when wallet balance changes
- Events sent to cdc.mining-wallet.outbox topic for mining-admin-service
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add handler for CONTRIBUTION_CREDITED events from mining-wallet-service
to sync user wallet data to synced_user_wallets table.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Return usdtAvailable, usdtFrozen, pendingUsdt, settleableUsdt,
settledTotalUsdt, expiredTotalUsdt instead of old field names
- Query SyncedUserWallet table for GREEN_POINTS wallet data
- Use miningAccount.availableBalance for pendingUsdt
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add @Public() decorator to MiningController to allow mining-admin-service
to fetch mining records without authentication.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Changed event handler to:
- Listen to 'cdc.contribution.outbox' topic (CDC/Debezium format)
- Handle 'ContributionAccountUpdated' events instead of 'ContributionCalculated'
- Use effectiveContribution for mining power calculation
This fixes the issue where mining accounts had zero totalContribution
because they weren't receiving contribution sync events.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Update getUserMiningRecords to call mining-service API instead of
returning empty records. This enables the admin dashboard to display
actual user mining records.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
NestJS matches routes in definition order. The :category/:key route was
matching mining/status before the specific mining routes. Moved mining
routes before the parameter routes to fix routing.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add debug logging to trace mining service calls
- Return error object instead of null when data is missing
- Include error message in response for debugging
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Clean NEXT_PUBLIC_API_URL to remove trailing /api/v2 if present,
preventing paths like /api/v2/api/v2/configs/mining/status
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Browser cannot access Docker internal URLs like http://mining-admin-service:3023.
Always use /api which is proxied by Next.js rewrites to the backend service.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add GET and POST /configs/transfer-enabled endpoints to control
the transfer switch. Routes are placed before :category/:key to
avoid being matched as path parameters.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
mining-admin-service uses TransformInterceptor which wraps all responses
with { success, data, timestamp } format. Frontend needs to access
response.data.data to get the actual data.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- 添加ts-node/typescript到生产环境以支持seed执行
- 启动脚本中添加prisma db seed执行
- 复制tsconfig.json到生产环境
参考mining-wallet-service的Dockerfile配置
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add admin endpoints:
- GET /admin/status - Get mining system status
- POST /admin/initialize - Initialize mining config (one-time)
- POST /admin/activate - Activate mining distribution
Add prisma seed script for database initialization:
- MiningConfig: 100.02B total shares, 200万 distribution pool
- BlackHole: 100亿 burn target
- MiningEra: First era with 100万 distribution
- PoolAccounts: SHARE_POOL, BLACK_HOLE_POOL, CIRCULATION_POOL
Based on requirements:
- 第一个两年分配100万积分股
- 第二个两年分配50万积分股(减半)
- 100亿通过10年销毁到黑洞
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Use 'all' instead of empty string for SelectItem value (Radix requirement)
- Add null safety for items array with fallback to empty array
- Fix potential undefined access on data.items
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Frontend expects flat DashboardStats and RealtimeData interfaces.
Transform backend nested response to:
- totalUsers, adoptedUsers, networkEffectiveContribution, etc.
- currentMinuteDistribution, activeOrders, pendingTrades, etc.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
System initialization is now handled by seed scripts and CDC sync,
so the manual initialization UI is no longer needed.
Removed:
- Frontend: initialization page and sidebar menu item
- Backend: InitializationController and InitializationService
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Change controller path from /audit-logs to /audit to match frontend
- Transform response to frontend expected format (items, totalPages, etc.)
- Map admin.username to adminUsername field
- Add keyword query parameter support
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add ReportsController with /reports/daily endpoint that maps the
dashboard service data to the format expected by the frontend.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Update categorizeAccounts to use correct account types returned by backend:
- Core accounts: HEADQUARTERS, OPERATION, FEE
- Region accounts: PROVINCE, CITY
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Change SystemAccountsService to read from syncedWalletSystemAccount and
syncedWalletPoolAccount tables instead of local tables. This fixes the
issue where the frontend shows "暂无数据" despite data being synced.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add WalletSystemAccountCreated and WalletPoolAccountCreated events:
- seed.ts: publish events when creating HQ/OP/FEE and pool accounts
- contribution-wallet.service.ts: publish events when auto-creating
province/city system accounts
This enables mining-admin-service to sync system accounts via CDC.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Use unitOfWork.isInTransaction() to detect if already in a transaction
context (called from ContributionCalculationService). If so, reuse the
existing transaction instead of opening a new one, preventing Prisma
interactive transaction timeout errors.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Use provinceCode directly instead of inferring from cityCode
- Use code as name for province/city records
- Add ts-node to production for seed execution
- Run prisma db seed on container startup
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When a user's direct referral count reaches 2 or 4, the system now automatically
backfills previously pending TEAM_BONUS (T2/T3) contributions that were allocated
to headquarters while waiting for unlock conditions.
- Add BonusClaimService for handling bonus backfill logic
- Add findPendingBonusByAccountSequence and claimBonusRecords to repository
- Integrate bonus claim into updateReferrerUnlockStatus flow
- Add BonusClaimed event consumer in mining-wallet-service
- Generate ledger records for backfilled contributions
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add prisma seed to initialize core system accounts (HQ, OP, FEE) and pool accounts
- Auto-create province/city system accounts on-demand during contribution distribution
- Province/city regions are also auto-created if not exist
This ensures:
1. Core accounts exist after deployment (via seed)
2. Province/city accounts are created dynamically as orders come in
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Change consumers from @Injectable to @Controller for @EventPattern to work
- Move consumers from providers to controllers array in module
- Add subscribe.fromBeginning config to Kafka microservice
The consumers were not receiving messages because NestJS microservices
require @EventPattern handlers to be in @Controller classes, not just
@Injectable services.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Changed system-accounts/initialize and pool-accounts/initialize endpoints from
@AdminOnly to @Public to allow deploy scripts to call them without authentication.
These endpoints are only accessible from internal network.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>