UNPKG

@turnkey/viem

Version:

Turnkey Helpers to work with Viem

88 lines 4.12 kB
import { BaseError } from "viem"; import { SignAuthorizationReturnType, SignAuthorizationParameters } from "viem/accounts"; import type { Hex, LocalAccount, SerializeTransactionFn, SignableMessage, TransactionSerializable, TypedData } from "viem"; import { TActivityStatus, TActivityId, TSignature, TurnkeyClient } from "@turnkey/http"; import type { TurnkeyBrowserClient } from "@turnkey/sdk-browser"; import type { TurnkeyServerClient } from "@turnkey/sdk-server"; export type TTurnkeyConsensusNeededErrorType = TurnkeyConsensusNeededError & { name: "TurnkeyConsensusNeededError"; }; export type TTurnkeyActivityErrorType = TurnkeyActivityError & { name: "TurnkeyActivityError"; }; type TSignAuthorizationParameters = Omit<SignAuthorizationParameters, "privateKey">; type TSignatureFormat = "object" | "bytes" | "hex"; export declare class TurnkeyConsensusNeededError extends BaseError { name: string; activityId: TActivityId | undefined; activityStatus: TActivityStatus | undefined; constructor({ message, activityId, activityStatus, }: { message?: string | undefined; activityId: TActivityId | undefined; activityStatus: TActivityStatus | undefined; }); } export declare class TurnkeyActivityError extends BaseError { name: string; activityId: TActivityId | undefined; activityStatus: TActivityStatus | undefined; constructor({ message, activityId, activityStatus, }: { message?: string | undefined; activityId?: TActivityId | undefined; activityStatus?: TActivityStatus | undefined; }); } export declare function createAccountWithAddress(input: { client: TurnkeyClient | TurnkeyBrowserClient | TurnkeyServerClient; organizationId: string; signWith: string; ethereumAddress?: string; }): LocalAccount; export declare function createAccount(input: { client: TurnkeyClient | TurnkeyBrowserClient | TurnkeyServerClient; organizationId: string; signWith: string; ethereumAddress?: string; }): Promise<LocalAccount>; /** * Type bundling configuration for an API Key Viem account creation * @deprecated this is used only with {@link createApiKeyAccount}, a deprecated API. See {@link createAccount}. */ type TApiKeyAccountConfig = { /** * Turnkey API public key */ apiPublicKey: string; /** * Turnkey API private key */ apiPrivateKey: string; /** * Turnkey API base URL */ baseUrl: string; /** * Turnkey organization ID */ organizationId: string; /** * Turnkey private key ID */ privateKeyId: string; }; /** * Creates a new Custom Account backed by a Turnkey API key. * @deprecated use {@link createAccount} instead. */ export declare function createApiKeyAccount(config: TApiKeyAccountConfig): Promise<LocalAccount>; export declare function signAuthorization(client: TurnkeyClient | TurnkeyBrowserClient | TurnkeyServerClient, parameters: TSignAuthorizationParameters, organizationId: string, signWith: string): Promise<SignAuthorizationReturnType>; export declare function signMessage(client: TurnkeyClient | TurnkeyBrowserClient | TurnkeyServerClient, message: SignableMessage, organizationId: string, signWith: string): Promise<Hex>; export declare function signTransaction<TTransactionSerializable extends TransactionSerializable>(client: TurnkeyClient | TurnkeyBrowserClient | TurnkeyServerClient, transaction: TTransactionSerializable, serializer: SerializeTransactionFn<TTransactionSerializable>, organizationId: string, signWith: string): Promise<Hex>; export declare function signTypedData(client: TurnkeyClient | TurnkeyBrowserClient | TurnkeyServerClient, data: TypedData | { [key: string]: unknown; }, organizationId: string, signWith: string): Promise<Hex>; export declare function serializeSignature(sig: TSignature, to?: TSignatureFormat): Uint8Array | `0x${string}1b` | `0x${string}1c`; export declare function isTurnkeyActivityConsensusNeededError(error: any): any; export declare function isTurnkeyActivityError(error: any): any; export {}; //# sourceMappingURL=index.d.ts.map