Skip to content

Commit 81e998c

Browse files
authored
fix(nfts): NFT celebration dynamic config defaultValues (#4922)
### Description All possible dynamic config properties must be listed in `defaultValues` when declaring that config. Otherwise, they [won't be forwarded](https://github.com/valora-inc/wallet/blob/a0b4675774579822a6c2ac55e7de38f6658b45c2/src/statsig/index.ts#L29-L34). ### Test plan * Updated unit tests ### Related issues Related to RET-1000 ### Backwards compatibility NFT celebration is not released yet ### Network scalability If a new NetworkId and/or Network are added in the future, the changes in this PR will: - [x] Continue to work without code changes, OR trigger a compilation error (guaranteeing we find it when a new network is added)
1 parent 107a092 commit 81e998c

File tree

4 files changed

+8
-10
lines changed

4 files changed

+8
-10
lines changed

src/home/celebration/NftCelebration.test.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { render } from '@testing-library/react-native'
22
import React from 'react'
33
import { Provider } from 'react-redux'
4-
import { getDynamicConfigParams, getFeatureGate } from 'src/statsig/index'
4+
import { getFeatureGate } from 'src/statsig/index'
55
import { createMockStore } from 'test/utils'
66
import { mockNftAllFields } from 'test/values'
77
import NftCelebration from './NftCelebration'
@@ -66,10 +66,6 @@ const mockStoreWithDifferentNft = {
6666
describe('NftCelebration', () => {
6767
beforeEach(() => {
6868
jest.mocked(getFeatureGate).mockReturnValue(true)
69-
jest.mocked(getDynamicConfigParams).mockReturnValue({
70-
networkId: mockNftAllFields.networkId,
71-
contractAddress: mockNftAllFields.contractAddress,
72-
})
7369
})
7470

7571
afterEach(() => {

src/nfts/saga.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ describe('Given Nfts saga', () => {
148148
}
149149

150150
jest.mocked(getFeatureGate).mockReturnValue(true)
151-
jest.mocked(getDynamicConfigParams).mockReturnValue(mockCelebratedNft)
151+
jest.mocked(getDynamicConfigParams).mockReturnValue({ celebratedNft: mockCelebratedNft })
152152

153153
return expectSaga(nftSaga.findCelebratedNft, mockAction)
154154
.provide([[select(celebratedNftSelector), null]])
@@ -169,7 +169,7 @@ describe('Given Nfts saga', () => {
169169
}
170170

171171
jest.mocked(getFeatureGate).mockReturnValue(false)
172-
jest.mocked(getDynamicConfigParams).mockReturnValue(mockCelebratedNft)
172+
jest.mocked(getDynamicConfigParams).mockReturnValue({ celebratedNft: mockCelebratedNft })
173173

174174
return expectSaga(nftSaga.findCelebratedNft, mockAction)
175175
.provide([[select(celebratedNftSelector), null]])
@@ -197,7 +197,7 @@ describe('Given Nfts saga', () => {
197197
}
198198

199199
jest.mocked(getFeatureGate).mockReturnValue(true)
200-
jest.mocked(getDynamicConfigParams).mockReturnValue(mockCelebratedNft)
200+
jest.mocked(getDynamicConfigParams).mockReturnValue({ celebratedNft: mockCelebratedNft })
201201

202202
return expectSaga(nftSaga.findCelebratedNft, mockAction)
203203
.provide([[select(celebratedNftSelector), mockCelebratedNft]])

src/nfts/saga.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export function* findCelebratedNft({ payload: { nfts } }: PayloadAction<FetchNft
8282
return
8383
}
8484

85-
const celebratedNft = getDynamicConfigParams(
85+
const { celebratedNft } = getDynamicConfigParams(
8686
DynamicConfigs[StatsigDynamicConfigs.NFT_CELEBRATION_CONFIG]
8787
)
8888
if (!celebratedNft || !celebratedNft.networkId || !celebratedNft.contractAddress) {

src/statsig/constants.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ export const DynamicConfigs = {
105105
},
106106
[StatsigDynamicConfigs.NFT_CELEBRATION_CONFIG]: {
107107
configName: StatsigDynamicConfigs.NFT_CELEBRATION_CONFIG,
108-
defaultValues: {} as { networkId?: NetworkId; contractAddress?: string },
108+
defaultValues: {
109+
celebratedNft: {} as { networkId?: NetworkId; contractAddress?: string },
110+
},
109111
},
110112
}

0 commit comments

Comments
 (0)