Conversation
Introduce EarnBalanceUpdatable protocol and have BalanceService conform to it so earn balances can be updated via a shared interface. EarnService now accepts an EarnBalanceUpdatable dependency and triggers an earn balance refresh after updating positions. ServicesFactory is updated to inject the balance service into EarnService, and Package.swift adds the BalanceService dependency for the EarnService target. BalanceStore gains hasEarnBalance(...) to gate earn updates, the TransactionStateService testkit adds an EarnBalanceUpdaterMock and updated mock constructor, and a small UI label change for earn deposit was applied. Also bumps core submodule commit.
Show provider/earn-specific labels and capitalize names across stake/transaction/transfer views. Changes include: capitalizing validator name for .earn; adding earnProviderItemModel and routing .earnDeposit/.earnWithdraw to it in TransactionParticipantViewModel (and using Localized.Common.provider as the label); and updating ConfirmRecipientViewModel to use the provider title for .earn and make recipient input visible for earn flows. Files updated: ValidatorViewModel.swift, TransactionParticipantViewModel.swift, ConfirmRecipientViewModel.swift.
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the integration of 'Earn yielder' functionality by introducing a new protocol for managing earn balance updates, refactoring the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request integrates the 'Earn' yielder functionality across various features. The changes include UI updates for displaying earn-related information, service layer modifications to handle earn logic, and database extensions to support earn balances. A notable improvement is the refactoring in EarnService and BalanceService to use the EarnBalanceUpdatable protocol, which decouples the services and improves modularity. My review includes one suggestion for improving code style and readability.
| } | ||
|
|
||
| // earn balance | ||
| if (try? balanceStore.hasEarnBalance(walletId: walletId, chain: chain)) == true { |
There was a problem hiding this comment.
This condition is functionally correct, but it can be written more concisely and idiomatically in Swift. Using the nil-coalescing operator ?? can make the intent clearer by treating a nil result from the throwing function as false.
| if (try? balanceStore.hasEarnBalance(walletId: walletId, chain: chain)) == true { | |
| if (try? balanceStore.hasEarnBalance(walletId: walletId, chain: chain)) ?? false { |
| public struct EarnService: Sendable { | ||
| private let store: StakeStore | ||
| private let gatewayService: GatewayService | ||
| private let earnBalanceUpdater: any EarnBalanceUpdatable |
There was a problem hiding this comment.
| private let earnBalanceUpdater: any EarnBalanceUpdatable | |
| private let balanceUpdater: any EarnBalanceUpdatable |
|
|
||
| try updatePositions(walletId: walletId, assetId: assetId, positions: positions) | ||
|
|
||
| await earnBalanceUpdater.updateEarnBalance(walletId: walletId, chain: assetId.chain, address: address) |
There was a problem hiding this comment.
| await earnBalanceUpdater.updateEarnBalance(walletId: walletId, chain: assetId.chain, address: address) | |
| await balanceUpdater.updateEarnBalance(walletId: walletId, chain: assetId.chain, address: address) |
| ) -> EarnService { | ||
| let provider = NativeProvider(url: Constants.apiURL, requestInterceptor: EmptyRequestInterceptor()) | ||
| return EarnService(store: store, gatewayService: GatewayService(provider: provider)) | ||
| return EarnService(store: store, gatewayService: GatewayService(provider: provider), earnBalanceUpdater: earnBalanceUpdater) |
There was a problem hiding this comment.
| return EarnService(store: store, gatewayService: GatewayService(provider: provider), earnBalanceUpdater: earnBalanceUpdater) | |
| return EarnService(store: store, gatewayService: GatewayService(provider: provider), balanceUpdater: balanceUpdater) |
| try db.read { db in | ||
| try BalanceRecord | ||
| .filter(BalanceRecord.Columns.walletId == walletId.id) | ||
| .filter(BalanceRecord.Columns.assetId.like("\(chain.rawValue)%")) |
There was a problem hiding this comment.
| .filter(BalanceRecord.Columns.assetId.like("\(chain.rawValue)%")) | |
| .filter(BalanceRecord.Columns.chain = chain.rawValue ) |
| private var earnProviderItemModel: TransactionItemModel { | ||
| let address = transactionViewModel.participant | ||
| let addressName = transactionViewModel.getAddressName(address: address) | ||
| let name = (addressName?.name ?? address).capitalized |
There was a problem hiding this comment.
| let name = (addressName?.name ?? address).capitalized |
| return validator.name | ||
| case .earn: | ||
| return validator.name | ||
| return validator.name.capitalized |
There was a problem hiding this comment.
| return validator.name.capitalized | |
| return validator.name |
Update getEarnBalance to accept [AssetId] tokenIds, consistent with tokenBalance pattern. BalanceService passes wallet's token IDs so only chains with matching earn assets trigger RPC calls.
Use contract address as recipient so provider is shown with explorer link, matching staking validator display pattern
No description provided.