10000 Debug TF by brunobar79 · Pull Request #6475 · rainbow-me/rainbow · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Debug TF #6475

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

Merged
merged 5 commits into from
Mar 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions globals.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,6 @@ declare module 'react-native-dotenv' {
export const MWP_ENCRYPTION_KEY: string;
export const METADATA_BASE_URL: string;
export const ADDYS_BASE_URL: string;
export const TOKEN_LAUNCHER_URL: string;
export const TOKEN_LAUNCHER_API_KEY: string;
}
3 changes: 1 addition & 2 deletions src/handlers/dispersion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ import { RainbowFetchClient } from '../rainbow-fetch';
import { EthereumAddress, RainbowToken } from '@/entities';
import UniswapAssetsCache from '@/utils/uniswapAssetsCache';
import { logger, RainbowError } from '@/logger';
import { METADATA_BASE_URL } from 'react-native-dotenv';

let dispersionApi: RainbowFetchClient | undefined;

const getDispersionApi = () => {
const clientUrl = dispersionApi?.baseURL;
const baseUrl = METADATA_BASE_URL;
const baseUrl = 'https://metadata.p.rainbow.me';
if (!dispersionApi || clientUrl !== baseUrl) {
dispersionApi = new RainbowFetchClient({
baseURL: baseUrl,
Expand Down
5 changes: 2 additions & 3 deletions src/handlers/gasFees.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { useBackendNetworksStore } from '@/state/backendNetworks/backendNetworks';
import { RainbowFetchClient } from '../rainbow-fetch';
import { ChainId } from '@/state/backendNetworks/types';
import { METADATA_BASE_URL } from 'react-native-dotenv';

let rainbowMeteorologyApi: RainbowFetchClient | undefined;

const getRainbowMeteorologyApi = () => {
export const getRainbowMeteorologyApi = () => {
const clientUrl = rainbowMeteorologyApi?.baseURL;
const baseUrl = METADATA_BASE_URL;
const baseUrl = 'https://metadata.p.rainbow.me';
if (!rainbowMeteorologyApi || clientUrl !== baseUrl) {
rainbowMeteorologyApi = new RainbowFetchClient({
baseURL: baseUrl,
Expand Down
1 change: 1 addition & 0 deletions src/languages/en_US.json
10000
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@
},
"developer_settings": {
"alert": "Alert",
"analyze_env_variables": "Analyze ENV Variables",
"analyze_react_query": "Analyze React Query",
"applied": "APPLIED",
"backups_deleted_successfully": "Backups Deleted Successfully",
Expand Down
4 changes: 2 additions & 2 deletions src/resources/metadata/backendNetworks.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { BackendNetwork } from '@/state/backendNetworks/types';
import { BACKEND_NETWORKS_QUERY } from './sharedQueries';
import { METADATA_BASE_URL } from 'react-native-dotenv';

// ///////////////////////////////////////////////
// Query Types
Expand All @@ -13,7 +12,8 @@ export interface BackendNetworksResponse {
// Query Function

export async function fetchBackendNetworks(): Promise<BackendNetworksResponse> {
const response = await fetch(`${METADATA_BASE_URL}/v1/graph`, {
const BASE_URL = 'https://metadata.p.rainbow.me';
const response = await fetch(`${BASE_URL}/v1/graph`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
Expand Down
7 changes: 7 additions & 0 deletions src/screens/SettingsSheet/components/DevSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import { addDefaultNotificationGroupSettings } from '@/notifications/settings/in
import { unsubscribeAllNotifications } from '@/notifications/settings/settings';
import FastImage from 'react-native-fast-image';
import { analyzeReactQueryStore, clearReactQueryCache } from '@/react-query/reactQueryUtils';
import { analyzeEnvVariables } from '@/utils/analyzeEnvVariables';

const DevSection = () => {
const { navigate } = useNavigation();
Expand Down Expand Up @@ -264,6 +265,12 @@ const DevSection = () => {
size={52}
titleComponent={<MenuItem.Title text={lang.t('developer_settings.restart_app')} />}
/>
<MenuItem
leftComponent={<MenuItem.TextIcon icon="🔍" isEmoji />}
>
size={52}
titleComponent={<MenuItem.Title text={lang.t('developer_settings.analyze_env_variables')} />}
/>
<MenuItem
leftComponent={<MenuItem.TextIcon icon="🔦" isEmoji />}
=> analyzeReactQueryStore()}
Expand Down
102 changes: 102 additions & 0 deletions src/utils/analyzeEnvVariables.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import { logger, RainbowError } from '@/logger';
import {
METADATA_BASE_URL,
ARC_GRAPHQL_API_KEY,
METADATA_GRAPHQL_API_KEY,
ADDYS_API_KEY,
ADDYS_BASE_URL,
TOKEN_LAUNCHER_API_KEY,
TOKEN_LAUNCHER_URL,
} from 'react-native-dotenv';
import { getRainbowMeteorologyApi } from '@/handlers/gasFees';
import { showLogSheet } from '@/components/debugging/LogSheet';
import { getAddysHttpClient } from '@/resources/addys/client';

/**
* Analyzes environment variables and API clients in the app
* Displays the results in a log sheet
*/
export const analyzeEnvVariables = () => {
// Collect environment variables we know exist
const envVars: Record<string, string> = {};

// Add known environment variables
if (METADATA_BASE_URL) envVars['METADATA_BASE_URL'] = METADATA_BASE_URL;
if (METADATA_GRAPHQL_API_KEY) envVars['METADATA_GRAPHQL_API_KEY'] = METADATA_GRAPHQL_API_KEY;
if (ADDYS_BASE_URL) envVars['ADDYS_BASE_URL'] = ADDYS_BASE_URL;
if (ADDYS_API_KEY) envVars['ADDYS_API_KEY'] = ADDYS_API_KEY;
if (TOKEN_LAUNCHER_URL) envVars['TOKEN_LAUNCHER_URL'] = TOKEN_LAUNCHER_URL;
if (TOKEN_LAUNCHER_API_KEY) envVars['TOKEN_LAUNCHER_API_KEY'] = TOKEN_LAUNCHER_API_KEY;
if (ARC_GRAPHQL_API_KEY) envVars['ARC_GRAPHQL_API_KEY'] = ARC_GRAPHQL_API_KEY;

// Find all RainbowFetchClient instances in the app
const fetchClients: Record<string, any> = {};

// Add the known RainbowFetchClient from gasFees.ts
try {
const meteorologyApi = getRainbowMeteorologyApi();
if (meteorologyApi) {
fetchClients['rainbowMeteorologyApi'] = {
baseURL: meteorologyApi.baseURL || 'undefined',
// Access properties safely with type casting
headers: (meteorologyApi as any).defaults?.headers || {},
timeout: (meteorologyApi as any).defaults?.timeout,
};
}
} catch (e) {
logger.error(new RainbowError(`Error accessing meteorology API: ${e}`));
}

// Try to get other known clients if they exist in global scope
try {
// @ts-ignore - Global object access
const globalClients = Object.keys(global)
.filter(key => key.includes('Api') || key.includes('Client') || key.includes('Fetch'))
.reduce((acc: Record<string, any>, key) => {
try {
// @ts-ignore - Global object access
const client = global[key];
if (client && typeof client === 'object') {
if (client.baseURL) {
acc[key] = {
baseURL: client.baseURL,
headers: client.defaults?.headers || {},
timeout: client.defaults?.timeout,
};
} else if (client.defaults?.baseURL) {
acc[key] = {
baseURL: client.defaults.baseURL,
headers: client.defaults?.headers || {},
timeout: client.defaults?.timeout,
};
}
}
} catch (err) {
// Ignore errors for individual clients
}
return acc;
}, {});

globalClients['addysHttpClient'] = getAddysHttpClient();

Object.assign(fetchClients, globalClients);
} catch (e) {
logger.error(new RainbowError(`Error finding global RainbowFetchClients: ${e}`));
}

// Create formatted data for the log sheet
const logEntries = [
{ title: '🔍 Environment Variables Analysis', message: '' },
{ title: 'Environment Variables', message: JSON.stringify(envVars, null, 2) },
{ title: 'Fetch Clients', message: JSON.stringify(fetchClients, null, 2) },
];

// Show the log sheet with the data
showLogSheet({ data: logEntries });

// Also log to console for easier debugging
console.log('[ENV VARIABLES ANALYSIS]', {
envVars,
fetchClients,
});
};
Loading
0