Skip to content

Commit 5d70e8e

Browse files
authored
fix(jumpstart): correct jumpstart contracts defaultValue (#4923)
### Description 1) 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). 2) In addition, it seems more appropriate to use `NetworkId` as network specifier instead of `Network` to enable jumpstart contracts on the testnet as well. ### Test plan * Updated unit tests ### Related issues - Related to RET-999 ### Backwards compatibility Jumpstart functionality is not fully 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 81e998c commit 5d70e8e

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

src/jumpstart/jumpstartLinkHandler.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { getDynamicConfigParams } from 'src/statsig'
22
import Logger from 'src/utils/Logger'
33
import { fetchWithTimeout } from 'src/utils/fetchWithTimeout'
4+
import networkConfig from 'src/web3/networkConfig'
45
import { mockAccount, mockAccount2 } from 'test/values'
56
import { jumpstartLinkHandler } from './jumpstartLinkHandler'
67

@@ -43,7 +44,9 @@ describe('jumpstartLinkHandler', () => {
4344
;(fetchWithTimeout as jest.Mock).mockImplementation(() => ({
4445
ok: true,
4546
}))
46-
jest.mocked(getDynamicConfigParams).mockReturnValue({ celo: { contractAddress: '0xTEST' } })
47+
jest.mocked(getDynamicConfigParams).mockReturnValue({
48+
jumpstartContracts: { [networkConfig.defaultNetworkId]: { contractAddress: '0xTEST' } },
49+
})
4750

4851
await jumpstartLinkHandler(privateKey, mockAccount2)
4952

src/jumpstart/jumpstartLinkHandler.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import jumpstartAbi from 'src/abis/WalletJumpStart.json'
44
import { getDynamicConfigParams } from 'src/statsig'
55
import { DynamicConfigs } from 'src/statsig/constants'
66
import { StatsigDynamicConfigs } from 'src/statsig/types'
7-
import { Network } from 'src/transactions/types'
87
import Logger from 'src/utils/Logger'
98
import { fetchWithTimeout } from 'src/utils/fetchWithTimeout'
109
import { getWeb3Async } from 'src/web3/contracts'
@@ -16,7 +15,7 @@ const TAG = 'WalletJumpstart'
1615
export async function jumpstartLinkHandler(privateKey: string, userAddress: string) {
1716
const contractAddress = getDynamicConfigParams(
1817
DynamicConfigs[StatsigDynamicConfigs.WALLET_JUMPSTART_CONFIG]
19-
)?.[Network.Celo]?.contractAddress
18+
).jumpstartContracts?.[networkConfig.defaultNetworkId]?.contractAddress
2019

2120
if (!contractAddress) {
2221
Logger.error(TAG, 'Contract address is not provided in dynamic config')

src/statsig/constants.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { StatsigDynamicConfigs, StatsigExperiments, StatsigFeatureGates } from 'src/statsig/types'
2-
import { Network, NetworkId } from 'src/transactions/types'
2+
import { NetworkId } from 'src/transactions/types'
33
import networkConfig from 'src/web3/networkConfig'
44

55
export const FeatureGates = {
@@ -101,7 +101,9 @@ export const DynamicConfigs = {
101101
},
102102
[StatsigDynamicConfigs.WALLET_JUMPSTART_CONFIG]: {
103103
configName: StatsigDynamicConfigs.WALLET_JUMPSTART_CONFIG,
104-
defaultValues: {} as { [key in Network]?: { contractAddress?: string } },
104+
defaultValues: {
105+
jumpstartContracts: {} as { [key in NetworkId]?: { contractAddress?: string } },
106+
},
105107
},
106108
[StatsigDynamicConfigs.NFT_CELEBRATION_CONFIG]: {
107109
configName: StatsigDynamicConfigs.NFT_CELEBRATION_CONFIG,

0 commit comments

Comments
 (0)