mirror of
https://github.com/logos-messaging/OpChan.git
synced 2026-01-02 12:53:10 +00:00
fix: ens
This commit is contained in:
parent
539c596974
commit
c0497610c3
@ -31,6 +31,7 @@ import { AppKitProvider } from "@reown/appkit/react";
|
||||
// Create a client
|
||||
const queryClient = new QueryClient();
|
||||
|
||||
|
||||
const App = () => (
|
||||
<WagmiProvider config={config}>
|
||||
<QueryClientProvider client={queryClient}>
|
||||
|
||||
@ -104,10 +104,15 @@ export class AuthService {
|
||||
|
||||
// Add ENS info for Ethereum wallets (if available)
|
||||
if (walletType === 'ethereum') {
|
||||
// Note: ENS resolution would need to be implemented separately
|
||||
// For now, we'll leave it as undefined
|
||||
user.ensName = undefined;
|
||||
user.ensOwnership = false;
|
||||
try {
|
||||
const walletInfo = await this.walletService.getWalletInfo();
|
||||
user.ensName = walletInfo?.ensName;
|
||||
user.ensOwnership = !!(walletInfo?.ensName);
|
||||
} catch (error) {
|
||||
console.warn('Failed to resolve ENS during wallet connection:', error);
|
||||
user.ensName = undefined;
|
||||
user.ensOwnership = false;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
@ -190,21 +195,40 @@ export class AuthService {
|
||||
* Verify Ethereum ENS ownership
|
||||
*/
|
||||
private async verifyEthereumENS(user: User): Promise<AuthResult> {
|
||||
// Note: ENS resolution would need to be implemented separately
|
||||
// For now, we'll assume no ENS ownership
|
||||
const hasENS = false;
|
||||
try {
|
||||
// Get wallet info with ENS resolution
|
||||
const walletInfo = await this.walletService.getWalletInfo();
|
||||
|
||||
const hasENS = !!(walletInfo?.ensName);
|
||||
const ensName = walletInfo?.ensName;
|
||||
|
||||
const updatedUser = {
|
||||
...user,
|
||||
ensOwnership: hasENS,
|
||||
ensName: undefined,
|
||||
lastChecked: Date.now(),
|
||||
};
|
||||
const updatedUser = {
|
||||
...user,
|
||||
ensOwnership: hasENS,
|
||||
ensName: ensName,
|
||||
lastChecked: Date.now(),
|
||||
};
|
||||
|
||||
return {
|
||||
success: true,
|
||||
user: updatedUser
|
||||
};
|
||||
return {
|
||||
success: true,
|
||||
user: updatedUser
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('Error verifying ENS ownership:', error);
|
||||
|
||||
// Fall back to no ENS ownership on error
|
||||
const updatedUser = {
|
||||
...user,
|
||||
ensOwnership: false,
|
||||
ensName: undefined,
|
||||
lastChecked: Date.now(),
|
||||
};
|
||||
|
||||
return {
|
||||
success: true,
|
||||
user: updatedUser
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -298,25 +322,8 @@ export class AuthService {
|
||||
* Get current wallet info
|
||||
*/
|
||||
async getWalletInfo() {
|
||||
// Return basic wallet info based on what's available
|
||||
const isBitcoinConnected = this.walletService.isWalletAvailable('bitcoin');
|
||||
const isEthereumConnected = this.walletService.isWalletAvailable('ethereum');
|
||||
|
||||
if (isBitcoinConnected) {
|
||||
return {
|
||||
address: this.getActiveAddress(),
|
||||
walletType: 'bitcoin' as const,
|
||||
isConnected: true
|
||||
};
|
||||
} else if (isEthereumConnected) {
|
||||
return {
|
||||
address: this.getActiveAddress(),
|
||||
walletType: 'ethereum' as const,
|
||||
isConnected: true
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
// Use the wallet service to get detailed wallet info including ENS
|
||||
return await this.walletService.getWalletInfo();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1,9 +1,18 @@
|
||||
import { UseAppKitAccountReturn } from '@reown/appkit/react';
|
||||
import { KeyDelegation } from '../signatures/key-delegation';
|
||||
import { AppKit } from '@reown/appkit';
|
||||
import { getEnsName } from '@wagmi/core';
|
||||
import { ChainNamespace } from '@reown/appkit-common';
|
||||
import { config } from './appkit';
|
||||
import { Provider} from '@reown/appkit-controllers';
|
||||
|
||||
export interface WalletInfo {
|
||||
address: string;
|
||||
walletType: 'bitcoin' | 'ethereum';
|
||||
ensName?: string;
|
||||
isConnected: boolean;
|
||||
}
|
||||
|
||||
export class ReOwnWalletService {
|
||||
private keyDelegation: KeyDelegation;
|
||||
private bitcoinAccount?: UseAppKitAccountReturn;
|
||||
@ -207,4 +216,40 @@ export class ReOwnWalletService {
|
||||
clearDelegation(walletType: 'bitcoin' | 'ethereum'): void {
|
||||
this.keyDelegation.clearDelegation();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get wallet connection info with ENS resolution for Ethereum
|
||||
*/
|
||||
async getWalletInfo(): Promise<WalletInfo | null> {
|
||||
if (this.bitcoinAccount?.isConnected) {
|
||||
return {
|
||||
address: this.bitcoinAccount.address,
|
||||
walletType: 'bitcoin',
|
||||
isConnected: true
|
||||
};
|
||||
} else if (this.ethereumAccount?.isConnected) {
|
||||
// Use Wagmi to resolve ENS name
|
||||
let ensName: string | undefined;
|
||||
try {
|
||||
const resolvedName = await getEnsName(config, {
|
||||
address: this.ethereumAccount.address as `0x${string}`
|
||||
});
|
||||
ensName = resolvedName || undefined;
|
||||
} catch (error) {
|
||||
console.warn('Failed to resolve ENS name:', error);
|
||||
// Continue without ENS name
|
||||
}
|
||||
|
||||
return {
|
||||
address: this.ethereumAccount.address,
|
||||
walletType: 'ethereum',
|
||||
ensName,
|
||||
isConnected: true
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user