Skip to content

fix(samples/kotlin): select crypto network when funding a quote from USDC#603

Merged
pengying merged 1 commit into
mainfrom
06-18-fix_samples_kotlin_select_crypto_network_when_funding_a_quote_from_usdc
Jun 26, 2026
Merged

fix(samples/kotlin): select crypto network when funding a quote from USDC#603
pengying merged 1 commit into
mainfrom
06-18-fix_samples_kotlin_select_crypto_network_when_funding_a_quote_from_usdc

Conversation

@pengying

Copy link
Copy Markdown
Contributor

A RealtimeFundingQuoteSource with a crypto currency (e.g. USDC) requires a
cryptoNetwork, otherwise the quote fails with INVALID_INPUT ("Crypto network
is required ... for a crypto currency"). Pass cryptoNetwork through the
quotes route and add a Funding Network selector to the quote step, shown
only when the source currency is crypto. Fixes the Payout flow when funding
from USDC.

Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com

@vercel

vercel Bot commented Jun 18, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Actions Updated (UTC)
grid-flow-builder Ignored Ignored Preview Jun 26, 2026 12:23am
grid-wallet-demo Ignored Ignored Preview Jun 26, 2026 12:23am

Request Review

@greptile-apps

greptile-apps Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes the Payout flow when funding from USDC by threading cryptoNetwork through the quote creation path. Without the network field, the API returned INVALID_INPUT: Crypto network is required for crypto funding sources.

  • Frontend (CreateQuote.tsx): Adds a CRYPTO_NETWORKS constant (BASE, ETHEREUM, POLYGON, SOLANA), a cryptoNetwork state variable, and a conditional "Funding Network" dropdown that appears only when the selected source currency is in CRYPTO_SOURCE_CURRENCIES. The network is appended to the request body only when isCryptoSource is true.
  • Kotlin backend (Quotes.kt): Reads the optional cryptoNetwork field from the incoming JSON and passes it to RealtimeFundingQuoteSource.builder(), matching the existing optional-field pattern used for customerId.

Confidence Score: 5/5

Safe to merge — the change is a minimal, targeted fix that adds an optional field to the crypto funding path without touching any other flows.

Both changes are additive. The frontend conditionally shows the network picker only for crypto sources and conditionally includes the field in the body; non-crypto flows are unchanged. The Kotlin side uses the same optText(...)?let {} pattern already established for customerId, so the field is silently ignored when absent, preserving backward compatibility.

No files require special attention.

Important Files Changed

Filename Overview
samples/frontend/src/steps/CreateQuote.tsx Adds conditional cryptoNetwork selector and conditionally includes the field in the request body; deps array correctly updated.
samples/kotlin/src/main/kotlin/com/grid/sample/routes/Quotes.kt Reads optional cryptoNetwork from the JSON source node and forwards it to the SDK builder; follows the same optional-field pattern used for customerId.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant User
    participant CreateQuote as CreateQuote.tsx
    participant KtorRoute as Quotes.kt (POST /api/quotes)
    participant GridSDK as Grid SDK

    User->>CreateQuote: Select USDC as source currency
    CreateQuote->>CreateQuote: "isCryptoSource = true → show Funding Network dropdown"
    User->>CreateQuote: Select network (e.g. BASE)
    CreateQuote->>CreateQuote: "Build body with source.cryptoNetwork = BASE"
    User->>CreateQuote: Click Create Quote
    CreateQuote->>KtorRoute: "POST /api/quotes {source:{currency:USDC, cryptoNetwork:BASE, ...}}"
    KtorRoute->>KtorRoute: "buildQuoteSource → optText(cryptoNetwork) = BASE"
    KtorRoute->>GridSDK: RealtimeFundingQuoteSource.builder().currency(USDC).cryptoNetwork(BASE).build()
    GridSDK-->>KtorRoute: Quote response
    KtorRoute-->>CreateQuote: 201 JSON
    CreateQuote-->>User: Show response
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
    participant User
    participant CreateQuote as CreateQuote.tsx
    participant KtorRoute as Quotes.kt (POST /api/quotes)
    participant GridSDK as Grid SDK

    User->>CreateQuote: Select USDC as source currency
    CreateQuote->>CreateQuote: "isCryptoSource = true → show Funding Network dropdown"
    User->>CreateQuote: Select network (e.g. BASE)
    CreateQuote->>CreateQuote: "Build body with source.cryptoNetwork = BASE"
    User->>CreateQuote: Click Create Quote
    CreateQuote->>KtorRoute: "POST /api/quotes {source:{currency:USDC, cryptoNetwork:BASE, ...}}"
    KtorRoute->>KtorRoute: "buildQuoteSource → optText(cryptoNetwork) = BASE"
    KtorRoute->>GridSDK: RealtimeFundingQuoteSource.builder().currency(USDC).cryptoNetwork(BASE).build()
    GridSDK-->>KtorRoute: Quote response
    KtorRoute-->>CreateQuote: 201 JSON
    CreateQuote-->>User: Show response
Loading

Reviews (2): Last reviewed commit: "fix(samples/kotlin): select crypto netwo..." | Re-trigger Greptile

shreyav
shreyav previously approved these changes Jun 26, 2026

pengying commented Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

Merge activity

  • Jun 26, 12:16 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Jun 26, 12:24 AM UTC: Graphite rebased this pull request as part of a merge.
  • Jun 26, 12:24 AM UTC: @pengying merged this pull request with Graphite.

@pengying pengying changed the base branch from 06-18-feat_samples_kotlin_add_exchange-rates_lookup_flow to graphite-base/603 June 26, 2026 00:21
@pengying pengying changed the base branch from graphite-base/603 to main June 26, 2026 00:22
@pengying pengying dismissed shreyav’s stale review June 26, 2026 00:22

The base branch was changed.

…USDC

A RealtimeFundingQuoteSource with a crypto currency (e.g. USDC) requires a
cryptoNetwork, otherwise the quote fails with INVALID_INPUT ("Crypto network
is required ... for a crypto currency"). Pass cryptoNetwork through the
quotes route and add a Funding Network selector to the quote step, shown
only when the source currency is crypto. Fixes the Payout flow when funding
from USDC.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@pengying pengying force-pushed the 06-18-fix_samples_kotlin_select_crypto_network_when_funding_a_quote_from_usdc branch from 51a4aa7 to a950d97 Compare June 26, 2026 00:23

@restamp-bot restamp-bot 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.

a950d97 is a pure rebase onto af8d404. Approving based on @shreyav's previous approval of 51a4aa7.

@pengying pengying merged commit 0b15995 into main Jun 26, 2026
10 checks passed
@pengying pengying deleted the 06-18-fix_samples_kotlin_select_crypto_network_when_funding_a_quote_from_usdc branch June 26, 2026 00:24
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.

2 participants