Skip to content

[FIX] 파트너 저장/삭제 API 및 에스크로 판매자 지갑 주소 조회#25

Merged
Takch02 merged 4 commits into
mainfrom
feat/escrow-seller-by-wallet
May 10, 2026
Merged

[FIX] 파트너 저장/삭제 API 및 에스크로 판매자 지갑 주소 조회#25
Takch02 merged 4 commits into
mainfrom
feat/escrow-seller-by-wallet

Conversation

@Takch02

@Takch02 Takch02 commented May 10, 2026

Copy link
Copy Markdown
Contributor

Resolves #24

Summary

에스크로 결제 생성 시 sellerId를 직접 전달받는 대신, 판매자의 XRPL 지갑 주소로 seller를 조회하도록 변경

Changes

  • CreateEscrowPaymentDto.sellerIdsellerWalletAddress (XRPL Base58 주소 정규식 검증)
  • EscrowPaymentsCrudService.create(): wallet.address로 seller DB 조회 후 sellerId 주입
  • SellerWalletNotFoundException 추가 (지갑 주소에 해당하는 유저 없을 때 404)
  • 결제 생성 권한 검사를 buyer 전용으로 단순화 (seller는 생성 주체가 아님)

Why

프론트엔드가 상대방의 MongoDB ObjectId를 알 필요 없이, XRPL 지갑 주소만으로 에스크로 결제를 생성할 수 있도록 개선. 지갑 주소는 XRPL 상 고유값이므로 신뢰할 수 있는 조회 키로 활용 가능.

Summary by CodeRabbit

변경 사항

  • 새로운 기능

    • 판매자의 지갑 주소를 통한 판매자 확인 메커니즘이 추가되었습니다.
    • 판매자 지갑 주소가 존재하지 않을 경우 적절한 오류 처리가 구현되었습니다.
  • 테스트

    • 에스크로 결제 생성 기능에 대한 확장된 테스트 범위가 추가되었습니다.
    • 지갑 주소 조회 및 오류 처리 시나리오에 대한 테스트가 추가되었습니다.

Review Change Stack

Takch02 and others added 3 commits May 10, 2026 16:40
- 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>
@coderabbitai

coderabbitai Bot commented May 10, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@Takch02 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 42 minutes and 38 seconds before requesting another review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8500b3e9-75f0-420b-ae39-6af1b72250ab

📥 Commits

Reviewing files that changed from the base of the PR and between 276bd18 and d49e95e.

📒 Files selected for processing (3)
  • src/modules/escrow-payments/__tests__/create.spec.ts
  • src/modules/escrow-payments/dto/create-escrow-payment.dto.ts
  • src/modules/escrow-payments/escrow-payments-crud.service.ts
📝 Walkthrough

변경 사항 개요

이 PR은 Escrow 결제 생성 시 판매자 식별 방식을 MongoDB 사용자 ID(sellerId) 대신 XRPL 지갑 주소(sellerWalletAddress)로 변경합니다. 서비스는 지갑 주소로 판매자를 조회한 후 내부적으로 sellerId를 도출하며, 판매자를 찾을 수 없을 시 SellerWalletNotFoundException을 발생시킵니다.

변경 내용

판매자 지갑 주소 기반 생성 흐름

Layer / File(s) 설명
예외 클래스 정의
src/common/exceptions/escrow.exceptions.ts
SellerWalletNotFoundException 추가: 판매자 지갑 주소 조회 실패 시 발생합니다.
DTO 데이터 계약
src/modules/escrow-payments/dto/create-escrow-payment.dto.ts
CreateEscrowPaymentDto에서 sellerId 제거, sellerWalletAddress(XRPL 주소 정규식 @Matches 검증) 추가
서비스 핵심 로직
src/modules/escrow-payments/escrow-payments-crud.service.ts
userModel 의존성 주입 추가; create 메서드는 userModel.findOne({wallet.address}) 로 판매자 조회 후 sellerId 도출; 판매자 부재 시 SellerWalletNotFoundException 발생
테스트 인프라
src/modules/escrow-payments/__tests__/helpers.ts
makeUserModelMock(): findOne() 모의 추가; makeCrudServiceTestingModule(): userModel 컨텍스트 포함
단위 테스트
src/modules/escrow-payments/__tests__/create.spec.ts
판매자 조회 성공, SellerWalletNotFoundException 발생, 비인가 호출자 거부 시나리오 검증
E2E 테스트
test/escrow-*.e2e-spec.ts
결제 생성 페이로드에서 sellerIdsellerWalletAddress 변경; XRPL 서비스 어설션 업데이트; 지갑 주소 상수 일관성 관리

예상 검토 시간

🎯 3 (중간) | ⏱️ ~25분

관련 가능성 있는 PR

  • K-Statra/backend#13: Escrow 결제 기능의 기초 PR로서, 이 PR이 직접 확장합니다.
  • K-Statra/backend#21: 동일한 escrow 예외, 테스트 헬퍼, EscrowPaymentsCrudService 로직을 수정합니다.

축하 시

🎉 판매자를 지갑으로 찾아내다니,
주소만으로 신원 확인! XRPL의 마법,
파트너 누락? 이제는 걱정 없어~
테스트도 완벽하게 준비된 여행,
B2B 결제의 새로운 시대가 열린다! 🚀

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Title check ⚠️ Warning 제목은 지갑 주소 조회라는 주요 변경사항을 언급하고 있지만, PR의 핵심은 CreateEscrowPaymentDto에서 sellerId를 sellerWalletAddress로 변경하는 것이고, 제목의 '파트너 저장/삭제 API' 부분은 실제 변경사항에 반영되어 있지 않습니다. 제목을 '[FIX] 에스크로 결제 생성 시 sellerId를 sellerWalletAddress로 변경' 등으로 수정하여 실제 구현된 변경사항만 정확히 반영하세요.
Out of Scope Changes check ❓ Inconclusive 제목에 언급된 '파트너 저장/삭제 API' 관련 코드는 이 PR에 포함되어 있지 않으며, 모든 변경사항은 에스크로 결제 생성 시 판매자 지갑 주소 조회로 제한되어 있습니다. PR 제목과 실제 구현된 변경사항 간의 불일치를 명확히 하세요. 파트너 API 변경사항이 누락된 것인지 또는 제목이 잘못된 것인지 확인 필요합니다.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed PR의 모든 변경사항이 #24의 요구사항을 충족합니다: sellerId → sellerWalletAddress 변경, 지갑 주소로 seller 검색, 내부적 sellerId 주입, SellerWalletNotFoundException 구현으로 미발견 시 처리.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/escrow-seller-by-wallet

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 01ceb0d and 276bd18.

📒 Files selected for processing (9)
  • src/common/exceptions/escrow.exceptions.ts
  • src/modules/escrow-payments/__tests__/create.spec.ts
  • src/modules/escrow-payments/__tests__/helpers.ts
  • src/modules/escrow-payments/dto/create-escrow-payment.dto.ts
  • src/modules/escrow-payments/escrow-payments-crud.service.ts
  • test/escrow-mock.e2e-spec.ts
  • test/escrow-rlusd-mock.e2e-spec.ts
  • test/escrow-rlusd-testnet.e2e-spec.ts
  • test/escrow-testnet.e2e-spec.ts

Comment thread src/modules/escrow-payments/__tests__/create.spec.ts
Comment thread src/modules/escrow-payments/dto/create-escrow-payment.dto.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FIX] 결제내역 생성 시 SellerId -> SellerWalletAddress를 받도록 수정

1 participant