import * as Address from '../core/Address.js'; import type * as Bytes from '../core/Bytes.js'; import * as Errors from '../core/Errors.js'; import * as Hash from '../core/Hash.js'; import * as Hex from '../core/Hex.js'; import type { Compute } from '../core/internal/types.js'; /** Maximum encoded byte length for one primitive owner approval. */ export declare const maxOwnerSignatureBytes = 2049; /** Maximum number of owners allowed in an account config. */ export declare const maxOwners = 48; /** Maximum number of owner approvals in a configurable account signature. */ export declare const maxSignatures = 8; /** * Maximum threshold accepted by an account config. * * The threshold must also be reachable by at most {@link ox#AccountConfig.maxSignatures} * owner approvals. */ export declare const maxThreshold = 255; /** Maximum version accepted by an account config. */ export declare const maxVersion: bigint; /** Tempo signature type byte for configurable account signatures. */ export declare const signatureTypeByte: "0x05"; /** Zero 32-byte salt (the default when no salt is provided). */ export declare const zeroSalt: `0x${string}`; /** * Complete account configuration witness. */ export type Config = Compute<{ /** Weighted owner list, strictly ascending by owner address. */ owners: readonly Owner[]; /** Caller-chosen 32-byte salt. */ salt: Hex.Hex; /** Minimum total owner weight required for authorization. */ threshold: numberType; /** Configuration version. Zero identifies the initial configuration. */ version: bigintType; }>; /** Input accepted when constructing an account configuration. */ export type Input = Compute<{ /** Weighted owner list (strictly ascending by `owner` address). */ owners: readonly Owner[]; /** * Caller-chosen 32-byte salt mixed into the derived account address. * Defaults to the zero salt (`AccountConfig.zeroSalt`) when omitted. */ salt?: Hex.Hex | undefined; /** Minimum total owner weight required to authorize a transaction. */ threshold: numberType; /** Configuration version as a safe integer or bigint. Defaults to `0n`. */ version?: versionType | undefined; }>; /** Account config owner entry. */ export type Owner = { /** Owner address (recovered from the owner's approval). */ owner: Address.Address; /** Nonzero owner weight. */ weight: numberType; }; /** JSON-RPC representation of an account configuration. */ export type Rpc = Config; /** RLP tuple representation of a {@link ox#AccountConfig.Config}. */ export type Tuple = readonly [ salt: Hex.Hex, version: Hex.Hex, threshold: Hex.Hex, owners: readonly Hex.Hex[][] ]; /** * Asserts that an {@link ox#AccountConfig.Config} is valid. * * Mirrors the Tempo configuration rules: owners non-empty and * `<= maxOwners`, strictly ascending unique nonzero owner addresses, nonzero * integer owner weights, integer `threshold` between `1` and `maxThreshold`, * total weight `<= 255` (u8 max), and a threshold reachable by at most * `maxSignatures` owners. * * @example * ```ts twoslash * import { AccountConfig } from 'ox/tempo' * * AccountConfig.assert({ * threshold: 1, * owners: [ * { * owner: '0x1111111111111111111111111111111111111111', * weight: 1 * } * ] * }) * ``` * * @param config - The account config. */ export declare function assert(config: Input): void; export declare namespace assert { type ErrorType = InvalidConfigError | Errors.GlobalErrorType; } /** * Normalizes an {@link ox#AccountConfig.Config}. * * Sorts owners into strictly ascending `owner` address order (the canonical * form required for account derivation) and asserts the config is valid. * * @example * ```ts twoslash * import { AccountConfig } from 'ox/tempo' * * const config = AccountConfig.from({ * owners: [ * { * owner: '0x2222222222222222222222222222222222222222', * weight: 1 * }, * { * owner: '0x1111111111111111111111111111111111111111', * weight: 1 * } * ], * threshold: 2 * }) * // owners are now sorted ascending by address * ``` * * @param config - The account config. * @returns The normalized account config. */ export declare function from(config: Input<0 | 0n, numberType> & { version?: 0 | 0n | undefined; }): Config<0n, numberType>; export declare function from(config: Input & { version: bigintType; }): Config; export declare function from(config: Input & { version: number; }): Config; export declare function from(config: Input): Config; /** * Converts a JSON-RPC account configuration to its domain representation. * * @example * ```ts twoslash * import { AccountConfig } from 'ox/tempo' * * const config = AccountConfig.fromRpc({ * owners: [ * { * owner: '0x1111111111111111111111111111111111111111', * weight: 1 * } * ], * salt: `0x${'00'.repeat(32)}`, * threshold: 1, * version: '0x0' * }) * ``` * * @param config - The JSON-RPC account configuration. * @returns The normalized account configuration. */ export declare function fromRpc(config: Rpc): Config; export declare namespace fromRpc { type ErrorType = assert.ErrorType | Hex.toBigInt.ErrorType | Errors.GlobalErrorType; } /** * Converts an RLP {@link ox#AccountConfig.Tuple} back to a * {@link ox#AccountConfig.Config}. * * @example * ```ts twoslash * import { AccountConfig } from 'ox/tempo' * * const config = AccountConfig.fromTuple([ * `0x${'00'.repeat(32)}`, * '0x', * '0x01', * [['0x1111111111111111111111111111111111111111', '0x01']] * ]) * ``` * * @param tuple - The RLP tuple. * @returns The account config. */ export declare function fromTuple(tuple: Tuple): Config; /** * Derives the configuration an existing account installs when it migrates in * place with the `upgradeAccount` precompile call * ([TIP-1113](https://tips.sh/1113)). * * The account keeps its address. Its salt is * `keccak256("tempo:configurable-account:upgrade" || account)` and its version * is `1n`. Owners are sorted into canonical order and the config is validated. * The account itself may be listed as an owner. * * @example * ```ts twoslash * import { AccountConfig } from 'ox/tempo' * * const config = AccountConfig.fromUpgrade( * '0x3333333333333333333333333333333333333333', * { * owners: [ * { * owner: '0x1111111111111111111111111111111111111111', * weight: 1 * } * ], * threshold: 1 * } * ) * // config.version === 1n * ``` * * @param account - The account migrating in place. * @param options - The owners and threshold to install. * @returns The installed account config. */ export declare function fromUpgrade(account: Address.Address, options: fromUpgrade.Options): Config<1n, numberType>; export declare namespace fromUpgrade { type Options = { /** Weighted owners to install. Sorted into canonical order. */ owners: readonly Owner[]; /** Minimum total owner weight required for authorization. */ threshold: numberType; }; type ErrorType = Address.assert.ErrorType | assert.ErrorType | Hash.keccak256.ErrorType | Hex.concat.ErrorType | Hex.fromString.ErrorType | Errors.GlobalErrorType; } /** * Derives the stable configurable account address. * * The address is the last 20 bytes of the keccak256 hash of the initial * config, encoded with fixed-width big-endian fields, not RLP: * `keccak256("tempo:configurable-account:account" || salt || uint8(threshold) || uint8(owners.length) || owners)`. * * The address is derived once from the initial version-0 config. Config * updates do not change it. * * @example * ```ts twoslash * import { AccountConfig } from 'ox/tempo' * * const initialConfig = AccountConfig.from({ * owners: [ * { * owner: '0x1111111111111111111111111111111111111111', * weight: 1 * } * ], * threshold: 1 * }) * * const address = AccountConfig.getAddress(initialConfig) * ``` * * @param config - The initial account config. * @returns The configurable account address. */ export declare function getAddress(config: Input): Address.Address; export declare namespace getAddress { type ErrorType = assert.ErrorType | Hash.keccak256.ErrorType | Hex.concat.ErrorType | Hex.fromNumber.ErrorType | Hex.fromString.ErrorType | Hex.slice.ErrorType | Errors.GlobalErrorType; } /** * Computes the commitment for an account configuration. * * The commitment uses raw fixed-width fields, not RLP or ABI encoding: * `keccak256("tempo:configurable-account:config" || salt || uint64be(version) || uint8(threshold) || uint8(owners.length) || owners)`. * * @example * ```ts twoslash * import { AccountConfig } from 'ox/tempo' * * const commitment = AccountConfig.getCommitment({ * owners: [ * { * owner: '0x1111111111111111111111111111111111111111', * weight: 1 * } * ], * threshold: 1, * version: 1n * }) * ``` * * @param config - The complete account configuration. * @returns The configuration commitment. */ export declare function getCommitment(config: Input): Hex.Hex; export declare namespace getCommitment { type ErrorType = assert.ErrorType | Hash.keccak256.ErrorType | Hex.concat.ErrorType | Hex.fromNumber.ErrorType | Hex.fromString.ErrorType | Errors.GlobalErrorType; } /** * Computes the digest a configurable account owner approves (signs). * * `keccak256("tempo:configurable-account:signature" || inner_digest || account || uint64be(version))`, * where `inner_digest` is the transaction sign payload * ({@link ox#TxEnvelopeTempo.(getSignPayload:function)}). * * The digest is keyed on the permanent `account` and the supplied config * version. Initial approvals use version `0n`; each config update increments * it. * * @example * ```ts twoslash * import { AccountConfig, TxEnvelopeTempo } from 'ox/tempo' * * const config = AccountConfig.from({ * owners: [ * { * owner: '0x1111111111111111111111111111111111111111', * weight: 1 * } * ], * threshold: 1 * }) * * const envelope = TxEnvelopeTempo.from({ * chainId: 1, * calls: [] * }) * * const digest = AccountConfig.getSignPayload({ * account: AccountConfig.getAddress(config), * config, * payload: TxEnvelopeTempo.getSignPayload(envelope) * }) * ``` * * @param value - The digest derivation parameters. * @returns The owner approval digest. */ export declare function getSignPayload(value: getSignPayload.Value): Hex.Hex; export declare namespace getSignPayload { type Value = { /** The configurable account address. */ account: Address.Address; /** Configuration whose version applies to the approval. */ config: Pick, 'version'>; /** The inner transaction sign payload (`tx.signature_hash()`). */ payload: Hex.Hex | Bytes.Bytes; }; type ErrorType = assert.ErrorType | Hash.keccak256.ErrorType | Hex.concat.ErrorType | Hex.from.ErrorType | Hex.fromNumber.ErrorType | Errors.GlobalErrorType; } /** * Converts an account configuration to its JSON-RPC representation. * * @example * ```ts twoslash * import { AccountConfig } from 'ox/tempo' * * const config = AccountConfig.toRpc({ * owners: [ * { * owner: '0x1111111111111111111111111111111111111111', * weight: 1 * } * ], * threshold: 1 * }) * ``` * * @param config - The account configuration. * @returns The JSON-RPC account configuration. */ export declare function toRpc(config: Input): Rpc; export declare namespace toRpc { type ErrorType = assert.ErrorType | Hex.fromNumber.ErrorType | Errors.GlobalErrorType; } /** * Converts a {@link ox#AccountConfig.Config} to its RLP tuple form. * * Tuple shape: `[salt, version, threshold, [[owner, weight], ...]]`. The * 32-byte `salt` encodes as a full fixed-width string; other integers use * canonical RLP encoding (zero values encode as `0x`). * * @example * ```ts twoslash * import { AccountConfig } from 'ox/tempo' * * const tuple = AccountConfig.toTuple({ * owners: [ * { * owner: '0x1111111111111111111111111111111111111111', * weight: 1 * } * ], * threshold: 1 * }) * ``` * * @param config - The account config. * @returns The RLP tuple. */ export declare function toTuple(config: Input): Tuple; /** * Derives the configuration that replaces the current one in an owner update. * * Mirrors the `updateConfig` precompile ([TIP-1109](https://tips.sh/1109)): * keeps the current salt, increments the version by one, and replaces the * owners and threshold. Owners are sorted into canonical order and the next * configuration is validated. The account address does not change. * * @example * ```ts twoslash * import { AccountConfig } from 'ox/tempo' * * const initialConfig = AccountConfig.from({ * owners: [ * { * owner: '0x1111111111111111111111111111111111111111', * weight: 1 * } * ], * threshold: 1 * }) * * const config = AccountConfig.update(initialConfig, { * owners: [ * { * owner: '0x2222222222222222222222222222222222222222', * weight: 1 * } * ], * threshold: 1 * }) * // config.version === 1n, with the initial salt * ``` * * @param config - The current account config. * @param options - The replacement owners and threshold. * @returns The next account config. */ export declare function update(config: Input, options: update.Options): Config; export declare namespace update { type Options = { /** Replacement weighted owners. Sorted into canonical order. */ owners: readonly Owner[]; /** Replacement minimum total owner weight required for authorization. */ threshold: numberType; }; type ErrorType = assert.ErrorType | InvalidConfigError | Errors.GlobalErrorType; } /** * Validates an {@link ox#AccountConfig.Config}. Returns `true` * if valid, `false` otherwise. * * @example * ```ts twoslash * import { AccountConfig } from 'ox/tempo' * * const valid = AccountConfig.validate({ * owners: [ * { * owner: '0x1111111111111111111111111111111111111111', * weight: 1 * } * ], * threshold: 1 * }) * // @log: true * ``` * * @param config - The account config. * @returns Whether the config is valid. */ export declare function validate(config: Input): boolean; /** Thrown when an account config is invalid. */ export declare class InvalidConfigError extends Errors.BaseError { readonly name = "AccountConfig.InvalidConfigError"; constructor({ reason }: { reason: string; }); } //# sourceMappingURL=AccountConfig.d.ts.map