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

QR Image Not Loading #6

Open
WoodsFiend opened this issue Jun 14, 2024 · 13 comments
Open

QR Image Not Loading #6

WoodsFiend opened this issue Jun 14, 2024 · 13 comments
Labels
bug Something isn't working

Comments

@WoodsFiend
Copy link

After setting up Web3Modal by following the documentation, no QR codes are loading for me to scan when testing in the editor.

Unity Version: 2022.3.11f1
Web3Modal Version: 0.3.1

image
image

There doesn't seem to be any errors and the logs seem to indicate I established a connection.
Connector.Connect UnityEngine.Debug:Log (object) WalletConnect.Web3Modal.Connector:Connect () (at ./Library/PackageCache/[email protected]/Runtime/Connectors/Connector.cs:62)

Got connection UnityEngine.Debug:Log (object) WalletConnect.Web3Modal.Connector:Connect () (at ./Library/PackageCache/[email protected]/Runtime/Connectors/Connector.cs:68)

@skibitsky
Copy link
Member

Hello,

It appears the app did not receive a response from the WalletConnect relay. Could you please answer a few questions to help me better understand the situation?

  1. What's your operating system?
  2. Do you have VPN/Proxy enabled?
  3. Can you access https://walletconnect.com/ in your browser without VPN/Proxy in your network?
  4. Have you tried connecting on another network?
  5. What target platform is selected in the build settings?

@WoodsFiend
Copy link
Author

WoodsFiend commented Jun 14, 2024

  1. Windows 10
  2. No VPN/Proxy
  3. Yes I can access walletconnect.com
  4. I tried 2 different Wifi networks that I have
  5. Build settings are for Windows (Intel 64-bit Architecture)

I found more logs when I enabled logging in the config, this comes after the logs I sent above. (I removed the params in-case my app id is in there)
[Relayer] Checking for established connection
[Relayer] Sending request through provider
[JsonRpcProvider] Checking if connected
[JsonRpcProvider] Sending request irn_subscribe with data {"method":"irn_subscribe","params":{}
[Relayer] Checking for established connection
[Relayer] Sending request through provider
[JsonRpcProvider] Checking if connected
[JsonRpcProvider] Sending request irn_publish with data {"method":"irn_publish","params":{}

Sometimes if I try to reload a QR after this I get a couple expired topic logs, then an unsubscribe log:
Expired topic topic:1557bade5ac4527512223d3b6cfdfb09eae1a38ffad2196223153f7ba7dc4c68
Expired topic id:74258315530174
[JsonRpcProvider] Sending request irn_unsubscribe with data {"method":"irn_unsubscribe","params":{}

@WoodsFiend
Copy link
Author

WoodsFiend commented Jun 14, 2024

I just tried a build and it seems to be the same issue, so not just an editor problem.

Though when I ran the build I did notice this warning about an uncompiled Assembly Definition File. This might be the culprit since I think its a barcode library. There doesn't seem to be any scripts alongside the dll.
Assembly for Assembly Definition File 'Packages/com.walletconnect.core/Runtime/External/ZXing/ZXing.asmdef' will not be compiled, because it has no scripts associated with it.

@skibitsky
Copy link
Member

@WoodsFiend thank you providing more information 🙏

It looks like the problem is with the ZXing library used for generating QR code images. I'm looking into it. Meanwhile, can you confirm if the "Copy link" button on the screen where the QR code should appear is working for you? Does it copy the WalletConnect connection URI?

@skibitsky skibitsky added the bug Something isn't working label Jun 17, 2024
@WoodsFiend
Copy link
Author

@skibitsky Yes it does copy the WalletConnect connection URI

@skibitsky
Copy link
Member

Hey @WoodsFiend,

Sorry for the delay. I have fixed the warning in the recent release. Could you please upgrade Web3Modal to v0.3.2 and check if the issue persists?

@mrsaleh
Copy link

mrsaleh commented Jul 26, 2024

I also have this issue.
"com.walletconnect.web3modal": "0.4.1"

@skibitsky
Copy link
Member

@mrsaleh do you use linear or gamma color space?

@mrsaleh
Copy link

mrsaleh commented Jul 26, 2024

@skibitsky Linear color space. I changed it to gamma, still the same issue.

@mrsaleh
Copy link

mrsaleh commented Jul 26, 2024

I just manually generated QRCode , and it worked , I also achieved to connect my trust wallet by scanning the QRCode. So I'm pretty sure QRCode generation is the issue.

`[SerializeField]
private Image _qrCode;

private static Color32[] Encode(string textForEncoding, int width, int height) {
    var writer = new BarcodeWriter {
        Format = BarcodeFormat.QR_CODE,
        Options = new QrCodeEncodingOptions {
        Height = height,
        Width = width
        }
    };
    return writer.Write(textForEncoding);
}

public Texture2D generateQR(string text) {
    var encoded = new Texture2D (256, 256);
    var color32 = Encode(text, encoded.width, encoded.height);
    encoded.SetPixels32(color32);
    encoded.Apply();
    return encoded;
}


public async UniTask Start(){
    // Initialize singleton

    
    await WalletConnectUnity.Core.WalletConnect.Instance.InitializeAsync();

    // Or handle instancing manually
    var walletConnectUnity = new WalletConnectUnity.Core.WalletConnect();
    await walletConnectUnity.InitializeAsync();


    var dappConnectOptions = new ConnectOptions()
    {
        RequiredNamespaces = new RequiredNamespaces().WithProposedNamespace("eip155", new ProposedNamespace(){
                    Methods = new[]
                    {
                        "eth_sendTransaction",
                        "eth_signTransaction",
                        "eth_sign",
                        "personal_sign",
                        "eth_signTypedData",
                    },
                    Chains = new[]
                    {
                        "eip155:1"
                    },
                    Events = new[]
                    {
                        "chainChanged",
                        "accountsChanged",
                    }
        })
    };
    // Try resume last session
    var sessionResumed = await WalletConnectUnity.Core.WalletConnect.Instance.TryResumeSessionAsync();              
    if (!sessionResumed)                                                                         
    {                                                                                            
        var connectedData = await WalletConnectUnity.Core.WalletConnect.Instance.ConnectAsync(dappConnectOptions);

        Debug.Log("Generating qr code!");
        // Create QR code texture
        // var texture = WalletConnectUnity.Core.Utils.QRCode.EncodeTexture(connectedData.Uri);    
        Debug.Log(connectedData.Uri);
        Texture2D texture = generateQR(connectedData.Uri);

        Debug.Log("QR code generated!");
        Debug.Log(texture);
        _qrCode.sprite = Sprite.Create(texture,new Rect(0,0,texture.width,texture.height),new Vector2(0.5f,0.5f));
        // ... Display QR code texture
        
        // Wait for wallet approval
        var res = await connectedData.Approval;  
        Debug.Log($"wallet address: {res.Self.PublicKey}");
        
    }else{
        var res = WalletConnectUnity.Core.WalletConnect.Instance.ActiveSession;
        Debug.Log($"wallet address: {res.Self.PublicKey}");
        
        Debug.Log($"wallet address: {res.CurrentAddress("eip155:1").Address}");            
    }
}`

@mrsaleh
Copy link

mrsaleh commented Jul 27, 2024

@skibitsky I opened a pull request for this #16

Apparently it was the QRCode generator library issue. I will also report the issue to the library repository. Maybe in the future we can get back to higher resolution.

@skibitsky
Copy link
Member

Hey @mrsaleh,

Thank you for this!

Could you please provide more details about your issue?

  1. What operating system are you using?
  2. On which platform does the issue occur (e.g., Editor, Windows 11 Mono, Android 14 IL2CPP, etc.)?
  3. Are there any exceptions or error messages logged?

@skibitsky
Copy link
Member

Hey @mrsaleh @WoodsFiend,

Could you please upgrade to v0.4.2 and check if that solves the issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants