Commit 313ab35
authored
feat: Update current-account domain for dimension-agnostic Amount (#1242)
* feat: Update current-account domain for dimension-agnostic Amount
Replace Money with Amount throughout the current-account service to
support multi-asset accounts (KWH, CARBON_CREDIT, GPU_HOUR, etc.).
- Add Amount = sharedamount.Amount type alias to domain/quantity.go
- Add NewAmountFromInstrument constructor re-export
- Keep Money = Amount and ErrCurrencyMismatch as deprecated aliases
- Update NewCurrentAccountWithDimension to use NewAmountFromInstrument
- Replace Currency()/CurrencyCode() with InstrumentCode() throughout
- Replace ErrCurrencyMismatch with ErrInstrumentMismatch in account.go
- Update persistence layer to use NewAmountFromInstrument
- Update service layer: grpc_mappers, lien_service, deposit/withdrawal
- Update all tests: use InstrumentCode(), toMinorUnits() helper
- Add multi-asset tests: KWH, CARBON_CREDIT account creation/deposit
Closes asset-agnostic-accounts#16
* fix: Update balance_ownership_test.go for cadomain.Amount API
Replace sharedmoney.Money with cadomain.Amount in MockCurrentAccountService:
- Use cadomain.NewMoney() to convert legacy money.Money for Deposit/Withdraw
- Use caBalance.ToMinorUnits() + money.NewFromMinorUnits() for GetBalance
- Remove unused sharedmoney import
EOF
* fix: set SAGA_ASSET_DIR in E2E workflow for saga script loading
The unified binary loads saga scripts at startup via loadSagaAsset(),
which resolves paths relative to SAGA_ASSET_DIR env var or the
executable directory. In the E2E workflow, the binary is at dist/meridian
but saga files are in the repo checkout root, so assets were not found.
Set SAGA_ASSET_DIR=$(pwd) so the binary finds saga scripts and handlers
schema at services/reference-data/saga/ and shared/pkg/saga/schema/.
* fix: add precision argument to NewCurrentAccountWithDimension test calls
After rebasing with PR #1241 (instrument precision resolution), the
NewCurrentAccountWithDimension function gained a required precision int
parameter. Update test calls for non-CURRENCY dimensions (ENERGY, CARBON)
to pass precision=0, as precision is not validated for non-currency instruments.
* fix: restrict NewMoneyFromInstrument to CURRENCY dimension only
NewMoneyFromInstrument hardcoded precision=2 and would silently mis-scale
non-CURRENCY dimensions (ENERGY, CARBON) when called with incorrect dimension.
Add an explicit CURRENCY dimension guard that returns ErrInvalidCurrency for
non-CURRENCY inputs, preserving the money-only semantics of this deprecated
compatibility API.
---------
Co-authored-by: Ben Coombs <bjcoombs@users.noreply.github.com>1 parent 0ce4eef commit 313ab35
24 files changed
Lines changed: 328 additions & 169 deletions
File tree
- .github/workflows
- services/current-account
- adapters/persistence
- domain
- service
- tests/integration
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
| 157 | + | |
157 | 158 | | |
158 | 159 | | |
159 | 160 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
332 | 332 | | |
333 | 333 | | |
334 | 334 | | |
335 | | - | |
| 335 | + | |
336 | 336 | | |
337 | 337 | | |
338 | 338 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
90 | | - | |
| 90 | + | |
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
691 | 691 | | |
692 | 692 | | |
693 | 693 | | |
694 | | - | |
| 694 | + | |
695 | 695 | | |
696 | 696 | | |
697 | 697 | | |
698 | | - | |
| 698 | + | |
699 | 699 | | |
700 | 700 | | |
701 | 701 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
174 | 174 | | |
175 | 175 | | |
176 | 176 | | |
177 | | - | |
| 177 | + | |
178 | 178 | | |
179 | 179 | | |
180 | 180 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
127 | | - | |
| 127 | + | |
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | 135 | | |
139 | 136 | | |
140 | 137 | | |
141 | 138 | | |
142 | 139 | | |
143 | 140 | | |
144 | | - | |
| 141 | + | |
145 | 142 | | |
146 | 143 | | |
147 | 144 | | |
| |||
152 | 149 | | |
153 | 150 | | |
154 | 151 | | |
155 | | - | |
| 152 | + | |
156 | 153 | | |
157 | 154 | | |
158 | 155 | | |
| |||
164 | 161 | | |
165 | 162 | | |
166 | 163 | | |
167 | | - | |
168 | | - | |
| 164 | + | |
| 165 | + | |
169 | 166 | | |
170 | 167 | | |
171 | 168 | | |
| |||
200 | 197 | | |
201 | 198 | | |
202 | 199 | | |
203 | | - | |
204 | | - | |
| 200 | + | |
| 201 | + | |
205 | 202 | | |
206 | 203 | | |
207 | 204 | | |
| |||
294 | 291 | | |
295 | 292 | | |
296 | 293 | | |
297 | | - | |
298 | | - | |
| 294 | + | |
| 295 | + | |
299 | 296 | | |
300 | 297 | | |
301 | 298 | | |
302 | | - | |
| 299 | + | |
303 | 300 | | |
304 | 301 | | |
305 | 302 | | |
| |||
347 | 344 | | |
348 | 345 | | |
349 | 346 | | |
350 | | - | |
351 | | - | |
| 347 | + | |
| 348 | + | |
352 | 349 | | |
353 | 350 | | |
354 | 351 | | |
355 | | - | |
| 352 | + | |
356 | 353 | | |
357 | 354 | | |
358 | 355 | | |
| |||
0 commit comments