Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@ public static void CleanUp()
/// Open the Login UI Boilerplate from a Prefab inside the Resources folder.
/// </summary>
/// <param name="parent">Transform inside of a Canvas object.</param>
/// <param name="wallet">Wallet to use for account federation.</param>
/// <param name="onClose">(Optional) Callback when the user closes this window or when an account was successfully federated.</param>
/// <returns></returns>
public static SequenceLoginWindow OpenSequenceLoginWindow(Transform parent, Action onClose = null)
public static SequenceLoginWindow OpenSequenceLoginWindow(Transform parent, IWallet wallet = null, Action onClose = null)
{
return GetOrSpawnBoilerplate<SequenceLoginWindow>("Login/SequenceLoginWindow", parent,
b => b.Show(onClose));
b => b.Show(wallet, onClose));
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class SequenceLoginWindow : MonoBehaviour
[SerializeField] private MessagePopup _messagePopup;
[SerializeField] private GameObject[] _socialTexts;

private IWallet _wallet;
private Action _onClose;
private SequenceLogin _loginHandler;
private string _curEmail;
Expand Down Expand Up @@ -65,8 +66,9 @@ public void Hide()
/// <summary>
/// Required function to configure this Boilerplate.
/// </summary>
public void Show(Action onClose = null)
public void Show(IWallet wallet = null, Action onClose = null)
{
_wallet = wallet;
_onClose = onClose;
if (_loginHandler == null)
{
Expand All @@ -75,8 +77,11 @@ public void Show(Action onClose = null)
_loginHandler.OnLoginFailed += LoginHandlerOnOnLoginFailed;
_loginHandler.OnMFAEmailSent += LoginHandlerOnOnMFAEmailSent;
}

if (wallet != null)
_loginHandler.SetConnectedWalletAddress(wallet.GetWalletAddress());

var isFederating = _loginHandler.HasConnectedWalletAddress();
var isFederating = _wallet != null;
_closeButton.gameObject.SetActive(isFederating);
_guestLoginButton.gameObject.SetActive(!isFederating);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public async void SignOut()
public void OpenLoginWindowForFederation()
{
gameObject.SetActive(false);
BoilerplateFactory.OpenSequenceLoginWindow(transform.parent,
BoilerplateFactory.OpenSequenceLoginWindow(transform.parent, _wallet,
() => gameObject.SetActive(true));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,6 @@ public void SetConnectedWalletAddress(Address connectedWalletAddress)
_connectedWalletAddress = connectedWalletAddress;
}

public bool HasConnectedWalletAddress()
{
return _connectedWalletAddress != null;
}

[Obsolete("Use GetInstance() instead.")]
public SequenceLogin(IValidator validator = null, IAuthenticator authenticator = null, IWaaSConnector connector = null, bool automaticallyFederateAccountsWhenPossible = true, Address connectedWalletAddress = null)
{
Expand Down Expand Up @@ -134,7 +129,7 @@ public void ResetLoginAfterTest()
public void SetupAuthenticator(IValidator validator = null, IAuthenticator authenticator = null)
{
ConfigJwt configJwt = SequenceConfig.GetConfigJwt(SequenceConfig.GetConfig(SequenceService.WaaS));
if (_connectedWalletAddress == null || _sessionWallet == null)
if (_sessionWallet == null)
{
_sessionWallet = new EOAWallet();
}
Expand Down Expand Up @@ -241,7 +236,6 @@ private void TryToLoginWithStoredSessionWallet()

_sessionWallet = walletInfo.Item1;
_sessionId = IntentDataOpenSession.CreateSessionId(_sessionWallet.GetAddress());
SetConnectedWalletAddress(new Address(walletInfo.Item2));

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

Expand All @@ -251,7 +245,6 @@ private void TryToLoginWithStoredSessionWallet()
private void FailedLoginWithStoredSessionWallet(string error)
{
CreateWallet();
SetConnectedWalletAddress(null);
SequenceWallet.OnFailedToRecoverSession?.Invoke(error);
}

Expand Down Expand Up @@ -389,7 +382,6 @@ public async Task ConnectToWaaS(IntentDataOpenSession loginIntent, LoginMethod m
string sessionId = registerSessionResponse.sessionId;
walletAddress = registerSessionResponse.wallet;
OnLoginSuccess?.Invoke(sessionId, walletAddress);
SetConnectedWalletAddress(new Address(walletAddress));
SequenceWallet wallet = new SequenceWallet(new Address(walletAddress), sessionId, new IntentSender(new HttpClient(SequenceLogin.WaaSWithAuthUrl), _sessionWallet, sessionId, _waasProjectId, _waasVersion), email);
PlayerPrefs.SetInt(WaaSLoginMethod, (int)method);
PlayerPrefs.SetString(OpenIdAuthenticator.LoginEmail, email);
Expand Down
Loading