Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FRONT-1978: Update @streamr/config to the "typed" version (v5.5.0) + clean up #1974

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"@metamask/providers": "^17.1.2",
"@sambego/storybook-styles": "^1.0.0",
"@sentry/react": "^8.34.0",
"@streamr/config": "^5.4.0",
"@streamr/config": "^5.5.0",
"@streamr/hub-contracts": "^1.1.2",
"@streamr/sdk": "^102.0.0",
"@streamr/streamr-icons": "^0.1.9",
Expand Down
4 changes: 2 additions & 2 deletions src/components/ChainSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Chain } from '@streamr/config'
import React from 'react'
import { useSearchParams } from 'react-router-dom'
import styled from 'styled-components'
import { SimpleDropdown, SimpleListDropdownMenu } from '~/components/SimpleDropdown'
import { getEnvironmentConfig } from '~/getters/getEnvironmentConfig'
import UnstyledNetworkIcon from '~/shared/components/NetworkIcon'
import SvgIcon from '~/shared/components/SvgIcon'
import { getSymbolicChainName, useCurrentChain } from '~/utils/chains'
import { COLORS, LAPTOP } from '~/shared/utils/styled'
import { StreamDraft } from '~/stores/streamDraft'
import { Chain } from '~/types'
import { getSymbolicChainName, useCurrentChain } from '~/utils/chains'

type MenuItemProps = {
chain: Chain
Expand Down
2 changes: 1 addition & 1 deletion src/getters/getClientConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function getClientConfig(
if (chainConfig.entryPoints && chainConfig.entryPoints.length > 0) {
config.network = {
controlLayer: {
entryPoints: chainConfig.entryPoints,
entryPoints: [...chainConfig.entryPoints],
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

controlLayer.entryPoints is a mutable collection while chainConfig.entryPoints is a read-only collection. ts rightfully complains.

},
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/pages/ProjectPage/ProjectEditorPage.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Chain } from '@streamr/config'
import React, { useMemo } from 'react'
import { useNavigate } from 'react-router-dom'
import styled, { css } from 'styled-components'
Expand All @@ -21,18 +22,17 @@ import { deleteProject } from '~/services/projects'
import { DetailsPageHeader } from '~/shared/components/DetailsPageHeader'
import LoadingIndicator from '~/shared/components/LoadingIndicator'
import useIsMounted from '~/shared/hooks/useIsMounted'
import { ProjectType, SalePoint } from '~/shared/types'
import { ProjectDraft } from '~/stores/projectDraft'
import { SalePointsPayload } from '~/types/projects'
import { formatChainName } from '~/utils'
import {
getChainConfig,
getChainConfigExtension,
useCurrentChainId,
} from '~/utils/chains'
import { ProjectType, SalePoint } from '~/shared/types'
import { ProjectDraft } from '~/stores/projectDraft'
import { Chain } from '~/types'
import { SalePointsPayload } from '~/types/projects'
import { formatChainName } from '~/utils'
import { toastedOperation } from '~/utils/toastedOperation'
import { Route as R, routeOptions } from '~/utils/routes'
import { toastedOperation } from '~/utils/toastedOperation'
import DataUnionFee from './DataUnionFee'
import DataUnionPayment from './DataUnionPayment'
import EditorHero from './EditorHero'
Expand Down
2 changes: 1 addition & 1 deletion src/parsers/ProjectParser.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Chain } from '@streamr/config'
import { z } from 'zod'
import { address0 } from '~/consts'
import { getProjectImageUrl } from '~/getters'
Expand All @@ -9,7 +10,6 @@ import {
timeUnitSecondsMultiplierMap,
timeUnits,
} from '~/shared/utils/timeUnit'
import { Chain } from '~/types'
import { toBigInt } from '~/utils/bn'
import {
getChainConfig,
Expand Down
27 changes: 0 additions & 27 deletions src/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { config as configs } from '@streamr/config'
import { MessageID } from '@streamr/sdk'
import { TheGraph } from '~/shared/types'

Expand Down Expand Up @@ -42,32 +41,6 @@ export type ChainConfigKey =
| 'minimumDelegationWei'
| 'earlyLeaverPenaltyWei'

type ContractAddressKey = typeof configs extends Record<
any,
Record<'contracts', Partial<Record<infer K, string>>>
>
? K
: never

export interface Chain {
name: string
id: number
theGraphUrl?: string
rpcEndpoints: { url: string }[]
contracts: Partial<Record<ContractAddressKey | (string & {}), string>>
entryPoints?: {
nodeId: string
websocket: {
host: string
port: number
tls: boolean
}
}[]
nativeCurrency: { symbol: string; name: string; decimals: number }
blockExplorerUrl?: string
adminPrivateKey?: string
}

export type OrderDirection = 'asc' | 'desc'

export interface DataPoint {
Expand Down
5 changes: 2 additions & 3 deletions src/utils/chains.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { config as configs } from '@streamr/config'
import { Chain, Config, config as configs } from '@streamr/config'

Check warning on line 1 in src/utils/chains.ts

View workflow job for this annotation

GitHub Actions / eslint, stylelint (18.x)

'Config' is defined but never used. Allowed unused vars must match /^_/u
import { produce } from 'immer'
import { useMemo } from 'react'
import { useSearchParams } from 'react-router-dom'
import { ethereumNetworks } from '~/shared/utils/constants'
import {
ChainConfigExtension,
fallbackChainConfigExtension,
parsedChainConfigExtension,
} from '~/utils/chainConfigExtension'
import { Chain } from '~/types'
import { ethereumNetworks } from '~/shared/utils/constants'
import formatConfigUrl from './formatConfigUrl'

function getPreferredChainName(chainName: string) {
Expand Down
2 changes: 0 additions & 2 deletions src/utils/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ export function getContractAddress(
return contracts.SponsorshipStakeWeightedAllocationPolicy
case 'sponsorshipVoteKickPolicy':
return contracts.SponsorshipVoteKickPolicy
case 'sponsorshipPaymentToken':
return contracts.SponsorshipPaymentToken
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting! sponsorshipPaymentToken is properly resolved by this switch earlier. This here is redundant, plus, sponsorshipPaymentToken doesn't exist on contracts anyway.

Issue detected by the typed config. Pretty cool.

case 'streamRegistry':
return contracts.StreamRegistry
case 'streamStorage':
Expand Down