Skip to content

#Base Account SDK wallet and EIP-5792 extensions #608

@Dargon789

Description

@Dargon789

Reviewer's Guide

Implements "Last Used" surfacing across the Connect UI and social auth flows, adds Base Account SDK wallet integration, upgrades x402 payment protocol handling to support version 2 with header-based signatures, adds EIP-5792 raw call status support and fallbacks for zkSync gas estimation, and wires corresponding docs, examples, tests, and changelog/version bumps.

Class diagram for Base Account SDK wallet and EIP-5792 extensions

classDiagram
  class Wallet {
    <<interface>>
    +string id
    +Account getAccount()
    +Chain getChain()
    +Promise~Account~ connect(options)
    +Promise~Account~ autoConnect(options)
    +Promise void disconnect()
    +Promise void switchChain(chain)
    +subscribe(event, listener)
  }

  class Account {
    <<interface>>
    +string address
    +Promise sendTransaction(options)
    +Promise~string~ signMessage(message)
    +Promise~string~ signTypedData(typedData)
    +Promise sendCalls(options)
    +Promise~GetCallsStatusResponse~ getCallsStatus(options)
    +Promise~GetCallsStatusRawResponse~ getCallsStatusRaw(options)
    +Promise~WalletCapabilitiesResult~ getCapabilities(options)
  }

  class BaseAccountWalletCreationOptions {
    +AppMetadata appMetadata
    +Chain[] chains
  }

  class BaseAccountSDKWalletConnectionOptions {
    +ThirdwebClient client
    +Chain chain
  }

  class BaseAccountWallet {
    <<Wallet "org.base.account">>
    +string id
    +BaseAccountWalletCreationOptions getConfig()
    +Promise~Account~ connect(options)
    +Promise~Account~ autoConnect(options)
    +Promise void disconnect()
    +Promise void switchChain(chain)
    +Account getAccount()
    +Chain getChain()
  }

  class ProviderInterface {
    <<from @base-org/account>>
    +Promise~unknown~ request(request)
    +on(event, listener)
    +off(event, listener)
    +Promise void disconnect()
  }

  class GetCallsStatusRawResponse {
    +string id
    +string chainId
    +boolean atomic
    +int status
    +Receipt[] receipts
    +string version
  }

  class CoinbaseAccount {
    <<EIP-1193 wallet>>
    +Promise~GetCallsStatusRawResponse~ getCallsStatusRaw(options)
  }

  class InjectedAccount {
    <<EIP-1193 wallet>>
    +Promise~GetCallsStatusRawResponse~ getCallsStatusRaw(options)
  }

  class SmartAccount {
    <<Smart wallet>>
    +Promise~GetCallsStatusRawResponse~ getCallsStatusRaw(options)
  }

  class Minimal7702Account {
    <<EIP-7702 account>>
    +Promise~GetCallsStatusRawResponse~ getCallsStatusRaw(options)
  }

  class EnclaveWalletAccount {
    <<In-app enclave>>
    +Promise~GetCallsStatusRawResponse~ getCallsStatusRaw(options)
  }

  class ToEip1193Provider {
    +EIP1193Provider toProvider(options)
  }

  Wallet <|.. BaseAccountWallet
  Account <.. BaseAccountWallet : uses
  ProviderInterface <.. BaseAccountWallet : providerFactory
  GetCallsStatusRawResponse <.. Account
  Account <|.. CoinbaseAccount
  Account <|.. InjectedAccount
  Account <|.. SmartAccount
  Account <|.. Minimal7702Account
  Account <|.. EnclaveWalletAccount
  ToEip1193Provider --> Account : calls getCallsStatusRaw
Loading

Flow diagram for Last Used wallet and social auth persistence

flowchart TD
  subgraph Storage
    S1[localStorage
      LAST_USED_WALLET_ID]
    S2[localStorage
      LAST_AUTH_PROVIDER]
  end

  subgraph ConnectModalOpen
    O1[WalletSelector] --> O2[getLastUsedWalletId]
    O2 --> S1
    O1 --> O3[sortWallets]
    O3 -->|prioritize installed| O4
    O3 -->|then last used id| O5
    O5 --> WalletList

    WalletList -->|render| W1[WalletEntryButton]
    W1 -->|if wallet.id === lastUsedId| W2[badge = Last used]

    O1 --> C1[Connect a wallet button]
    C1 -->|prop lastUsedBadge
      when lastUsedId is non inApp non ecosystem| C2[Show LastUsedBadge]
  end

  subgraph SocialAuthOptions
    SA1[ConnectWalletSocialOptions]
    SA1 --> SA2[getLastUsedWalletId]
    SA1 --> SA3[getLastUsedSocialAuth]
    SA2 --> S1
    SA3 --> S2
    SA1 --> SA4[_authOptions]
    SA4 -->|if wallet.id == lastUsedId
      and lastUsedSocialAuth set| SA5[Sort auth options
      to put last used first]

    SA5 --> SA6[Render social buttons/InputSelectionUI]
    SA6 -->|if wallet.id and method match last used| SA7[Show LastUsedBadge]
  end

  subgraph OnSuccessfulConnect
    C10[ConnectionManager.connect]
    C10 --> C11[Set LAST_ACTIVE_EOA_ID]
    C10 --> C12[Set LAST_USED_WALLET_ID]
    C11 --> S1
    C12 --> S1

    SocialLoginSuccess --> C13[setLastAuthProvider]
    C13 --> S2
  end
Loading

File-Level Changes

Change Details Files
Add Base Account SDK wallet integration and typings, wired through createWallet and exports.
  • Introduce BASE_ACCOUNT wallet id constant and extend WalletId union and typed option helpers to support Base Account creation/connection/autoconnect types.
  • Implement Base Account SDK web provider and wallet wrappers that adapt @base-org/account ProviderInterface into thirdweb Wallet/Account, including EIP-155, EIP-712 signing, EIP-5792 sendCalls/getCallsStatus/getCapabilities, and chain switching.
  • Wire BASE_ACCOUNT into createWallet, exports, and include @base-org/account 2.5.0 dependency plus generated wallet metadata/icons for org.base.account.
packages/thirdweb/src/wallets/constants.ts
packages/thirdweb/src/wallets/wallet-types.ts
packages/thirdweb/src/wallets/create-wallet.ts
packages/thirdweb/src/exports/wallets.ts
packages/thirdweb/package.json
packages/thirdweb/src/wallets/base-account/base-account-web.ts
packages/thirdweb/src/wallets/base-account/base-account-wallet.ts
packages/thirdweb/src/wallets/__generated__/wallet/org.base.account/index.ts
packages/thirdweb/src/wallets/__generated__/wallet/org.base.account/image.ts
packages/thirdweb/scripts/wallets/extra-wallet-icons/base.svg
Surface and persist "Last used" wallet/auth method across Connect UI and social login, including badges and layout tweaks.
  • Persist LAST_USED_WALLET_ID in ConnectionManager whenever an EOA connects or becomes active, and expose browser helpers to read last used wallet and social auth strategy from localStorage.
  • Update wallet sorting and Connect UI to prioritize last used wallet and display a Last Used badge on the generic connect button, wallet list entries, and social auth methods (email/phone/passkey/SIWE/guest) including inputs; adjust layout paddings to reserve vertical space and avoid overlap.
  • Introduce reusable Badge/LastUsedBadge UI component and ensure all call sites (WalletTypeRowButton, InputSelectionUI, WalletConnectReceiverScreen) handle the new lastUsedBadge prop, plus Storybook stories for connect button variants.
packages/thirdweb/src/wallets/manager/index.ts
packages/thirdweb/src/react/web/ui/ConnectWallet/Modal/storage.ts
packages/thirdweb/src/react/web/utils/sortWallets.ts
packages/thirdweb/src/react/web/ui/ConnectWallet/WalletSelector.tsx
packages/thirdweb/src/react/web/ui/ConnectWallet/WalletTypeRowButton.tsx
packages/thirdweb/src/react/web/ui/ConnectWallet/WalletEntryButton.tsx
packages/thirdweb/src/react/web/wallets/shared/ConnectWalletSocialOptions.tsx
packages/thirdweb/src/react/web/wallets/in-app/InputSelectionUI.tsx
packages/thirdweb/src/react/web/wallets/in-app/InputSelectionUI.test.tsx
packages/thirdweb/src/react/web/ui/ConnectWallet/screens/WalletConnectReceiverScreen.tsx
packages/thirdweb/src/react/web/ui/components/badge.tsx
packages/thirdweb/src/stories/ConnectButton/others.stories.tsx
packages/thirdweb/src/stories/ConnectButton/themes.stories.tsx
Add redirect-based in-app profile linking flow and autoConnect handling for OAuth linking redirects.
  • Extend in-app auth login URL and URL token parsing to support an authFlow flag (connect
link) and ensure query params are cleaned from location after parsing.
  • Add linkProfileWithRedirect helper and InAppWebConnector.linkProfileWithRedirect that kick off OAuth redirect with authFlow=link, and have linkProfile short-circuit to redirect when given social strategies with redirect/window mode.
  • Implement handleLinkingFlow in autoConnectCore to auto-connect with stored credentials (ignoring URL auth token), then call linkAccount with the new social token, update auth provider, manage connection state flags, and invoke onConnect callbacks.
  • Add playground example wiring redirect-based GitHub linking and relax useLinkProfile refetch delay for more reliable profile refresh after linking.
  • Upgrade x402 payment protocol support to v2 with header-based signatures while maintaining v1 compatibility across types, encode/decode, facilitator, verify/settle helpers, and fetchWithPayment.
    • Introduce X402Version type, switch default x402Version to 2, split PaymentRequiredResult into v1 and v2 variants, and add helper functions to resolve correct request/response header names and encode PAYMENT-REQUIRED payloads.
    • Adjust facilitator.accepts to always return v1 body format but accept requested x402Version, add formatting helpers in decodePaymentRequest to return v2 header-based 402 responses by default, preserving client version where known and falling back to v2 for decode errors.
    • Update verifyPayment and settlePayment (and Nexus/portal/playground docs) to read from PAYMENT-SIGNATURE or X-PAYMENT headers, emit version-appropriate response headers (PAYMENT-RESPONSE/X-PAYMENT-RESPONSE) and x402Version fields, and update wrapFetchWithPayment and tests to use header helpers and versioned behaviors.
    • Adjust schemas and tests to allow both versions, prefer header-based payment-required metadata, and ensure retry requests use the version-appropriate request header and exposed response header.
    packages/thirdweb/src/x402/types.ts
    packages/thirdweb/src/x402/headers.ts
    packages/thirdweb/src/x402/encode.ts
    packages/thirdweb/src/x402/common.ts
    packages/thirdweb/src/x402/facilitator.ts
    packages/thirdweb/src/x402/verify-payment.ts
    packages/thirdweb/src/x402/settle-payment.ts
    packages/thirdweb/src/x402/fetchWithPayment.ts
    packages/thirdweb/src/x402/schemas.ts
    packages/thirdweb/src/x402/fetchWithPayment.test.ts
    apps/playground-web/src/app/api/paywall/route.ts
    apps/portal/src/app/x402/page.mdx
    apps/portal/src/app/x402/server/page.mdx
    apps/portal/src/app/x402/facilitator/page.mdx
    packages/nexus/src/verify-payment.ts
    packages/nexus/src/settle-payment.ts
    Enhance EIP-5792 support by exposing raw call status, propagating it through accounts/providers, and adapting the EIP-1193 adapter.
    • Extend Account interface with optional getCallsStatusRaw, implement it for in-app minimal, smart, zkSync, and enclave wallets using new inAppWalletGetCallsStatusRaw helper that reconstructs raw receipts for stored bundles.
    • Add getCallsStatusRaw implementations for Coinbase and injected wallets that call wallet_getCallsStatus and map unsupported errors to explicit messages, and change toProvider EIP-1193 adapter to call getCallsStatusRaw and return raw bundle status on wallet_getCallsStatus RPC requests.
    • Refactor wagmi-demo to use useWaitForCallsStatus hook with multiple calls, switch JSON.stringify to internal stringify helper, and adjust demo types to align with new 5792 responses.
    packages/thirdweb/src/wallets/interfaces/wallet.ts
    packages/thirdweb/src/wallets/in-app/core/eip5792/in-app-wallet-calls.ts
    packages/thirdweb/src/wallets/in-app/core/eip7702/minimal-account.ts
    packages/thirdweb/src/wallets/smart/index.ts
    packages/thirdweb/src/wallets/in-app/core/wallet/enclave-wallet.ts
    packages/thirdweb/src/wallets/coinbase/coinbase-web.ts
    packages/thirdweb/src/wallets/injected/index.ts
    packages/thirdweb/src/adapters/eip1193/to-eip1193.ts
    apps/wagmi-demo/src/App.tsx
    Improve zkSync gas estimation by handling chains that no longer expose zks_estimateFee.
    • Wrap zks_estimateFee usage in a try/catch and, on failure, fall back to standard EVM estimation via estimateGas and getDefaultGasOverrides, doubling gas and fee values similarly to the zkSync path and using a default gasPerPubdata.
    • Add a test that defines a zkSync-compatible chain without zks_ support and asserts the fallback path returns non-zero gas values and the expected default gasPerPubdata.
    packages/thirdweb/src/transaction/actions/zksync/send-eip712-transaction.ts
    packages/thirdweb/src/transaction/actions/zksync/send-eip712-transaction.test.ts
    Docs, examples, and versioning updates to reflect new features and dependencies.
    • Bump thirdweb core, nebula, wagmi-demo, and wagmi-adapter versions and add changelog entries capturing Base Account SDK integration, x402 v2, linking redirect support, zkSync fallback, and Connect UI UX updates including Last Used badge.
    • Add connect button Storybook stories for wide/compact modals and tweak dark theme story naming and theme overrides to better exercise new UI spacing/badge behavior.
    packages/thirdweb/CHANGELOG.md
    packages/thirdweb/package.json
    packages/nebula/CHANGELOG.md
    packages/nebula/package.json
    apps/wagmi-demo/CHANGELOG.md
    apps/wagmi-demo/package.json
    packages/wagmi-adapter/CHANGELOG.md
    packages/wagmi-adapter/package.json
    packages/thirdweb/src/stories/ConnectButton/others.stories.tsx
    packages/thirdweb/src/stories/ConnectButton/themes.stories.tsx

    Tips and commands

    Interacting with Sourcery

    • Trigger a new review: Comment @sourcery-ai review on the pull request.
    • Continue discussions: Reply directly to Sourcery's review comments.
    • Generate a GitHub issue from a review comment: Ask Sourcery to create an
      issue from a review comment by replying to it. You can also reply to a
      review comment with @sourcery-ai issue to create an issue from it.
    • Generate a pull request title: Write @sourcery-ai anywhere in the pull
      request title to generate a title at any time. You can also comment
      @sourcery-ai title on the pull request to (re-)generate the title at any time.
    • Generate a pull request summary: Write @sourcery-ai summary anywhere in
      the pull request body to generate a PR summary at any time exactly where you
      want it. You can also comment @sourcery-ai summary on the pull request to
      (re-)generate the summary at any time.
    • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
      request to (re-)generate the reviewer's guide at any time.
    • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
      pull request to resolve all Sourcery comments. Useful if you've already
      addressed all the comments and don't want to see them anymore.
    • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
      request to dismiss all existing Sourcery reviews. Especially useful if you
      want to start fresh with a new review - don't forget to comment
      @sourcery-ai review to trigger a new review!

    Customizing Your Experience

    Access your dashboard to:

    • Enable or disable review features such as the Sourcery-generated pull request
      summary, the reviewer's guide, and others.
    • Change the review language.
    • Add, remove or edit custom review instructions.
    • Adjust other review settings.

    Getting Help

    Originally posted by @sourcery-ai[bot] in #601 (comment)

    Metadata

    Metadata

    Assignees

    Projects

    Status

    Done

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions