-
Notifications
You must be signed in to change notification settings - Fork 6
Description
Description
I am scanning QR code using mobile metamsk for connecting. And then when trying to switch chain on wallet using AppKit.NetworkController.ChangeActiveChainAsync()
then not getting switch chain request at metamask mobile and getting an error on Unity Console
Exception: Failed to send web request: HTTP/1.1 503 Service Unavailable. Url: https://rpc.walletconnect.org/v1/account/0x65ce881f19a3d81ad6be7e7b6d35795571aa148f/balance?projectId=7afe2b7cf56a8d21fb89e343ec308c4e¤cy=usd&chainId=eip155:1328
Reown.AppKit.Unity.Http.UnityHttpClient.GetAsync[T] (System.String path, System.Collections.Generic.IDictionary2[TKey,TValue] parameters, System.Collections.Generic.IDictionary
2[TKey,TValue] headers) (at ./Library/PackageCache/com.reown.appkit.unity@afb2f76865d0/Runtime/Http/UnityHttpClient.cs:142)
Reown.AppKit.Unity.BlockchainApiController.GetBalanceAsync (System.String address) (at ./Library/PackageCache/com.reown.appkit.unity@afb2f76865d0/Runtime/Controllers/BlockchainApiController.cs:63)
Reown.AppKit.Unity.AccountController.UpdateBalance () (at ./Library/PackageCache/com.reown.appkit.unity@afb2f76865d0/Runtime/Controllers/AccountController.cs:199)
Reown.AppKit.Unity.AccountController.ConnectorAccountConnectedHandler (System.Object sender, Reown.AppKit.Unity.Connector+AccountConnectedEventArgs e) (at ./Library/PackageCache/com.reown.appkit.unity@afb2f76865d0/Runtime/Controllers/AccountController.cs:124)
System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.b__7_0 (System.Object state)
Expected behavior
AppKit.NetworkController.ChangeActiveChainAsync() should send switch network request.
Actual behavior
It's not sending request to metamask mobile wallet and showing Exception: Failed to send web request: HTTP/1.1 503 Service Unavailable. Url: https://rpc.walletconnect.org/v1/account/0x65ce881f19a3d81ad6be7e7b6d35795571aa148f/balance?projectId=7afe2b7cf56a8d21fb89e343ec308c4e¤cy=usd&chainId=eip155:1328
Reown.AppKit.Unity.Http.UnityHttpClient.GetAsync[T]
Steps to reproduce
- Connect with Wallet
- call await AppKit.NetworkController.ChangeActiveChainAsync(seiChain);
AppKit version
1.4.0
How did you install the package?
Git via Unity Package Manager
Version of the Unity Editor
6000.1.46f1
Platform
Windows Unity Editor
What wallets did you use for testing?
Metamask Android
Troubleshooting steps
- I've tested with the latest version of the SDK
- I've checked the Unity console for errors
Additional context
Here is the code to connect with wallet and to switch chain.
We get the same error after connecting with Wallet also.
using Reown.AppKit.Unity;
using Reown.AppKit.Unity.Model;
using System;
using UnityEngine;
using UnityEngine.UI;
using static Reown.AppKit.Unity.Connector;
namespace DD.Web3.Test
{
public class ConnectWallet : MonoBehaviour
{
[SerializeField] private Button connectButton;
private Chain seiChain;
private async void Start()
{
seiChain = new Chain(ChainConstants.Namespaces.Evm,
chainReference: "1328",
name: "Sei Testnet",
nativeCurrency: new Currency("Sei", "SEI", 18),
blockExplorer: new BlockExplorer("Seitrace", "https://seitrace.com"),
//rpcUrl: "https://evm-rpc-testnet.sei-apis.com",
rpcUrl: "https://quiet-necessary-scion.sei-atlantic.quiknode.pro/1bb4d0aa8bef30063dc7aa3d9c286d9f4297c371/",
isTestnet: true,
imageUrl: $"https://i.ibb.co/JwG1DpR9/SeiIcon.jpg"
);
// AppKit configuration
var appKitConfig = new AppKitConfig
{
// Project ID from https://cloud.reown.com/
projectId = "7afe2b7cf56a8d21fb89e343ec308c4e",
metadata = new Metadata(
"AppKit Unity",
"AppKit Unity Sample",
"https://reown.com",
"https://raw.githubusercontent.com/reown-com/reown-dotnet/main/media/appkit-icon.png",
new RedirectData
{
// Used by native wallets to redirect back to the app after approving requests
Native = "appkit-sample-unity://"
}
),
customWallets = GetCustomWallets(),
// On mobile show 5 wallets on the Connect view (the first AppKit modal screen)
connectViewWalletsCountMobile = 5,
supportedChains = new[]
{
seiChain,
},
socials = new[]
{
SocialLogin.Google,
SocialLogin.X,
SocialLogin.Discord,
SocialLogin.Apple,
SocialLogin.GitHub
},
includedWalletIds = new[]
{
"82061ee410cab0e705cf38830db84ba965effc51a1e1bf43da6d39ff70ae94fb",
},
};
AppKit.Initialized += (sender, eventArgs) =>
{
AppKit.AccountConnected += OnAccountConnected;
};
connectButton.onClick.AddListener(() => {
Debug.Log("Connect Button Clicked");
AppKit.OpenModal();
}
);
Debug.Log("[AppKit Init] Initializing AppKit...");
await AppKit.InitializeAsync(
appKitConfig
);
#if !UNITY_WEBGL
// The Mixpanel are Sentry are used by the sample project to collect telemetry
var clientId = await AppKit.Instance.SignClient.CoreClient.Crypto.GetClientId();
Mixpanel.Identify(clientId);
SentrySdk.ConfigureScope(scope =>
{
scope.User = new SentryUser
{
Id = clientId
};
});
#endif
Debug.Log($"[AppKit Init] AppKit initialized.");
}
/// <summary>
/// This method returns a list of Reown sample wallets on iOS and Android.
/// These wallets are used for testing and are not included in the default list of wallets returned by AppKit's REST API.
/// On other platforms, this method returns null, so only the default list of wallets is used.
/// </summary>
private Wallet[] GetCustomWallets()
{
#if UNITY_IOS && !UNITY_EDITOR
return new[]
{
new Wallet
{
Name = "Swift Wallet",
ImageUrl = "https://github.com/reown-com/reown-dotnet/blob/develop/media/wallet-swift.png?raw=true",
MobileLink = "walletapp://"
},
new Wallet
{
Name = "React Native Wallet",
ImageUrl = "https://github.com/reown-com/reown-dotnet/blob/develop/media/wallet-rn.png?raw=true",
MobileLink = "rn-web3wallet://"
},
new Wallet
{
Name = "Flutter Wallet Prod",
ImageUrl = "https://github.com/reown-com/reown-dotnet/blob/develop/media/wallet-flutter.png?raw=true",
MobileLink = "wcflutterwallet://"
}
};
#endif
#if UNITY_ANDROID && !UNITY_EDITOR
return new[]
{
new Wallet
{
Name = "Kotlin Wallet",
ImageUrl = "https://github.com/reown-com/reown-dotnet/blob/develop/media/wallet-kotlin.png?raw=true",
MobileLink = "kotlin-web3wallet://"
},
new Wallet
{
Name = "React Native Wallet",
ImageUrl = "https://github.com/reown-com/reown-dotnet/blob/develop/media/wallet-rn.png?raw=true",
MobileLink = "rn-web3wallet://"
},
new Wallet
{
Name = "Flutter Wallet Prod",
ImageUrl = "https://github.com/reown-com/reown-dotnet/blob/develop/media/wallet-flutter.png?raw=true",
MobileLink = "wcflutterwallet://"
}
};
#endif
return null;
}
public async void Disconnect()
{
await AppKit.DisconnectAsync();
}
private void OnAccountConnected(object sender, AccountConnectedEventArgs eventArgs)
{
Debug.Log("Account connected");
}
public async void SwitchChain()
{
Debug.Log("Will Switch Chain");
try
{
Debug.Log("Try block. Switching Chain");
await AppKit.NetworkController.ChangeActiveChainAsync(seiChain);
Debug.Log("Chain switched");
}
catch (Exception e)
{
Debug.Log("Switching Failed Catch block");
Debug.LogError("Failed Chain switching: " + e.Message);
}
}
}
}