Skip to content

Commit b08adb9

Browse files
authored
chore(contract): sync ocp protos to ea6418c5 and add a changelog (#4)
* chore(contract): sync ocp protos to ea6418c5 Adds the Balance service: ocp.balance.v1.Balance, one unary RPC GetBalance. Nothing existing changed — the other nine generated Swift files are untouched, so no enum case was renumbered and the toolchain did not move. * chore(release): build release notes from a changelog publish.yml created the GitHub release with --generate-notes, which lists merged PR titles. For a contract package that says nothing useful: 0.1.0 released with a body that was only a "Full Changelog" link, so a consumer reading it could not tell what was in the API. Release notes now come from a CHANGELOG.md section matching the published version, written in the PR that syncs the contract while the diff is still at hand. A version with no section fails the publish, and it fails before the upload, since Maven Central will not take a version number twice.
1 parent b7fa255 commit b08adb9

7 files changed

Lines changed: 458 additions & 3 deletions

File tree

‎.github/workflows/publish.yml‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,23 @@ jobs:
5050
exit 1
5151
fi
5252
53+
# The release notes come from CHANGELOG.md, not from generated commit titles, so a
54+
# missing entry is a missing release note. Fail here rather than after the upload.
55+
- name: Extract the release notes
56+
run: |
57+
set -euo pipefail
58+
awk -v ver="${{ inputs.version }}" '
59+
$0 == "## " ver { found = 1; next }
60+
found && /^## / { exit }
61+
found { print }
62+
' CHANGELOG.md > release-notes.md
63+
if [ ! -s release-notes.md ]; then
64+
echo "::error::CHANGELOG.md has no '## ${{ inputs.version }}' section. Add one describing the contract change before publishing."
65+
exit 1
66+
fi
67+
echo "Release notes for ${{ inputs.version }}:"
68+
cat release-notes.md
69+
5370
- name: Validate Gradle wrapper
5471
uses: gradle/actions/wrapper-validation@v4
5572

@@ -122,7 +139,7 @@ jobs:
122139
run: |
123140
gh release create "${{ inputs.version }}" \
124141
--title "${{ inputs.version }}" \
125-
--generate-notes
142+
--notes-file release-notes.md
126143
127144
- name: Summary
128145
run: |

‎.gitignore‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ local.properties
66

77
# Pinned codegen toolchain, installed by scripts/install-swift-toolchain.sh.
88
.tools/
9+
10+
# Written by publish.yml when it extracts release notes from CHANGELOG.md
11+
release-notes.md

‎CHANGELOG.md‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Changelog
2+
3+
Contract changes from a consumer's point of view: what appeared, what changed shape, and what breaks
4+
if you upgrade. Field and enum renumbering matters more than its diff size suggests, so it gets
5+
called out explicitly even when nothing else did.
6+
7+
`publish.yml` reads the section matching the version it is publishing and uses it as the GitHub
8+
release notes, so a version with no entry here does not release. Write the entry in the same PR that
9+
syncs the contract, while the diff is still in front of you.
10+
11+
## 0.2.0
12+
13+
Synced to [`ocp-protobuf-api@ea6418c5`](https://github.com/code-payments/ocp-protobuf-api/commit/ea6418c5561e16771d456062be2fcbd3ddeb9caf).
14+
15+
### Added
16+
17+
- `ocp.balance.v1.Balance`, a new service with one unary RPC, `GetBalance`. It takes an owner account
18+
and returns `core_mint_value`, a `uint64` in quarks, alongside a result enum of `OK`, `DENIED`, and
19+
`NOT_FOUND`.
20+
21+
`GetBalanceRequest` carries no auth or signature field, unlike every other OCP request. It reads
22+
balance for any owner account rather than the caller's own, so there is nothing to sign.
23+
24+
Nothing existing changed. No field number or enum value moved, so upgrading from `0.1.0` needs no
25+
consumer changes.
26+
27+
## 0.1.0
28+
29+
First release. The OCP contract is now generated once here and published for both platforms, replacing
30+
the copies each app vendored and generated for itself.
31+
32+
- Kotlin, on Maven Central as `com.flipcash:ocp-client-protocol`, under `com.codeinc.opencode.gen.*`.
33+
- Swift, as the `OCPClientProtocol` module. The git tag is the SPM release.
Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
// DO NOT EDIT.
2+
// swift-format-ignore-file
3+
// swiftlint:disable all
4+
//
5+
// Generated by the gRPC Swift generator plugin for the protocol buffer compiler.
6+
// Source: balance/v1/ocp_balance_service.proto
7+
//
8+
// For information on using the generated types, please see the documentation:
9+
// https://github.com/grpc/grpc-swift
10+
11+
import GRPCCore
12+
import GRPCProtobuf
13+
14+
// MARK: - ocp.balance.v1.Balance
15+
16+
/// Namespace containing generated types for the "ocp.balance.v1.Balance" service.
17+
@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
18+
public enum Ocp_Balance_V1_Balance {
19+
/// Service descriptor for the "ocp.balance.v1.Balance" service.
20+
public static let descriptor = GRPCCore.ServiceDescriptor(fullyQualifiedService: "ocp.balance.v1.Balance")
21+
/// Namespace for method metadata.
22+
public enum Method {
23+
/// Namespace for "GetBalance" metadata.
24+
public enum GetBalance {
25+
/// Request type for "GetBalance".
26+
public typealias Input = Ocp_Balance_V1_GetBalanceRequest
27+
/// Response type for "GetBalance".
28+
public typealias Output = Ocp_Balance_V1_GetBalanceResponse
29+
/// Descriptor for "GetBalance".
30+
public static let descriptor = GRPCCore.MethodDescriptor(
31+
service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "ocp.balance.v1.Balance"),
32+
method: "GetBalance"
33+
)
34+
}
35+
/// Descriptors for all methods in the "ocp.balance.v1.Balance" service.
36+
public static let descriptors: [GRPCCore.MethodDescriptor] = [
37+
GetBalance.descriptor
38+
]
39+
}
40+
}
41+
42+
@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
43+
extension GRPCCore.ServiceDescriptor {
44+
/// Service descriptor for the "ocp.balance.v1.Balance" service.
45+
public static let ocp_balance_v1_Balance = GRPCCore.ServiceDescriptor(fullyQualifiedService: "ocp.balance.v1.Balance")
46+
}
47+
48+
// MARK: ocp.balance.v1.Balance (client)
49+
50+
@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
51+
extension Ocp_Balance_V1_Balance {
52+
/// Generated client protocol for the "ocp.balance.v1.Balance" service.
53+
///
54+
/// You don't need to implement this protocol directly, use the generated
55+
/// implementation, ``Client``.
56+
public protocol ClientProtocol: Sendable {
57+
/// Call the "GetBalance" method.
58+
///
59+
/// > Source IDL Documentation:
60+
/// >
61+
/// > GetBalance returns balance data for any owner account
62+
///
63+
/// - Parameters:
64+
/// - request: A request containing a single `Ocp_Balance_V1_GetBalanceRequest` message.
65+
/// - serializer: A serializer for `Ocp_Balance_V1_GetBalanceRequest` messages.
66+
/// - deserializer: A deserializer for `Ocp_Balance_V1_GetBalanceResponse` messages.
67+
/// - options: Options to apply to this RPC.
68+
/// - handleResponse: A closure which handles the response, the result of which is
69+
/// returned to the caller. Returning from the closure will cancel the RPC if it
70+
/// hasn't already finished.
71+
/// - Returns: The result of `handleResponse`.
72+
func getBalance<Result>(
73+
request: GRPCCore.ClientRequest<Ocp_Balance_V1_GetBalanceRequest>,
74+
serializer: some GRPCCore.MessageSerializer<Ocp_Balance_V1_GetBalanceRequest>,
75+
deserializer: some GRPCCore.MessageDeserializer<Ocp_Balance_V1_GetBalanceResponse>,
76+
options: GRPCCore.CallOptions,
77+
onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse<Ocp_Balance_V1_GetBalanceResponse>) async throws -> Result
78+
) async throws -> Result where Result: Sendable
79+
}
80+
81+
/// Generated client for the "ocp.balance.v1.Balance" service.
82+
///
83+
/// The ``Client`` provides an implementation of ``ClientProtocol`` which wraps
84+
/// a `GRPCCore.GRPCCClient`. The underlying `GRPCClient` provides the long-lived
85+
/// means of communication with the remote peer.
86+
public struct Client<Transport>: ClientProtocol where Transport: GRPCCore.ClientTransport {
87+
private let client: GRPCCore.GRPCClient<Transport>
88+
89+
/// Creates a new client wrapping the provided `GRPCCore.GRPCClient`.
90+
///
91+
/// - Parameters:
92+
/// - client: A `GRPCCore.GRPCClient` providing a communication channel to the service.
93+
public init(wrapping client: GRPCCore.GRPCClient<Transport>) {
94+
self.client = client
95+
}
96+
97+
/// Call the "GetBalance" method.
98+
///
99+
/// > Source IDL Documentation:
100+
/// >
101+
/// > GetBalance returns balance data for any owner account
102+
///
103+
/// - Parameters:
104+
/// - request: A request containing a single `Ocp_Balance_V1_GetBalanceRequest` message.
105+
/// - serializer: A serializer for `Ocp_Balance_V1_GetBalanceRequest` messages.
106+
/// - deserializer: A deserializer for `Ocp_Balance_V1_GetBalanceResponse` messages.
107+
/// - options: Options to apply to this RPC.
108+
/// - handleResponse: A closure which handles the response, the result of which is
109+
/// returned to the caller. Returning from the closure will cancel the RPC if it
110+
/// hasn't already finished.
111+
/// - Returns: The result of `handleResponse`.
112+
public func getBalance<Result>(
113+
request: GRPCCore.ClientRequest<Ocp_Balance_V1_GetBalanceRequest>,
114+
serializer: some GRPCCore.MessageSerializer<Ocp_Balance_V1_GetBalanceRequest>,
115+
deserializer: some GRPCCore.MessageDeserializer<Ocp_Balance_V1_GetBalanceResponse>,
116+
options: GRPCCore.CallOptions = .defaults,
117+
onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse<Ocp_Balance_V1_GetBalanceResponse>) async throws -> Result = { response in
118+
try response.message
119+
}
120+
) async throws -> Result where Result: Sendable {
121+
try await self.client.unary(
122+
request: request,
123+
descriptor: Ocp_Balance_V1_Balance.Method.GetBalance.descriptor,
124+
serializer: serializer,
125+
deserializer: deserializer,
126+
options: options,
127+
onResponse: handleResponse
128+
)
129+
}
130+
}
131+
}
132+
133+
// Helpers providing default arguments to 'ClientProtocol' methods.
134+
@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
135+
extension Ocp_Balance_V1_Balance.ClientProtocol {
136+
/// Call the "GetBalance" method.
137+
///
138+
/// > Source IDL Documentation:
139+
/// >
140+
/// > GetBalance returns balance data for any owner account
141+
///
142+
/// - Parameters:
143+
/// - request: A request containing a single `Ocp_Balance_V1_GetBalanceRequest` message.
144+
/// - options: Options to apply to this RPC.
145+
/// - handleResponse: A closure which handles the response, the result of which is
146+
/// returned to the caller. Returning from the closure will cancel the RPC if it
147+
/// hasn't already finished.
148+
/// - Returns: The result of `handleResponse`.
149+
public func getBalance<Result>(
150+
request: GRPCCore.ClientRequest<Ocp_Balance_V1_GetBalanceRequest>,
151+
options: GRPCCore.CallOptions = .defaults,
152+
onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse<Ocp_Balance_V1_GetBalanceResponse>) async throws -> Result = { response in
153+
try response.message
154+
}
155+
) async throws -> Result where Result: Sendable {
156+
try await self.getBalance(
157+
request: request,
158+
serializer: GRPCProtobuf.ProtobufSerializer<Ocp_Balance_V1_GetBalanceRequest>(),
159+
deserializer: GRPCProtobuf.ProtobufDeserializer<Ocp_Balance_V1_GetBalanceResponse>(),
160+
options: options,
161+
onResponse: handleResponse
162+
)
163+
}
164+
}
165+
166+
// Helpers providing sugared APIs for 'ClientProtocol' methods.
167+
@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
168+
extension Ocp_Balance_V1_Balance.ClientProtocol {
169+
/// Call the "GetBalance" method.
170+
///
171+
/// > Source IDL Documentation:
172+
/// >
173+
/// > GetBalance returns balance data for any owner account
174+
///
175+
/// - Parameters:
176+
/// - message: request message to send.
177+
/// - metadata: Additional metadata to send, defaults to empty.
178+
/// - options: Options to apply to this RPC, defaults to `.defaults`.
179+
/// - handleResponse: A closure which handles the response, the result of which is
180+
/// returned to the caller. Returning from the closure will cancel the RPC if it
181+
/// hasn't already finished.
182+
/// - Returns: The result of `handleResponse`.
183+
public func getBalance<Result>(
184+
_ message: Ocp_Balance_V1_GetBalanceRequest,
185+
metadata: GRPCCore.Metadata = [:],
186+
options: GRPCCore.CallOptions = .defaults,
187+
onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse<Ocp_Balance_V1_GetBalanceResponse>) async throws -> Result = { response in
188+
try response.message
189+
}
190+
) async throws -> Result where Result: Sendable {
191+
let request = GRPCCore.ClientRequest<Ocp_Balance_V1_GetBalanceRequest>(
192+
message: message,
193+
metadata: metadata
194+
)
195+
return try await self.getBalance(
196+
request: request,
197+
options: options,
198+
onResponse: handleResponse
199+
)
200+
}
201+
}

0 commit comments

Comments
 (0)