- SDK Version: 6.0.0
- Platform: React Native (Android nd IOS)
Hi,
Im using web3auth in my dapp. Im able to successfully login and able to use the functionalities. Im too able to successfully logout as well. But after logout when I try to login the sdk throws error [TypeError: Attempting to change value of a readonly property.] .
I have tried the same in the example provided in the doc, Im getting Property is not writable in the console.
example link: Github
LOGIN_PROVIDER in both the cases are social methods like GOOGLE/APPLE etc.
Web3Auth.tsx
const redirectUrl = REDIRECT_URL;
const chainConfig = {
chainNamespace: ChainNamespace.EIP155,
chainId: '0x1',
rpcTarget: RPC_URL_1,
displayName: 'Ethereum Main Network',
blockExplorerUrl: 'https://etherscan.io',
ticker: 'ETH',
tickerName: 'Ethereum',
decimals: 18,
logo: 'https://cryptologos.cc/logos/ethereum-eth-logo.png',
};
const clientId = WEB3AUTH_CLIENT_ID;
export const ethereumPrivateKeyProvider = new EthereumPrivateKeyProvider({
config: {
chainConfig,
networks,
},
});
export const web3auth = new Web3Auth(WebBrowser, EncryptedStorage, {
redirectUrl,
network: OPENLOGIN_NETWORK.SAPPHIRE_MAINNET,
clientId,
});
export default function Web3AuthComponent() {
const init = useCallback(async () => {
await web3auth.init();
if (web3auth.privKey) {
await ethereumPrivateKeyProvider.setupProvider(web3auth.privKey);
const ethersProvider = new ethers.providers.Web3Provider(
ethereumPrivateKeyProvider,
);
ethereumPrivateKeyProvider.addChain(networks.Ethereum);
ethereumPrivateKeyProvider.addChain(networks.Arbitrum);
ethereumPrivateKeyProvider.addChain(networks.BNB_Smart_Chain);
ethereumPrivateKeyProvider.addChain(networks.Polygon);
const signer = ethersProvider.getSigner();
const address = await signer.getAddress();
const chainId = await signer.getChainId();
const __wallet: Wallet = {
address,
chainId,
provider: ethereumPrivateKeyProvider,
};
addWallet(__wallet);
}
}, [addWallet]);
useEffect(() => {
init();
}, [init]);
return (
<View>
{/* other UI codes */}
</View>
)
}
// Login code // used in other components or hooks
if (!web3auth.ready) {
return;
}
await web3auth.login({
loginProvider: loginProvider,
});
// Logout code
if (web3auth.privKey) {
await web3auth.logout();
}