Skip to content

Commit

Permalink
feat: add feature flag for VAI mint warning
Browse files Browse the repository at this point in the history
  • Loading branch information
gleiser-oliveira committed Dec 6, 2023
1 parent eeec567 commit 75d70ce
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 5 deletions.
1 change: 0 additions & 1 deletion src/clients/api/queries/useGetVaults/useGetVaiVault.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ const useGetVaiVault = ({ accountAddress }: { accountAddress?: string }): UseGet
isGetXvsPriceLoading ||
isGetVaiVaultUserInfoLoading;


return {
data,
isLoading,
Expand Down
42 changes: 42 additions & 0 deletions src/hooks/useIsFeatureEnabled/__tests__/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,4 +248,46 @@ describe('useIsFeatureEnabled', () => {

expect(result.current).toBe(false);
});

it('should return false for the VAI mint warning for Prime users on BSC_MAINNET', () => {
(useChainId as Vi.Mock).mockImplementation(() => ({
chainId: ChainId.BSC_MAINNET,
}));

const { result } = renderHook(() =>
useIsFeatureEnabled({
name: 'vaiMintPrimeOnlyWarning',
}),
);

expect(result.current).toBe(false);
});

it('should return true for the VAI mint warning for Prime users on BSC_TESTNET', () => {
(useChainId as Vi.Mock).mockImplementation(() => ({
chainId: ChainId.BSC_TESTNET,
}));

const { result } = renderHook(() =>
useIsFeatureEnabled({
name: 'vaiMintPrimeOnlyWarning',
}),
);

expect(result.current).toBe(true);
});

it('should return false for the VAI mint warning for Prime users on SEPOLIA', () => {
(useChainId as Vi.Mock).mockImplementation(() => ({
chainId: ChainId.SEPOLIA,
}));

const { result } = renderHook(() =>
useIsFeatureEnabled({
name: 'vaiMintPrimeOnlyWarning',
}),
);

expect(result.current).toBe(false);
});
});
1 change: 1 addition & 0 deletions src/hooks/useIsFeatureEnabled/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const featureFlags = {
lunaUstWarning: [ChainId.BSC_MAINNET, ChainId.BSC_TESTNET],
marketHistory: [ChainId.BSC_MAINNET, ChainId.BSC_TESTNET],
marketParticipantCounts: [ChainId.BSC_MAINNET, ChainId.BSC_TESTNET],
vaiMintPrimeOnlyWarning: [ChainId.BSC_TESTNET],
};

export type FeatureFlag = keyof typeof featureFlags;
Expand Down
6 changes: 4 additions & 2 deletions src/packages/contracts/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,10 @@ export const contracts: ContractConfig[] = [
name: 'GovernorBravoDelegate',
abi: GovernorBravoDelegateAbi,
address: {
[ChainId.BSC_TESTNET]: venusGovernanceBscTestnetDeployments.addresses.GovernorBravoDelegator_Proxy,
[ChainId.BSC_MAINNET]: venusGovernanceBscMainnetDeployments.addresses.GovernorBravoDelegator_Proxy,
[ChainId.BSC_TESTNET]:
venusGovernanceBscTestnetDeployments.addresses.GovernorBravoDelegator_Proxy,
[ChainId.BSC_MAINNET]:
venusGovernanceBscMainnetDeployments.addresses.GovernorBravoDelegator_Proxy,
},
},
{
Expand Down
6 changes: 5 additions & 1 deletion src/pages/Vai/MintVai/Form/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@ export const Form: React.FC = () => {
const isPrimeEnabled = useIsFeatureEnabled({
name: 'prime',
});
const shouldShowPrimeOnlyWarning = isPrimeEnabled && !isUserPrime;
const isVaiMintPrimeOnlyWarningEnabled = useIsFeatureEnabled({
name: 'vaiMintPrimeOnlyWarning',
});
const shouldShowPrimeOnlyWarning =
isVaiMintPrimeOnlyWarningEnabled && isPrimeEnabled && !isUserPrime;

const { data: mintableVaiData, isLoading: isGetMintableVaiLoading } = useGetMintableVai(
{
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Vai/MintVai/__tests__/indexPrime.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import TEST_IDS from '../../testIds';
describe('MintVai - Feature enabled: Prime', () => {
beforeEach(() => {
(useIsFeatureEnabled as Vi.Mock).mockImplementation(
({ name }: UseIsFeatureEnabled) => name === 'prime',
({ name }: UseIsFeatureEnabled) => name === 'prime' || name === 'vaiMintPrimeOnlyWarning',
);
});

Expand Down

0 comments on commit 75d70ce

Please sign in to comment.