Skip to content
This repository was archived by the owner on May 2, 2023. It is now read-only.

Commit 3fdc3fe

Browse files
authored
Merge pull request #5 from Ankr-network/Fix-WalletConnect-Instance-Issue
Update ConnectionController.cs
2 parents 8cd55e1 + ae4573f commit 3fdc3fe

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

Assets/AnkrSDK/Examples/Scripts/ConnectionController.cs

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ private void UpdateSceneState(WCSessionData _ = null)
5353

5454
private async UniTaskVoid TrySubscribeToWalletEvents()
5555
{
56-
if (WalletConnect.Instance == null)
56+
if (WalletConnect.ActiveSession == null)
5757
{
5858
Debug.Log("Wallet Connect Instance is null waiting.");
59-
await UniTask.WaitWhile(() => WalletConnect.Instance == null);
59+
await UniTask.WaitWhile(() => WalletConnect.ActiveSession == null);
6060
}
6161

6262
_loginButton.onClick.AddListener(GetLoginAction());
@@ -72,23 +72,30 @@ private static UnityAction GetLoginAction()
7272
#else
7373
private UnityAction GetLoginAction()
7474
{
75-
var connectURL = WalletConnect.Instance.ConnectURL;
7675
if (_qrCodeImage != null)
7776
{
78-
return () =>
79-
{
80-
_qrCodeImage.UpdateQRCode(connectURL);
81-
_qrCodeImage.SetImageActive(true);
82-
};
77+
return QrLogicAction;
8378
}
8479

85-
return () => Debug.Log($"Trying to open {connectURL}");
80+
return DefaultLoginAction;
81+
}
82+
83+
private void QrLogicAction()
84+
{
85+
var connectURL = WalletConnect.Instance.ConnectURL;
86+
_qrCodeImage.UpdateQRCode(connectURL);
87+
_qrCodeImage.SetImageActive(true);
88+
}
89+
90+
private static void DefaultLoginAction()
91+
{
92+
var connectURL = WalletConnect.Instance.ConnectURL;
93+
Debug.Log($"Trying to open {connectURL}");
8694
}
8795
#endif
8896

8997
private void SubscribeOnTransportEvents()
9098
{
91-
UpdateSceneState();
9299
UpdateLoginButtonState(this, WalletConnect.ActiveSession);
93100

94101
WalletConnect.Instance.ConnectedEvent.AddListener(UpdateSceneState);

0 commit comments

Comments
 (0)