Skip to content

Commit

Permalink
feat: add mock-qa-rewards-address for rewards table
Browse files Browse the repository at this point in the history
  • Loading branch information
solidovic committed Aug 6, 2024
1 parent 368dc6c commit 9c3484d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
7 changes: 6 additions & 1 deletion features/rewards/hooks/useGetCurrentAddress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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]);

Expand Down
10 changes: 10 additions & 0 deletions utils/qa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <TArrayElement>(
value: TArrayElement[],
key: string,
Expand Down

0 comments on commit 9c3484d

Please sign in to comment.