"use client"; import { useAccountContext } from "../../../../core/account/provider.js"; /** * @component * @wallet */ export interface AccountAddressProps extends Omit, "children"> { /** * The function used to transform (format) the wallet address * Specifically useful for shortening the wallet. * * This function should take in a string and output a string */ formatFn?: (str: string) => string; } /** * * @returns a containing the full wallet address of the account * * @example * ### Basic usage * ```tsx * import { AccountProvider, AccountAddress } from "thirdweb/react"; * * * * * ``` * Result: * ```html * 0x12345674b599ce99958242b3D3741e7b01841DF3 * ``` * * * ### Shorten the address * ```tsx * import { AccountProvider, AccountAddress } from "thirdweb/react"; * import { shortenAddress } from "thirdweb/utils"; * * * * * ``` * Result: * ```html * 0x1234...1DF3 * ``` * * @component * @wallet * @beta */ export function AccountAddress({ formatFn, ...restProps }: AccountAddressProps) { const { address } = useAccountContext(); const value = formatFn ? formatFn(address) : address; return {value}; }