[FIX] 파트너 저장/삭제 API 및 에스크로 판매자 지갑 주소 조회#25
Conversation
- CreateEscrowPaymentDto의 sellerId 필드를 sellerWalletAddress(XRPL 주소 형식 검증)로 교체 - EscrowPaymentsCrudService.create()에서 wallet.address로 seller 조회 후 sellerId 주입 - SellerWalletNotFoundException 추가 (지갑 주소에 해당하는 유저 없을 때) - 결제 생성 권한 검사를 buyer 전용으로 단순화 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- helpers.ts: makeUserModelMock에 findOne 추가, makeCrudServiceTestingModule에 UserModel 프로바이더 및 userModel 반환 추가 - create.spec.ts: dto를 sellerWalletAddress 필드로 변경, seller 조회/예외/권한 테스트 케이스 추가 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- escrow-mock / escrow-rlusd-mock: sellerId → sellerWalletAddress, 테스트 지갑 주소를 유효한 XRPL 형식(25자 이상, Base58 문자셋)으로 변경 - escrow-testnet / escrow-rlusd-testnet: SELLER_WALLET_ADDR 상수 제거, beforeAll에서 생성한 실제 sellerWallet.address를 sellerWalletAddress에 주입 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 Walkthrough변경 사항 개요이 PR은 Escrow 결제 생성 시 판매자 식별 방식을 MongoDB 사용자 ID(sellerId) 대신 XRPL 지갑 주소(sellerWalletAddress)로 변경합니다. 서비스는 지갑 주소로 판매자를 조회한 후 내부적으로 sellerId를 도출하며, 판매자를 찾을 수 없을 시 SellerWalletNotFoundException을 발생시킵니다. 변경 내용판매자 지갑 주소 기반 생성 흐름
예상 검토 시간🎯 3 (중간) | ⏱️ ~25분 관련 가능성 있는 PR
축하 시
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
src/modules/escrow-payments/escrow-payments-crud.service.ts (1)
40-40: ⚡ Quick win코드 최적화: 불필요한 타입 변환 제거 가능
40번 라인에서
seller._id.toString()으로 문자열 변환 후, 45번 라인에서 다시new Types.ObjectId(sellerId)로 변환하고 있습니다.
.lean()을 사용했으므로seller._id는 이미 ObjectId 인스턴스입니다. 직접 사용하여 불필요한 변환을 제거할 수 있습니다.♻️ 최적화 제안
- const sellerId = seller._id.toString(); const totalAmountXrp = dto.escrows.reduce((sum, e) => sum + e.amountXrp, 0); const doc = new this.escrowPaymentModel({ buyerId: new Types.ObjectId(dto.buyerId), - sellerId: new Types.ObjectId(sellerId), + sellerId: seller._id, totalAmountXrp,Also applies to: 45-45
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/modules/escrow-payments/escrow-payments-crud.service.ts` at line 40, The code unnecessarily converts seller._id to string then back to ObjectId; remove the intermediate string conversion by dropping sellerId = seller._id.toString() and instead use the existing ObjectId directly where needed (e.g., replace uses of new Types.ObjectId(sellerId) with seller._id or assign sellerObjectId = seller._id to make intent clear); update any references to sellerId accordingly in escrow-payments-crud.service.ts to avoid redundant toString()/Types.ObjectId conversions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/modules/escrow-payments/__tests__/create.spec.ts`:
- Around line 76-79: The test's user lookup is too broad: update the assertion
for ctx.userModel.findOne to include a role/type filter so it queries for the
seller role (e.g., add type: "seller" alongside { "wallet.address":
SELLER_WALLET_ADDRESS }) and, if relevant to the implementation, also assert
exclusion conditions like absence of buyerId; target the call represented by
ctx.userModel.findOne and the SELLER_WALLET_ADDRESS constant to ensure the test
matches the intended seller-only lookup.
In `@src/modules/escrow-payments/dto/create-escrow-payment.dto.ts`:
- Around line 56-58: 현재 sellerWalletAddress에 적용된 `@Matches` 정규식의 반복 범위 `{24,33}`이
XRPL 클래식 주소(총 길이 25~35자)를 충분히 허용하지 못합니다; create-escrow-payment.dto.ts에서
`@Matches`(...) 데코레이터(대상: sellerWalletAddress)의 길이 한도를 `{24,34}`로 늘려 정규식이
`^r[1-9A-HJ-NP-Za-km-z]{24,34}$`와 같이 총 25~35자를 허용하도록 수정하세요.
---
Nitpick comments:
In `@src/modules/escrow-payments/escrow-payments-crud.service.ts`:
- Line 40: The code unnecessarily converts seller._id to string then back to
ObjectId; remove the intermediate string conversion by dropping sellerId =
seller._id.toString() and instead use the existing ObjectId directly where
needed (e.g., replace uses of new Types.ObjectId(sellerId) with seller._id or
assign sellerObjectId = seller._id to make intent clear); update any references
to sellerId accordingly in escrow-payments-crud.service.ts to avoid redundant
toString()/Types.ObjectId conversions.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 7fa9189f-d95f-4de0-acf5-44c0d37a1331
📒 Files selected for processing (9)
src/common/exceptions/escrow.exceptions.tssrc/modules/escrow-payments/__tests__/create.spec.tssrc/modules/escrow-payments/__tests__/helpers.tssrc/modules/escrow-payments/dto/create-escrow-payment.dto.tssrc/modules/escrow-payments/escrow-payments-crud.service.tstest/escrow-mock.e2e-spec.tstest/escrow-rlusd-mock.e2e-spec.tstest/escrow-rlusd-testnet.e2e-spec.tstest/escrow-testnet.e2e-spec.ts
Resolves #24
Summary
에스크로 결제 생성 시
sellerId를 직접 전달받는 대신, 판매자의 XRPL 지갑 주소로 seller를 조회하도록 변경Changes
CreateEscrowPaymentDto.sellerId→sellerWalletAddress(XRPL Base58 주소 정규식 검증)EscrowPaymentsCrudService.create():wallet.address로 seller DB 조회 후sellerId주입SellerWalletNotFoundException추가 (지갑 주소에 해당하는 유저 없을 때 404)Why
프론트엔드가 상대방의 MongoDB ObjectId를 알 필요 없이, XRPL 지갑 주소만으로 에스크로 결제를 생성할 수 있도록 개선. 지갑 주소는 XRPL 상 고유값이므로 신뢰할 수 있는 조회 키로 활용 가능.
Summary by CodeRabbit
변경 사항
새로운 기능
테스트