Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the balance-related methods across the SDK to return a new AddressBalance type that provides both aggregated (overall) balance information and per-vault breakdowns. This change aligns with a new data format from Mycelium Cloud and provides a better API for consumers who need both summary and detailed balance information.
Changes:
- Introduced
AddressBalanceandOverallAddressBalancetypes to replace directVaultBalance[]returns - Updated
getBalances()methods inSparkProtocol,ProxyProtocol, andBaseProtocolto returnAddressBalance - Updated
getEarnBalances()method in wallet classes to returnAddressBalance - Updated all tests to work with the new return type structure
- Updated CLI to access balance data via the new
perVaultproperty
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/sdk/src/types/protocols/general.ts | Added OverallAddressBalance and AddressBalance interfaces with aggregated and per-vault balance information |
| packages/sdk/src/public/types.ts | Exported AddressBalance type from the public SDK API |
| packages/sdk/src/protocols/base/BaseProtocol.ts | Updated abstract getBalances() method signature to return AddressBalance |
| packages/sdk/src/protocols/implementations/SparkProtocol.ts | Refactored getBalances() to return AddressBalance with overall totals and per-vault array |
| packages/sdk/src/protocols/implementations/ProxyProtocol.ts | Updated getBalances() return type and withdraw() method to access perVault property |
| packages/sdk/src/protocols/implementations/SparkProtocol.spec.ts | Updated tests to validate new AddressBalance structure with overall and perVault properties |
| packages/sdk/src/protocols/implementations/ProxyProtocol.spec.ts | Refactored tests to use helper function creating mock AddressBalance objects |
| packages/sdk/src/wallet/base/wallets/SmartWallet.ts | Updated abstract getEarnBalances() return type to AddressBalance | null |
| packages/sdk/src/wallet/DefaultSmartWallet.ts | Updated getEarnBalances() implementation to return AddressBalance |
| packages/sdk/src/wallet/DefaultSmartWallet.spec.ts | Updated tests to work with new return structure and added mock AddressBalance objects |
| packages/cli/src/cli.ts | Updated CLI to access balance data through perVault property of AddressBalance |
| .changeset/spotty-crabs-listen.md | Added changeset documenting the breaking changes as a major version bump |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was changed?
Why was changed/added?
How to use the change?
Use the new return type:
result.overallfor aggregated numbers, result.perVault for the list of vault balances (same structure as before, but under perVault)Example:
and then use
perVault[0].balance,perVault[0].vaultInfo, etc. Replace any code that treated the result as a plain array (e.g.result[0]) withresult.perVault[0]and useresult.overallwhen you need totals