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
42 changes: 42 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,48 @@ called out explicitly even when nothing else did.
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.4.0

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

**Breaking.** `ocp.balance.v1.Balance` had exactly one RPC and it has been replaced, so every
consumer of the service has work to do. There is no deprecation window: `GetBalance` is gone in the
same release that adds `GetBalances`.

### Removed

- `GetBalance`, along with `GetBalanceRequest` and `GetBalanceResponse`.

- `GetBalancesResponse.Result.NOT_FOUND`. `OK` and `DENIED` keep `0` and `1`, so no surviving case
renumbers and no positional mapping shifts underneath you. What changes is that "this owner has no
balance" no longer has a result code: an owner with nothing to report is simply absent from
`balances_by_owner`. Code that branched on `NOT_FOUND` needs to branch on a missing map entry
instead, and code that treated a non-`OK` result as a hard failure will now see `OK` where it used
to see `NOT_FOUND`.

### Added

- `GetBalances`, a unary RPC that batches what `GetBalance` did one owner at a time.

`GetBalancesRequest` takes `repeated owners` (1 to 1024) where the old request took a single
`owner`, plus an optional `repeated mints` filter (up to 1024). Leaving `mints` empty returns
every mint each owner holds, which is the closest thing to the old behaviour.

`GetBalancesResponse` returns `map<string, OwnerBalance> balances_by_owner`, keyed by owner
address. Each `OwnerBalance` carries the `core_mint_value` total in quarks that the old flat
response returned directly, plus `map<string, MintBalance> balances_by_mint` keyed by mint
address for the per-mint breakdown. So the scalar total still exists, one level further down.

Like `GetBalance` before it, `GetBalancesRequest` carries no auth or signature field. It reads
balances for arbitrary owner accounts rather than the caller's own, so there is nothing to sign.

### Migrating

A single-owner call maps across mechanically: wrap the owner in `owners`, leave `mints` empty, and
read `balances_by_owner[owner]?.core_mint_value` where you read `core_mint_value` before. Treat a
missing entry as the old `NOT_FOUND`. The per-mint breakdown and the multi-owner batch are new
capability, not something the old shape expressed, so nothing forces you to use either.

## 0.3.0

No contract change. `ocp.lock` points at the same upstream commit as `0.2.0`, and the generated
Expand Down
96 changes: 50 additions & 46 deletions Sources/OCPClientProtocol/balance_v1_ocp_balance_service.grpc.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@ public enum Ocp_Balance_V1_Balance {
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".
/// Namespace for "GetBalances" metadata.
public enum GetBalances {
/// Request type for "GetBalances".
public typealias Input = Ocp_Balance_V1_GetBalancesRequest
/// Response type for "GetBalances".
public typealias Output = Ocp_Balance_V1_GetBalancesResponse
/// Descriptor for "GetBalances".
public static let descriptor = GRPCCore.MethodDescriptor(
service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "ocp.balance.v1.Balance"),
method: "GetBalance"
method: "GetBalances"
)
}
/// Descriptors for all methods in the "ocp.balance.v1.Balance" service.
public static let descriptors: [GRPCCore.MethodDescriptor] = [
GetBalance.descriptor
GetBalances.descriptor
]
}
}
Expand All @@ -54,27 +54,28 @@ extension Ocp_Balance_V1_Balance {
/// You don't need to implement this protocol directly, use the generated
/// implementation, ``Client``.
public protocol ClientProtocol: Sendable {
/// Call the "GetBalance" method.
/// Call the "GetBalances" method.
///
/// > Source IDL Documentation:
/// >
/// > GetBalance returns balance data for any owner account
/// > GetBalances returns balance data for a set of owner accounts, optionally
/// > filtered by a set of mints
///
/// - 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.
/// - request: A request containing a single `Ocp_Balance_V1_GetBalancesRequest` message.
/// - serializer: A serializer for `Ocp_Balance_V1_GetBalancesRequest` messages.
/// - deserializer: A deserializer for `Ocp_Balance_V1_GetBalancesResponse` 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>,
func getBalances<Result>(
request: GRPCCore.ClientRequest<Ocp_Balance_V1_GetBalancesRequest>,
serializer: some GRPCCore.MessageSerializer<Ocp_Balance_V1_GetBalancesRequest>,
deserializer: some GRPCCore.MessageDeserializer<Ocp_Balance_V1_GetBalancesResponse>,
options: GRPCCore.CallOptions,
onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse<Ocp_Balance_V1_GetBalanceResponse>) async throws -> Result
onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse<Ocp_Balance_V1_GetBalancesResponse>) async throws -> Result
) async throws -> Result where Result: Sendable
}

Expand All @@ -94,33 +95,34 @@ extension Ocp_Balance_V1_Balance {
self.client = client
}

/// Call the "GetBalance" method.
/// Call the "GetBalances" method.
///
/// > Source IDL Documentation:
/// >
/// > GetBalance returns balance data for any owner account
/// > GetBalances returns balance data for a set of owner accounts, optionally
/// > filtered by a set of mints
///
/// - 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.
/// - request: A request containing a single `Ocp_Balance_V1_GetBalancesRequest` message.
/// - serializer: A serializer for `Ocp_Balance_V1_GetBalancesRequest` messages.
/// - deserializer: A deserializer for `Ocp_Balance_V1_GetBalancesResponse` 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>,
public func getBalances<Result>(
request: GRPCCore.ClientRequest<Ocp_Balance_V1_GetBalancesRequest>,
serializer: some GRPCCore.MessageSerializer<Ocp_Balance_V1_GetBalancesRequest>,
deserializer: some GRPCCore.MessageDeserializer<Ocp_Balance_V1_GetBalancesResponse>,
options: GRPCCore.CallOptions = .defaults,
onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse<Ocp_Balance_V1_GetBalanceResponse>) async throws -> Result = { response in
onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse<Ocp_Balance_V1_GetBalancesResponse>) 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,
descriptor: Ocp_Balance_V1_Balance.Method.GetBalances.descriptor,
serializer: serializer,
deserializer: deserializer,
options: options,
Expand All @@ -133,30 +135,31 @@ extension Ocp_Balance_V1_Balance {
// 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.
/// Call the "GetBalances" method.
///
/// > Source IDL Documentation:
/// >
/// > GetBalance returns balance data for any owner account
/// > GetBalances returns balance data for a set of owner accounts, optionally
/// > filtered by a set of mints
///
/// - Parameters:
/// - request: A request containing a single `Ocp_Balance_V1_GetBalanceRequest` message.
/// - request: A request containing a single `Ocp_Balance_V1_GetBalancesRequest` 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>,
public func getBalances<Result>(
request: GRPCCore.ClientRequest<Ocp_Balance_V1_GetBalancesRequest>,
options: GRPCCore.CallOptions = .defaults,
onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse<Ocp_Balance_V1_GetBalanceResponse>) async throws -> Result = { response in
onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse<Ocp_Balance_V1_GetBalancesResponse>) async throws -> Result = { response in
try response.message
}
) async throws -> Result where Result: Sendable {
try await self.getBalance(
try await self.getBalances(
request: request,
serializer: GRPCProtobuf.ProtobufSerializer<Ocp_Balance_V1_GetBalanceRequest>(),
deserializer: GRPCProtobuf.ProtobufDeserializer<Ocp_Balance_V1_GetBalanceResponse>(),
serializer: GRPCProtobuf.ProtobufSerializer<Ocp_Balance_V1_GetBalancesRequest>(),
deserializer: GRPCProtobuf.ProtobufDeserializer<Ocp_Balance_V1_GetBalancesResponse>(),
options: options,
onResponse: handleResponse
)
Expand All @@ -166,11 +169,12 @@ extension Ocp_Balance_V1_Balance.ClientProtocol {
// 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.
/// Call the "GetBalances" method.
///
/// > Source IDL Documentation:
/// >
/// > GetBalance returns balance data for any owner account
/// > GetBalances returns balance data for a set of owner accounts, optionally
/// > filtered by a set of mints
///
/// - Parameters:
/// - message: request message to send.
Expand All @@ -180,19 +184,19 @@ extension Ocp_Balance_V1_Balance.ClientProtocol {
/// 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,
public func getBalances<Result>(
_ message: Ocp_Balance_V1_GetBalancesRequest,
metadata: GRPCCore.Metadata = [:],
options: GRPCCore.CallOptions = .defaults,
onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse<Ocp_Balance_V1_GetBalanceResponse>) async throws -> Result = { response in
onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse<Ocp_Balance_V1_GetBalancesResponse>) async throws -> Result = { response in
try response.message
}
) async throws -> Result where Result: Sendable {
let request = GRPCCore.ClientRequest<Ocp_Balance_V1_GetBalanceRequest>(
let request = GRPCCore.ClientRequest<Ocp_Balance_V1_GetBalancesRequest>(
message: message,
metadata: metadata
)
return try await self.getBalance(
return try await self.getBalances(
request: request,
options: options,
onResponse: handleResponse
Expand Down
Loading
Loading