refactor(dapp-v2): use existing onSessionConnected
handler for session_updated
This commit is contained in:
parent
6eec915a46
commit
1998be6295
@ -173,7 +173,8 @@ export function ClientContextProvider({ children }: { children: ReactNode | Reac
|
||||
});
|
||||
}, [client, session]);
|
||||
|
||||
const _subscribeToEvents = useCallback(async (_client: Client) => {
|
||||
const _subscribeToEvents = useCallback(
|
||||
async (_client: Client) => {
|
||||
if (typeof _client === "undefined") {
|
||||
throw new Error("WalletConnect is not initialized");
|
||||
}
|
||||
@ -192,15 +193,16 @@ export function ClientContextProvider({ children }: { children: ReactNode | Reac
|
||||
|
||||
_client.on(CLIENT_EVENTS.session.updated, (updatedSession: SessionTypes.Settled) => {
|
||||
console.log("EVENT", "session_updated");
|
||||
setChains(updatedSession.permissions.blockchain.chains);
|
||||
setAccounts(updatedSession.state.accounts);
|
||||
onSessionConnected(updatedSession);
|
||||
});
|
||||
|
||||
_client.on(CLIENT_EVENTS.session.deleted, () => {
|
||||
console.log("EVENT", "session_deleted");
|
||||
resetApp();
|
||||
});
|
||||
}, []);
|
||||
},
|
||||
[onSessionConnected],
|
||||
);
|
||||
|
||||
const _checkPersistedState = useCallback(
|
||||
async (_client: Client) => {
|
||||
|
Loading…
Reference in New Issue
Block a user