Using wagmi-web3auth-connector, setting "autoconnect" to true results in error

I am trying to use the no-modal SDK to connect through email, google, apple, twitter, facebook.
The login works but after the redirect, wagmi cannot reconnect using autoconnect:true.
The web3AuthConnector seems to have lost the loginParams context.

How to connect using the no-modal SDK and persist login after redirect?

  const chainConfig = {
    chainNamespace: CHAIN_NAMESPACES.EIP155,
    chainId: '0x' + chains[0].id.toString(16),
    rpcTarget: chains[0].rpcUrls.default.http[0],
    displayName: chains[0].name,
    tickerName: chains[0].nativeCurrency?.name,
    ticker: chains[0].nativeCurrency?.symbol,
    blockExplorer: chains[0]?.blockExplorers?.default.url ?? chains[0].rpcUrls.default.http[0],
  };

  const web3AuthInstance = new Web3AuthNoModal({
    clientId: environment.web3AuthClientId,
    web3AuthNetwork: OPENLOGIN_NETWORK.CYAN,
    storageKey: 'local',
    chainConfig,
    enableLogging: false,
  });

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

  web3AuthInstance.configureAdapter(
    new OpenloginAdapter({
      adapterSettings: {
        uxMode: 'redirect',
        replaceUrlOnRedirect: false,
      },
      loginSettings: {
        mfaLevel: 'none', // Testnet
      },
      privateKeyProvider,
    }),
  );

const web3AuthConnector = new Web3AuthConnector({
          chains,
          options: {
            web3AuthInstance: getWeb3AuthInstance(chains),
          },
});

  const connectWithWeb3Auth = (loginParams: OpenloginLoginParams) => {
    // @ts-ignore
    web3AuthConnector.loginParams = loginParams;
    web3AuthConnector.options.loginParams = loginParams;

    connect({
      connector: web3AuthConnector,
    });
  }

@afarley Thanks for your recent post.

Your request has been forwarded to our Dev team and we will get back with further updates.

Hey, any news on this?

hi @afarley,

Please check the new updates in the wagmi example: https://github.com/Web3Auth/web3auth-pnp-examples/tree/main/web-no-modal-sdk/wagmi/wagmi-no-modal-example

We are using updated libraries

    "@web3auth/base": "^8.0.0",
    "@web3auth/ethereum-provider": "^8.0.1",
    "@web3auth/no-modal": "^8.0.1",
    "@web3auth/openlogin-adapter": "^8.0.1",
    "@web3auth/wallet-services-plugin": "^8.0.1",
    "@web3auth/web3auth-wagmi-connector": "^6.0.0",

Also please check the wagmi documentation:

  • Removed autoConnect. The reconnecting behavior must be managed manually and is not related to the Wagmi Config. Use the reconnect action instead.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.