From 51e82e727efa9c19d9cbfb9bbe8e99ccefd1841f Mon Sep 17 00:00:00 2001 From: tomiir Date: Mon, 9 Sep 2024 13:55:35 -0600 Subject: [PATCH 1/4] chore: remove intermediate select screen account --- .../core/src/controllers/RouterController.ts | 1 - packages/scaffold-ui/exports/index.ts | 1 - .../scaffold-ui/src/modal/w3m-router/index.ts | 2 - .../src/partials/w3m-header/index.ts | 3 +- .../src/views/w3m-connecting-wc-view/index.ts | 7 +- .../views/w3m-email-verify-otp-view/index.ts | 35 +--- .../src/views/w3m-profile-view/index.ts | 2 +- .../views/w3m-select-addresses-view/index.ts | 158 ------------------ .../views/w3m-select-addresses-view/styles.ts | 10 -- 9 files changed, 5 insertions(+), 214 deletions(-) delete mode 100644 packages/scaffold-ui/src/views/w3m-select-addresses-view/index.ts delete mode 100644 packages/scaffold-ui/src/views/w3m-select-addresses-view/styles.ts diff --git a/packages/core/src/controllers/RouterController.ts b/packages/core/src/controllers/RouterController.ts index a39d013905..80ef6872fd 100644 --- a/packages/core/src/controllers/RouterController.ts +++ b/packages/core/src/controllers/RouterController.ts @@ -17,7 +17,6 @@ export interface RouterControllerState { view: | 'Account' | 'AccountSettings' - | 'SelectAddresses' | 'AllWallets' | 'ApproveTransaction' | 'BuyInProgress' diff --git a/packages/scaffold-ui/exports/index.ts b/packages/scaffold-ui/exports/index.ts index d03ca1ac71..d1d1221b03 100644 --- a/packages/scaffold-ui/exports/index.ts +++ b/packages/scaffold-ui/exports/index.ts @@ -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' diff --git a/packages/scaffold-ui/src/modal/w3m-router/index.ts b/packages/scaffold-ui/src/modal/w3m-router/index.ts index f8e0e5666a..1f1f376d44 100644 --- a/packages/scaffold-ui/src/modal/w3m-router/index.ts +++ b/packages/scaffold-ui/src/modal/w3m-router/index.ts @@ -101,8 +101,6 @@ export class W3mRouter extends LitElement { return html`` case 'Profile': return html`` - case 'SelectAddresses': - return html`` case 'SwitchAddress': return html`` case 'Transactions': diff --git a/packages/scaffold-ui/src/partials/w3m-header/index.ts b/packages/scaffold-ui/src/partials/w3m-header/index.ts index 6c4b10115a..add7acb012 100644 --- a/packages/scaffold-ui/src/partials/w3m-header/index.ts +++ b/packages/scaffold-ui/src/partials/w3m-header/index.ts @@ -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', @@ -212,7 +211,7 @@ export class W3mHeader extends LitElement { return html`` diff --git a/packages/scaffold-ui/src/views/w3m-connecting-wc-view/index.ts b/packages/scaffold-ui/src/views/w3m-connecting-wc-view/index.ts index 270ad271e6..81e05615e2 100644 --- a/packages/scaffold-ui/src/views/w3m-connecting-wc-view/index.ts +++ b/packages/scaffold-ui/src/views/w3m-connecting-wc-view/index.ts @@ -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() diff --git a/packages/scaffold-ui/src/views/w3m-email-verify-otp-view/index.ts b/packages/scaffold-ui/src/views/w3m-email-verify-otp-view/index.ts index 54dd5c30a4..8224bddbe7 100644 --- a/packages/scaffold-ui/src/views/w3m-email-verify-otp-view/index.ts +++ b/packages/scaffold-ui/src/views/w3m-email-verify-otp-view/index.ts @@ -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) @@ -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' }) diff --git a/packages/scaffold-ui/src/views/w3m-profile-view/index.ts b/packages/scaffold-ui/src/views/w3m-profile-view/index.ts index 8a41480ce5..f7ec66e535 100644 --- a/packages/scaffold-ui/src/views/w3m-profile-view/index.ts +++ b/packages/scaffold-ui/src/views/w3m-profile-view/index.ts @@ -145,7 +145,7 @@ export class W3mProfileView extends LitElement { : html` this.onSwitchAccount(account)} >Switch { - this.allAccounts = allAccounts - }) - } - - // -- Render -------------------------------------------- // - public override render() { - return html` - - - - - Select all - - - - ${this.allAccounts.map(account => this.getAddressTemplate(account))} - - - - Cancel - - - ${this.isApproving ? 'Signing...' : 'Continue'} - - - ` - } - - // -- Private ------------------------------------------- // - - private getAddressTemplate = (account: AccountType) => { - const checked = this.selectedAccounts.some(_account => _account.address === account.address) - - return html` - - ` - } - - private onSelectAll = (event: Event) => { - const checked = (event.target as HTMLInputElement).checked - this.selectAll = this.selectedAccounts.length === this.allAccounts.length - this.allAccounts.forEach(account => { - this.onSelect(account, checked) - }) - } - - private onSelect = (account: AccountType, add: boolean) => { - if (add) { - this.selectedAccounts.push(account) - } else { - this.selectedAccounts = this.selectedAccounts.filter(a => a.address !== account.address) - } - if (this.selectedAccounts.length > 0) { - this.selectAll = this.selectedAccounts.length === this.allAccounts.length - } - } - - private handleClick(account: AccountType) { - return (event: Event) => { - const target = event.target as HTMLInputElement - this.onSelect?.({ ...account }, target?.checked) - } - } - - private onContinue() { - if (this.selectedAccounts.length > 0) { - this.isApproving = true - AccountController.setAllAccounts(this.selectedAccounts, ChainController.state.activeChain) - AccountController.setShouldUpdateToAddress( - this.selectedAccounts[0]?.address ?? '', - ChainController.state.activeChain - ) - this.approved = true - this.isApproving = false - ModalController.close() - } else { - this.onCancel() - } - } - - private async onCancel() { - const { isConnected } = AccountController.state - if (isConnected) { - await ConnectionController.disconnect() - ModalController.close() - } else { - RouterController.push('Connect') - } - } - public override disconnectedCallback() { - super.disconnectedCallback() - if (!this.approved) { - this.onCancel() - } - } -} - -declare global { - interface HTMLElementTagNameMap { - 'w3m-select-addresses-view': W3mSelectAddressesView - } -} diff --git a/packages/scaffold-ui/src/views/w3m-select-addresses-view/styles.ts b/packages/scaffold-ui/src/views/w3m-select-addresses-view/styles.ts deleted file mode 100644 index 0a60778245..0000000000 --- a/packages/scaffold-ui/src/views/w3m-select-addresses-view/styles.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { css } from 'lit' - -export default css` - input[type='checkbox'] { - all: revert; - width: var(--wui-spacing-xl); - height: var(--wui-spacing-xl); - accent-color: var(--wui-color-accent-100); - } -` From 221c6289b049f27d67937b206e39e57d143b9f73 Mon Sep 17 00:00:00 2001 From: tomiir Date: Thu, 19 Sep 2024 17:53:54 -0300 Subject: [PATCH 2/4] chore: add changeset --- .changeset/sour-laws-divide.md | 38 ++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .changeset/sour-laws-divide.md diff --git a/.changeset/sour-laws-divide.md b/.changeset/sour-laws-divide.md new file mode 100644 index 0000000000..bef4916122 --- /dev/null +++ b/.changeset/sour-laws-divide.md @@ -0,0 +1,38 @@ +--- +'@reown/appkit-adapter-ethers5': patch +'@reown/appkit-adapter-ethers': patch +'@reown/appkit-adapter-solana': patch +'@reown/appkit-adapter-wagmi': patch +'@reown/appkit-utils': patch +'@reown/appkit-scaffold-ui': patch +'@apps/laboratory': patch +'@reown/appkit': patch +'@reown/appkit-common': patch +'@reown/appkit-wallet': patch +'@reown/appkit-core': patch +'@apps/demo': patch +'@apps/gallery': patch +'@examples/html-ethers': patch +'@examples/html-ethers5': patch +'@examples/html-wagmi': patch +'@examples/next-ethers': patch +'@examples/next-wagmi': patch +'@examples/react-ethers': patch +'@examples/react-ethers5': patch +'@examples/react-solana': patch +'@examples/react-wagmi': patch +'@examples/vue-ethers5': patch +'@examples/vue-solana': patch +'@examples/vue-wagmi': patch +'@reown/appkit-adapter-polkadot': patch +'@reown/appkit-cdn': patch +'@reown/appkit-ethers': patch +'@reown/appkit-ethers5': patch +'@reown/appkit-polyfills': patch +'@reown/appkit-siwe': patch +'@reown/appkit-solana': patch +'@reown/appkit-ui': patch +'@reown/appkit-wagmi': patch +--- + +Remove intermediate screen for multi address on auth wallet From d017800c9b9a7569a3a6e492aa1d3af31c038404 Mon Sep 17 00:00:00 2001 From: tomiir Date: Mon, 28 Oct 2024 13:13:02 +0100 Subject: [PATCH 3/4] chore: recreate changeset --- ...laws-divide.md => gold-needles-pretend.md} | 35 ++++++------------- 1 file changed, 10 insertions(+), 25 deletions(-) rename .changeset/{sour-laws-divide.md => gold-needles-pretend.md} (50%) diff --git a/.changeset/sour-laws-divide.md b/.changeset/gold-needles-pretend.md similarity index 50% rename from .changeset/sour-laws-divide.md rename to .changeset/gold-needles-pretend.md index bef4916122..d9d8f32833 100644 --- a/.changeset/sour-laws-divide.md +++ b/.changeset/gold-needles-pretend.md @@ -1,38 +1,23 @@ --- -'@reown/appkit-adapter-ethers5': patch -'@reown/appkit-adapter-ethers': patch -'@reown/appkit-adapter-solana': patch -'@reown/appkit-adapter-wagmi': patch -'@reown/appkit-utils': patch '@reown/appkit-scaffold-ui': patch -'@apps/laboratory': patch '@reown/appkit': patch -'@reown/appkit-common': patch -'@reown/appkit-wallet': patch '@reown/appkit-core': patch '@apps/demo': patch '@apps/gallery': patch -'@examples/html-ethers': patch -'@examples/html-ethers5': patch -'@examples/html-wagmi': patch -'@examples/next-ethers': patch -'@examples/next-wagmi': patch -'@examples/react-ethers': patch -'@examples/react-ethers5': patch -'@examples/react-solana': patch -'@examples/react-wagmi': patch -'@examples/vue-ethers5': patch -'@examples/vue-solana': patch -'@examples/vue-wagmi': patch +'@apps/laboratory': patch +'@reown/appkit-adapter-ethers': patch +'@reown/appkit-adapter-ethers5': patch '@reown/appkit-adapter-polkadot': patch +'@reown/appkit-adapter-solana': patch +'@reown/appkit-adapter-wagmi': patch +'@reown/appkit-utils': patch '@reown/appkit-cdn': patch -'@reown/appkit-ethers': patch -'@reown/appkit-ethers5': patch +'@reown/appkit-common': patch +'@reown/appkit-experimental': patch '@reown/appkit-polyfills': patch '@reown/appkit-siwe': patch -'@reown/appkit-solana': patch '@reown/appkit-ui': patch -'@reown/appkit-wagmi': patch +'@reown/appkit-wallet': patch --- -Remove intermediate screen for multi address on auth wallet +Removes intermediate screen for Embedded Wallet multi-account From 669fad702f642af20e1e2faa866d293242390dba Mon Sep 17 00:00:00 2001 From: tomiir Date: Wed, 30 Oct 2024 11:43:41 +0100 Subject: [PATCH 4/4] fix: dont close if siwe is enabled --- .../src/views/w3m-email-verify-otp-view/index.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/scaffold-ui/src/views/w3m-email-verify-otp-view/index.ts b/packages/scaffold-ui/src/views/w3m-email-verify-otp-view/index.ts index 794859e785..084202e630 100644 --- a/packages/scaffold-ui/src/views/w3m-email-verify-otp-view/index.ts +++ b/packages/scaffold-ui/src/views/w3m-email-verify-otp-view/index.ts @@ -5,7 +5,8 @@ import { EventsController, ConnectionController, ModalController, - ChainController + ChainController, + OptionsController } from '@reown/appkit-core' @customElement('w3m-email-verify-otp-view') @@ -31,7 +32,9 @@ export class W3mEmailVerifyOtpView extends W3mEmailOtpWidget { event: 'CONNECT_SUCCESS', properties: { method: 'email', name: this.authConnector.name || 'Unknown' } }) - ModalController.close() + if (!OptionsController.state.isSiweEnabled) { + ModalController.close() + } } } catch (error) { EventsController.sendEvent({ type: 'track', event: 'EMAIL_VERIFICATION_CODE_FAIL' })