Skip to content

Commit 71cf87c

Browse files
authored
variation to federation issue (#281)
1 parent 867694b commit 71cf87c

File tree

4 files changed

+12
-14
lines changed

4 files changed

+12
-14
lines changed

Packages/Sequence-Unity/Sequence/SequenceFrontend/Scripts/UI/Boilerplates/BoilerplateFactory.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,13 @@ public static void CleanUp()
3232
/// Open the Login UI Boilerplate from a Prefab inside the Resources folder.
3333
/// </summary>
3434
/// <param name="parent">Transform inside of a Canvas object.</param>
35+
/// <param name="wallet">Wallet to use for account federation.</param>
3536
/// <param name="onClose">(Optional) Callback when the user closes this window or when an account was successfully federated.</param>
3637
/// <returns></returns>
37-
public static SequenceLoginWindow OpenSequenceLoginWindow(Transform parent, Action onClose = null)
38+
public static SequenceLoginWindow OpenSequenceLoginWindow(Transform parent, IWallet wallet = null, Action onClose = null)
3839
{
3940
return GetOrSpawnBoilerplate<SequenceLoginWindow>("Login/SequenceLoginWindow", parent,
40-
b => b.Show(onClose));
41+
b => b.Show(wallet, onClose));
4142
}
4243

4344
/// <summary>

Packages/Sequence-Unity/Sequence/SequenceFrontend/Scripts/UI/Boilerplates/Login/SequenceLoginWindow.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public class SequenceLoginWindow : MonoBehaviour
2525
[SerializeField] private MessagePopup _messagePopup;
2626
[SerializeField] private GameObject[] _socialTexts;
2727

28+
private IWallet _wallet;
2829
private Action _onClose;
2930
private SequenceLogin _loginHandler;
3031
private string _curEmail;
@@ -65,8 +66,9 @@ public void Hide()
6566
/// <summary>
6667
/// Required function to configure this Boilerplate.
6768
/// </summary>
68-
public void Show(Action onClose = null)
69+
public void Show(IWallet wallet = null, Action onClose = null)
6970
{
71+
_wallet = wallet;
7072
_onClose = onClose;
7173
if (_loginHandler == null)
7274
{
@@ -75,8 +77,11 @@ public void Show(Action onClose = null)
7577
_loginHandler.OnLoginFailed += LoginHandlerOnOnLoginFailed;
7678
_loginHandler.OnMFAEmailSent += LoginHandlerOnOnMFAEmailSent;
7779
}
80+
81+
if (wallet != null)
82+
_loginHandler.SetConnectedWalletAddress(wallet.GetWalletAddress());
7883

79-
var isFederating = _loginHandler.HasConnectedWalletAddress();
84+
var isFederating = _wallet != null;
8085
_closeButton.gameObject.SetActive(isFederating);
8186
_guestLoginButton.gameObject.SetActive(!isFederating);
8287

Packages/Sequence-Unity/Sequence/SequenceFrontend/Scripts/UI/Boilerplates/PlayerProfile/SequencePlayerProfile.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public async void SignOut()
8080
public void OpenLoginWindowForFederation()
8181
{
8282
gameObject.SetActive(false);
83-
BoilerplateFactory.OpenSequenceLoginWindow(transform.parent,
83+
BoilerplateFactory.OpenSequenceLoginWindow(transform.parent, _wallet,
8484
() => gameObject.SetActive(true));
8585
}
8686

Packages/Sequence-Unity/Sequence/SequenceSDK/EmbeddedWallet/SequenceLogin.cs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,6 @@ public void SetConnectedWalletAddress(Address connectedWalletAddress)
7575
_connectedWalletAddress = connectedWalletAddress;
7676
}
7777

78-
public bool HasConnectedWalletAddress()
79-
{
80-
return _connectedWalletAddress != null;
81-
}
82-
8378
[Obsolete("Use GetInstance() instead.")]
8479
public SequenceLogin(IValidator validator = null, IAuthenticator authenticator = null, IWaaSConnector connector = null, bool automaticallyFederateAccountsWhenPossible = true, Address connectedWalletAddress = null)
8580
{
@@ -135,7 +130,7 @@ public void ResetLoginAfterTest()
135130
public void SetupAuthenticator(IValidator validator = null, IAuthenticator authenticator = null)
136131
{
137132
ConfigJwt configJwt = SequenceConfig.GetConfigJwt(SequenceConfig.GetConfig(SequenceService.WaaS));
138-
if (_connectedWalletAddress == null || _sessionWallet == null)
133+
if (_sessionWallet == null)
139134
{
140135
_sessionWallet = new EOAWallet();
141136
}
@@ -242,7 +237,6 @@ private void TryToLoginWithStoredSessionWallet()
242237

243238
_sessionWallet = walletInfo.Item1;
244239
_sessionId = IntentDataOpenSession.CreateSessionId(_sessionWallet.GetAddress());
245-
SetConnectedWalletAddress(new Address(walletInfo.Item2));
246240

247241
SequenceWallet wallet = new SequenceWallet(new Address(walletInfo.Item2), _sessionId, new IntentSender(new HttpClient(WaaSWithAuthUrl), walletInfo.Item1, _sessionId, _waasProjectId, _waasVersion), walletInfo.Item3);
248242

@@ -252,7 +246,6 @@ private void TryToLoginWithStoredSessionWallet()
252246
private void FailedLoginWithStoredSessionWallet(string error)
253247
{
254248
CreateWallet();
255-
SetConnectedWalletAddress(null);
256249
SequenceWallet.OnFailedToRecoverSession?.Invoke(error);
257250
}
258251

@@ -390,7 +383,6 @@ public async Task ConnectToWaaS(IntentDataOpenSession loginIntent, LoginMethod m
390383
string sessionId = registerSessionResponse.sessionId;
391384
walletAddress = registerSessionResponse.wallet;
392385
OnLoginSuccess?.Invoke(sessionId, walletAddress);
393-
SetConnectedWalletAddress(new Address(walletAddress));
394386
SequenceWallet wallet = new SequenceWallet(new Address(walletAddress), sessionId, new IntentSender(new HttpClient(SequenceLogin.WaaSWithAuthUrl), _sessionWallet, sessionId, _waasProjectId, _waasVersion), email);
395387
PlayerPrefs.SetInt(WaaSLoginMethod, (int)method);
396388
PlayerPrefs.SetString(OpenIdAuthenticator.LoginEmail, email);

0 commit comments

Comments
 (0)