Skip to content

Commit b96d81c

Browse files
committed
Use Chain and Config types from @streamr/config
1 parent d19a6ae commit b96d81c

File tree

7 files changed

+12
-42
lines changed

7 files changed

+12
-42
lines changed

src/components/ChainSelector.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1+
import { Chain } from '@streamr/config'
12
import React from 'react'
23
import { useSearchParams } from 'react-router-dom'
34
import styled from 'styled-components'
45
import { SimpleDropdown, SimpleListDropdownMenu } from '~/components/SimpleDropdown'
56
import { getEnvironmentConfig } from '~/getters/getEnvironmentConfig'
67
import UnstyledNetworkIcon from '~/shared/components/NetworkIcon'
78
import SvgIcon from '~/shared/components/SvgIcon'
8-
import { getSymbolicChainName, useCurrentChain } from '~/utils/chains'
99
import { COLORS, LAPTOP } from '~/shared/utils/styled'
1010
import { StreamDraft } from '~/stores/streamDraft'
11-
import { Chain } from '~/types'
11+
import { getSymbolicChainName, useCurrentChain } from '~/utils/chains'
1212

1313
type MenuItemProps = {
1414
chain: Chain

src/getters/getClientConfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default function getClientConfig(
1717
if (chainConfig.entryPoints && chainConfig.entryPoints.length > 0) {
1818
config.network = {
1919
controlLayer: {
20-
entryPoints: chainConfig.entryPoints,
20+
entryPoints: [...chainConfig.entryPoints],
2121
},
2222
}
2323
}

src/pages/ProjectPage/ProjectEditorPage.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Chain } from '@streamr/config'
12
import React, { useMemo } from 'react'
23
import { useNavigate } from 'react-router-dom'
34
import styled, { css } from 'styled-components'
@@ -21,18 +22,17 @@ import { deleteProject } from '~/services/projects'
2122
import { DetailsPageHeader } from '~/shared/components/DetailsPageHeader'
2223
import LoadingIndicator from '~/shared/components/LoadingIndicator'
2324
import useIsMounted from '~/shared/hooks/useIsMounted'
25+
import { ProjectType, SalePoint } from '~/shared/types'
26+
import { ProjectDraft } from '~/stores/projectDraft'
27+
import { SalePointsPayload } from '~/types/projects'
28+
import { formatChainName } from '~/utils'
2429
import {
2530
getChainConfig,
2631
getChainConfigExtension,
2732
useCurrentChainId,
2833
} from '~/utils/chains'
29-
import { ProjectType, SalePoint } from '~/shared/types'
30-
import { ProjectDraft } from '~/stores/projectDraft'
31-
import { Chain } from '~/types'
32-
import { SalePointsPayload } from '~/types/projects'
33-
import { formatChainName } from '~/utils'
34-
import { toastedOperation } from '~/utils/toastedOperation'
3534
import { Route as R, routeOptions } from '~/utils/routes'
35+
import { toastedOperation } from '~/utils/toastedOperation'
3636
import DataUnionFee from './DataUnionFee'
3737
import DataUnionPayment from './DataUnionPayment'
3838
import EditorHero from './EditorHero'

src/parsers/ProjectParser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Chain } from '@streamr/config'
12
import { z } from 'zod'
23
import { address0 } from '~/consts'
34
import { getProjectImageUrl } from '~/getters'
@@ -9,7 +10,6 @@ import {
910
timeUnitSecondsMultiplierMap,
1011
timeUnits,
1112
} from '~/shared/utils/timeUnit'
12-
import { Chain } from '~/types'
1313
import { toBigInt } from '~/utils/bn'
1414
import {
1515
getChainConfig,

src/types/index.ts

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { config as configs } from '@streamr/config'
21
import { MessageID } from '@streamr/sdk'
32
import { TheGraph } from '~/shared/types'
43

@@ -42,32 +41,6 @@ export type ChainConfigKey =
4241
| 'minimumDelegationWei'
4342
| 'earlyLeaverPenaltyWei'
4443

45-
type ContractAddressKey = typeof configs extends Record<
46-
any,
47-
Record<'contracts', Partial<Record<infer K, string>>>
48-
>
49-
? K
50-
: never
51-
52-
export interface Chain {
53-
name: string
54-
id: number
55-
theGraphUrl?: string
56-
rpcEndpoints: { url: string }[]
57-
contracts: Partial<Record<ContractAddressKey | (string & {}), string>>
58-
entryPoints?: {
59-
nodeId: string
60-
websocket: {
61-
host: string
62-
port: number
63-
tls: boolean
64-
}
65-
}[]
66-
nativeCurrency: { symbol: string; name: string; decimals: number }
67-
blockExplorerUrl?: string
68-
adminPrivateKey?: string
69-
}
70-
7144
export type OrderDirection = 'asc' | 'desc'
7245

7346
export interface DataPoint {

src/utils/chains.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
import { config as configs } from '@streamr/config'
1+
import { Chain, Config, config as configs } from '@streamr/config'
22
import { produce } from 'immer'
33
import { useMemo } from 'react'
44
import { useSearchParams } from 'react-router-dom'
5+
import { ethereumNetworks } from '~/shared/utils/constants'
56
import {
67
ChainConfigExtension,
78
fallbackChainConfigExtension,
89
parsedChainConfigExtension,
910
} from '~/utils/chainConfigExtension'
10-
import { Chain } from '~/types'
11-
import { ethereumNetworks } from '~/shared/utils/constants'
1211
import formatConfigUrl from './formatConfigUrl'
1312

1413
function getPreferredChainName(chainName: string) {

src/utils/contracts.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,6 @@ export function getContractAddress(
9797
return contracts.SponsorshipStakeWeightedAllocationPolicy
9898
case 'sponsorshipVoteKickPolicy':
9999
return contracts.SponsorshipVoteKickPolicy
100-
case 'sponsorshipPaymentToken':
101-
return contracts.SponsorshipPaymentToken
102100
case 'streamRegistry':
103101
return contracts.StreamRegistry
104102
case 'streamStorage':

0 commit comments

Comments
 (0)