Skip to content

Make protocol agnostic to usage#307

Draft
markmur wants to merge 1 commit into
mainfrom
agnostic-protocol-refactor
Draft

Make protocol agnostic to usage#307
markmur wants to merge 1 commit into
mainfrom
agnostic-protocol-refactor

Conversation

@markmur

@markmur markmur commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

The protocol/ package previously baked in opinions about which checkout events matter and how their payloads should be shaped for consumers, which meant every platform inherited the same curation and any change rippled through the shared layer. This splits those concerns: protocol/ is now purely agnostic — transport (CheckoutTransport), the full generated payload type set, and a generated GeneratedProtocolCatalog describing every OpenRPC method with no view on which ones surface — and each platform's CheckoutKit owns curation (which ec.* events it exposes) and consumer-facing transformation. The Swift transport enum was renamed CheckoutProtocolCheckoutTransport so the kit can own the CheckoutProtocol name as its single curated, consumer-facing namespace. Web and React Native curate the same six events against the generated catalog.


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)

Comment on lines +51 to +58
epCartReady.method,
epCartAuth.method,
epCartError.method,
epCartStart.method,
epCartComplete.method,
epCartLineItemsChange.method,
epCartBuyerChange.method,
epCartMessagesChange.method,

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.

TBD on whether these events should be part of the generated API surface. They're part of the spec so arguably they should.

Comment on lines -1 to -34
import Foundation

public enum CheckoutProtocol {
public static let specVersion = "2026-04-08"

public static let defaultDelegations: [String] = ["window.open"]

package static let readyMethod = "ec.ready"
package static let parseErrorCode = -32700
package static let parseErrorMessage = "Parse error"
package static let methodNotFoundCode = -32601
package static let methodNotFoundMessage = "Method not found"

public static let complete = NotificationDescriptor<Checkout>(method: "ec.complete")
public static let error = NotificationDescriptor<ErrorResponse>(method: "ec.error")
public static let lineItemsChange = NotificationDescriptor<Checkout>(
method: "ec.line_items.change"
)
public static let messagesChange = NotificationDescriptor<Checkout>(
method: "ec.messages.change"
)
public static let start = NotificationDescriptor<Checkout>(method: "ec.start")
public static let totalsChange = NotificationDescriptor<Checkout>(method: "ec.totals.change")

package static let supportedProtocolMethods: Set<String> = [
readyMethod,
start.method,
complete.method,
error.method,
lineItemsChange.method,
messagesChange.method,
totalsChange.method,
windowOpen.method
]

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.

This change lifts the curation out of the protocol into the kit - since that's where the abstraction should live

public static func url(
for url: URL,
delegations: [String] = defaultDelegations
delegations: [String] = []

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.

The protocol should be agnostic to defaults. They should be provided by the kit

@markmur markmur force-pushed the agnostic-protocol-refactor branch from 9b8bfaf to a5da2b9 Compare June 19, 2026 11:22
Comment on lines 2 to 26
#if COCOAPODS
import ShopifyCheckoutKit

extension CheckoutProtocol.Client: @retroactive CheckoutCommunicationProtocol {}
extension CheckoutTransport.Client: @retroactive CheckoutCommunicationProtocol {}

private enum RelayCuration {
static let complete = CheckoutProtocol.complete
static let error = CheckoutProtocol.error
static let lineItemsChange = CheckoutProtocol.lineItemsChange
static let messagesChange = CheckoutProtocol.messagesChange
static let start = CheckoutProtocol.start
static let totalsChange = CheckoutProtocol.totalsChange
}
#else
import ShopifyCheckoutProtocol

private enum RelayCuration {
static let complete = GeneratedProtocolCatalog.ecComplete
static let error = GeneratedProtocolCatalog.ecError
static let lineItemsChange = GeneratedProtocolCatalog.ecLineItemsChange
static let messagesChange = GeneratedProtocolCatalog.ecMessagesChange
static let start = GeneratedProtocolCatalog.ecStart
static let totalsChange = GeneratedProtocolCatalog.ecTotalsChange
}
#endif

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.

TODO: figure out if we can remove this mapping

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