From 97ba72b68c160cbe39d784ec01b7d805f5738b25 Mon Sep 17 00:00:00 2001 From: gomes <17035424+gomesalexandre@users.noreply.github.com> Date: Mon, 6 May 2024 20:19:01 +0300 Subject: [PATCH 1/4] feat: sentry environments (#6820) --- src/index.tsx | 81 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 51 insertions(+), 30 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index c9b1ef0c1ea..1a3d865b816 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -12,36 +12,57 @@ import { reportWebVitals } from 'lib/reportWebVitals' import * as serviceWorkerRegistration from './serviceWorkerRegistration' -Sentry.init({ - ...(window.location.hostname === 'localhost' - ? {} - : { dsn: getConfig().REACT_APP_SENTRY_DSN_URL }), - attachStacktrace: true, - denyUrls: ['alchemy.com'], - integrations: [ - // Sentry.browserTracingIntegration(), - // Sentry.replayIntegration(), - Sentry.httpClientIntegration({ - failedRequestStatusCodes: [ - [400, 428], - // i.e no 429s - [430, 599], - ], - }), - Sentry.browserApiErrorsIntegration(), - Sentry.breadcrumbsIntegration(), - Sentry.globalHandlersIntegration(), - Sentry.httpContextIntegration(), - ], - beforeSend(event) { - // https://github.com/getsentry/sentry-javascript/issues/8353 / https://forum.sentry.io/t/turn-off-event-grouping/10916/3 - event.fingerprint = [(Math.random() * 1000000).toString()] - return event - }, - enableTracing: true, - // Set 'tracePropagationTargets' to control for which URLs distributed tracing should be enabled - tracePropagationTargets: ['localhost'], -}) +// Remove this condition to test sentry locally +if (window.location.hostname !== 'localhost') { + const VALID_ENVS = [ + 'localhost', + 'develop', + 'release', + 'app', + 'private', + 'yeet', + 'beard', + 'juice', + 'wood', + 'gome', + ] as const + + const environment = (() => { + if (window.location.hostname.includes('app')) return 'production' + + if (VALID_ENVS.some(env => window.location.hostname.includes(env))) + return window.location.hostname.split('.')[0] + })() + Sentry.init({ + environment, + dsn: getConfig().REACT_APP_SENTRY_DSN_URL, + attachStacktrace: true, + denyUrls: ['alchemy.com'], + integrations: [ + // Sentry.browserTracingIntegration(), + // Sentry.replayIntegration(), + Sentry.httpClientIntegration({ + failedRequestStatusCodes: [ + [400, 428], + // i.e no 429s + [430, 599], + ], + }), + Sentry.browserApiErrorsIntegration(), + Sentry.breadcrumbsIntegration(), + Sentry.globalHandlersIntegration(), + Sentry.httpContextIntegration(), + ], + beforeSend(event) { + // https://github.com/getsentry/sentry-javascript/issues/8353 / https://forum.sentry.io/t/turn-off-event-grouping/10916/3 + event.fingerprint = [(Math.random() * 1000000).toString()] + return event + }, + enableTracing: true, + // Set 'tracePropagationTargets' to control for which URLs distributed tracing should be enabled + tracePropagationTargets: ['localhost'], + }) +} const rootElement = document.getElementById('root')! const root = createRoot(rootElement) From 618b86ed18edcd547ec9d1df4d4bfb56bbd1e2d8 Mon Sep 17 00:00:00 2001 From: gomes <17035424+gomesalexandre@users.noreply.github.com> Date: Mon, 6 May 2024 20:32:50 +0300 Subject: [PATCH 2/4] fix: sentry actually deny URLs (#6821) --- src/index.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index 1a3d865b816..8ac0ed30299 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -37,7 +37,6 @@ if (window.location.hostname !== 'localhost') { environment, dsn: getConfig().REACT_APP_SENTRY_DSN_URL, attachStacktrace: true, - denyUrls: ['alchemy.com'], integrations: [ // Sentry.browserTracingIntegration(), // Sentry.replayIntegration(), @@ -47,13 +46,21 @@ if (window.location.hostname !== 'localhost') { // i.e no 429s [430, 599], ], + + failedRequestTargets: [/^(?!.*\.?(alchemy|snapshot)\.(com|org)).*$/], }), Sentry.browserApiErrorsIntegration(), Sentry.breadcrumbsIntegration(), Sentry.globalHandlersIntegration(), Sentry.httpContextIntegration(), ], - beforeSend(event) { + beforeSend(event, hint) { + // Drop closed ws errors to avoid spew + if ( + (hint.originalException as Error | undefined)?.message === + 'failed to reconnect, connection closed' + ) + return null // https://github.com/getsentry/sentry-javascript/issues/8353 / https://forum.sentry.io/t/turn-off-event-grouping/10916/3 event.fingerprint = [(Math.random() * 1000000).toString()] return event From a404f13b373e14501a7baec18d731732cd50e6f1 Mon Sep 17 00:00:00 2001 From: gomes <17035424+gomesalexandre@users.noreply.github.com> Date: Mon, 6 May 2024 20:40:06 +0300 Subject: [PATCH 3/4] fix: remove useless allowance checks for savers non-token deposits (#6822) --- .../Deposit/components/Deposit.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/features/defi/providers/thorchain-savers/components/ThorchainSaversManager/Deposit/components/Deposit.tsx b/src/features/defi/providers/thorchain-savers/components/ThorchainSaversManager/Deposit/components/Deposit.tsx index 73fa9674c1b..337eda2f6ac 100644 --- a/src/features/defi/providers/thorchain-savers/components/ThorchainSaversManager/Deposit/components/Deposit.tsx +++ b/src/features/defi/providers/thorchain-savers/components/ThorchainSaversManager/Deposit/components/Deposit.tsx @@ -194,6 +194,8 @@ export const Deposit: React.FC = ({ const isApprovalRequired = await (async () => { // Router contract address is only set in case we're depositting a token, not a native asset if (!inboundAddress) return false + // Do not try to get allowance for native assets, including non-EVM ones. + if (!isTokenDeposit) return false const allowanceOnChainCryptoBaseUnit = await getErc20Allowance({ address: fromAssetId(assetId).assetReference, @@ -211,7 +213,15 @@ export const Deposit: React.FC = ({ })() setIsApprovalRequired(isApprovalRequired) })() - }, [accountId, asset.chainId, asset.precision, assetId, inputValues, inboundAddress]) + }, [ + accountId, + asset.chainId, + asset.precision, + assetId, + inputValues, + inboundAddress, + isTokenDeposit, + ]) // TODO(gomes): this will work for UTXO but is invalid for tokens since they use diff. denoms // the current workaround is to not do fee deduction for non-UTXO chains, From 898f274364ff86b39f8b9f7a95acf0e6f4bd641b Mon Sep 17 00:00:00 2001 From: gomes <17035424+gomesalexandre@users.noreply.github.com> Date: Mon, 6 May 2024 20:53:07 +0300 Subject: [PATCH 4/4] feat: bail on fetching zapper /apps/balances when accountIds are empty (#6823) --- .../StakingVaults/hooks/useFetchOpportunities.tsx | 7 ++++++- src/state/apis/zapper/zapperApi.ts | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/StakingVaults/hooks/useFetchOpportunities.tsx b/src/components/StakingVaults/hooks/useFetchOpportunities.tsx index 70f9433aca4..5bcd20b1685 100644 --- a/src/components/StakingVaults/hooks/useFetchOpportunities.tsx +++ b/src/components/StakingVaults/hooks/useFetchOpportunities.tsx @@ -23,7 +23,12 @@ export const useFetchOpportunities = () => { const portfolioAccounts = useSelector(selectPortfolioAccounts) const DynamicLpAssets = useFeatureFlag('DynamicLpAssets') - const { isLoading: isZapperAppsBalancesOutputLoading } = useGetZapperAppsBalancesOutputQuery() + const { isLoading: isZapperAppsBalancesOutputLoading } = useGetZapperAppsBalancesOutputQuery( + undefined, + { + skip: !requestedAccountIds.length, + }, + ) const { isLoading: isZapperUniV2PoolAssetIdsLoading } = useGetZapperUniV2PoolAssetIdsQuery( undefined, { skip: !DynamicLpAssets }, diff --git a/src/state/apis/zapper/zapperApi.ts b/src/state/apis/zapper/zapperApi.ts index 68a9a774ac2..8125e4a9f30 100644 --- a/src/state/apis/zapper/zapperApi.ts +++ b/src/state/apis/zapper/zapperApi.ts @@ -330,6 +330,8 @@ export const zapper = createApi({ const accountIds = selectWalletAccountIds(state) + if (!accountIds.length) throw new Error('Not ready') + const assets = selectAssets(state) const evmNetworks = evmChainIds.map(chainIdToZapperNetwork).filter(isSome)