File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
Assets/WebGLTemplates/Thirdweb/lib Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -28,18 +28,25 @@ w.bridge.initialize = (chain, options) => {
2828 w . thirdweb = sdk ;
2929} ;
3030
31+ const updateSDKSigner = ( ) => {
32+ if ( w . thirdweb ) {
33+ const provider = new ethers . providers . Web3Provider ( w . ethereum ) ;
34+ w . thirdweb . updateSignerOrProvider ( provider . getSigner ( ) ) ;
35+ }
36+ } ;
37+
3138w . bridge . connect = async ( ) => {
3239 if ( w . ethereum ) {
3340 await w . ethereum . enable ;
3441 const provider = new ethers . providers . Web3Provider ( w . ethereum ) ;
3542 await provider . send ( "eth_requestAccounts" , [ ] ) ;
3643 if ( w . thirdweb ) {
37- w . thirdweb . updateSignerOrProvider ( provider . getSigner ( ) ) ;
44+ updateSDKSigner ( ) ;
3845 w . ethereum . on ( "accountsChanged" , async ( accounts ) => {
39- w . thirdweb . updateSignerOrProvider ( provider . getSigner ( ) ) ;
46+ updateSDKSigner ( ) ;
4047 } ) ;
4148 w . ethereum . on ( "chainChanged" , async ( chain ) => {
42- w . thirdweb . updateSignerOrProvider ( provider . getSigner ( ) ) ;
49+ updateSDKSigner ( ) ;
4350 } ) ;
4451 return await w . thirdweb . wallet . getAddress ( ) ;
4552 } else {
@@ -56,6 +63,7 @@ w.bridge.switchNetwork = async (chainId) => {
5663 method : "wallet_switchEthereumChain" ,
5764 params : [ { chainId : "0x" + chainId . toString ( 16 ) } ] ,
5865 } ) ;
66+ updateSDKSigner ( ) ;
5967 } else {
6068 throw "Error Switching Network" ;
6169 }
You can’t perform that action at this time.
0 commit comments