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) => {
28
28
w . thirdweb = sdk ;
29
29
} ;
30
30
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
+
31
38
w . bridge . connect = async ( ) => {
32
39
if ( w . ethereum ) {
33
40
await w . ethereum . enable ;
34
41
const provider = new ethers . providers . Web3Provider ( w . ethereum ) ;
35
42
await provider . send ( "eth_requestAccounts" , [ ] ) ;
36
43
if ( w . thirdweb ) {
37
- w . thirdweb . updateSignerOrProvider ( provider . getSigner ( ) ) ;
44
+ updateSDKSigner ( ) ;
38
45
w . ethereum . on ( "accountsChanged" , async ( accounts ) => {
39
- w . thirdweb . updateSignerOrProvider ( provider . getSigner ( ) ) ;
46
+ updateSDKSigner ( ) ;
40
47
} ) ;
41
48
w . ethereum . on ( "chainChanged" , async ( chain ) => {
42
- w . thirdweb . updateSignerOrProvider ( provider . getSigner ( ) ) ;
49
+ updateSDKSigner ( ) ;
43
50
} ) ;
44
51
return await w . thirdweb . wallet . getAddress ( ) ;
45
52
} else {
@@ -56,6 +63,7 @@ w.bridge.switchNetwork = async (chainId) => {
56
63
method : "wallet_switchEthereumChain" ,
57
64
params : [ { chainId : "0x" + chainId . toString ( 16 ) } ] ,
58
65
} ) ;
66
+ updateSDKSigner ( ) ;
59
67
} else {
60
68
throw "Error Switching Network" ;
61
69
}
You can’t perform that action at this time.
0 commit comments