diff --git a/account-kit/core/src/actions/createAccount.ts b/account-kit/core/src/actions/createAccount.ts index effb56e0ec..e4121227db 100644 --- a/account-kit/core/src/actions/createAccount.ts +++ b/account-kit/core/src/actions/createAccount.ts @@ -21,6 +21,7 @@ import type { import { getBundlerClient } from "./getBundlerClient.js"; import { getSigner } from "./getSigner.js"; import { getSignerStatus } from "./getSignerStatus.js"; +import type { GetAccountParams } from "./getAccount"; type OmitSignerTransportChain = Omit; @@ -75,7 +76,7 @@ export type CreateAccountParams = { * @returns {Promise} A promise that resolves to the created account object */ export async function createAccount( - { type, accountParams: params }: CreateAccountParams, + params: CreateAccountParams, config: AlchemyAccountsConfig ): Promise { const store = config.store; @@ -83,6 +84,7 @@ export async function createAccount( if (!accounts) { throw new ClientOnlyPropertyError("account"); } + const accountConfigs = store.getState().accountConfigs; const bundlerClient = getBundlerClient(config); const transport = custom(bundlerClient); @@ -94,102 +96,106 @@ export async function createAccount( throw new Error("Signer not connected"); } - const cachedAccount = accounts[chain.id]?.[type]; + const cachedAccount = accounts[chain.id]?.[params.type]; if (cachedAccount.status !== "RECONNECTING" && cachedAccount.account) { return cachedAccount.account; } - const cachedConfig = store.getState().accountConfigs[chain.id]?.[type]; const accountPromise = (() => { - switch (type) { - case "LightAccount": - return createLightAccount({ - ...params, - ...cachedConfig, - signer, - transport: (opts) => transport({ ...opts, retryCount: 0 }), - chain, - }).then((account) => { - CoreLogger.trackEvent({ - name: "account_initialized", - data: { - accountType: "LightAccount", - accountVersion: account.getLightAccountVersion(), - }, - }); - - return account; + if (isLightAccountParams(params)) { + return createLightAccount({ + ...accountConfigs[chain.id]?.[params.type], + ...params.accountParams, + signer, + transport: (opts) => transport({ ...opts, retryCount: 0 }), + chain, + }).then((account) => { + CoreLogger.trackEvent({ + name: "account_initialized", + data: { + accountType: "LightAccount", + accountVersion: account.getLightAccountVersion(), + }, }); - case "MultiOwnerLightAccount": - return createMultiOwnerLightAccount({ - ...(params as AccountConfig<"MultiOwnerLightAccount">), - ...(cachedConfig as OmitSignerTransportChain), - signer, - transport: (opts) => transport({ ...opts, retryCount: 0 }), - chain, - }).then((account) => { - CoreLogger.trackEvent({ - name: "account_initialized", - data: { - accountType: "MultiOwnerLightAccount", - accountVersion: account.getLightAccountVersion(), - }, - }); - return account; + return account; + }); + } else if (isMultiOwnerLightAccountParams(params)) { + return createMultiOwnerLightAccount({ + ...accountConfigs[chain.id]?.[params.type], + ...params.accountParams, + signer, + transport: (opts) => transport({ ...opts, retryCount: 0 }), + chain, + }).then((account) => { + CoreLogger.trackEvent({ + name: "account_initialized", + data: { + accountType: "MultiOwnerLightAccount", + accountVersion: account.getLightAccountVersion(), + }, }); - case "MultiOwnerModularAccount": - return createMultiOwnerModularAccount({ - ...(params as AccountConfig<"MultiOwnerModularAccount">), - ...(cachedConfig as OmitSignerTransportChain), - signer, - transport: (opts) => transport({ ...opts, retryCount: 0 }), - chain, - }).then((account) => { - CoreLogger.trackEvent({ - name: "account_initialized", - data: { - accountType: "MultiOwnerModularAccount", - accountVersion: "v1.0.0", - }, - }); - - return account; + return account; + }); + } else if (isMultiOwnerModularAccountParams(params)) { + return createMultiOwnerModularAccount({ + ...accountConfigs[chain.id]?.[params.type], + ...params.accountParams, + signer, + transport: (opts) => transport({ ...opts, retryCount: 0 }), + chain, + }).then((account) => { + CoreLogger.trackEvent({ + name: "account_initialized", + data: { + accountType: "MultiOwnerModularAccount", + accountVersion: "v1.0.0", + }, }); - case "ModularAccountV2": - return createModularAccountV2({ - ...(params as AccountConfig<"ModularAccountV2">), - ...(cachedConfig as OmitSignerTransportChain), - signer, - transport: (opts) => transport({ ...opts, retryCount: 0 }), - chain, - }).then((account) => { - CoreLogger.trackEvent({ - name: "account_initialized", - data: { - accountType: "ModularAccountV2", - accountVersion: "v2.0.0", - }, - }); - - return account; + return account; + }); + } else if (isModularV2AccountParams(params)) { + return createModularAccountV2({ + ...accountConfigs[chain.id]?.[params.type], + ...params.accountParams, + signer, + transport: (opts) => transport({ ...opts, retryCount: 0 }), + chain, + }).then((account) => { + CoreLogger.trackEvent({ + name: "account_initialized", + data: { + accountType: "ModularAccountV2", + accountVersion: "v2.0.0", + }, }); - default: - throw new Error("Unsupported account type"); + return account; + }); + } else { + throw new Error(`Unsupported account type: ${params.type}`); } })(); if (cachedAccount.status !== "RECONNECTING") { - store.setState(() => ({ + store.setState((state) => ({ accounts: { ...accounts, [chain.id]: { ...accounts[chain.id], - [type]: { + [params.type]: { status: "INITIALIZING", account: accountPromise, }, }, }, + accountConfigs: { + ...state.accountConfigs, + [chain.id]: { + ...state.accountConfigs[chain.id], + [params.type]: { + ...params.accountParams, + }, + }, + }, })); } @@ -201,7 +207,7 @@ export async function createAccount( ...accounts, [chain.id]: { ...accounts[chain.id], - [type]: { + [params.type]: { status: "READY", account, }, @@ -211,8 +217,8 @@ export async function createAccount( ...state.accountConfigs, [chain.id]: { ...state.accountConfigs[chain.id], - [type]: { - ...params, + [params.type]: { + ...params.accountParams, accountAddress: account.address, initCode, }, @@ -225,7 +231,7 @@ export async function createAccount( ...accounts, [chain.id]: { ...accounts[chain.id], - [type]: { + [params.type]: { status: "ERROR", error, }, @@ -236,3 +242,27 @@ export async function createAccount( return accountPromise; } + +export const isModularV2AccountParams = ( + params: CreateAccountParams +): params is GetAccountParams<"ModularAccountV2"> => { + return params.type === "ModularAccountV2"; +}; + +export const isLightAccountParams = ( + params: CreateAccountParams +): params is GetAccountParams<"LightAccount"> => { + return params.type === "LightAccount"; +}; + +export const isMultiOwnerLightAccountParams = ( + params: CreateAccountParams +): params is GetAccountParams<"MultiOwnerLightAccount"> => { + return params.type === "MultiOwnerLightAccount"; +}; + +export const isMultiOwnerModularAccountParams = ( + params: CreateAccountParams +): params is GetAccountParams<"MultiOwnerModularAccount"> => { + return params.type === "MultiOwnerModularAccount"; +}; diff --git a/account-kit/core/src/actions/getAccount.ts b/account-kit/core/src/actions/getAccount.ts index b52b62b385..28620615ab 100644 --- a/account-kit/core/src/actions/getAccount.ts +++ b/account-kit/core/src/actions/getAccount.ts @@ -1,6 +1,10 @@ +import { defaultAccountState } from "../store/store.js"; import type { AccountState } from "../store/types.js"; import type { AlchemyAccountsConfig, SupportedAccountTypes } from "../types.js"; -import { type CreateAccountParams } from "./createAccount.js"; +import { + isModularV2AccountParams, + type CreateAccountParams, +} from "./createAccount.js"; import { getChain } from "./getChain.js"; export type GetAccountResult = @@ -28,17 +32,24 @@ export type GetAccountParams = * @returns {GetAccountResult} The result which includes the account if found and its status */ export const getAccount = ( - { type }: GetAccountParams, + params: GetAccountParams, config: AlchemyAccountsConfig ): GetAccountResult => { const accounts = config.store.getState().accounts; const chain = getChain(config); - const account = accounts?.[chain.id]?.[type]; + const account = accounts?.[chain.id]?.[params.type]; if (!account) { - return { - account: undefined, - status: "DISCONNECTED", - }; + return defaultAccountState(); + } + + if (isModularV2AccountParams(params) && account?.status === "READY") { + const accountConfig = + config.store.getState().accountConfigs[chain.id]?.[params.type]; + const haveMode = accountConfig?.mode ?? "default"; + const wantMode = params.accountParams?.mode ?? "default"; + if (haveMode !== wantMode) { + return defaultAccountState(); + } } return account; diff --git a/account-kit/core/src/actions/getSmartAccountClient.ts b/account-kit/core/src/actions/getSmartAccountClient.ts index da0374333c..a26566eb01 100644 --- a/account-kit/core/src/actions/getSmartAccountClient.ts +++ b/account-kit/core/src/actions/getSmartAccountClient.ts @@ -28,7 +28,7 @@ import type { SupportedAccounts, SupportedAccountTypes, } from "../types"; -import { createAccount } from "./createAccount.js"; +import { createAccount, isModularV2AccountParams } from "./createAccount.js"; import { getAccount, type GetAccountParams } from "./getAccount.js"; import { getAlchemyTransport } from "./getAlchemyTransport.js"; import { getConnection } from "./getConnection.js"; @@ -142,8 +142,9 @@ export function getSmartAccountClient( signerStatus.isAuthenticating || signerStatus.isInitializing ) { - if (!account && signerStatus.isConnected) + if (!account && signerStatus.isConnected) { createAccount({ type, accountParams }, config); + } if (clientState && clientState.isLoadingClient) { return clientState; @@ -220,9 +221,8 @@ export function getSmartAccountClient( }; case "ModularAccountV2": const is7702 = - params.accountParams && - "mode" in params.accountParams && - params.accountParams.mode === "7702"; + isModularV2AccountParams(params) && + params.accountParams?.mode === "7702"; return { client: createAlchemySmartAccountClient({ transport, diff --git a/examples/ui-demo/src/app/config.tsx b/examples/ui-demo/src/app/config.tsx index 1075e3e0e7..8b797b4ea7 100644 --- a/examples/ui-demo/src/app/config.tsx +++ b/examples/ui-demo/src/app/config.tsx @@ -40,14 +40,11 @@ export type Config = { } | undefined; }; - walletType: WalletTypes; + accountMode: AccountMode; supportUrl?: string; }; -export enum WalletTypes { - smart = "smart", - hybrid7702 = "7702", -} +export type AccountMode = "default" | "7702"; export const DEFAULT_CONFIG: Config = { auth: { @@ -77,7 +74,7 @@ export const DEFAULT_CONFIG: Config = { logoLight: undefined, logoDark: undefined, }, - walletType: WalletTypes.smart, + accountMode: "default", }; export const queryClient = new QueryClient(); diff --git a/examples/ui-demo/src/components/configuration/Configuration.tsx b/examples/ui-demo/src/components/configuration/Configuration.tsx index bf3efba406..e97d3089b0 100644 --- a/examples/ui-demo/src/components/configuration/Configuration.tsx +++ b/examples/ui-demo/src/components/configuration/Configuration.tsx @@ -4,23 +4,37 @@ import { SettingsIcon } from "../icons/settings"; import { WalletTypeSwitch } from "../shared/WalletTypeSwitch"; import ExternalLink from "../shared/ExternalLink"; import { useConfigStore } from "@/state"; -import { WalletTypes } from "@/app/config"; -import { useChain } from "@account-kit/react"; +import { + useAccount, + useChain, + useSmartAccountClient, + useUser, +} from "@account-kit/react"; import { arbitrumSepolia } from "@account-kit/infra"; import { odyssey } from "@/hooks/7702/transportSetup"; +import { useMemo } from "react"; export const Configuration = ({ className }: { className?: string }) => { - const { setWalletType, walletType } = useConfigStore(); + const { setAccountMode, accountMode } = useConfigStore(); const { setChain } = useChain(); + const clientParams = useMemo( + () => ({ + type: "ModularAccountV2" as const, + accountParams: { + mode: accountMode, + }, + }), + [accountMode] + ); + const { isLoadingAccount } = useAccount(clientParams); + const { isLoadingClient } = useSmartAccountClient(clientParams); + const user = useUser(); const onSwitchWalletType = () => { - const newValue = - walletType === WalletTypes.smart - ? WalletTypes.hybrid7702 - : WalletTypes.smart; - setWalletType(newValue); + const newMode = accountMode === "default" ? "7702" : "default"; + setAccountMode(newMode); setChain({ - chain: newValue === WalletTypes.smart ? arbitrumSepolia : odyssey, + chain: newMode === "default" ? arbitrumSepolia : odyssey, }); }; @@ -41,8 +55,9 @@ export const Configuration = ({ className }: { className?: string }) => {

EIP-7702 adds smart account features to an EOA wallet.{" "} diff --git a/examples/ui-demo/src/components/small-cards/MintCard.tsx b/examples/ui-demo/src/components/small-cards/MintCard.tsx index d5f60b3af0..973d257f8f 100644 --- a/examples/ui-demo/src/components/small-cards/MintCard.tsx +++ b/examples/ui-demo/src/components/small-cards/MintCard.tsx @@ -1,11 +1,12 @@ import { LoadingIcon } from "@/components/icons/loading"; -import { UseMintReturn } from "@/hooks/useMintDefault"; +import { UseMintReturn } from "@/hooks/useMint"; import { nftContractAddress, nftContractAddressOdyssey } from "@/utils/config"; import Image from "next/image"; -import { useMintDefault } from "@/hooks/useMintDefault"; +import { useMint } from "@/hooks/useMint"; import { Button } from "./Button"; import { MintStages } from "./MintStages"; -import { useMint7702 } from "@/hooks/useMint7702"; +import { odyssey } from "@/hooks/7702/transportSetup"; +import { arbitrumSepolia } from "@account-kit/infra"; type NFTLoadingState = "initial" | "loading" | "success"; @@ -16,15 +17,19 @@ export type MintStatus = { }; export const MintCardDefault = () => { - const mint = useMintDefault({ + const mint = useMint({ + mode: "default", contractAddress: nftContractAddress, + chain: arbitrumSepolia, }); return ; }; export const MintCard7702 = () => { - const mint = useMint7702({ + const mint = useMint({ + mode: "7702", contractAddress: nftContractAddressOdyssey, + chain: odyssey, }); return ; }; diff --git a/examples/ui-demo/src/components/small-cards/Wrapper.tsx b/examples/ui-demo/src/components/small-cards/Wrapper.tsx index 70b8aaeabc..e7642d19d3 100644 --- a/examples/ui-demo/src/components/small-cards/Wrapper.tsx +++ b/examples/ui-demo/src/components/small-cards/Wrapper.tsx @@ -1,5 +1,4 @@ import { useConfigStore } from "@/state"; -import { WalletTypes } from "@/app/config"; import { MintCard7702, MintCardDefault } from "./MintCard"; import { TransactionsCard7702, @@ -7,11 +6,11 @@ import { } from "./TransactionsCard"; export const SmallCardsWrapper = () => { - const { walletType } = useConfigStore(); + const { accountMode } = useConfigStore(); return (

- {walletType === WalletTypes.smart ? ( + {accountMode === "default" ? ( <> diff --git a/examples/ui-demo/src/components/user-connection-avatar/RenderUserConnectionAvatar.tsx b/examples/ui-demo/src/components/user-connection-avatar/RenderUserConnectionAvatar.tsx index 1b7426d9d8..c1fa3089f7 100644 --- a/examples/ui-demo/src/components/user-connection-avatar/RenderUserConnectionAvatar.tsx +++ b/examples/ui-demo/src/components/user-connection-avatar/RenderUserConnectionAvatar.tsx @@ -6,7 +6,6 @@ import React, { useEffect, useState } from "react"; import { useAccount, useSigner } from "@account-kit/react"; import { useQuery } from "@tanstack/react-query"; import { useConfigStore } from "@/state"; -import { WalletTypes } from "@/app/config"; import { createPublicClient, Hex, http } from "viem"; import { odysseyTestnet } from "viem/chains"; @@ -18,10 +17,16 @@ export const RenderUserConnectionAvatar = ( props: React.HTMLAttributes ) => { const [autoRefresh, setAutoRefresh] = useState(true); + const { accountMode } = useConfigStore(({ accountMode }) => ({ + accountMode, + })); const { account } = useAccount({ type: "ModularAccountV2", + accountParams: { + mode: accountMode, + }, + skipCreate: true, }); - const { walletType } = useConfigStore(); const [publicClient] = useState(() => createPublicClient({ @@ -76,7 +81,7 @@ export const RenderUserConnectionAvatar = (
{ const { theme, primaryColor } = useConfigStore( - ({ ui: { theme, primaryColor } }) => ({ + ({ ui: { theme, primaryColor }, accountMode }) => ({ theme, primaryColor, }) ); const user = useUser(); - const { address: SCAUserAddress } = useAccount({ - type: "ModularAccountV2", - }); const isEOAUser = user?.type === "eoa"; @@ -38,10 +33,7 @@ const UserConnectionAvatar = ({ return (
- + {showDeploymentStatus && (
({ + const { theme, primaryColor, accountMode } = useConfigStore( + ({ ui: { theme, primaryColor }, accountMode }) => ({ theme, primaryColor, - walletType, + accountMode, }) ); - const scaAccount = useAccount({ type: "ModularAccountV2" }); + const scaAccount = useAccount({ + type: "ModularAccountV2", + accountParams: { + mode: accountMode, + }, + skipCreate: true, + }); const isEOAUser = user?.type === "eoa"; @@ -78,19 +83,12 @@ export function UserConnectionDetails({ {/* Smart Account */}
- {walletType === WalletTypes.smart ? "Smart account" : "Address"} + {accountMode === "default" ? "Smart account" : "Address"} - +
- {walletType === WalletTypes.smart ? ( + {accountMode === "default" ? ( <> {/* Status */}
diff --git a/examples/ui-demo/src/hooks/useMintDefault.tsx b/examples/ui-demo/src/hooks/useMint.tsx similarity index 90% rename from examples/ui-demo/src/hooks/useMintDefault.tsx rename to examples/ui-demo/src/hooks/useMint.tsx index 2d5f6ccc7e..094ff0acb5 100644 --- a/examples/ui-demo/src/hooks/useMintDefault.tsx +++ b/examples/ui-demo/src/hooks/useMint.tsx @@ -4,8 +4,9 @@ import { useToast } from "./useToast"; import { useSmartAccountClient, useSendUserOperation, + useChain, } from "@account-kit/react"; -import { Address, encodeFunctionData } from "viem"; +import { Address, Chain, encodeFunctionData } from "viem"; import { AccountKitNftMinterABI } from "@/utils/config"; import { MintStatus } from "@/components/small-cards/MintCard"; @@ -24,22 +25,27 @@ export interface UseMintReturn { transactionUrl?: string; } -// TODO(jh): Once the client supports switching b/w default -// & 7702 modes, this hook should support both modes. -export const useMintDefault = (props: { +export const useMint = (props: { contractAddress: Address; + mode: "default" | "7702"; + chain: Chain; }): UseMintReturn => { + const { chain: activeChain, isSettingChain } = useChain(); + const { client, isLoadingClient } = useSmartAccountClient({ type: "ModularAccountV2", accountParams: { - mode: "default", + mode: props.mode, }, }); const [status, setStatus] = useState(initialValuePropState); const [mintStarted, setMintStarted] = useState(false); const isLoading = - Object.values(status).some((x) => x === "loading") || isLoadingClient; + Object.values(status).some((x) => x === "loading") || + isLoadingClient || + isSettingChain || + activeChain !== props.chain; const { setToast } = useToast(); const handleSuccess = () => { diff --git a/examples/ui-demo/src/hooks/useMint7702.tsx b/examples/ui-demo/src/hooks/useMint7702.tsx deleted file mode 100644 index 7d099b2bbc..0000000000 --- a/examples/ui-demo/src/hooks/useMint7702.tsx +++ /dev/null @@ -1,141 +0,0 @@ -import { useQuery } from "@tanstack/react-query"; -import { AccountKitNftMinterABI } from "@/utils/config"; -import { useCallback, useState, useMemo } from "react"; -import { useToast } from "@/hooks/useToast"; -import { Address, encodeFunctionData, Hash } from "viem"; -import { MintStatus } from "@/components/small-cards/MintCard"; -import { UseMintReturn } from "./useMintDefault"; -import { useModularAccountV2Client } from "./useModularAccountV2Client"; -import { odyssey, splitOdysseyTransport } from "./7702/transportSetup"; - -const initialValuePropState = { - signing: "initial", - gas: "initial", - batch: "initial", -} satisfies MintStatus; - -export const useMint7702 = (props: { - contractAddress: Address; -}): UseMintReturn => { - const { client, isLoadingClient } = useModularAccountV2Client({ - mode: "7702", - chain: odyssey, - transport: splitOdysseyTransport, - }); - - const [status, setStatus] = useState(initialValuePropState); - const [mintStarted, setMintStarted] = useState(false); - const [txnHash, setTxnHash] = useState(undefined); - const isLoading = - Object.values(status).some((x) => x === "loading") || isLoadingClient; - const { setToast } = useToast(); - - const { data: uri } = useQuery({ - queryKey: ["contractURI", props.contractAddress], - queryFn: async () => { - const uri = await client?.readContract({ - address: props.contractAddress, - abi: AccountKitNftMinterABI, - functionName: "baseURI", - }); - return uri; - }, - enabled: !!client && !!client?.readContract, - }); - - const handleCollectNFT = useCallback(async () => { - const handleSuccess = (txnHash: Hash) => { - setStatus(() => ({ - batch: "success", - gas: "success", - signing: "success", - })); - setTxnHash(txnHash); - - setToast({ - type: "success", - text: ( - <> - - {`You've collected your NFT!`} - - - {`You've successfully collected your NFT! Refresh to mint - again.`} - - - ), - open: true, - }); - }; - - const handleError = (error: Error) => { - console.error(error); - setStatus(initialValuePropState); - setMintStarted(false); - setToast({ - type: "error", - text: "There was a problem with that action", - open: true, - }); - }; - - if (!client) { - console.error("no client"); - return; - } - - setTxnHash(undefined); - setMintStarted(true); - - setStatus({ - signing: "loading", - gas: "loading", - batch: "loading", - }); - - setTimeout(() => { - setStatus((prev) => ({ ...prev, signing: "success" })); - }, 500); - setTimeout(() => { - setStatus((prev) => ({ ...prev, gas: "success" })); - }, 750); - - const uoHash = await client.sendUserOperation({ - uo: { - target: props.contractAddress, - data: encodeFunctionData({ - abi: AccountKitNftMinterABI, - functionName: "mintTo", - args: [client.getAddress()], - }), - }, - }); - - const txnHash = await client - .waitForUserOperationTransaction(uoHash) - .catch((e) => { - handleError(e); - }); - - if (txnHash) { - handleSuccess(txnHash); - } - }, [client, props.contractAddress, setToast]); - - const transactionUrl = useMemo(() => { - if (!client?.chain?.blockExplorers || !txnHash) { - return undefined; - } - return `${client.chain.blockExplorers.default.url}/tx/${txnHash}`; - }, [client?.chain.blockExplorers, txnHash]); - - return { - isLoading, - status, - mintStarted, - handleCollectNFT, - uri, - transactionUrl, - }; -}; diff --git a/examples/ui-demo/src/hooks/useRecurringTransactions.ts b/examples/ui-demo/src/hooks/useRecurringTransactions.ts index 2ba52523d3..8ddb888ceb 100644 --- a/examples/ui-demo/src/hooks/useRecurringTransactions.ts +++ b/examples/ui-demo/src/hooks/useRecurringTransactions.ts @@ -18,7 +18,6 @@ import { TimeRangeModule, } from "@account-kit/smart-contracts/experimental"; import { SingleSignerValidationModule } from "@account-kit/smart-contracts/experimental"; -import { useModularAccountV2Client } from "./useModularAccountV2Client"; import { DEMO_USDC_ADDRESS, SWAP_VENUE_ADDRESS } from "./7702/dca/constants"; import { swapAbi } from "./7702/dca/abi/swap"; import { erc20MintableAbi } from "./7702/dca/abi/erc20Mintable"; @@ -26,6 +25,7 @@ import { genEntityId } from "./7702/genEntityId"; import { SESSION_KEY_VALIDITY_TIME_SECONDS } from "./7702/constants"; import { useToast } from "@/hooks/useToast"; import { AlchemyTransport } from "@account-kit/infra"; +import { useModularAccountV2Client } from "./useModularAccountV2Client"; export type CardStatus = "initial" | "setup" | "active" | "done"; diff --git a/examples/ui-demo/src/state/store.tsx b/examples/ui-demo/src/state/store.tsx index e99db24681..cc6f7b2327 100644 --- a/examples/ui-demo/src/state/store.tsx +++ b/examples/ui-demo/src/state/store.tsx @@ -1,4 +1,4 @@ -import { Config, DEFAULT_CONFIG, WalletTypes } from "@/app/config"; +import { AccountMode, Config, DEFAULT_CONFIG } from "@/app/config"; import { getSectionsForConfig } from "@/app/sections"; import { AuthCardHeader } from "@/components/shared/AuthCardHeader"; import { cookieStorage, parseCookie } from "@account-kit/core"; @@ -49,7 +49,7 @@ export type DemoState = Config & { ) => void; setTheme: (theme: Config["ui"]["theme"]) => void; setSupportUrl: (url: string) => void; - setWalletType: (walletType: WalletTypes) => void; + setAccountMode: (accountMode: AccountMode) => void; }; export const createDemoStore = (initialConfig: Config = DEFAULT_CONFIG) => { @@ -69,7 +69,7 @@ export const createDemoStore = (initialConfig: Config = DEFAULT_CONFIG) => { setTheme, setNftTransferred, nftTransferred, - setWalletType, + setAccountMode, ...config }) => config, skipHydration: true, @@ -143,9 +143,9 @@ function createInitialState( }, })); }, - setWalletType: (walletType: WalletTypes) => { + setAccountMode: (accountMode: AccountMode) => { set(() => ({ - walletType, + accountMode, })); }, });