Skip to content

Commit 7bd1f8c

Browse files
authored
feat: update current account proto for asset-agnostic fields (#1205)
* feat: update current account proto for asset-agnostic fields Replace currency-specific fields with instrument-agnostic equivalents: - Replace base_currency (Currency enum) with instrument_code (string) in CurrentAccountFacility and InitiateCurrentAccountRequest; supports any instrument code (GBP, kWh, GPU_HOUR, etc.) - Rename account_identification to external_identifier in both messages; remove IBAN-only pattern validation and widen max_len from 34 to 255 to support product-type-specific identifier formats - Remove overdraft_limit field (field 9) from CurrentAccountFacility and mark OverdraftConfiguration message as deprecated; overdraft configuration moves to product type definitions - Add dimension field (field 14) to CurrentAccountFacility for instrument classification (CURRENCY, ENERGY, COMPUTE, CARBON, etc.) - Fix all compile errors in gRPC service layer, test files, and utilities caused by removed and renamed proto fields * fix: update proto test file for renamed and removed fields Update current_account_test.go to use the new asset-agnostic field names: - Replace AccountIdentification with ExternalIdentifier - Replace BaseCurrency with InstrumentCode - Remove OverdraftLimit test (field removed from CurrentAccountFacility) - Replace IBAN format validation test with ExternalIdentifier format test reflecting the widened validation (format now validated by CEL rules) - Add InstrumentCode test covering multi-asset instrument types * fix: update stale base_currency reference in proto comment Replace the comment referencing 'base_currency-derived defaults' in InitiateCurrentAccountRequest.product_type_code with the current approach: when product_type_code is empty, the service uses instrument_code and dimension from the request directly. * test: add ExternalIdentifier max-length boundary tests Add boundary cases for exactly 255 (valid) and 256 (invalid) characters to cover the widened max_len validation on external_identifier field. * fix: update instrument_code comment example to use KWH (uppercase, matching pattern) --------- Co-authored-by: Ben Coombs <bjcoombs@users.noreply.github.com>
1 parent 5220e71 commit 7bd1f8c

9 files changed

Lines changed: 228 additions & 417 deletions

File tree

api/proto/meridian/current_account/v1/current_account.proto

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,11 @@ message CurrentAccountFacility {
115115
pattern: "^[a-zA-Z0-9_-]+$"
116116
}];
117117

118-
// account_identification is the IBAN or other standard account identifier.
119-
// IBAN format: 2 letter country code + 2 check digits + up to 30 alphanumeric characters.
120-
string account_identification = 2 [(buf.validate.field).string = {
118+
// external_identifier is the external account identifier (e.g. IBAN, sort code + account number, or
119+
// any product-type-specific reference). Format validated by product type CEL rules.
120+
string external_identifier = 2 [(buf.validate.field).string = {
121121
min_len: 1
122-
max_len: 34 // IBAN max length
123-
pattern: "^[A-Z]{2}[0-9]{2}[A-Z0-9]{1,30}$" // IBAN format validation
122+
max_len: 255
124123
}];
125124

126125
// account_status is the current lifecycle state of the account
@@ -129,10 +128,11 @@ message CurrentAccountFacility {
129128
not_in: [0] /* Prevent UNSPECIFIED in requests */
130129
}];
131130

132-
// base_currency is the primary currency for this account
133-
meridian.common.v1.Currency base_currency = 4 [(buf.validate.field).enum = {
134-
defined_only: true
135-
not_in: [0] /* Prevent UNSPECIFIED currency */
131+
// instrument_code is the primary instrument for this account (e.g. "GBP", "KWH", "GPU_HOUR").
132+
string instrument_code = 4 [(buf.validate.field).string = {
133+
min_len: 1
134+
max_len: 32
135+
pattern: "^[A-Z][A-Z0-9_]*$"
136136
}];
137137

138138
// created_at is when the account facility was created
@@ -148,8 +148,9 @@ message CurrentAccountFacility {
148148
// Task 5.2: Implement account balance tracking and overdraft limits
149149
AccountBalance current_balance = 8;
150150

151-
// overdraft_limit configures the overdraft facility for this account
152-
OverdraftConfiguration overdraft_limit = 9;
151+
// Field 9 reserved - overdraft_limit removed (use product type configuration instead)
152+
reserved 9;
153+
reserved "overdraft_limit";
153154

154155
// transaction_history tracks recent transactions for this account
155156
// Task 5.4: Add transaction history and account status management features
@@ -167,6 +168,10 @@ message CurrentAccountFacility {
167168

168169
// product_type_version is the pinned version of the product type definition (immutable after creation).
169170
int32 product_type_version = 13;
171+
172+
// dimension classifies the instrument type (e.g. "CURRENCY", "ENERGY", "COMPUTE", "CARBON").
173+
// Used for reporting, validation, and routing. Validated by product type CEL rules.
174+
string dimension = 14;
170175
}
171176

172177
// AccountBalance represents the current balance state of an account
@@ -183,8 +188,10 @@ message AccountBalance {
183188
}
184189

185190
// OverdraftConfiguration defines the overdraft facility settings
186-
// Task 5.2: Overdraft limits
191+
// Deprecated: Overdraft configuration is now managed via product type definitions.
192+
// This message is retained for wire compatibility with existing consumers.
187193
message OverdraftConfiguration {
194+
option deprecated = true;
188195
// overdraft_limit is the maximum overdraft amount allowed
189196
meridian.common.v1.MoneyAmount overdraft_limit = 1 [(buf.validate.field).required = true];
190197

@@ -333,17 +340,18 @@ message InitiateCurrentAccountRequest {
333340
max_len: 100
334341
}];
335342

336-
// account_identification is the IBAN
337-
string account_identification = 2 [(buf.validate.field).string = {
343+
// external_identifier is the external account identifier (e.g. IBAN, sort code + account number, or
344+
// any product-type-specific reference). Format validated by product type CEL rules.
345+
string external_identifier = 2 [(buf.validate.field).string = {
338346
min_len: 1
339-
max_len: 34
340-
pattern: "^[A-Z]{2}[0-9]{2}[A-Z0-9]{1,30}$"
347+
max_len: 255
341348
}];
342349

343-
// base_currency is the account currency
344-
meridian.common.v1.Currency base_currency = 3 [(buf.validate.field).enum = {
345-
defined_only: true
346-
not_in: [0]
350+
// instrument_code is the primary instrument for this account (e.g. "GBP", "KWH", "GPU_HOUR").
351+
string instrument_code = 3 [(buf.validate.field).string = {
352+
min_len: 1
353+
max_len: 32
354+
pattern: "^[A-Z][A-Z0-9_]*$"
347355
}];
348356

349357
// org_party_id references the organization party for org-scoped accounts.
@@ -357,7 +365,7 @@ message InitiateCurrentAccountRequest {
357365
// When provided, the service resolves the product type via LocalAccountTypeCache,
358366
// validates BehaviorClass == CUSTOMER, evaluates EligibilityCEL, validates attributes
359367
// against AttributeSchema, and seeds ValuationFeatures from templates.
360-
// During transition, if empty, the service falls back to base_currency-derived defaults.
368+
// When empty, the service uses instrument_code and dimension from this request directly.
361369
string product_type_code = 5 [(buf.validate.field).string = {
362370
max_len: 50
363371
pattern: "^[A-Z0-9_]*$"

0 commit comments

Comments
 (0)