TypeError: Cannot read properties of undefined (reading 'setKeyExportFlag')

Error Details

Error Type: TypeError

Error Message: Cannot read properties of undefined (reading ‘setKeyExportFlag’)

Description

An error occurred when attempting to set web3auth no modal init

Steps to Reproduce

  1. [Need more information]

Expected Behavior

[Need more information]

Actual Behavior

The application throws a TypeError, indicating that it’s attempting to access a property of an undefined object.

Possible Causes

  1. The object containing setKeyExportFlag may not have been properly initialized.
  2. There might be a race condition where the object is being accessed before it’s fully defined.
  3. The object might have been accidentally overwritten or set to undefined elsewhere in the code.

Suggested Next Steps

  1. Identify the specific line of code where this error is occurring.
  2. Check the object’s initialization and ensure it’s properly defined before setKeyExportFlag is called.
  3. Use debugging tools to trace the object’s state leading up to the error.
  4. Implement null checks before accessing setKeyExportFlag.

Additional Context

js```

const chainConfig = {
chainNamespace: CHAIN_NAMESPACES.EIP155,
chainId: ‘0x’ + activeChain.id.toString(16),
rpcTarget: https://base-${dev ? 'sepolia' : 'mainnet'}.g.alchemy.com/v2/${PUBLIC_ALCHEMY_KEY},
tickerName: activeChain.nativeCurrency?.name,
displayName: activeChain.name,
ticker: activeChain.nativeCurrency?.symbol,
blockExplorer: activeChain?.blockExplorers.default?.url as string
};

		const web3AuthNoModal = new Web3AuthNoModal({
			clientId: PUBLIC_WEB3AUTH_ID,
			chainConfig,
			web3AuthNetwork: dev ? 'sapphire_devnet' : 'sapphire_mainnet',
			sessionTime: 86400 * 7
		});
	
	const ethereumPrivateKeyProvider = new EthereumPrivateKeyProvider({ config: { chainConfig } });
		const openloginAdapter = new AuthAdapter({
			privateKeyProvider: ethereumPrivateKeyProvider,
			loginSettings: {
				mfaLevel: 'none'
			},
			adapterSettings: {
				uxMode: 'redirect',
				network: dev ? 'sapphire_devnet' : 'sapphire_mainnet',
				whiteLabel: {
					appName: 'rip.fun',
					defaultLanguage: 'en',
					mode: 'dark'
				}
			}
		});
	
		web3AuthNoModal.configureAdapter(openloginAdapter);

Hi Joseph! Let’s see if we can get to the bottom of this. Based on your description, it sounds like the issue might be related to the initialization of the web3AuthNoModal object or its configuration.

Here are a few suggestions:

  1. Initialization Check: Ensure that all required dependencies and objects, especially web3AuthNoModal, are properly initialized before calling setKeyExportFlag.

  2. Order of Operations: Make sure that configureAdapter is called after proper initialization and setup of web3AuthNoModal.

  3. Adapter Configuration: Verify that openloginAdapter is correctly set up and all its dependencies are in place.

  4. Null Checks: Consider adding checks to confirm objects are not undefined before accessing their properties.

To assist further, could you provide:

  • Details on the version of the SDK you’re using.
  • Any relevant browser console screenshots showing the error.

This information will help narrow down the root cause. Thanks for reaching out, and we’ll make sure someone from the Web3Auth team responds to your inquiry shortly!

This response was generated by the Web3Auth Bot, and a support team member will follow up with more help.

Hey @joseph2
I might need more logs to understand where is this issue originating from. Can you please submit a recording via a tool like jam.dev?

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