From a61d0706072ce46a518b8dfcd005add88dccce04 Mon Sep 17 00:00:00 2001 From: Dmitrii Podlesnyi Date: Wed, 20 Nov 2024 22:51:58 +0900 Subject: [PATCH 01/12] feat: more token to wallet response messages --- .../token-to-wallet/token-to-wallet.tsx | 36 +++++++++++++++---- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/shared/components/token-to-wallet/token-to-wallet.tsx b/shared/components/token-to-wallet/token-to-wallet.tsx index bad2f4d24..843beaa44 100644 --- a/shared/components/token-to-wallet/token-to-wallet.tsx +++ b/shared/components/token-to-wallet/token-to-wallet.tsx @@ -1,10 +1,9 @@ -import { ToastInfo, Tooltip } from '@lidofinance/lido-ui'; +import { ToastError, ToastInfo, Tooltip } from '@lidofinance/lido-ui'; import { TokenToWalletStyle } from './styles'; import { Component } from 'types'; import { useWalletClient, useWatchAsset } from 'wagmi'; import { Address, getContract } from 'viem'; -import { useConnectorInfo } from 'reef-knot/core-react'; export type TokenToWalletComponent = Component<'button', { address?: string }>; @@ -27,10 +26,9 @@ const ERC20_METADATA_ABI = [ export const TokenToWallet: TokenToWalletComponent = ({ address, ...rest }) => { const { watchAssetAsync } = useWatchAsset(); - const { isInjected } = useConnectorInfo(); const { data: walletClient } = useWalletClient(); - if (!walletClient || !address || !isInjected) return null; + if (!walletClient || !address) return null; const onClickHandler = async () => { if (!address) return; @@ -51,10 +49,36 @@ export const TokenToWallet: TokenToWalletComponent = ({ address, ...rest }) => { type: 'ERC20', options: { address, decimals, symbol }, }); - if (!result) return; - ToastInfo('Tokens were successfully added to your wallet', {}); + if (result) { + ToastInfo('Tokens were successfully added to your wallet', {}); + } else { + ToastInfo('User rejected the request'); + } } catch (error) { + // Associating error code to UI messages + if (error && typeof error === 'object' && 'code' in error) { + if ( + error?.code === -32602 // Trust + ) { + ToastInfo('Tokens already existed'); + } else if ( + error?.code === 4001 || // Metamask, coin98, okx + error?.code === -32603 // Bitget + ) { + ToastInfo('User rejected the request'); + } else if ( + error?.code === -1 || // LL and Safe through WC + error?.code === -32601 // LL in Discover + ) { + ToastError('The wallet does not support adding a token'); + } else { + ToastError( + 'An error occurred while adding token to wallet\nThe wallet probably does not support adding a token', + ); + } + } + console.warn('[TokenToWallet] error adding token to wallet', error); } }; From d80e030458d90d62e4d3a032347403aabb06b9f3 Mon Sep 17 00:00:00 2001 From: Dmitrii Podlesnyi Date: Wed, 4 Dec 2024 16:25:06 +0700 Subject: [PATCH 02/12] chore: token to wallet toast texts updated --- shared/components/token-to-wallet/token-to-wallet.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shared/components/token-to-wallet/token-to-wallet.tsx b/shared/components/token-to-wallet/token-to-wallet.tsx index 843beaa44..6b2094ed0 100644 --- a/shared/components/token-to-wallet/token-to-wallet.tsx +++ b/shared/components/token-to-wallet/token-to-wallet.tsx @@ -61,7 +61,7 @@ export const TokenToWallet: TokenToWalletComponent = ({ address, ...rest }) => { if ( error?.code === -32602 // Trust ) { - ToastInfo('Tokens already existed'); + ToastInfo('Tokens already added'); } else if ( error?.code === 4001 || // Metamask, coin98, okx error?.code === -32603 // Bitget @@ -74,7 +74,7 @@ export const TokenToWallet: TokenToWalletComponent = ({ address, ...rest }) => { ToastError('The wallet does not support adding a token'); } else { ToastError( - 'An error occurred while adding token to wallet\nThe wallet probably does not support adding a token', + 'An error occurred while adding token to wallet\nThe wallet might not support adding a token', ); } } From c5a183133aad015dd2aa3fd1bf0cd246fc247216 Mon Sep 17 00:00:00 2001 From: Dmitrii Podlesnyi Date: Fri, 13 Dec 2024 20:30:40 +0700 Subject: [PATCH 03/12] style: transaction modal upper space improved --- shared/transaction-modal/transaction-modal-content.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/shared/transaction-modal/transaction-modal-content.tsx b/shared/transaction-modal/transaction-modal-content.tsx index 7a1d70abf..fa7b6adf2 100644 --- a/shared/transaction-modal/transaction-modal-content.tsx +++ b/shared/transaction-modal/transaction-modal-content.tsx @@ -1,9 +1,15 @@ import { memo } from 'react'; import styled from 'styled-components'; import { Text } from '@lidofinance/lido-ui'; +import { devicesHeaderMedia } from 'styles/global'; export const Wrap = styled.div` text-align: center; + margin-top: -46px; + + @media ${devicesHeaderMedia.mobile} { + margin-top: -42px; + } `; export const Title = styled(Text).attrs({ From e84195f822139348556f691f5fc5ca2fd8696b9f Mon Sep 17 00:00:00 2001 From: Evgeny Taktarov Date: Fri, 13 Dec 2024 20:46:51 +0700 Subject: [PATCH 04/12] fix: use package rpcFactory --- package.json | 20 +-- pages/api/rpc.ts | 2 +- utilsApi/rpcFactory/errors.ts | 30 ---- utilsApi/rpcFactory/index.ts | 6 - utilsApi/rpcFactory/rpc-factory.ts | 155 -------------------- utilsApi/rpcFactory/types.ts | 38 ----- utilsApi/rpcFactory/validation.ts | 223 ----------------------------- yarn.lock | 84 +++++------ 8 files changed, 54 insertions(+), 504 deletions(-) delete mode 100644 utilsApi/rpcFactory/errors.ts delete mode 100644 utilsApi/rpcFactory/index.ts delete mode 100644 utilsApi/rpcFactory/rpc-factory.ts delete mode 100644 utilsApi/rpcFactory/types.ts delete mode 100644 utilsApi/rpcFactory/validation.ts diff --git a/package.json b/package.json index 6e0976da2..9827e01c2 100644 --- a/package.json +++ b/package.json @@ -20,18 +20,18 @@ "test:e2e": "playwright test" }, "dependencies": { - "@lidofinance/analytics-matomo": "^0.45.1", - "@lidofinance/api-metrics": "^0.45.1", - "@lidofinance/api-rpc": "^0.45.1", - "@lidofinance/eth-api-providers": "^0.45.1", - "@lidofinance/eth-providers": "^0.45.1", + "@lidofinance/analytics-matomo": "^0.47.0", + "@lidofinance/api-metrics": "^0.47.0", + "@lidofinance/api-rpc": "^0.47.0", + "@lidofinance/eth-api-providers": "^0.47.0", + "@lidofinance/eth-providers": "^0.47.0", "@lidofinance/lido-ethereum-sdk": "4.1.0", "@lidofinance/lido-ui": "^3.26.0", - "@lidofinance/next-api-wrapper": "^0.45.1", - "@lidofinance/next-ip-rate-limit": "^0.45.1", - "@lidofinance/next-pages": "^0.45.1", - "@lidofinance/rpc": "^0.45.1", - "@lidofinance/satanizer": "^0.45.1", + "@lidofinance/next-api-wrapper": "^0.47.0", + "@lidofinance/next-ip-rate-limit": "^0.47.0", + "@lidofinance/next-pages": "^0.47.0", + "@lidofinance/rpc": "^0.47.0", + "@lidofinance/satanizer": "^0.47.0", "@reef-knot/types": "^4.0.0", "@tanstack/react-query": "^5.51.21", "copy-to-clipboard": "^3.3.1", diff --git a/pages/api/rpc.ts b/pages/api/rpc.ts index 57bffcd24..5aed36e27 100644 --- a/pages/api/rpc.ts +++ b/pages/api/rpc.ts @@ -1,5 +1,6 @@ import { wrapRequest as wrapNextRequest } from '@lidofinance/next-api-wrapper'; import { trackedFetchRpcFactory } from '@lidofinance/api-rpc'; +import { rpcFactory } from '@lidofinance/next-pages'; import { config, secretConfig } from 'config'; import { API_ROUTES } from 'consts/api'; @@ -14,7 +15,6 @@ import { HttpMethod, } from 'utilsApi'; import Metrics from 'utilsApi/metrics'; -import { rpcFactory } from 'utilsApi/rpcFactory'; import { METRIC_CONTRACT_ADDRESSES, METRIC_CONTRACT_EVENT_ADDRESSES, diff --git a/utilsApi/rpcFactory/errors.ts b/utilsApi/rpcFactory/errors.ts deleted file mode 100644 index 646790891..000000000 --- a/utilsApi/rpcFactory/errors.ts +++ /dev/null @@ -1,30 +0,0 @@ -export const DEFAULT_API_ERROR_MESSAGE = - 'Something went wrong. Sorry, try again later :('; - -export const HEALTHY_RPC_SERVICES_ARE_OVER = 'Healthy RPC services are over!'; - -export class ClientError extends Error {} - -export class UnsupportedChainIdError extends ClientError { - constructor(message?: string) { - super(message || 'Unsupported chainId'); - } -} - -export class UnsupportedHTTPMethodError extends ClientError { - constructor(message?: string) { - super(message || 'Unsupported HTTP method'); - } -} - -export class InvalidRequestError extends ClientError { - constructor(message?: string) { - super(message || 'Invalid Request'); - } -} - -export class SizeTooLargeError extends ClientError { - constructor(message?: string) { - super(message || 'Invalid Request'); - } -} diff --git a/utilsApi/rpcFactory/index.ts b/utilsApi/rpcFactory/index.ts deleted file mode 100644 index a15e981c7..000000000 --- a/utilsApi/rpcFactory/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export { rpcFactory } from './rpc-factory'; -export type { - RPCFactoryParams, - RPCFactoryValidationParams, - RpcProviders, -} from './types'; diff --git a/utilsApi/rpcFactory/rpc-factory.ts b/utilsApi/rpcFactory/rpc-factory.ts deleted file mode 100644 index b8e15ede1..000000000 --- a/utilsApi/rpcFactory/rpc-factory.ts +++ /dev/null @@ -1,155 +0,0 @@ -import { Readable } from 'node:stream'; -import { ReadableStream } from 'node:stream/web'; -import { pipeline } from 'node:stream/promises'; -import type { NextApiRequest, NextApiResponse } from 'next'; -import { Counter } from 'prom-client'; -import type { FetchRpcInitBody } from '@lidofinance/rpc'; -import { iterateUrls } from '@lidofinance/rpc'; - -import { - DEFAULT_API_ERROR_MESSAGE, - HEALTHY_RPC_SERVICES_ARE_OVER, - ClientError, -} from './errors'; -import { - baseRequestValidationFactory, - ethCallValidationFactory, - ethGetLogsValidationFactory, - rpcMethodsValidationFactory, - shouldValidateRpcMethod, - streamMaxSizeValidationFactory, -} from './validation'; -import { RPCFactoryParams } from './types'; - -export const rpcFactory = ({ - metrics, - providers, - fetchRPC, - defaultChain, - validation, -}: RPCFactoryParams) => { - const { - allowedRPCMethods, - allowedCallAddresses, - allowedLogsAddresses, - maxResponseSize = 1_000_000, - maxBatchCount = 20, - currentBlockTTLms = 60_000, - maxGetLogsRange = 20_000, - blockEmptyAddressGetLogs = true, - } = validation; - - // optional metrics - const { registry, prefix = '' } = metrics ?? {}; - const rpcRequestBlocked = new Counter({ - name: prefix + 'rpc_service_request_blocked', - help: 'RPC service request blocked', - labelNames: ['reason'], - registers: [], - }); - registry?.registerMetric(rpcRequestBlocked); - - const validateBaseRequest = baseRequestValidationFactory( - defaultChain, - providers, - maxBatchCount, - ); - - const validateRpcMethod = rpcMethodsValidationFactory(allowedRPCMethods); - - const validateEthCall = - allowedCallAddresses && - shouldValidateRpcMethod('eth_call', allowedRPCMethods) - ? ethCallValidationFactory(allowedCallAddresses) - : undefined; - - const validateEthGetLogs = - (allowedLogsAddresses || blockEmptyAddressGetLogs) && - shouldValidateRpcMethod('eth_getLogs', allowedRPCMethods) - ? ethGetLogsValidationFactory( - allowedLogsAddresses, - blockEmptyAddressGetLogs, - maxGetLogsRange, - currentBlockTTLms, - ) - : undefined; - - const validateMaxSteamSize = streamMaxSizeValidationFactory(maxResponseSize); - - const requestRPC = (chainId: number, body: FetchRpcInitBody) => - iterateUrls( - providers[chainId], - // TODO: consider adding verification that body is actually matches FetchRpcInitBody - (url) => fetchRPC(url, { body }, { chainId }), - // eslint-disable-next-line @typescript-eslint/unbound-method - console.error, - ); - - return async (req: NextApiRequest, res: NextApiResponse): Promise => { - const abortController = new AbortController(); - try { - const { chainId, requests } = validateBaseRequest(req); - - const validationContext = { - chainId, - rpcRequestBlocked, - requestRPC, - }; - - // We throw HTTP error for ANY invalid RPC request out of batch - // because we assume that frontend must not send invalid requests at all - for (const request of requests) { - validateRpcMethod(request, validationContext); - - const method = request.method; - - if (method === 'eth_call' && validateEthCall) { - validateEthCall(request, validationContext); - } - if (method === 'eth_getLogs' && validateEthGetLogs) { - await validateEthGetLogs(request, validationContext); - } - } - - const proxyedRPC = await requestRPC( - chainId, - req.body as FetchRpcInitBody, - ); - - res.setHeader( - 'Content-Type', - proxyedRPC.headers.get('Content-Type') ?? 'application/json', - ); - if (!proxyedRPC.body) { - throw new Error('There are a problems with RPC provider'); - } - - // auto closes both Readable.fromWeb() and underlying proxyedRPC streams on error - await pipeline( - Readable.fromWeb(proxyedRPC.body as ReadableStream), - validateMaxSteamSize(validationContext), - res, - { - signal: abortController.signal, - }, - ); - } catch (error) { - if (error instanceof ClientError) { - res.status(400).json(error.message ?? DEFAULT_API_ERROR_MESSAGE); - } else if (error instanceof Error) { - // TODO: check if there are errors duplication with iterateUrls - console.error( - '[rpcFactory]' + (error.message ?? DEFAULT_API_ERROR_MESSAGE), - ); - if (!res.headersSent) { - res.status(500).json(error.message ?? DEFAULT_API_ERROR_MESSAGE); - } - } else { - res.status(500).json(HEALTHY_RPC_SERVICES_ARE_OVER); - } - } finally { - // forces pipeline closure in case of external error/abort - abortController.abort(); - } - }; -}; diff --git a/utilsApi/rpcFactory/types.ts b/utilsApi/rpcFactory/types.ts deleted file mode 100644 index da9b34a31..000000000 --- a/utilsApi/rpcFactory/types.ts +++ /dev/null @@ -1,38 +0,0 @@ -import type { TrackedFetchRPC } from '@lidofinance/api-rpc'; -import type { FetchRpcInitBody } from '@lidofinance/rpc'; -import type { Counter, Registry } from 'prom-client'; - -export type RpcProviders = Record; - -export type RPCFactoryValidationParams = { - maxBatchCount?: number; - maxResponseSize?: number; - allowedRPCMethods?: string[]; - allowedCallAddresses?: Record; - allowedLogsAddresses?: Record; - blockEmptyAddressGetLogs?: boolean; - maxGetLogsRange?: number; - currentBlockTTLms?: number; -}; - -export type RPCFactoryParams = { - metrics?: { - prefix: string; - registry: Registry; - }; - providers: RpcProviders; - fetchRPC: TrackedFetchRPC; - defaultChain: string | number; - validation: RPCFactoryValidationParams; -}; - -export type RpcRequest = { - method: string; - params: unknown[]; -}; - -export type ValidationContext = { - chainId: number; - rpcRequestBlocked: Counter<'reason'>; - requestRPC: (chainId: number, body: FetchRpcInitBody) => Promise; -}; diff --git a/utilsApi/rpcFactory/validation.ts b/utilsApi/rpcFactory/validation.ts deleted file mode 100644 index 27f554a93..000000000 --- a/utilsApi/rpcFactory/validation.ts +++ /dev/null @@ -1,223 +0,0 @@ -import { Transform } from 'node:stream'; -import type { NextApiRequest } from 'next'; -import { Cache } from 'memory-cache'; - -import { - ClientError, - InvalidRequestError, - SizeTooLargeError, - UnsupportedChainIdError, - UnsupportedHTTPMethodError, -} from './errors'; - -import type { RpcRequest, ValidationContext } from './types'; - -// validation factories - -export const baseRequestValidationFactory = ( - defaultChain: number | string, - providers: Record, - maxBatchSize?: number, -) => { - return (req: NextApiRequest) => { - if (req.method !== 'POST') { - // We don't care about tracking blocked requests here - throw new UnsupportedHTTPMethodError(); - } - - const chainId = Number(req.query.chainId || defaultChain); - - // Allow only chainId of specified chains - if (providers[chainId] == null) { - // We don't care about tracking blocked requests here - throw new UnsupportedChainIdError(); - } - - const requests = Array.isArray(req.body) ? req.body : [req.body]; - - if (typeof maxBatchSize === 'number' && requests.length > maxBatchSize) { - throw new InvalidRequestError(`Too many batched requests`); - } - return { chainId, requests }; - }; -}; - -export const rpcMethodsValidationFactory = (allowedMethods?: string[]) => { - const methodsMap = new Set(allowedMethods ?? []); - - return (request: RpcRequest, context: ValidationContext) => { - const method = request.method; - if (typeof method !== 'string') { - throw new InvalidRequestError(`RPC method isn't string`); - } - if (allowedMethods && !methodsMap.has(request.method)) { - context.rpcRequestBlocked.inc({ reason: 'method not allowed' }); - throw new InvalidRequestError(`RPC method ${method} not allowed`); - } - }; -}; - -export const ethCallValidationFactory = ( - allowedAddress: Record, -) => { - const allowedCallAddressMap = createAllowedAddressMap(allowedAddress); - - return ( - request: RpcRequest, - { chainId, rpcRequestBlocked }: ValidationContext, - ) => { - const { params } = request; - if ( - Array.isArray(params) && - params[0] && - typeof params[0] === 'object' && - 'to' in params[0] && - typeof params[0].to === 'string' - ) { - if (!allowedCallAddressMap[chainId]?.has(params[0].to.toLowerCase())) { - rpcRequestBlocked.inc({ reason: 'address not allowed for eth_call' }); - throw new InvalidRequestError(`Address not allowed for eth_call`); - } - } else throw new InvalidRequestError(`RPC method eth_call is invalid`); - }; -}; - -export const ethGetLogsValidationFactory = ( - allowedAddress: Record | undefined, - blockEmptyAddressGetLogs: boolean | undefined, - maxBlockRange: number | undefined, - currentBlockTTL = 60_000, -) => { - const allowedAddressMap = createAllowedAddressMap(allowedAddress ?? {}); - - const maxBlockRangeBigInt = maxBlockRange ? BigInt(maxBlockRange) : 0n; - - const currentBlock = new Cache(); - - return async ( - request: RpcRequest, - { chainId, rpcRequestBlocked, requestRPC }: ValidationContext, - ) => { - try { - const params = request.params[0] as any; - const fromBlock: string = params.fromBlock; - const toBlock: string = params.toBlock ?? 'latest'; - - if (blockEmptyAddressGetLogs || allowedAddress) { - // address validation - const address: string | string[] = params.address; - - if (blockEmptyAddressGetLogs && !address) - throw new InvalidRequestError( - `RPC method eth_getLogs address is invalid`, - ); - - const addresses = Array.isArray(address) ? address : [address]; - - if (blockEmptyAddressGetLogs && addresses.length === 0) { - throw new InvalidRequestError( - `RPC method eth_getLogs address is invalid`, - ); - } - if ( - allowedAddress && - addresses.some( - (eventAddress) => - // needs this check before toLowerCase - typeof eventAddress !== 'string' || - !allowedAddressMap[chainId]?.has(eventAddress.toLowerCase()), - ) - ) { - rpcRequestBlocked.inc({ - reason: 'address not allowed for eth_getLogs', - }); - throw new InvalidRequestError(`Address not allowed for eth_getLogs`); - } - } - - // block range validation - if (maxBlockRange) { - if (fromBlock === 'earliest') - throw new InvalidRequestError( - `RPC method eth_getLogs fromBlock is invalid`, - ); - - const shouldValidateBlockDistance = fromBlock.startsWith('0x'); - - if (shouldValidateBlockDistance) { - const normalizedFromBlock = BigInt(fromBlock); - let normalizedToBlock: bigint; - if (toBlock.startsWith('0x')) normalizedToBlock = BigInt(toBlock); - else { - const cached = currentBlock.get(chainId); - if (cached) { - normalizedToBlock = cached; - } else { - normalizedToBlock = await requestRPC(chainId, { - id: 1, - jsonrpc: '2.0', - method: 'eth_blockNumber', - }) - .then((res) => res.json()) - .then((res) => BigInt(res.result)); - currentBlock.put(chainId, normalizedToBlock, currentBlockTTL); - } - } - const range = normalizedToBlock - normalizedFromBlock; - - if (range < 0n || range > maxBlockRangeBigInt) { - rpcRequestBlocked.inc({ - reason: 'eth_getLogs range is invalid', - }); - throw new InvalidRequestError( - `RPC method eth_getLogs range is invalid`, - ); - } - } - } - } catch (error) { - if (error instanceof ClientError) throw error; - throw new InvalidRequestError(`RPC method eth_getLogs is invalid`); - } - }; -}; - -export const streamMaxSizeValidationFactory = - (MAX_SIZE: number) => (context: ValidationContext) => { - let bytesWritten = 0; - return new Transform({ - transform(chunk, _encoding, callback) { - bytesWritten += chunk.length; - if (bytesWritten > MAX_SIZE) { - // Emit an error if size exceeds MAX_SIZE - context.rpcRequestBlocked.inc({ reason: 'response too large' }); - return callback( - new SizeTooLargeError( - `Stream size exceeds the maximum limit of ${MAX_SIZE} bytes`, - ), - ); - } - return callback(null, chunk); // Pass the chunk through - }, - flush(callback) { - callback(); - }, - }); - }; - -// utils - -export const shouldValidateRpcMethod = ( - method: string, - allowedRPCMethods?: string[], -) => !allowedRPCMethods || allowedRPCMethods.includes(method); - -const createAllowedAddressMap = (allowedAddress: Record) => { - return Object.entries(allowedAddress).reduce( - (acc, [chainId, addresses]) => { - acc[chainId] = new Set(addresses.map((a) => a.toLowerCase())); - return acc; - }, - {} as Record>, - ); -}; diff --git a/yarn.lock b/yarn.lock index 9d74da266..f6494ec91 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2280,20 +2280,20 @@ bignumber.js "^9.1.2" rxjs "^7.8.1" -"@lidofinance/analytics-matomo@^0.45.1": - version "0.45.1" - resolved "https://registry.yarnpkg.com/@lidofinance/analytics-matomo/-/analytics-matomo-0.45.1.tgz#f1ee0df1f6babb1f806e258831efd4ba568ad188" - integrity sha512-D35q+0XnqhWkKJidmT0iWKtLZ+KDj8z9J3t3wP+D0zi53+bP9dd7sU1ciZBUal1Sp0IjEzfiGVSiWKFQqyB8Pg== +"@lidofinance/analytics-matomo@^0.47.0": + version "0.47.0" + resolved "https://registry.yarnpkg.com/@lidofinance/analytics-matomo/-/analytics-matomo-0.47.0.tgz#3c0c608048b1b41eadfff08daac5ea454ddd3616" + integrity sha512-/cn5y0R85EzVDZI1ShUizsToWnpMXs7jMGRu8yRrX4iN3pMLgYJzqawKbZf2rwDyyNfHZpUOs4ZYyTRZUMslIg== -"@lidofinance/api-metrics@^0.45.1": - version "0.45.1" - resolved "https://registry.yarnpkg.com/@lidofinance/api-metrics/-/api-metrics-0.45.1.tgz#0c093ebeb5fa3b2b73533ec933e0bbd20bbb37dd" - integrity sha512-iPzE4RzPxeApCF7+rIQcng/zos7gHY4ibTBkTF4Vt32P9aCtt70YinQ2Sf2KY8AnBeWhGJLXjvAPWr9P3OI18A== +"@lidofinance/api-metrics@^0.47.0": + version "0.47.0" + resolved "https://registry.yarnpkg.com/@lidofinance/api-metrics/-/api-metrics-0.47.0.tgz#285b941e588ad33cc1032ed7e7080977b7444dec" + integrity sha512-lyxLAji9uCQgAa2N++y5XrC99iEf7oaBC4sHDQEoKjed1Tt30AAEjm8Wuko1MfwPscSCeeBc4u/jKAK4KuAcbA== -"@lidofinance/api-rpc@^0.45.1": - version "0.45.1" - resolved "https://registry.yarnpkg.com/@lidofinance/api-rpc/-/api-rpc-0.45.1.tgz#0a2002e233bd1233ed68d3a479a41ed93868a6d8" - integrity sha512-rTuLPs0EiOZa3tap2+zAgJ1/kpygjX+R5LgfkBw5oxZn1Dj9k+XvWuPAWBkHAsNVKonYTucD4F/NP0XhNlYuYQ== +"@lidofinance/api-rpc@^0.47.0": + version "0.47.0" + resolved "https://registry.yarnpkg.com/@lidofinance/api-rpc/-/api-rpc-0.47.0.tgz#2367eec1c8363516bde48b632a6fbe32aec33a1e" + integrity sha512-6xx2O89OhWAxaob+SqXEX2xtrumG4MCUrclooCIvAhz64Lp3Wa0Hzt2lgJyFMhJxpDPMj3LmYNbuB15lwEQKwg== "@lidofinance/eslint-config@^0.34.0": version "0.34.0" @@ -2302,15 +2302,15 @@ dependencies: typescript "^4.7" -"@lidofinance/eth-api-providers@^0.45.1": - version "0.45.1" - resolved "https://registry.yarnpkg.com/@lidofinance/eth-api-providers/-/eth-api-providers-0.45.1.tgz#090e6a3957b664ce54641453357850cac0022a97" - integrity sha512-/8BbPUmBUhB8hRHZpzFXcK/i2jk7pmzhh2NJWjya+G3nSmXaw8U6PInpArB/ZxRAErs0zufUIOm4w7Qrr9mVPw== +"@lidofinance/eth-api-providers@^0.47.0": + version "0.47.0" + resolved "https://registry.yarnpkg.com/@lidofinance/eth-api-providers/-/eth-api-providers-0.47.0.tgz#c5a5ce843de4347277db2f046a07c804b1a5f454" + integrity sha512-thuuF9CGcXQD1FAP1LY3wQHvpNElrGEvQPPmeF1kfE7KuaQKv6DpNZxdP+QnLnxxLtXRn8RD92y8wSbWAzy/EA== -"@lidofinance/eth-providers@^0.45.1": - version "0.45.1" - resolved "https://registry.yarnpkg.com/@lidofinance/eth-providers/-/eth-providers-0.45.1.tgz#54cbd893c92c06f7ad605ebe0fd8059fc326f180" - integrity sha512-ugkRCI0BPFjWY2h/cDcM8IiibQ8i/wycUgVk2C+E7gCZkjL1YPxGZdnQkfFgIHXAtPhw2YeKHP+VC6HiZpVrZw== +"@lidofinance/eth-providers@^0.47.0": + version "0.47.0" + resolved "https://registry.yarnpkg.com/@lidofinance/eth-providers/-/eth-providers-0.47.0.tgz#186d6e2695c9470cc171d111dac352da5106e681" + integrity sha512-dF8eUUnK35CNCVa3Z++INtlxlRlYKGx2//eLz7nyFkqwPoOGI0PmVW0qgGiGY9TrGAqkJuXlERszclH8eunYCw== "@lidofinance/lido-ethereum-sdk@4.1.0": version "4.1.0" @@ -2349,34 +2349,36 @@ ua-parser-js "^1.0.35" use-callback-ref "1.2.5" -"@lidofinance/next-api-wrapper@^0.45.1", "@lidofinance/next-api-wrapper@~0.45.1": - version "0.45.1" - resolved "https://registry.yarnpkg.com/@lidofinance/next-api-wrapper/-/next-api-wrapper-0.45.1.tgz#59fe3c654c9276eaef8674302470fcc7bb9d8211" - integrity sha512-SUAc520aooNwNJZ0Q1391Yz8iONPiVMQrRC0wWXWDETMFy0ZhCsQ5VCuRKf6rmZwxYjK7K600GV8ke06IIetaw== +"@lidofinance/next-api-wrapper@^0.47.0", "@lidofinance/next-api-wrapper@~0.47.0": + version "0.47.0" + resolved "https://registry.yarnpkg.com/@lidofinance/next-api-wrapper/-/next-api-wrapper-0.47.0.tgz#8452659d8f5a75fb1e6a91d814397797a2113a69" + integrity sha512-td1ckCuqguXQ4imQ6smnekh72gT1C9ku9Cl9P4Mo0Cd70NYTv0QIGoY1swARHOrAdTGhxyE0H5l7vMOdcGSgFQ== -"@lidofinance/next-ip-rate-limit@^0.45.1": - version "0.45.1" - resolved "https://registry.yarnpkg.com/@lidofinance/next-ip-rate-limit/-/next-ip-rate-limit-0.45.1.tgz#79ab181e9f125ad79c46a642dbeec5d8a194397c" - integrity sha512-8d0l6zi4IqX08Op5UCnGM5Z76tkX6GjzzfyjD6Mt7cNt/eNS8AGGKK9wbhUGmumu97l5L0hTZgEW3rNxA8+ptg== +"@lidofinance/next-ip-rate-limit@^0.47.0": + version "0.47.0" + resolved "https://registry.yarnpkg.com/@lidofinance/next-ip-rate-limit/-/next-ip-rate-limit-0.47.0.tgz#73e2eef3b91e32b2356dbc2c0b27269a55132f46" + integrity sha512-BFmz50orMcQYItPOaNBEaz/Cx8TYljvhfdIfrdShjyX8HO+ohfesMJlSdEHmHLiC/J7gEoDdiZXRl63HO5+WDg== dependencies: - "@lidofinance/next-api-wrapper" "~0.45.1" + "@lidofinance/next-api-wrapper" "~0.47.0" -"@lidofinance/next-pages@^0.45.1": - version "0.45.1" - resolved "https://registry.yarnpkg.com/@lidofinance/next-pages/-/next-pages-0.45.1.tgz#b4c8fe555ba8f04b9cb2fe88a258632fe3e8552a" - integrity sha512-eaqZ2LUWsQg+lOhdzdL+WGQ3h5p7R+HYJ78q3UhnhWMrwZkMDNgxX6dWw7TudcD1yVC9yeZeT9tpfe7Hbd/XEQ== +"@lidofinance/next-pages@^0.47.0": + version "0.47.0" + resolved "https://registry.yarnpkg.com/@lidofinance/next-pages/-/next-pages-0.47.0.tgz#3f4551209a4aec0e43dfee36ec20b18bdc473576" + integrity sha512-UewzyshAQqxHx7I/xTnZIM8Gv7zoa0VfkRmDUDLwY8Xk3A1bHqaf5uRqF+yJu3aQZVvFrNSVe7DTTsavlzINzQ== + dependencies: + memory-cache "^0.2.0" -"@lidofinance/rpc@^0.45.1": - version "0.45.1" - resolved "https://registry.yarnpkg.com/@lidofinance/rpc/-/rpc-0.45.1.tgz#53e2717ac434c4467ba0135d5144b64cb7af5548" - integrity sha512-F3ZgvBqM9sm8sQEiqGRO05fwBV/ZaexT4RmeSp3I6NcBtpaNuTf8z8IMDcslDhgk7HZZHt/VIAY+8TgVqV8jXw== +"@lidofinance/rpc@^0.47.0": + version "0.47.0" + resolved "https://registry.yarnpkg.com/@lidofinance/rpc/-/rpc-0.47.0.tgz#8721e2ac492ab8a5590d17d988546bd89bca7537" + integrity sha512-niepeZ5nTr3QQwZMW0j6c0i8z8KZSmjW1GKDIXcC0ro51rMgGu3gQ7iuXiQ2HnTYEb/fCHTH/Migz4ldPAhtjg== dependencies: isomorphic-fetch "^3.0.0" -"@lidofinance/satanizer@^0.45.1": - version "0.45.1" - resolved "https://registry.yarnpkg.com/@lidofinance/satanizer/-/satanizer-0.45.1.tgz#22fe644d7657b333074e9806e2b4229d210ba3a7" - integrity sha512-RC9jKEKykFhHFHUJNziFzvTP4LEIr1idRHgK96myKOn2w5GsiZkTd6SiaI7H9/X+Rg9ZbnTb0zcLZdYQPG946A== +"@lidofinance/satanizer@^0.47.0": + version "0.47.0" + resolved "https://registry.yarnpkg.com/@lidofinance/satanizer/-/satanizer-0.47.0.tgz#e6d6af704a7a111bca1bdea70e89f1089b646bff" + integrity sha512-oB62ld2W0XKxC3YFvRd2ZzAh5MY28ZLs01Jo9Cp8HOFvWvxnF5GrThm8Op3D/urq+cCmZODiUiMI9BMZuymDog== "@lit-labs/ssr-dom-shim@^1.0.0", "@lit-labs/ssr-dom-shim@^1.1.0": version "1.1.2" From 85fa8235c56eaa965f548e590cd8a36a19705903 Mon Sep 17 00:00:00 2001 From: Andrew Ilin Date: Wed, 18 Dec 2024 21:06:31 +0800 Subject: [PATCH 05/12] feat: updated matomo script to 5.2.0 --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 6e0976da2..bdfb723a6 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "test:e2e": "playwright test" }, "dependencies": { - "@lidofinance/analytics-matomo": "^0.45.1", + "@lidofinance/analytics-matomo": "^0.48.0", "@lidofinance/api-metrics": "^0.45.1", "@lidofinance/api-rpc": "^0.45.1", "@lidofinance/eth-api-providers": "^0.45.1", diff --git a/yarn.lock b/yarn.lock index 9d74da266..b9b979a6f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2280,10 +2280,10 @@ bignumber.js "^9.1.2" rxjs "^7.8.1" -"@lidofinance/analytics-matomo@^0.45.1": - version "0.45.1" - resolved "https://registry.yarnpkg.com/@lidofinance/analytics-matomo/-/analytics-matomo-0.45.1.tgz#f1ee0df1f6babb1f806e258831efd4ba568ad188" - integrity sha512-D35q+0XnqhWkKJidmT0iWKtLZ+KDj8z9J3t3wP+D0zi53+bP9dd7sU1ciZBUal1Sp0IjEzfiGVSiWKFQqyB8Pg== +"@lidofinance/analytics-matomo@^0.48.0": + version "0.48.0" + resolved "https://registry.yarnpkg.com/@lidofinance/analytics-matomo/-/analytics-matomo-0.48.0.tgz#0a4ad9dd4af1d49cdf5f9206b1dde9c08216fff0" + integrity sha512-HJBmnXFeQp2PuE8/rghhXy6PbykdSd7g5qqDKuPg5l97rbqbtdFJU2lZuwmPs+PMNquhcdn+yUyEXC4gRSC2Hw== "@lidofinance/api-metrics@^0.45.1": version "0.45.1" From 42608fc0ec2604d09c003ed79c3edc21840b642b Mon Sep 17 00:00:00 2001 From: Evgeny Taktarov Date: Tue, 24 Dec 2024 15:26:27 +0700 Subject: [PATCH 06/12] fix: match with ui system --- shared/transaction-modal/transaction-modal-content.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/shared/transaction-modal/transaction-modal-content.tsx b/shared/transaction-modal/transaction-modal-content.tsx index fa7b6adf2..94e797d42 100644 --- a/shared/transaction-modal/transaction-modal-content.tsx +++ b/shared/transaction-modal/transaction-modal-content.tsx @@ -1,14 +1,14 @@ import { memo } from 'react'; import styled from 'styled-components'; import { Text } from '@lidofinance/lido-ui'; -import { devicesHeaderMedia } from 'styles/global'; export const Wrap = styled.div` text-align: center; - margin-top: -46px; + margin-top: -34px; - @media ${devicesHeaderMedia.mobile} { - margin-top: -42px; + ${({ theme }) => theme.mediaQueries.md} { + margin-top: -26px; + padding-bottom: 12px; } `; From ff368acac084e575686f02266fe81453838a2db9 Mon Sep 17 00:00:00 2001 From: alx-khramov Date: Fri, 17 Jan 2025 14:08:54 +0300 Subject: [PATCH 07/12] feat: update playwright to 1.49.1 --- package.json | 4 ++-- yarn.lock | 28 ++++++++++++++-------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index 6e0976da2..dead051de 100644 --- a/package.json +++ b/package.json @@ -70,7 +70,7 @@ "@lidofinance/eslint-config": "^0.34.0", "@next/bundle-analyzer": "^13.2.4", "@next/eslint-plugin-next": "^13.4.13", - "@playwright/test": "^1.29.2", + "@playwright/test": "^1.49.1", "@svgr/webpack": "^8.0.1", "@types/jest": "28.1.6", "@types/js-cookie": "^3.0.0", @@ -103,7 +103,7 @@ "jest": "^29.5.0", "jsonschema": "^1.4.1", "lint-staged": "^13.2.3", - "playwright": "^1.29.2", + "playwright": "^1.49.1", "prettier": "^3.0.1", "ts-jest": "^29.1.0", "typescript": "5.4.5", diff --git a/yarn.lock b/yarn.lock index 9d74da266..d79d1a99d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2886,12 +2886,12 @@ resolved "https://registry.yarnpkg.com/@pkgjs/parseargs/-/parseargs-0.11.0.tgz#a77ea742fab25775145434eb1d2328cf5013ac33" integrity sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg== -"@playwright/test@^1.29.2": - version "1.41.1" - resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.41.1.tgz#6954139ed4a67999f1b17460aa3d184f4b334f18" - integrity sha512-9g8EWTjiQ9yFBXc6HjCWe41msLpxEX0KhmfmPl9RPLJdfzL4F0lg2BdJ91O9azFdl11y1pmpwdjBiSxvqc+btw== +"@playwright/test@^1.49.1": + version "1.49.1" + resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.49.1.tgz#55fa360658b3187bfb6371e2f8a64f50ef80c827" + integrity sha512-Ky+BVzPz8pL6PQxHqNRW1k3mIyv933LML7HktS8uik0bUXNCdPhoS/kLihiO1tMf/egaJb4IutXd7UywvXEW+g== dependencies: - playwright "1.41.1" + playwright "1.49.1" "@polka/url@^1.0.0-next.20": version "1.0.0-next.24" @@ -9019,17 +9019,17 @@ pkg-types@^1.0.3: mlly "^1.2.0" pathe "^1.1.0" -playwright-core@1.41.1: - version "1.41.1" - resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.41.1.tgz#9c152670010d9d6f970f34b68e3e935d3c487431" - integrity sha512-/KPO5DzXSMlxSX77wy+HihKGOunh3hqndhqeo/nMxfigiKzogn8kfL0ZBDu0L1RKgan5XHCPmn6zXd2NUJgjhg== +playwright-core@1.49.1: + version "1.49.1" + resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.49.1.tgz#32c62f046e950f586ff9e35ed490a424f2248015" + integrity sha512-BzmpVcs4kE2CH15rWfzpjzVGhWERJfmnXmniSyKeRZUs9Ws65m+RGIi7mjJK/euCegfn3i7jvqWeWyHe9y3Vgg== -playwright@1.41.1, playwright@^1.29.2: - version "1.41.1" - resolved "https://registry.yarnpkg.com/playwright/-/playwright-1.41.1.tgz#83325f34165840d019355c2a78a50f21ed9b9c85" - integrity sha512-gdZAWG97oUnbBdRL3GuBvX3nDDmUOuqzV/D24dytqlKt+eI5KbwusluZRGljx1YoJKZ2NRPaeWiFTeGZO7SosQ== +playwright@1.49.1, playwright@^1.49.1: + version "1.49.1" + resolved "https://registry.yarnpkg.com/playwright/-/playwright-1.49.1.tgz#830266dbca3008022afa7b4783565db9944ded7c" + integrity sha512-VYL8zLoNTBxVOrJBbDuRgDWa3i+mfQgDTrL8Ah9QXZ7ax4Dsj0MSq5bYgytRnDVVe+njoKnfsYkH3HzqVj5UZA== dependencies: - playwright-core "1.41.1" + playwright-core "1.49.1" optionalDependencies: fsevents "2.3.2" From 8abde7c669376a19cb6896a5c6997dd24fdccdd7 Mon Sep 17 00:00:00 2001 From: Evgeny Taktarov Date: Tue, 21 Jan 2025 13:40:58 +0700 Subject: [PATCH 08/12] fix: update message wording --- shared/components/token-to-wallet/token-to-wallet.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/shared/components/token-to-wallet/token-to-wallet.tsx b/shared/components/token-to-wallet/token-to-wallet.tsx index 6b2094ed0..33cd0edee 100644 --- a/shared/components/token-to-wallet/token-to-wallet.tsx +++ b/shared/components/token-to-wallet/token-to-wallet.tsx @@ -31,8 +31,6 @@ export const TokenToWallet: TokenToWalletComponent = ({ address, ...rest }) => { if (!walletClient || !address) return null; const onClickHandler = async () => { - if (!address) return; - try { const tokenContract = getContract({ abi: ERC20_METADATA_ABI, @@ -51,9 +49,11 @@ export const TokenToWallet: TokenToWalletComponent = ({ address, ...rest }) => { }); if (result) { - ToastInfo('Tokens were successfully added to your wallet', {}); + ToastInfo(`${symbol} token was successfully added to your wallet`); } else { - ToastInfo('User rejected the request'); + ToastInfo( + `Request to watch ${symbol} token was rejected by your wallet`, + ); } } catch (error) { // Associating error code to UI messages From a75c1bd98b4ae71d80b28c50e1c6ee993786a9da Mon Sep 17 00:00:00 2001 From: Evgeny Taktarov Date: Tue, 21 Jan 2025 14:05:23 +0700 Subject: [PATCH 09/12] fix: package versions --- package.json | 20 ++++++------- yarn.lock | 82 ++++++++++++++++++++++++++-------------------------- 2 files changed, 51 insertions(+), 51 deletions(-) diff --git a/package.json b/package.json index c8342d31f..1e61c1220 100644 --- a/package.json +++ b/package.json @@ -20,18 +20,18 @@ "test:e2e": "playwright test" }, "dependencies": { - "@lidofinance/analytics-matomo": "^0.47.0", - "@lidofinance/api-metrics": "^0.47.0", - "@lidofinance/api-rpc": "^0.47.0", - "@lidofinance/eth-api-providers": "^0.47.0", - "@lidofinance/eth-providers": "^0.47.0", + "@lidofinance/analytics-matomo": "^0.48.0", + "@lidofinance/api-metrics": "^0.48.0", + "@lidofinance/api-rpc": "^0.48.0", + "@lidofinance/eth-api-providers": "^0.48.0", + "@lidofinance/eth-providers": "^0.48.0", "@lidofinance/lido-ethereum-sdk": "4.1.0", "@lidofinance/lido-ui": "^3.26.0", - "@lidofinance/next-api-wrapper": "^0.47.0", - "@lidofinance/next-ip-rate-limit": "^0.47.0", - "@lidofinance/next-pages": "^0.47.0", - "@lidofinance/rpc": "^0.47.0", - "@lidofinance/satanizer": "^0.47.0", + "@lidofinance/next-api-wrapper": "^0.48.0", + "@lidofinance/next-ip-rate-limit": "^0.48.0", + "@lidofinance/next-pages": "^0.48.0", + "@lidofinance/rpc": "^0.48.0", + "@lidofinance/satanizer": "^0.48.0", "@reef-knot/types": "^4.0.0", "@tanstack/react-query": "^5.51.21", "copy-to-clipboard": "^3.3.1", diff --git a/yarn.lock b/yarn.lock index b1b868da8..19fcc1225 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2280,20 +2280,20 @@ bignumber.js "^9.1.2" rxjs "^7.8.1" -"@lidofinance/analytics-matomo@^0.47.0": - version "0.47.0" - resolved "https://registry.yarnpkg.com/@lidofinance/analytics-matomo/-/analytics-matomo-0.47.0.tgz#3c0c608048b1b41eadfff08daac5ea454ddd3616" - integrity sha512-/cn5y0R85EzVDZI1ShUizsToWnpMXs7jMGRu8yRrX4iN3pMLgYJzqawKbZf2rwDyyNfHZpUOs4ZYyTRZUMslIg== +"@lidofinance/analytics-matomo@^0.48.0": + version "0.48.0" + resolved "https://registry.yarnpkg.com/@lidofinance/analytics-matomo/-/analytics-matomo-0.48.0.tgz#0a4ad9dd4af1d49cdf5f9206b1dde9c08216fff0" + integrity sha512-HJBmnXFeQp2PuE8/rghhXy6PbykdSd7g5qqDKuPg5l97rbqbtdFJU2lZuwmPs+PMNquhcdn+yUyEXC4gRSC2Hw== -"@lidofinance/api-metrics@^0.47.0": - version "0.47.0" - resolved "https://registry.yarnpkg.com/@lidofinance/api-metrics/-/api-metrics-0.47.0.tgz#285b941e588ad33cc1032ed7e7080977b7444dec" - integrity sha512-lyxLAji9uCQgAa2N++y5XrC99iEf7oaBC4sHDQEoKjed1Tt30AAEjm8Wuko1MfwPscSCeeBc4u/jKAK4KuAcbA== +"@lidofinance/api-metrics@^0.48.0": + version "0.48.0" + resolved "https://registry.yarnpkg.com/@lidofinance/api-metrics/-/api-metrics-0.48.0.tgz#48ee6bfaafa4ba0ec4da2daa460bc3b7b5e76419" + integrity sha512-iHOh+BuvKO7f+L8bpPg+R3bXRcHGeKMPZpSp6WitQ8/1QZ19adAeWQryJaM+h1faoIYVUONs6IMxUoquM3OoRg== -"@lidofinance/api-rpc@^0.47.0": - version "0.47.0" - resolved "https://registry.yarnpkg.com/@lidofinance/api-rpc/-/api-rpc-0.47.0.tgz#2367eec1c8363516bde48b632a6fbe32aec33a1e" - integrity sha512-6xx2O89OhWAxaob+SqXEX2xtrumG4MCUrclooCIvAhz64Lp3Wa0Hzt2lgJyFMhJxpDPMj3LmYNbuB15lwEQKwg== +"@lidofinance/api-rpc@^0.48.0": + version "0.48.0" + resolved "https://registry.yarnpkg.com/@lidofinance/api-rpc/-/api-rpc-0.48.0.tgz#f97e99cdffaacae64f994b928d568e14f7b6e2d6" + integrity sha512-+DVlDKNAKLkYdwn3KHb8TCeM2jRyhy2RIEn9AvTMWfS6csicSfi8dTn4J1F8FHlz6LXoiE1eJ7l3nb29NtbGgg== "@lidofinance/eslint-config@^0.34.0": version "0.34.0" @@ -2302,15 +2302,15 @@ dependencies: typescript "^4.7" -"@lidofinance/eth-api-providers@^0.47.0": - version "0.47.0" - resolved "https://registry.yarnpkg.com/@lidofinance/eth-api-providers/-/eth-api-providers-0.47.0.tgz#c5a5ce843de4347277db2f046a07c804b1a5f454" - integrity sha512-thuuF9CGcXQD1FAP1LY3wQHvpNElrGEvQPPmeF1kfE7KuaQKv6DpNZxdP+QnLnxxLtXRn8RD92y8wSbWAzy/EA== +"@lidofinance/eth-api-providers@^0.48.0": + version "0.48.0" + resolved "https://registry.yarnpkg.com/@lidofinance/eth-api-providers/-/eth-api-providers-0.48.0.tgz#e60e1c8cf17ad7d1f18a1a32627d4d555d357c7c" + integrity sha512-PfJFVCXumdBvwXR8fDCsb361+ILw7MP0T2Pk7epMVEP9Xr7Q4rl208Sr3l1H5hFX+aKrofZwJO5I7/MycxCz1g== -"@lidofinance/eth-providers@^0.47.0": - version "0.47.0" - resolved "https://registry.yarnpkg.com/@lidofinance/eth-providers/-/eth-providers-0.47.0.tgz#186d6e2695c9470cc171d111dac352da5106e681" - integrity sha512-dF8eUUnK35CNCVa3Z++INtlxlRlYKGx2//eLz7nyFkqwPoOGI0PmVW0qgGiGY9TrGAqkJuXlERszclH8eunYCw== +"@lidofinance/eth-providers@^0.48.0": + version "0.48.0" + resolved "https://registry.yarnpkg.com/@lidofinance/eth-providers/-/eth-providers-0.48.0.tgz#217279cc8433968531283b985617b981d59a8393" + integrity sha512-ItzIN9psHu8stf8MTAmNaXmKyaVnsYzQ10zdvdX6TM56TcFRlxidTnR5UVeOObtr1Bm/pz61GYCOZkUI6q3aAw== "@lidofinance/lido-ethereum-sdk@4.1.0": version "4.1.0" @@ -2349,36 +2349,36 @@ ua-parser-js "^1.0.35" use-callback-ref "1.2.5" -"@lidofinance/next-api-wrapper@^0.47.0", "@lidofinance/next-api-wrapper@~0.47.0": - version "0.47.0" - resolved "https://registry.yarnpkg.com/@lidofinance/next-api-wrapper/-/next-api-wrapper-0.47.0.tgz#8452659d8f5a75fb1e6a91d814397797a2113a69" - integrity sha512-td1ckCuqguXQ4imQ6smnekh72gT1C9ku9Cl9P4Mo0Cd70NYTv0QIGoY1swARHOrAdTGhxyE0H5l7vMOdcGSgFQ== +"@lidofinance/next-api-wrapper@^0.48.0", "@lidofinance/next-api-wrapper@~0.48.0": + version "0.48.0" + resolved "https://registry.yarnpkg.com/@lidofinance/next-api-wrapper/-/next-api-wrapper-0.48.0.tgz#0da8d18e05110d241303b06055239c6f2f874a93" + integrity sha512-zj1goZYUi58DiCTmvjhnc42SmPjOkaHeGdCXQXYExAyM7HstIDrz/Eh2KODowXI2w0vRZiBFEHWSa8ahDDmHGw== -"@lidofinance/next-ip-rate-limit@^0.47.0": - version "0.47.0" - resolved "https://registry.yarnpkg.com/@lidofinance/next-ip-rate-limit/-/next-ip-rate-limit-0.47.0.tgz#73e2eef3b91e32b2356dbc2c0b27269a55132f46" - integrity sha512-BFmz50orMcQYItPOaNBEaz/Cx8TYljvhfdIfrdShjyX8HO+ohfesMJlSdEHmHLiC/J7gEoDdiZXRl63HO5+WDg== +"@lidofinance/next-ip-rate-limit@^0.48.0": + version "0.48.0" + resolved "https://registry.yarnpkg.com/@lidofinance/next-ip-rate-limit/-/next-ip-rate-limit-0.48.0.tgz#c94a0bfe8b7976d899bac8461faeb6bf40617bda" + integrity sha512-JIEJY7TL5swzwL9LOhtM9Sk1WjiLCgx9y0EtItcphiR2AQF7MCaf9XMQujgX2sQVOy747VrfFZY6AA7ZMKLdUg== dependencies: - "@lidofinance/next-api-wrapper" "~0.47.0" + "@lidofinance/next-api-wrapper" "~0.48.0" -"@lidofinance/next-pages@^0.47.0": - version "0.47.0" - resolved "https://registry.yarnpkg.com/@lidofinance/next-pages/-/next-pages-0.47.0.tgz#3f4551209a4aec0e43dfee36ec20b18bdc473576" - integrity sha512-UewzyshAQqxHx7I/xTnZIM8Gv7zoa0VfkRmDUDLwY8Xk3A1bHqaf5uRqF+yJu3aQZVvFrNSVe7DTTsavlzINzQ== +"@lidofinance/next-pages@^0.48.0": + version "0.48.0" + resolved "https://registry.yarnpkg.com/@lidofinance/next-pages/-/next-pages-0.48.0.tgz#94f6da226e28dff2595b916a4ed1e93ee72be316" + integrity sha512-JbTB4m6O5MdLvCOC/MW9ttGngQ9A1FKyIY7mMiPHUeBhhZB8A1dCGX8qrcjPrCB8qqsmSphjniX5fFWk1AR5Kg== dependencies: memory-cache "^0.2.0" -"@lidofinance/rpc@^0.47.0": - version "0.47.0" - resolved "https://registry.yarnpkg.com/@lidofinance/rpc/-/rpc-0.47.0.tgz#8721e2ac492ab8a5590d17d988546bd89bca7537" - integrity sha512-niepeZ5nTr3QQwZMW0j6c0i8z8KZSmjW1GKDIXcC0ro51rMgGu3gQ7iuXiQ2HnTYEb/fCHTH/Migz4ldPAhtjg== +"@lidofinance/rpc@^0.48.0": + version "0.48.0" + resolved "https://registry.yarnpkg.com/@lidofinance/rpc/-/rpc-0.48.0.tgz#436615fc88ff545f8ed4254a11a56313780dfc4f" + integrity sha512-wv+KRYYIUbLx3kh8t1/W5D5c2mVn5uabB9cZ1s5V0BiWrofjdXddcZd+dw5WzHZAQSe72zx8iChv1zieiVJKWQ== dependencies: isomorphic-fetch "^3.0.0" -"@lidofinance/satanizer@^0.47.0": - version "0.47.0" - resolved "https://registry.yarnpkg.com/@lidofinance/satanizer/-/satanizer-0.47.0.tgz#e6d6af704a7a111bca1bdea70e89f1089b646bff" - integrity sha512-oB62ld2W0XKxC3YFvRd2ZzAh5MY28ZLs01Jo9Cp8HOFvWvxnF5GrThm8Op3D/urq+cCmZODiUiMI9BMZuymDog== +"@lidofinance/satanizer@^0.48.0": + version "0.48.0" + resolved "https://registry.yarnpkg.com/@lidofinance/satanizer/-/satanizer-0.48.0.tgz#518d1f6574a6a2f38dc80b6dbc3636829eaa95aa" + integrity sha512-wQ36dV9/C/aliykg1cOeJoCl7yc72bJ8+zekzsIrIu3VExI2eV8rk79HWYNHoGcnhJPPRCGonnJh+0Zx3OF5Gw== "@lit-labs/ssr-dom-shim@^1.0.0", "@lit-labs/ssr-dom-shim@^1.1.0": version "1.1.2" From 8e9c8b3d08e13fa5dd0ca24df557d774167c5092 Mon Sep 17 00:00:00 2001 From: Evgeny Taktarov Date: Tue, 21 Jan 2025 15:15:08 +0700 Subject: [PATCH 10/12] fix: use public client --- .../token-to-wallet/token-to-wallet.tsx | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/shared/components/token-to-wallet/token-to-wallet.tsx b/shared/components/token-to-wallet/token-to-wallet.tsx index 33cd0edee..a7cb21982 100644 --- a/shared/components/token-to-wallet/token-to-wallet.tsx +++ b/shared/components/token-to-wallet/token-to-wallet.tsx @@ -1,9 +1,10 @@ +import { usePublicClient, useWalletClient, useWatchAsset } from 'wagmi'; +import { type Address, type PublicClient, getContract } from 'viem'; + import { ToastError, ToastInfo, Tooltip } from '@lidofinance/lido-ui'; import { TokenToWalletStyle } from './styles'; -import { Component } from 'types'; -import { useWalletClient, useWatchAsset } from 'wagmi'; -import { Address, getContract } from 'viem'; +import type { Component } from 'types'; export type TokenToWalletComponent = Component<'button', { address?: string }>; @@ -25,7 +26,8 @@ const ERC20_METADATA_ABI = [ ] as const; export const TokenToWallet: TokenToWalletComponent = ({ address, ...rest }) => { - const { watchAssetAsync } = useWatchAsset(); + const { watchAssetAsync } = useWatchAsset({ mutation: { retry: false } }); + const client = usePublicClient(); const { data: walletClient } = useWalletClient(); if (!walletClient || !address) return null; @@ -35,7 +37,7 @@ export const TokenToWallet: TokenToWalletComponent = ({ address, ...rest }) => { const tokenContract = getContract({ abi: ERC20_METADATA_ABI, address: address as Address, - client: walletClient, + client: client as PublicClient, }); const [decimals, symbol] = await Promise.all([ @@ -61,12 +63,12 @@ export const TokenToWallet: TokenToWalletComponent = ({ address, ...rest }) => { if ( error?.code === -32602 // Trust ) { - ToastInfo('Tokens already added'); + ToastInfo('Token is already added'); } else if ( error?.code === 4001 || // Metamask, coin98, okx error?.code === -32603 // Bitget ) { - ToastInfo('User rejected the request'); + ToastInfo(`Request to watch token was rejected by your wallet`); } else if ( error?.code === -1 || // LL and Safe through WC error?.code === -32601 // LL in Discover From 55e8277446fd4e29c1a19ba899155bdc5933c9b2 Mon Sep 17 00:00:00 2001 From: Evgeny Taktarov Date: Thu, 23 Jan 2025 14:13:16 +0700 Subject: [PATCH 11/12] fix: disable for ledger live --- shared/components/token-to-wallet/token-to-wallet.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/shared/components/token-to-wallet/token-to-wallet.tsx b/shared/components/token-to-wallet/token-to-wallet.tsx index a7cb21982..429e402fb 100644 --- a/shared/components/token-to-wallet/token-to-wallet.tsx +++ b/shared/components/token-to-wallet/token-to-wallet.tsx @@ -5,6 +5,7 @@ import { ToastError, ToastInfo, Tooltip } from '@lidofinance/lido-ui'; import { TokenToWalletStyle } from './styles'; import type { Component } from 'types'; +import { useIsLedgerLive } from 'shared/hooks/useIsLedgerLive'; export type TokenToWalletComponent = Component<'button', { address?: string }>; @@ -27,10 +28,11 @@ const ERC20_METADATA_ABI = [ export const TokenToWallet: TokenToWalletComponent = ({ address, ...rest }) => { const { watchAssetAsync } = useWatchAsset({ mutation: { retry: false } }); + const isLegerLive = useIsLedgerLive(); const client = usePublicClient(); const { data: walletClient } = useWalletClient(); - if (!walletClient || !address) return null; + if (isLegerLive || !walletClient || !address) return null; const onClickHandler = async () => { try { From 3d8fbbabd86aa400c89c57742cbddccb09dd2244 Mon Sep 17 00:00:00 2001 From: Evgeny Taktarov Date: Thu, 23 Jan 2025 14:14:46 +0700 Subject: [PATCH 12/12] fix: import order --- shared/components/token-to-wallet/token-to-wallet.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/components/token-to-wallet/token-to-wallet.tsx b/shared/components/token-to-wallet/token-to-wallet.tsx index 429e402fb..12d1bf4b0 100644 --- a/shared/components/token-to-wallet/token-to-wallet.tsx +++ b/shared/components/token-to-wallet/token-to-wallet.tsx @@ -2,10 +2,10 @@ import { usePublicClient, useWalletClient, useWatchAsset } from 'wagmi'; import { type Address, type PublicClient, getContract } from 'viem'; import { ToastError, ToastInfo, Tooltip } from '@lidofinance/lido-ui'; +import { useIsLedgerLive } from 'shared/hooks/useIsLedgerLive'; import { TokenToWalletStyle } from './styles'; import type { Component } from 'types'; -import { useIsLedgerLive } from 'shared/hooks/useIsLedgerLive'; export type TokenToWalletComponent = Component<'button', { address?: string }>;