Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/abstractionkit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,13 @@ export {
fromViemWalletClient,
} from "./signer/adapters";
// ─── Signer interface design (capability-oriented) ──────────────────────
// Exported as `ExternalSigner` because the old package-level `Signer` is
// already taken by an owner-identifier union in Safe/types. An eventual
// rename there would promote this to the unqualified `Signer`.
// Named `ExternalSigner` (declaration and export alike) because the old
// package-level `Signer` is already taken by an owner-identifier union in
// Safe/types. An eventual rename there would free the unqualified `Signer`.
export type {
ExternalSigner,
MultiOpSignContext,
SignContext,
Signer as ExternalSigner,
SignHashFn,
SigningScheme,
SignTypedDataFn,
Expand Down
6 changes: 3 additions & 3 deletions src/account/Calibur/Calibur7702Account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
import {AbstractionKitError} from "src/errors";
import type {PrependTokenPaymasterApproveAccount} from "src/paymaster/types";
import {invokeSigner, pickScheme} from "src/signer/negotiate";
import type {SignContext, Signer as AkSigner, SigningScheme, TypedData} from "src/signer/types";
import type {SignContext, ExternalSigner, SigningScheme, TypedData} from "src/signer/types";
import {JsonRpcNode, type Transport} from "src/transport";
import type {JsonRpcResult, UserOperationV8, UserOperationV9} from "src/types";
import {
Expand Down Expand Up @@ -706,7 +706,7 @@ export class Calibur7702Account
public static readonly ACCEPTED_SIGNING_SCHEMES: readonly SigningScheme[] = ["typedData", "hash"];

/**
* Sign a UserOperation with an {@link AkSigner}. The signer can implement
* Sign a UserOperation with an {@link ExternalSigner}. The signer can implement
* either `signTypedData` (preferred — JSON-RPC wallets, viem `WalletClient`)
* or `signHash` (local keys, hardware wallets). Both schemes produce
* signatures that validate against the same `userOpHash` because the
Expand All @@ -718,7 +718,7 @@ export class Calibur7702Account
*/
public async signUserOperationWithSigner(
userOperation: UserOperationV8,
signer: AkSigner,
signer: ExternalSigner,
chainId: bigint,
overrides: CaliburSignatureOverrides = {},
): Promise<string> {
Expand Down
4 changes: 2 additions & 2 deletions src/account/Safe/SafeAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {Bundler} from "src/Bundler";
import {AbstractionKitError, ensureError} from "src/errors";
import {SafeAccountFactory} from "src/factory/SafeAccountFactory";
import {invokeSigner, pickScheme} from "src/signer/negotiate";
import type {Signer as AkSigner, SigningScheme, TypedData} from "src/signer/types";
import type {ExternalSigner, SigningScheme, TypedData} from "src/signer/types";
import {JsonRpcNode, type Transport} from "src/transport";
import {
BaseUserOperationDummyValues,
Expand Down Expand Up @@ -1978,7 +1978,7 @@ export class SafeAccount extends SmartAccount {
C,
>(
useroperation: T,
signers: ReadonlyArray<AkSigner<C>>,
signers: ReadonlyArray<ExternalSigner<C>>,
chainId: bigint,
params: {
entrypointAddress: string;
Expand Down
6 changes: 3 additions & 3 deletions src/account/Safe/SafeAccountV0_2_0.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type {Bundler} from "src/Bundler";
import {ENTRYPOINT_V6} from "src/constants";
import type {SignContext, Signer as AkSigner} from "src/signer/types";
import type {SignContext, ExternalSigner} from "src/signer/types";
import type {JsonRpcNode, Transport} from "src/transport";
import type {MetaTransaction, OnChainIdentifierParamsType, StateOverrideSet, UserOperationV6,} from "../../types";
import {SafeAccount} from "./SafeAccount";
Expand Down Expand Up @@ -452,7 +452,7 @@ export class SafeAccountV0_2_0 extends SafeAccount {
}

/**
* Sign a UserOperation using one or more {@link AkSigner} instances.
* Sign a UserOperation using one or more {@link ExternalSigner} instances.
* See {@link SafeAccountV0_3_0.signUserOperationWithSigners} for full
* design rationale and examples.
*
Expand All @@ -464,7 +464,7 @@ export class SafeAccountV0_2_0 extends SafeAccount {
*/
public signUserOperationWithSigners(
useroperation: UserOperationV6,
signers: ReadonlyArray<AkSigner>,
signers: ReadonlyArray<ExternalSigner>,
chainId: bigint,
options: SafeSignatureOptions = {},
): Promise<string> {
Expand Down
4 changes: 2 additions & 2 deletions src/account/Safe/SafeAccountV0_3_0.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type {Bundler} from "src/Bundler";
import {ENTRYPOINT_V7} from "src/constants";
import type {SignContext, Signer as AkSigner} from "src/signer/types";
import type {SignContext, ExternalSigner} from "src/signer/types";
import type {JsonRpcNode, Transport} from "src/transport";

import type {MetaTransaction, OnChainIdentifierParamsType, StateOverrideSet, UserOperationV7,} from "../../types";
Expand Down Expand Up @@ -408,7 +408,7 @@ export class SafeAccountV0_3_0 extends SafeAccount {
*/
public signUserOperationWithSigners(
useroperation: UserOperationV7,
signers: ReadonlyArray<AkSigner>,
signers: ReadonlyArray<ExternalSigner>,
chainId: bigint,
options: SafeSignatureOptions = {}
): Promise<string> {
Expand Down
8 changes: 4 additions & 4 deletions src/account/Safe/SafeMultiChainSigAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
ENTRYPOINT_V9,
} from "src/constants";
import {invokeSigner, pickScheme} from "src/signer/negotiate";
import type {MultiOpSignContext, SignContext, Signer as AkSigner, TypedData} from "src/signer/types";
import type {MultiOpSignContext, SignContext, ExternalSigner, TypedData} from "src/signer/types";
import type {JsonRpcNode, Transport} from "src/transport";
import type {MetaTransaction, OnChainIdentifierParamsType, StateOverrideSet, UserOperationV9} from "../../types";
import {
Expand Down Expand Up @@ -611,7 +611,7 @@ export class SafeMultiChainSigAccountV1 extends SafeAccount {

/**
* Sign a single UserOperation for multi-chain using one or more
* {@link AkSigner} instances. See
* {@link ExternalSigner} instances. See
* {@link SafeAccountV0_3_0.signUserOperationWithSigners} for the full
* design rationale. Sets the multi-chain flag automatically.
*
Expand All @@ -631,7 +631,7 @@ export class SafeMultiChainSigAccountV1 extends SafeAccount {
*/
public signUserOperationWithSigners(
userOperation: UserOperationV9,
signers: ReadonlyArray<AkSigner>,
signers: ReadonlyArray<ExternalSigner>,
chainId: bigint,
options: SafeSignatureOptions = {},
): Promise<string> {
Expand Down Expand Up @@ -767,7 +767,7 @@ export class SafeMultiChainSigAccountV1 extends SafeAccount {
*/
public async signUserOperationsWithSigners(
userOperationsToSign: UserOperationToSign[],
signers: ReadonlyArray<AkSigner<MultiOpSignContext<UserOperationV9>>>,
signers: ReadonlyArray<ExternalSigner<MultiOpSignContext<UserOperationV9>>>,
): Promise<string[]> {
if (userOperationsToSign.length < 1) {
throw new RangeError("There should be at least one userOperationsToSign");
Expand Down
6 changes: 3 additions & 3 deletions src/account/Safe/adapters.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { fromUtf8Bytes, getBytes, hexlify, toUtf8Bytes } from "../../ethereUtils";
import type { Signer } from "src/signer/types";
import type { ExternalSigner } from "src/signer/types";
import { SafeAccount } from "./SafeAccount";
import type { WebauthnPublicKey, WebauthnSignatureData } from "./types";

Expand Down Expand Up @@ -73,7 +73,7 @@ export interface FromSafeWebauthnParams {
}

/**
* Adapt a WebAuthn credential to a Signer for `signUserOperationWithSigners`
* Adapt a WebAuthn credential to an ExternalSigner for `signUserOperationWithSigners`
* on Safe accounts. Safe-specific (uses Safe's WebAuthn shared signer /
* verifier proxy / signature encoding) — for non-Safe accounts, use the
* account's own WebAuthn adapter.
Expand Down Expand Up @@ -136,7 +136,7 @@ export interface FromSafeWebauthnParams {
* userOperation, [signer], chainId,
* );
*/
export function fromSafeWebauthn(params: FromSafeWebauthnParams): Signer<unknown> {
export function fromSafeWebauthn(params: FromSafeWebauthnParams): ExternalSigner<unknown> {
const {
publicKey,
isInit,
Expand Down
10 changes: 5 additions & 5 deletions src/account/simple/Simple7702Account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {Bundler} from "src/Bundler";
import {BaseUserOperationDummyValues, ENTRYPOINT_V8, ENTRYPOINT_V9} from "src/constants";
import {AbstractionKitError} from "src/errors";
import {invokeSigner, pickScheme} from "src/signer/negotiate";
import type {SignContext, Signer as AkSigner, SigningScheme, TypedData} from "src/signer/types";
import type {SignContext, ExternalSigner, SigningScheme, TypedData} from "src/signer/types";
import {JsonRpcNode, type Transport} from "src/transport";
import type {
GasOption,
Expand Down Expand Up @@ -795,7 +795,7 @@ export class BaseSimple7702Account extends SmartAccount {
* EntryPoint v0.8 / v0.9 domain. Lower-level escape hatch for integrators
* driving `signTypedData` themselves with their own signing primitive
* (HSM, MPC, custom wallet abstraction). Most callers should pass an
* {@link AkSigner} to {@link signUserOperationWithSigner} instead, which
* {@link ExternalSigner} to {@link signUserOperationWithSigner} instead, which
* builds this internally.
*
* The digest of the returned payload equals the UserOperation hash from
Expand Down Expand Up @@ -848,7 +848,7 @@ export class BaseSimple7702Account extends SmartAccount {
}

/**
* Sign a UserOperation with an {@link AkSigner}. The signer can implement
* Sign a UserOperation with an {@link ExternalSigner}. The signer can implement
* either `signTypedData` (preferred — JSON-RPC wallets, viem `WalletClient`)
* or `signHash` (local keys, hardware wallets). Both schemes produce
* signatures that validate against the same `userOpHash` because the
Expand All @@ -860,7 +860,7 @@ export class BaseSimple7702Account extends SmartAccount {
*/
protected async baseSignUserOperationWithSigner<T extends UserOperationV8 | UserOperationV9>(
useroperation: T,
signer: AkSigner,
signer: ExternalSigner,
chainId: bigint,
): Promise<string> {
const scheme = pickScheme(signer, BaseSimple7702Account.ACCEPTED_SIGNING_SCHEMES, {
Expand Down Expand Up @@ -1122,7 +1122,7 @@ export class Simple7702Account extends BaseSimple7702Account {
*/
public async signUserOperationWithSigner(
useroperation: UserOperationV8,
signer: AkSigner,
signer: ExternalSigner,
chainId: bigint,
): Promise<string> {
return this.baseSignUserOperationWithSigner(useroperation, signer, chainId);
Expand Down
4 changes: 2 additions & 2 deletions src/account/simple/Simple7702AccountV09.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type {Bundler} from "src/Bundler";
import {ENTRYPOINT_V9} from "src/constants";
import type {Signer as AkSigner, TypedData} from "src/signer/types";
import type {ExternalSigner, TypedData} from "src/signer/types";
import type {JsonRpcNode, Transport} from "src/transport";
import type {StateOverrideSet, UserOperationV9} from "src/types";
import type {SendUseroperationResponse} from "../SendUseroperationResponse";
Expand Down Expand Up @@ -155,7 +155,7 @@ export class Simple7702AccountV09 extends BaseSimple7702Account {
*/
public async signUserOperationWithSigner(
useroperation: UserOperationV9,
signer: AkSigner,
signer: ExternalSigner,
chainId: bigint,
): Promise<string> {
return this.baseSignUserOperationWithSigner(useroperation, signer, chainId);
Expand Down
18 changes: 9 additions & 9 deletions src/signer/adapters.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { privateKeyToAddress, signHash, signTypedData } from "../ethereUtils";
import type { Signer, TypedData } from "./types";
import type { ExternalSigner, TypedData } from "./types";

// Structural types for well-known signers. NO imports from viem / ethers
// at the type level (beyond the already-present ethers runtime dep used by
Expand Down Expand Up @@ -79,7 +79,7 @@ export interface EthersWalletLike {
}

/**
* Build a Signer from a raw private-key hex string. Supports both raw-hash
* Build an ExternalSigner from a raw private-key hex string. Supports both raw-hash
* and typed-data signing, delegated to the internal `ethereUtils` helpers
* ({@link signHash}, {@link signTypedData}) — no extra packages needed.
* If you already hold a viem Account or ethers Wallet, use {@link fromViem}
Expand All @@ -90,7 +90,7 @@ export interface EthersWalletLike {
* const signer = fromPrivateKey(process.env.PRIVATE_KEY!);
* userOp.signature = await safe.signUserOperationWithSigners(userOp, [signer], chainId);
*/
export function fromPrivateKey(privateKey: string): Signer<unknown> {
export function fromPrivateKey(privateKey: string): ExternalSigner<unknown> {
return {
address: privateKeyToAddress(privateKey),
signHash: (hash) => signHash(privateKey, hash).serialized,
Expand All @@ -99,12 +99,12 @@ export function fromPrivateKey(privateKey: string): Signer<unknown> {
}

/**
* Adapt a viem Local Account (e.g. `privateKeyToAccount(pk)`) to a Signer.
* Adapt a viem Local Account (e.g. `privateKeyToAccount(pk)`) to an ExternalSigner.
* Supports both raw-hash and typed-data signing.
*
* @remarks Requires viem &gt;= 2.0.
*/
export function fromViem(account: ViemLocalAccountLike): Signer<unknown> {
export function fromViem(account: ViemLocalAccountLike): ExternalSigner<unknown> {
return {
address: account.address,
signHash: (hash) => account.sign({ hash }),
Expand All @@ -119,15 +119,15 @@ export function fromViem(account: ViemLocalAccountLike): Signer<unknown> {
}

/**
* Adapt a viem `WalletClient` to a Signer. Only typed-data signing is
* Adapt a viem `WalletClient` to an ExternalSigner. Only typed-data signing is
* exposed, because `WalletClient` drives browser/JSON-RPC wallets which
* can't sign raw hashes. Requires the client to have been constructed with
* an `account`; for local accounts, prefer `fromViem` so you also get
* raw-hash fallback.
*
* @remarks Requires viem &gt;= 2.0.
*/
export function fromViemWalletClient(client: ViemWalletClientLike): Signer<unknown> {
export function fromViemWalletClient(client: ViemWalletClientLike): ExternalSigner<unknown> {
if (!client.account) {
throw new Error(
"fromViemWalletClient: client has no `account` configured. " +
Expand All @@ -153,12 +153,12 @@ export function fromViemWalletClient(client: ViemWalletClientLike): Signer<unkno
}

/**
* Adapt an ethers `Wallet` / `HDNodeWallet` to a Signer. Supports both
* Adapt an ethers `Wallet` / `HDNodeWallet` to an ExternalSigner. Supports both
* raw-hash and typed-data signing.
*
* @remarks Requires ethers &gt;= 6.0.
*/
export function fromEthersWallet(wallet: EthersWalletLike): Signer<unknown> {
export function fromEthersWallet(wallet: EthersWalletLike): ExternalSigner<unknown> {
// ethers types `address` as plain `string`; at runtime it's always
// checksummed 0x-prefixed hex.
return {
Expand Down
8 changes: 4 additions & 4 deletions src/signer/negotiate.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AbstractionKitError } from "../errors";
import type { Signer, SigningScheme, TypedData } from "./types";
import type { ExternalSigner, SigningScheme, TypedData } from "./types";

/**
* Pick the best mutually-supported signing scheme for one signer against an
Expand All @@ -11,7 +11,7 @@ import type { Signer, SigningScheme, TypedData } from "./types";
* signer can do.
*/
export function pickScheme<C>(
signer: Signer<C>,
signer: ExternalSigner<C>,
accepted: readonly SigningScheme[],
context: { accountName: string; signerIndex: number },
): SigningScheme {
Expand Down Expand Up @@ -51,7 +51,7 @@ function buildMismatchMessage(params: {
`No compatible signing scheme for signer[${signerIndex}] ${signerAddress}. ` +
`${accountName} accepts: [${accepted.join(", ")}]; signer provides: [${canStr}]. ` +
(signerCan.length === 0
? "Signer must implement at least one of `signHash` or `signTypedData`. "
? "ExternalSigner must implement at least one of `signHash` or `signTypedData`. "
: "") +
"Hint: `fromViem` / `fromEthersWallet` give both; " +
"`fromViemWalletClient` gives only `typedData` (use Safe for JSON-RPC wallets)."
Expand All @@ -67,7 +67,7 @@ function buildMismatchMessage(params: {
* can inspect the userOp.
*/
export async function invokeSigner<C>(
signer: Signer<C>,
signer: ExternalSigner<C>,
scheme: SigningScheme,
payload: {
hash: `0x${string}`;
Expand Down
Loading
Loading