Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v5.9.0 WebGL Android Mobile Browser - Connect Feature - window.ethereum is undefined causing Metamask Deeplink Not Working #219

Open
quurkyhongyu opened this issue Nov 13, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@quurkyhongyu
Copy link

The window.ethereum is undefined on mobile browser, therefore before the Connect try to switch ethereum chain, it failed to get the instance and return false

The code below is from MetaMaskWallet.cs & WebGLMetaMask.jslib, I believe the jslib function below to check the wallet was existed or not in browser. But I think it is not for case like webgl mobile browser;

// MetaMaskWallet.cs
if (metaMaskInstance.IsMetaMaskAvailable())
{
    // switch to ethereum network...
}
else
{
    throw new Exception("MetaMask is not available.");
}
// WebGLMetaMask.cs
public async Task<T> RequestAsync<T>(RpcRequest rpcRequest)
{
    var rpcRequestMessage = JsonConvert.SerializeObject(rpcRequest);
    _rpcResponseCompletionSource = new TaskCompletionSource<string>();
    
#if UNITY_WEBGL && !UNITY_EDITOR
    Request(rpcRequestMessage, gameObject.name, nameof(OnRequestCallback), nameof(OnRequestFallback));
#endif

    var response = await _rpcResponseCompletionSource.Task;
    var rpcResponseRaw = JsonConvert.DeserializeObject<RpcResponse<T>>(response);
    if (rpcResponseRaw.Error != null)
    {
        throw new Exception(rpcResponseRaw.Error.Message);
    }
    return rpcResponseRaw.Result;
}
// WebGLMetaMask.jslib
IsMetamaskAvailable: function () {
  return window.ethereum ? true : false;
}
@warengonzaga
Copy link
Member

Hello @quurkyhongyu, we received your ticket, and I'm tagging @0xFirekeeper for an extra eye and explanation about this. However, we recommend using native builds for mobile instead of using WebGL for your mobile app, as this is a known issue.

@0xFirekeeper 0xFirekeeper added the enhancement New feature or request label Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants