Skip to content

Commit

Permalink
Merge pull request #1868 from streamr-dev/FRONT-1840-ethers6
Browse files Browse the repository at this point in the history
FRONT-1840: Ethers v6
  • Loading branch information
mondoreale committed Jul 4, 2024
2 parents ad88842 + 52d019a commit 2b196e4
Show file tree
Hide file tree
Showing 131 changed files with 13,593 additions and 4,533 deletions.
8 changes: 8 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ module.exports = {
],
"@typescript-eslint/no-namespace": "off",
"no-underscore-dangle": "off",
"@typescript-eslint/ban-types": [
"error",
{
"types": {
"{}": false,
},
},
],
},
overrides: [
{
Expand Down
2,600 changes: 1,492 additions & 1,108 deletions package-lock.json

Large diffs are not rendered by default.

18 changes: 10 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"prettier": "pretty-quick --staged",
"prepare": "husky install",
"codegen": "graphql-codegen --config codegen.ts",
"typechain": "typechain --target=ethers-v5 'src/shared/web3/abis/*.json' --out-dir src/generated/types"
"typechain": "npx typechain --target=ethers-v6 --out-dir=src/generated/types/local src/shared/web3/abis/*.json",
"typechain-hub": "npx typechain --target=ethers-v6 --out-dir=src/generated/types/hub ./node_modules/@streamr/hub-contracts/dist/**/*.json"
},
"lint-staged": {
"*.{js,ts,tsx}": [
Expand All @@ -39,16 +40,16 @@
"@apollo/client": "^3.7.16",
"@atlaskit/icon": "^21.11.5",
"@dataunions/client": "^3.0.12",
"@ensdomains/ens-contracts": "^1.1.4",
"@ibm/plex": "^6.3.0",
"@metamask/detect-provider": "^2.0.0",
"@metamask/providers": "^10.2.1",
"@sambego/storybook-styles": "^1.0.0",
"@sentry/browser": "^7.51.2",
"@sentry/integrations": "^7.51.2",
"@streamr/config": "^5.3.11",
"@streamr/hub-contracts": "^1.0.2",
"@streamr/network-contracts": "^7.1.1",
"@streamr/sdk": "^100.2.4",
"@streamr/config": "^5.3.12",
"@streamr/hub-contracts": "^1.1.2",
"@streamr/sdk": "^101.0.0-beta.4",
"@streamr/streamr-icons": "^0.1.9",
"@streamr/streamr-layout": "^2.5.3",
"@tanstack/react-query": "^4.29.5",
Expand All @@ -63,7 +64,7 @@
"dotenv": "^16.0.3",
"dotenv-safe": "^8.2.0",
"ethereumjs-wallet": "^1.0.2",
"ethers": "^5.7.2",
"ethers": "^6.13.1",
"eventemitter3": "^5.0.1",
"events": "^3.3.0",
"file-saver": "^2.0.5",
Expand All @@ -77,6 +78,7 @@
"logrocket": "^4.0.1",
"moment": "^2.29.4",
"moment-timezone": "^0.5.44",
"network-contracts-ethers6": "^7.1.1",
"normalizr": "^3.6.2",
"path-to-regexp": "^6.2.1",
"platform": "^1.3.6",
Expand Down Expand Up @@ -151,7 +153,7 @@
"@storybook/source-loader": "^7.6.6",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^14.0.0",
"@typechain/ethers-v5": "^11.1.1",
"@typechain/ethers-v6": "^0.5.1",
"@types/cypress": "^1.1.3",
"@types/jest": "^29.5.2",
"@types/lunr": "^2.3.4",
Expand Down Expand Up @@ -222,7 +224,7 @@
"ts-loader": "^9.4.3",
"tsconfig-paths-webpack-plugin": "^4.0.1",
"typechain": "^8.3.1",
"typescript": "^5.1.6",
"typescript": "^5.5.2",
"typescript-plugin-css-modules": "^5.0.1",
"typescript-plugin-styled-components": "^3.0.0",
"url-loader": "^4.1.1",
Expand Down
39 changes: 0 additions & 39 deletions src/components/Abbr.tsx

This file was deleted.

5 changes: 2 additions & 3 deletions src/components/ActionBars/ActionBarButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ import SvgIcon from '~/shared/components/SvgIcon'
import { COLORS } from '~/shared/utils/styled'
import { ExternalLinkIcon } from '~/icons'
import { Tooltip } from '~/components/Tooltip'
import { getBlockExplorerUrl } from '~/getters'
import { truncate } from '~/shared/utils/text'
import { CopyButton } from '~/components/CopyButton'
import { useCurrentChainId } from '~/utils/chains'
import { getChainConfig, useCurrentChainId } from '~/utils/chains'

export const ActionBarButtonBody = styled.div<{ $background?: string; $color?: string }>`
align-items: center;
Expand Down Expand Up @@ -116,7 +115,7 @@ export function ActionBarWalletDisplay({
}) {
const chainId = useCurrentChainId()

const blockExplorerUrl = getBlockExplorerUrl(chainId)
const { blockExplorerUrl } = getChainConfig(chainId)

return (
<ActionBarButtonBody>
Expand Down
89 changes: 47 additions & 42 deletions src/components/ActionBars/OperatorActionBar.tsx
Original file line number Diff line number Diff line change
@@ -1,39 +1,37 @@
import React, { FunctionComponent, useMemo } from 'react'
import { useQuery } from '@tanstack/react-query'
import JiraFailedBuildStatusIcon from '@atlaskit/icon/glyph/jira/failed-build-status'
import { useQuery } from '@tanstack/react-query'
import React, { FunctionComponent, useMemo } from 'react'
import { AboutOperator } from '~/components/ActionBars/AboutOperator'
import {
ActionBarButton,
ActionBarButtonCaret,
ActionBarButtonInnerBody,
ActionBarWalletDisplay,
} from '~/components/ActionBars/ActionBarButton'
import { Button } from '~/components/Button'
import SvgIcon from '~/shared/components/SvgIcon'
import useOperatorLiveNodes from '~/hooks/useOperatorLiveNodes'
import { fromAtto } from '~/marketplace/utils/math'
import { useWalletAccount } from '~/shared/stores/wallet'
import { SponsorshipDecimals } from '~/components/Decimals'
import { Hint } from '~/components/Hint'
import { Separator } from '~/components/Separator'
import { SimpleDropdown } from '~/components/SimpleDropdown'
import Spinner from '~/components/Spinner'
import { Separator } from '~/components/Separator'
import StatGrid, { StatCell } from '~/components/StatGrid'
import { Tooltip, TooltipIconWrap } from '~/components/Tooltip'
import { getSelfDelegationFraction, getSpotApy } from '~/getters'
import { ParsedOperator } from '~/parsers/OperatorParser'
import {
useDelegateFunds,
useIsDelegatingFundsToOperator,
useIsUndelegatingFundsToOperator,
useUndelegateFunds,
} from '~/hooks/operators'
import { useInterceptHeartbeats } from '~/hooks/useInterceptHeartbeats'
import { Tooltip, TooltipIconWrap } from '~/components/Tooltip'
import { getOperatorDelegationAmount } from '~/services/operators'
import useOperatorLiveNodes from '~/hooks/useOperatorLiveNodes'
import { PencilIcon } from '~/icons'
import { abbr } from '~/utils'
import {
ActionBarButton,
ActionBarButtonCaret,
ActionBarButtonInnerBody,
ActionBarWalletDisplay,
} from '~/components/ActionBars/ActionBarButton'
import { AboutOperator } from '~/components/ActionBars/AboutOperator'
import { Hint } from '~/components/Hint'
import { useCurrentChainId } from '~/utils/chains'
import { ParsedOperator } from '~/parsers/OperatorParser'
import { getOperatorDelegationAmount } from '~/services/operators'
import SvgIcon from '~/shared/components/SvgIcon'
import { useWalletAccount } from '~/shared/stores/wallet'
import { useCurrentChainId, useCurrentChainSymbolicName } from '~/utils/chains'
import { Route as R, routeOptions } from '~/utils/routes'
import { useCurrentChainSymbolicName } from '~/utils/chains'
import { SponsorshipPaymentTokenName } from '../SponsorshipPaymentTokenName'
import { OperatorAvatar } from '../avatars'
import { AbstractActionBar, Pad } from './AbstractActionBar'
Expand All @@ -51,9 +49,10 @@ export const OperatorActionBar: FunctionComponent<{

const canEdit = !!walletAddress && walletAddress == operator.owner

const ownerDelegationPercentage = useMemo(() => {
return getSelfDelegationFraction(operator).multipliedBy(100)
}, [operator])
const ownerDelegationPercentage = useMemo(
() => getSelfDelegationFraction(operator).multipliedBy(100),
[operator],
)

const isDelegatingFunds = useIsDelegatingFundsToOperator(operator.id, walletAddress)

Expand Down Expand Up @@ -84,12 +83,12 @@ export const OperatorActionBar: FunctionComponent<{
}

return (
await getOperatorDelegationAmount(
(await getOperatorDelegationAmount(
currentChainId,
operator.id,
walletAddress,
)
).isGreaterThan(0)
)) > 0n
)
} catch (e) {
console.warn(
'Failed to load delegation amount',
Expand All @@ -98,9 +97,12 @@ export const OperatorActionBar: FunctionComponent<{
e,
)
}

return null
},
})
const { data: canUndelegate = false } = canUndelegateQuery

const canUndelegate = !!canUndelegateQuery.data

const { metadata } = operator

Expand Down Expand Up @@ -188,7 +190,7 @@ export const OperatorActionBar: FunctionComponent<{
label="Total stake"
tip={
<>
{operator.valueWithoutEarnings.isZero() ? (
{operator.valueWithoutEarnings === 0n ? (
<Tooltip
content={
<p>
Expand Down Expand Up @@ -220,8 +222,10 @@ export const OperatorActionBar: FunctionComponent<{
}
>
<div>
{abbr(fromAtto(operator.valueWithoutEarnings))}{' '}
<SponsorshipPaymentTokenName />
<SponsorshipDecimals
abbr
amount={operator.valueWithoutEarnings}
/>
</div>
</StatCell>
<StatCell
Expand All @@ -236,8 +240,10 @@ export const OperatorActionBar: FunctionComponent<{
</Hint>
}
>
{abbr(fromAtto(operator.totalStakeInSponsorshipsWei))}{' '}
<SponsorshipPaymentTokenName />
<SponsorshipDecimals
abbr
amount={operator.totalStakeInSponsorshipsWei}
/>
</StatCell>
<StatCell
label="Owner's stake"
Expand Down Expand Up @@ -280,7 +286,7 @@ export const OperatorActionBar: FunctionComponent<{
</Hint>
}
>
{operator.metadata?.redundancyFactor?.toString() || '1'}
{operator.metadata.redundancyFactor || 1}
</StatCell>
</StatGrid>
</Pad>
Expand Down Expand Up @@ -334,14 +340,13 @@ export const OperatorActionBar: FunctionComponent<{
</Hint>
}
>
{abbr(
fromAtto(
operator.cumulativeProfitsWei.plus(
operator.cumulativeOperatorsCutWei,
),
),
)}{' '}
<SponsorshipPaymentTokenName />
<SponsorshipDecimals
abbr
amount={
operator.cumulativeProfitsWei +
operator.cumulativeOperatorsCutWei
}
/>
</StatCell>
<StatCell
label="Live nodes"
Expand Down
Loading

0 comments on commit 2b196e4

Please sign in to comment.