Closed alsakhaev closed 1 year ago
Hey @alsakhaev, we've just created a PR to reuse the existing session. After that merge, the session will load automatically
@alsakhaev we released a new alpha version that reuses the existing session automatically 💪 Closing the issue.
This still doesn't work for me. provider is undefined until the open function is called.
Hey @taibenvenuti 👋 are you using the last version of the SDK? Can you upload the piece of code where you render the Web3Modal
component?
Yes I updated to alpha3
import './expo-crypto-shim.js';
import '@walletconnect/react-native-compat';
import '@ethersproject/shims';
import { ThemeProvider } from './src/styles/ThemeContext';
import { Navigation } from './src/navigation/Navigation';
import { Provider } from 'react-redux';
import { persistor, store } from './src/store/store';
import { PersistGate } from 'redux-persist/integration/react';
import { AuthenticationProvider } from './src/services/AuthenticationContext';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import { Web3Modal } from '@web3modal/react-native';
import { PROJECT_ID } from '@env';
import { AssetsProvider } from './src/services/AssetsContext';
import { providerMetadata } from './src/Config';
export default function App() {
return (
<Provider store={store}>
<Web3Modal projectId={PROJECT_ID} providerMetadata={providerMetadata} />
<PersistGate loading={null} persistor={persistor}>
<ThemeProvider>
<AuthenticationProvider>
<AssetsProvider>
<SafeAreaProvider style={{ margin: 0 }}>
<Navigation />
</SafeAreaProvider>
</AssetsProvider>
</AuthenticationProvider>
</ThemeProvider>
</PersistGate>
</Provider>
);
}
@taibenvenuti When <Web3Modal />
renders, it initializes the provider and automatically restores the connection with the wallet (if exists).
If you didn't connect with a wallet before, when you open the modal a new session is created but it wont be saved unless you actually connect with a wallet.
Hi @ignaciosantise question: do we have option to not to store/persist the session or our only option is to disconnect manually visa provider?.disconnect()
? We don't want to persist isConnected/address
or other variables on the app startup.
We are initializing the modal with following versions and method:
"@walletconnect/modal-react-native": "^1.1.0",
"@walletconnect/react-native-compat": "^2.15.0",
export const ProviderMetadata: IProviderMetadata = {
name: 'Brand',
description: 'Connect your wallet',
url: 'https://your-project-website.com/',
icons: ['https://your-project-logo.com/'],
redirect: {
native: `namespace://`
}
};
//
const { open, isConnected, provider, address } = useWalletConnectModal();
//
<WalletConnectModal projectId={projectId} providerMetadata={ProviderMetadata} />
hey @ozgurrgul 👋 the SDK restores the active session automatically. So if you want to remove a session you need to call disconnect, as it will also notify the wallet to disconnect on their side too.
Cleaning values without calling disconnect might leave the connection open, so i recommend not doing that
After app reloading I have to connect a wallet again. The
provider
property from the hook is null until I call theopen()
function. After calling (the modal is shown, but I didn't select a wallet yet) I see thatprovider.session
exists and there is info about my wallet, butisConnected
is still false. I'd like to understand how to reuse the previous connection to the wallet.