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

Develop to main #461

Merged
merged 61 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
9d4fa3d
refactor: remove 'active' from 'useWeb3'
solidovic Jul 14, 2024
6f8b1f7
refactor: remove 'chainId' and 'account' from 'useWeb3'
solidovic Jul 14, 2024
013eb0d
refactor: remove a useWeb3Key
solidovic Jul 14, 2024
ab51d32
refactor(sdk-legacy provider): remove a useWeb3
solidovic Jul 14, 2024
789ea0d
refactor: get error connect from wagmi
solidovic Jul 15, 2024
c9064bc
docs: add todo
solidovic Jul 16, 2024
ea933b2
Merge branch 'develop' into feature/si-1481-remove-using-useweb3-from…
solidovic Jul 16, 2024
f6757b6
fix: use address from wagmi
solidovic Jul 16, 2024
6a94516
Merge branch 'develop' into feature/si-1481-remove-using-useweb3-from…
solidovic Jul 16, 2024
57532d5
Merge branch 'feature/si-1310-unsupported-chain-banner-rework' into f…
solidovic Jul 19, 2024
357872b
fix: after resolve conflicts
solidovic Jul 19, 2024
e8a61fb
Merge branch 'develop' into feature/si-1481-remove-using-useweb3-from…
solidovic Aug 5, 2024
1d33fc7
Merge branch 'develop' into feature/si-1481-remove-using-useweb3-from…
solidovic Aug 5, 2024
7e864e0
fix: use ether balance dedupe
Jeday Aug 8, 2024
7518803
Merge branch 'develop' of github.com:lidofinance/ethereum-staking-wid…
Jeday Aug 8, 2024
7af2cbd
fix: tests (temply)
solidovic Aug 8, 2024
448ed06
feat: custom viem web3 transport
Jeday Aug 8, 2024
b4610f1
feat: use token balance from sdk
Jeday Aug 8, 2024
686897f
fix: use polling
Jeday Aug 8, 2024
95ce456
feat: use united token events subscription
Jeday Aug 9, 2024
d0847d3
feat: use approve
Jeday Aug 9, 2024
fd43861
fix: ipfs support
Jeday Aug 12, 2024
1f369b6
fix: update ratelimit middleware
Jeday Aug 19, 2024
52aef00
Merge branch 'develop' of github.com:lidofinance/ethereum-staking-wid…
Jeday Aug 21, 2024
e37dab3
chore: type import
Jeday Aug 21, 2024
2125464
fix: remove rpc methods
Jeday Aug 21, 2024
bc014ae
feat: rewards page matomo events
manneredboor Aug 21, 2024
012b9c3
fix: rewards balance for inputed address
Jeday Aug 22, 2024
066b6f7
fix: do not send dexes rate request if tvl error occured
manneredboor Aug 22, 2024
d7a84aa
fix: tvl error hook usage
manneredboor Aug 22, 2024
d8884d1
Merge branch 'develop' of github.com:lidofinance/ethereum-staking-wid…
Jeday Aug 23, 2024
160c22d
feat: ledger live claim tooltip
Jeday Aug 26, 2024
7f6f4e2
Merge branch 'develop' of github.com:lidofinance/ethereum-staking-wid…
Jeday Aug 30, 2024
027451c
fix: event subscription
Jeday Aug 30, 2024
c6a0730
fix: await tx with wagmi
Jeday Aug 30, 2024
37043d9
feat: display dashed dex rate for inaccessible withdrawal wsteth amount
manneredboor Sep 3, 2024
86251bf
Merge branch 'develop' into feature/si-1481-remove-using-useweb3-from…
solidovic Sep 3, 2024
98c9c9e
fix: fix after develop merge
solidovic Sep 3, 2024
881d40c
Merge pull request #399 from lidofinance/feature/si-1481-remove-using…
jake4take Sep 4, 2024
8523c4b
Merge pull request #442 from lidofinance/feature/si-1523-rewards-shar…
Vorobeyko Sep 4, 2024
6a54a3c
Merge pull request #443 from lidofinance/feature/si-1439-aggregators-…
Vorobeyko Sep 4, 2024
225dcd7
Merge branch 'develop' of github.com:lidofinance/ethereum-staking-wid…
Jeday Sep 5, 2024
65de0c4
Merge pull request #447 from lidofinance/feature/si-1533-add-hover-on…
Vorobeyko Sep 5, 2024
7be1cba
fix: ipfs rpc check on infra
Jeday Sep 5, 2024
ecb696b
Merge pull request #437 from lidofinance/feature/si-1539-fix-retryaft…
itaven Sep 5, 2024
3009628
Merge branch 'develop' of github.com:lidofinance/ethereum-staking-wid…
Jeday Sep 5, 2024
fef840a
chore: up deps
Jeday Sep 5, 2024
105b167
fix: sdk package
Jeday Sep 5, 2024
5b3e5df
fix: increase balance cache-time
Jeday Sep 6, 2024
4665a1f
feat: mode network multichain banner
manneredboor Sep 6, 2024
96cf9f7
feat: use config for multichain banner
Jeday Sep 6, 2024
c7731f7
Merge pull request #458 from lidofinance/feature/add-multichain-to-co…
Jeday Sep 6, 2024
6f26854
Merge pull request #427 from lidofinance/feature/si-1198-use-ethereum…
Vorobeyko Sep 6, 2024
5f0000c
Merge pull request #457 from lidofinance/feature/si-1593-mode-launch-…
itaven Sep 9, 2024
b4142ca
fix: higher block fetch interval
Jeday Sep 9, 2024
de5b5a8
fix: disable agressive default
Jeday Sep 9, 2024
7a65a1e
fix: unstable query key
Jeday Sep 9, 2024
dcf6b23
fix: refetch allowance data
Jeday Sep 9, 2024
5e226a8
fix: allowance events
Jeday Sep 9, 2024
491b420
test: remove deprecated endpoints from test
Jeday Sep 9, 2024
768123d
Merge pull request #460 from lidofinance/fix/wc-rate-limit
itaven Sep 9, 2024
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
8 changes: 6 additions & 2 deletions IPFS.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"cid": "bafybeib3zmyqlmantvdd6i5q4ehmo4larvorgquyanne3uoqdbedwgh3aq",
"leastSafeVersion": "0.36.1",
"config": {
"enabledWithdrawalDexes": ["one-inch", "paraswap", "bebop"]
"enabledWithdrawalDexes": ["one-inch", "paraswap", "bebop"],
"multiChainBanner": [324, 10, 42161, 137, 8453, 5000, 59144, 534352, 56]
}
},
"5": {
Expand All @@ -16,7 +17,10 @@
"cid": "bafybeibbsoqlofslw273b4ih2pdxfaz2zbjmred2ijog725tcmfoewix7y",
"leastSafeVersion": "0.36.1",
"config": {
"enabledWithdrawalDexes": ["one-inch", "paraswap", "bebop"]
"enabledWithdrawalDexes": ["one-inch", "paraswap", "bebop"],
"multiChainBanner": [
324, 10, 42161, 137, 8453, 5000, 59144, 534352, 56, 34443
]
}
}
}
11 changes: 11 additions & 0 deletions assets/icons/lido-multichain/mode.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions config/external-config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export type ManifestEntry = {

export type ManifestConfig = {
enabledWithdrawalDexes: DexWithdrawalApi[];
multiChainBanner: number[];
};

export type ExternalConfig = Omit<ManifestEntry, 'config'> &
Expand Down
55 changes: 44 additions & 11 deletions config/external-config/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,45 @@ import { getDexConfig } from 'features/withdrawals/request/withdrawal-rates';

import FallbackLocalManifest from 'IPFS.json' assert { type: 'json' };

// TODO: refactor on config expansion
const isEnabledDexesValid = (config: object) => {
if (
!(
'enabledWithdrawalDexes' in config &&
Array.isArray(config.enabledWithdrawalDexes)
)
)
return false;

const enabledWithdrawalDexes = config.enabledWithdrawalDexes;

if (
!enabledWithdrawalDexes.every(
(dex) => typeof dex === 'string' && dex !== '',
)
)
return false;

return new Set(enabledWithdrawalDexes).size === enabledWithdrawalDexes.length;
};

const isMultiChainBannerValid = (config: object) => {
// allow empty config
if (!('multiChainBanner' in config) || !config.multiChainBanner) return true;

if (!Array.isArray(config.multiChainBanner)) return false;

const multiChainBanner = config.multiChainBanner;

if (
!multiChainBanner.every(
(chainId) => typeof chainId === 'number' && chainId > 0,
)
)
return false;

return !(new Set(multiChainBanner).size !== multiChainBanner.length);
};

export const isManifestEntryValid = (
entry?: unknown,
): entry is ManifestEntry => {
Expand All @@ -18,16 +56,10 @@ export const isManifestEntryValid = (
entry.config
) {
const config = entry.config;
if (
'enabledWithdrawalDexes' in config &&
Array.isArray(config.enabledWithdrawalDexes)
) {
const enabledWithdrawalDexes = config.enabledWithdrawalDexes;
return (
new Set(enabledWithdrawalDexes).size === enabledWithdrawalDexes.length
);
}
return false;

return [isEnabledDexesValid, isMultiChainBannerValid]
.map((validator) => validator(config))
.every((isValid) => isValid);
}
return false;
};
Expand All @@ -39,6 +71,7 @@ export const getBackwardCompatibleConfig = (
enabledWithdrawalDexes: config.enabledWithdrawalDexes.filter(
(dex) => !!getDexConfig(dex),
),
multiChainBanner: config.multiChainBanner ?? [],
};
};

Expand Down
13 changes: 0 additions & 13 deletions config/groups/revalidation.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,2 @@
import type { ManifestConfig, ManifestEntry } from 'config/external-config';

export const DEFAULT_REVALIDATION = 60 * 15; // 15 minutes
export const ERROR_REVALIDATION_SECONDS = 60; // 1 minute

export const FALLBACK_CONFIG: ManifestConfig = {
enabledWithdrawalDexes: [],
};

export const FALLBACK_MANIFEST_ENTRY: ManifestEntry = {
cid: undefined,
ens: undefined,
leastSafeVersion: undefined,
config: FALLBACK_CONFIG,
};
2 changes: 2 additions & 0 deletions config/groups/web3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { parseEther } from '@ethersproject/units';

// interval in ms for RPC event polling for token balance and tx updates
export const PROVIDER_POLLING_INTERVAL = 12_000;
// how long in ms to wait for RPC batching(multicall and provider)
export const PROVIDER_BATCH_TIME = 150;

// account for gas estimation
// will always have >=0.001 ether, >=0.001 stETH, >=0.001 wstETH
Expand Down
1 change: 1 addition & 0 deletions consts/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ export enum LIDO_MULTICHAIN_CHAINS {
Linea = 59144,
Scroll = 534352,
'BNB Chain' = 56,
'Mode Chain' = 34443,
}
2 changes: 1 addition & 1 deletion consts/external-links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ export const LINK_ADD_NFT_GUIDE = `${config.helpOrigin}/en/articles/7858367-how-
export const OPEN_OCEAN_REFERRAL_ADDRESS =
'0xbb1263222b2c020f155d409dba05c4a3861f18f8';

// for dev and local testing you can set to 'http:/localhost:3000/runtime/IPFS.json' and have file at /public/runtime/IPFS.json
// for dev and local testing you can set to 'http://localhost:3000/runtime/IPFS.json' and have file at /public/runtime/IPFS.json
export const IPFS_MANIFEST_URL =
'https://raw.githubusercontent.com/lidofinance/ethereum-staking-widget/main/IPFS.json';
52 changes: 52 additions & 0 deletions consts/matomo-click-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ export const enum MATOMO_CLICK_EVENTS_TYPES {
// /withdrawal/request and /withdrawal/claim shared events
withdrawalWhatAreStakingPenaltiesFAQ = 'withdrawalWhatAreStakingPenaltiesFAQ',
withdrawalNFTGuideFAQ = 'withdrawalNFTGuideFAQ',

// /rewards page
rewardsExportCSV = 'rewardsExportCSV',
rewardsHistoricalStethPriceCheck = 'rewardsHistoricalStethPriceCheck',
rewardsHistoricalStethPriceUncheck = 'rewardsHistoricalStethPriceUncheck',
rewardsIncludeTransfersCheck = 'rewardsIncludeTransfersCheck',
rewardsIncludeTransfersUncheck = 'rewardsIncludeTransfersUncheck',
rewardsHistoricalCurrencyUSD = 'rewardsHistoricalCurrencyUSD',
rewardsHistoricalCurrencyEUR = 'rewardsHistoricalCurrencyEUR',
rewardsHistoricalCurrencyGBP = 'rewardsHistoricalCurrencyGBP',
}

export const MATOMO_CLICK_EVENTS: Record<
Expand Down Expand Up @@ -339,4 +349,46 @@ export const MATOMO_CLICK_EVENTS: Record<
'Push on "How do I add the Lido NFT to my wallet" guide link in FAQ',
'eth_withdrawals_how_to_add_nft_guide_FAQ',
],

// /rewards page
[MATOMO_CLICK_EVENTS_TYPES.rewardsExportCSV]: [
'Ethereum_Rewards_Widget',
'Click on "Export CSV"',
'eth_rewards_export_csv',
],
[MATOMO_CLICK_EVENTS_TYPES.rewardsHistoricalStethPriceCheck]: [
'Ethereum_Rewards_Widget',
'Click check on "Historical stETH price" in check-box',
'eth_historical_stETH_price_check_box_check',
],
[MATOMO_CLICK_EVENTS_TYPES.rewardsHistoricalStethPriceUncheck]: [
'Ethereum_Rewards_Widget',
'Click uncheck on "Historical stETH price" in check-box',
'eth_historical_stETH_price_check_box_uncheck',
],
[MATOMO_CLICK_EVENTS_TYPES.rewardsIncludeTransfersCheck]: [
'Ethereum_Rewards_Widget',
'Click check on "Include transfers" in check-box',
'eth_include_transfers_check_box_check',
],
[MATOMO_CLICK_EVENTS_TYPES.rewardsIncludeTransfersUncheck]: [
'Ethereum_Rewards_Widget',
'Click uncheck on "Include transfers" in check-box',
'eth_include_transfers_check_box_uncheck',
],
[MATOMO_CLICK_EVENTS_TYPES.rewardsHistoricalCurrencyUSD]: [
'Ethereum_Rewards_Widget',
'Click on "USD" in currency choice',
'eth_historical_usd_currency_choice',
],
[MATOMO_CLICK_EVENTS_TYPES.rewardsHistoricalCurrencyEUR]: [
'Ethereum_Rewards_Widget',
'Click on "EUR" in currency choice',
'eth_historical_eur_currency_choice',
],
[MATOMO_CLICK_EVENTS_TYPES.rewardsHistoricalCurrencyGBP]: [
'Ethereum_Rewards_Widget',
'Click on "GBP" in currency choice',
'eth_historical_gbp_currency_choice',
],
};
8 changes: 4 additions & 4 deletions features/ipfs/security-status-banner/use-version-check.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { useEffect, useState } from 'react';
import { useLidoSWR } from '@lido-sdk/react';
import { useWeb3 } from 'reef-knot/web3-react';
import { useForceDisconnect } from 'reef-knot/core-react';
import { useLidoSWR } from '@lido-sdk/react';

import buildInfo from 'build-info.json';
import { config } from 'config';
import { useUserConfig } from 'config/user-config';
import { STRATEGY_IMMUTABLE } from 'consts/swr-strategies';
import { useDappStatus } from 'shared/hooks/use-dapp-status';
import { overrideWithQAMockBoolean } from 'utils/qa';

import { isVersionLess } from './utils';
Expand All @@ -19,7 +19,7 @@ const URL_CID_REGEX =
/[/.](?<cid>Qm[1-9A-HJ-NP-Za-km-z]{44,}|b[A-Za-z2-7]{58,}|B[A-Z2-7]{58,}|z[1-9A-HJ-NP-Za-km-z]{48,}|F[0-9A-F]{50,})([./#?]|$)/;

export const useVersionCheck = () => {
const { active } = useWeb3();
const { isDappActive } = useDappStatus();
const { setIsWalletConnectionAllowed } = useUserConfig();
const { forceDisconnect } = useForceDisconnect();
const [areConditionsAccepted, setConditionsAccepted] = useState(false);
Expand Down Expand Up @@ -84,7 +84,7 @@ export const useVersionCheck = () => {
forceDisconnect();
}
}, [
active,
isDappActive,
forceDisconnect,
isNotVerifiable,
isVersionUnsafe,
Expand Down
3 changes: 3 additions & 0 deletions features/rewards/components/export/Export.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { backendRequest } from 'features/rewards/fetchers/backend';
import { ButtonStyle } from './Exportstyled';

import type { CurrencyType } from 'features/rewards/constants';
import { trackEvent } from '@lidofinance/analytics-matomo';
import { MATOMO_CLICK_EVENTS } from 'consts/matomo-click-events';

type ExportProps = {
currency: CurrencyType;
Expand Down Expand Up @@ -33,6 +35,7 @@ export const Export = ({
});
const formatted = genExportData(currencyObject, result.events);
saveAsCSV(formatted);
trackEvent(...MATOMO_CLICK_EVENTS.rewardsExportCSV);
};

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { FC } from 'react';
import { Loader, Divider } from '@lidofinance/lido-ui';
import { useSDK, useTokenBalance } from '@lido-sdk/react';
import { TOKENS, getTokenAddress } from '@lido-sdk/constants';
import { Zero } from '@ethersproject/constants';

import { STRATEGY_LAZY } from 'consts/swr-strategies';
import { useRewardsHistory } from 'features/rewards/hooks';
import { ErrorBlockNoSteth } from 'features/rewards/components/errorBlocks/ErrorBlockNoSteth';
import { RewardsTable } from 'features/rewards/components/rewardsTable';
import { useStethBalance } from 'shared/hooks/use-balance';
import { useDappStatus } from 'shared/hooks/use-dapp-status';

import { RewardsListsEmpty } from './RewardsListsEmpty';
Expand All @@ -19,6 +17,8 @@ import {
ErrorWrapper,
} from './RewardsListContentStyles';

import type { Address } from 'viem';

export const RewardsListContent: FC = () => {
const { isWalletConnected, isSupportedChain } = useDappStatus();
const {
Expand All @@ -31,14 +31,11 @@ export const RewardsListContent: FC = () => {
setPage,
isLagging,
} = useRewardsHistory();
// temporarily until we switched to a new SDK
const { chainId } = useSDK();
const { data: stethBalance, initialLoading: isStethBalanceLoading } =
useTokenBalance(
getTokenAddress(chainId || 1, TOKENS.STETH),
address,
STRATEGY_LAZY,
);
const { data: stethBalance, isLoading: isStethBalanceLoading } =
useStethBalance({
account: address as Address,
shouldSubscribeToUpdates: false,
});
const hasSteth = stethBalance?.gt(Zero);

if (isWalletConnected && !isSupportedChain)
Expand Down
22 changes: 18 additions & 4 deletions features/rewards/components/rewardsListHeader/LeftOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { Tooltip, Checkbox } from '@lidofinance/lido-ui';

import { useRewardsHistory } from 'features/rewards/hooks/useRewardsHistory';
import { LeftOptionsWrapper } from './styles';
import { trackEvent } from '@lidofinance/analytics-matomo';
import { MATOMO_CLICK_EVENTS } from 'consts/matomo-click-events';

export const LeftOptions: FC = () => {
const {
Expand All @@ -20,7 +22,14 @@ export const LeftOptions: FC = () => {
>
<Checkbox
checked={isIncludeTransfers}
onChange={() => setIsIncludeTransfers(!isIncludeTransfers)}
onChange={() => {
trackEvent(
...(!isIncludeTransfers
? MATOMO_CLICK_EVENTS.rewardsIncludeTransfersCheck
: MATOMO_CLICK_EVENTS.rewardsIncludeTransfersUncheck),
);
setIsIncludeTransfers(!isIncludeTransfers);
}}
data-testid="includeTransfersCheckbox"
label="Include transfers"
/>
Expand All @@ -33,9 +42,14 @@ export const LeftOptions: FC = () => {
>
<Checkbox
checked={isUseArchiveExchangeRate}
onChange={() =>
setIsUseArchiveExchangeRate(!isUseArchiveExchangeRate)
}
onChange={() => {
trackEvent(
...(!isUseArchiveExchangeRate
? MATOMO_CLICK_EVENTS.rewardsHistoricalStethPriceCheck
: MATOMO_CLICK_EVENTS.rewardsHistoricalStethPriceUncheck),
);
setIsUseArchiveExchangeRate(!isUseArchiveExchangeRate);
}}
data-testid="historicalStEthCheckbox"
label="Historical stETH price"
/>
Expand Down
17 changes: 16 additions & 1 deletion features/rewards/components/rewardsListHeader/RightOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ import { Export } from 'features/rewards/components/export';

import { RightOptionsWrapper } from './styles';
import { useRewardsHistory } from 'features/rewards/hooks/useRewardsHistory';
import { MatomoEventType, trackEvent } from '@lidofinance/analytics-matomo';
import { MATOMO_CLICK_EVENTS } from 'consts/matomo-click-events';

const MATOMO_EVENTS_MAP_CURRENCY_SELECTOR: Record<string, MatomoEventType> = {
usd: MATOMO_CLICK_EVENTS.rewardsHistoricalCurrencyUSD,
eur: MATOMO_CLICK_EVENTS.rewardsHistoricalCurrencyEUR,
gbp: MATOMO_CLICK_EVENTS.rewardsHistoricalCurrencyGBP,
};

export const RightOptions: FC = () => {
const {
Expand All @@ -15,7 +23,14 @@ export const RightOptions: FC = () => {
} = useRewardsHistory();
return (
<RightOptionsWrapper>
<CurrencySelector currency={currencyObject} onChange={setCurrency} />
<CurrencySelector
currency={currencyObject}
onChange={(value) => {
const event = MATOMO_EVENTS_MAP_CURRENCY_SELECTOR[value];
if (event) trackEvent(...event);
setCurrency(value);
}}
/>
<Export
currency={currencyObject}
address={address}
Expand Down
Loading
Loading