@circle-fin/modular-wallets-core
Version:
Serverless Typescript SDK
1,432 lines (1,389 loc) • 71 kB
TypeScript
import * as viem from 'viem';
import { Hex, Transport, Assign, Client, LocalAccount, Prettify, Address as Address$1, Chain, RpcSchema, ClientConfig, CreateClientErrorType, Account, Hash, PublicClient, WalletClient } from 'viem';
import { EstimateUserOperationGasReturnType as EstimateUserOperationGasReturnType$1, SendUserOperationReturnType as SendUserOperationReturnType$1, SmartAccount as SmartAccount$2, WebAuthnAccount as WebAuthnAccount$1, BundlerClient } from 'viem/_types/account-abstraction';
import { CreateCredentialReturnType, PublicKeyCredential as PublicKeyCredential$1 } from 'webauthn-p256';
import { Address } from 'abitype';
import { SmartAccountImplementation, WebAuthnAccount, SmartAccount } from 'viem/_types/account-abstraction/accounts/types';
import { entryPoint07Abi } from 'viem/account-abstraction/constants/abis';
import { EstimateUserOperationGasParameters, SmartAccount as SmartAccount$1, EstimateUserOperationGasReturnType, P256Credential, SendUserOperationParameters, SendUserOperationReturnType, WebAuthnAccount as WebAuthnAccount$2 } from 'viem/account-abstraction';
import { ErrorType } from 'viem/_types/errors/utils';
import { Web3APISpec, EthExecutionAPI, Web3BaseProvider, Web3APIMethod, Web3APIPayload, JsonRpcResponseWithResult, Web3ProviderStatus, Web3APIReturnType } from 'web3-types';
/**
* Copyright 2025 Circle Internet Group, Inc. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at.
*
* Http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Utility type to enforce that at least one key in `T` is present.
*/
type AtLeastOne<T, Keys extends keyof T = keyof T> = Partial<T> & {
[K in Keys]: Required<Pick<T, K>>;
}[Keys];
/**
* Utility type to ensure an array contains at least one element of the given type.
*/
type NonEmptyArray<T> = [T, ...T[]];
/**
* Copyright 2025 Circle Internet Group, Inc. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at.
*
* Http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* The EOA identifier.
*/
interface EOAIdentifier {
/**
* The address.
*/
address: Hex;
}
/**
* The Webauthn identifier.
*/
interface WebAuthnIdentifier {
/**
* The public key X coordinate.
*/
publicKeyX: string;
/**
* The public key Y coordinate.
*/
publicKeyY: string;
}
/**
* The Webauthn owner.
*/
interface WebauthnOwner extends WebAuthnIdentifier {
/**
* The weight.
*/
weight: number;
}
/**
* The Eoa owner.
*/
interface EoaOwner extends EOAIdentifier {
/**
* The weight.
*/
weight: number;
}
/**
* The Base type of Circle modular wallet weighted multisig.
*/
interface WeightedMultisigBase {
/**
* The threshold weight.
*/
thresholdWeight: number;
}
/**
* The Circle modular wallet weighted multisig.
* Ensures at least one owner is present.
*/
type WeightedMultisig = WeightedMultisigBase & AtLeastOne<{
owners?: EoaOwner[];
webauthnOwners?: WebauthnOwner[];
}>;
/**
* The Circle modular wallet initial ownership configuration.
*/
interface InitialOwnershipConfiguration {
/**
* The ownership contract address.
*/
ownershipContractAddress: Hex;
/**
* The weighted multisig.
*/
weightedMultisig: WeightedMultisig;
}
/**
* The Circle modular wallet SCA configuration.
*/
interface ScaConfiguration {
/**
* The initial ownership configuration.
*/
initialOwnershipConfiguration: InitialOwnershipConfiguration;
/**
* The initial code.
*/
initCode: Hex;
}
/**
* The Circle modular wallet.
*/
interface ModularWallet {
/**
* The wallet ID.
*/
id: string;
/**
* The wallet address.
*/
address: Hex;
/**
* The blockchain.
*/
blockchain: string;
/**
* The state.
*/
state: string;
/**
* The SCA core.
*/
scaCore: string;
/**
* The SCA configuration.
*/
scaConfiguration: ScaConfiguration;
/**
* The create date.
*/
createDate: string;
/**
* The update date.
*/
updateDate: string;
}
/**
* The Get Circle modular wallet address response.
*/
type GetAddressReturnType = ModularWallet;
/**
* The return type for encodeTransfer.
*/
interface EncodeTransferReturnType {
/**
* The encoded data.
*/
data: Hex;
/**
* The token address.
*/
to: Hex;
}
declare enum AccountType {
/** Used for {@link WebAuthnAccount}, an account that relies on WebAuthn for authentication and signing. */
WebAuthn = "webAuthn",
/** Used for {@link LocalAccount}, an account that is stored locally and supports private key-based signing. */
Local = "local"
}
/**
* The owner identifier type for address mapping.
*/
declare enum OwnerIdentifierType {
EOA = "EOAOWNER",
WebAuthn = "WEBAUTHOWNER"
}
/**
* The owner for address mapping.
*/
type AddressMappingOwner = {
/**
* The EOA owner type.
*/
type: OwnerIdentifierType.EOA;
/**
* The EOA identifier.
*/
identifier: EOAIdentifier;
} | {
/**
* The WebAuthn owner type.
*/
type: OwnerIdentifierType.WebAuthn;
/**
* The WebAuthn identifier.
*/
identifier: WebAuthnIdentifier;
};
/**
* The parameters for creating an address mapping.
*/
interface CreateAddressMappingParameters {
/**
* The Circle smart wallet address.
*/
walletAddress: Hex;
/**
* The owners of the wallet.
* Requires at least one owner to be specified.
*/
owners: NonEmptyArray<AddressMappingOwner>;
}
/**
* The address mapping response.
*/
interface AddressMappingResponse {
/**
* The mapping ID.
*/
id: string;
/**
* The blockchain identifier.
*/
blockchain: string;
/**
* The owner information.
*/
owner: AddressMappingOwner;
/**
* The wallet address.
*/
walletAddress: Hex;
/**
* The creation date (ISO 8601 format).
*/
createDate: string;
/**
* The last update date (ISO 8601 format).
*/
updateDate: string;
}
/**
* The return type for adding an address mapping.
*/
type CreateAddressMappingReturnType = AddressMappingResponse[];
/**
* The parameters for getting an address mapping.
*/
interface GetAddressMappingParameters {
/**
* The owner information.
*/
owner: AddressMappingOwner;
}
/**
* The return type for getting an address mapping.
*/
type GetAddressMappingReturnType = AddressMappingResponse[];
/**
* Represents gas prices for different priority levels.
*/
interface GasPriceLevel {
/**
* The max priority fee per gas.
*/
maxPriorityFeePerGas: string;
/**
* The max fee per gas.
*/
maxFeePerGas: string;
}
/**
* The get user operation gas price response.
*/
interface GetUserOperationGasPriceResponse {
/**
* The low gas price level.
*/
low: GasPriceLevel;
/**
* The medium gas price level.
*/
medium: GasPriceLevel;
/**
* The high gas price level.
*/
high: GasPriceLevel;
/**
* The deployed verification gas.
*/
deployed?: string;
/**
* The non-deployed verification gas.
*/
notDeployed?: string;
}
/**
* Response type for circle_getUserOperationGasPrice RPC method.
*/
type GetUserOperationGasPriceReturnType = GetUserOperationGasPriceResponse;
/**
* Copyright 2025 Circle Internet Group, Inc. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at.
*
* Http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
declare enum WebAuthnMode {
Login = "Login",
Register = "Register"
}
interface CreateCredentialParameters {
credential: PublicKeyCredential;
rpId: string | undefined;
}
interface CustomPublicKeyCredentialDescriptor extends Omit<PublicKeyCredentialDescriptor, 'id'> {
id: string;
}
interface CustomPublicKeyCredentialRequestOptions extends Omit<PublicKeyCredentialRequestOptions, 'allowCredentials' | 'challenge'> {
allowCredentials?: CustomPublicKeyCredentialDescriptor[];
challenge: string;
}
interface CustomPublicKeyCredentialUserEntity extends Omit<PublicKeyCredentialUserEntity, 'id'> {
id: string;
}
interface CustomPublicKeyCredentialCreationOptions extends Omit<PublicKeyCredentialCreationOptions, 'challenge' | 'user'> {
challenge: string;
user: CustomPublicKeyCredentialUserEntity;
}
interface ToWebAuthnAccountParameters {
transport: Transport;
username?: string;
credentialId?: string;
mode: WebAuthnMode;
}
/**
* Available only in secure contexts.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AuthenticatorAssertionResponse).
*/
interface AuthenticatorAssertionResponse extends AuthenticatorResponse {
/**
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AuthenticatorAssertionResponse/userHandle).
*/
readonly userHandle: ArrayBuffer;
}
/**
* Available only in secure contexts.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AuthenticatorAttestationResponse).
*/
interface AuthenticatorAttestationResponse extends AuthenticatorResponse {
/**
* Returns Public Key.
*/
getPublicKey(): ArrayBuffer;
}
interface WebAuthnCredential extends CreateCredentialReturnType {
rpId: string | undefined;
}
type GetLoginOptionsReturnType = CustomPublicKeyCredentialRequestOptions;
type GetRegistrationOptionsReturnType = CustomPublicKeyCredentialCreationOptions;
interface GetLoginVerificationReturnType {
publicKey: string;
}
interface GetRegistrationVerificationReturnType {
verified?: boolean | null;
}
/**
* Copyright 2025 Circle Internet Group, Inc. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at.
*
* Http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Generate login options, including a challenge for verification, and return them to the client.
*/
type GetLoginOptionsRpcSchema = {
Method: 'rp_getLoginOptions';
Parameters?: [userId: string];
ReturnType: GetLoginOptionsReturnType;
};
/**
* Verify the login response (authentication credential) and report the outcome to the client.
*/
type GetLoginVerificationRpcSchema = {
Method: 'rp_getLoginVerification';
Parameters?: [authenticationCredential: PublicKeyCredential$1];
ReturnType: GetLoginVerificationReturnType;
};
/**
* Generate and return registration options to the client. The client will use these options to prompt the user to create a passkey.
*/
type GetRegistrationOptionsRpcSchema = {
Method: 'rp_getRegistrationOptions';
Parameters?: [username: string];
ReturnType: GetRegistrationOptionsReturnType;
};
/**
* Verify the registration response (registration credential) and return the results to the client.
*/
type GetRegistrationVerificationRpcSchema = {
Method: 'rp_getRegistrationVerification';
Parameters?: [registrationCredential: PublicKeyCredential$1];
ReturnType: GetRegistrationVerificationReturnType;
};
/**
* Gets the Circle modular wallet address for the user.
*/
type GetAddressRpcSchema = {
Method: 'circle_getAddress';
Parameters?: [
{
scaConfiguration: {
initialOwnershipConfiguration: Omit<InitialOwnershipConfiguration, 'ownershipContractAddress'>;
scaCore: string;
};
}
];
ReturnType: GetAddressReturnType;
};
/**
* The RPC schema for adding an address mapping.
*/
type CreateAddressMappingRpcSchema = {
Method: 'circle_createAddressMapping';
Parameters: [CreateAddressMappingParameters];
ReturnType: CreateAddressMappingReturnType;
};
/**
* Get the address mapping for the specified owner.
*/
type GetAddressMappingRpcSchema = {
Method: 'circle_getAddressMapping';
Parameters: [GetAddressMappingParameters];
ReturnType: GetAddressMappingReturnType;
};
/**
* Gets the gas prices for user operations.
*/
type GetUserOperationGasPriceRpcSchema = {
Method: 'circle_getUserOperationGasPrice';
Parameters?: [];
ReturnType: GetUserOperationGasPriceReturnType;
};
type RpRpcSchema = [
GetLoginOptionsRpcSchema,
GetLoginVerificationRpcSchema,
GetRegistrationOptionsRpcSchema,
GetRegistrationVerificationRpcSchema
];
type ModularWalletRpcSchema = [
GetAddressRpcSchema,
CreateAddressMappingRpcSchema,
GetAddressMappingRpcSchema,
GetUserOperationGasPriceRpcSchema
];
/**
* Copyright 2025 Circle Internet Group, Inc. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at.
*
* Http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
declare const CIRCLE_MSCA_6900_V1_EP07_FACTORY_ABI: readonly [{
readonly inputs: readonly [{
readonly internalType: "address";
readonly name: "_owner";
readonly type: "address";
}, {
readonly internalType: "address";
readonly name: "_entryPointAddr";
readonly type: "address";
}, {
readonly internalType: "address";
readonly name: "_pluginManagerAddr";
readonly type: "address";
}];
readonly stateMutability: "nonpayable";
readonly type: "constructor";
}, {
readonly inputs: readonly [];
readonly name: "Create2FailedDeployment";
readonly type: "error";
}, {
readonly inputs: readonly [];
readonly name: "InvalidInitializationInput";
readonly type: "error";
}, {
readonly inputs: readonly [];
readonly name: "InvalidLength";
readonly type: "error";
}, {
readonly inputs: readonly [{
readonly internalType: "address";
readonly name: "owner";
readonly type: "address";
}];
readonly name: "OwnableInvalidOwner";
readonly type: "error";
}, {
readonly inputs: readonly [{
readonly internalType: "address";
readonly name: "account";
readonly type: "address";
}];
readonly name: "OwnableUnauthorizedAccount";
readonly type: "error";
}, {
readonly inputs: readonly [{
readonly internalType: "address";
readonly name: "plugin";
readonly type: "address";
}];
readonly name: "PluginIsNotAllowed";
readonly type: "error";
}, {
readonly anonymous: false;
readonly inputs: readonly [{
readonly indexed: true;
readonly internalType: "address";
readonly name: "proxy";
readonly type: "address";
}, {
readonly indexed: false;
readonly internalType: "bytes32";
readonly name: "sender";
readonly type: "bytes32";
}, {
readonly indexed: false;
readonly internalType: "bytes32";
readonly name: "salt";
readonly type: "bytes32";
}];
readonly name: "AccountCreated";
readonly type: "event";
}, {
readonly anonymous: false;
readonly inputs: readonly [{
readonly indexed: true;
readonly internalType: "address";
readonly name: "factory";
readonly type: "address";
}, {
readonly indexed: false;
readonly internalType: "address";
readonly name: "accountImplementation";
readonly type: "address";
}, {
readonly indexed: false;
readonly internalType: "address";
readonly name: "entryPoint";
readonly type: "address";
}];
readonly name: "FactoryDeployed";
readonly type: "event";
}, {
readonly anonymous: false;
readonly inputs: readonly [{
readonly indexed: true;
readonly internalType: "address";
readonly name: "previousOwner";
readonly type: "address";
}, {
readonly indexed: true;
readonly internalType: "address";
readonly name: "newOwner";
readonly type: "address";
}];
readonly name: "OwnershipTransferStarted";
readonly type: "event";
}, {
readonly anonymous: false;
readonly inputs: readonly [{
readonly indexed: true;
readonly internalType: "address";
readonly name: "previousOwner";
readonly type: "address";
}, {
readonly indexed: true;
readonly internalType: "address";
readonly name: "newOwner";
readonly type: "address";
}];
readonly name: "OwnershipTransferred";
readonly type: "event";
}, {
readonly inputs: readonly [];
readonly name: "ACCOUNT_IMPLEMENTATION";
readonly outputs: readonly [{
readonly internalType: "contract UpgradableMSCA";
readonly name: "";
readonly type: "address";
}];
readonly stateMutability: "view";
readonly type: "function";
}, {
readonly inputs: readonly [];
readonly name: "ENTRY_POINT";
readonly outputs: readonly [{
readonly internalType: "contract IEntryPoint";
readonly name: "";
readonly type: "address";
}];
readonly stateMutability: "view";
readonly type: "function";
}, {
readonly inputs: readonly [];
readonly name: "acceptOwnership";
readonly outputs: readonly [];
readonly stateMutability: "nonpayable";
readonly type: "function";
}, {
readonly inputs: readonly [{
readonly internalType: "uint32";
readonly name: "_unstakeDelaySec";
readonly type: "uint32";
}];
readonly name: "addStake";
readonly outputs: readonly [];
readonly stateMutability: "payable";
readonly type: "function";
}, {
readonly inputs: readonly [{
readonly internalType: "bytes32";
readonly name: "_sender";
readonly type: "bytes32";
}, {
readonly internalType: "bytes32";
readonly name: "_salt";
readonly type: "bytes32";
}, {
readonly internalType: "bytes";
readonly name: "_initializingData";
readonly type: "bytes";
}];
readonly name: "createAccount";
readonly outputs: readonly [{
readonly internalType: "contract UpgradableMSCA";
readonly name: "account";
readonly type: "address";
}];
readonly stateMutability: "nonpayable";
readonly type: "function";
}, {
readonly inputs: readonly [{
readonly internalType: "bytes32";
readonly name: "_sender";
readonly type: "bytes32";
}, {
readonly internalType: "bytes32";
readonly name: "_salt";
readonly type: "bytes32";
}, {
readonly internalType: "bytes";
readonly name: "_initializingData";
readonly type: "bytes";
}];
readonly name: "getAddress";
readonly outputs: readonly [{
readonly internalType: "address";
readonly name: "addr";
readonly type: "address";
}, {
readonly internalType: "bytes32";
readonly name: "mixedSalt";
readonly type: "bytes32";
}];
readonly stateMutability: "view";
readonly type: "function";
}, {
readonly inputs: readonly [{
readonly internalType: "address";
readonly name: "";
readonly type: "address";
}];
readonly name: "isPluginAllowed";
readonly outputs: readonly [{
readonly internalType: "bool";
readonly name: "";
readonly type: "bool";
}];
readonly stateMutability: "view";
readonly type: "function";
}, {
readonly inputs: readonly [];
readonly name: "owner";
readonly outputs: readonly [{
readonly internalType: "address";
readonly name: "";
readonly type: "address";
}];
readonly stateMutability: "view";
readonly type: "function";
}, {
readonly inputs: readonly [];
readonly name: "pendingOwner";
readonly outputs: readonly [{
readonly internalType: "address";
readonly name: "";
readonly type: "address";
}];
readonly stateMutability: "view";
readonly type: "function";
}, {
readonly inputs: readonly [];
readonly name: "renounceOwnership";
readonly outputs: readonly [];
readonly stateMutability: "nonpayable";
readonly type: "function";
}, {
readonly inputs: readonly [{
readonly internalType: "address[]";
readonly name: "_plugins";
readonly type: "address[]";
}, {
readonly internalType: "bool[]";
readonly name: "_permissions";
readonly type: "bool[]";
}];
readonly name: "setPlugins";
readonly outputs: readonly [];
readonly stateMutability: "nonpayable";
readonly type: "function";
}, {
readonly inputs: readonly [{
readonly internalType: "address";
readonly name: "newOwner";
readonly type: "address";
}];
readonly name: "transferOwnership";
readonly outputs: readonly [];
readonly stateMutability: "nonpayable";
readonly type: "function";
}, {
readonly inputs: readonly [];
readonly name: "unlockStake";
readonly outputs: readonly [];
readonly stateMutability: "nonpayable";
readonly type: "function";
}, {
readonly inputs: readonly [{
readonly internalType: "address payable";
readonly name: "_withdrawAddress";
readonly type: "address";
}];
readonly name: "withdrawStake";
readonly outputs: readonly [];
readonly stateMutability: "nonpayable";
readonly type: "function";
}];
/**
* Copyright 2025 Circle Internet Group, Inc. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at.
*
* Http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Parameters to create a Circle smart account.
*/
type ToCircleSmartAccountParameters = {
/**
* The address.
*/
address?: Address;
/**
* The client instance.
*/
client: Client;
/**
* The owner.
*/
owner: LocalAccount | WebAuthnAccount;
/**
* The Nonce.
*/
nonce?: bigint;
/**
* The Circle Smart Account Wallet Name.
*/
name?: string;
};
/**
* Return type of the Circle smart account.
*/
type ToCircleSmartAccountReturnType = Prettify<SmartAccount<CircleSmartAccountImplementation>>;
/**
* Circle smart account implementation.
*/
type CircleSmartAccountImplementation = Assign<SmartAccountImplementation<typeof entryPoint07Abi, '0.7', {
abi: typeof entryPoint07Abi;
factory: {
abi: typeof CIRCLE_MSCA_6900_V1_EP07_FACTORY_ABI;
address: Address;
};
}>, {
sign: NonNullable<SmartAccountImplementation['sign']>;
getFactoryArgs: NonNullable<SmartAccountImplementation['getFactoryArgs']>;
}>;
type GetAddressParameters = [
{
/**
* The SCA configuration.
*/
scaConfiguration: {
initialOwnershipConfiguration: Omit<InitialOwnershipConfiguration, 'ownershipContractAddress'>;
scaCore: string;
};
/**
* The metadata.
*/
metadata?: {
name?: string;
};
}
];
/**
* Gets the Circle smart wallet address for the user.
* @param client - Client to use.
* @param params - Parameters to use. See {@link GetAddressParameters}.
* @returns Circle smart wallet creation response. See {@link GetAddressReturnType}.
*/
declare function getAddress(client: Client<Transport>, params: GetAddressParameters): Promise<ModularWallet>;
/**
* Copyright 2025 Circle Internet Group, Inc. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at.
*
* Http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Gets the address mapping for a given owner.
* @param client - Client to use.
* @param parameters - Parameters to use. See {@link GetAddressMappingParameters}.
* @returns The mapping result. See {@link GetAddressMappingReturnType}.
* @throws Error if the parameters are invalid.
*/
declare function getAddressMapping(client: Client<Transport>, parameters: GetAddressMappingParameters): Promise<GetAddressMappingReturnType>;
/**
* Copyright 2025 Circle Internet Group, Inc. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at.
*
* Http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Creates an address mapping for recovery.
* @param client - Client to use.
* @param parameters - Parameters to use. See {@link CreateAddressMappingParameters}.
* @returns The mapping result. See {@link CreateAddressMappingReturnType}.
* @throws Error if the parameters are invalid.
*/
declare function createAddressMapping(client: Client<Transport>, parameters: CreateAddressMappingParameters): Promise<CreateAddressMappingReturnType>;
/**
* Copyright 2025 Circle Internet Group, Inc. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at.
*
* Http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Gets the user operation gas price.
* @param client - Client to use.
* @returns The user operation gas price. See {@link GetUserOperationGasPriceReturnType}.
*/
declare function getUserOperationGasPrice(client: Client<Transport>): Promise<GetUserOperationGasPriceReturnType>;
/**
* Copyright 2025 Circle Internet Group, Inc. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at.
*
* Http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
interface EstimateRegisterRecoveryAddressGasParameters extends Omit<EstimateUserOperationGasParameters, 'callData'> {
/**
* The derived address of the recovery key.
*/
recoveryAddress: Address$1;
}
/**
* Estimates the gas required to register a recovery address during the recovery process.
* @param client - Client to use.
* @param params - Parameters to use. See {@link EstimateRegisterRecoveryAddressGasParameters}.
* @returns An estimate of gas values necessary to register a recovery address. See {@link EstimateUserOperationGasReturnType}.
*/
declare function estimateRegisterRecoveryAddressGas(client: Client<Transport, Chain | undefined, SmartAccount$1 | undefined>, params: EstimateRegisterRecoveryAddressGasParameters): Promise<EstimateUserOperationGasReturnType>;
/**
* Copyright 2025 Circle Internet Group, Inc. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at.
*
* Http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
interface EstimateExecuteRecoveryGasParameters extends Omit<EstimateUserOperationGasParameters, 'callData'> {
/**
* The newly registered passkey credential.
*/
credential: P256Credential;
}
/**
* Estimates the gas required to execute and finalize the recovery process.
* @param client - Client to use.
* @param params - Parameters to use. See {@link EstimateExecuteRecoveryGasParameters}.
* @returns An estimate of gas values necessary to execute recovery. See {@link EstimateUserOperationGasReturnType}.
*/
declare function estimateExecuteRecoveryGas(client: Client<Transport, Chain | undefined, SmartAccount$1 | undefined>, params: EstimateExecuteRecoveryGasParameters): Promise<EstimateUserOperationGasReturnType>;
/**
* Copyright 2025 Circle Internet Group, Inc. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at.
*
* Http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
interface ExecuteRecoveryParameters extends Omit<SendUserOperationParameters, 'callData'> {
/**
* The newly registered passkey credential.
*/
credential: P256Credential;
}
/**
* Executes and finalizes the recovery process.
* @param client - Client to use.
* @param params - Parameters to use. See {@link ExecuteRecoveryParameters}.
* @returns The user operation hash from executing recovery onchain. See {@link SendUserOperationReturnType}.
*/
declare function executeRecovery(client: Client<Transport, Chain | undefined, SmartAccount$1 | undefined>, params: ExecuteRecoveryParameters): Promise<SendUserOperationReturnType>;
/**
* Copyright 2025 Circle Internet Group, Inc. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at.
*
* Http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
interface RegisterRecoveryAddressParameters extends Omit<SendUserOperationParameters, 'callData'> {
/**
* The recovery address.
*/
recoveryAddress: Address$1;
}
/**
* Registers a recovery address during the recovery process.
* @param client - Client to use.
* @param params - Parameters to use. See {@link RegisterRecoveryAddressParameters}.
* @returns The user operation hash from registering the recovery address onchain. See {@link SendUserOperationReturnType}.
*/
declare function registerRecoveryAddress(client: Client<Transport, Chain | undefined, SmartAccount$1 | undefined>, params: RegisterRecoveryAddressParameters): Promise<SendUserOperationReturnType>;
type GetLoginOptionsParameters = {
userId: string;
};
/**
* Returns the login options, including a challenge for verification.
* @param client - Client to use.
* @param parameters - Parameters to use. See {@link GetLoginOptionsParameters}.
* @returns Credential Request Options. See {@link GetLoginOptionsReturnType}.
*/
declare function getLoginOptions(client: Client<Transport>, { userId }: GetLoginOptionsParameters): Promise<CustomPublicKeyCredentialRequestOptions>;
/**
* Copyright 2025 Circle Internet Group, Inc. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at.
*
* Http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
type GetLoginVerificationParameters = {
credential: PublicKeyCredential$1;
};
/**
* Returns the login verification response to indicate if it's verified or not.
* @param client - Client to use.
* @param parameters - Parameters to use. See {@link GetLoginVerificationParameters}.
* @returns WebAuthn Verification Response. See {@link GetLoginVerificationReturnType}.
*/
declare function getLoginVerification(client: Client<Transport>, { credential }: GetLoginVerificationParameters): Promise<GetLoginVerificationReturnType>;
type GetRegistrationOptionsParameters = {
username: string;
};
/**
* Returns the registration options, including a challenge for verification.
* @param client - Client to use.
* @param parameters - Parameters to use. See {@link GetRegistrationOptionsParameters}.
* @returns Credential Creation Options. See {@link GetRegistrationOptionsReturnType}.
*/
declare function getRegistrationOptions(client: Client<Transport>, { username }: GetRegistrationOptionsParameters): Promise<CustomPublicKeyCredentialCreationOptions>;
/**
* Copyright 2025 Circle Internet Group, Inc. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at.
*
* Http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
type GetRegistrationVerificationParameters = {
credential: PublicKeyCredential$1;
};
/**
* Returns the registration verification response to indicate if it's verified or not.
* @param client - Client to use.
* @param parameters - Parameters to use. See {@link GetRegistrationVerificationParameters}.
* @returns WebAuthn Verification Response. See {@link GetRegistrationVerificationReturnType}.
*/
declare function getRegistrationVerification(client: Client<Transport>, { credential }: GetRegistrationVerificationParameters): Promise<GetRegistrationVerificationReturnType>;
/**
* Copyright 2025 Circle Internet Group, Inc. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at.
*
* Http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
type ModularWalletActions = {
/**
* Gets the modular wallet address for the user.
* @param parameters - Parameters to use. See {@link GetAddressParameters}.
* @returns Wallets created. See {@link GetAddressReturnType}.
*/
getAddress: (parameters: GetAddressParameters) => Promise<GetAddressReturnType>;
/**
* Creates an address mapping between new account owners and the modular wallet.
* @param parameters - Parameters to use. See {@link CreateAddressMappingParameters}.
* @returns Address mapping id. See {@link CreateAddressMappingReturnType}.
*/
createAddressMapping: (parameters: CreateAddressMappingParameters) => Promise<CreateAddressMappingReturnType>;
/**
* Gets the address mapping for the modular wallet.
* @param parameters - Parameters to use. See {@link GetAddressMappingParameters}.
* @returns Address mapping. See {@link GetAddressMappingReturnType}.
*/
getAddressMapping: (parameters: GetAddressMappingParameters) => Promise<GetAddressMappingReturnType>;
/**
* Gets the gas prices for user operations.
* @returns Gas prices. See {@link GetUserOperationGasPriceReturnType}.
*/
getUserOperationGasPrice: () => Promise<GetUserOperationGasPriceReturnType>;
};
/**
* Returns the Modular Wallets actions.
* @param client - Client to use.
* @returns Modular Wallets Actions. See {@link ModularWalletActions}.
*/
declare function modularWalletActions<transport extends Transport = Transport>(client: Client<transport>): ModularWalletActions;
/**
* Copyright 2025 Circle Internet Group, Inc. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at.
*
* Http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
type RecoveryActions = {
/**
* Estimates the gas for registering a recovery address.
* @param parameters - Parameters to use. See {@link EstimateRegisterRecoveryAddressGasParameters}.
* @returns An estimate of gas values necessary to register a recovery address. See {@link EstimateUserOperationGasReturnType}.
*/
estimateRegisterRecoveryAddressGas: (parameters: EstimateRegisterRecoveryAddressGasParameters) => Promise<EstimateUserOperationGasReturnType$1>;
/**
* Estimates the gas for executing recovery.
* @param parameters - Parameters to use. See {@link EstimateExecuteRecoveryGasParameters}.
* @returns An estimate of gas values necessary to execute recovery. See {@link EstimateUserOperationGasReturnType}.
*/
estimateExecuteRecoveryGas: (parameters: EstimateExecuteRecoveryGasParameters) => Promise<EstimateUserOperationGasReturnType$1>;
/**
* Executes the recovery process.
* @param parameters - Parameters to use. See {@link ExecuteRecoveryParameters}.
* @returns The user operation hash from executing recovery onchain. See {@link SendUserOperationReturnType}.
*/
executeRecovery: (parameters: ExecuteRecoveryParameters) => Promise<SendUserOperationReturnType$1>;
/**
* Registers a recovery address during the recovery process.
* @param parameters - Parameters to use. See {@link RegisterRecoveryAddressParameters}.
* @returns The user operation hash from registering the recovery address onchain. See {@link SendUserOperationReturnType}.
*/
registerRecoveryAddress: (params: RegisterRecoveryAddressParameters) => Promise<SendUserOperationReturnType$1>;
};
/**
* Returns the Recovery actions.
* @param client - Client to use.
* @returns Recovery Actions. See {@link RecoveryActions}.
*/
declare function recoveryActions<transport extends Transport = Transport>(client: Client<transport, Chain | undefined, SmartAccount$2 | undefined>): RecoveryActions;
/**
* Copyright 2025 Circle Internet Group, Inc. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at.
*
* Http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
type RpActions = {
/**
* Returns the login options, including a challenge for verification.
* @param parameters - Parameters to use. See {@link GetLoginOptionsParameters}.
* @returns Credential Request Options. See {@link GetLoginOptionsReturnType}.
*/
getLoginOptions: (parameters: GetLoginOptionsParameters) => Promise<GetLoginOptionsReturnType>;
/**
* Returns the login verification response to indicate if it's verified or not.
* @param parameters - Parameters to use. See {@link GetLoginVerificationParameters}.
* @returns WebAuthn Verification Response. See {@link GetLoginVerificationReturnType}.
*/
getLoginVerification: (parameters: GetLoginVerificationParameters) => Promise<GetLoginVerificationReturnType>;
/**
* Returns the registration options, including a challenge for verification.
* @param parameters - Parameters to use. See {@link GetRegistrationOptionsParameters}.
* @returns Credential Creation Options. See {@link GetRegistrationOptionsReturnType}.
*/
getRegistrationOptions: (parameters: GetRegistrationOptionsParameters) => Promise<GetRegistrationOptionsReturnType>;
/**
* Returns the registration verification response to indicate if it's verified or not.
* @param parameters - Parameters to use. See {@link GetRegistrationVerificationParameters}.
* @returns WebAuthn Verification Response. See {@link GetRegistrationVerificationReturnType}.
*/
getRegistrationVerification: (parameters: GetRegistrationVerificationParameters) => Promise<GetRegistrationVerificationReturnType>;
};
/**
* Returns the RP actions.
* @param client - Client to use.
* @returns Rp Actions. See.
*/
declare function rpActions<transport extends Transport = Transport>(client: Client<transport>): RpActions;
/**
* Copyright 2025 Circle Internet Group, Inc. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at.
*
* Http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
type RpClientConfig<transport extends Transport = Transport, rpcSchema extends RpcSchema | undefined = undefined> = Prettify<Pick<ClientConfig<transport, undefined, undefined, rpcSchema>, 'cacheTime' | 'key' | 'name' | 'pollingInterval' | 'rpcSchema' | 'transport'>>;
type RpClient<transport extends Transport = Transport, rpcSchema extends RpcSchema | undefined = undefined> = Prettify<Client<transport, undefined, undefined, rpcSchema extends RpcSchema ? [...RpRpcSchema, ...rpcSchema] : RpRpcSchema, RpActions>>;
type CreateRpClientErrorType = CreateClientErrorType | ErrorType;
/**
* Creates a RP Client.
* @param parameters - See {@link RpClientConfig}.
* @returns A RP Client. See {@link RpClient}.
*/
declare function createRpClient<transport extends Transport, rpcSchema extends RpcSchema | undefined = undefined>(parameters: RpClientConfig<transport, rpcSchema>): RpClient<transport, rpcSchema>;
/**
* Copyright 2025 Circle Internet Group, Inc. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at.
*
* Http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
interface ToCircleModularWalletClientParameters {
/**
* The client instance.
*/
client: Client;
}
type ExtendedRpcSchema<rpcSchema extends RpcSchema | undefined = undefined> = rpcSchema extends RpcSchema ? [...ModularWalletRpcSchema, ...rpcSchema] : ModularWalletRpcSchema;
type CircleModularWalletClient = Client<Transport, Chain | undefined, Account | undefined, ExtendedRpcSchema<RpcSchema>, ModularWalletActions>;
/**
* Transforms a client into a Circle modular wallet client using decorators.
* @param parameters - Parameters to use. See {@link ToCircleModularWalletClientParameters}.
* @returns A decorated Circle modular wallet client. See {@link CircleModularWalletClient}.
*/
declare function toCircleModularWalletClient({ client, }: ToCircleModularWalletClientParameters): CircleModularWalletClient;
/**
* Copyright 2025 Circle Internet Group, Inc. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at.
*
* Http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Creates a custom transport instance with the given clientUrl and clientKey.
* @param clientUrl - The Client URL to use.
* @param clientKey - The Client key to use.
* @returns The custom transport instance.
*/
declare const toModularTransport: (clientUrl: string, clientKey: string) => viem.CustomTransport;
/**
* Copyright 2025 Circle Internet Group, Inc. All rights reserved.