@@ -89,7 +89,7 @@ export class EmbeddedWalletConnector extends Connector<EmbeddedWalletConnectionA
89
89
if ( ! this . user ) {
90
90
throw new Error ( "Embedded Wallet is not connected" ) ;
91
91
}
92
- return this . user . walletAddress ;
92
+ return await this . getSigner ( ) . then ( ( signer ) => signer . getAddress ( ) ) ;
93
93
}
94
94
95
95
async isConnected ( ) : Promise < boolean > {
@@ -115,7 +115,7 @@ export class EmbeddedWalletConnector extends Connector<EmbeddedWalletConnectionA
115
115
}
116
116
117
117
const user = await this . getUser ( ) ;
118
- const signer = await user ? .wallet . getEthersJsSigner ( {
118
+ const signer = await user . wallet . getEthersJsSigner ( {
119
119
rpcEndpoint : this . options . chain . rpc [ 0 ] || "" , // TODO: handle chain.rpc being empty array
120
120
} ) ;
121
121
@@ -180,11 +180,11 @@ export class EmbeddedWalletConnector extends Connector<EmbeddedWalletConnectionA
180
180
this . emit ( "disconnect" ) ;
181
181
} ;
182
182
183
- async getUser ( ) : Promise < InitializedUser | null > {
183
+ private async getUser ( ) : Promise < InitializedUser > {
184
184
if (
185
185
! this . user ||
186
186
! this . user . wallet ||
187
- typeof this . user . wallet . getEthersJsSigner !== "function"
187
+ ! this . user . wallet . getEthersJsSigner // when serializing, functions are lost
188
188
) {
189
189
const embeddedWalletSdk = this . getEmbeddedWalletSDK ( ) ;
190
190
const user = await embeddedWalletSdk . getUser ( ) ;
@@ -195,25 +195,22 @@ export class EmbeddedWalletConnector extends Connector<EmbeddedWalletConnectionA
195
195
}
196
196
}
197
197
}
198
+ if ( ! this . user ) {
199
+ throw new Error (
200
+ "No user found, Embedded Wallet is not authenticated, please authenticate first" ,
201
+ ) ;
202
+ }
198
203
return this . user ;
199
204
}
200
205
201
206
async getEmail ( ) {
202
- // implicit call to set the user
203
- await this . getSigner ( ) ;
204
- if ( ! this . user ) {
205
- throw new Error ( "No user found, Embedded Wallet is not connected" ) ;
206
- }
207
- return this . user . authDetails . email ;
207
+ const user = await this . getUser ( ) ;
208
+ return user . authDetails . email ;
208
209
}
209
210
210
211
async getRecoveryInformation ( ) {
211
- // implicit call to set the user
212
- await this . getSigner ( ) ;
213
- if ( ! this . user ) {
214
- throw new Error ( "No user found, Embedded Wallet is not connected" ) ;
215
- }
216
- return this . user . authDetails ;
212
+ const user = await this . getUser ( ) ;
213
+ return user . authDetails ;
217
214
}
218
215
219
216
async sendVerificationEmail ( {
0 commit comments