Skip to content

Commit 3aa18f7

Browse files
committed
feat: updated other connectors
1 parent b15697e commit 3aa18f7

File tree

7 files changed

+56
-26
lines changed

7 files changed

+56
-26
lines changed

packages/modal/src/ui/components/Loader/Loader.tsx

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import i18n from "../../localeImport";
66
import CircularLoader from "../CircularLoader";
77
import Image from "../Image";
88
import PulseLoader from "../PulseLoader";
9-
import { ConnectedStatusType, ConnectingStatusType, ErroredStatusType, LoaderProps } from "./Loader.type";
9+
import { AuthorizingStatusType, ConnectedStatusType, ConnectingStatusType, ErroredStatusType, LoaderProps } from "./Loader.type";
1010

1111
/**
1212
* ConnectingStatus component
@@ -89,29 +89,27 @@ function ErroredStatus(props: ErroredStatusType) {
8989
);
9090
}
9191

92-
function AuthorizingStatus() {
92+
function AuthorizingStatus(props: AuthorizingStatusType) {
93+
// const [t] = useTranslation(undefined, { i18n });
94+
const { connector, externalWalletsConfig } = props;
95+
96+
// eslint-disable-next-line no-console
97+
console.log("externalWalletsConfig", externalWalletsConfig);
98+
9399
return (
94-
<div className="w3a--flex w3a--size-full w3a--flex-col w3a--items-center w3a--justify-center w3a--gap-y-6">
100+
<div className="w3a--flex w3a--size-full w3a--flex-col w3a--items-center w3a--justify-between w3a--gap-y-6">
95101
<p className="w3a--p-2 w3a--text-center w3a--text-base w3a--font-semibold w3a--text-app-gray-900 dark:w3a--text-app-white">
96-
Verify on MetaMask
102+
Verify on {externalWalletsConfig[connector].label}
97103
</p>
98104
<div className="w3a--flex w3a--justify-center">
99105
<CircularLoader width={95} height={95} thickness={6} arcSizeDeg={100}>
100-
<Image
101-
imageId={`login-metamask`}
102-
hoverImageId={`login-metamask`}
103-
fallbackImageId="wallet"
104-
height="45"
105-
width="45"
106-
isButton
107-
extension="svg"
108-
/>
106+
<Image imageId={`login-${connector}`} hoverImageId={`login-${connector}`} height="45" width="45" />
109107
</CircularLoader>
110108
</div>
111109
<p className="w3a--text-center w3a--text-sm w3a--text-app-gray-500 dark:w3a--text-app-gray-400">
112110
We’ve sent a request to your wallet. Verify on your wallet to confirm that you own this wallet.
113111
</p>
114-
<button className="w3a--w-full w3a--rounded-xl w3a--bg-app-gray-100 w3a--p-2 w3a--py-3 w3a--text-sm w3a--text-app-gray-900 dark:w3a--bg-app-gray-800 dark:w3a--text-app-white">
112+
<button className="w3a--w-full w3a--rounded-xl w3a--bg-app-gray-100 w3a--p-2 w3a--py-3 w3a--text-sm w3a--text-app-gray-900 dark:w3a--bg-app-gray-800 dark:w3a--text-app-white md:w3a--hidden">
115113
Click here to verify
116114
</button>
117115
</div>
@@ -124,7 +122,10 @@ function AuthorizingStatus() {
124122
* @returns Loader component
125123
*/
126124
function Loader(props: LoaderProps) {
127-
const { connector, connectorName, modalStatus, onClose, appLogo, message, isConnectAndSignAuthenticationMode } = props;
125+
const { connector, connectorName, modalStatus, onClose, appLogo, message, isConnectAndSignAuthenticationMode, externalWalletsConfig } = props;
126+
127+
// eslint-disable-next-line no-console
128+
console.log("connectorName", connectorName);
128129

129130
useEffect(() => {
130131
if (modalStatus === MODAL_STATUS.CONNECTED) {
@@ -147,7 +148,7 @@ function Loader(props: LoaderProps) {
147148

148149
{modalStatus === MODAL_STATUS.ERRORED && <ErroredStatus message={message} />}
149150

150-
{modalStatus === MODAL_STATUS.AUTHORIZING && <AuthorizingStatus />}
151+
{modalStatus === MODAL_STATUS.AUTHORIZING && <AuthorizingStatus connector={connector} externalWalletsConfig={externalWalletsConfig} />}
151152
</div>
152153
);
153154
}

packages/modal/src/ui/components/Loader/Loader.type.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
import { BaseConnectorConfig } from "@web3auth/no-modal";
2+
13
import type { ModalStatusType } from "../../interfaces";
24

35
export interface LoaderProps {
6+
externalWalletsConfig: Record<string, BaseConnectorConfig>;
47
message?: string;
58
appLogo?: string;
69
connector: string;
@@ -15,3 +18,5 @@ export type ConnectingStatusType = Pick<LoaderProps, "connectorName" | "appLogo"
1518
export type ConnectedStatusType = Pick<LoaderProps, "message">;
1619

1720
export type ErroredStatusType = Pick<LoaderProps, "message">;
21+
22+
export type AuthorizingStatusType = Pick<LoaderProps, "connector" | "externalWalletsConfig">;

packages/modal/src/ui/components/Root/Root.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,7 @@ function Root(props: RootProps) {
442442
onClose={onCloseLoader}
443443
appLogo={appLogo}
444444
isConnectAndSignAuthenticationMode={isConnectAndSignAuthenticationMode}
445+
externalWalletsConfig={modalState.externalWalletsConfig}
445446
/>
446447
) : (
447448
<>

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
clearToken,
88
CONNECTOR_EVENTS,
99
CONNECTOR_STATUS,
10+
CONNECTOR_STATUS_TYPE,
1011
ConnectorInitOptions,
1112
getSavedToken,
1213
IdentityTokenInfo,
@@ -19,7 +20,8 @@ export abstract class BaseSolanaConnector<T> extends BaseConnector<T> {
1920
async init(_?: ConnectorInitOptions): Promise<void> {}
2021

2122
async getIdentityToken(): Promise<IdentityTokenInfo> {
22-
if (!this.provider || this.status !== CONNECTOR_STATUS.CONNECTED) throw WalletLoginError.notConnectedError();
23+
if (!this.provider || !([CONNECTOR_STATUS.CONNECTED, CONNECTOR_STATUS.AUTHORIZING] as CONNECTOR_STATUS_TYPE[]).includes(this.status))
24+
throw WalletLoginError.notConnectedError();
2325
if (!this.coreOptions) throw WalletInitializationError.invalidParams("Please initialize Web3Auth with a valid options");
2426

2527
const accounts = await this.provider.request<never, string[]>({ method: SOLANA_METHOD_TYPES.GET_ACCOUNTS });

packages/no-modal/src/connectors/coinbase-connector/coinbaseConnector.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,16 +114,24 @@ class CoinbaseConnector extends BaseEvmConnector<void> {
114114
// ready to be connected again
115115
this.disconnect();
116116
});
117+
117118
let identityTokenInfo: IdentityTokenInfo | undefined;
118-
if (getIdentityToken) {
119-
identityTokenInfo = await this.getIdentityToken();
120-
}
119+
121120
this.emit(CONNECTOR_EVENTS.CONNECTED, {
122121
connector: WALLET_CONNECTORS.COINBASE,
123122
reconnected: this.rehydrated,
124123
provider: this.provider,
125124
identityTokenInfo,
126125
} as CONNECTED_EVENT_DATA);
126+
127+
if (getIdentityToken) {
128+
this.status = CONNECTOR_STATUS.AUTHORIZING;
129+
this.emit(CONNECTOR_EVENTS.AUTHORIZING, { connector: WALLET_CONNECTORS.COINBASE });
130+
identityTokenInfo = await this.getIdentityToken();
131+
this.status = CONNECTOR_STATUS.AUTHORIZED;
132+
this.emit(CONNECTOR_EVENTS.AUTHORIZED, { connector: WALLET_CONNECTORS.COINBASE });
133+
}
134+
127135
return this.provider;
128136
} catch (error) {
129137
// ready again to be connected

packages/no-modal/src/connectors/injected-solana-connector/walletStandardConnector.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,22 @@ export class WalletStandardConnector extends BaseSolanaConnector<void> {
112112

113113
this.status = CONNECTOR_STATUS.CONNECTED;
114114
let identityTokenInfo: IdentityTokenInfo | undefined;
115-
if (getIdentityToken) {
116-
identityTokenInfo = await this.getIdentityToken();
117-
}
115+
118116
this.emit(CONNECTOR_EVENTS.CONNECTED, {
119117
connector: this.name,
120118
reconnected: this.rehydrated,
121119
provider: this.provider,
122120
identityTokenInfo,
123121
} as CONNECTED_EVENT_DATA);
122+
123+
if (getIdentityToken) {
124+
this.status = CONNECTOR_STATUS.AUTHORIZING;
125+
this.emit(CONNECTOR_EVENTS.AUTHORIZING, { connector: this.name });
126+
identityTokenInfo = await this.getIdentityToken();
127+
this.status = CONNECTOR_STATUS.AUTHORIZED;
128+
this.emit(CONNECTOR_EVENTS.AUTHORIZED, { connector: this.name });
129+
}
130+
124131
return this.provider;
125132
} catch (error: unknown) {
126133
// ready again to be connected

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,16 +179,22 @@ class MetaMaskConnector extends BaseEvmConnector<void> {
179179
}
180180

181181
let identityTokenInfo: IdentityTokenInfo | undefined;
182-
if (getIdentityToken) {
183-
identityTokenInfo = await this.getIdentityToken();
184-
}
185182

186183
this.emit(CONNECTOR_EVENTS.CONNECTED, {
187184
connector: WALLET_CONNECTORS.METAMASK,
188185
reconnected: this.rehydrated,
189186
provider: this.metamaskProvider,
190187
identityTokenInfo,
191188
} as CONNECTED_EVENT_DATA);
189+
190+
if (getIdentityToken) {
191+
this.status = CONNECTOR_STATUS.AUTHORIZING;
192+
this.emit(CONNECTOR_EVENTS.AUTHORIZING, { connector: WALLET_CONNECTORS.METAMASK });
193+
identityTokenInfo = await this.getIdentityToken();
194+
this.status = CONNECTOR_STATUS.AUTHORIZED;
195+
this.emit(CONNECTOR_EVENTS.AUTHORIZED, { connector: WALLET_CONNECTORS.METAMASK });
196+
}
197+
192198
return this.metamaskProvider;
193199
} catch (error) {
194200
// ready again to be connected

0 commit comments

Comments
 (0)