UNPKG

@abstract-foundation/agw-client

Version:
51 lines 2.75 kB
import { type Account, type Address, type Chain, type Client, type IsUndefined, type MaybeRequired, type Transport } from "viem"; import type { ChainEIP712 } from "viem/zksync"; export interface GetLinkedAgwReturnType { agw: Address | undefined; } export type GetLinkedAgwParameters<account extends Account | undefined = Account | undefined> = MaybeRequired<{ address?: Address | undefined; }, IsUndefined<account>>; export type GetLinkedAgwAction<account extends Account | undefined = Account | undefined> = IsUndefined<account> extends true ? (parameters: GetLinkedAgwParameters<account>) => Promise<GetLinkedAgwReturnType> : (parameters?: GetLinkedAgwParameters<account>) => Promise<GetLinkedAgwReturnType>; export interface IsLinkedAccountParameters { address: Address; } /** * Get the linked Abstract Global Wallet for an Ethereum Mainnet address. * * @example * ```tsx * import { linkableWalletActions } from "@abstract-foundation/agw-client"; * import { createWalletClient, custom } from "viem"; * import { sepolia } from "viem/chains"; * * export default function CheckLinkedWallet() { * async function checkLinkedWallet() { * // Initialize a Viem Wallet client and extend it with linkableWalletActions * const client = createWalletClient({ * chain: sepolia, * transport: custom(window.ethereum!), * }).extend(linkableWalletActions()); * * // Check if an address has a linked AGW * const { agw } = await client.getLinkedAgw(); * * if (agw) { * console.log("Linked AGW:", agw); * } else { * console.log("No linked AGW found"); * } * } * * return <button onClick={checkLinkedWallet}>Check Linked AGW</button>; * } * ``` * * @param parameters - Parameters for getting the linked AGW. If the client has a connected account, this can be omitted * @param parameters.address - The Ethereum Mainnet address to check for a linked AGW. If not provided, defaults to the connected account's address * @returns Object containing the address of the linked AGW, or undefined if no AGW is linked */ export declare function getLinkedAgw<chain extends Chain | undefined = Chain | undefined>(client: Client<Transport, chain, undefined>, parameters: GetLinkedAgwParameters<undefined>): Promise<GetLinkedAgwReturnType>; export declare function getLinkedAgw<chain extends Chain | undefined = Chain | undefined, account extends Account = Account>(client: Client<Transport, chain, account>, parameters?: GetLinkedAgwParameters<account>): Promise<GetLinkedAgwReturnType>; export declare function isLinkedAccount(client: Client<Transport, ChainEIP712, Account>, parameters: IsLinkedAccountParameters): Promise<boolean>; //# sourceMappingURL=getLinkedAgw.d.ts.map