Skip to content

Use typed Android JSON-RPC params#300

Open
kiftio wants to merge 1 commit into
json-rpc-typing/swift-typed-envelopefrom
json-rpc-typing/android-typed-params
Open

Use typed Android JSON-RPC params#300
kiftio wants to merge 1 commit into
json-rpc-typing/swift-typed-envelopefrom
json-rpc-typing/android-typed-params

Conversation

@kiftio

@kiftio kiftio commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

What changes are you making?

Replaces manual JSON field extraction logic in CheckoutProtocol and EmbeddedCheckoutProtocol with typed, serializable data classes (ReadyParams, CheckoutParams, ErrorParams, WindowOpenParams). Instead of casting JsonElement to JsonObject and manually extracting fields, params are now decoded directly via json.decodeFromJsonElement into the appropriate typed wrapper.

As a side effect, the ec.ready handler now treats non-string values in the delegate array (e.g. null, {}) as a parse error rather than silently ignoring them, which is reflected in the updated test expectations.

How to test

  1. Run the Android unit tests to verify all existing and updated test cases pass:
    ./gradlew :lib:test
    
  2. Verify that ec.ready with a mixed-type delegate array (e.g. ["window.open", null, {}]) now returns a JSON-RPC parse error (-32700) rather than a success response with partial results.
  3. Verify that ec.error, ec.window.open_request, and checkout lifecycle events (ec.checkout.start, etc.) continue to decode correctly when valid params are provided, and return null gracefully on invalid input.

Before you merge

Important

  • I've added tests to support my implementation
  • I have read and agree with the Contribution Guidelines
  • I have read and agree with the Code of Conduct
  • I've updated the relevant platform README (platforms/swift/README.md and/or platforms/android/README.md)

Releasing a new Swift version?
  • I have bumped the version in ShopifyCheckoutKit.podspec
  • I have bumped the version in platforms/swift/Sources/ShopifyCheckoutKit/ShopifyCheckoutKit.swift
  • I have updated platforms/swift/CHANGELOG.md
  • I have updated the SwiftPM/CocoaPods version snippets in platforms/swift/README.md (major version only)
Releasing a new Android version?
  • I have bumped the versionName in platforms/android/lib/build.gradle
  • I have updated platforms/android/CHANGELOG.md
  • I have updated the Gradle/Maven version snippets in platforms/android/README.md

Tip

See the Contributing documentation for the full release process per platform.

kiftio commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@kiftio kiftio mentioned this pull request Jun 18, 2026
11 tasks
@kiftio kiftio marked this pull request as ready for review June 18, 2026 14:03
@kiftio kiftio requested a review from a team as a code owner June 18, 2026 14:03
@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown

React Native — Coverage Report

Lines Statements Branches Functions
Coverage: 92%
91.66% (319/348) 87.86% (181/206) 100% (82/82)

decode = { params ->
((params as? JsonObject)?.get("url") as? JsonPrimitive)?.contentOrNull
?.takeIf { it.isNotBlank() }
json.decodeFromJsonElement<WindowOpenParams>(params ?: JsonNull).url

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

think we've lost some null safety here

@kiftio kiftio force-pushed the json-rpc-typing/android-typed-params branch 2 times, most recently from 8b22ab3 to 80de055 Compare June 18, 2026 14:54
@kiftio kiftio force-pushed the json-rpc-typing/swift-typed-envelope branch from 6c13b4c to 1880dcb Compare June 18, 2026 14:54
@kiftio kiftio force-pushed the json-rpc-typing/android-typed-params branch from 80de055 to 1d0dac2 Compare June 18, 2026 15:01
@kiftio kiftio force-pushed the json-rpc-typing/swift-typed-envelope branch from 1880dcb to b042647 Compare June 18, 2026 15:23
@kiftio kiftio force-pushed the json-rpc-typing/android-typed-params branch from 1d0dac2 to 1f5c3e9 Compare June 18, 2026 15:23
@kiftio kiftio force-pushed the json-rpc-typing/swift-typed-envelope branch from b042647 to 940fa40 Compare June 18, 2026 15:45
@kiftio kiftio force-pushed the json-rpc-typing/android-typed-params branch from 1f5c3e9 to 23452c0 Compare June 18, 2026 15:45
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