import type { Abi, AbiFunction, Account, Address, Chain, Hex } from 'viem'; import type { WebAuthnAccount } from 'viem/account-abstraction'; import type { AccountType } from '../accounts/types.js'; import type { NonEvmAddress, NonEvmChain } from '../chains/non-evm.js'; import type { AppFeeRate, AuxiliaryFunds, ProtocolFeeRate, SettlementLayerFilter } from '../clients/orchestrator/public.js'; declare const MODULE_TYPE_VALIDATOR = "validator"; declare const MODULE_TYPE_EXECUTOR = "executor"; declare const MODULE_TYPE_FALLBACK = "fallback"; declare const MODULE_TYPE_HOOK = "hook"; type ModuleType = typeof MODULE_TYPE_VALIDATOR | typeof MODULE_TYPE_EXECUTOR | typeof MODULE_TYPE_FALLBACK | typeof MODULE_TYPE_HOOK; interface AuthProvider { getHeaders(): Promise>; getSubmitHeaders(intentInput: unknown, isSponsored: boolean): Promise>; } interface SafeAccount { type: 'safe'; version?: '1.4.1'; adapter?: '1.0.0' | '2.0.0'; nonce?: bigint; } interface NexusAccount { type: 'nexus'; version?: '1.2.0' | '1.2.1'; salt?: Hex; } interface KernelAccount { type: 'kernel'; version?: '3.3'; salt?: Hex; } interface StartaleAccount { type: 'startale'; salt?: Hex; } interface HcaAccount { type: 'hca'; factory?: Address; } interface EoaAccount { type: 'eoa'; } type AccountProviderConfig = SafeAccount | NexusAccount | KernelAccount | StartaleAccount | HcaAccount | EoaAccount; interface OwnableValidatorConfig { type: 'ecdsa'; accounts: Account[]; threshold?: number; module?: Address; } interface ENSValidatorConfig { type: 'ens'; /** Each owner with an optional expiry. Omit `expiration` to never expire. */ owners: { account: Account; expiration?: Date; }[]; threshold?: number; } interface WebauthnValidatorConfig { type: 'passkey'; accounts: WebAuthnAccount[]; threshold?: number; module?: Address; } interface MultiFactorValidatorConfig { type: 'multi-factor'; validators: (OwnableValidatorConfig | ENSValidatorConfig | WebauthnValidatorConfig)[]; threshold?: number; module?: Address; } type ProviderConfig = { type: 'custom'; urls: Record; }; type BundlerConfig = { type: 'pimlico' | 'biconomy'; apiKey: string; } | { type: 'custom'; url: string | Record; }; type PaymasterConfig = { type: 'pimlico' | 'biconomy'; apiKey: string; } | { type: 'custom'; url: string | Record; }; type OwnerSet = OwnableValidatorConfig | ENSValidatorConfig | WebauthnValidatorConfig | MultiFactorValidatorConfig; interface SudoPolicy { type: 'sudo'; } interface UniversalActionPolicy { type: 'universal-action'; valueLimitPerUse?: bigint; rules: [UniversalActionPolicyParamRule, ...UniversalActionPolicyParamRule[]]; } interface UniversalActionPolicyParamRule { condition: UniversalActionPolicyParamCondition; calldataOffset: bigint; usageLimit?: bigint; referenceValue: Hex | bigint; } type UniversalActionPolicyParamCondition = 'equal' | 'greaterThan' | 'lessThan' | 'greaterThanOrEqual' | 'lessThanOrEqual' | 'notEqual' | 'inRange'; type ArgPolicyExpression = { type: 'rule'; rule: UniversalActionPolicyParamRule; } | { type: 'not'; child: ArgPolicyExpression; } | { type: 'and'; left: ArgPolicyExpression; right: ArgPolicyExpression; } | { type: 'or'; left: ArgPolicyExpression; right: ArgPolicyExpression; }; interface ArgPolicy { type: 'arg-policy'; valueLimitPerUse?: bigint; expression: ArgPolicyExpression; } interface SpendingLimitsPolicy { type: 'spending-limits'; limits: { token: Address; amount: bigint; }[]; } interface TimeFramePolicy { type: 'time-frame'; validUntil: number; validAfter: number; } interface UsageLimitPolicy { type: 'usage-limit'; limit: bigint; } interface ValueLimitPolicy { type: 'value-limit'; limit: bigint; } interface IntentExecutionPolicy { type: 'intent-execution'; } interface Permit2ClaimPolicy { type: 'permit2'; /** Whitelisted Permit2 spender addresses */ spenders?: Address[]; /** Permitted input tokens per origin chain */ sourceTokens?: { chain: Chain; address: Address; }[]; /** Permitted output tokens per destination chain */ destinationTokens?: { chain: Chain; address: Address; }[]; /** Permitted recipients per destination chain (use `'any'` to allow all) */ recipients?: { chain: Chain; address: Address | 'any'; }[]; /** Enforce that the destination recipient is the smart account */ recipientIsAccount?: boolean; /** Bounds for the Permit2 signature deadline */ permitDeadline?: { min?: bigint; max?: bigint; }; /** Bounds for the mandate target fill deadline, per destination chain */ fillDeadline?: { chain: Chain; min?: bigint; max?: bigint; }[]; } /** * Settlement layers supported by the cross-chain session abstraction. * Each value maps to one or more Permit2 arbiter addresses from the SDK's * bundled arbiter allow-set — devs pick a layer, the SDK resolves it to the * on-chain arbiter whitelist. * * The set is intentionally narrower than the orchestrator's broader * `SettlementLayer` union (which also names intent-executor-backed * bridges like `CCTP`, `RHINO`, ...). Once the params-bearing * intent-executor policy lands in smart-sessions-v2 (see * `rhinestonewtf/smart-sessions-v2#46`), this union grows to cover those * layers via the same selector interface. */ type CrossChainSettlementLayer = 'SAME_CHAIN' | 'ECO' | 'ACROSS'; /** * A high-level permit that authorises a session key to move funds * between two chains via Permit2 arbiter settlement. The SDK expands * one `CrossChainPermit` into a {@link Permit2ClaimPolicy} (claim-side) * plus optional {@link SpendingLimitsPolicy} / {@link TimeFramePolicy} * entries on the fallback action — the claim policy itself doesn't * enforce amounts or expiry on-chain, so we lift those guarantees into * action-level policies that do. * * Resolved from {@link CrossChainPermissionInput} by the SDK; consumers * normally set `SessionDefinition.crossChainPermits` with the input shape, * not this one. Exported as a low-level escape hatch. */ interface CrossChainPermit { /** * Allowed source legs: chain + token (+ optional max amount cap). * Omit for no source-token restriction (any token on any chain may be * pulled) — only the arbiter whitelist, deadline, and bridge-to-self * flag then constrain the source side. */ from?: { chain: Chain; token: Address; maxAmount?: bigint; }[]; /** * Allowed destination legs: chain + token (+ optional recipient pin). * Omit for no destination-token restriction. Note `recipientIsAccount` * still constrains the destination recipient even when `to` is absent. */ to?: { chain: Chain; token: Address; recipient?: Address | 'any'; }[]; /** Upper bound on the permit deadline (Permit2 deadline) — unix seconds */ validUntil?: bigint; /** Lower bound on the permit deadline — unix seconds */ validAfter?: bigint; /** Per-destination fill-deadline windows — unix seconds */ fillDeadline?: { chain: Chain; min?: bigint; max?: bigint; }[]; /** * Enforce bridge-to-self (the destination recipient must be the smart * account). Defaults to `true` when resolved from * {@link CrossChainPermissionInput}. */ recipientIsAccount?: boolean; /** * Settlement layers this session is permitted to use. Omit (or pass * `[]`) for any supported layer — the SDK resolves to the union of * every arbiter in its bundled allow-set. */ settlementLayers?: CrossChainSettlementLayer[]; } interface FromLeg { chain: Chain; token: Address; maxAmount?: bigint; } interface ToLeg { chain: Chain; token: Address; recipient?: Address | 'any'; } /** * Ergonomic input for a cross-chain session permit. Set on * `SessionDefinition.crossChainPermits`; token fields are per-chain ERC-20 * addresses (v2 no longer accepts symbols) and the SDK resolves `Date`s to * on-chain deadlines, then expands * each entry into a {@link Permit2ClaimPolicy} (claim-side) plus optional * {@link SpendingLimitsPolicy} / {@link TimeFramePolicy} guardrails. */ interface CrossChainPermissionInput { /** * Source chain + token (+ optional max amount cap). Pass a single leg * or an array for multi-leg permits. Omit for no source-token * restriction (any token on any chain may be pulled) — the arbiter * whitelist, deadline, and bridge-to-self flag still apply. */ from?: FromLeg | FromLeg[]; /** * Destination chain + token (+ optional recipient pin). Pass a single * leg or an array for fan-out destinations. Omit for no * destination-token restriction; `recipientIsAccount` still constrains * the recipient. */ to?: ToLeg | ToLeg[]; /** Upper bound on the permit deadline. */ validUntil?: Date; /** Lower bound on the permit deadline. */ validAfter?: Date; /** Per-destination fill-deadline windows. */ fillDeadline?: { chain: Chain; min?: Date; max?: Date; }[]; /** * Allow the destination recipient to differ from the smart account * (the sponsor funding the cross-chain transfer). Defaults to * `false`, which enforces bridge-to-self on-chain — the safer default * since it prevents a compromised session key from routing funds to * an attacker-controlled address. Set to `true` to opt out explicitly. */ allowRecipientNotAccount?: boolean; /** * Settlement layers this session is permitted to use. Omit (or pass * `[]`) to allow **any of the supported settlement layers** — the SDK * resolves to the union of every arbiter in its bundled allow-set. Pass * a subset (e.g. `['ECO']`) to narrow. */ settlementLayers?: CrossChainSettlementLayer[]; } type Policy = SudoPolicy | UniversalActionPolicy | ArgPolicy | SpendingLimitsPolicy | TimeFramePolicy | UsageLimitPolicy | ValueLimitPolicy | IntentExecutionPolicy; /** @internal */ interface FallbackAction { policies?: Policy[]; } /** @internal */ interface ScopedAction { target: Address; selector: Hex; policies?: Policy[]; } /** @internal */ type Action = FallbackAction | ScopedAction; /** Extract function names from an ABI. */ type FunctionNames = Extract['name']; /** Pull the AbiFunction entry for a given name (union if overloaded). */ type GetFunction = Extract; /** * Map a Solidity type string to the TypeScript value a developer provides as * `value` in a param constraint. Dynamic types resolve to `never` so the * compiler prevents rules on params the on-chain policy cannot compare. */ type AbiTypeToValue = T extends 'address' ? Address : T extends 'bool' ? boolean : T extends `uint${string}` ? bigint : T extends `int${string}` ? bigint : T extends `bytes${infer N}` ? N extends '' ? never : Hex : never; type ParamValue = AbiTypeToValue['type']>; type NamedInputs = Extract; type ParamConstraint = { condition: UniversalActionPolicyParamCondition; value: TValue; usageLimit?: bigint; anyOf?: never; } | { anyOf: readonly [TValue, ...TValue[]]; condition?: never; value?: never; usageLimit?: never; }; type IsERC20TransferLike = TFn['name'] extends 'approve' | 'increaseAllowance' | 'transfer' ? TFn['inputs'] extends readonly [{ type: 'address'; }, { type: 'uint256'; }] ? true : false : TFn['name'] extends 'transferFrom' ? TFn['inputs'] extends readonly [ { type: 'address'; }, { type: 'address'; }, { type: 'uint256'; } ] ? true : false : false; type IsPayable = TFn['stateMutability'] extends 'payable' ? true : false; type SpendingLimitField = IsERC20TransferLike extends true ? { spendingLimit?: { token: Address; amount: bigint; }; } : { spendingLimit?: never; }; type ValueLimitField = IsPayable extends true ? { valueLimit?: bigint; } : { valueLimit?: never; }; type PermissionFunctionConfig = { /** `valueLimitPerUse` embedded in universal/arg-policy `ActionConfig`. */ valueLimitPerUse?: bigint; params?: { [K in NamedInputs['name']]?: ParamConstraint>; }; /** * Per-action call cap. Emits a standalone `usage-limit` policy. * Counter is scoped to this single action — `transfer.maxUses=10` and * `approve.maxUses=10` are independent counters. */ maxUses?: bigint; /** * Upper bound on `block.timestamp`. Pairs with `validAfter` into one * `time-frame` policy. If only one of the two is set, the other defaults to * "always passes" (validAfter=0 / validUntil=year-2100). */ validUntil?: Date; /** Lower bound on `block.timestamp`. See `validUntil`. */ validAfter?: Date; } & SpendingLimitField & ValueLimitField; interface Permission { abi: TAbi; address: Address; functions: { [K in FunctionNames]?: PermissionFunctionConfig & AbiFunction>; }; } type PermissionsForAbis = { [K in keyof TAbis]: TAbis[K] extends Abi ? Permission : never; }; /** * Per-session override for SmartSession policy singleton addresses. * * Defaults are the latest canonical V2 deployments. Provide a partial map to * pin one or more policies to non-default addresses — primarily for backwards * compatibility with accounts that already enabled sessions against the * previous V1 deployments. * * Resolved addresses are baked into `Session.actions[i].actionPolicies[j].policy` * at construction time, so this only needs to be set on `SessionDefinition` — * downstream consumers read the already-resolved values off the `Session`. */ interface SessionPolicyAddresses { sudo?: Address; universalAction?: Address; argPolicy?: Address; spendingLimits?: Address; timeFrame?: Address; usageLimit?: Address; valueLimit?: Address; } interface SessionDefinition { chain: Chain; owners: OwnerSet; permissions?: readonly [...PermissionsForAbis]; claimPolicies?: readonly Permit2ClaimPolicy[]; /** * Cross-chain permits expanded by the SDK into matching * {@link Permit2ClaimPolicy} (claim-side) plus action-level * {@link SpendingLimitsPolicy} / {@link TimeFramePolicy} guardrails. * See {@link CrossChainPermissionInput}. */ crossChainPermits?: readonly CrossChainPermissionInput[]; /** * Override one or more SmartSession policy addresses. Defaults to the latest * V2 deployments. Use to pin to V1 deployments for an account that already * has sessions enabled against them. */ policyAddresses?: SessionPolicyAddresses; } type SessionInput = Omit, 'chain'>; interface ResolvedERC7739Content { appDomainSeparator: Hex; contentNames: readonly string[]; } interface ResolvedPolicy { policy: Address; initData: Hex; } interface ResolvedERC7739Policies { allowedERC7739Content: readonly ResolvedERC7739Content[]; erc1271Policies: readonly ResolvedPolicy[]; } interface ResolvedAction { actionTargetSelector: Hex; actionTarget: Address; actionPolicies: readonly ResolvedPolicy[]; } interface Session { chain: Chain; owners: OwnerSet; hasExplicitPermissions: boolean; permissionId: Hex; sessionValidator: Address; sessionValidatorInitData: Hex; salt: Hex; erc7739Policies: ResolvedERC7739Policies; actions: readonly ResolvedAction[]; claimPolicies: readonly Permit2ClaimPolicy[]; } interface ModuleInput { type: ModuleType; address: Address; initData?: Hex; deInitData?: Hex; additionalContext?: Hex; } interface RhinestoneAccountConfig { account?: AccountProviderConfig; owners?: OwnerSet; sessions?: { enabled: boolean; module?: Address; compatibilityFallback?: Address; }; eoa?: Account; modules?: ModuleInput[]; initData?: { address: Address; factory: Address; factoryData: Hex; intentExecutorInstalled: boolean; } | { address: Address; }; } interface ApiKeyAuth { mode: 'apiKey'; apiKey: string; } interface JwtAuth { mode: 'experimental_jwt'; /** Static access token, or async getter for refreshable tokens. */ accessToken: string | (() => Promise); /** * Called when submitting a sponsored intent. Receives the raw intent * input object and must return a signed intent_extension_token JWT. */ getIntentExtensionToken?: (intentInput: unknown) => Promise; } type AuthConfig = ApiKeyAuth | JwtAuth; interface RhinestoneSDKConfigBase { provider?: ProviderConfig; bundler?: BundlerConfig; paymaster?: PaymasterConfig; /** * @internal * Optional orchestrator URL override for internal testing - do not use */ endpointUrl?: string; /** * @internal * Optional intent executor address override for internal testing - do not use */ useDevContracts?: boolean; /** * Optional custom headers sent with every orchestrator request. */ headers?: Record; } type RhinestoneSDKConfig = RhinestoneSDKConfigBase & ({ /** @deprecated Use `auth` instead. Still supported for backward compatibility. */ apiKey: string; } | { auth: AuthConfig; }); type RhinestoneConfig = RhinestoneAccountConfig & Partial & { /** @internal Resolved auth provider — set by RhinestoneSDK, not by users. */ _authProvider?: AuthProvider; }; type TokenSymbol = 'ETH' | 'WETH' | 'USDC' | 'USDT' | 'USDT0'; interface CalldataInput { to: Address; data?: Hex; value?: bigint; } interface CallResolveContext { config: RhinestoneConfig; chain: Chain; accountAddress: Address; } interface LazyCallInput { resolve: (context: CallResolveContext) => Promise; } type CallInput = CalldataInput | LazyCallInput; interface Call { to: Address; data: Hex; value: bigint; } type SourceCallProvidedFunds = { token: Address; amount: bigint; }; type SourceCallInput = CallInput & { provides?: SourceCallProvidedFunds[]; }; interface TokenRequestWithAmount { address: Address; amount: bigint; } interface TokenRequestWithoutAmount { address: Address; amount?: undefined; } type TokenRequest = TokenRequestWithAmount | TokenRequestWithoutAmount; type TokenRequests = [TokenRequestWithoutAmount] | TokenRequestWithAmount[]; interface NonEvmTokenRequestWithAmount { address: NonEvmAddress; amount: bigint; } interface NonEvmTokenRequestWithoutAmount { address: NonEvmAddress; amount?: undefined; } type NonEvmTokenRequest = NonEvmTokenRequestWithAmount | NonEvmTokenRequestWithoutAmount; type NonEvmTokenRequests = [NonEvmTokenRequestWithoutAmount] | NonEvmTokenRequestWithAmount[]; export type SimpleTokenList = Address[]; export type ChainTokenMap = Record; export type ExactInputConfig = { chain: Chain; address: Address; amount?: bigint; }; type SourceAssetInput = SimpleTokenList | ChainTokenMap | ExactInputConfig[]; type OwnerSignerSet = { type: 'owner'; kind: 'ecdsa'; accounts: Account[]; module?: Address; } | { type: 'owner'; kind: 'passkey'; accounts: WebAuthnAccount[]; module?: Address; } | { type: 'owner'; kind: 'multi-factor'; validators: ({ type: 'ecdsa'; id: number | Hex; accounts: Account[]; } | { type: 'passkey'; id: number | Hex; accounts: WebAuthnAccount[]; })[]; module?: Address; }; interface SessionEnableData { userSignature: Hex; hashesAndChainIds: { chainId: bigint; sessionDigest: Hex; }[]; sessionToEnableIndex: number; } interface ChainSessionConfig { session: Session; enableData?: SessionEnableData; } interface SingleSessionSignerSet { type: 'session'; session: Session; enableData?: SessionEnableData; } interface PerChainSessionSignerSet { type: 'session'; sessions: Record; } type SessionSignerSet = SingleSessionSignerSet | PerChainSessionSignerSet; type SignerSet = OwnerSignerSet | SessionSignerSet; type Sponsorship = boolean | { gas: boolean; bridging: boolean; swaps: boolean; /** * Sponsor the Rhinestone protocol fee (`protocolFees`) from the * integrator's sponsorship balance instead of charging the user, without * the sponsorship surcharge. Defaults to `false` in the object form; the * `sponsored: true` shorthand enables it along with the other categories. */ protocolFees?: boolean; }; interface BaseTransaction { calls?: CallInput[]; /** * Per-chain executions to run on the source side, before the claim. * Keyed by chain ID (must be present in `sourceChains`, or equal the * target chain for same-chain transactions). Bundled into the intent * at routing time and covered by the user's mandate signature. * * Caveat: only executes if the orchestrator creates an element on the * matching chain — i.e. when the intent actually moves tokens from * that source. Sponsored / no-op fills with no source movement skip * the source element entirely, and `sourceCalls` keyed on that chain * are silently dropped. */ sourceCalls?: Record; gasLimit?: bigint; signers?: SignerSet; sponsored?: Sponsorship; eip7702InitSignature?: Hex; sourceAssets?: SourceAssetInput; appFees?: AppFeeRate; /** * Rhinestone protocol fee rate in basis points of the input value (0–10000 = * 0–100%). Collected alongside `appFees` in one batched transfer and always * accrues to Rhinestone. Sponsor it via `sponsored.protocolFees` to charge * the integrator's sponsorship balance instead of the user. */ protocolFees?: ProtocolFeeRate; settlementLayers?: SettlementLayerFilter; auxiliaryFunds?: AuxiliaryFunds; experimental_accountOverride?: { setupOps?: { to: Address; data: Hex; }[]; }; } interface SameChainTransaction extends BaseTransaction { chain: Chain; tokenRequests?: TokenRequests; recipient?: RhinestoneAccountConfig | Address; /** * Absolute unix timestamp (seconds) overriding the on-chain fill deadline * (default 2 min). Same-chain only — the field lives on this type precisely * because the orchestrator honors it only on the same-chain (tokenless) * route; cross-chain transactions cannot set it. Must be between * `now + 120s` and `now + 86400s` (24h); out-of-range values are rejected * by the orchestrator with a `400`. When honored, the quoted `expiresAt` * and the bundle claim/nonce expiry track this value automatically. */ customDeadline?: number; } interface CrossChainEvmTransaction extends BaseTransaction { sourceChains?: Chain[]; targetChain: Chain; tokenRequests?: TokenRequests; recipient?: RhinestoneAccountConfig | Address; } interface CrossChainNonEvmTransaction extends BaseTransaction { sourceChains?: Chain[]; targetChain: NonEvmChain; tokenRequests?: NonEvmTokenRequests; recipient?: NonEvmAddress; } type CrossChainTransaction = CrossChainEvmTransaction | CrossChainNonEvmTransaction; interface UserOperationTransaction { calls: CallInput[]; gasLimit?: bigint; signers?: SignerSet; chain: Chain; } type Transaction = SameChainTransaction | CrossChainTransaction; export type { AccountType, SafeAccount, NexusAccount, KernelAccount, StartaleAccount, HcaAccount, EoaAccount, RhinestoneAccountConfig, RhinestoneSDKConfig, RhinestoneConfig, AccountProviderConfig, ProviderConfig, BundlerConfig, PaymasterConfig, Transaction, UserOperationTransaction, TokenSymbol, CalldataInput, LazyCallInput, CallInput, SourceCallProvidedFunds, SourceCallInput, CallResolveContext, Call, Sponsorship, TokenRequest, TokenRequests, NonEvmTokenRequest, NonEvmTokenRequests, SourceAssetInput, OwnerSet, OwnableValidatorConfig, ENSValidatorConfig, WebauthnValidatorConfig, MultiFactorValidatorConfig, SignerSet, ChainSessionConfig, SingleSessionSignerSet, PerChainSessionSignerSet, SessionSignerSet, SessionDefinition, SessionInput, SessionEnableData, Session, ModuleType, ModuleInput, Action, ScopedAction, FallbackAction, Permission, PermissionsForAbis, PermissionFunctionConfig, ParamConstraint, ResolvedAction, ResolvedERC7739Content, ResolvedERC7739Policies, ResolvedPolicy, Policy, Permit2ClaimPolicy, CrossChainPermit, CrossChainPermissionInput, FromLeg, ToLeg, CrossChainSettlementLayer, UniversalActionPolicyParamCondition, ArgPolicyExpression, SessionPolicyAddresses, ApiKeyAuth, JwtAuth, AuthConfig, }; //# sourceMappingURL=account.d.ts.map