chore: allow reown project ID through config

This commit is contained in:
Danish Arora 2025-10-23 19:08:01 +05:30
parent 05938b5127
commit 3197dcaa6f
No known key found for this signature in database
GPG Key ID: 1C6EF37CDAE1426E
4 changed files with 14 additions and 3 deletions

View File

@ -14,7 +14,8 @@ createRoot(document.getElementById('root')!).render(
wakuConfig: { wakuConfig: {
contentTopic: '/opchan/1/messages/proto', contentTopic: '/opchan/1/messages/proto',
reliableChannelId: 'opchan-messages' reliableChannelId: 'opchan-messages'
} },
reownProjectId: import.meta.env.VITE_REOWN_SECRET || '2ead96ea166a03e5ab50e5c190532e72'
}}> }}>
<App /> <App />
</OpChanProvider> </OpChanProvider>

View File

@ -12,6 +12,7 @@ import { WakuConfig } from '../types';
export interface OpChanClientConfig { export interface OpChanClientConfig {
ordiscanApiKey: string; ordiscanApiKey: string;
wakuConfig: WakuConfig; wakuConfig: WakuConfig;
reownProjectId?: string;
} }
export class OpChanClient { export class OpChanClient {
@ -33,6 +34,7 @@ export class OpChanClient {
apiKeys: { apiKeys: {
ordiscan: config.ordiscanApiKey, ordiscan: config.ordiscanApiKey,
}, },
reownProjectId: config.reownProjectId,
}; };
environment.configure(env); environment.configure(env);

View File

@ -7,6 +7,7 @@ export interface EnvironmentConfig {
apiKeys?: { apiKeys?: {
ordiscan?: string; ordiscan?: string;
}; };
reownProjectId?: string;
} }
class Environment { class Environment {
@ -20,6 +21,10 @@ class Environment {
public get ordiscanApiKey(): string | undefined { public get ordiscanApiKey(): string | undefined {
return this.config.apiKeys?.ordiscan; return this.config.apiKeys?.ordiscan;
} }
public get reownProjectId(): string | undefined {
return this.config.reownProjectId;
}
} }
export const environment = new Environment(); export const environment = new Environment();

View File

@ -3,15 +3,18 @@ import { BitcoinAdapter } from '@reown/appkit-adapter-bitcoin';
import { WagmiAdapter } from '@reown/appkit-adapter-wagmi'; import { WagmiAdapter } from '@reown/appkit-adapter-wagmi';
import { createStorage } from 'wagmi'; import { createStorage } from 'wagmi';
import { mainnet, bitcoin, AppKitNetwork } from '@reown/appkit/networks'; import { mainnet, bitcoin, AppKitNetwork } from '@reown/appkit/networks';
import { environment } from '../utils/environment';
const networks: [AppKitNetwork, ...AppKitNetwork[]] = [mainnet, bitcoin]; const networks: [AppKitNetwork, ...AppKitNetwork[]] = [mainnet, bitcoin];
const projectId = const projectId =
process.env.VITE_REOWN_SECRET || '2ead96ea166a03e5ab50e5c190532e72'; environment.reownProjectId ||
process.env.VITE_REOWN_SECRET ||
'2ead96ea166a03e5ab50e5c190532e72';
if (!projectId) { if (!projectId) {
throw new Error( throw new Error(
'VITE_REOWN_SECRET is not defined. Please set it in your .env file' 'Reown project ID is not defined. Please set it via config.reownProjectId, VITE_REOWN_SECRET environment variable, or use the default.'
); );
} }