diff --git a/CHANGELOG.md b/CHANGELOG.md index 337d0f5..927e263 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,26 @@ 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.7.0 + +Synced to [`ocp-protobuf-api@00ea80d0`](https://github.com/code-payments/ocp-protobuf-api/commit/00ea80d00cf1ce76216937b60cfd60adfd37dc99), +picking up [#69](https://github.com/code-payments/ocp-protobuf-api/pull/69). Only `balance.v1` moved. + +`GetBalances` now reports each mint's balance in quarks, and can skip the per-mint breakdown when a +caller only needs owner totals. Both are additive, so the upgrade is free. + +### Added + +- `MintBalance.quarks` (field 4), a `uint64` holding the balance of that mint in quarks. +- `GetBalancesRequest.exclude_per_mint_balances` (field 4), a `bool`. When true, + `OwnerBalance.balances_by_mint` comes back empty. Owner totals are unaffected and still count + every mint matching the `mints` filter. The default, false, keeps today's response. + +### Unchanged + +Nothing was renumbered, and nothing existing changed type or meaning. No service, RPC, message or +enum case was removed. Everything else in the diff is comments. + ## 0.6.0 Synced to [`ocp-protobuf-api@e3d25a85`](https://github.com/code-payments/ocp-protobuf-api/commit/e3d25a85b1e1ce088e956714e1a71248322e215f), diff --git a/Sources/OCPClientProtocol/ContractInfo.swift b/Sources/OCPClientProtocol/ContractInfo.swift index 1dfcdfe..c12f15f 100644 --- a/Sources/OCPClientProtocol/ContractInfo.swift +++ b/Sources/OCPClientProtocol/ContractInfo.swift @@ -1,8 +1,8 @@ // Generated by scripts/generate-swift.sh. Do not edit. public enum OCPContractInfo { - public static let version = "0.5.0-dev" - public static let protoCommit = "e3d25a85b1e1ce088e956714e1a71248322e215f" + public static let version = "0.7.0-dev" + public static let protoCommit = "00ea80d00cf1ce76216937b60cfd60adfd37dc99" public static var isLocal: Bool { protoCommit == localSentinel } diff --git a/Sources/OCPClientProtocol/balance_v1_ocp_balance_service.pb.swift b/Sources/OCPClientProtocol/balance_v1_ocp_balance_service.pb.swift index 343a8e5..5545ed6 100644 --- a/Sources/OCPClientProtocol/balance_v1_ocp_balance_service.pb.swift +++ b/Sources/OCPClientProtocol/balance_v1_ocp_balance_service.pb.swift @@ -37,6 +37,10 @@ public struct Ocp_Balance_V1_GetBalancesRequest: Sendable { /// empty, only core mint values are returned. public var currencyCodes: [String] = [] + /// When true, OwnerBalance.balances_by_mint is not populated. Owner totals + /// are unaffected and still account for every mint matching the mints filter. + public var excludePerMintBalances: Bool = false + public var unknownFields = SwiftProtobuf.UnknownStorage() public init() {} @@ -109,7 +113,8 @@ public struct Ocp_Balance_V1_OwnerBalance: Sendable { /// The total core mint value, in quarks, across all balances for the owner public var coreMintValue: UInt64 = 0 - /// Individual balances keyed by mint address + /// Individual balances keyed by mint address. Not populated when + /// GetBalancesRequest.exclude_per_mint_balances is true. public var balancesByMint: Dictionary = [:] /// The total fiat value across all balances for the owner, keyed by currency @@ -147,6 +152,9 @@ public struct Ocp_Balance_V1_MintBalance: Sendable { /// GetBalancesRequest.currency_codes. public var fiatValuesByCurrency: Dictionary = [:] + /// The balance amount, in quarks, of the mint the balance is for + public var quarks: UInt64 = 0 + public var unknownFields = SwiftProtobuf.UnknownStorage() public init() {} @@ -160,7 +168,7 @@ fileprivate let _protobuf_package = "ocp.balance.v1" extension Ocp_Balance_V1_GetBalancesRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { public static let protoMessageName: String = _protobuf_package + ".GetBalancesRequest" - public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}owners\0\u{1}mints\0\u{3}currency_codes\0") + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}owners\0\u{1}mints\0\u{3}currency_codes\0\u{3}exclude_per_mint_balances\0") public mutating func decodeMessage(decoder: inout D) throws { while let fieldNumber = try decoder.nextFieldNumber() { @@ -171,6 +179,7 @@ extension Ocp_Balance_V1_GetBalancesRequest: SwiftProtobuf.Message, SwiftProtobu case 1: try { try decoder.decodeRepeatedMessageField(value: &self.owners) }() case 2: try { try decoder.decodeRepeatedMessageField(value: &self.mints) }() case 3: try { try decoder.decodeRepeatedStringField(value: &self.currencyCodes) }() + case 4: try { try decoder.decodeSingularBoolField(value: &self.excludePerMintBalances) }() default: break } } @@ -186,6 +195,9 @@ extension Ocp_Balance_V1_GetBalancesRequest: SwiftProtobuf.Message, SwiftProtobu if !self.currencyCodes.isEmpty { try visitor.visitRepeatedStringField(value: self.currencyCodes, fieldNumber: 3) } + if self.excludePerMintBalances != false { + try visitor.visitSingularBoolField(value: self.excludePerMintBalances, fieldNumber: 4) + } try unknownFields.traverse(visitor: &visitor) } @@ -193,6 +205,7 @@ extension Ocp_Balance_V1_GetBalancesRequest: SwiftProtobuf.Message, SwiftProtobu if lhs.owners != rhs.owners {return false} if lhs.mints != rhs.mints {return false} if lhs.currencyCodes != rhs.currencyCodes {return false} + if lhs.excludePerMintBalances != rhs.excludePerMintBalances {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } @@ -288,7 +301,7 @@ extension Ocp_Balance_V1_OwnerBalance: SwiftProtobuf.Message, SwiftProtobuf._Mes extension Ocp_Balance_V1_MintBalance: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { public static let protoMessageName: String = _protobuf_package + ".MintBalance" - public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}mint\0\u{3}core_mint_value\0\u{3}fiat_values_by_currency\0") + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}mint\0\u{3}core_mint_value\0\u{3}fiat_values_by_currency\0\u{1}quarks\0") public mutating func decodeMessage(decoder: inout D) throws { while let fieldNumber = try decoder.nextFieldNumber() { @@ -299,6 +312,7 @@ extension Ocp_Balance_V1_MintBalance: SwiftProtobuf.Message, SwiftProtobuf._Mess case 1: try { try decoder.decodeSingularMessageField(value: &self._mint) }() case 2: try { try decoder.decodeSingularUInt64Field(value: &self.coreMintValue) }() case 3: try { try decoder.decodeMapField(fieldType: SwiftProtobuf._ProtobufMap.self, value: &self.fiatValuesByCurrency) }() + case 4: try { try decoder.decodeSingularUInt64Field(value: &self.quarks) }() default: break } } @@ -318,6 +332,9 @@ extension Ocp_Balance_V1_MintBalance: SwiftProtobuf.Message, SwiftProtobuf._Mess if !self.fiatValuesByCurrency.isEmpty { try visitor.visitMapField(fieldType: SwiftProtobuf._ProtobufMap.self, value: self.fiatValuesByCurrency, fieldNumber: 3) } + if self.quarks != 0 { + try visitor.visitSingularUInt64Field(value: self.quarks, fieldNumber: 4) + } try unknownFields.traverse(visitor: &visitor) } @@ -325,6 +342,7 @@ extension Ocp_Balance_V1_MintBalance: SwiftProtobuf.Message, SwiftProtobuf._Mess if lhs._mint != rhs._mint {return false} if lhs.coreMintValue != rhs.coreMintValue {return false} if lhs.fiatValuesByCurrency != rhs.fiatValuesByCurrency {return false} + if lhs.quarks != rhs.quarks {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } diff --git a/ocp.lock b/ocp.lock index 0e51570..8e17ded 100644 --- a/ocp.lock +++ b/ocp.lock @@ -1,4 +1,4 @@ # Pinned upstream contract. Regenerate with scripts/sync-protos.sh . upstream: code-payments/ocp-protobuf-api -commit: e3d25a85b1e1ce088e956714e1a71248322e215f -subject: GetBalance now supports balance values across many fiat currencies (#68) +commit: 00ea80d00cf1ce76216937b60cfd60adfd37dc99 +subject: GetBalances now returns per-mint quarks and can exclude per-mint balances (#69) diff --git a/proto/balance/v1/ocp_balance_service.proto b/proto/balance/v1/ocp_balance_service.proto index 40f7f3a..be9c810 100644 --- a/proto/balance/v1/ocp_balance_service.proto +++ b/proto/balance/v1/ocp_balance_service.proto @@ -41,6 +41,10 @@ message GetBalancesRequest { } } }]; + + // When true, OwnerBalance.balances_by_mint is not populated. Owner totals + // are unaffected and still account for every mint matching the mints filter. + bool exclude_per_mint_balances = 4; } message GetBalancesResponse { @@ -61,7 +65,8 @@ message OwnerBalance { // The total core mint value, in quarks, across all balances for the owner uint64 core_mint_value = 2; - // Individual balances keyed by mint address + // Individual balances keyed by mint address. Not populated when + // GetBalancesRequest.exclude_per_mint_balances is true. map balances_by_mint = 3; // The total fiat value across all balances for the owner, keyed by currency @@ -81,4 +86,7 @@ message MintBalance { // populated for the currency codes requested in // GetBalancesRequest.currency_codes. map fiat_values_by_currency = 3; + + // The balance amount, in quarks, of the mint the balance is for + uint64 quarks = 4; }