Skip to content

Commit

Permalink
Merge pull request #556 from lidofinance/develop
Browse files Browse the repository at this point in the history
Merge develop to main
  • Loading branch information
jake4take authored Dec 4, 2024
2 parents 5156cd6 + 6155ea4 commit f05ed6b
Show file tree
Hide file tree
Showing 43 changed files with 350 additions and 523 deletions.
4 changes: 4 additions & 0 deletions assets/icons/lido-multichain/unichain.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 consts/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export enum LIDO_MULTICHAIN_CHAINS {
'BNB Chain' = 56,
'Mode Chain' = 34443,
'Zircuit Chain' = 48900,
Unichain = 130,
}

// TODO: move to @lidofinance/lido-ethereum-sdk package
Expand Down
317 changes: 62 additions & 255 deletions consts/matomo-wallets-events.ts
Original file line number Diff line number Diff line change
@@ -1,263 +1,70 @@
import { MatomoEventType, trackEvent } from '@lidofinance/analytics-matomo';
import { MetricsProp } from '@reef-knot/types';
import { WalletIdsEthereum } from 'reef-knot/wallets';
import { trackEvent } from '@lidofinance/analytics-matomo';
import type { ReefKnotWalletsModalConfig } from '@reef-knot/types';
import type { WalletIdsEthereum } from '@reef-knot/wallets-list';
import { MATOMO_CLICK_EVENTS } from './matomo-click-events';

export const enum MATOMO_WALLETS_EVENTS_TYPES {
onClickAmbire = 'onClickAmbire',
onConnectAmbire = 'onConnectAmbire',
onClickBrave = 'onClickBrave',
onConnectBrave = 'onConnectBrave',
onClickCoin98 = 'onClickCoin98',
onConnectCoin98 = 'onConnectCoin98',
onClickCoinbase = 'onClickCoinbase',
onClickCoinbaseSmartWallet = 'onClickCoinbaseSmartWallet',
onConnectCoinbase = 'onConnectCoinbase',
onConnectCoinbaseSmartWallet = 'onConnectCoinbaseSmartWallet',
onClickExodus = 'onClickExodus',
onConnectExodus = 'onConnectExodus',
onClickImToken = 'onClickImToken',
onConnectImToken = 'onConnectImToken',
onClickLedger = 'onClickLedger',
onConnectLedger = 'onConnectLedger',
onClickMetamask = 'onClickMetamask',
onConnectMetamask = 'onConnectMetamask',
onClickTrust = 'onClickTrust',
onConnectTrust = 'onConnectTrust',
onClickWC = 'onClickWC',
onConnectWC = 'onConnectWC',
onClickXdefi = 'onClickXdefi',
onConnectXdefi = 'onConnectXdefi',
onClickOkx = 'onClickOkx',
onConnectOkx = 'onConnectOkx',
onClickBitget = 'onClickBitget',
onConnectBitget = 'onConnectBitget',
onClickBrowser = 'onClickBrowser',
onConnectBrowser = 'onConnectBrowser',
onClickBinance = 'onClickBinance',
onConnectBinance = 'onConnectBinance',
}
type MetricProps = Pick<
ReefKnotWalletsModalConfig<WalletIdsEthereum>,
| 'onClickTermsAccept'
| 'onClickWalletsMore'
| 'onClickWalletsLess'
| 'onConnectStart'
| 'onConnectSuccess'
>;

export const MATOMO_WALLETS_EVENTS: Record<
MATOMO_WALLETS_EVENTS_TYPES,
MatomoEventType
> = {
[MATOMO_WALLETS_EVENTS_TYPES.onClickAmbire]: [
'Ethereum_Staking_Widget',
'Click on Ambire wallet',
'eth_widget_click_ambire',
],
[MATOMO_WALLETS_EVENTS_TYPES.onConnectAmbire]: [
'Ethereum_Staking_Widget',
'Connect Ambire wallet',
'eth_widget_connect_ambire',
],
[MATOMO_WALLETS_EVENTS_TYPES.onClickBrave]: [
'Ethereum_Staking_Widget',
'Click Brave wallet',
'eth_widget_click_brave',
],
[MATOMO_WALLETS_EVENTS_TYPES.onConnectBrave]: [
'Ethereum_Staking_Widget',
'Connect Brave wallet',
'eth_widget_connect_brave',
],
[MATOMO_WALLETS_EVENTS_TYPES.onClickCoin98]: [
'Ethereum_Staking_Widget',
'Click Coin98 wallet',
'eth_widget_click_coin98',
],
[MATOMO_WALLETS_EVENTS_TYPES.onConnectCoin98]: [
'Ethereum_Staking_Widget',
'Connect Coin98 wallet',
'eth_widget_connect_coin98',
],
[MATOMO_WALLETS_EVENTS_TYPES.onClickCoinbase]: [
'Ethereum_Staking_Widget',
'Click Coinbase Wallet wallet',
'eth_widget_click_coinbase_wallet',
],
[MATOMO_WALLETS_EVENTS_TYPES.onConnectCoinbase]: [
'Ethereum_Staking_Widget',
'Connect Coinbase Wallet wallet',
'eth_widget_connect_coinbase_wallet',
],
[MATOMO_WALLETS_EVENTS_TYPES.onClickCoinbaseSmartWallet]: [
'Ethereum_Staking_Widget',
'Click Coinbase Smart Wallet wallet',
'eth_widget_click_coinbase_smart_wallet',
],
[MATOMO_WALLETS_EVENTS_TYPES.onConnectCoinbaseSmartWallet]: [
'Ethereum_Staking_Widget',
'Connect Coinbase Smart Wallet wallet',
'eth_widget_connect_coinbase_smart_wallet',
],
[MATOMO_WALLETS_EVENTS_TYPES.onClickExodus]: [
'Ethereum_Staking_Widget',
'Click Exodus wallet',
'eth_widget_click_exodus',
],
[MATOMO_WALLETS_EVENTS_TYPES.onConnectExodus]: [
'Ethereum_Staking_Widget',
'Connect Exodus wallet',
'eth_widget_connect_exodus',
],
[MATOMO_WALLETS_EVENTS_TYPES.onClickImToken]: [
'Ethereum_Staking_Widget',
'Click imToken wallet',
'eth_widget_click_imtoken',
],
[MATOMO_WALLETS_EVENTS_TYPES.onConnectImToken]: [
'Ethereum_Staking_Widget',
'Connect imToken wallet',
'eth_widget_connect_imtoken',
],
[MATOMO_WALLETS_EVENTS_TYPES.onClickLedger]: [
'Ethereum_Staking_Widget',
'Click Ledger wallet',
'eth_widget_click_ledger',
],
[MATOMO_WALLETS_EVENTS_TYPES.onConnectLedger]: [
'Ethereum_Staking_Widget',
'Connect Ledger wallet',
'eth_widget_connect_ledger',
],
[MATOMO_WALLETS_EVENTS_TYPES.onClickMetamask]: [
'Ethereum_Staking_Widget',
'Click Metamask wallet',
'eth_widget_click_metamask',
],
[MATOMO_WALLETS_EVENTS_TYPES.onConnectMetamask]: [
'Ethereum_Staking_Widget',
'Connect Metamask wallet',
'eth_widget_connect_metamask',
],
[MATOMO_WALLETS_EVENTS_TYPES.onClickTrust]: [
'Ethereum_Staking_Widget',
'Click Trust wallet',
'eth_widget_click_trust',
],
[MATOMO_WALLETS_EVENTS_TYPES.onConnectTrust]: [
'Ethereum_Staking_Widget',
'Connect Trust wallet',
'eth_widget_connect_trust',
],
[MATOMO_WALLETS_EVENTS_TYPES.onClickWC]: [
'Ethereum_Staking_Widget',
'Click WalletConnect wallet',
'eth_widget_click_walletconnect',
],
[MATOMO_WALLETS_EVENTS_TYPES.onConnectWC]: [
'Ethereum_Staking_Widget',
'Connect WalletConnect wallet',
'eth_widget_connect_walletconnect',
],
[MATOMO_WALLETS_EVENTS_TYPES.onClickXdefi]: [
'Ethereum_Staking_Widget',
'Click XDEFI wallet',
'eth_widget_click_xdefi',
],
[MATOMO_WALLETS_EVENTS_TYPES.onConnectXdefi]: [
'Ethereum_Staking_Widget',
'Connect XDEFI wallet',
'eth_widget_connect_xdefi',
],
[MATOMO_WALLETS_EVENTS_TYPES.onClickOkx]: [
'Ethereum_Staking_Widget',
'Click OKX wallet',
'eth_widget_click_okx',
],
[MATOMO_WALLETS_EVENTS_TYPES.onConnectOkx]: [
'Ethereum_Staking_Widget',
'Connect OKX wallet',
'eth_widget_connect_okx',
],
[MATOMO_WALLETS_EVENTS_TYPES.onClickBitget]: [
'Ethereum_Staking_Widget',
'Click BitGet wallet',
'eth_widget_click_bitget',
],
[MATOMO_WALLETS_EVENTS_TYPES.onConnectBitget]: [
'Ethereum_Staking_Widget',
'Connect BitGet wallet',
'eth_widget_connect_bitget',
],
[MATOMO_WALLETS_EVENTS_TYPES.onClickBrowser]: [
'Ethereum_Staking_Widget',
'Click Browser wallet',
'eth_widget_click_browser',
],
[MATOMO_WALLETS_EVENTS_TYPES.onConnectBrowser]: [
'Ethereum_Staking_Widget',
'Connect Browser wallet',
'eth_widget_connect_browser',
],
[MATOMO_WALLETS_EVENTS_TYPES.onClickBinance]: [
'Ethereum_Staking_Widget',
'Click Binance Web3 wallet',
'eth_widget_click_binance_web3',
],
[MATOMO_WALLETS_EVENTS_TYPES.onConnectBinance]: [
'Ethereum_Staking_Widget',
'Connect Binance Web3 wallet',
'eth_widget_connect_binance_web3_wallet',
],
type EventsData = Partial<Record<WalletIdsEthereum, [string, string]>>;

const EVENTS_DATA_CONNECT_START: EventsData = {
ambire: ['on Ambire', 'ambire'],
binanceWallet: ['Binance Web3', 'binance_web3'],
bitget: ['BitGet', 'bitget'],
brave: ['Brave', 'brave'],
browserExtension: ['Browser', 'browser'],
coin98: ['Coin98', 'coin98'],
coinbase: ['Coinbase Wallet', 'coinbase_wallet'],
coinbaseSmartWallet: ['Coinbase Smart Wallet', 'coinbase_smart_wallet'],
exodus: ['Exodus', 'exodus'],
imToken: ['imToken', 'imtoken'],
ledgerHID: ['Ledger', 'ledger'],
metaMask: ['Metamask', 'metamask'],
okx: ['OKX', 'okx'],
trust: ['Trust', 'trust'],
walletConnect: ['WalletConnect', 'walletconnect'],
xdefi: ['XDEFI', 'xdefi'],
} as const;

const EVENTS_DATA_CONNECT_SUCCESS: EventsData = {
...EVENTS_DATA_CONNECT_START,
ambire: ['Ambire', 'ambire'],
binanceWallet: ['Binance Web3', 'binance_web3_wallet'],
};

const getMetricHandler = (event: Parameters<typeof trackEvent>) => () =>
trackEvent(...event);
export const walletMetricProps: MetricProps = {
onClickWalletsLess: () =>
trackEvent(...MATOMO_CLICK_EVENTS.clickShowLessWallets),

onClickWalletsMore: () =>
trackEvent(...MATOMO_CLICK_EVENTS.clickShowMoreWallets),

onConnectStart: ({ walletId }) => {
const eventData = EVENTS_DATA_CONNECT_START[walletId];
if (eventData) {
trackEvent(
'Ethereum_Staking_Widget',
`Click ${eventData[0]} wallet`,
`eth_widget_click_${eventData[1]}`,
);
}
},

export const walletsMetrics: MetricsProp<WalletIdsEthereum> = {
events: {
click: {
handlers: {
ambire: getMetricHandler(MATOMO_WALLETS_EVENTS.onClickAmbire),
brave: getMetricHandler(MATOMO_WALLETS_EVENTS.onClickBrave),
coin98: getMetricHandler(MATOMO_WALLETS_EVENTS.onClickCoin98),
coinbase: getMetricHandler(MATOMO_WALLETS_EVENTS.onClickCoinbase),
coinbaseSmartWallet: getMetricHandler(
MATOMO_WALLETS_EVENTS.onClickCoinbaseSmartWallet,
),
exodus: getMetricHandler(MATOMO_WALLETS_EVENTS.onClickExodus),
imToken: getMetricHandler(MATOMO_WALLETS_EVENTS.onClickImToken),
ledgerHID: getMetricHandler(MATOMO_WALLETS_EVENTS.onClickLedger),
metaMask: getMetricHandler(MATOMO_WALLETS_EVENTS.onClickMetamask),
trust: getMetricHandler(MATOMO_WALLETS_EVENTS.onClickTrust),
walletConnect: getMetricHandler(MATOMO_WALLETS_EVENTS.onClickWC),
xdefi: getMetricHandler(MATOMO_WALLETS_EVENTS.onClickXdefi),
okx: getMetricHandler(MATOMO_WALLETS_EVENTS.onClickOkx),
bitget: getMetricHandler(MATOMO_WALLETS_EVENTS.onClickBitget),
browserExtension: getMetricHandler(
MATOMO_WALLETS_EVENTS.onClickBrowser,
),
binanceWallet: getMetricHandler(MATOMO_WALLETS_EVENTS.onClickBinance),
walletsLess: getMetricHandler(MATOMO_CLICK_EVENTS.clickShowLessWallets),
walletsMore: getMetricHandler(MATOMO_CLICK_EVENTS.clickShowMoreWallets),
},
},
connect: {
handlers: {
ambire: getMetricHandler(MATOMO_WALLETS_EVENTS.onConnectAmbire),
brave: getMetricHandler(MATOMO_WALLETS_EVENTS.onConnectBrave),
coin98: getMetricHandler(MATOMO_WALLETS_EVENTS.onConnectCoin98),
coinbase: getMetricHandler(MATOMO_WALLETS_EVENTS.onConnectCoinbase),
coinbaseSmartWallet: getMetricHandler(
MATOMO_WALLETS_EVENTS.onConnectCoinbaseSmartWallet,
),
exodus: getMetricHandler(MATOMO_WALLETS_EVENTS.onConnectExodus),
imToken: getMetricHandler(MATOMO_WALLETS_EVENTS.onConnectImToken),
ledgerHID: getMetricHandler(MATOMO_WALLETS_EVENTS.onConnectLedger),
metaMask: getMetricHandler(MATOMO_WALLETS_EVENTS.onConnectMetamask),
trust: getMetricHandler(MATOMO_WALLETS_EVENTS.onConnectTrust),
walletConnect: getMetricHandler(MATOMO_WALLETS_EVENTS.onConnectWC),
xdefi: getMetricHandler(MATOMO_WALLETS_EVENTS.onConnectXdefi),
okx: getMetricHandler(MATOMO_WALLETS_EVENTS.onConnectOkx),
bitget: getMetricHandler(MATOMO_WALLETS_EVENTS.onConnectBitget),
browserExtension: getMetricHandler(
MATOMO_WALLETS_EVENTS.onConnectBrowser,
),
binanceWallet: getMetricHandler(MATOMO_WALLETS_EVENTS.onConnectBinance),
},
},
onConnectSuccess: ({ walletId }) => {
const eventData = EVENTS_DATA_CONNECT_SUCCESS[walletId];
if (eventData) {
trackEvent(
'Ethereum_Staking_Widget',
`Connect ${eventData[0]}`,
`eth_widget_connect_${eventData[1]}`,
);
}
},
};
2 changes: 1 addition & 1 deletion features/rewards/components/IndexerLink.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Box, External as ExternalLinkIcon } from '@lidofinance/lido-ui';
import { getEtherscanTxLink } from 'utils/get-etherscan-tx-link';
import { getEtherscanTxLink } from 'utils/etherscan';

import { config } from 'config';

Expand Down
9 changes: 4 additions & 5 deletions features/stake/lido-stats/lido-stats.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import { FC, memo, useMemo } from 'react';

import { getEtherscanTokenLink } from '@lido-sdk/helpers';
import { useSDK } from '@lido-sdk/react';
import { getTokenAddress, TOKENS } from '@lido-sdk/constants';
import { Block, DataTable, Question, Tooltip } from '@lidofinance/lido-ui';

import { Section, MatomoLink } from 'shared/components';
import { useLidoApr, useLidoStats } from 'shared/hooks';

import { config } from 'config';

import { LIDO_APR_TOOLTIP_TEXT, DATA_UNAVAILABLE } from 'consts/text';
import { MATOMO_CLICK_EVENTS_TYPES } from 'consts/matomo-click-events';
import { getEtherscanTokenLink } from 'utils/etherscan';

import { Section, MatomoLink } from 'shared/components';
import { useLidoApr, useLidoStats } from 'shared/hooks';

import { FlexCenterVertical } from './styles';
import { LidoStatsItem } from './lido-stats-item';
Expand Down
5 changes: 1 addition & 4 deletions features/stake/stake.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { FaqPlaceholder } from 'features/ipfs';
import { useWagmiKey } from 'modules/web3';
import NoSSRWrapper from 'shared/components/no-ssr-wrapper';
import { OnlyInfraRender } from 'shared/components/only-infra-render';

Expand All @@ -8,12 +7,10 @@ import { LidoStats } from './lido-stats/lido-stats';
import { StakeForm } from './stake-form';

export const Stake = () => {
const key = useWagmiKey();

return (
<>
<NoSSRWrapper>
<StakeForm key={key} />
<StakeForm />
</NoSSRWrapper>
<LidoStats />
<OnlyInfraRender renderIPFS={<FaqPlaceholder />}>
Expand Down
Loading

0 comments on commit f05ed6b

Please sign in to comment.