mirror of
https://github.com/logos-messaging/OpChan.git
synced 2026-01-13 01:53:11 +00:00
remove env logs
This commit is contained in:
parent
466f98b76b
commit
619c914e1b
@ -7,11 +7,6 @@ export class DelegationStorage {
|
||||
* Store delegation information in IndexedDB
|
||||
*/
|
||||
static async store(delegation: DelegationInfo): Promise<void> {
|
||||
// Reduce verbose logging in production; keep minimal signal
|
||||
if (!environment.isProduction) {
|
||||
console.log('DelegationStorage.store');
|
||||
}
|
||||
|
||||
try {
|
||||
await localDatabase.storeDelegation(delegation);
|
||||
} catch (e) {
|
||||
@ -25,9 +20,6 @@ export class DelegationStorage {
|
||||
static async retrieve(): Promise<DelegationInfo | null> {
|
||||
try {
|
||||
const delegation = await localDatabase.loadDelegation();
|
||||
if (!environment.isProduction) {
|
||||
console.log('DelegationStorage.retrieve');
|
||||
}
|
||||
return delegation;
|
||||
} catch (e) {
|
||||
console.error('Failed to retrieve delegation information', e);
|
||||
|
||||
@ -9,7 +9,6 @@ import { MessageService } from './MessageService';
|
||||
import messageManager from '../waku';
|
||||
import { localDatabase } from '../database/LocalDatabase';
|
||||
import { WalletManager } from '../wallet';
|
||||
import { environment } from '../utils/environment';
|
||||
|
||||
export interface UserIdentity {
|
||||
address: string;
|
||||
@ -62,9 +61,6 @@ export class UserIdentityService {
|
||||
// Check internal cache first
|
||||
if (this.userIdentityCache[address]) {
|
||||
const cached = this.userIdentityCache[address];
|
||||
if (environment.isDev) {
|
||||
console.debug('UserIdentityService: cache hit (internal)');
|
||||
}
|
||||
// Enrich with ENS name if missing and ETH address
|
||||
if (!cached.ensName && address.startsWith('0x')) {
|
||||
const ensName = await this.resolveENSName(address);
|
||||
@ -144,9 +140,6 @@ export class UserIdentityService {
|
||||
messageManager.messageCache.userIdentities[address];
|
||||
|
||||
if (cacheServiceData) {
|
||||
if (environment.isDev) {
|
||||
console.debug('UserIdentityService: cache hit (message cache)');
|
||||
}
|
||||
|
||||
// Store in internal cache for future use
|
||||
this.userIdentityCache[address] = {
|
||||
@ -191,9 +184,6 @@ export class UserIdentityService {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (environment.isDev) {
|
||||
console.debug('UserIdentityService: cache miss, resolving');
|
||||
}
|
||||
|
||||
// Try to resolve identity from various sources
|
||||
const identity = await this.resolveUserIdentity(address);
|
||||
@ -226,9 +216,6 @@ export class UserIdentityService {
|
||||
* Useful for explicit verification flows where we must hit upstream resolvers.
|
||||
*/
|
||||
async getUserIdentityFresh(address: string): Promise<UserIdentity | null> {
|
||||
if (environment.isDev) {
|
||||
console.debug('UserIdentityService: fresh resolve requested');
|
||||
}
|
||||
const identity = await this.resolveUserIdentity(address);
|
||||
if (identity) {
|
||||
// Update in-memory cache to reflect the fresh result
|
||||
@ -278,9 +265,6 @@ export class UserIdentityService {
|
||||
displayPreference: EDisplayPreference
|
||||
): Promise<boolean> {
|
||||
try {
|
||||
if (environment.isDev) {
|
||||
console.debug('UserIdentityService: updating profile', { address });
|
||||
}
|
||||
|
||||
const timestamp = Date.now();
|
||||
const unsignedMessage: UnsignedUserProfileUpdateMessage = {
|
||||
@ -295,19 +279,10 @@ export class UserIdentityService {
|
||||
unsignedMessage.callSign = callSign.trim();
|
||||
}
|
||||
|
||||
if (environment.isDev) {
|
||||
console.debug('UserIdentityService: created unsigned message');
|
||||
}
|
||||
|
||||
const signedMessage =
|
||||
await this.messageService.signAndBroadcastMessage(unsignedMessage);
|
||||
|
||||
if (environment.isDev) {
|
||||
console.debug(
|
||||
'UserIdentityService: message broadcast result',
|
||||
!!signedMessage
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// If broadcast was successful, immediately update local cache
|
||||
if (signedMessage) {
|
||||
|
||||
@ -33,9 +33,7 @@ export class WakuNodeManager {
|
||||
const health = event.detail;
|
||||
this._currentHealth = health;
|
||||
|
||||
if (environment.isDev) {
|
||||
console.debug(`Waku health status: ${health}`);
|
||||
}
|
||||
|
||||
|
||||
const wasReady = this._isReady;
|
||||
this._isReady =
|
||||
|
||||
@ -201,10 +201,6 @@ export class WalletManager {
|
||||
walletType: 'bitcoin' | 'ethereum'
|
||||
): Promise<boolean> {
|
||||
try {
|
||||
if (environment.isDev) {
|
||||
// Keep this lightweight in dev; avoid logging full message/signature repeatedly
|
||||
console.debug('WalletManager.verifySignature', { walletType });
|
||||
}
|
||||
if (walletType === 'ethereum') {
|
||||
return await verifyEthereumMessage(config, {
|
||||
address: walletAddress as `0x${string}`,
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import React, { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react';
|
||||
import { User, EVerificationStatus, EDisplayPreference } from '@opchan/core';
|
||||
import { delegationManager, type messageManager, localDatabase } from '@opchan/core';
|
||||
import { delegationManager, localDatabase } from '@opchan/core';
|
||||
import { DelegationDuration } from '@opchan/core';
|
||||
import { useAppKitAccount } from '@reown/appkit/react';
|
||||
import { useClient } from './ClientContext';
|
||||
@ -19,7 +19,11 @@ export interface AuthContextValue {
|
||||
getDelegationStatus: () => ReturnType<typeof delegationManager.getStatus>;
|
||||
clearDelegation: () => Promise<void>;
|
||||
|
||||
signMessage: typeof messageManager.sendMessage;
|
||||
signMessage: (message: unknown, statusCallback?: {
|
||||
onSent?: (messageId: string) => void;
|
||||
onAcknowledged?: (messageId: string) => void;
|
||||
onError?: (messageId: string, error: string) => void;
|
||||
}) => Promise<void>;
|
||||
verifyMessage: (message: unknown) => Promise<boolean>;
|
||||
}
|
||||
|
||||
|
||||
@ -1,95 +0,0 @@
|
||||
import React, { createContext, useContext, useEffect, useMemo, useState } from 'react';
|
||||
import { OpChanClient, type EVerificationStatus } from '@opchan/core';
|
||||
|
||||
export interface IdentityRecord {
|
||||
address: string;
|
||||
displayName: string;
|
||||
callSign: string | null;
|
||||
ensName: string | null;
|
||||
ordinalDetails: string | null;
|
||||
verificationStatus: EVerificationStatus;
|
||||
lastUpdated: number;
|
||||
}
|
||||
|
||||
export interface IdentityContextValue {
|
||||
getIdentity: (address: string) => IdentityRecord | null;
|
||||
getDisplayName: (address: string) => string;
|
||||
}
|
||||
|
||||
const IdentityContext = createContext<IdentityContextValue | null>(null);
|
||||
|
||||
export const IdentityProvider: React.FC<{ client: OpChanClient; children: React.ReactNode }> = ({ client, children }) => {
|
||||
const [cache, setCache] = useState<Record<string, IdentityRecord>>({});
|
||||
|
||||
useEffect(() => {
|
||||
let mounted = true;
|
||||
const seedFromService = async () => {
|
||||
try {
|
||||
// Warm snapshot of any already-cached identities
|
||||
const identities = client.userIdentityService.getAllUserIdentities();
|
||||
if (!mounted) return;
|
||||
const next: Record<string, IdentityRecord> = {};
|
||||
identities.forEach(id => {
|
||||
next[id.address] = {
|
||||
address: id.address,
|
||||
displayName: client.userIdentityService.getDisplayName(id.address),
|
||||
callSign: id.callSign ?? null,
|
||||
ensName: id.ensName ?? null,
|
||||
ordinalDetails: id.ordinalDetails?.ordinalDetails ?? null,
|
||||
verificationStatus: id.verificationStatus,
|
||||
lastUpdated: id.lastUpdated,
|
||||
};
|
||||
});
|
||||
setCache(next);
|
||||
} catch {}
|
||||
};
|
||||
seedFromService();
|
||||
|
||||
// Subscribe to identity refresh events for live updates
|
||||
const off = client.userIdentityService.addRefreshListener(async (address: string) => {
|
||||
try {
|
||||
const fresh = await client.userIdentityService.getUserIdentity(address);
|
||||
if (!fresh) return;
|
||||
setCache(prev => ({
|
||||
...prev,
|
||||
[address]: {
|
||||
address,
|
||||
displayName: client.userIdentityService.getDisplayName(address),
|
||||
callSign: fresh.callSign ?? null,
|
||||
ensName: fresh.ensName ?? null,
|
||||
ordinalDetails: fresh.ordinalDetails?.ordinalDetails ?? null,
|
||||
verificationStatus: fresh.verificationStatus,
|
||||
lastUpdated: fresh.lastUpdated,
|
||||
},
|
||||
}));
|
||||
} catch {}
|
||||
});
|
||||
|
||||
return () => {
|
||||
try { off && off(); } catch {}
|
||||
mounted = false;
|
||||
};
|
||||
}, [client]);
|
||||
|
||||
const getIdentity = useMemo(() => {
|
||||
return (address: string): IdentityRecord | null => cache[address] ?? null;
|
||||
}, [cache]);
|
||||
|
||||
const getDisplayName = useMemo(() => {
|
||||
return (address: string): string => client.userIdentityService.getDisplayName(address);
|
||||
}, [client]);
|
||||
|
||||
const value: IdentityContextValue = useMemo(() => ({ getIdentity, getDisplayName }), [getIdentity, getDisplayName]);
|
||||
|
||||
return <IdentityContext.Provider value={value}>{children}</IdentityContext.Provider>;
|
||||
};
|
||||
|
||||
export function useIdentity(): IdentityContextValue {
|
||||
const ctx = useContext(IdentityContext);
|
||||
if (!ctx) throw new Error('useIdentity must be used within OpChanProvider');
|
||||
return ctx;
|
||||
}
|
||||
|
||||
export { IdentityContext };
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
import { EDisplayPreference, EVerificationStatus } from '@opchan/core';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useClient } from '../../contexts/ClientContext';
|
||||
import { useIdentity } from '../../contexts/IdentityContext';
|
||||
|
||||
export interface UserDisplayInfo {
|
||||
displayName: string;
|
||||
@ -19,7 +18,7 @@ export interface UserDisplayInfo {
|
||||
*/
|
||||
export function useUserDisplay(address: string): UserDisplayInfo {
|
||||
const client = useClient();
|
||||
const { getIdentity, getDisplayName } = useIdentity();
|
||||
const getDisplayName = (addr: string) => client.userIdentityService.getDisplayName(addr);
|
||||
const [displayInfo, setDisplayInfo] = useState<UserDisplayInfo>({
|
||||
displayName: `${address.slice(0, 6)}...${address.slice(-4)}`,
|
||||
callSign: null,
|
||||
@ -30,7 +29,7 @@ export function useUserDisplay(address: string): UserDisplayInfo {
|
||||
isLoading: true,
|
||||
error: null,
|
||||
});
|
||||
// Subscribe via IdentityContext by relying on its internal listener
|
||||
// Subscribe to identity service refresh events directly
|
||||
useEffect(() => {
|
||||
let cancelled = false;
|
||||
const prime = async () => {
|
||||
@ -69,24 +68,27 @@ export function useUserDisplay(address: string): UserDisplayInfo {
|
||||
};
|
||||
prime();
|
||||
return () => { cancelled = true; };
|
||||
}, [address, client.userIdentityService, getDisplayName]);
|
||||
}, [address, client, getDisplayName]);
|
||||
|
||||
// Reactively reflect IdentityContext cache changes
|
||||
useEffect(() => {
|
||||
if (!address) return;
|
||||
const id = getIdentity(address);
|
||||
if (!id) return;
|
||||
setDisplayInfo(prev => ({
|
||||
...prev,
|
||||
displayName: getDisplayName(address),
|
||||
callSign: id.callSign,
|
||||
ensName: id.ensName,
|
||||
ordinalDetails: id.ordinalDetails,
|
||||
verificationLevel: id.verificationStatus,
|
||||
isLoading: false,
|
||||
error: null,
|
||||
}));
|
||||
}, [address, getIdentity, getDisplayName]);
|
||||
const off = client.userIdentityService.addRefreshListener(async (changed) => {
|
||||
if (changed !== address) return;
|
||||
const identity = await client.userIdentityService.getUserIdentity(address);
|
||||
if (!identity) return;
|
||||
setDisplayInfo(prev => ({
|
||||
...prev,
|
||||
displayName: getDisplayName(address),
|
||||
callSign: identity.callSign || null,
|
||||
ensName: identity.ensName || null,
|
||||
ordinalDetails: identity.ordinalDetails ? identity.ordinalDetails.ordinalDetails : null,
|
||||
verificationLevel: identity.verificationStatus,
|
||||
isLoading: false,
|
||||
error: null,
|
||||
}));
|
||||
});
|
||||
return () => { try { off && off(); } catch {} };
|
||||
}, [address, client, getDisplayName]);
|
||||
|
||||
return displayInfo;
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ export { useForumApi } from './useForum';
|
||||
export { useForumData } from './core/useForumData';
|
||||
export { usePermissions } from './core/usePermissions';
|
||||
export { useUserDisplay } from './core/useUserDisplay';
|
||||
export { useIdentity } from './useIdentity';
|
||||
|
||||
// Derived hooks (data slicing utilities)
|
||||
export { useCell } from './derived/useCell';
|
||||
|
||||
@ -3,6 +3,7 @@ export { ClientProvider, useClient } from './contexts/ClientContext';
|
||||
export { AuthProvider, useAuth } from './contexts/AuthContext';
|
||||
export { ForumProvider, useForum as useForumContext } from './contexts/ForumContext';
|
||||
export { ModerationProvider, useModeration } from './contexts/ModerationContext';
|
||||
export { useIdentity } from './hooks/useIdentity';
|
||||
|
||||
export * from './hooks';
|
||||
export { useForumApi as useForum } from './hooks/useForum';
|
||||
|
||||
@ -5,7 +5,6 @@ import { ClientProvider } from '../contexts/ClientContext';
|
||||
import { AuthProvider } from '../contexts/AuthContext';
|
||||
import { ForumProvider } from '../contexts/ForumContext';
|
||||
import { ModerationProvider } from '../contexts/ModerationContext';
|
||||
import { IdentityProvider } from '../contexts/IdentityContext';
|
||||
|
||||
export interface OpChanProviderProps {
|
||||
ordiscanApiKey: string;
|
||||
@ -56,13 +55,11 @@ export const OpChanProvider: React.FC<OpChanProviderProps> = ({
|
||||
if (!isReady || !clientRef.current) return null;
|
||||
return (
|
||||
<ClientProvider client={clientRef.current}>
|
||||
<IdentityProvider client={clientRef.current}>
|
||||
<AuthProvider>
|
||||
<ModerationProvider>
|
||||
<ForumProvider>{children}</ForumProvider>
|
||||
</ModerationProvider>
|
||||
</AuthProvider>
|
||||
</IdentityProvider>
|
||||
<AuthProvider>
|
||||
<ModerationProvider>
|
||||
<ForumProvider>{children}</ForumProvider>
|
||||
</ModerationProvider>
|
||||
</AuthProvider>
|
||||
</ClientProvider>
|
||||
);
|
||||
}, [isReady, children]);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user