Skip to content

Integrations#14

Merged
JoE11-y merged 2 commits intomainfrom
integrations
Sep 25, 2025
Merged

Integrations#14
JoE11-y merged 2 commits intomainfrom
integrations

Conversation

@JoE11-y
Copy link
Copy Markdown
Contributor

@JoE11-y JoE11-y commented Sep 25, 2025

Summary by CodeRabbit

  • New Features

    • API responses for ads and trades now include chainId for clearer network context.
    • Ad creation now supports optional minAmount and maxAmount; values are saved when greater than zero and otherwise omitted.
  • Bug Fixes

    • Validation ensures maxAmount is greater than or equal to minAmount; invalid requests are rejected.
    • Consistent null handling for unset minAmount/maxAmount in responses, improving data clarity.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Sep 25, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Adds optional minAmount/maxAmount to ad creation with validation and conditional persistence. Expands multiple DTOs and provider types to include chainId as string. Updates viem service methods to return chainId. Minor type tweak in trade liquidity calculation without control-flow changes.

Changes

Cohort / File(s) Summary of changes
Ads: min/max validation and persistence
apps/backend-relayer/src/modules/ads/ad.service.ts
Validates minAmount/maxAmount (Prisma.Decimal), enforces maxAmount ≥ minAmount; persists values as null when ≤ 0; propagates to requestDetails payload.
Ads DTOs: new fields and chainId exposure
apps/backend-relayer/src/modules/ads/dto/ad.dto.ts
Adds optional minAmount? and maxAmount? (string, digit validation). Adds chainId!: string to Create/Fund/Withdraw/Close Ad response DTOs.
Trades DTOs: chainId added
apps/backend-relayer/src/modules/trades/dto/trade.dto.ts
Adds chainId!: string to LockForOrderResponseDto, CreateOrderRequestContractDetailsDto, UnlockOrderResponseDto.
Trades service: typing adjustment
apps/backend-relayer/src/modules/trades/trade.service.ts
Removes explicit Prisma.Decimal cast in available liquidity calculation; uses ad.poolAmount.sub(locked) directly.
Viem provider types: chainId added
apps/backend-relayer/src/providers/viem/types.ts
Adds chainId: string to multiple exported contract detail types (Create/Fund/Withdraw/Close Ad; Lock/Unlock Order; Create Order).
Viem service returns: chainId included
apps/backend-relayer/src/providers/viem/viem.service.ts
Inserts chainId: ...toString() into returned contract detail payloads across methods; aligns with updated public types.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Client
  participant AdsAPI as Ads Controller/Service
  participant Viem as ViemService
  participant DB as Database

  rect rgb(235, 248, 255)
    note over Client,AdsAPI: Create Ad request (includes optional minAmount/maxAmount)
    Client->>AdsAPI: POST /ads (payload)
    AdsAPI->>AdsAPI: Parse min/max as Decimal<br/>Check max >= min
    alt Invalid min/max
      AdsAPI-->>Client: 400 BadRequest
    else Valid
      AdsAPI->>Viem: getCreateAdContractDetails(...)
      Viem-->>AdsAPI: {..., chainId: "<id>"}
      AdsAPI->>DB: Create Ad<br/>(store min/max or null if <= 0)
      DB-->>AdsAPI: Ad record
      AdsAPI-->>Client: CreateAdResponseDto<br/>{..., chainId, min/max/null}
    end
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

I tap my paws, approve the plan,
Min meets Max, we check and scan.
Chain IDs twinkle, strings in tow,
Viem whispers back with on-chain glow.
Ads now bounded, trades aligned—
A happy hop, with types refined. 🐇✨

✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch integrations

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0ddb79e and 6b6831d.

📒 Files selected for processing (6)
  • apps/backend-relayer/src/modules/ads/ad.service.ts (2 hunks)
  • apps/backend-relayer/src/modules/ads/dto/ad.dto.ts (5 hunks)
  • apps/backend-relayer/src/modules/trades/dto/trade.dto.ts (3 hunks)
  • apps/backend-relayer/src/modules/trades/trade.service.ts (1 hunks)
  • apps/backend-relayer/src/providers/viem/types.ts (7 hunks)
  • apps/backend-relayer/src/providers/viem/viem.service.ts (7 hunks)

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.

@JoE11-y JoE11-y merged commit daba4a2 into main Sep 25, 2025
1 check was pending
@coderabbitai coderabbitai Bot mentioned this pull request Oct 21, 2025
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.

1 participant