6
6
using UnityEngine . UI ;
7
7
using UnityEngine . Events ;
8
8
using WalletConnectSharp . Core . Models ;
9
+ using System . Numerics ;
9
10
10
11
[ Serializable ]
11
12
public struct WalletButton
@@ -75,10 +76,7 @@ public class Prefab_ConnectWallet : MonoBehaviour
75
76
76
77
public string Address
77
78
{
78
- get
79
- {
80
- return address ;
81
- }
79
+ get { return address ; }
82
80
}
83
81
84
82
// UI Initialization
@@ -168,7 +166,9 @@ public async void OnConnect(WalletProvider wallet, string password = null, strin
168
166
{
169
167
try
170
168
{
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 ) ) ;
172
172
173
173
if ( wallet == WalletProvider . LocalWallet || ( wallet == WalletProvider . SmartWallet && personalWallet == WalletProvider . LocalWallet ) )
174
174
{
@@ -206,7 +206,7 @@ async void OnConnected()
206
206
balanceText2 . text = balanceText . text ;
207
207
walletAddressText . text = await Utils . GetENSName ( address ) ?? address . ShortenAddress ( ) ;
208
208
walletAddressText2 . text = walletAddressText . text ;
209
- currentNetworkText . text = ThirdwebManager . Instance . GetCurrentChainIdentifier ( ) ;
209
+ currentNetworkText . text = ThirdwebManager . Instance . chain ;
210
210
currentNetworkImage . sprite = networkSprites . Find ( x => x . chain == _chain ) . sprite ;
211
211
connectButton . SetActive ( false ) ;
212
212
connectedButton . SetActive ( true ) ;
@@ -230,7 +230,8 @@ public async void OnSwitchNetwork(string _chain)
230
230
try
231
231
{
232
232
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 ) ) ;
234
235
OnConnected ( ) ;
235
236
OnSwitchNetworkCallback ? . Invoke ( ) ;
236
237
Debug . Log ( $ "Switched Network Successfully: { _chain } ") ;
0 commit comments