Skip to content

Commit 7d086b7

Browse files
feat: make logo optional
1 parent 184ca0e commit 7d086b7

4 files changed

Lines changed: 15 additions & 49 deletions

File tree

demo/vue-app-new/src/MainView.vue

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -112,25 +112,14 @@ const options = computed((): Web3AuthOptions => {
112112
113113
const { widget, targetId } = formData;
114114
const uiConfig: Web3AuthOptions["uiConfig"] = enabledWhiteLabel
115-
? {
116-
...whiteLabel,
117-
widgetType: widget,
118-
targetId,
119-
logoLight: whiteLabel.logoLight || "",
120-
logoDark: whiteLabel.logoDark || "",
121-
}
122-
: {
123-
widgetType: widget,
124-
targetId,
125-
logoLight: "",
126-
logoDark: "",
127-
};
115+
? { ...whiteLabel, widgetType: widget, targetId }
116+
: { widgetType: widget, targetId };
128117
const authConnectorInstance = authConnector({ connectorSettings: {} });
129118
130119
return {
131120
clientId: clientIds[formData.network],
132121
web3AuthNetwork: formData.network,
133-
uiConfig: uiConfig,
122+
uiConfig,
134123
accountAbstractionConfig,
135124
useAAWithExternalWallet: formData.useAAWithExternalWallet,
136125
// TODO: Add more options

packages/modal/src/modalManager.ts

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,7 @@ export interface Web3AuthOptions extends IWeb3AuthCoreOptions {
4343
/**
4444
* Config for configuring modal ui display properties
4545
*/
46-
uiConfig: Omit<UIConfig, "connectorListener" | "logoLight" | "logoDark"> & {
47-
/**
48-
* App logo to use in light mode
49-
*/
50-
logoLight: string;
51-
/**
52-
* App logo to use in dark mode
53-
*/
54-
logoDark: string;
55-
};
46+
uiConfig?: Omit<UIConfig, "connectorListener">;
5647

5748
/**
5849
* Config for configuring modal ui display properties
@@ -71,7 +62,7 @@ export class Web3Auth extends Web3AuthNoModal implements IWeb3AuthModal {
7162
super(options, initialState);
7263
this.options = { ...options };
7364

74-
if (!this.options.uiConfig) this.options.uiConfig = { logoLight: "", logoDark: "" };
65+
if (!this.options.uiConfig) this.options.uiConfig = {};
7566
if (this.options.modalConfig) this.modalConfig = this.options.modalConfig;
7667

7768
log.info("modalConfig", this.modalConfig);
@@ -218,14 +209,9 @@ export class Web3Auth extends Web3AuthNoModal implements IWeb3AuthModal {
218209
this.options.uiConfig = deepmerge(cloneDeep(projectConfig.whitelabel || {}), this.options.uiConfig || {});
219210
if (!this.options.uiConfig.defaultLanguage) this.options.uiConfig.defaultLanguage = getUserLanguage(this.options.uiConfig.defaultLanguage);
220211
if (!this.options.uiConfig.mode) this.options.uiConfig.mode = "light";
221-
const uiConfig = deepmerge.all<UIConfig>([projectConfig.loginModal || {}, this.options.uiConfig], {
212+
this.options.uiConfig = deepmerge(projectConfig.loginModal || {}, this.options.uiConfig, {
222213
arrayMerge: (_, sourceArray) => sourceArray,
223214
});
224-
this.options.uiConfig = {
225-
...uiConfig,
226-
logoLight: uiConfig.logoLight || "",
227-
logoDark: uiConfig.logoDark || "",
228-
};
229215

230216
// merge login methods order from project config and user config, with user config taking precedence
231217
const defaultAuthConnections = projectConfig.embeddedWalletAuth.filter((x) => x.isDefault).map((x) => x.authConnection);

packages/no-modal/src/connectors/auth-connector/authConnector.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,18 +143,15 @@ class AuthConnector extends BaseConnector<AuthLoginParams> {
143143
const wsSupportedChains = chains.filter(
144144
(x) => x.chainNamespace === CHAIN_NAMESPACES.EIP155 || x.chainNamespace === CHAIN_NAMESPACES.SOLANA
145145
);
146-
const wsEmbedWhiteLabel = {
147-
...this.authOptions.whiteLabel,
148-
...this.wsSettings.whiteLabel,
149-
logoLight: this.wsSettings.whiteLabel?.logoLight || this.authOptions.whiteLabel?.logoLight || "",
150-
logoDark: this.wsSettings.whiteLabel?.logoDark || this.authOptions.whiteLabel?.logoDark || "",
151-
};
152146
this.wsEmbedInstancePromise = this.wsEmbedInstance
153147
.init({
154148
...this.wsSettings,
155149
chains: wsSupportedChains as ProviderConfig[],
156150
chainId,
157-
whiteLabel: { ...wsEmbedWhiteLabel, logoLight: wsEmbedWhiteLabel.logoLight || "", logoDark: wsEmbedWhiteLabel.logoDark || "" },
151+
whiteLabel: {
152+
...this.authOptions.whiteLabel,
153+
...this.wsSettings.whiteLabel,
154+
},
158155
})
159156
.then(() => {
160157
this.wsEmbedInstancePromise = null;
@@ -619,7 +616,7 @@ export const authConnector = (params?: AuthConnectorFuncParams): ConnectorFn =>
619616
const finalWsSettings: WalletServicesSettings = {
620617
...coreOptions.walletServicesConfig,
621618
whiteLabel,
622-
accountAbstractionConfig: coreOptions.accountAbstractionConfig as WalletServicesSettings["accountAbstractionConfig"],
619+
accountAbstractionConfig: coreOptions.accountAbstractionConfig,
623620
enableLogging: coreOptions.enableLogging,
624621
};
625622

packages/no-modal/src/noModal.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ import {
5858
} from "./base";
5959
import { cookieStorage } from "./base/cookie";
6060
import { deserialize } from "./base/deserialize";
61-
import { authConnector, type AuthConnectorType, WalletServicesSettings } from "./connectors/auth-connector";
61+
import { authConnector, type AuthConnectorType } from "./connectors/auth-connector";
6262
import { metaMaskConnector } from "./connectors/metamask-connector";
6363
import { walletServicesPlugin } from "./plugins/wallet-services-plugin";
6464
import { type AccountAbstractionProvider } from "./providers/account-abstraction-provider";
@@ -607,22 +607,16 @@ export class Web3AuthNoModal extends SafeEventEmitter<Web3AuthNoModalEvents> imp
607607
buttonPosition: portfolioWidgetPosition,
608608
defaultPortfolio,
609609
};
610-
const whiteLabel: WalletServicesSettings["whiteLabel"] = deepmerge.all([
611-
projectConfigWhiteLabel,
612-
this.coreOptions.walletServicesConfig?.whiteLabel || {},
613-
]);
610+
const whiteLabel = deepmerge.all([projectConfigWhiteLabel, this.coreOptions.walletServicesConfig?.whiteLabel || {}]);
611+
614612
const confirmationStrategy =
615613
this.coreOptions.walletServicesConfig?.confirmationStrategy ??
616614
(enableConfirmationModal ? CONFIRMATION_STRATEGY.MODAL : CONFIRMATION_STRATEGY.AUTO_APPROVE);
617615
const isKeyExportEnabled = this.coreOptions.walletServicesConfig?.enableKeyExport ?? enableKeyExport ?? true;
618616
this.coreOptions.walletServicesConfig = {
619617
...this.coreOptions.walletServicesConfig,
620618
confirmationStrategy,
621-
whiteLabel: {
622-
...whiteLabel,
623-
logoLight: whiteLabel?.logoLight || "",
624-
logoDark: whiteLabel?.logoDark || "",
625-
},
619+
whiteLabel,
626620
enableKeyExport: isKeyExportEnabled,
627621
};
628622
}

0 commit comments

Comments
 (0)