Skip to content

Commit

Permalink
Merge commit 'c607e0da3f599330d54f7e3d35cb732ac8e31b35' into feat/sdk…
Browse files Browse the repository at this point in the history
…-v10
  • Loading branch information
Nguyen Anh Tu committed Feb 19, 2025
2 parents 14ee848 + c607e0d commit e964414
Show file tree
Hide file tree
Showing 23 changed files with 300 additions and 328 deletions.
6 changes: 5 additions & 1 deletion demo/vue-app-new2/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions demo/vue-app-new2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"@toruslabs/vue-icons": "^7.6.2",
"@web3auth/auth": "^9.6.4",
"@web3auth/modal": "file:../../packages/modal",
"@web3auth/no-modal": "file:../../packages/no-modal",
"@web3auth/sign-in-with-ethereum": "^4.2.2",
"@web3auth/ws-embed": "^3.4.4",
"bs58": "^6.0.0",
Expand Down
2 changes: 1 addition & 1 deletion demo/vue-app-new2/src/MainView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Web3 from "web3";
const ethereumChainConfig = getEvmChainConfig(Number("0x13882"))!;
const ethWeb3AuthOptions: Web3AuthOptions = {
chainConfig: ethereumChainConfig,
chainConfigs: [ethereumChainConfig],
enableLogging: true,
clientId: clientIds["mainnet"],
web3AuthNetwork: "mainnet",
Expand Down
18 changes: 1 addition & 17 deletions demo/vue-app-new2/src/components/AppSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ const onChainNamespaceChange = (value: string) => {
<Card class="h-auto p-4 sm:p-8 col-span-8 sm:col-span-6 lg:col-span-4 max-sm:!shadow-none max-sm:!border-0">
<div class="text-2xl font-bold leading-tight text-center sm:text-3xl">{{ $t("app.greeting") }}</div>
<div class="my-4 font-extrabold leading-tight text-center">
<Tag v-bind="{ minWidth: 'inherit' }" :class="['uppercase', { '!bg-blue-400 text-white': status.value === ADAPTER_STATUS.READY }]">
<Tag v-bind="{ minWidth: 'inherit' }" :class="['uppercase', { '!bg-blue-400 text-white': status === ADAPTER_STATUS.READY }]">
{{ status }}
</Tag>
&nbsp;
Expand Down Expand Up @@ -348,22 +348,6 @@ const onChainNamespaceChange = (value: string) => {
:label-enabled="$t('app.walletPlugin.title')"
class="mb-2"
/>
<TextField
v-model="formData.walletPlugin.logoLight"
:label="$t('app.walletPlugin.logoLight')"
:disabled="isDisabled('walletServicePlugin')"
:aria-label="$t('app.walletPlugin.logoLight')"
:placeholder="$t('app.walletPlugin.logoLight')"
class="sm:col-span-2"
/>
<TextField
v-model="formData.walletPlugin.logoDark"
:disabled="isDisabled('walletServicePlugin')"
:label="$t('app.walletPlugin.logoDark')"
:aria-label="$t('app.walletPlugin.logoDark')"
:placeholder="$t('app.walletPlugin.logoDark')"
class="sm:col-span-2"
/>
<Select
v-model="formData.walletPlugin.confirmationStrategy"
data-testid="selectLoginProviders"
Expand Down
16 changes: 8 additions & 8 deletions packages/modal/src/modalManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,10 @@ export class Web3Auth extends Web3AuthNoModal implements IWeb3AuthModal {
}

// initialize login modal
const currentChainConfig = this.getCurrentChainConfig();
this.loginModal = new LoginModal({
...this.options.uiConfig,
adapterListener: this,
chainNamespace: currentChainConfig.chainNamespace,
chainNamespace: this.currentChainConfig.chainNamespace,
walletRegistry,
});
this.subscribeToLoginModalEvents();
Expand Down Expand Up @@ -121,9 +120,9 @@ export class Web3Auth extends Web3AuthNoModal implements IWeb3AuthModal {
await this.loginModal.initModal();

// load default adapters: auth, injected wallets
const adapterFns = await this.loadDefaultAdapters();
const adapterFns = await this.loadDefaultAdapters({ projectConfig });
adapterFns.map(async (adapterFn) => {
const adapter = adapterFn({ projectConfig, options: this.coreOptions, getCurrentChainConfig: this.getCurrentChainConfig });
const adapter = adapterFn({ projectConfig, coreOptions: this.coreOptions });
if (this.walletAdapters[adapter.name]) return;
this.walletAdapters[adapter.name] = adapter;
});
Expand Down Expand Up @@ -199,7 +198,8 @@ export class Web3Auth extends Web3AuthNoModal implements IWeb3AuthModal {
// if adapter is configured then only initialize in app or cached adapter.
// external wallets are initialized on INIT_EXTERNAL_WALLET event.
this.subscribeToAdapterEvents(connector);
if (connector.status === ADAPTER_STATUS.NOT_READY) await connector.init({ autoConnect: this.cachedAdapter === adapterName });
if (connector.status === ADAPTER_STATUS.NOT_READY)
await connector.init({ autoConnect: this.cachedAdapter === adapterName, chainId: this.currentChainConfig.chainId });
// note: not adding cachedWallet to modal if it is external wallet.
// adding it later if no in-app wallets are available.
if (connector.type === ADAPTER_CATEGORY.IN_APP) {
Expand All @@ -210,7 +210,7 @@ export class Web3Auth extends Web3AuthNoModal implements IWeb3AuthModal {
}
});

this.commonJRPCProvider = await CommonJRPCProvider.getProviderInstance({ chainConfig: this.getCurrentChainConfig() });
this.commonJRPCProvider = await CommonJRPCProvider.getProviderInstance({ chainConfig: this.currentChainConfig });
if (typeof keyExportEnabled === "boolean") {
// dont know if we need to do this.
this.commonJRPCProvider.setKeyExportFlag(keyExportEnabled);
Expand Down Expand Up @@ -276,7 +276,7 @@ export class Web3Auth extends Web3AuthNoModal implements IWeb3AuthModal {
}
if (adapter.status === ADAPTER_STATUS.NOT_READY) {
await adapter
.init({ autoConnect: this.cachedAdapter === adapterName })
.init({ autoConnect: this.cachedAdapter === adapterName, chainId: this.currentChainConfig.chainId })
.then<undefined>(() => {
const adapterModalConfig = (this.modalConfig.adapters as Record<WALLET_ADAPTER_TYPE, ModalConfig>)[adapterName];
adaptersConfig[adapterName] = { ...adapterModalConfig, isInjected: adapter.isInjected };
Expand Down Expand Up @@ -340,7 +340,7 @@ export class Web3Auth extends Web3AuthNoModal implements IWeb3AuthModal {

// refreshing session for wallet connect whenever modal is opened.
try {
adapter.connect();
adapter.connect({ chainId: this.currentChainConfig.chainId });
} catch (error) {
log.error(`Error while disconnecting to wallet connect in core`, error);
}
Expand Down
Loading

0 comments on commit e964414

Please sign in to comment.