AccountAbstraction Provider + Wagmi connector

Hey!
I try to run abstraction account wallet with social login and wagmi.
I use

Everything works but when I try to login (Google) for the first time I get only EOA wallet address from web3auth. After page refreshing it becomes possible to get smart account address too.
What am I doing wrong ?

here is my code

import { CHAIN_NAMESPACES, WEB3AUTH_NETWORK } from '@web3auth/base';
import { EthereumPrivateKeyProvider } from '@web3auth/ethereum-provider';
import { Web3AuthNoModal } from '@web3auth/no-modal';
import { AuthAdapter } from '@web3auth/auth-adapter';

import { entryPoint06Address } from 'viem/account-abstraction';
import {
  AccountAbstractionProvider,
  KernelSmartAccount
} from '@web3auth/account-abstraction-provider';

const clientId =
  '...';
const chainConfig = {
  chainNamespace: CHAIN_NAMESPACES.EIP155,
  chainId: '0x1',
  rpcTarget: 'https://rpc.ankr.com/eth',
  displayName: 'Ethereum Mainnet',
  blockExplorerUrl: 'https://etherscan.io',
  ticker: 'ETH',
  tickerName: 'Ethereum',
  logo: 'https://cryptologos.cc/logos/ethereum-eth-logo.png'
};

const accountAbstractionProvider = new AccountAbstractionProvider({
  config: {
    chainConfig,
    smartAccountInit: new KernelSmartAccount({
      entryPoint: {
        address: entryPoint06Address,
        version: '0.6'
      },
      version: '0.2.2'
    }),
    bundlerConfig: {
      url: `https://rpc.zerodev.app/api/v2/bundler/...`
    },
    paymasterConfig: {
      url: 'https://rpc.zerodev.app/api/v2/paymaster/...'
    }
  }
});

const privateKeyProvider = new EthereumPrivateKeyProvider({
  config: { chainConfig }
});

export const web3auth = new Web3AuthNoModal({
  clientId,
  web3AuthNetwork: WEB3AUTH_NETWORK.SAPPHIRE_MAINNET,
  accountAbstractionProvider,
  privateKeyProvider,
  enableLogging: true,
  useAAWithExternalWallet: false
});

const authadapter = new AuthAdapter({
  adapterSettings: {
    loginConfig: {
      google: {
        verifier: 'google',
        typeOfLogin: 'google',
        clientId: '...'
      },
      twitter: {
        verifier: 'twitter',
        typeOfLogin: 'twitter',
        clientId: '...'
      },
      discord: {
        verifier: 'discord-verifier',
        typeOfLogin: 'discord',
        clientId: '...
      }
    }
  }
});

web3auth.configureAdapter(authadapter);

// wagmi config
export const wagmiConfig = createConfig({
  chains: [mainnet, bsc, polygon, arbitrum, optimism, avalanche, base],
  connectors: [
    metaMask(),
    injected(),
    walletConnect({
      projectId: '...',
      qrModalOptions: {
        themeMode: 'light'
      }
    }),
    Web3AuthConnector({
      web3AuthInstance: web3auth,
      name: 'Google',
      id: 'google',
      loginParams: {
        loginProvider: 'google'
      }
    }),
    Web3AuthConnector({
      web3AuthInstance: web3auth,
      name: 'Twitter',
      id: 'twitter',
      loginParams: {
        loginProvider: 'twitter'
      }
    }),
    Web3AuthConnector({
      web3AuthInstance: web3auth,
      name: 'Discord',
      id: 'discord',
      loginParams: {
        loginProvider: 'discord'
      }
    })
  ],
  transports: {
    [mainnet.id]: http(),
    [bsc.id]: http(),
    [polygon.id]: http(),
    [arbitrum.id]: http(),
    [optimism.id]: http(),
    [avalanche.id]: http(),
    [base.id]: http()
  }
});

Console after the first connecting

success data - is from onSuccess handler

import { useConnect } from 'wagmi';

const {connect} = useConnect();

connect(params, {
      onSuccess: (data) => {
        console.log('success data: ', data);
      }
    });

addresses

    const walletClient = createWalletClient({
      transport: custom(web3auth.provider)
    });
    const addresses = await walletClient.getAddresses();

Hello! Thank you for reaching out with your issue regarding the AccountAbstraction Provider and Wagmi connector.

Based on the details you’ve shared, here’s a summary for our support team:

  • SDK Details: Help - Plug n Play
  • SDK Version: Not explicitly mentioned, please verify if you have a specific version in mind.
  • Platform: Not specified, please confirm if applicable.
  • Issue Faced: When logging in with Google for the first time, an EOA wallet address is returned. After a page refresh, it switches to a smart account address.

Suggested Actions

It may be helpful to ensure that you are handling the asynchronous setup properly, especially since the smart account address appears only after a refresh.

Would you be able to provide:

  • Any relevant browser console screenshots to check for errors.
  • Code snippets related specifically to the Web3Auth initialization and login process, if different from the ones shared.

These will help us better understand the issue you are facing! Looking forward to your response.

Note: This response was generated by an AI bot and may require further verification. The Web3Auth support team has tracked this issue and will be responding as soon as possible.

Hey, thanks for the details. I’ll try to reproduce the issue and get back to you.

I tried to reproduce the issue but it’s working fine for me, is it possible for you to host it on Github repo so we can have a look?