Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,23 @@ jobs:
exit 1
fi

# The release notes come from CHANGELOG.md, not from generated commit titles, so a
# missing entry is a missing release note. Fail here rather than after the upload.
- name: Extract the release notes
run: |
set -euo pipefail
awk -v ver="${{ inputs.version }}" '
$0 == "## " ver { found = 1; next }
found && /^## / { exit }
found { print }
' CHANGELOG.md > release-notes.md
if [ ! -s release-notes.md ]; then
echo "::error::CHANGELOG.md has no '## ${{ inputs.version }}' section. Add one describing the contract change before publishing."
exit 1
fi
echo "Release notes for ${{ inputs.version }}:"
cat release-notes.md

- name: Validate Gradle wrapper
uses: gradle/actions/wrapper-validation@v4

Expand Down Expand Up @@ -122,7 +139,7 @@ jobs:
run: |
gh release create "${{ inputs.version }}" \
--title "${{ inputs.version }}" \
--generate-notes
--notes-file release-notes.md

- name: Summary
run: |
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ local.properties

# Pinned codegen toolchain, installed by scripts/install-swift-toolchain.sh.
.tools/

# Written by publish.yml when it extracts release notes from CHANGELOG.md
release-notes.md
33 changes: 33 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Changelog

Contract changes from a consumer's point of view: what appeared, what changed shape, and what breaks
if you upgrade. Field and enum renumbering matters more than its diff size suggests, so it gets
called out explicitly even when nothing else did.

`publish.yml` reads the section matching the version it is publishing and uses it as the GitHub
release notes, so a version with no entry here does not release. Write the entry in the same PR that
syncs the contract, while the diff is still in front of you.

## 0.2.0

Synced to [`ocp-protobuf-api@ea6418c5`](https://github.com/code-payments/ocp-protobuf-api/commit/ea6418c5561e16771d456062be2fcbd3ddeb9caf).

### Added

- `ocp.balance.v1.Balance`, a new service with one unary RPC, `GetBalance`. It takes an owner account
and returns `core_mint_value`, a `uint64` in quarks, alongside a result enum of `OK`, `DENIED`, and
`NOT_FOUND`.

`GetBalanceRequest` carries no auth or signature field, unlike every other OCP request. It reads
balance for any owner account rather than the caller's own, so there is nothing to sign.

Nothing existing changed. No field number or enum value moved, so upgrading from `0.1.0` needs no
consumer changes.

## 0.1.0

First release. The OCP contract is now generated once here and published for both platforms, replacing
the copies each app vendored and generated for itself.

- Kotlin, on Maven Central as `com.flipcash:ocp-client-protocol`, under `com.codeinc.opencode.gen.*`.
- Swift, as the `OCPClientProtocol` module. The git tag is the SPM release.
201 changes: 201 additions & 0 deletions Sources/OCPClientProtocol/balance_v1_ocp_balance_service.grpc.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
// DO NOT EDIT.
// swift-format-ignore-file
// swiftlint:disable all
//
// Generated by the gRPC Swift generator plugin for the protocol buffer compiler.
// Source: balance/v1/ocp_balance_service.proto
//
// For information on using the generated types, please see the documentation:
// https://github.com/grpc/grpc-swift

import GRPCCore
import GRPCProtobuf

// MARK: - ocp.balance.v1.Balance

/// Namespace containing generated types for the "ocp.balance.v1.Balance" service.
@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
public enum Ocp_Balance_V1_Balance {
/// Service descriptor for the "ocp.balance.v1.Balance" service.
public static let descriptor = GRPCCore.ServiceDescriptor(fullyQualifiedService: "ocp.balance.v1.Balance")
/// Namespace for method metadata.
public enum Method {
/// Namespace for "GetBalance" metadata.
public enum GetBalance {
/// Request type for "GetBalance".
public typealias Input = Ocp_Balance_V1_GetBalanceRequest
/// Response type for "GetBalance".
public typealias Output = Ocp_Balance_V1_GetBalanceResponse
/// Descriptor for "GetBalance".
public static let descriptor = GRPCCore.MethodDescriptor(
service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "ocp.balance.v1.Balance"),
method: "GetBalance"
)
}
/// Descriptors for all methods in the "ocp.balance.v1.Balance" service.
public static let descriptors: [GRPCCore.MethodDescriptor] = [
GetBalance.descriptor
]
}
}

@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
extension GRPCCore.ServiceDescriptor {
/// Service descriptor for the "ocp.balance.v1.Balance" service.
public static let ocp_balance_v1_Balance = GRPCCore.ServiceDescriptor(fullyQualifiedService: "ocp.balance.v1.Balance")
}

// MARK: ocp.balance.v1.Balance (client)

@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
extension Ocp_Balance_V1_Balance {
/// Generated client protocol for the "ocp.balance.v1.Balance" service.
///
/// You don't need to implement this protocol directly, use the generated
/// implementation, ``Client``.
public protocol ClientProtocol: Sendable {
/// Call the "GetBalance" method.
///
/// > Source IDL Documentation:
/// >
/// > GetBalance returns balance data for any owner account
///
/// - Parameters:
/// - request: A request containing a single `Ocp_Balance_V1_GetBalanceRequest` message.
/// - serializer: A serializer for `Ocp_Balance_V1_GetBalanceRequest` messages.
/// - deserializer: A deserializer for `Ocp_Balance_V1_GetBalanceResponse` messages.
/// - options: Options to apply to this RPC.
/// - handleResponse: A closure which handles the response, the result of which is
/// returned to the caller. Returning from the closure will cancel the RPC if it
/// hasn't already finished.
/// - Returns: The result of `handleResponse`.
func getBalance<Result>(
request: GRPCCore.ClientRequest<Ocp_Balance_V1_GetBalanceRequest>,
serializer: some GRPCCore.MessageSerializer<Ocp_Balance_V1_GetBalanceRequest>,
deserializer: some GRPCCore.MessageDeserializer<Ocp_Balance_V1_GetBalanceResponse>,
options: GRPCCore.CallOptions,
onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse<Ocp_Balance_V1_GetBalanceResponse>) async throws -> Result
) async throws -> Result where Result: Sendable
}

/// Generated client for the "ocp.balance.v1.Balance" service.
///
/// The ``Client`` provides an implementation of ``ClientProtocol`` which wraps
/// a `GRPCCore.GRPCCClient`. The underlying `GRPCClient` provides the long-lived
/// means of communication with the remote peer.
public struct Client<Transport>: ClientProtocol where Transport: GRPCCore.ClientTransport {
private let client: GRPCCore.GRPCClient<Transport>

/// Creates a new client wrapping the provided `GRPCCore.GRPCClient`.
///
/// - Parameters:
/// - client: A `GRPCCore.GRPCClient` providing a communication channel to the service.
public init(wrapping client: GRPCCore.GRPCClient<Transport>) {
self.client = client
}

/// Call the "GetBalance" method.
///
/// > Source IDL Documentation:
/// >
/// > GetBalance returns balance data for any owner account
///
/// - Parameters:
/// - request: A request containing a single `Ocp_Balance_V1_GetBalanceRequest` message.
/// - serializer: A serializer for `Ocp_Balance_V1_GetBalanceRequest` messages.
/// - deserializer: A deserializer for `Ocp_Balance_V1_GetBalanceResponse` messages.
/// - options: Options to apply to this RPC.
/// - handleResponse: A closure which handles the response, the result of which is
/// returned to the caller. Returning from the closure will cancel the RPC if it
/// hasn't already finished.
/// - Returns: The result of `handleResponse`.
public func getBalance<Result>(
request: GRPCCore.ClientRequest<Ocp_Balance_V1_GetBalanceRequest>,
serializer: some GRPCCore.MessageSerializer<Ocp_Balance_V1_GetBalanceRequest>,
deserializer: some GRPCCore.MessageDeserializer<Ocp_Balance_V1_GetBalanceResponse>,
options: GRPCCore.CallOptions = .defaults,
onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse<Ocp_Balance_V1_GetBalanceResponse>) async throws -> Result = { response in
try response.message
}
) async throws -> Result where Result: Sendable {
try await self.client.unary(
request: request,
descriptor: Ocp_Balance_V1_Balance.Method.GetBalance.descriptor,
serializer: serializer,
deserializer: deserializer,
options: options,
onResponse: handleResponse
)
}
}
}

// Helpers providing default arguments to 'ClientProtocol' methods.
@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
extension Ocp_Balance_V1_Balance.ClientProtocol {
/// Call the "GetBalance" method.
///
/// > Source IDL Documentation:
/// >
/// > GetBalance returns balance data for any owner account
///
/// - Parameters:
/// - request: A request containing a single `Ocp_Balance_V1_GetBalanceRequest` message.
/// - options: Options to apply to this RPC.
/// - handleResponse: A closure which handles the response, the result of which is
/// returned to the caller. Returning from the closure will cancel the RPC if it
/// hasn't already finished.
/// - Returns: The result of `handleResponse`.
public func getBalance<Result>(
request: GRPCCore.ClientRequest<Ocp_Balance_V1_GetBalanceRequest>,
options: GRPCCore.CallOptions = .defaults,
onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse<Ocp_Balance_V1_GetBalanceResponse>) async throws -> Result = { response in
try response.message
}
) async throws -> Result where Result: Sendable {
try await self.getBalance(
request: request,
serializer: GRPCProtobuf.ProtobufSerializer<Ocp_Balance_V1_GetBalanceRequest>(),
deserializer: GRPCProtobuf.ProtobufDeserializer<Ocp_Balance_V1_GetBalanceResponse>(),
options: options,
onResponse: handleResponse
)
}
}

// Helpers providing sugared APIs for 'ClientProtocol' methods.
@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
extension Ocp_Balance_V1_Balance.ClientProtocol {
/// Call the "GetBalance" method.
///
/// > Source IDL Documentation:
/// >
/// > GetBalance returns balance data for any owner account
///
/// - Parameters:
/// - message: request message to send.
/// - metadata: Additional metadata to send, defaults to empty.
/// - options: Options to apply to this RPC, defaults to `.defaults`.
/// - handleResponse: A closure which handles the response, the result of which is
/// returned to the caller. Returning from the closure will cancel the RPC if it
/// hasn't already finished.
/// - Returns: The result of `handleResponse`.
public func getBalance<Result>(
_ message: Ocp_Balance_V1_GetBalanceRequest,
metadata: GRPCCore.Metadata = [:],
options: GRPCCore.CallOptions = .defaults,
onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse<Ocp_Balance_V1_GetBalanceResponse>) async throws -> Result = { response in
try response.message
}
) async throws -> Result where Result: Sendable {
let request = GRPCCore.ClientRequest<Ocp_Balance_V1_GetBalanceRequest>(
message: message,
metadata: metadata
)
return try await self.getBalance(
request: request,
options: options,
onResponse: handleResponse
)
}
}
Loading