From 983c62f8657257c2f77d90891245eed9f257fdb5 Mon Sep 17 00:00:00 2001 From: Ivan Grachyov Date: Sat, 10 Jul 2021 18:49:43 +0300 Subject: [PATCH] Alpha reconnecting to WC --- Encrypted Ink/WalletConnect.swift | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Encrypted Ink/WalletConnect.swift b/Encrypted Ink/WalletConnect.swift index 5f2d203c..b1c124b0 100644 --- a/Encrypted Ink/WalletConnect.swift +++ b/Encrypted Ink/WalletConnect.swift @@ -57,11 +57,17 @@ class WalletConnect { if let id = interactor?.clientId { self?.peers[id] = peer } + if let session = interactor?.session { + WCSessionStore.store(session, peerId: peerParam.peerId, peerMeta: peer) + // TODO: store session if it is not already stored + } interactor?.approveSession(accounts: accounts, chainId: chainId).cauterize() } - interactor.onDisconnect = { _ in - // TODO: reconnect when appropriate. should not reconnect when session is killed. + interactor.onDisconnect = { [weak interactor] _ in + DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(10)) { + interactor?.resume() // TODO: reconnect when appropriate. should not reconnect when session is killed. + } } interactor.eth.onSign = { [weak self, weak interactor] (id, payload) in