Skip to content

Commit 1ffc94a

Browse files
fix more cursor comments reg. tokens
1 parent b4a1f32 commit 1ffc94a

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

packages/modal/src/modalManager.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ export class Web3Auth extends Web3AuthNoModal implements IWeb3AuthModal {
191191

192192
const handleError = (err: unknown) => {
193193
this.removeListener(CONNECTOR_EVENTS.CONNECTED, handleConnected);
194+
this.removeListener(CONNECTOR_EVENTS.AUTHORIZED, handleConnected);
194195
this.removeListener(LOGIN_MODAL_EVENTS.MODAL_VISIBILITY, handleVisibility);
195196
return reject(err);
196197
};

packages/no-modal/src/connectors/base-solana-connector/baseSolanaConnector.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ import {
66
checkIfTokenIsExpired,
77
clearToken,
88
CONNECTOR_EVENTS,
9+
CONNECTOR_STATUS,
910
ConnectorInitOptions,
1011
getSavedToken,
1112
IdentityTokenInfo,
1213
saveToken,
14+
WALLET_CONNECTOR_TYPE,
1315
WalletInitializationError,
1416
WalletLoginError,
1517
} from "../../base";
@@ -21,12 +23,17 @@ export abstract class BaseSolanaConnector<T> extends BaseConnector<T> {
2123
if (!this.provider || !this.canAuthorize) throw WalletLoginError.notConnectedError();
2224
if (!this.coreOptions) throw WalletInitializationError.invalidParams("Please initialize Web3Auth with a valid options");
2325

26+
this.status = CONNECTOR_STATUS.AUTHORIZING;
27+
this.emit(CONNECTOR_EVENTS.AUTHORIZING, { connector: this.name as WALLET_CONNECTOR_TYPE });
28+
2429
const accounts = await this.provider.request<never, string[]>({ method: SOLANA_METHOD_TYPES.GET_ACCOUNTS });
2530
if (accounts && accounts.length > 0) {
2631
const existingToken = getSavedToken(accounts[0] as string, this.name);
2732
if (existingToken) {
2833
const isExpired = checkIfTokenIsExpired(existingToken);
2934
if (!isExpired) {
35+
this.status = CONNECTOR_STATUS.AUTHORIZED;
36+
this.emit(CONNECTOR_EVENTS.AUTHORIZED, { connector: this.name as WALLET_CONNECTOR_TYPE, identityTokenInfo: { idToken: existingToken } });
3037
return { idToken: existingToken };
3138
}
3239
}
@@ -61,6 +68,8 @@ export abstract class BaseSolanaConnector<T> extends BaseConnector<T> {
6168
this.coreOptions.web3AuthNetwork
6269
);
6370
saveToken(accounts[0] as string, this.name, idToken);
71+
this.status = CONNECTOR_STATUS.AUTHORIZED;
72+
this.emit(CONNECTOR_EVENTS.AUTHORIZED, { connector: this.name as WALLET_CONNECTOR_TYPE, identityTokenInfo: { idToken } });
6473
return { idToken };
6574
}
6675
throw WalletLoginError.notConnectedError("Not connected with wallet, Please login/connect first");

packages/no-modal/src/connectors/metamask-connector/metamaskConnector.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,17 +180,17 @@ class MetaMaskConnector extends BaseEvmConnector<void> {
180180

181181
let identityTokenInfo: IdentityTokenInfo | undefined;
182182

183+
if (getIdentityToken) {
184+
identityTokenInfo = await this.getIdentityToken();
185+
}
186+
183187
this.emit(CONNECTOR_EVENTS.CONNECTED, {
184188
connector: WALLET_CONNECTORS.METAMASK,
185189
reconnected: this.rehydrated,
186190
provider: this.metamaskProvider,
187191
identityTokenInfo,
188192
} as CONNECTED_EVENT_DATA);
189193

190-
if (getIdentityToken) {
191-
identityTokenInfo = await this.getIdentityToken();
192-
}
193-
194194
return this.metamaskProvider;
195195
} catch (error) {
196196
// ready again to be connected

0 commit comments

Comments
 (0)