Skip to content

Commit

Permalink
feat: updated call arguments for earn controller get pooled stakes me…
Browse files Browse the repository at this point in the history
…thod
  • Loading branch information
Matt561 committed Feb 14, 2025
1 parent 1e5b340 commit 1eeb132
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/earn-controller/src/EarnController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import type {
} from '@metamask/base-controller';
import { BaseController } from '@metamask/base-controller';
import { convertHexToDecimal } from '@metamask/controller-utils';
import type { NetworkControllerStateChangeEvent } from '@metamask/network-controller';
import type {
NetworkControllerGetNetworkClientByIdAction,
NetworkControllerGetStateAction,
NetworkControllerStateChangeEvent,
} from '@metamask/network-controller';
import {
StakeSdk,
Expand Down Expand Up @@ -298,9 +298,10 @@ export class EarnController extends BaseController<
* Fetches updated stake information including lifetime rewards, assets, and exit requests
* from the staking API service and updates the state.
*
* @param resetCache - Control whether the BE cache should be invalidated.
* @returns A promise that resolves when the stakes data has been updated
*/
async refreshPooledStakes(): Promise<void> {
async refreshPooledStakes(resetCache = false): Promise<void> {
const currentAccount = this.#getCurrentAccount();
if (!currentAccount?.address) {
return;
Expand All @@ -312,6 +313,7 @@ export class EarnController extends BaseController<
await this.#stakingApiService.getPooledStakes(
[currentAccount.address],
chainId,
resetCache,
);

this.update((state) => {
Expand Down Expand Up @@ -370,7 +372,7 @@ export class EarnController extends BaseController<
const errors: Error[] = [];

await Promise.all([
this.refreshPooledStakes().catch((error) => {
this.refreshPooledStakes(true).catch((error) => {
errors.push(error);
}),
this.refreshStakingEligibility().catch((error) => {
Expand Down

0 comments on commit 1eeb132

Please sign in to comment.