diff --git a/app/components/UI/Stake/__mocks__/mockData.ts b/app/components/UI/Stake/__mocks__/mockData.ts index 4e3d6674ebd..43762d3eb16 100644 --- a/app/components/UI/Stake/__mocks__/mockData.ts +++ b/app/components/UI/Stake/__mocks__/mockData.ts @@ -1,5 +1,6 @@ import { ChainId, + StakingApiService, StakingType, type PooledStakes, type VaultData, @@ -94,6 +95,14 @@ export const MOCK_REWARD_DATA = { }, }; +export const MOCK_STAKING_API_SERVICE: Partial = { + fetchFromApi: jest.fn(), + getPooledStakes: jest.fn(), + getVaultData: jest.fn(), + getPooledStakingEligibility: jest.fn(), + baseUrl: 'https://staking.api.com', +}; + const MOCK_POOLED_STAKING_CONTRACT_SERVICE = { chainId: ChainId.ETHEREUM, connectSignerOrProvider: jest.fn(), @@ -111,6 +120,7 @@ const MOCK_POOLED_STAKING_CONTRACT_SERVICE = { export const MOCK_POOL_STAKING_SDK: Stake = { stakingContract: MOCK_POOLED_STAKING_CONTRACT_SERVICE, + stakingApiService: MOCK_STAKING_API_SERVICE as StakingApiService, sdkType: StakingType.POOLED, setSdkType: jest.fn(), }; diff --git a/app/components/UI/Stake/components/StakingConfirmation/ConfirmationFooter/FooterButtonGroup/FooterButtonGroup.test.tsx b/app/components/UI/Stake/components/StakingConfirmation/ConfirmationFooter/FooterButtonGroup/FooterButtonGroup.test.tsx index fdcd012f7b6..b67a2a409e8 100644 --- a/app/components/UI/Stake/components/StakingConfirmation/ConfirmationFooter/FooterButtonGroup/FooterButtonGroup.test.tsx +++ b/app/components/UI/Stake/components/StakingConfirmation/ConfirmationFooter/FooterButtonGroup/FooterButtonGroup.test.tsx @@ -69,6 +69,13 @@ jest.mock('../../../../hooks/usePoolStakedUnstake', () => ({ }), })); +jest.mock('../../../../hooks/usePooledStakes', () => ({ + __esModule: true, + default: () => ({ + refreshPooledStakes: jest.fn(), + }), +})); + describe('FooterButtonGroup', () => { beforeEach(() => { jest.resetAllMocks(); diff --git a/app/components/UI/Stake/sdk/stakeSdkProvider.tsx b/app/components/UI/Stake/sdk/stakeSdkProvider.tsx index 9d946918a59..43ca70d1a90 100644 --- a/app/components/UI/Stake/sdk/stakeSdkProvider.tsx +++ b/app/components/UI/Stake/sdk/stakeSdkProvider.tsx @@ -4,7 +4,6 @@ import { PooledStakingContract, type StakingApiService, isSupportedChain, - ChainId, } from '@metamask/stake-sdk'; import React, { useState, @@ -15,10 +14,7 @@ import React, { import { getProviderByChainId } from '../../../../util/notifications'; import { useSelector } from 'react-redux'; import { selectChainId } from '../../../../selectors/networkController'; -import { hexToDecimal } from '../../../../util/conversions'; - -const hexToChainId = (hex: `0x${string}`): ChainId => - hexToDecimal(hex).toString() as unknown as ChainId; +import { getDecimalChainId } from '../../../../util/networks'; export const SDK = StakeSdk.create({ stakingType: StakingType.POOLED }); @@ -42,7 +38,7 @@ export const StakeSDKProvider: React.FC< const chainId = useSelector(selectChainId); const sdkService = useMemo(() => { - if (!chainId || !isSupportedChain(hexToChainId(chainId))) { + if (!chainId || !isSupportedChain(getDecimalChainId(chainId))) { console.error( 'Failed to initialize Staking SDK Service: chainId unsupported', ); @@ -59,7 +55,7 @@ export const StakeSDKProvider: React.FC< } const sdk = StakeSdk.create({ - chainId: parseInt(hexToChainId(chainId).toString()), + chainId: getDecimalChainId(chainId), stakingType: sdkType, });