From 9c3484d85d33d685882b3e0e6cc16ae3be45a007 Mon Sep 17 00:00:00 2001 From: Anton Shalimov Date: Tue, 6 Aug 2024 12:22:33 +0300 Subject: [PATCH] feat: add `mock-qa-rewards-address` for rewards table --- features/rewards/hooks/useGetCurrentAddress.ts | 7 ++++++- utils/qa.ts | 10 ++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/features/rewards/hooks/useGetCurrentAddress.ts b/features/rewards/hooks/useGetCurrentAddress.ts index 9f46299be..3a0e672c1 100644 --- a/features/rewards/hooks/useGetCurrentAddress.ts +++ b/features/rewards/hooks/useGetCurrentAddress.ts @@ -6,6 +6,7 @@ import { useSDK } from '@lido-sdk/react'; import { resolveEns, isValidEns, isValidAddress } from 'features/rewards/utils'; import { useCurrentStaticRpcProvider } from 'shared/hooks/use-current-static-rpc-provider'; +import { overrideWithQAMockString } from 'utils/qa'; type UseGetCurrentAddress = () => { address: string; @@ -86,7 +87,11 @@ export const useGetCurrentAddress: UseGetCurrentAddress = () => { return; } // From a connected wallet - if (account) setInputValue(account); + if (account) { + setInputValue( + overrideWithQAMockString(account, 'mock-qa-rewards-address'), + ); + } } }, [account, query.address, isReady, setInputValue]); diff --git a/utils/qa.ts b/utils/qa.ts index e5e56bda3..f7b46c421 100644 --- a/utils/qa.ts +++ b/utils/qa.ts @@ -20,6 +20,16 @@ export const overrideWithQAMockNumber = (value: number, key: string) => { return value; }; +export const overrideWithQAMockString = (value: string, key: string) => { + if (config.enableQaHelpers && typeof window !== 'undefined') { + const mock = localStorage.getItem(key); + if (mock) { + return mock; + } + } + return value; +}; + export const overrideWithQAMockArray = ( value: TArrayElement[], key: string,