Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove intermediate select screen account on auth connector #2827

Merged
merged 10 commits into from
Oct 30, 2024
1 change: 0 additions & 1 deletion packages/core/src/controllers/RouterController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export interface RouterControllerState {
view:
| 'Account'
| 'AccountSettings'
| 'SelectAddresses'
| 'AllWallets'
| 'ApproveTransaction'
| 'BuyInProgress'
Expand Down
1 change: 0 additions & 1 deletion packages/scaffold-ui/exports/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ export * from '../src/views/w3m-connect-wallets-view/index.js'
export * from '../src/views/w3m-connect-socials-view/index.js'
export * from '../src/views/w3m-connecting-social-view/index.js'
export * from '../src/views/w3m-profile-view/index.js'
export * from '../src/views/w3m-select-addresses-view/index.js'
export * from '../src/views/w3m-switch-address-view/index.js'
export * from '../src/views/w3m-connecting-farcaster-view/index.js'

Expand Down
2 changes: 0 additions & 2 deletions packages/scaffold-ui/src/modal/w3m-router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ export class W3mRouter extends LitElement {
return html`<w3m-network-switch-view></w3m-network-switch-view>`
case 'Profile':
return html`<w3m-profile-view></w3m-profile-view>`
case 'SelectAddresses':
return html`<w3m-select-addresses-view></w3m-select-addresses-view>`
case 'SwitchAddress':
return html`<w3m-switch-address-view></w3m-switch-address-view>`
case 'Transactions':
Expand Down
3 changes: 1 addition & 2 deletions packages/scaffold-ui/src/partials/w3m-header/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ function headings() {
OnRampTokenSelect: 'Select Token',
OnRampFiatSelect: 'Select Currency',
Profile: undefined,
SelectAddresses: 'Select accounts',
SwitchNetwork: networkName ?? 'Switch Network',
SwitchAddress: 'Switch Address',
Transactions: 'Activity',
Expand Down Expand Up @@ -212,7 +211,7 @@ export class W3mHeader extends LitElement {
return html`<wui-select
id="dynamic"
data-testid="w3m-account-select-network"
active-network=${this.network?.name}
active-network=${ifDefined(this.network?.name)}
@click=${this.onNetworks.bind(this)}
imageSrc=${ifDefined(AssetUtil.getNetworkImage(this.network))}
></wui-select>`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,7 @@ export class W3mConnectingWcView extends LitElement {
if (retry || CoreHelperUtil.isPairingExpired(wcPairingExpiry)) {
await ConnectionController.connectWalletConnect()
this.finalizeConnection()
if (
StorageUtil.getConnectedConnector() === 'AUTH' &&
OptionsController.state.hasMultipleAddresses
) {
RouterController.push('SelectAddresses')
} else if (OptionsController.state.isSiweEnabled) {
if (OptionsController.state.isSiweEnabled) {
const { SIWEController } = await import('@web3modal/siwe')
if (SIWEController.state.status === 'success') {
ModalController.close()
Expand Down
35 changes: 2 additions & 33 deletions packages/scaffold-ui/src/views/w3m-email-verify-otp-view/index.ts
Original file line number Diff line number Diff line change
@@ -1,39 +1,14 @@
import { customElement } from '@web3modal/ui'
import { W3mEmailOtpWidget } from '../../utils/w3m-email-otp-widget/index.js'
import type { OnOtpSubmitFn, OnOtpResendFn } from '../../utils/w3m-email-otp-widget/index.js'
import {
EventsController,
ConnectionController,
ModalController,
NetworkController,
RouterController,
AccountController
} from '@web3modal/core'
import { state } from 'lit/decorators.js'
import { EventsController, ConnectionController, ModalController } from '@web3modal/core'

@customElement('w3m-email-verify-otp-view')
export class W3mEmailVerifyOtpView extends W3mEmailOtpWidget {
// -- Members ------------------------------------------- //
private unsubscribe: (() => void)[] = []

// -- State ------------------------------------------- //
@state() private smartAccountDeployed = AccountController.state.smartAccountDeployed

public constructor() {
super()

this.unsubscribe.push(
AccountController.subscribeKey('smartAccountDeployed', val => {
this.smartAccountDeployed = val
})
)
}

// -- Private ------------------------------------------ //
override onOtpSubmit: OnOtpSubmitFn = async otp => {
try {
if (this.authConnector) {
const smartAccountEnabled = NetworkController.checkIfSmartAccountEnabled()
await this.authConnector.provider.connectOtp({ otp })
EventsController.sendEvent({ type: 'track', event: 'EMAIL_VERIFICATION_CODE_PASS' })
await ConnectionController.connectExternal(this.authConnector, this.authConnector.chain)
Expand All @@ -42,13 +17,7 @@ export class W3mEmailVerifyOtpView extends W3mEmailOtpWidget {
event: 'CONNECT_SUCCESS',
properties: { method: 'email', name: this.authConnector.name || 'Unknown' }
})
if (AccountController.state.allAccounts.length > 1) {
RouterController.push('SelectAddresses')
} else if (smartAccountEnabled && !this.smartAccountDeployed) {
RouterController.push('UpgradeToSmartAccount')
} else {
ModalController.close()
}
ModalController.close()
}
} catch (error) {
EventsController.sendEvent({ type: 'track', event: 'EMAIL_VERIFICATION_CODE_FAIL' })
Expand Down
2 changes: 1 addition & 1 deletion packages/scaffold-ui/src/views/w3m-profile-view/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export class W3mProfileView extends LitElement {
: html`<wui-button
tomiir marked this conversation as resolved.
Show resolved Hide resolved
slot="action"
textVariant="small-600"
size="sm"
size="md"
variant="accent"
@click=${() => this.onSwitchAccount(account)}
>Switch</wui-button
Expand Down
158 changes: 0 additions & 158 deletions packages/scaffold-ui/src/views/w3m-select-addresses-view/index.ts

This file was deleted.

10 changes: 0 additions & 10 deletions packages/scaffold-ui/src/views/w3m-select-addresses-view/styles.ts

This file was deleted.

Loading