@nasirs, @SamR, @vivraan, @cuongnm, @jlourie, @YosephKS, @enoonmai, @K00N
I had to release a critical update this afternoon. Authentication now requires server Time be included in the message being signed.
The change was made in the MainMenuScript.cs file of the Demo
public async void WalletConnectHandler(WCSessionData data)
{
Debug.Log("Wallet connection received");
// Extract wallet address from the Wallet Connect Session data object.
string address = data.accounts[0].ToLower();
string appId = MoralisInterface.GetClient().ApplicationId;
long serverTime = 0;
// Retrieve server time from Moralis Server for message signature
Dictionary<string, object> serverTimeResponse = await MoralisInterface.GetClient().Cloud.RunAsync<Dictionary<string, object>>("getServerTime", new Dictionary<string, object>());
if (serverTimeResponse == null || !serverTimeResponse.ContainsKey("dateTime") ||
!long.TryParse(serverTimeResponse["dateTime"].ToString(), out serverTime))
{
Debug.Log("Failed to retrieve server time from Moralis Server!");
}
Debug.Log($"Sending sign request for {address} ...");
string signMessage = $"Moralis Authentication\n\nId: {appId}:{serverTime}";
string response = await walletConnect.Session.EthPersonalSign(address, signMessage);
Debug.Log($"Signature {response} for {address} was returned.");
// Create moralis auth data from message signing response.
Dictionary<string, object> authData = new Dictionary<string, object> { { "id", address }, { "signature", response }, { "data", signMessage } };
Debug.Log("Logging in user.");
// Attempt to login user.
MoralisUser user = await MoralisInterface.LogInAsync(authData);
if (user != null)
{
Debug.Log($"User {user.username} logged in successfully. ");
}
else
{
Debug.Log("User login failed.");
}
HideWalletSelection();
}
The newest release (v1.0.5) has this patch.