Skip to content

feat(keyring-api): add optional Balance.metadata#601

Open
ccharly wants to merge 7 commits into
mainfrom
cc/feat/balance-metadata
Open

feat(keyring-api): add optional Balance.metadata#601
ccharly wants to merge 7 commits into
mainfrom
cc/feat/balance-metadata

Conversation

@ccharly

@ccharly ccharly commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Adding a new metadata field for BalanceStruct. This way, asset balances can now provide more "specific" information alongside the current balance.

There is not defined shape, we leave it for the consumer and producer to be in-sync regarding the content of it.


Note

Low Risk
Backward-compatible optional API field on balance/asset structs with added tests; no auth, security, or runtime behavior changes in this diff.

Overview
Adds an optional metadata field on BalanceStruct so producers can attach extra JSON-compatible key/value data next to amount and unit. Validation uses exactOptional(record(string(), JsonStruct)), so the key must be omitted when unused (not undefined) and values must be JSON-safe.

FungibleAssetAmountStruct now spreads BalanceStruct.schema instead of inlining unit / amount, so fungible Asset balances pick up metadata without duplicating fields. Type and runtime tests cover valid metadata on Balance and fungible assets, plus rejection of invalid shapes.

Reviewed by Cursor Bugbot for commit c51e757. Bugbot is set up for automated code reviews on this repo. Configure here.

@ccharly
ccharly marked this pull request as ready for review July 22, 2026 13:04
@ccharly
ccharly requested a review from a team as a code owner July 22, 2026 13:04

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c31e9cf. Configure here.

Comment thread packages/keyring-api/src/api/balance.ts
* Asset amount.
*/
amount: StringNumberStruct,
...BalanceStruct.schema,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just re-inject this schema to avoid drifting. (I almost missed it initially, but Cursor reported it, so I think this refactor makes sense to avoid that in the future)

@ccharly
ccharly enabled auto-merge July 22, 2026 14:51
@ccharly
ccharly disabled auto-merge July 22, 2026 14:51
@ccharly ccharly changed the title feat(keyring-api): add optional balance.metadata feat(keyring-api): add optional Balance.metadata Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant