-
Notifications
You must be signed in to change notification settings - Fork 7
feat!: expose color as a first-class Posting property #139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
1b159d6
378a303
0fa5ddd
f4fae45
6fa2898
cb5e8ce
90dd2ac
36653bc
fbac745
f8b9593
9a568a6
649546a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
|
|
||
| [TestPrettyPrintBalance - 1] | ||
| | [36mAccount[0m | [36mAsset [0m | [36mBalance[0m | | ||
| | alice | EUR/2 | 1 | | ||
| | alice | USD/1234 | 999999 | | ||
| | bob | BTC | 3 | | ||
| | [36mAccount[0m | [36mAsset [0m | [36mColor[0m | [36mBalance[0m | | ||
| | alice | EUR/2 | | 1 | | ||
| | alice | USD/1234 | | 999999 | | ||
| | bob | BTC | | 3 | | ||
| --- |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,13 +38,21 @@ func getAssetScale(asset string) (string, int64) { | |
| return asset, 0 | ||
| } | ||
|
|
||
| // getAssets returns, for a given baseAsset, the per-scale uncolored balance. | ||
| // Asset scaling operates on the uncolored bucket only — colored funds are not | ||
| // implicitly converted across scales. | ||
| func getAssets(balance AccountBalance, baseAsset string) map[int64]*big.Int { | ||
| result := make(map[int64]*big.Int) | ||
| for asset, amount := range balance { | ||
| if strings.HasPrefix(asset, baseAsset) { | ||
| _, scale := getAssetScale(asset) | ||
| result[scale] = amount | ||
| for asset, colorMap := range balance { | ||
| if !strings.HasPrefix(asset, baseAsset) { | ||
| continue | ||
| } | ||
| amount, ok := colorMap[""] | ||
| if !ok { | ||
| continue | ||
| } | ||
| _, scale := getAssetScale(asset) | ||
| result[scale] = amount | ||
|
Comment on lines
+41
to
+55
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't drop the color dimension during scaling lookup.
🤖 Prompt for AI Agents
Comment on lines
+46
to
+55
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use exact base-asset matching here.
Suggested fix for asset, colorMap := range balance {
- if !strings.HasPrefix(asset, baseAsset) {
+ if asset != baseAsset && !strings.HasPrefix(asset, baseAsset+"/") {
continue
}
amount, ok := colorMap[""]
if !ok {
continue🤖 Prompt for AI Agents |
||
| } | ||
| return result | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This matches any asset starting with
baseAsset, sogetAssets(balance, "USD")also includes assets likeUSDCorUSDX/2in the scaling pool. The match should be exact base asset orbaseAsset + "/"; otherwise unrelated asset balances can be converted during asset scaling.