66using UnityEngine . UI ;
77using UnityEngine . Events ;
88using WalletConnectSharp . Core . Models ;
9+ using System . Numerics ;
910
1011[ Serializable ]
1112public struct WalletButton
@@ -75,10 +76,7 @@ public class Prefab_ConnectWallet : MonoBehaviour
7576
7677 public string Address
7778 {
78- get
79- {
80- return address ;
81- }
79+ get { return address ; }
8280 }
8381
8482 // UI Initialization
@@ -168,7 +166,9 @@ public async void OnConnect(WalletProvider wallet, string password = null, strin
168166 {
169167 try
170168 {
171- address = await ThirdwebManager . Instance . SDK . wallet . Connect ( new WalletConnection ( wallet , ThirdwebManager . Instance . GetCurrentChainID ( ) , password , email , personalWallet ) ) ;
169+ ChainData currentChain = ThirdwebManager . Instance . supportedChains . Find ( x => x . identifier == ThirdwebManager . Instance . chain ) ;
170+
171+ address = await ThirdwebManager . Instance . SDK . wallet . Connect ( new WalletConnection ( wallet , BigInteger . Parse ( currentChain . chainId ) , password , email , personalWallet ) ) ;
172172
173173 if ( wallet == WalletProvider . LocalWallet || ( wallet == WalletProvider . SmartWallet && personalWallet == WalletProvider . LocalWallet ) )
174174 {
@@ -206,7 +206,7 @@ async void OnConnected()
206206 balanceText2 . text = balanceText . text ;
207207 walletAddressText . text = await Utils . GetENSName ( address ) ?? address . ShortenAddress ( ) ;
208208 walletAddressText2 . text = walletAddressText . text ;
209- currentNetworkText . text = ThirdwebManager . Instance . GetCurrentChainIdentifier ( ) ;
209+ currentNetworkText . text = ThirdwebManager . Instance . chain ;
210210 currentNetworkImage . sprite = networkSprites . Find ( x => x . chain == _chain ) . sprite ;
211211 connectButton . SetActive ( false ) ;
212212 connectedButton . SetActive ( true ) ;
@@ -230,7 +230,8 @@ public async void OnSwitchNetwork(string _chain)
230230 try
231231 {
232232 ThirdwebManager . Instance . chain = _chain ;
233- await ThirdwebManager . Instance . SDK . wallet . SwitchNetwork ( int . Parse ( ThirdwebManager . Instance . GetCurrentChainData ( ) . chainId ) ) ;
233+ ChainData currentChain = ThirdwebManager . Instance . supportedChains . Find ( x => x . identifier == ThirdwebManager . Instance . chain ) ;
234+ await ThirdwebManager . Instance . SDK . wallet . SwitchNetwork ( int . Parse ( currentChain . chainId ) ) ;
234235 OnConnected ( ) ;
235236 OnSwitchNetworkCallback ? . Invoke ( ) ;
236237 Debug . Log ( $ "Switched Network Successfully: { _chain } ") ;
0 commit comments