UNPKG

accounts

Version:

Tempo Accounts SDK

77 lines 2.9 kB
import { type WebCryptoP256 } from 'ox'; import type { Hex } from 'viem'; import type { Address, JsonRpcAccount } from 'viem/accounts'; import { Account as TempoAccount } from 'viem/tempo'; import type { OneOf } from '../internal/types.js'; import type * as core_Store from './Store.js'; /** Account stored in the provider state. */ export type Store = { /** Account address. */ address: Address; /** Display label used during registration (e.g. email). */ label?: string | undefined; } & OneOf<{} | Pick<TempoAccount.Account, 'keyType' | 'sign'> | { keyType: 'secp256k1'; privateKey: Hex; } | { keyType: 'p256'; privateKey: Hex; } | { keyType: 'webAuthn'; credential: { id: string; publicKey: Hex; rpId: string; }; } | { keyType: 'webCrypto'; keyPair: Awaited<ReturnType<typeof WebCryptoP256.createKeyPair>>; } | { keyType: 'webAuthn_headless'; privateKey: Hex; rpId: string; origin: string; }>; /** * Maps a stored account's key type to the signature key type used on the wire. * * The node sizes intrinsic gas in `eth_fillTransaction` from the request's * `keyType`. Store-only key types (`webCrypto`, `webAuthn_headless`) sign with * a `p256` / `webAuthn` signature envelope respectively, so they must be * reported as their on-chain signature type — otherwise gas is underestimated. */ export declare function signatureKeyType(account: Store | undefined): 'secp256k1' | 'p256' | 'webAuthn' | undefined; /** Resolves a viem Account from the store by address (or active account). */ export declare function find(options: find.Options & { signable: true; }): TempoAccount.Account; export declare function find(options: find.Options): TempoAccount.Account | JsonRpcAccount; export declare namespace find { type Options = { /** Address to find. Defaults to the active account. */ address?: Address | undefined; /** Whether to hydrate signing capability. @default false */ signable?: boolean | undefined; /** Reactive state store. */ store: core_Store.Store; }; } /** Overloaded signature for `find` without `store` (pre-bound by the provider). */ export type Find = { (options: Omit<find.Options, 'store'> & { signable: true; }): TempoAccount.Account; (options?: Omit<find.Options, 'store'>): TempoAccount.Account | JsonRpcAccount; }; /** Hydrates a store account to a viem Account. */ export declare function hydrate(account: Store, options: { signable: true; }): TempoAccount.Account; export declare function hydrate(account: Store, options?: hydrate.Options): TempoAccount.Account | JsonRpcAccount; export declare namespace hydrate { type Options = { /** Whether to hydrate signing capability. @default false */ signable?: boolean | undefined; }; } //# sourceMappingURL=Account.d.ts.map