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
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions Sources/OCPClientProtocol/ContractInfo.swift
Original file line number Diff line number Diff line change
@@ -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 }

Expand Down
24 changes: 21 additions & 3 deletions Sources/OCPClientProtocol/balance_v1_ocp_balance_service.pb.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
Expand Down Expand Up @@ -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<String,Ocp_Balance_V1_MintBalance> = [:]

/// The total fiat value across all balances for the owner, keyed by currency
Expand Down Expand Up @@ -147,6 +152,9 @@ public struct Ocp_Balance_V1_MintBalance: Sendable {
/// GetBalancesRequest.currency_codes.
public var fiatValuesByCurrency: Dictionary<String,Double> = [:]

/// The balance amount, in quarks, of the mint the balance is for
public var quarks: UInt64 = 0

public var unknownFields = SwiftProtobuf.UnknownStorage()

public init() {}
Expand All @@ -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<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
while let fieldNumber = try decoder.nextFieldNumber() {
Expand All @@ -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
}
}
Expand All @@ -186,13 +195,17 @@ 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)
}

public static func ==(lhs: Ocp_Balance_V1_GetBalancesRequest, rhs: Ocp_Balance_V1_GetBalancesRequest) -> Bool {
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
}
Expand Down Expand Up @@ -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<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
while let fieldNumber = try decoder.nextFieldNumber() {
Expand All @@ -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<SwiftProtobuf.ProtobufString,SwiftProtobuf.ProtobufDouble>.self, value: &self.fiatValuesByCurrency) }()
case 4: try { try decoder.decodeSingularUInt64Field(value: &self.quarks) }()
default: break
}
}
Expand All @@ -318,13 +332,17 @@ extension Ocp_Balance_V1_MintBalance: SwiftProtobuf.Message, SwiftProtobuf._Mess
if !self.fiatValuesByCurrency.isEmpty {
try visitor.visitMapField(fieldType: SwiftProtobuf._ProtobufMap<SwiftProtobuf.ProtobufString,SwiftProtobuf.ProtobufDouble>.self, value: self.fiatValuesByCurrency, fieldNumber: 3)
}
if self.quarks != 0 {
try visitor.visitSingularUInt64Field(value: self.quarks, fieldNumber: 4)
}
try unknownFields.traverse(visitor: &visitor)
}

public static func ==(lhs: Ocp_Balance_V1_MintBalance, rhs: Ocp_Balance_V1_MintBalance) -> Bool {
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
}
Expand Down
4 changes: 2 additions & 2 deletions ocp.lock
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Pinned upstream contract. Regenerate with scripts/sync-protos.sh <sha>.
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)
10 changes: 9 additions & 1 deletion proto/balance/v1/ocp_balance_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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<string, MintBalance> balances_by_mint = 3;

// The total fiat value across all balances for the owner, keyed by currency
Expand All @@ -81,4 +86,7 @@ message MintBalance {
// populated for the currency codes requested in
// GetBalancesRequest.currency_codes.
map<string, double> fiat_values_by_currency = 3;

// The balance amount, in quarks, of the mint the balance is for
uint64 quarks = 4;
}
Loading