Remove debugging console logs

This commit is contained in:
SaraJane
2026-01-13 16:35:42 +00:00
parent 9e7874af60
commit a6622d2cf8
2 changed files with 0 additions and 72 deletions

View File

@ -33,34 +33,22 @@ export function Web3AuthProvider({ children }: { children: ReactNode }) {
useEffect(() => { useEffect(() => {
const initializeWeb3Auth = async () => { const initializeWeb3Auth = async () => {
console.log('🎯 WEB3AUTHPROVIDER: Starting initialization')
console.log('🎯 Environment variables:', {
clientId: import.meta.env.VITE_WEB3AUTH_CLIENT_ID ? 'SET' : 'MISSING',
mode: import.meta.env.MODE,
dev: import.meta.env.DEV,
})
try { try {
setIsLoading(true) setIsLoading(true)
setError(null) setError(null)
console.log('🎯 Calling initWeb3Auth()...')
const web3auth = await initWeb3Auth() const web3auth = await initWeb3Auth()
console.log('🎯 initWeb3Auth() returned:', web3auth)
setWeb3AuthInstance(web3auth) setWeb3AuthInstance(web3auth)
if (web3auth.status === 'connected' && web3auth.provider) { if (web3auth.status === 'connected' && web3auth.provider) {
console.log('🎯 User already connected from previous session')
setProvider(web3auth.provider) setProvider(web3auth.provider)
setIsConnected(true) setIsConnected(true)
try { try {
const account = await getAlgorandAccount(web3auth.provider) const account = await getAlgorandAccount(web3auth.provider)
setAlgorandAccount(account) setAlgorandAccount(account)
console.log('🎯 Algorand account derived:', account.address)
} catch (err) { } catch (err) {
console.error('🎯 Failed to derive Algorand account:', err)
setError('Failed to derive Algorand account. Please reconnect.') setError('Failed to derive Algorand account. Please reconnect.')
} }
@ -68,7 +56,6 @@ export function Web3AuthProvider({ children }: { children: ReactNode }) {
const userInformation = await getWeb3AuthUserInfo() const userInformation = await getWeb3AuthUserInfo()
if (userInformation) { if (userInformation) {
setUserInfo(userInformation) setUserInfo(userInformation)
console.log('🎯 User info fetched:', userInformation)
} }
} catch (err) { } catch (err) {
console.error('🎯 Failed to fetch user info:', err) console.error('🎯 Failed to fetch user info:', err)
@ -76,7 +63,6 @@ export function Web3AuthProvider({ children }: { children: ReactNode }) {
} }
setIsInitialized(true) setIsInitialized(true)
console.log('🎯 WEB3AUTHPROVIDER: Initialization complete')
} catch (err) { } catch (err) {
const errorMessage = err instanceof Error ? err.message : 'Failed to initialize Web3Auth' const errorMessage = err instanceof Error ? err.message : 'Failed to initialize Web3Auth'
console.error('🎯 WEB3AUTHPROVIDER: Initialization error:', err) console.error('🎯 WEB3AUTHPROVIDER: Initialization error:', err)
@ -91,7 +77,6 @@ export function Web3AuthProvider({ children }: { children: ReactNode }) {
}, []) }, [])
const login = async () => { const login = async () => {
console.log('🎯 LOGIN: Called')
if (!web3AuthInstance) { if (!web3AuthInstance) {
console.error('🎯 LOGIN: Web3Auth not initialized') console.error('🎯 LOGIN: Web3Auth not initialized')
@ -109,9 +94,7 @@ export function Web3AuthProvider({ children }: { children: ReactNode }) {
setIsLoading(true) setIsLoading(true)
setError(null) setError(null)
console.log('🎯 LOGIN: Calling web3AuthInstance.connect()...')
const web3authProvider = await web3AuthInstance.connect() const web3authProvider = await web3AuthInstance.connect()
console.log('🎯 LOGIN: connect() returned:', web3authProvider ? 'PROVIDER' : 'NULL')
if (!web3authProvider) { if (!web3authProvider) {
throw new Error('Failed to connect Web3Auth provider') throw new Error('Failed to connect Web3Auth provider')
@ -121,28 +104,22 @@ export function Web3AuthProvider({ children }: { children: ReactNode }) {
setIsConnected(true) setIsConnected(true)
try { try {
console.log('🎯 LOGIN: Deriving Algorand account...')
const account = await getAlgorandAccount(web3authProvider) const account = await getAlgorandAccount(web3authProvider)
setAlgorandAccount(account) setAlgorandAccount(account)
console.log('🎯 LOGIN: Successfully derived Algorand account:', account.address)
} catch (err) { } catch (err) {
const errorMessage = err instanceof Error ? err.message : 'Failed to derive Algorand account' const errorMessage = err instanceof Error ? err.message : 'Failed to derive Algorand account'
setError(errorMessage) setError(errorMessage)
console.error('🎯 LOGIN: Algorand account derivation error:', err)
} }
try { try {
console.log('🎯 LOGIN: Fetching user info...')
const userInformation = await getWeb3AuthUserInfo() const userInformation = await getWeb3AuthUserInfo()
if (userInformation) { if (userInformation) {
setUserInfo(userInformation) setUserInfo(userInformation)
console.log('🎯 LOGIN: User info fetched')
} }
} catch (err) { } catch (err) {
console.error('🎯 LOGIN: Failed to fetch user info:', err) console.error('🎯 LOGIN: Failed to fetch user info:', err)
} }
console.log('🎯 LOGIN: Complete')
} catch (err) { } catch (err) {
const errorMessage = err instanceof Error ? err.message : 'Login failed' const errorMessage = err instanceof Error ? err.message : 'Login failed'
console.error('🎯 LOGIN: Error:', err) console.error('🎯 LOGIN: Error:', err)
@ -156,8 +133,6 @@ export function Web3AuthProvider({ children }: { children: ReactNode }) {
} }
const logout = async () => { const logout = async () => {
console.log('🎯 LOGOUT: Called')
try { try {
setIsLoading(true) setIsLoading(true)
setError(null) setError(null)
@ -169,7 +144,6 @@ export function Web3AuthProvider({ children }: { children: ReactNode }) {
setAlgorandAccount(null) setAlgorandAccount(null)
setUserInfo(null) setUserInfo(null)
console.log('🎯 LOGOUT: Complete')
} catch (err) { } catch (err) {
const errorMessage = err instanceof Error ? err.message : 'Logout failed' const errorMessage = err instanceof Error ? err.message : 'Logout failed'
console.error('🎯 LOGOUT: Error:', err) console.error('🎯 LOGOUT: Error:', err)
@ -185,12 +159,10 @@ export function Web3AuthProvider({ children }: { children: ReactNode }) {
} }
const refreshUserInfo = async () => { const refreshUserInfo = async () => {
console.log('🎯 REFRESH: Called')
try { try {
const userInformation = await getWeb3AuthUserInfo() const userInformation = await getWeb3AuthUserInfo()
if (userInformation) { if (userInformation) {
setUserInfo(userInformation) setUserInfo(userInformation)
console.log('🎯 REFRESH: User info refreshed')
} }
} catch (err) { } catch (err) {
console.error('🎯 REFRESH: Failed:', err) console.error('🎯 REFRESH: Failed:', err)

View File

@ -5,19 +5,12 @@ import { Web3Auth } from '@web3auth/modal'
let web3authInstance: Web3Auth | null = null let web3authInstance: Web3Auth | null = null
export async function initWeb3Auth(): Promise<Web3Auth> { export async function initWeb3Auth(): Promise<Web3Auth> {
console.log('========================================')
console.log('🔧 STARTING WEB3AUTH INITIALIZATION')
console.log('========================================')
if (web3authInstance) { if (web3authInstance) {
console.log('✅ Web3Auth already initialized, returning existing instance')
return web3authInstance return web3authInstance
} }
const clientId = import.meta.env.VITE_WEB3AUTH_CLIENT_ID const clientId = import.meta.env.VITE_WEB3AUTH_CLIENT_ID
console.log('📋 Client ID check:', clientId ? '✅ SET' : '❌ MISSING')
console.log('📋 Client ID length:', clientId?.length || 0)
console.log('📋 Client ID (first 20 chars):', clientId?.substring(0, 20) + '...')
if (!clientId) { if (!clientId) {
const error = new Error('VITE_WEB3AUTH_CLIENT_ID is not configured') const error = new Error('VITE_WEB3AUTH_CLIENT_ID is not configured')
@ -26,7 +19,6 @@ export async function initWeb3Auth(): Promise<Web3Auth> {
} }
try { try {
console.log('📦 Creating privateKeyProvider...')
// Create the private key provider for Algorand // Create the private key provider for Algorand
const privateKeyProvider = new CommonPrivateKeyProvider({ const privateKeyProvider = new CommonPrivateKeyProvider({
@ -43,9 +35,6 @@ export async function initWeb3Auth(): Promise<Web3Auth> {
}, },
}) })
console.log('✅ privateKeyProvider created')
console.log('📦 Creating Web3Auth configuration object...')
const web3AuthConfig = { const web3AuthConfig = {
clientId, clientId,
web3AuthNetwork: WEB3AUTH_NETWORK.SAPPHIRE_DEVNET, web3AuthNetwork: WEB3AUTH_NETWORK.SAPPHIRE_DEVNET,
@ -61,51 +50,27 @@ export async function initWeb3Auth(): Promise<Web3Auth> {
}, },
} }
console.log('📦 Config created with privateKeyProvider')
console.log('🏗️ Instantiating Web3Auth...')
web3authInstance = new Web3Auth(web3AuthConfig) web3authInstance = new Web3Auth(web3AuthConfig)
console.log('✅ Web3Auth instance created successfully')
console.log('📞 Calling initModal()...')
await web3authInstance.initModal() await web3authInstance.initModal()
console.log('✅ initModal() completed successfully')
console.log('📊 Web3Auth status:', web3authInstance.status)
console.log('📊 Web3Auth connected:', web3authInstance.connected)
console.log('========================================')
console.log('✅ WEB3AUTH INITIALIZATION COMPLETE')
console.log('========================================')
return web3authInstance return web3authInstance
} catch (error) { } catch (error) {
console.error('========================================')
console.error('❌ WEB3AUTH INITIALIZATION FAILED')
console.error('========================================')
console.error('Error type:', error?.constructor?.name)
console.error('Error message:', error instanceof Error ? error.message : 'Unknown error')
console.error('Full error:', error)
console.error('Stack trace:', error instanceof Error ? error.stack : 'No stack trace')
console.error('========================================')
throw error throw error
} }
} }
export function getWeb3AuthInstance(): Web3Auth | null { export function getWeb3AuthInstance(): Web3Auth | null {
console.log('🔍 getWeb3AuthInstance() called, instance:', web3authInstance ? '✅ EXISTS' : '❌ NULL')
return web3authInstance return web3authInstance
} }
export function getWeb3AuthProvider(): IProvider | null { export function getWeb3AuthProvider(): IProvider | null {
const provider = web3authInstance?.provider || null const provider = web3authInstance?.provider || null
console.log('🔍 getWeb3AuthProvider() called, provider:', provider ? '✅ EXISTS' : '❌ NULL')
return provider return provider
} }
export function isWeb3AuthConnected(): boolean { export function isWeb3AuthConnected(): boolean {
const connected = web3authInstance?.status === 'connected' const connected = web3authInstance?.status === 'connected'
console.log('🔍 isWeb3AuthConnected() called, connected:', connected)
return connected return connected
} }
@ -117,36 +82,27 @@ export interface Web3AuthUserInfo {
} }
export async function getWeb3AuthUserInfo(): Promise<Web3AuthUserInfo | null> { export async function getWeb3AuthUserInfo(): Promise<Web3AuthUserInfo | null> {
console.log('🔍 getWeb3AuthUserInfo() called')
if (!web3authInstance || !isWeb3AuthConnected()) { if (!web3authInstance || !isWeb3AuthConnected()) {
console.log('❌ Cannot get user info: not connected')
return null return null
} }
try { try {
const userInfo = await web3authInstance.getUserInfo() const userInfo = await web3authInstance.getUserInfo()
console.log('✅ User info retrieved:', userInfo)
return userInfo as Web3AuthUserInfo return userInfo as Web3AuthUserInfo
} catch (error) { } catch (error) {
console.error('❌ Failed to get user info:', error)
return null return null
} }
} }
export async function logoutFromWeb3Auth(): Promise<void> { export async function logoutFromWeb3Auth(): Promise<void> {
console.log('🚪 logoutFromWeb3Auth() called')
if (!web3authInstance) { if (!web3authInstance) {
console.log('⚠️ No instance to logout from')
return return
} }
try { try {
await web3authInstance.logout() await web3authInstance.logout()
console.log('✅ Logged out successfully')
} catch (error) { } catch (error) {
console.error('❌ Logout failed:', error)
throw error throw error
} }
} }