import type { Abi } from "abitype"; import { type GetContractReturnType, type PublicClient, type WalletClient } from "viem"; import type { Chain } from "../chains/types.js"; import type { ThirdwebClient } from "../client/client.js"; import { type ThirdwebContract } from "../contract/contract.js"; import type { Account, Wallet } from "../wallets/interfaces/wallet.js"; /** * Converts thirdweb accounts and contracts to viem wallet clients and contract objects or the other way around. * @example * * ### Converting a thirdweb account to a viem wallet client * * ```ts * import { viemAdapter } from "thirdweb/adapters/viem"; * * const walletClient = viemAdapter.walletClient.toViem({ * account, * client, * chain: ethereum, * }); * ``` * * ### Converting a viem wallet client to a thirdweb account * ```ts * import { viemAdapter } from "thirdweb/adapters"; * * const account = viemAdapter.walletClient.fromViem({ * walletClient, * }); * ``` * * ### Converting a thirdweb contract to a viem contract * ```ts * import { viemAdapter } from "thirdweb/adapters"; * const viemContract = await viemAdapter.contract.toViem({ thirdwebContract }); * ``` * * ### Converting a viem contract to a thirdweb contract * ```ts * import { viemAdapter } from "thirdweb/adapters/viem"; * * const contract = viemAdapter.contract.fromViem({ * viemContract: viemContract, * chain: ethereum, * client, * }); * ``` * * ### Converting a thirdweb client to a public viem client * ```ts * import { viemAdapter } from "thirdweb/adapters"; * * const publicClient = viemAdapter.publicClient.toViem({ * chain: ethereum, * client, * }); * ``` * */ export declare const viemAdapter: { /** * Creates a ThirdwebContract from a Viem contract or the other way around. * @param options - The options for creating the contract. * @returns The ThirdwebContract. * @example * * ### fromViem * * ```ts * import { viemAdapter } from "thirdweb/adapters/viem"; * * const contract = viemAdapter.contract.fromViem({ * viemContract: viemContract, * chain: ethereum, * client, * }); * ``` * * ### toViem * * ```ts * import { viemAdapter } from "thirdweb/adapters"; * const viemContract = await viemAdapter.contract.toViem({ thirdwebContract }); * ``` */ contract: { fromViem: typeof fromViemContract; toViem: typeof toViemContract; }; /** * Converts options to a Viem public client. * @param options - The options for creating the Viem public client. * @returns The Viem public client. * @example * ```ts * import { viemAdapter } from "thirdweb/adapters/viem"; * * const publicClient = viemAdapter.publicClient.toViem({ * chain: ethereum, * client, * }); * ``` */ publicClient: { toViem: typeof toViemPublicClient; }; /** * Converts a thirdweb account to a Viem Wallet client or the other way around. * @param options - The options for creating the Viem Wallet client. * @returns The Viem Wallet client. * @example * * ### toViem * ```ts * import { viemAdapter } from "thirdweb/adapters/viem"; * * const walletClient = viemAdapter.wallet.toViem({ * wallet, * client, * chain: ethereum, * }); * ``` * * ### fromViem * ```ts * import { viemAdapter } from "thirdweb/adapters"; * * const wallet = viemAdapter.wallet.fromViem({ * walletClient, * }); * ``` */ wallet: { /** * Converts a Viem wallet client to a Thirdweb wallet. * @param options - The options for converting a Viem wallet client to a Thirdweb wallet. * @param options.walletClient - The Viem wallet client to convert. * @returns A Promise that resolves to a Thirdweb wallet. * @example * ```ts * import { viemAdapter } from "thirdweb/adapters"; * const wallet = viemAdapter.wallet.fromViem({ walletClient }); * ``` */ fromViem: typeof walletFromViem; /** * Converts a Thirdweb wallet to a Viem wallet client. * @param options - The options for converting a Thirdweb wallet to a Viem wallet client. * @param options.wallet - The Thirdweb wallet to convert. * @returns A Promise that resolves to a Viem wallet client. * @example * ```ts * import { viemAdapter } from "thirdweb/adapters"; * const walletClient = viemAdapter.wallet.toViem({ wallet, client, chain }); * ``` */ toViem: typeof walletToViem; }; /** * Converts a thirdweb account to a Viem Wallet client or the other way around. * @param options - The options for creating the Viem Wallet client. * @returns The Viem Wallet client. * @example * * ### toViem * ```ts * import { viemAdapter } from "thirdweb/adapters/viem"; * * const walletClient = viemAdapter.walletClient.toViem({ * account, * client, * chain: ethereum, * }); * ``` * * ### fromViem * ```ts * import { viemAdapter } from "thirdweb/adapters"; * * const account = viemAdapter.walletClient.fromViem({ * walletClient, * }); * ``` * @deprecated use viemAdapter.wallet instead */ walletClient: { /** * Converts a Viem wallet client to a Thirdweb wallet. * @param options - The options for converting a Viem wallet client to a Thirdweb wallet. * @param options.walletClient - The Viem wallet client to convert. * @returns A Promise that resolves to a Thirdweb wallet. * @example * ```ts * import { viemAdapter } from "thirdweb/adapters"; * const account = viemAdapter.walletClient.fromViem({ walletClient }); * ``` * @deprecated use viemAdapter.wallet instead */ fromViem: typeof fromViemWalletClient; /** * Converts a Thirdweb wallet to a Viem wallet client. * @param options - The options for converting a Thirdweb wallet to a Viem wallet client. * @param options.account - The Thirdweb wallet to convert. * @returns A Promise that resolves to a Viem wallet client. * @example * ```ts * import { viemAdapter } from "thirdweb/adapters"; * const walletClient = viemAdapter.walletClient.toViem({ account, client, chain }); * ``` * @deprecated use viemAdapter.wallet instead */ toViem: typeof toViemWalletClient; }; }; type FromViemContractOptions = { client: ThirdwebClient; viemContract: GetContractReturnType; chain: Chain; }; declare function fromViemContract(options: FromViemContractOptions): ThirdwebContract; /** * @internal */ export declare function toViemContract(options: { thirdwebContract: ThirdwebContract; }): Promise>; type ToViemPublicClientOptions = { client: ThirdwebClient; chain: Chain; }; declare function toViemPublicClient(options: ToViemPublicClientOptions): PublicClient; type ToViemWalletClientOptions = { account: Account; client: ThirdwebClient; chain: Chain; }; declare function toViemWalletClient(options: ToViemWalletClientOptions): WalletClient; declare function fromViemWalletClient(options: { walletClient: WalletClient; }): Account; type WalletToViemOptions = { client: ThirdwebClient; chain: Chain; wallet: Wallet; }; declare function walletToViem(options: WalletToViemOptions): WalletClient; declare function walletFromViem(options: { walletClient: WalletClient; }): Wallet; export {}; //# sourceMappingURL=viem.d.ts.map