@crossmint/client-sdk-smart-wallet 0.1.6 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +4 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/api/CrossmintWalletService.ts +1 -1
- package/src/blockchain/chains.ts +2 -2
- package/src/blockchain/rpc.ts +18 -0
- package/src/blockchain/wallets/service.ts +2 -3
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/blockchain/wallets/EVMSmartWallet.ts","../src/services/logger.ts","../src/utils/constants.ts","../src/blockchain/transfer.ts","../src/ABI/ERC1155.json","../src/error/index.ts","../src/SmartWalletSDK.ts","../src/api/CrossmintWalletService.ts","../src/types/schema.ts","../src/utils/api.ts","../src/blockchain/wallets/account/cache.ts","../src/blockchain/wallets/account/signer.ts","../src/blockchain/wallets/account/config.ts","../src/types/internal.ts","../src/blockchain/wallets/account/creator.ts","../src/blockchain/wallets/account/eoa.ts","../src/utils/helpers.ts","../src/utils/signer.ts","../src/blockchain/wallets/account/passkey.ts","../src/blockchain/wallets/clientDecorator.ts","../src/utils/blockchain.ts","../src/blockchain/wallets/service.ts","../src/blockchain/chains.ts","../src/blockchain/wallets/paymaster.ts","../src/error/processor.ts","../src/utils/environment.ts"],"sourcesContent":["export { blockchainToChainId, EVMBlockchainIncludingTestnet as Chain } from \"@crossmint/common-sdk-base\";\n\nexport { EVMSmartWallet } from \"./blockchain/wallets/EVMSmartWallet\";\n\nexport type {\n SmartWalletSDKInitParams,\n UserParams,\n ViemAccount,\n PasskeySigner,\n EOASigner,\n WalletParams,\n} from \"./types/params\";\n\nexport type { TransferType, ERC20TransferType, NFTTransferType, SFTTransferType } from \"./types/token\";\n\nexport {\n SmartWalletError,\n UserWalletAlreadyCreatedError,\n AdminAlreadyUsedError,\n AdminMismatchError,\n PasskeyMismatchError,\n PasskeyPromptError,\n PasskeyRegistrationError,\n PasskeyIncompatibleAuthenticatorError,\n ConfigError,\n SmartWalletsNotEnabledError,\n} from \"./error\";\n\nexport {\n SmartWalletErrorCode,\n CrossmintSDKError,\n CrossmintServiceError,\n TransferError,\n JWTDecryptionError,\n JWTExpiredError,\n JWTIdentifierError,\n JWTInvalidError,\n NotAuthorizedError,\n} from \"@crossmint/client-sdk-base\";\n\nexport { SmartWalletSDK } from \"./SmartWalletSDK\";\n","import { type HttpTransport, type PublicClient, isAddress, publicActions } from \"viem\";\n\nimport { TransferError } from \"@crossmint/client-sdk-base\";\n\nimport type { CrossmintWalletService } from \"../../api/CrossmintWalletService\";\nimport { scwLogger } from \"../../services/logger\";\nimport { SmartWalletClient } from \"../../types/internal\";\nimport type { TransferType } from \"../../types/token\";\nimport { SmartWalletChain } from \"../chains\";\nimport { transferParams } from \"../transfer\";\n\n/**\n * Smart wallet interface for EVM chains enhanced with Crossmint capabilities.\n * Core functionality is exposed via [viem](https://viem.sh/) clients within the `client` property of the class.\n */\nexport class EVMSmartWallet {\n public readonly chain: SmartWalletChain;\n\n /**\n * [viem](https://viem.sh/) clients that provide an interface for core wallet functionality.\n */\n public readonly client: {\n /**\n * An interface to interact with the smart wallet, execute transactions, sign messages, etc.\n */\n wallet: SmartWalletClient;\n\n /**\n * An interface to read onchain data, fetch transactions, retrieve account balances, etc. Corresponds to public [JSON-RPC API](https://ethereum.org/en/developers/docs/apis/json-rpc/) methods.\n */\n public: PublicClient;\n };\n\n constructor(\n private readonly crossmintService: CrossmintWalletService,\n private readonly accountClient: SmartWalletClient,\n publicClient: PublicClient<HttpTransport>,\n chain: SmartWalletChain,\n protected readonly logger = scwLogger\n ) {\n this.chain = chain;\n this.client = {\n wallet: accountClient,\n public: publicClient,\n };\n }\n\n /**\n * The address of the smart wallet.\n */\n public get address() {\n return this.accountClient.account.address;\n }\n\n /**\n * @returns The transaction hash.\n */\n public async transferToken(toAddress: string, config: TransferType): Promise<string> {\n return this.logger.logPerformance(\n \"TRANSFER\",\n async () => {\n if (this.chain !== config.token.chain) {\n throw new Error(\n `Chain mismatch: Expected ${config.token.chain}, but got ${this.chain}. Ensure you are interacting with the correct blockchain.`\n );\n }\n\n if (!isAddress(toAddress)) {\n throw new Error(`Invalid recipient address: '${toAddress}' is not a valid EVM address.`);\n }\n\n if (!isAddress(config.token.contractAddress)) {\n throw new Error(\n `Invalid contract address: '${config.token.contractAddress}' is not a valid EVM address.`\n );\n }\n\n const tx = transferParams({\n contract: config.token.contractAddress,\n to: toAddress,\n from: this.accountClient.account,\n config,\n });\n\n try {\n const client = this.accountClient.extend(publicActions);\n const { request } = await client.simulateContract(tx);\n const hash = await client.writeContract(request);\n this.logger.log(`[TRANSFER] - Transaction hash from transfer: ${hash}`);\n\n return hash;\n } catch (error) {\n this.logger.error(\"[TRANSFER] - ERROR_TRANSFERRING_TOKEN\", {\n error: error instanceof Error ? error.message : JSON.stringify(error),\n tokenId: tx.tokenId,\n contractAddress: config.token.contractAddress,\n chain: config.token.chain,\n });\n const tokenIdString = tx.tokenId == null ? \"\" : `:${tx.tokenId}}`;\n throw new TransferError(`Error transferring token ${config.token.contractAddress}${tokenIdString}`);\n }\n },\n { toAddress, config }\n );\n }\n\n /**\n * @returns A list of NFTs owned by the wallet.\n */\n public async nfts() {\n return this.crossmintService.fetchNFTs(this.address, this.chain);\n }\n}\n","import { SDKLogger, getBrowserLogger } from \"@crossmint/client-sdk-base\";\n\nimport { SCW_SERVICE } from \"../utils/constants\";\n\nexport const scwLogger = new SDKLogger(SCW_SERVICE);\nexport const scwDatadogLogger = new SDKLogger(SCW_SERVICE, getBrowserLogger(SCW_SERVICE, { onlyDatadog: true }));\n","export const ZERO_DEV_TYPE = \"ZeroDev\";\nexport const CURRENT_VERSION = 0;\nexport const SCW_SERVICE = \"SCW_SDK\";\nexport const SDK_VERSION = \"0.1.0\";\nexport const API_VERSION = \"2024-06-09\";\nexport const BUNDLER_RPC = \"https://rpc.zerodev.app/api/v2/bundler/\";\nexport const PAYMASTER_RPC = \"https://rpc.zerodev.app/api/v2/paymaster/\";\nexport const SUPPORTED_KERNEL_VERSIONS = [\"0.3.1\", \"0.3.0\", \"0.2.4\"] as const;\nexport const SUPPORTED_ENTRYPOINT_VERSIONS = [\"v0.6\", \"v0.7\"] as const;\n","import { Abi, Account, Address, erc20Abi, erc721Abi } from \"viem\";\n\nimport erc1155Abi from \"../ABI/ERC1155.json\";\nimport type { ERC20TransferType, SFTTransferType, TransferType } from \"../types/token\";\n\ntype TransferInputParams = {\n from: Account;\n contract: Address;\n to: Address;\n config: TransferType;\n};\n\ntype TransferSimulationParams = {\n account: Account;\n address: Address;\n abi: Abi;\n functionName: string;\n args: any[];\n tokenId?: string;\n};\n\nexport function transferParams({ contract, config, from, to }: TransferInputParams): TransferSimulationParams {\n switch (config.token.type) {\n case \"ft\": {\n return {\n account: from,\n address: contract,\n abi: erc20Abi,\n functionName: \"transfer\",\n args: [to, (config as ERC20TransferType).amount],\n };\n }\n case \"sft\": {\n return {\n account: from,\n address: contract,\n abi: erc1155Abi as Abi,\n functionName: \"safeTransferFrom\",\n args: [from.address, to, config.token.tokenId, (config as SFTTransferType).quantity, \"0x00\"],\n tokenId: config.token.tokenId,\n };\n }\n case \"nft\": {\n return {\n account: from,\n address: contract,\n abi: erc721Abi,\n functionName: \"safeTransferFrom\",\n args: [from.address, to, config.token.tokenId],\n tokenId: config.token.tokenId,\n };\n }\n }\n}\n","[\n {\n \"inputs\": [\n {\n \"internalType\": \"string\",\n \"name\": \"uri_\",\n \"type\": \"string\"\n }\n ],\n \"stateMutability\": \"nonpayable\",\n \"type\": \"constructor\"\n },\n {\n \"anonymous\": false,\n \"inputs\": [\n {\n \"indexed\": true,\n \"internalType\": \"address\",\n \"name\": \"account\",\n \"type\": \"address\"\n },\n {\n \"indexed\": true,\n \"internalType\": \"address\",\n \"name\": \"operator\",\n \"type\": \"address\"\n },\n {\n \"indexed\": false,\n \"internalType\": \"bool\",\n \"name\": \"approved\",\n \"type\": \"bool\"\n }\n ],\n \"name\": \"ApprovalForAll\",\n \"type\": \"event\"\n },\n {\n \"anonymous\": false,\n \"inputs\": [\n {\n \"indexed\": true,\n \"internalType\": \"address\",\n \"name\": \"operator\",\n \"type\": \"address\"\n },\n {\n \"indexed\": true,\n \"internalType\": \"address\",\n \"name\": \"from\",\n \"type\": \"address\"\n },\n {\n \"indexed\": true,\n \"internalType\": \"address\",\n \"name\": \"to\",\n \"type\": \"address\"\n },\n {\n \"indexed\": false,\n \"internalType\": \"uint256[]\",\n \"name\": \"ids\",\n \"type\": \"uint256[]\"\n },\n {\n \"indexed\": false,\n \"internalType\": \"uint256[]\",\n \"name\": \"values\",\n \"type\": \"uint256[]\"\n }\n ],\n \"name\": \"TransferBatch\",\n \"type\": \"event\"\n },\n {\n \"anonymous\": false,\n \"inputs\": [\n {\n \"indexed\": true,\n \"internalType\": \"address\",\n \"name\": \"operator\",\n \"type\": \"address\"\n },\n {\n \"indexed\": true,\n \"internalType\": \"address\",\n \"name\": \"from\",\n \"type\": \"address\"\n },\n {\n \"indexed\": true,\n \"internalType\": \"address\",\n \"name\": \"to\",\n \"type\": \"address\"\n },\n {\n \"indexed\": false,\n \"internalType\": \"uint256\",\n \"name\": \"id\",\n \"type\": \"uint256\"\n },\n {\n \"indexed\": false,\n \"internalType\": \"uint256\",\n \"name\": \"value\",\n \"type\": \"uint256\"\n }\n ],\n \"name\": \"TransferSingle\",\n \"type\": \"event\"\n },\n {\n \"anonymous\": false,\n \"inputs\": [\n {\n \"indexed\": false,\n \"internalType\": \"string\",\n \"name\": \"value\",\n \"type\": \"string\"\n },\n {\n \"indexed\": true,\n \"internalType\": \"uint256\",\n \"name\": \"id\",\n \"type\": \"uint256\"\n }\n ],\n \"name\": \"URI\",\n \"type\": \"event\"\n },\n {\n \"inputs\": [\n {\n \"internalType\": \"address\",\n \"name\": \"account\",\n \"type\": \"address\"\n },\n {\n \"internalType\": \"uint256\",\n \"name\": \"id\",\n \"type\": \"uint256\"\n }\n ],\n \"name\": \"balanceOf\",\n \"outputs\": [\n {\n \"internalType\": \"uint256\",\n \"name\": \"\",\n \"type\": \"uint256\"\n }\n ],\n \"stateMutability\": \"view\",\n \"type\": \"function\"\n },\n {\n \"inputs\": [\n {\n \"internalType\": \"address[]\",\n \"name\": \"accounts\",\n \"type\": \"address[]\"\n },\n {\n \"internalType\": \"uint256[]\",\n \"name\": \"ids\",\n \"type\": \"uint256[]\"\n }\n ],\n \"name\": \"balanceOfBatch\",\n \"outputs\": [\n {\n \"internalType\": \"uint256[]\",\n \"name\": \"\",\n \"type\": \"uint256[]\"\n }\n ],\n \"stateMutability\": \"view\",\n \"type\": \"function\"\n },\n {\n \"inputs\": [\n {\n \"internalType\": \"address\",\n \"name\": \"account\",\n \"type\": \"address\"\n },\n {\n \"internalType\": \"address\",\n \"name\": \"operator\",\n \"type\": \"address\"\n }\n ],\n \"name\": \"isApprovedForAll\",\n \"outputs\": [\n {\n \"internalType\": \"bool\",\n \"name\": \"\",\n \"type\": \"bool\"\n }\n ],\n \"stateMutability\": \"view\",\n \"type\": \"function\"\n },\n {\n \"inputs\": [\n {\n \"internalType\": \"address\",\n \"name\": \"from\",\n \"type\": \"address\"\n },\n {\n \"internalType\": \"address\",\n \"name\": \"to\",\n \"type\": \"address\"\n },\n {\n \"internalType\": \"uint256[]\",\n \"name\": \"ids\",\n \"type\": \"uint256[]\"\n },\n {\n \"internalType\": \"uint256[]\",\n \"name\": \"amounts\",\n \"type\": \"uint256[]\"\n },\n {\n \"internalType\": \"bytes\",\n \"name\": \"data\",\n \"type\": \"bytes\"\n }\n ],\n \"name\": \"safeBatchTransferFrom\",\n \"outputs\": [],\n \"stateMutability\": \"nonpayable\",\n \"type\": \"function\"\n },\n {\n \"inputs\": [\n {\n \"internalType\": \"address\",\n \"name\": \"from\",\n \"type\": \"address\"\n },\n {\n \"internalType\": \"address\",\n \"name\": \"to\",\n \"type\": \"address\"\n },\n {\n \"internalType\": \"uint256\",\n \"name\": \"id\",\n \"type\": \"uint256\"\n },\n {\n \"internalType\": \"uint256\",\n \"name\": \"amount\",\n \"type\": \"uint256\"\n },\n {\n \"internalType\": \"bytes\",\n \"name\": \"data\",\n \"type\": \"bytes\"\n }\n ],\n \"name\": \"safeTransferFrom\",\n \"outputs\": [],\n \"stateMutability\": \"nonpayable\",\n \"type\": \"function\"\n },\n {\n \"inputs\": [\n {\n \"internalType\": \"address\",\n \"name\": \"operator\",\n \"type\": \"address\"\n },\n {\n \"internalType\": \"bool\",\n \"name\": \"approved\",\n \"type\": \"bool\"\n }\n ],\n \"name\": \"setApprovalForAll\",\n \"outputs\": [],\n \"stateMutability\": \"nonpayable\",\n \"type\": \"function\"\n },\n {\n \"inputs\": [\n {\n \"internalType\": \"bytes4\",\n \"name\": \"interfaceId\",\n \"type\": \"bytes4\"\n }\n ],\n \"name\": \"supportsInterface\",\n \"outputs\": [\n {\n \"internalType\": \"bool\",\n \"name\": \"\",\n \"type\": \"bool\"\n }\n ],\n \"stateMutability\": \"view\",\n \"type\": \"function\"\n },\n {\n \"inputs\": [\n {\n \"internalType\": \"uint256\",\n \"name\": \"\",\n \"type\": \"uint256\"\n }\n ],\n \"name\": \"uri\",\n \"outputs\": [\n {\n \"internalType\": \"string\",\n \"name\": \"\",\n \"type\": \"string\"\n }\n ],\n \"stateMutability\": \"view\",\n \"type\": \"function\"\n }\n]\n","import { CrossmintSDKError, SmartWalletErrorCode } from \"@crossmint/client-sdk-base\";\n\nimport { PasskeyDisplay, SignerDisplay } from \"../types/service\";\n\nexport class SmartWalletError extends CrossmintSDKError {\n constructor(message: string, details?: string, code: SmartWalletErrorCode = SmartWalletErrorCode.UNCATEGORIZED) {\n super(message, code, details);\n }\n}\n\nexport class AdminMismatchError extends SmartWalletError {\n public readonly required: SignerDisplay;\n public readonly used?: SignerDisplay;\n\n constructor(message: string, required: SignerDisplay, used?: SignerDisplay) {\n super(message, SmartWalletErrorCode.ADMIN_MISMATCH);\n this.required = required;\n this.used = used;\n }\n}\n\nexport class PasskeyMismatchError extends SmartWalletError {\n public readonly required: PasskeyDisplay;\n public readonly used?: PasskeyDisplay;\n\n constructor(message: string, required: PasskeyDisplay, used?: PasskeyDisplay) {\n super(message, SmartWalletErrorCode.PASSKEY_MISMATCH);\n this.required = required;\n this.used = used;\n }\n}\n\nexport class UserWalletAlreadyCreatedError extends SmartWalletError {\n public readonly code = SmartWalletErrorCode.USER_WALLET_ALREADY_CREATED;\n\n constructor(userId: string) {\n super(`The user with userId ${userId.toString()} already has a wallet created for this project`);\n }\n}\n\nexport class PasskeyPromptError extends SmartWalletError {\n public passkeyName: string;\n\n constructor(passkeyName: string) {\n super(\n `Prompt was either cancelled or timed out for passkey ${passkeyName}`,\n undefined,\n SmartWalletErrorCode.PASSKEY_PROMPT\n );\n this.passkeyName = passkeyName;\n }\n}\n\nexport class PasskeyRegistrationError extends SmartWalletError {\n public passkeyName: string;\n\n constructor(passkeyName: string) {\n super(\n `Registration for passkey ${passkeyName} failed, either the registration took too long, or passkey signature vaildation failed.`,\n undefined,\n SmartWalletErrorCode.PASSKEY_REGISTRATION\n );\n this.passkeyName = passkeyName;\n }\n}\n\nexport class PasskeyIncompatibleAuthenticatorError extends SmartWalletError {\n public passkeyName: string;\n\n constructor(passkeyName: string) {\n super(\n `User selected authenticator for passkey ${passkeyName} is not compatible with Crossmint's Smart Wallets.`,\n undefined,\n SmartWalletErrorCode.PASSKEY_INCOMPATIBLE_AUTHENTICATOR\n );\n this.passkeyName = passkeyName;\n }\n}\n\nexport class ConfigError extends SmartWalletError {\n constructor(message: string) {\n super(message, undefined, SmartWalletErrorCode.WALLET_CONFIG);\n }\n}\n\nexport class AdminAlreadyUsedError extends ConfigError {\n public readonly code = SmartWalletErrorCode.ADMIN_SIGNER_ALREADY_USED;\n constructor() {\n super(\"This signer was already used to create another wallet. Please use a different signer.\");\n }\n}\n\nexport class SmartWalletsNotEnabledError extends ConfigError {\n public readonly code = SmartWalletErrorCode.SMART_WALLETS_NOT_ENABLED;\n constructor() {\n super(\n \"Smart wallets are not enabled for this project. They can be enabled on the project settings page in the developer console.\"\n );\n }\n}\n","import { stringify } from \"viem\";\n\nimport { validateAPIKey } from \"@crossmint/common-sdk-base\";\n\nimport { CrossmintWalletService } from \"./api/CrossmintWalletService\";\nimport type { SmartWalletChain } from \"./blockchain/chains\";\nimport type { EVMSmartWallet } from \"./blockchain/wallets\";\nimport { AccountConfigCache } from \"./blockchain/wallets/account/cache\";\nimport { AccountConfigService } from \"./blockchain/wallets/account/config\";\nimport { AccountCreator } from \"./blockchain/wallets/account/creator\";\nimport { EOACreationStrategy } from \"./blockchain/wallets/account/eoa\";\nimport { PasskeyCreationStrategy } from \"./blockchain/wallets/account/passkey\";\nimport { ClientDecorator } from \"./blockchain/wallets/clientDecorator\";\nimport { SmartWalletService } from \"./blockchain/wallets/service\";\nimport { SmartWalletError } from \"./error\";\nimport { ErrorProcessor } from \"./error/processor\";\nimport { scwDatadogLogger, scwLogger } from \"./services\";\nimport type { SmartWalletSDKInitParams, UserParams, WalletParams } from \"./types/params\";\nimport { SDK_VERSION } from \"./utils/constants\";\nimport { isClient } from \"./utils/environment\";\n\nexport class SmartWalletSDK {\n private constructor(\n private readonly smartWalletService: SmartWalletService,\n private readonly errorProcessor: ErrorProcessor,\n private readonly logger = scwLogger\n ) {}\n\n /**\n * Initializes the SDK with the **client side** API key obtained from the Crossmint console.\n * @throws error if the api key is not formatted correctly.\n */\n static init({ clientApiKey }: SmartWalletSDKInitParams): SmartWalletSDK {\n if (!isClient()) {\n throw new SmartWalletError(\"Smart Wallet SDK should only be used client side.\");\n }\n\n const validationResult = validateAPIKey(clientApiKey);\n if (!validationResult.isValid) {\n throw new Error(\"API key invalid\");\n }\n\n const crossmintService = new CrossmintWalletService(clientApiKey);\n const errorProcessor = new ErrorProcessor(scwDatadogLogger);\n const accountCreator = new AccountCreator(\n new EOACreationStrategy(),\n new PasskeyCreationStrategy(crossmintService.getPasskeyServerUrl(), clientApiKey)\n );\n const accountCache = new AccountConfigCache(`smart-wallet-${SDK_VERSION}`);\n\n const smartWalletService = new SmartWalletService(\n crossmintService,\n new AccountConfigService(crossmintService, accountCache),\n accountCreator,\n new ClientDecorator(errorProcessor)\n );\n\n return new SmartWalletSDK(smartWalletService, errorProcessor);\n }\n\n /**\n * Retrieves or creates a wallet for the specified user.\n * The default configuration is a `PasskeySigner` with the name, which is displayed to the user during creation or signing prompts, derived from the provided jwt.\n *\n * Example using the default passkey signer:\n * ```ts\n * const wallet = await smartWalletSDK.getOrCreateWallet({ jwt: \"xxx\" }, \"base\");\n * ```\n */\n async getOrCreateWallet(\n user: UserParams,\n chain: SmartWalletChain,\n walletParams: WalletParams = { signer: { type: \"PASSKEY\" } }\n ): Promise<EVMSmartWallet> {\n return this.logger.logPerformance(\"GET_OR_CREATE_WALLET\", async () => {\n try {\n return await this.smartWalletService.getOrCreate(user, chain, walletParams);\n } catch (error: any) {\n throw this.errorProcessor.map(\n error,\n new SmartWalletError(`Wallet creation failed: ${error.message}.`, stringify(error))\n );\n }\n });\n }\n}\n","import type { UserOperation } from \"permissionless\";\nimport type { EntryPoint, GetEntryPointVersion } from \"permissionless/types/entrypoint\";\n\nimport { APIErrorService, BaseCrossmintService, CrossmintServiceError } from \"@crossmint/client-sdk-base\";\nimport { blockchainToChainId } from \"@crossmint/common-sdk-base\";\n\nimport type { SmartWalletChain } from \"../blockchain/chains\";\nimport { AdminAlreadyUsedError, SmartWalletsNotEnabledError, UserWalletAlreadyCreatedError } from \"../error\";\nimport { scwLogger } from \"../services\";\nimport type { UserParams } from \"../types/params\";\nimport { SmartWalletConfigSchema } from \"../types/schema\";\nimport type { SmartWalletConfig, StoreSmartWalletParams } from \"../types/service\";\nimport { bigintsToHex, parseBigintAPIResponse } from \"../utils/api\";\nimport { API_VERSION } from \"../utils/constants\";\n\ntype WalletsAPIErrorCodes =\n | \"ERROR_USER_WALLET_ALREADY_CREATED\"\n | \"ERROR_ADMIN_SIGNER_ALREADY_USED\"\n | \"ERROR_PROJECT_NONCUSTODIAL_WALLETS_NOT_ENABLED\";\n\nexport class CrossmintWalletService extends BaseCrossmintService {\n logger = scwLogger;\n protected apiErrorService = new APIErrorService<WalletsAPIErrorCodes>({\n ERROR_USER_WALLET_ALREADY_CREATED: ({ userId }: { userId: string }) =>\n new UserWalletAlreadyCreatedError(userId),\n ERROR_ADMIN_SIGNER_ALREADY_USED: () => new AdminAlreadyUsedError(),\n ERROR_PROJECT_NONCUSTODIAL_WALLETS_NOT_ENABLED: () => new SmartWalletsNotEnabledError(),\n });\n\n async idempotentCreateSmartWallet(user: UserParams, input: StoreSmartWalletParams): Promise<void> {\n await this.fetchCrossmintAPI(\n `${API_VERSION}/sdk/smart-wallet`,\n { method: \"PUT\", body: JSON.stringify(input) },\n \"Error creating abstract wallet. Please contact support\",\n user.jwt\n );\n }\n\n async sponsorUserOperation<E extends EntryPoint>(\n user: UserParams,\n userOp: UserOperation<GetEntryPointVersion<E>>,\n entryPoint: E,\n chain: SmartWalletChain\n ): Promise<{ sponsorUserOpParams: UserOperation<GetEntryPointVersion<E>> }> {\n const chainId = blockchainToChainId(chain);\n const result = await this.fetchCrossmintAPI(\n `${API_VERSION}/sdk/paymaster`,\n { method: \"POST\", body: JSON.stringify({ userOp: bigintsToHex(userOp), entryPoint, chainId }) },\n \"Error sponsoring user operation. Please contact support\",\n user.jwt\n );\n return parseBigintAPIResponse(result);\n }\n\n async getSmartWalletConfig(user: UserParams, chain: SmartWalletChain): Promise<SmartWalletConfig> {\n const data: unknown = await this.fetchCrossmintAPI(\n `${API_VERSION}/sdk/smart-wallet/config?chain=${chain}`,\n { method: \"GET\" },\n \"Error getting smart wallet version configuration. Please contact support\",\n user.jwt\n );\n\n const result = SmartWalletConfigSchema.safeParse(data);\n if (!result.success) {\n throw new CrossmintServiceError(\n `Invalid smart wallet config, please contact support. Details below:\\n${result.error.toString()}`\n );\n }\n\n return result.data;\n }\n\n async fetchNFTs(address: string, chain: SmartWalletChain) {\n return this.fetchCrossmintAPI(\n `v1-alpha1/wallets/${chain}:${address}/nfts`,\n { method: \"GET\" },\n `Error fetching NFTs for wallet: ${address}`\n );\n }\n\n public getPasskeyServerUrl(): string {\n return this.crossmintBaseUrl + \"/internal/passkeys\";\n }\n}\n","import { PasskeyValidatorContractVersion } from \"@zerodev/passkey-validator\";\nimport { isAddress, isHex } from \"viem\";\nimport { z } from \"zod\";\n\nimport { SUPPORTED_ENTRYPOINT_VERSIONS, SUPPORTED_KERNEL_VERSIONS } from \"../utils/constants\";\n\nconst HexSchema = z.custom<`0x${string}`>((val): val is `0x${string}` => isHex(val as string), {\n message: \"Invalid hex string\",\n});\n\nconst evmAddressSchema = z.custom<`0x${string}`>((val): val is `0x${string}` => isAddress(val as string), {\n message: \"Invalid evm address\",\n});\n\nexport const EOASignerDataSchema = z.object({\n eoaAddress: evmAddressSchema,\n type: z.literal(\"eoa\"),\n});\n\nexport const PasskeyValidatorSerializedDataSchema = z.object({\n entryPoint: evmAddressSchema,\n validatorAddress: evmAddressSchema,\n pubKeyX: z.string(),\n pubKeyY: z.string(),\n authenticatorIdHash: HexSchema,\n authenticatorId: z.string(),\n});\n\nexport const PasskeySignerDataSchema = PasskeyValidatorSerializedDataSchema.extend({\n passkeyName: z.string(),\n validatorContractVersion: z.nativeEnum(PasskeyValidatorContractVersion),\n domain: z.string(),\n type: z.literal(\"passkeys\"),\n});\n\nexport const SignerDataSchema = z.discriminatedUnion(\"type\", [PasskeySignerDataSchema, EOASignerDataSchema]);\n\nexport const SmartWalletConfigSchema = z.object({\n kernelVersion: z.enum(SUPPORTED_KERNEL_VERSIONS, {\n errorMap: (_, ctx) => ({\n message: `Unsupported kernel version. Supported versions: ${SUPPORTED_KERNEL_VERSIONS.join(\n \", \"\n )}. Version used: ${ctx.data}. Please contact support`,\n }),\n }),\n entryPointVersion: z.enum(SUPPORTED_ENTRYPOINT_VERSIONS, {\n errorMap: (_, ctx) => ({\n message: `Unsupported entry point version. Supported versions: ${SUPPORTED_ENTRYPOINT_VERSIONS.join(\n \", \"\n )}. Version used: ${ctx.data}. Please contact support`,\n }),\n }),\n userId: z.string().min(1),\n signers: z\n .array(\n z.object({\n signerData: SignerDataSchema,\n })\n )\n .min(0)\n .max(1, \"Invalid wallet signer configuration. Please contact support\"),\n smartContractWalletAddress: evmAddressSchema.optional(),\n});\n","import { toHex } from \"viem\";\n\nfunction mapObject(data: any, fn: (value: unknown) => { value: unknown; replace: boolean }): any {\n const result = fn(data);\n if (result.replace) {\n return result.value;\n }\n if (Array.isArray(data)) {\n return data.map((item) => mapObject(item, fn));\n } else if (data !== null && typeof data === \"object\") {\n return Object.fromEntries(Object.entries(data).map(([key, value]) => [key, mapObject(value, fn)]));\n }\n return result.value;\n}\n\nexport function bigintsToHex(data: any): any {\n return mapObject(data, (value) => {\n if (typeof value === \"bigint\") {\n return { value: toHex(value), replace: true };\n }\n return { value, replace: false };\n });\n}\n\nexport function parseBigintAPIResponse(data: any): any {\n return mapObject(data, (value) => {\n if (\n value != null &&\n typeof value == \"object\" &&\n \"__xm_serializedType\" in value &&\n \"value\" in value &&\n value.__xm_serializedType === \"bigint\" &&\n typeof value.value === \"string\"\n ) {\n return { value: BigInt(value.value), replace: true };\n }\n return { value, replace: false };\n });\n}\n","import { keccak256, toHex } from \"viem\";\n\nimport { UserParams } from \"../../../types/params\";\nimport { SmartWalletConfigSchema } from \"../../../types/schema\";\nimport type { SmartWalletConfig } from \"../../../types/service\";\n\nexport class AccountConfigCache {\n constructor(private readonly keyPrefix: string) {}\n\n public set(user: UserParams, config: SmartWalletConfig) {\n localStorage.setItem(this.key(user), JSON.stringify(config));\n }\n\n public get(user: UserParams): SmartWalletConfig | null {\n const key = this.key(user);\n const data = localStorage.getItem(key);\n if (data == null) {\n return null;\n }\n\n const result = SmartWalletConfigSchema.safeParse(JSON.parse(data));\n if (!result.success) {\n localStorage.removeItem(key);\n return null;\n }\n\n return result.data;\n }\n\n public clear() {\n for (let i = 0; i < localStorage.length; i++) {\n const key = localStorage.key(i);\n if (key && key.startsWith(this.keyPrefix)) {\n localStorage.removeItem(key);\n i--; // Decrement i since we've removed an item\n }\n }\n }\n\n private key(user: UserParams) {\n return `${this.keyPrefix}-${keccak256(toHex(user.jwt))}`;\n }\n}\n","import type {\n EOASignerData,\n PasskeyDisplay,\n PasskeySignerData,\n SignerData,\n SignerDisplay,\n} from \"../../../types/service\";\n\nexport interface SignerConfig {\n readonly type: \"passkeys\" | \"eoa\";\n display(): SignerDisplay;\n readonly data: SignerData;\n}\n\nexport class PasskeySignerConfig implements SignerConfig {\n public readonly data: PasskeySignerData;\n public readonly type = \"passkeys\";\n\n constructor(data: PasskeySignerData) {\n this.data = data;\n }\n\n public display(): PasskeyDisplay {\n return {\n pubKeyX: this.data.pubKeyX,\n pubKeyY: this.data.pubKeyY,\n passkeyName: this.data.passkeyName,\n type: this.type,\n };\n }\n}\n\nexport class EOASignerConfig implements SignerConfig {\n public readonly data: EOASignerData;\n public readonly type = \"eoa\";\n\n constructor(data: EOASignerData) {\n this.data = data;\n }\n\n public display() {\n return this.data;\n }\n}\n","import type { CrossmintWalletService } from \"../../../api/CrossmintWalletService\";\nimport type { SmartWalletChain } from \"../../../blockchain/chains\";\nimport { SmartWalletError } from \"../../../error\";\nimport type {\n PreExistingWalletProperties,\n SupportedEntryPointVersion,\n SupportedKernelVersion,\n} from \"../../../types/internal\";\nimport type { UserParams } from \"../../../types/params\";\nimport type { SignerData, SmartWalletConfig } from \"../../../types/service\";\nimport { AccountConfigCache } from \"./cache\";\nimport { EOASignerConfig, PasskeySignerConfig, type SignerConfig } from \"./signer\";\n\ninterface AccountConfig {\n entryPointVersion: SupportedEntryPointVersion;\n kernelVersion: SupportedKernelVersion;\n userWithId: UserParams & { id: string };\n existing?: PreExistingWalletProperties;\n}\nexport class AccountConfigService {\n constructor(\n private readonly crossmintService: CrossmintWalletService,\n private readonly configCache: AccountConfigCache\n ) {}\n\n public async get(\n user: UserParams,\n chain: SmartWalletChain\n ): Promise<{\n config: AccountConfig;\n cached: boolean;\n }> {\n const cached = this.configCache.get(user);\n if (cached != null) {\n return {\n config: this.validateAndFormat(user, cached),\n cached: true,\n };\n }\n\n const config = await this.crossmintService.getSmartWalletConfig(user, chain);\n return { config: this.validateAndFormat(user, config), cached: false };\n }\n\n public cache({\n entryPointVersion,\n kernelVersion,\n user,\n existing,\n }: {\n entryPointVersion: SupportedEntryPointVersion;\n kernelVersion: SupportedKernelVersion;\n user: UserParams & { id: string };\n existing: PreExistingWalletProperties;\n }) {\n this.configCache.clear();\n this.configCache.set(user, {\n entryPointVersion,\n kernelVersion,\n userId: user.id,\n signers: [{ signerData: existing.signerConfig.data }],\n smartContractWalletAddress: existing.address,\n });\n }\n\n private validateAndFormat(\n user: UserParams,\n { entryPointVersion, kernelVersion, signers, smartContractWalletAddress, userId }: SmartWalletConfig\n ): AccountConfig {\n if (\n (entryPointVersion === \"v0.7\" && kernelVersion.startsWith(\"0.2\")) ||\n (entryPointVersion === \"v0.6\" && kernelVersion.startsWith(\"0.3\"))\n ) {\n throw new SmartWalletError(\n `Unsupported combination: entryPoint ${entryPointVersion} and kernel version ${kernelVersion}. Please contact support`\n );\n }\n\n const signerData = signers.map((x) => x.signerData);\n const signer = this.getSigner(signerData);\n\n if (\n (smartContractWalletAddress != null && signer == null) ||\n (signer != null && smartContractWalletAddress == null)\n ) {\n throw new SmartWalletError(\"Either both signer and address must be present, or both must be null\");\n }\n\n if (signer == null || smartContractWalletAddress == null) {\n return { entryPointVersion, kernelVersion, userWithId: { ...user, id: userId } };\n }\n\n return {\n entryPointVersion,\n kernelVersion,\n userWithId: { ...user, id: userId },\n existing: { signerConfig: signer, address: smartContractWalletAddress },\n };\n }\n\n private getSigner(signers: SignerData[]): SignerConfig | undefined {\n if (signers.length === 0) {\n return undefined;\n }\n\n const data = signers[0];\n\n if (data.type === \"eoa\") {\n return new EOASignerConfig(data);\n }\n\n if (data.type === \"passkeys\") {\n return new PasskeySignerConfig(data);\n }\n }\n}\n","import type { KernelSmartAccount } from \"@zerodev/sdk\";\nimport type { SmartAccountClient } from \"permissionless\";\nimport type { SmartAccount } from \"permissionless/accounts\";\nimport type { EntryPoint } from \"permissionless/types/entrypoint\";\nimport type { Address, Chain, HttpTransport, PublicClient } from \"viem\";\n\nimport type { SmartWalletChain } from \"../blockchain/chains\";\nimport type { EOASignerConfig, PasskeySignerConfig, SignerConfig } from \"../blockchain/wallets/account/signer\";\nimport { SUPPORTED_ENTRYPOINT_VERSIONS, SUPPORTED_KERNEL_VERSIONS } from \"../utils/constants\";\nimport type { EOASigner, PasskeySigner, UserParams, WalletParams } from \"./params\";\n\nexport type SupportedKernelVersion = (typeof SUPPORTED_KERNEL_VERSIONS)[number];\nexport function isSupportedKernelVersion(version: string): version is SupportedKernelVersion {\n return SUPPORTED_KERNEL_VERSIONS.includes(version as any);\n}\n\nexport type SupportedEntryPointVersion = (typeof SUPPORTED_ENTRYPOINT_VERSIONS)[number];\nexport function isSupportedEntryPointVersion(version: string): version is SupportedEntryPointVersion {\n return SUPPORTED_ENTRYPOINT_VERSIONS.includes(version as any);\n}\n\nexport interface PreExistingWalletProperties {\n signerConfig: SignerConfig;\n address: Address;\n}\n\nexport interface WalletCreationContext {\n user: UserParams & { id: string };\n chain: SmartWalletChain;\n publicClient: PublicClient<HttpTransport>;\n walletParams: WalletParams;\n entryPoint: EntryPoint;\n kernelVersion: SupportedKernelVersion;\n existing?: PreExistingWalletProperties;\n}\n\nexport interface PasskeyCreationContext extends WalletCreationContext {\n walletParams: WalletParams & { signer: PasskeySigner };\n existing?: { signerConfig: PasskeySignerConfig; address: Address };\n}\n\nexport interface EOACreationContext extends WalletCreationContext {\n walletParams: WalletParams & { signer: EOASigner };\n existing?: { signerConfig: EOASignerConfig; address: Address };\n}\n\nexport function isPasskeyWalletParams(params: WalletParams): params is WalletParams & { signer: PasskeySigner } {\n return \"signer\" in params && \"type\" in params.signer && params.signer.type === \"PASSKEY\";\n}\n\nexport function isPasskeyCreationContext(params: WalletCreationContext): params is PasskeyCreationContext {\n const signerIsPasskeyOrUndefined = params.existing == null || params.existing.signerConfig.type === \"passkeys\";\n\n return isPasskeyWalletParams(params.walletParams) && signerIsPasskeyOrUndefined;\n}\n\nexport function isEOAWalletParams(params: WalletParams): params is WalletParams & { signer: EOASigner } {\n return (\n \"signer\" in params &&\n ((\"type\" in params.signer && params.signer.type === \"VIEM_ACCOUNT\") ||\n (\"request\" in params.signer && typeof params.signer.request === \"function\"))\n );\n}\n\nexport function isEOACreationContext(params: WalletCreationContext): params is EOACreationContext {\n const signerIsEOAOrUndefined = params.existing == null || params.existing.signerConfig.type === \"eoa\";\n\n return isEOAWalletParams(params.walletParams) && signerIsEOAOrUndefined;\n}\n\nexport interface AccountAndSigner {\n account: KernelSmartAccount<EntryPoint, HttpTransport>;\n signerConfig: SignerConfig;\n}\n\nexport type SmartWalletClient = SmartAccountClient<EntryPoint, HttpTransport, Chain, SmartAccount<EntryPoint>>;\n","import { AdminMismatchError, ConfigError } from \"../../../error\";\nimport {\n type AccountAndSigner,\n type WalletCreationContext,\n isEOACreationContext,\n isPasskeyCreationContext,\n isPasskeyWalletParams,\n} from \"../../../types/internal\";\nimport { EOACreationStrategy } from \"./eoa\";\nimport { PasskeyCreationStrategy } from \"./passkey\";\n\nexport class AccountCreator {\n constructor(\n private readonly eoaStrategy: EOACreationStrategy,\n private readonly passkeyStrategy: PasskeyCreationStrategy\n ) {}\n\n public get(context: WalletCreationContext): Promise<AccountAndSigner> {\n if (isPasskeyCreationContext(context)) {\n return this.passkeyStrategy.create(context);\n }\n\n if (isEOACreationContext(context)) {\n return this.eoaStrategy.create(context);\n }\n\n if (context.existing == null) {\n throw new ConfigError(`Unsupported wallet params:\\n${context.walletParams}`);\n }\n\n const display = context.existing.signerConfig.display();\n const inputSignerType = isPasskeyWalletParams(context.walletParams) ? \"passkey\" : \"eoa\";\n throw new AdminMismatchError(\n `Cannot create wallet with ${inputSignerType} signer for user ${\n context.user.id\n }', they already have a wallet with signer:\\n'${JSON.stringify(display, null, 2)}'`,\n display\n );\n }\n}\n","import { signerToEcdsaValidator } from \"@zerodev/ecdsa-validator\";\nimport { createKernelAccount } from \"@zerodev/sdk\";\n\nimport { AdminMismatchError } from \"../../../error\";\nimport type { AccountAndSigner, EOACreationContext } from \"../../../types/internal\";\nimport { equalsIgnoreCase } from \"../../../utils/helpers\";\nimport { createOwnerSigner } from \"../../../utils/signer\";\nimport { EOASignerConfig } from \"./signer\";\nimport { AccountCreationStrategy } from \"./strategy\";\n\nexport class EOACreationStrategy implements AccountCreationStrategy {\n public async create({\n chain,\n publicClient,\n entryPoint,\n walletParams,\n kernelVersion,\n user,\n existing,\n }: EOACreationContext): Promise<AccountAndSigner> {\n const eoa = await createOwnerSigner({\n chain,\n walletParams,\n });\n\n if (existing != null && !equalsIgnoreCase(eoa.address, existing.signerConfig.data.eoaAddress)) {\n throw new AdminMismatchError(\n `User '${user.id}' has an existing wallet with an eoa signer '${existing.signerConfig.data.eoaAddress}', this does not match input eoa signer '${eoa.address}'.`,\n existing.signerConfig.display(),\n { type: \"eoa\", eoaAddress: existing.signerConfig.data.eoaAddress }\n );\n }\n\n const ecdsaValidator = await signerToEcdsaValidator(publicClient, {\n signer: eoa,\n entryPoint,\n kernelVersion,\n });\n const account = await createKernelAccount(publicClient, {\n plugins: {\n sudo: ecdsaValidator,\n },\n index: 0n,\n entryPoint,\n kernelVersion,\n deployedAccountAddress: existing?.address,\n });\n\n return { account, signerConfig: new EOASignerConfig({ eoaAddress: eoa.address, type: \"eoa\" }) };\n }\n}\n","export function isEmpty(str: string | undefined | null): str is undefined | null {\n return !str || str.length === 0 || str.trim().length === 0;\n}\n\nexport function equalsIgnoreCase(a?: string, b?: string): boolean {\n return a?.toLowerCase() === b?.toLowerCase();\n}\n","import { providerToSmartAccountSigner } from \"permissionless\";\nimport type { SmartAccountSigner } from \"permissionless/accounts\";\nimport { Address, EIP1193Provider } from \"viem\";\n\nimport { SmartWalletChain } from \"../blockchain/chains\";\nimport { SmartWalletError } from \"../error\";\nimport { ViemAccount, WalletParams } from \"../types/params\";\n\ntype CreateOwnerSignerInput = {\n chain: SmartWalletChain;\n walletParams: WalletParams;\n};\n\nexport async function createOwnerSigner({\n walletParams,\n}: CreateOwnerSignerInput): Promise<SmartAccountSigner<\"custom\", Address>> {\n if (isEIP1193Provider(walletParams.signer)) {\n return await providerToSmartAccountSigner(walletParams.signer);\n } else if (isAccount(walletParams.signer)) {\n return walletParams.signer.account;\n } else {\n const signer = walletParams.signer as any;\n throw new SmartWalletError(`The signer type ${signer.type} is not supported`);\n }\n}\n\nfunction isEIP1193Provider(signer: any): signer is EIP1193Provider {\n return signer && typeof signer.request === \"function\";\n}\n\nexport function isAccount(signer: any): signer is ViemAccount {\n return signer && signer.type === \"VIEM_ACCOUNT\";\n}\n","import { PasskeyValidatorContractVersion, WebAuthnMode, toPasskeyValidator } from \"@zerodev/passkey-validator\";\nimport { type KernelSmartAccount, type KernelValidator, createKernelAccount } from \"@zerodev/sdk\";\nimport { type WebAuthnKey, toWebAuthnKey } from \"@zerodev/webauthn-key\";\nimport type { SmartAccount } from \"permissionless/accounts\";\nimport type { EntryPoint } from \"permissionless/types/entrypoint\";\n\nimport {\n PasskeyIncompatibleAuthenticatorError,\n PasskeyMismatchError,\n PasskeyPromptError,\n PasskeyRegistrationError,\n} from \"../../../error\";\nimport type { AccountAndSigner, PasskeyCreationContext } from \"../../../types/internal\";\nimport type { UserParams } from \"../../../types/params\";\nimport type { PasskeySignerData, PasskeyValidatorSerializedData } from \"../../../types/service\";\nimport { PasskeySignerConfig } from \"./signer\";\nimport { AccountCreationStrategy } from \"./strategy\";\n\ntype PasskeyValidator = KernelValidator<EntryPoint, \"WebAuthnValidator\"> & {\n getSerializedData: () => string;\n};\nexport class PasskeyCreationStrategy implements AccountCreationStrategy {\n constructor(private readonly passkeyServerUrl: string, private readonly apiKey: string) {}\n\n public async create({\n user,\n publicClient,\n walletParams,\n entryPoint,\n kernelVersion,\n existing,\n }: PasskeyCreationContext): Promise<AccountAndSigner> {\n const inputPasskeyName = walletParams.signer.passkeyName ?? user.id;\n if (existing != null && existing.signerConfig.data.passkeyName !== inputPasskeyName) {\n throw new PasskeyMismatchError(\n `User '${user.id}' has an existing wallet created with a passkey named '${existing.signerConfig.data.passkeyName}', this does match input passkey name '${inputPasskeyName}'.`,\n existing.signerConfig.display()\n );\n }\n\n try {\n const passkey = await this.getPasskey(user, inputPasskeyName, existing?.signerConfig.data);\n\n const latestValidatorVersion = PasskeyValidatorContractVersion.V0_0_2;\n const validatorContractVersion =\n existing == null ? latestValidatorVersion : existing.signerConfig.data.validatorContractVersion;\n\n const validator = await toPasskeyValidator(publicClient, {\n webAuthnKey: passkey,\n entryPoint,\n validatorContractVersion,\n kernelVersion,\n });\n\n const kernelAccount = await createKernelAccount(publicClient, {\n plugins: { sudo: validator },\n entryPoint,\n kernelVersion,\n deployedAccountAddress: existing?.address,\n });\n\n return {\n signerConfig: this.getSignerConfig(validator, validatorContractVersion, inputPasskeyName),\n account: this.decorate(kernelAccount, inputPasskeyName),\n };\n } catch (error) {\n throw this.mapError(error, inputPasskeyName);\n }\n }\n\n private async getPasskey(\n user: UserParams,\n passkeyName: string,\n existing?: PasskeySignerData\n ): Promise<WebAuthnKey> {\n if (existing != null) {\n return {\n pubX: BigInt(existing.pubKeyX),\n pubY: BigInt(existing.pubKeyY),\n authenticatorId: existing.authenticatorId,\n authenticatorIdHash: existing.authenticatorIdHash,\n };\n }\n\n return toWebAuthnKey({\n passkeyName,\n passkeyServerUrl: this.passkeyServerUrl,\n mode: WebAuthnMode.Register,\n passkeyServerHeaders: this.createPasskeysServerHeaders(user),\n });\n }\n\n private getSignerConfig(\n validator: PasskeyValidator,\n validatorContractVersion: PasskeyValidatorContractVersion,\n passkeyName: string\n ): PasskeySignerConfig {\n return new PasskeySignerConfig({\n ...deserializePasskeyValidatorData(validator.getSerializedData()),\n passkeyName,\n validatorContractVersion,\n domain: window.location.hostname,\n type: \"passkeys\",\n });\n }\n\n private createPasskeysServerHeaders(user: UserParams) {\n return {\n \"x-api-key\": this.apiKey,\n Authorization: `Bearer ${user.jwt}`,\n };\n }\n\n private mapError(error: any, passkeyName: string) {\n if (error.code === 0 && error.name === \"DataError\") {\n return new PasskeyIncompatibleAuthenticatorError(passkeyName);\n }\n\n if (error.message === \"Registration not verified\") {\n return new PasskeyRegistrationError(passkeyName);\n }\n\n if (error.code === \"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY\" && error.name === \"NotAllowedError\") {\n return new PasskeyPromptError(passkeyName);\n }\n\n return error;\n }\n\n private decorate<Account extends KernelSmartAccount<EntryPoint>>(account: Account, passkeyName: string): Account {\n return new Proxy(account, {\n get: (target, prop, receiver) => {\n const original = Reflect.get(target, prop, receiver);\n if (typeof original !== \"function\" || typeof prop !== \"string\" || !isAccountSigningMethod(prop)) {\n return original;\n }\n\n return async (...args: any[]) => {\n try {\n return await original.call(target, ...args);\n } catch (error) {\n throw this.mapError(error, passkeyName);\n }\n };\n },\n });\n }\n}\n\nconst accountSigningMethods = [\n \"signMessage\",\n \"signTypedData\",\n \"signUserOperation\",\n \"signTransaction\",\n] as const satisfies readonly (keyof SmartAccount<EntryPoint>)[];\n\nfunction isAccountSigningMethod(method: string): method is (typeof accountSigningMethods)[number] {\n return accountSigningMethods.includes(method as any);\n}\n\nconst deserializePasskeyValidatorData = (params: string) => {\n const uint8Array = base64ToBytes(params);\n const jsonString = new TextDecoder().decode(uint8Array);\n\n return JSON.parse(jsonString) as PasskeyValidatorSerializedData;\n};\n\nfunction base64ToBytes(base64: string) {\n const binString = atob(base64);\n return Uint8Array.from(binString, (m) => m.codePointAt(0) as number);\n}\n","import type { SmartAccountClient } from \"permissionless\";\nimport type { EntryPoint } from \"permissionless/types/entrypoint\";\nimport { stringify } from \"viem\";\n\nimport { SmartWalletError } from \"../../error\";\nimport { ErrorProcessor } from \"../../error/processor\";\nimport { scwLogger } from \"../../services\";\nimport { usesGelatoBundler } from \"../../utils/blockchain\";\nimport { SmartWalletChain } from \"../chains\";\n\nconst transactionMethods = [\n \"sendTransaction\",\n \"writeContract\",\n \"sendUserOperation\",\n] as const satisfies readonly (keyof SmartAccountClient<EntryPoint>)[];\n\nconst signingMethods = [\n \"signMessage\",\n \"signTypedData\",\n] as const satisfies readonly (keyof SmartAccountClient<EntryPoint>)[];\n\ntype TxnMethod = (typeof transactionMethods)[number];\ntype SignMethod = (typeof signingMethods)[number];\n\nfunction isTxnMethod(method: string): method is TxnMethod {\n return transactionMethods.includes(method as any);\n}\n\nfunction isSignMethod(method: string): method is SignMethod {\n return signingMethods.includes(method as any);\n}\n\n/**\n * A decorator class for SmartAccountClient instances. It enhances the client with:\n * - Error handling & logging.\n * - Performance metrics.\n * - Automatic formatting of transactions for Gelato bundler compatibility.\n * */\nexport class ClientDecorator {\n constructor(private readonly errorProcessor: ErrorProcessor, protected logger = scwLogger) {}\n\n public decorate<Client extends SmartAccountClient<EntryPoint>>({\n crossmintChain,\n smartAccountClient,\n }: {\n crossmintChain: SmartWalletChain;\n smartAccountClient: Client;\n }): Client {\n return new Proxy(smartAccountClient, {\n get: (target, prop, receiver) => {\n const originalMethod = Reflect.get(target, prop, receiver);\n\n if (\n typeof originalMethod !== \"function\" ||\n typeof prop !== \"string\" ||\n !(isSignMethod(prop) || isTxnMethod(prop))\n ) {\n return originalMethod;\n }\n\n return (...args: any[]) =>\n this.logger.logPerformance(`CrossmintSmartWallet.${prop}`, () =>\n this.execute(target, prop, originalMethod, args, crossmintChain)\n );\n },\n }) as Client;\n }\n\n private async execute<M extends TxnMethod | SignMethod>(\n target: SmartAccountClient<EntryPoint>,\n prop: M,\n // eslint-disable-next-line @typescript-eslint/ban-types\n originalMethod: Function,\n args: any[],\n crossmintChain: SmartWalletChain\n ) {\n try {\n this.logger.log(`[CrossmintSmartWallet.${prop}] - params: ${stringify(args)}`);\n const processed = isTxnMethod(prop) ? this.processTxnArgs(prop, crossmintChain, args) : args;\n return await originalMethod.call(target, ...processed);\n } catch (error: any) {\n const description = isTxnMethod(prop) ? \"signing\" : \"sending transaction\";\n throw this.errorProcessor.map(\n error,\n new SmartWalletError(`Error ${description}: ${error.message}`, stringify(error))\n );\n }\n }\n\n private processTxnArgs(prop: TxnMethod, crossmintChain: SmartWalletChain, args: any[]): any[] {\n if (prop === \"sendUserOperation\") {\n const [{ userOperation, middleware, account }] = args as Parameters<\n SmartAccountClient<EntryPoint>[\"sendUserOperation\"]\n >;\n return [\n {\n middleware,\n account,\n userOperation: this.addGelatoBundlerProperties(crossmintChain, userOperation),\n },\n ...args.slice(1),\n ];\n }\n\n const [txn] = args as\n | Parameters<SmartAccountClient<EntryPoint>[\"sendTransaction\"]>\n | Parameters<SmartAccountClient<EntryPoint>[\"writeContract\"]>;\n\n return [this.addGelatoBundlerProperties(crossmintChain, txn), ...args.slice(1)];\n }\n\n /*\n * Chain that ZD uses Gelato as for bundler require special parameters:\n * https://docs.zerodev.app/sdk/faqs/use-with-gelato#transaction-configuration\n */\n private addGelatoBundlerProperties(\n crossmintChain: SmartWalletChain,\n txnParams: { maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint }\n ) {\n if (usesGelatoBundler(crossmintChain)) {\n return { ...txnParams, maxFeePerGas: \"0x0\" as any, maxPriorityFeePerGas: \"0x0\" as any };\n }\n\n return txnParams;\n }\n}\n","import { SmartWalletChain } from \"../blockchain/chains\";\n\nexport function usesGelatoBundler(chain: SmartWalletChain) {\n return false;\n}\n","import { createKernelAccountClient } from \"@zerodev/sdk\";\nimport { ENTRYPOINT_ADDRESS_V06, ENTRYPOINT_ADDRESS_V07 } from \"permissionless\";\nimport { createPublicClient, http } from \"viem\";\n\nimport { blockchainToChainId } from \"@crossmint/common-sdk-base\";\n\nimport type { CrossmintWalletService } from \"../../api/CrossmintWalletService\";\nimport { UserWalletAlreadyCreatedError } from \"../../error\";\nimport type { SmartWalletClient } from \"../../types/internal\";\nimport type { UserParams, WalletParams } from \"../../types/params\";\nimport { CURRENT_VERSION, ZERO_DEV_TYPE } from \"../../utils/constants\";\nimport { equalsIgnoreCase } from \"../../utils/helpers\";\nimport { type SmartWalletChain, getBundlerRPC, viemNetworks } from \"../chains\";\nimport { EVMSmartWallet } from \"./EVMSmartWallet\";\nimport type { AccountConfigService } from \"./account/config\";\nimport type { AccountCreator } from \"./account/creator\";\nimport type { ClientDecorator } from \"./clientDecorator\";\nimport { paymasterMiddleware, usePaymaster } from \"./paymaster\";\n\nexport class SmartWalletService {\n constructor(\n private readonly crossmintService: CrossmintWalletService,\n private readonly accountConfigService: AccountConfigService,\n private readonly accountCreator: AccountCreator,\n private readonly clientDecorator: ClientDecorator\n ) {}\n\n public async getOrCreate(\n user: UserParams,\n chain: SmartWalletChain,\n walletParams: WalletParams\n ): Promise<EVMSmartWallet> {\n const {\n config: { entryPointVersion, kernelVersion, existing, userWithId },\n cached,\n } = await this.accountConfigService.get(user, chain);\n\n const publicClient = createPublicClient({ transport: http(getBundlerRPC(chain)) });\n\n const { account, signerConfig } = await this.accountCreator.get({\n chain,\n walletParams,\n publicClient,\n user: userWithId,\n entryPoint: entryPointVersion === \"v0.6\" ? ENTRYPOINT_ADDRESS_V06 : ENTRYPOINT_ADDRESS_V07,\n kernelVersion,\n existing,\n });\n\n if (existing == null) {\n await this.crossmintService.idempotentCreateSmartWallet(user, {\n type: ZERO_DEV_TYPE,\n smartContractWalletAddress: account.address,\n signerData: signerConfig.data,\n version: CURRENT_VERSION,\n baseLayer: \"evm\",\n chainId: blockchainToChainId(chain),\n entryPointVersion,\n kernelVersion,\n });\n }\n\n if (!cached) {\n this.accountConfigService.cache({\n entryPointVersion,\n kernelVersion,\n user: userWithId,\n existing: { address: account.address, signerConfig },\n });\n }\n\n const kernelAccountClient: SmartWalletClient = createKernelAccountClient({\n account,\n chain: viemNetworks[chain],\n entryPoint: account.entryPoint,\n bundlerTransport: http(getBundlerRPC(chain)),\n ...(usePaymaster(chain) &&\n paymasterMiddleware({\n entryPoint: account.entryPoint,\n chain,\n walletService: this.crossmintService,\n user,\n })),\n });\n\n const smartAccountClient = this.clientDecorator.decorate({\n crossmintChain: chain,\n smartAccountClient: kernelAccountClient,\n });\n\n return new EVMSmartWallet(this.crossmintService, smartAccountClient, publicClient, chain);\n }\n}\n","import {\n Chain,\n arbitrum,\n arbitrumSepolia,\n base,\n baseSepolia,\n optimism,\n optimismSepolia,\n polygon,\n polygonAmoy,\n} from \"viem/chains\";\n\nimport { BlockchainIncludingTestnet as Blockchain, ObjectValues, objectValues } from \"@crossmint/common-sdk-base\";\n\nimport { BUNDLER_RPC } from \"../utils/constants\";\n\nexport const SmartWalletTestnet = {\n BASE_SEPOLIA: Blockchain.BASE_SEPOLIA,\n POLYGON_AMOY: Blockchain.POLYGON_AMOY,\n OPTIMISM_SEPOLIA: Blockchain.OPTIMISM_SEPOLIA,\n ARBITRUM_SEPOLIA: Blockchain.ARBITRUM_SEPOLIA,\n} as const;\nexport type SmartWalletTestnet = ObjectValues<typeof SmartWalletTestnet>;\nexport const SMART_WALLET_TESTNETS = objectValues(SmartWalletTestnet);\n\nexport const SmartWalletMainnet = {\n BASE: Blockchain.BASE,\n POLYGON: Blockchain.POLYGON,\n OPTIMISM: Blockchain.OPTIMISM,\n ARBITRUM: Blockchain.ARBITRUM,\n} as const;\nexport type SmartWalletMainnet = ObjectValues<typeof SmartWalletMainnet>;\nexport const SMART_WALLET_MAINNETS = objectValues(SmartWalletMainnet);\n\nexport const SmartWalletChain = {\n ...SmartWalletTestnet,\n ...SmartWalletMainnet,\n} as const;\nexport type SmartWalletChain = ObjectValues<typeof SmartWalletChain>;\nexport const SMART_WALLET_CHAINS = objectValues(SmartWalletChain);\n\nexport const zerodevProjects: Record<SmartWalletChain, string> = {\n polygon: \"5c9f4865-ca8e-44bb-9b9e-3810b2b46f9f\",\n \"polygon-amoy\": \"3deef404-ca06-4a5d-9a58-907c99e7ef00\",\n \"base-sepolia\": \"5a127978-6473-4784-9dfb-f74395b220a6\",\n base: \"e8b3020f-4dde-4176-8a7d-be8102527a5c\",\n \"optimism-sepolia\": \"f8dd488e-eaed-467d-a5de-0184c160f3b1\",\n optimism: \"505950ab-ee07-4a9c-bd16-320ac71a9350\",\n arbitrum: \"a965100f-fedf-4e6b-a207-20f5687fcc4f\",\n \"arbitrum-sepolia\": \"76c860ca-af77-4fb1-8eac-07825952f6f4\",\n};\n\nexport const viemNetworks: Record<SmartWalletChain, Chain> = {\n polygon: polygon,\n \"polygon-amoy\": polygonAmoy,\n base: base,\n \"base-sepolia\": baseSepolia,\n optimism: optimism,\n \"optimism-sepolia\": optimismSepolia,\n arbitrum: arbitrum,\n \"arbitrum-sepolia\": arbitrumSepolia,\n};\n\nexport const getBundlerRPC = (chain: SmartWalletChain) => {\n return BUNDLER_RPC + zerodevProjects[chain];\n};\n","import { CrossmintWalletService } from \"@/api/CrossmintWalletService\";\nimport { Middleware } from \"permissionless/actions/smartAccount\";\nimport { EntryPoint } from \"permissionless/types/entrypoint\";\n\nimport { UserParams } from \"../../types/params\";\nimport { usesGelatoBundler } from \"../../utils/blockchain\";\nimport { SmartWalletChain } from \"../chains\";\n\nexport function usePaymaster(chain: SmartWalletChain) {\n return !usesGelatoBundler(chain);\n}\n\nexport function paymasterMiddleware({\n entryPoint,\n chain,\n walletService,\n user,\n}: {\n entryPoint: EntryPoint;\n chain: SmartWalletChain;\n walletService: CrossmintWalletService;\n user: UserParams;\n}): Middleware<EntryPoint> {\n return {\n middleware: {\n sponsorUserOperation: async ({ userOperation }) => {\n const { sponsorUserOpParams } = await walletService.sponsorUserOperation(\n user,\n userOperation,\n entryPoint,\n chain\n );\n return sponsorUserOpParams;\n },\n },\n };\n}\n","import { BaseError, stringify } from \"viem\";\n\nimport { SDKLogger } from \"@crossmint/client-sdk-base\";\n\nimport { SmartWalletError } from \".\";\nimport { SDK_VERSION } from \"../utils/constants\";\n\nexport class ErrorProcessor {\n constructor(private readonly logger: SDKLogger) {}\n\n public map(error: unknown, fallback: SmartWalletError): SmartWalletError | BaseError {\n this.record(error);\n\n if (error instanceof SmartWalletError) {\n return error;\n }\n\n // Allow viem errors, which are generally pretty friendly.\n if (error instanceof BaseError) {\n return error;\n }\n\n return fallback;\n }\n\n private record(error: unknown) {\n const message = error instanceof Error ? error.message : String(error);\n this.logger.error(`Smart Wallet SDK Error: ${message}`, {\n stack: error instanceof Error ? error.stack : undefined,\n name: error instanceof Error ? error.name : \"UnknownError\",\n details: stringify(error),\n domain: window.location.hostname,\n sdk_version: SDK_VERSION,\n });\n }\n}\n","export function isClient() {\n return typeof window !== \"undefined\";\n}\n"],"mappings":"ubAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,2BAAAE,EAAA,uBAAAC,EAAA,2DAAAC,EAAA,+GAAAC,EAAA,0PAAAC,EAAA,yBAAAC,EAAA,uBAAAC,EAAA,6BAAAC,EAAA,qBAAAC,EAAA,mEAAAC,GAAA,gCAAAC,EAAA,oEAAAC,EAAA,gEAAAC,GAAAd,IAAA,IAAAe,GAA4E,sCCA5E,IAAAC,EAAgF,gBAEhFC,GAA8B,sCCF9B,IAAAC,EAA4C,sCCArC,IAAMC,GAAgB,UAEtB,IAAMC,EAAc,UACdC,EAAc,QACdC,EAAc,aACdC,GAAc,0CAEpB,IAAMC,GAA4B,CAAC,QAAS,QAAS,OAAO,EACtDC,GAAgC,CAAC,OAAQ,MAAM,EDJrD,IAAMC,EAAY,IAAI,YAAUC,CAAW,EACrCC,GAAmB,IAAI,YAAUD,KAAa,oBAAiBA,EAAa,CAAE,YAAa,EAAK,CAAC,CAAC,EEL/G,IAAAE,EAA2D,gBCA3D,IAAAC,GAAA,CACI,CACI,OAAU,CACN,CACI,aAAgB,SAChB,KAAQ,OACR,KAAQ,QACZ,CACJ,EACA,gBAAmB,aACnB,KAAQ,aACZ,EACA,CACI,UAAa,GACb,OAAU,CACN,CACI,QAAW,GACX,aAAgB,UAChB,KAAQ,UACR,KAAQ,SACZ,EACA,CACI,QAAW,GACX,aAAgB,UAChB,KAAQ,WACR,KAAQ,SAC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CnBmBO,IAAMC,GAAN,MAAMC,CAAe,CAChB,YACaC,EACAC,EACAC,EAASC,EAC5B,CAHmB,wBAAAH,EACA,oBAAAC,EACA,YAAAC,CAClB,CAMH,OAAO,KAAK,CAAE,aAAAE,CAAa,EAA6C,CACpE,GAAI,CAACC,GAAS,EACV,MAAM,IAAIC,EAAiB,mDAAmD,EAIlF,GAAI,IADqB,mBAAeF,CAAY,EAC9B,QAClB,MAAM,IAAI,MAAM,iBAAiB,EAGrC,IAAMG,EAAmB,IAAIC,EAAuBJ,CAAY,EAC1DH,EAAiB,IAAIQ,GAAeC,EAAgB,EACpDC,EAAiB,IAAIC,EACvB,IAAIC,EACJ,IAAIC,EAAwBP,EAAiB,oBAAoB,EAAGH,CAAY,CACpF,EACMW,EAAe,IAAIC,EAAmB,gBAAgBC,CAAW,EAAE,EAEnEjB,EAAqB,IAAIkB,EAC3BX,EACA,IAAIY,EAAqBZ,EAAkBQ,CAAY,EACvDJ,EACA,IAAIS,EAAgBnB,CAAc,CACtC,EAEA,OAAO,IAAIF,EAAeC,EAAoBC,CAAc,CAChE,CAWA,MAAM,kBACFoB,EACAC,EACAC,EAA6B,CAAE,OAAQ,CAAE,KAAM,SAAU,CAAE,EACpC,CACvB,OAAO,KAAK,OAAO,eAAe,uBAAwB,SAAY,CAClE,GAAI,CACA,OAAO,MAAM,KAAK,mBAAmB,YAAYF,EAAMC,EAAOC,CAAY,CAC9E,OAASC,EAAY,CACjB,MAAM,KAAK,eAAe,IACtBA,EACA,IAAIlB,EAAiB,2BAA2BkB,EAAM,OAAO,OAAK,cAAUA,CAAK,CAAC,CACtF,CACJ,CACJ,CAAC,CACL,CACJ","names":["src_exports","__export","AdminAlreadyUsedError","AdminMismatchError","ConfigError","EVMSmartWallet","PasskeyIncompatibleAuthenticatorError","PasskeyMismatchError","PasskeyPromptError","PasskeyRegistrationError","SmartWalletError","SmartWalletSDK","SmartWalletsNotEnabledError","UserWalletAlreadyCreatedError","__toCommonJS","import_common_sdk_base","import_viem","import_client_sdk_base","import_client_sdk_base","ZERO_DEV_TYPE","SCW_SERVICE","SDK_VERSION","API_VERSION","BUNDLER_RPC","SUPPORTED_KERNEL_VERSIONS","SUPPORTED_ENTRYPOINT_VERSIONS","scwLogger","SCW_SERVICE","scwDatadogLogger","import_viem","ERC1155_default","transferParams","contract","config","from","to","ERC1155_default","EVMSmartWallet","crossmintService","accountClient","publicClient","chain","logger","scwLogger","toAddress","config","tx","transferParams","client","request","hash","error","tokenIdString","import_client_sdk_base","SmartWalletError","message","details","code","AdminMismatchError","required","used","PasskeyMismatchError","UserWalletAlreadyCreatedError","userId","PasskeyPromptError","passkeyName","PasskeyRegistrationError","PasskeyIncompatibleAuthenticatorError","ConfigError","AdminAlreadyUsedError","SmartWalletsNotEnabledError","import_client_sdk_base","import_viem","import_common_sdk_base","import_client_sdk_base","import_common_sdk_base","import_passkey_validator","import_viem","import_zod","HexSchema","val","evmAddressSchema","EOASignerDataSchema","PasskeyValidatorSerializedDataSchema","PasskeySignerDataSchema","SignerDataSchema","SmartWalletConfigSchema","SUPPORTED_KERNEL_VERSIONS","_","ctx","SUPPORTED_ENTRYPOINT_VERSIONS","import_viem","mapObject","data","fn","result","item","key","value","bigintsToHex","parseBigintAPIResponse","CrossmintWalletService","scwLogger","userId","UserWalletAlreadyCreatedError","AdminAlreadyUsedError","SmartWalletsNotEnabledError","user","input","API_VERSION","userOp","entryPoint","chain","chainId","result","bigintsToHex","parseBigintAPIResponse","data","SmartWalletConfigSchema","address","import_viem","AccountConfigCache","keyPrefix","user","config","key","data","result","SmartWalletConfigSchema","i","PasskeySignerConfig","data","EOASignerConfig","AccountConfigService","crossmintService","configCache","user","chain","cached","config","entryPointVersion","kernelVersion","existing","signers","smartContractWalletAddress","userId","SmartWalletError","signerData","x","signer","data","EOASignerConfig","PasskeySignerConfig","isPasskeyWalletParams","params","isPasskeyCreationContext","signerIsPasskeyOrUndefined","isEOAWalletParams","isEOACreationContext","signerIsEOAOrUndefined","AccountCreator","eoaStrategy","passkeyStrategy","context","isPasskeyCreationContext","isEOACreationContext","ConfigError","display","inputSignerType","isPasskeyWalletParams","AdminMismatchError","import_ecdsa_validator","import_sdk","equalsIgnoreCase","a","b","import_permissionless","createOwnerSigner","walletParams","isEIP1193Provider","isAccount","signer","SmartWalletError","EOACreationStrategy","chain","publicClient","entryPoint","walletParams","kernelVersion","user","existing","eoa","createOwnerSigner","equalsIgnoreCase","AdminMismatchError","ecdsaValidator","EOASignerConfig","import_passkey_validator","import_sdk","import_webauthn_key","PasskeyCreationStrategy","passkeyServerUrl","apiKey","user","publicClient","walletParams","entryPoint","kernelVersion","existing","inputPasskeyName","PasskeyMismatchError","passkey","latestValidatorVersion","validatorContractVersion","validator","kernelAccount","error","passkeyName","PasskeySignerConfig","deserializePasskeyValidatorData","PasskeyIncompatibleAuthenticatorError","PasskeyRegistrationError","PasskeyPromptError","account","target","prop","receiver","original","isAccountSigningMethod","args","accountSigningMethods","method","params","uint8Array","base64ToBytes","jsonString","base64","binString","m","import_viem","usesGelatoBundler","chain","transactionMethods","signingMethods","isTxnMethod","method","isSignMethod","ClientDecorator","errorProcessor","logger","scwLogger","crossmintChain","smartAccountClient","target","prop","receiver","originalMethod","args","processed","error","description","SmartWalletError","userOperation","middleware","account","txn","txnParams","usesGelatoBundler","import_sdk","import_permissionless","import_viem","import_common_sdk_base","import_chains","import_common_sdk_base","SmartWalletTestnet","Blockchain","SMART_WALLET_TESTNETS","SmartWalletMainnet","SMART_WALLET_MAINNETS","SmartWalletChain","SMART_WALLET_CHAINS","zerodevProjects","viemNetworks","getBundlerRPC","chain","BUNDLER_RPC","usePaymaster","chain","usesGelatoBundler","paymasterMiddleware","entryPoint","walletService","user","userOperation","sponsorUserOpParams","SmartWalletService","crossmintService","accountConfigService","accountCreator","clientDecorator","user","chain","walletParams","entryPointVersion","kernelVersion","existing","userWithId","cached","publicClient","getBundlerRPC","account","signerConfig","ZERO_DEV_TYPE","kernelAccountClient","viemNetworks","usePaymaster","paymasterMiddleware","smartAccountClient","EVMSmartWallet","import_viem","ErrorProcessor","logger","error","fallback","SmartWalletError","message","SDK_VERSION","isClient","SmartWalletSDK","_SmartWalletSDK","smartWalletService","errorProcessor","logger","scwLogger","clientApiKey","isClient","SmartWalletError","crossmintService","CrossmintWalletService","ErrorProcessor","scwDatadogLogger","accountCreator","AccountCreator","EOACreationStrategy","PasskeyCreationStrategy","accountCache","AccountConfigCache","SDK_VERSION","SmartWalletService","AccountConfigService","ClientDecorator","user","chain","walletParams","error"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/blockchain/wallets/EVMSmartWallet.ts","../src/services/logger.ts","../src/utils/constants.ts","../src/blockchain/transfer.ts","../src/ABI/ERC1155.json","../src/error/index.ts","../src/SmartWalletSDK.ts","../src/api/CrossmintWalletService.ts","../src/types/schema.ts","../src/utils/api.ts","../src/blockchain/wallets/account/cache.ts","../src/blockchain/wallets/account/signer.ts","../src/blockchain/wallets/account/config.ts","../src/types/internal.ts","../src/blockchain/wallets/account/creator.ts","../src/blockchain/wallets/account/eoa.ts","../src/utils/helpers.ts","../src/utils/signer.ts","../src/blockchain/wallets/account/passkey.ts","../src/blockchain/wallets/clientDecorator.ts","../src/utils/blockchain.ts","../src/blockchain/wallets/service.ts","../src/blockchain/chains.ts","../src/blockchain/rpc.ts","../src/blockchain/wallets/paymaster.ts","../src/error/processor.ts","../src/utils/environment.ts"],"sourcesContent":["export { blockchainToChainId, EVMBlockchainIncludingTestnet as Chain } from \"@crossmint/common-sdk-base\";\n\nexport { EVMSmartWallet } from \"./blockchain/wallets/EVMSmartWallet\";\n\nexport type {\n SmartWalletSDKInitParams,\n UserParams,\n ViemAccount,\n PasskeySigner,\n EOASigner,\n WalletParams,\n} from \"./types/params\";\n\nexport type { TransferType, ERC20TransferType, NFTTransferType, SFTTransferType } from \"./types/token\";\n\nexport {\n SmartWalletError,\n UserWalletAlreadyCreatedError,\n AdminAlreadyUsedError,\n AdminMismatchError,\n PasskeyMismatchError,\n PasskeyPromptError,\n PasskeyRegistrationError,\n PasskeyIncompatibleAuthenticatorError,\n ConfigError,\n SmartWalletsNotEnabledError,\n} from \"./error\";\n\nexport {\n SmartWalletErrorCode,\n CrossmintSDKError,\n CrossmintServiceError,\n TransferError,\n JWTDecryptionError,\n JWTExpiredError,\n JWTIdentifierError,\n JWTInvalidError,\n NotAuthorizedError,\n} from \"@crossmint/client-sdk-base\";\n\nexport { SmartWalletSDK } from \"./SmartWalletSDK\";\n","import { type HttpTransport, type PublicClient, isAddress, publicActions } from \"viem\";\n\nimport { TransferError } from \"@crossmint/client-sdk-base\";\n\nimport type { CrossmintWalletService } from \"../../api/CrossmintWalletService\";\nimport { scwLogger } from \"../../services/logger\";\nimport { SmartWalletClient } from \"../../types/internal\";\nimport type { TransferType } from \"../../types/token\";\nimport { SmartWalletChain } from \"../chains\";\nimport { transferParams } from \"../transfer\";\n\n/**\n * Smart wallet interface for EVM chains enhanced with Crossmint capabilities.\n * Core functionality is exposed via [viem](https://viem.sh/) clients within the `client` property of the class.\n */\nexport class EVMSmartWallet {\n public readonly chain: SmartWalletChain;\n\n /**\n * [viem](https://viem.sh/) clients that provide an interface for core wallet functionality.\n */\n public readonly client: {\n /**\n * An interface to interact with the smart wallet, execute transactions, sign messages, etc.\n */\n wallet: SmartWalletClient;\n\n /**\n * An interface to read onchain data, fetch transactions, retrieve account balances, etc. Corresponds to public [JSON-RPC API](https://ethereum.org/en/developers/docs/apis/json-rpc/) methods.\n */\n public: PublicClient;\n };\n\n constructor(\n private readonly crossmintService: CrossmintWalletService,\n private readonly accountClient: SmartWalletClient,\n publicClient: PublicClient<HttpTransport>,\n chain: SmartWalletChain,\n protected readonly logger = scwLogger\n ) {\n this.chain = chain;\n this.client = {\n wallet: accountClient,\n public: publicClient,\n };\n }\n\n /**\n * The address of the smart wallet.\n */\n public get address() {\n return this.accountClient.account.address;\n }\n\n /**\n * @returns The transaction hash.\n */\n public async transferToken(toAddress: string, config: TransferType): Promise<string> {\n return this.logger.logPerformance(\n \"TRANSFER\",\n async () => {\n if (this.chain !== config.token.chain) {\n throw new Error(\n `Chain mismatch: Expected ${config.token.chain}, but got ${this.chain}. Ensure you are interacting with the correct blockchain.`\n );\n }\n\n if (!isAddress(toAddress)) {\n throw new Error(`Invalid recipient address: '${toAddress}' is not a valid EVM address.`);\n }\n\n if (!isAddress(config.token.contractAddress)) {\n throw new Error(\n `Invalid contract address: '${config.token.contractAddress}' is not a valid EVM address.`\n );\n }\n\n const tx = transferParams({\n contract: config.token.contractAddress,\n to: toAddress,\n from: this.accountClient.account,\n config,\n });\n\n try {\n const client = this.accountClient.extend(publicActions);\n const { request } = await client.simulateContract(tx);\n const hash = await client.writeContract(request);\n this.logger.log(`[TRANSFER] - Transaction hash from transfer: ${hash}`);\n\n return hash;\n } catch (error) {\n this.logger.error(\"[TRANSFER] - ERROR_TRANSFERRING_TOKEN\", {\n error: error instanceof Error ? error.message : JSON.stringify(error),\n tokenId: tx.tokenId,\n contractAddress: config.token.contractAddress,\n chain: config.token.chain,\n });\n const tokenIdString = tx.tokenId == null ? \"\" : `:${tx.tokenId}}`;\n throw new TransferError(`Error transferring token ${config.token.contractAddress}${tokenIdString}`);\n }\n },\n { toAddress, config }\n );\n }\n\n /**\n * @returns A list of NFTs owned by the wallet.\n */\n public async nfts() {\n return this.crossmintService.fetchNFTs(this.address, this.chain);\n }\n}\n","import { SDKLogger, getBrowserLogger } from \"@crossmint/client-sdk-base\";\n\nimport { SCW_SERVICE } from \"../utils/constants\";\n\nexport const scwLogger = new SDKLogger(SCW_SERVICE);\nexport const scwDatadogLogger = new SDKLogger(SCW_SERVICE, getBrowserLogger(SCW_SERVICE, { onlyDatadog: true }));\n","export const ZERO_DEV_TYPE = \"ZeroDev\";\nexport const CURRENT_VERSION = 0;\nexport const SCW_SERVICE = \"SCW_SDK\";\nexport const SDK_VERSION = \"0.1.0\";\nexport const API_VERSION = \"2024-06-09\";\nexport const BUNDLER_RPC = \"https://rpc.zerodev.app/api/v2/bundler/\";\nexport const PAYMASTER_RPC = \"https://rpc.zerodev.app/api/v2/paymaster/\";\nexport const SUPPORTED_KERNEL_VERSIONS = [\"0.3.1\", \"0.3.0\", \"0.2.4\"] as const;\nexport const SUPPORTED_ENTRYPOINT_VERSIONS = [\"v0.6\", \"v0.7\"] as const;\n","import { Abi, Account, Address, erc20Abi, erc721Abi } from \"viem\";\n\nimport erc1155Abi from \"../ABI/ERC1155.json\";\nimport type { ERC20TransferType, SFTTransferType, TransferType } from \"../types/token\";\n\ntype TransferInputParams = {\n from: Account;\n contract: Address;\n to: Address;\n config: TransferType;\n};\n\ntype TransferSimulationParams = {\n account: Account;\n address: Address;\n abi: Abi;\n functionName: string;\n args: any[];\n tokenId?: string;\n};\n\nexport function transferParams({ contract, config, from, to }: TransferInputParams): TransferSimulationParams {\n switch (config.token.type) {\n case \"ft\": {\n return {\n account: from,\n address: contract,\n abi: erc20Abi,\n functionName: \"transfer\",\n args: [to, (config as ERC20TransferType).amount],\n };\n }\n case \"sft\": {\n return {\n account: from,\n address: contract,\n abi: erc1155Abi as Abi,\n functionName: \"safeTransferFrom\",\n args: [from.address, to, config.token.tokenId, (config as SFTTransferType).quantity, \"0x00\"],\n tokenId: config.token.tokenId,\n };\n }\n case \"nft\": {\n return {\n account: from,\n address: contract,\n abi: erc721Abi,\n functionName: \"safeTransferFrom\",\n args: [from.address, to, config.token.tokenId],\n tokenId: config.token.tokenId,\n };\n }\n }\n}\n","[\n {\n \"inputs\": [\n {\n \"internalType\": \"string\",\n \"name\": \"uri_\",\n \"type\": \"string\"\n }\n ],\n \"stateMutability\": \"nonpayable\",\n \"type\": \"constructor\"\n },\n {\n \"anonymous\": false,\n \"inputs\": [\n {\n \"indexed\": true,\n \"internalType\": \"address\",\n \"name\": \"account\",\n \"type\": \"address\"\n },\n {\n \"indexed\": true,\n \"internalType\": \"address\",\n \"name\": \"operator\",\n \"type\": \"address\"\n },\n {\n \"indexed\": false,\n \"internalType\": \"bool\",\n \"name\": \"approved\",\n \"type\": \"bool\"\n }\n ],\n \"name\": \"ApprovalForAll\",\n \"type\": \"event\"\n },\n {\n \"anonymous\": false,\n \"inputs\": [\n {\n \"indexed\": true,\n \"internalType\": \"address\",\n \"name\": \"operator\",\n \"type\": \"address\"\n },\n {\n \"indexed\": true,\n \"internalType\": \"address\",\n \"name\": \"from\",\n \"type\": \"address\"\n },\n {\n \"indexed\": true,\n \"internalType\": \"address\",\n \"name\": \"to\",\n \"type\": \"address\"\n },\n {\n \"indexed\": false,\n \"internalType\": \"uint256[]\",\n \"name\": \"ids\",\n \"type\": \"uint256[]\"\n },\n {\n \"indexed\": false,\n \"internalType\": \"uint256[]\",\n \"name\": \"values\",\n \"type\": \"uint256[]\"\n }\n ],\n \"name\": \"TransferBatch\",\n \"type\": \"event\"\n },\n {\n \"anonymous\": false,\n \"inputs\": [\n {\n \"indexed\": true,\n \"internalType\": \"address\",\n \"name\": \"operator\",\n \"type\": \"address\"\n },\n {\n \"indexed\": true,\n \"internalType\": \"address\",\n \"name\": \"from\",\n \"type\": \"address\"\n },\n {\n \"indexed\": true,\n \"internalType\": \"address\",\n \"name\": \"to\",\n \"type\": \"address\"\n },\n {\n \"indexed\": false,\n \"internalType\": \"uint256\",\n \"name\": \"id\",\n \"type\": \"uint256\"\n },\n {\n \"indexed\": false,\n \"internalType\": \"uint256\",\n \"name\": \"value\",\n \"type\": \"uint256\"\n }\n ],\n \"name\": \"TransferSingle\",\n \"type\": \"event\"\n },\n {\n \"anonymous\": false,\n \"inputs\": [\n {\n \"indexed\": false,\n \"internalType\": \"string\",\n \"name\": \"value\",\n \"type\": \"string\"\n },\n {\n \"indexed\": true,\n \"internalType\": \"uint256\",\n \"name\": \"id\",\n \"type\": \"uint256\"\n }\n ],\n \"name\": \"URI\",\n \"type\": \"event\"\n },\n {\n \"inputs\": [\n {\n \"internalType\": \"address\",\n \"name\": \"account\",\n \"type\": \"address\"\n },\n {\n \"internalType\": \"uint256\",\n \"name\": \"id\",\n \"type\": \"uint256\"\n }\n ],\n \"name\": \"balanceOf\",\n \"outputs\": [\n {\n \"internalType\": \"uint256\",\n \"name\": \"\",\n \"type\": \"uint256\"\n }\n ],\n \"stateMutability\": \"view\",\n \"type\": \"function\"\n },\n {\n \"inputs\": [\n {\n \"internalType\": \"address[]\",\n \"name\": \"accounts\",\n \"type\": \"address[]\"\n },\n {\n \"internalType\": \"uint256[]\",\n \"name\": \"ids\",\n \"type\": \"uint256[]\"\n }\n ],\n \"name\": \"balanceOfBatch\",\n \"outputs\": [\n {\n \"internalType\": \"uint256[]\",\n \"name\": \"\",\n \"type\": \"uint256[]\"\n }\n ],\n \"stateMutability\": \"view\",\n \"type\": \"function\"\n },\n {\n \"inputs\": [\n {\n \"internalType\": \"address\",\n \"name\": \"account\",\n \"type\": \"address\"\n },\n {\n \"internalType\": \"address\",\n \"name\": \"operator\",\n \"type\": \"address\"\n }\n ],\n \"name\": \"isApprovedForAll\",\n \"outputs\": [\n {\n \"internalType\": \"bool\",\n \"name\": \"\",\n \"type\": \"bool\"\n }\n ],\n \"stateMutability\": \"view\",\n \"type\": \"function\"\n },\n {\n \"inputs\": [\n {\n \"internalType\": \"address\",\n \"name\": \"from\",\n \"type\": \"address\"\n },\n {\n \"internalType\": \"address\",\n \"name\": \"to\",\n \"type\": \"address\"\n },\n {\n \"internalType\": \"uint256[]\",\n \"name\": \"ids\",\n \"type\": \"uint256[]\"\n },\n {\n \"internalType\": \"uint256[]\",\n \"name\": \"amounts\",\n \"type\": \"uint256[]\"\n },\n {\n \"internalType\": \"bytes\",\n \"name\": \"data\",\n \"type\": \"bytes\"\n }\n ],\n \"name\": \"safeBatchTransferFrom\",\n \"outputs\": [],\n \"stateMutability\": \"nonpayable\",\n \"type\": \"function\"\n },\n {\n \"inputs\": [\n {\n \"internalType\": \"address\",\n \"name\": \"from\",\n \"type\": \"address\"\n },\n {\n \"internalType\": \"address\",\n \"name\": \"to\",\n \"type\": \"address\"\n },\n {\n \"internalType\": \"uint256\",\n \"name\": \"id\",\n \"type\": \"uint256\"\n },\n {\n \"internalType\": \"uint256\",\n \"name\": \"amount\",\n \"type\": \"uint256\"\n },\n {\n \"internalType\": \"bytes\",\n \"name\": \"data\",\n \"type\": \"bytes\"\n }\n ],\n \"name\": \"safeTransferFrom\",\n \"outputs\": [],\n \"stateMutability\": \"nonpayable\",\n \"type\": \"function\"\n },\n {\n \"inputs\": [\n {\n \"internalType\": \"address\",\n \"name\": \"operator\",\n \"type\": \"address\"\n },\n {\n \"internalType\": \"bool\",\n \"name\": \"approved\",\n \"type\": \"bool\"\n }\n ],\n \"name\": \"setApprovalForAll\",\n \"outputs\": [],\n \"stateMutability\": \"nonpayable\",\n \"type\": \"function\"\n },\n {\n \"inputs\": [\n {\n \"internalType\": \"bytes4\",\n \"name\": \"interfaceId\",\n \"type\": \"bytes4\"\n }\n ],\n \"name\": \"supportsInterface\",\n \"outputs\": [\n {\n \"internalType\": \"bool\",\n \"name\": \"\",\n \"type\": \"bool\"\n }\n ],\n \"stateMutability\": \"view\",\n \"type\": \"function\"\n },\n {\n \"inputs\": [\n {\n \"internalType\": \"uint256\",\n \"name\": \"\",\n \"type\": \"uint256\"\n }\n ],\n \"name\": \"uri\",\n \"outputs\": [\n {\n \"internalType\": \"string\",\n \"name\": \"\",\n \"type\": \"string\"\n }\n ],\n \"stateMutability\": \"view\",\n \"type\": \"function\"\n }\n]\n","import { CrossmintSDKError, SmartWalletErrorCode } from \"@crossmint/client-sdk-base\";\n\nimport { PasskeyDisplay, SignerDisplay } from \"../types/service\";\n\nexport class SmartWalletError extends CrossmintSDKError {\n constructor(message: string, details?: string, code: SmartWalletErrorCode = SmartWalletErrorCode.UNCATEGORIZED) {\n super(message, code, details);\n }\n}\n\nexport class AdminMismatchError extends SmartWalletError {\n public readonly required: SignerDisplay;\n public readonly used?: SignerDisplay;\n\n constructor(message: string, required: SignerDisplay, used?: SignerDisplay) {\n super(message, SmartWalletErrorCode.ADMIN_MISMATCH);\n this.required = required;\n this.used = used;\n }\n}\n\nexport class PasskeyMismatchError extends SmartWalletError {\n public readonly required: PasskeyDisplay;\n public readonly used?: PasskeyDisplay;\n\n constructor(message: string, required: PasskeyDisplay, used?: PasskeyDisplay) {\n super(message, SmartWalletErrorCode.PASSKEY_MISMATCH);\n this.required = required;\n this.used = used;\n }\n}\n\nexport class UserWalletAlreadyCreatedError extends SmartWalletError {\n public readonly code = SmartWalletErrorCode.USER_WALLET_ALREADY_CREATED;\n\n constructor(userId: string) {\n super(`The user with userId ${userId.toString()} already has a wallet created for this project`);\n }\n}\n\nexport class PasskeyPromptError extends SmartWalletError {\n public passkeyName: string;\n\n constructor(passkeyName: string) {\n super(\n `Prompt was either cancelled or timed out for passkey ${passkeyName}`,\n undefined,\n SmartWalletErrorCode.PASSKEY_PROMPT\n );\n this.passkeyName = passkeyName;\n }\n}\n\nexport class PasskeyRegistrationError extends SmartWalletError {\n public passkeyName: string;\n\n constructor(passkeyName: string) {\n super(\n `Registration for passkey ${passkeyName} failed, either the registration took too long, or passkey signature vaildation failed.`,\n undefined,\n SmartWalletErrorCode.PASSKEY_REGISTRATION\n );\n this.passkeyName = passkeyName;\n }\n}\n\nexport class PasskeyIncompatibleAuthenticatorError extends SmartWalletError {\n public passkeyName: string;\n\n constructor(passkeyName: string) {\n super(\n `User selected authenticator for passkey ${passkeyName} is not compatible with Crossmint's Smart Wallets.`,\n undefined,\n SmartWalletErrorCode.PASSKEY_INCOMPATIBLE_AUTHENTICATOR\n );\n this.passkeyName = passkeyName;\n }\n}\n\nexport class ConfigError extends SmartWalletError {\n constructor(message: string) {\n super(message, undefined, SmartWalletErrorCode.WALLET_CONFIG);\n }\n}\n\nexport class AdminAlreadyUsedError extends ConfigError {\n public readonly code = SmartWalletErrorCode.ADMIN_SIGNER_ALREADY_USED;\n constructor() {\n super(\"This signer was already used to create another wallet. Please use a different signer.\");\n }\n}\n\nexport class SmartWalletsNotEnabledError extends ConfigError {\n public readonly code = SmartWalletErrorCode.SMART_WALLETS_NOT_ENABLED;\n constructor() {\n super(\n \"Smart wallets are not enabled for this project. They can be enabled on the project settings page in the developer console.\"\n );\n }\n}\n","import { stringify } from \"viem\";\n\nimport { validateAPIKey } from \"@crossmint/common-sdk-base\";\n\nimport { CrossmintWalletService } from \"./api/CrossmintWalletService\";\nimport type { SmartWalletChain } from \"./blockchain/chains\";\nimport type { EVMSmartWallet } from \"./blockchain/wallets\";\nimport { AccountConfigCache } from \"./blockchain/wallets/account/cache\";\nimport { AccountConfigService } from \"./blockchain/wallets/account/config\";\nimport { AccountCreator } from \"./blockchain/wallets/account/creator\";\nimport { EOACreationStrategy } from \"./blockchain/wallets/account/eoa\";\nimport { PasskeyCreationStrategy } from \"./blockchain/wallets/account/passkey\";\nimport { ClientDecorator } from \"./blockchain/wallets/clientDecorator\";\nimport { SmartWalletService } from \"./blockchain/wallets/service\";\nimport { SmartWalletError } from \"./error\";\nimport { ErrorProcessor } from \"./error/processor\";\nimport { scwDatadogLogger, scwLogger } from \"./services\";\nimport type { SmartWalletSDKInitParams, UserParams, WalletParams } from \"./types/params\";\nimport { SDK_VERSION } from \"./utils/constants\";\nimport { isClient } from \"./utils/environment\";\n\nexport class SmartWalletSDK {\n private constructor(\n private readonly smartWalletService: SmartWalletService,\n private readonly errorProcessor: ErrorProcessor,\n private readonly logger = scwLogger\n ) {}\n\n /**\n * Initializes the SDK with the **client side** API key obtained from the Crossmint console.\n * @throws error if the api key is not formatted correctly.\n */\n static init({ clientApiKey }: SmartWalletSDKInitParams): SmartWalletSDK {\n if (!isClient()) {\n throw new SmartWalletError(\"Smart Wallet SDK should only be used client side.\");\n }\n\n const validationResult = validateAPIKey(clientApiKey);\n if (!validationResult.isValid) {\n throw new Error(\"API key invalid\");\n }\n\n const crossmintService = new CrossmintWalletService(clientApiKey);\n const errorProcessor = new ErrorProcessor(scwDatadogLogger);\n const accountCreator = new AccountCreator(\n new EOACreationStrategy(),\n new PasskeyCreationStrategy(crossmintService.getPasskeyServerUrl(), clientApiKey)\n );\n const accountCache = new AccountConfigCache(`smart-wallet-${SDK_VERSION}`);\n\n const smartWalletService = new SmartWalletService(\n crossmintService,\n new AccountConfigService(crossmintService, accountCache),\n accountCreator,\n new ClientDecorator(errorProcessor)\n );\n\n return new SmartWalletSDK(smartWalletService, errorProcessor);\n }\n\n /**\n * Retrieves or creates a wallet for the specified user.\n * The default configuration is a `PasskeySigner` with the name, which is displayed to the user during creation or signing prompts, derived from the provided jwt.\n *\n * Example using the default passkey signer:\n * ```ts\n * const wallet = await smartWalletSDK.getOrCreateWallet({ jwt: \"xxx\" }, \"base\");\n * ```\n */\n async getOrCreateWallet(\n user: UserParams,\n chain: SmartWalletChain,\n walletParams: WalletParams = { signer: { type: \"PASSKEY\" } }\n ): Promise<EVMSmartWallet> {\n return this.logger.logPerformance(\"GET_OR_CREATE_WALLET\", async () => {\n try {\n return await this.smartWalletService.getOrCreate(user, chain, walletParams);\n } catch (error: any) {\n throw this.errorProcessor.map(\n error,\n new SmartWalletError(`Wallet creation failed: ${error.message}.`, stringify(error))\n );\n }\n });\n }\n}\n","import type { UserOperation } from \"permissionless\";\nimport type { EntryPoint, GetEntryPointVersion } from \"permissionless/types/entrypoint\";\n\nimport { APIErrorService, BaseCrossmintService, CrossmintServiceError } from \"@crossmint/client-sdk-base\";\nimport { blockchainToChainId } from \"@crossmint/common-sdk-base\";\n\nimport type { SmartWalletChain } from \"../blockchain/chains\";\nimport { AdminAlreadyUsedError, SmartWalletsNotEnabledError, UserWalletAlreadyCreatedError } from \"../error\";\nimport { scwLogger } from \"../services\";\nimport type { UserParams } from \"../types/params\";\nimport { SmartWalletConfigSchema } from \"../types/schema\";\nimport type { SmartWalletConfig, StoreSmartWalletParams } from \"../types/service\";\nimport { bigintsToHex, parseBigintAPIResponse } from \"../utils/api\";\nimport { API_VERSION } from \"../utils/constants\";\n\ntype WalletsAPIErrorCodes =\n | \"ERROR_USER_WALLET_ALREADY_CREATED\"\n | \"ERROR_ADMIN_SIGNER_ALREADY_USED\"\n | \"ERROR_PROJECT_NONCUSTODIAL_WALLETS_NOT_ENABLED\";\n\nexport class CrossmintWalletService extends BaseCrossmintService {\n logger = scwLogger;\n protected apiErrorService = new APIErrorService<WalletsAPIErrorCodes>({\n ERROR_USER_WALLET_ALREADY_CREATED: ({ userId }: { userId: string }) =>\n new UserWalletAlreadyCreatedError(userId),\n ERROR_ADMIN_SIGNER_ALREADY_USED: () => new AdminAlreadyUsedError(),\n ERROR_PROJECT_NONCUSTODIAL_WALLETS_NOT_ENABLED: () => new SmartWalletsNotEnabledError(),\n });\n\n async idempotentCreateSmartWallet(user: UserParams, input: StoreSmartWalletParams): Promise<void> {\n await this.fetchCrossmintAPI(\n `${API_VERSION}/sdk/smart-wallet`,\n { method: \"PUT\", body: JSON.stringify(input) },\n \"Error creating abstract wallet. Please contact support\",\n user.jwt\n );\n }\n\n async sponsorUserOperation<E extends EntryPoint>(\n user: UserParams,\n userOp: UserOperation<GetEntryPointVersion<E>>,\n entryPoint: E,\n chain: SmartWalletChain\n ): Promise<{ sponsorUserOpParams: UserOperation<GetEntryPointVersion<E>> }> {\n const chainId = blockchainToChainId(chain);\n const result = await this.fetchCrossmintAPI(\n `${API_VERSION}/sdk/paymaster`,\n { method: \"POST\", body: JSON.stringify({ userOp: bigintsToHex(userOp), entryPoint, chainId }) },\n \"Error sponsoring user operation. Please contact support\",\n user.jwt\n );\n return parseBigintAPIResponse(result);\n }\n\n async getSmartWalletConfig(user: UserParams, chain: SmartWalletChain): Promise<SmartWalletConfig> {\n const data: unknown = await this.fetchCrossmintAPI(\n `${API_VERSION}/sdk/smart-wallet/config?chain=${chain}`,\n { method: \"GET\" },\n \"Error getting smart wallet version configuration. Please contact support\",\n user.jwt\n );\n\n const result = SmartWalletConfigSchema.safeParse(data);\n if (!result.success) {\n throw new CrossmintServiceError(\n `Invalid smart wallet config, please contact support. Details below:\\n${result.error.toString()}`\n );\n }\n\n return result.data;\n }\n\n async fetchNFTs(address: string, chain: SmartWalletChain) {\n return this.fetchCrossmintAPI(\n `v1-alpha1/wallets/${chain}:${address}/nfts`,\n { method: \"GET\" },\n `Error fetching NFTs for wallet: ${address}`\n );\n }\n\n public getPasskeyServerUrl(): string {\n return this.crossmintBaseUrl + \"api/internal/passkeys\";\n }\n}\n","import { PasskeyValidatorContractVersion } from \"@zerodev/passkey-validator\";\nimport { isAddress, isHex } from \"viem\";\nimport { z } from \"zod\";\n\nimport { SUPPORTED_ENTRYPOINT_VERSIONS, SUPPORTED_KERNEL_VERSIONS } from \"../utils/constants\";\n\nconst HexSchema = z.custom<`0x${string}`>((val): val is `0x${string}` => isHex(val as string), {\n message: \"Invalid hex string\",\n});\n\nconst evmAddressSchema = z.custom<`0x${string}`>((val): val is `0x${string}` => isAddress(val as string), {\n message: \"Invalid evm address\",\n});\n\nexport const EOASignerDataSchema = z.object({\n eoaAddress: evmAddressSchema,\n type: z.literal(\"eoa\"),\n});\n\nexport const PasskeyValidatorSerializedDataSchema = z.object({\n entryPoint: evmAddressSchema,\n validatorAddress: evmAddressSchema,\n pubKeyX: z.string(),\n pubKeyY: z.string(),\n authenticatorIdHash: HexSchema,\n authenticatorId: z.string(),\n});\n\nexport const PasskeySignerDataSchema = PasskeyValidatorSerializedDataSchema.extend({\n passkeyName: z.string(),\n validatorContractVersion: z.nativeEnum(PasskeyValidatorContractVersion),\n domain: z.string(),\n type: z.literal(\"passkeys\"),\n});\n\nexport const SignerDataSchema = z.discriminatedUnion(\"type\", [PasskeySignerDataSchema, EOASignerDataSchema]);\n\nexport const SmartWalletConfigSchema = z.object({\n kernelVersion: z.enum(SUPPORTED_KERNEL_VERSIONS, {\n errorMap: (_, ctx) => ({\n message: `Unsupported kernel version. Supported versions: ${SUPPORTED_KERNEL_VERSIONS.join(\n \", \"\n )}. Version used: ${ctx.data}. Please contact support`,\n }),\n }),\n entryPointVersion: z.enum(SUPPORTED_ENTRYPOINT_VERSIONS, {\n errorMap: (_, ctx) => ({\n message: `Unsupported entry point version. Supported versions: ${SUPPORTED_ENTRYPOINT_VERSIONS.join(\n \", \"\n )}. Version used: ${ctx.data}. Please contact support`,\n }),\n }),\n userId: z.string().min(1),\n signers: z\n .array(\n z.object({\n signerData: SignerDataSchema,\n })\n )\n .min(0)\n .max(1, \"Invalid wallet signer configuration. Please contact support\"),\n smartContractWalletAddress: evmAddressSchema.optional(),\n});\n","import { toHex } from \"viem\";\n\nfunction mapObject(data: any, fn: (value: unknown) => { value: unknown; replace: boolean }): any {\n const result = fn(data);\n if (result.replace) {\n return result.value;\n }\n if (Array.isArray(data)) {\n return data.map((item) => mapObject(item, fn));\n } else if (data !== null && typeof data === \"object\") {\n return Object.fromEntries(Object.entries(data).map(([key, value]) => [key, mapObject(value, fn)]));\n }\n return result.value;\n}\n\nexport function bigintsToHex(data: any): any {\n return mapObject(data, (value) => {\n if (typeof value === \"bigint\") {\n return { value: toHex(value), replace: true };\n }\n return { value, replace: false };\n });\n}\n\nexport function parseBigintAPIResponse(data: any): any {\n return mapObject(data, (value) => {\n if (\n value != null &&\n typeof value == \"object\" &&\n \"__xm_serializedType\" in value &&\n \"value\" in value &&\n value.__xm_serializedType === \"bigint\" &&\n typeof value.value === \"string\"\n ) {\n return { value: BigInt(value.value), replace: true };\n }\n return { value, replace: false };\n });\n}\n","import { keccak256, toHex } from \"viem\";\n\nimport { UserParams } from \"../../../types/params\";\nimport { SmartWalletConfigSchema } from \"../../../types/schema\";\nimport type { SmartWalletConfig } from \"../../../types/service\";\n\nexport class AccountConfigCache {\n constructor(private readonly keyPrefix: string) {}\n\n public set(user: UserParams, config: SmartWalletConfig) {\n localStorage.setItem(this.key(user), JSON.stringify(config));\n }\n\n public get(user: UserParams): SmartWalletConfig | null {\n const key = this.key(user);\n const data = localStorage.getItem(key);\n if (data == null) {\n return null;\n }\n\n const result = SmartWalletConfigSchema.safeParse(JSON.parse(data));\n if (!result.success) {\n localStorage.removeItem(key);\n return null;\n }\n\n return result.data;\n }\n\n public clear() {\n for (let i = 0; i < localStorage.length; i++) {\n const key = localStorage.key(i);\n if (key && key.startsWith(this.keyPrefix)) {\n localStorage.removeItem(key);\n i--; // Decrement i since we've removed an item\n }\n }\n }\n\n private key(user: UserParams) {\n return `${this.keyPrefix}-${keccak256(toHex(user.jwt))}`;\n }\n}\n","import type {\n EOASignerData,\n PasskeyDisplay,\n PasskeySignerData,\n SignerData,\n SignerDisplay,\n} from \"../../../types/service\";\n\nexport interface SignerConfig {\n readonly type: \"passkeys\" | \"eoa\";\n display(): SignerDisplay;\n readonly data: SignerData;\n}\n\nexport class PasskeySignerConfig implements SignerConfig {\n public readonly data: PasskeySignerData;\n public readonly type = \"passkeys\";\n\n constructor(data: PasskeySignerData) {\n this.data = data;\n }\n\n public display(): PasskeyDisplay {\n return {\n pubKeyX: this.data.pubKeyX,\n pubKeyY: this.data.pubKeyY,\n passkeyName: this.data.passkeyName,\n type: this.type,\n };\n }\n}\n\nexport class EOASignerConfig implements SignerConfig {\n public readonly data: EOASignerData;\n public readonly type = \"eoa\";\n\n constructor(data: EOASignerData) {\n this.data = data;\n }\n\n public display() {\n return this.data;\n }\n}\n","import type { CrossmintWalletService } from \"../../../api/CrossmintWalletService\";\nimport type { SmartWalletChain } from \"../../../blockchain/chains\";\nimport { SmartWalletError } from \"../../../error\";\nimport type {\n PreExistingWalletProperties,\n SupportedEntryPointVersion,\n SupportedKernelVersion,\n} from \"../../../types/internal\";\nimport type { UserParams } from \"../../../types/params\";\nimport type { SignerData, SmartWalletConfig } from \"../../../types/service\";\nimport { AccountConfigCache } from \"./cache\";\nimport { EOASignerConfig, PasskeySignerConfig, type SignerConfig } from \"./signer\";\n\ninterface AccountConfig {\n entryPointVersion: SupportedEntryPointVersion;\n kernelVersion: SupportedKernelVersion;\n userWithId: UserParams & { id: string };\n existing?: PreExistingWalletProperties;\n}\nexport class AccountConfigService {\n constructor(\n private readonly crossmintService: CrossmintWalletService,\n private readonly configCache: AccountConfigCache\n ) {}\n\n public async get(\n user: UserParams,\n chain: SmartWalletChain\n ): Promise<{\n config: AccountConfig;\n cached: boolean;\n }> {\n const cached = this.configCache.get(user);\n if (cached != null) {\n return {\n config: this.validateAndFormat(user, cached),\n cached: true,\n };\n }\n\n const config = await this.crossmintService.getSmartWalletConfig(user, chain);\n return { config: this.validateAndFormat(user, config), cached: false };\n }\n\n public cache({\n entryPointVersion,\n kernelVersion,\n user,\n existing,\n }: {\n entryPointVersion: SupportedEntryPointVersion;\n kernelVersion: SupportedKernelVersion;\n user: UserParams & { id: string };\n existing: PreExistingWalletProperties;\n }) {\n this.configCache.clear();\n this.configCache.set(user, {\n entryPointVersion,\n kernelVersion,\n userId: user.id,\n signers: [{ signerData: existing.signerConfig.data }],\n smartContractWalletAddress: existing.address,\n });\n }\n\n private validateAndFormat(\n user: UserParams,\n { entryPointVersion, kernelVersion, signers, smartContractWalletAddress, userId }: SmartWalletConfig\n ): AccountConfig {\n if (\n (entryPointVersion === \"v0.7\" && kernelVersion.startsWith(\"0.2\")) ||\n (entryPointVersion === \"v0.6\" && kernelVersion.startsWith(\"0.3\"))\n ) {\n throw new SmartWalletError(\n `Unsupported combination: entryPoint ${entryPointVersion} and kernel version ${kernelVersion}. Please contact support`\n );\n }\n\n const signerData = signers.map((x) => x.signerData);\n const signer = this.getSigner(signerData);\n\n if (\n (smartContractWalletAddress != null && signer == null) ||\n (signer != null && smartContractWalletAddress == null)\n ) {\n throw new SmartWalletError(\"Either both signer and address must be present, or both must be null\");\n }\n\n if (signer == null || smartContractWalletAddress == null) {\n return { entryPointVersion, kernelVersion, userWithId: { ...user, id: userId } };\n }\n\n return {\n entryPointVersion,\n kernelVersion,\n userWithId: { ...user, id: userId },\n existing: { signerConfig: signer, address: smartContractWalletAddress },\n };\n }\n\n private getSigner(signers: SignerData[]): SignerConfig | undefined {\n if (signers.length === 0) {\n return undefined;\n }\n\n const data = signers[0];\n\n if (data.type === \"eoa\") {\n return new EOASignerConfig(data);\n }\n\n if (data.type === \"passkeys\") {\n return new PasskeySignerConfig(data);\n }\n }\n}\n","import type { KernelSmartAccount } from \"@zerodev/sdk\";\nimport type { SmartAccountClient } from \"permissionless\";\nimport type { SmartAccount } from \"permissionless/accounts\";\nimport type { EntryPoint } from \"permissionless/types/entrypoint\";\nimport type { Address, Chain, HttpTransport, PublicClient } from \"viem\";\n\nimport type { SmartWalletChain } from \"../blockchain/chains\";\nimport type { EOASignerConfig, PasskeySignerConfig, SignerConfig } from \"../blockchain/wallets/account/signer\";\nimport { SUPPORTED_ENTRYPOINT_VERSIONS, SUPPORTED_KERNEL_VERSIONS } from \"../utils/constants\";\nimport type { EOASigner, PasskeySigner, UserParams, WalletParams } from \"./params\";\n\nexport type SupportedKernelVersion = (typeof SUPPORTED_KERNEL_VERSIONS)[number];\nexport function isSupportedKernelVersion(version: string): version is SupportedKernelVersion {\n return SUPPORTED_KERNEL_VERSIONS.includes(version as any);\n}\n\nexport type SupportedEntryPointVersion = (typeof SUPPORTED_ENTRYPOINT_VERSIONS)[number];\nexport function isSupportedEntryPointVersion(version: string): version is SupportedEntryPointVersion {\n return SUPPORTED_ENTRYPOINT_VERSIONS.includes(version as any);\n}\n\nexport interface PreExistingWalletProperties {\n signerConfig: SignerConfig;\n address: Address;\n}\n\nexport interface WalletCreationContext {\n user: UserParams & { id: string };\n chain: SmartWalletChain;\n publicClient: PublicClient<HttpTransport>;\n walletParams: WalletParams;\n entryPoint: EntryPoint;\n kernelVersion: SupportedKernelVersion;\n existing?: PreExistingWalletProperties;\n}\n\nexport interface PasskeyCreationContext extends WalletCreationContext {\n walletParams: WalletParams & { signer: PasskeySigner };\n existing?: { signerConfig: PasskeySignerConfig; address: Address };\n}\n\nexport interface EOACreationContext extends WalletCreationContext {\n walletParams: WalletParams & { signer: EOASigner };\n existing?: { signerConfig: EOASignerConfig; address: Address };\n}\n\nexport function isPasskeyWalletParams(params: WalletParams): params is WalletParams & { signer: PasskeySigner } {\n return \"signer\" in params && \"type\" in params.signer && params.signer.type === \"PASSKEY\";\n}\n\nexport function isPasskeyCreationContext(params: WalletCreationContext): params is PasskeyCreationContext {\n const signerIsPasskeyOrUndefined = params.existing == null || params.existing.signerConfig.type === \"passkeys\";\n\n return isPasskeyWalletParams(params.walletParams) && signerIsPasskeyOrUndefined;\n}\n\nexport function isEOAWalletParams(params: WalletParams): params is WalletParams & { signer: EOASigner } {\n return (\n \"signer\" in params &&\n ((\"type\" in params.signer && params.signer.type === \"VIEM_ACCOUNT\") ||\n (\"request\" in params.signer && typeof params.signer.request === \"function\"))\n );\n}\n\nexport function isEOACreationContext(params: WalletCreationContext): params is EOACreationContext {\n const signerIsEOAOrUndefined = params.existing == null || params.existing.signerConfig.type === \"eoa\";\n\n return isEOAWalletParams(params.walletParams) && signerIsEOAOrUndefined;\n}\n\nexport interface AccountAndSigner {\n account: KernelSmartAccount<EntryPoint, HttpTransport>;\n signerConfig: SignerConfig;\n}\n\nexport type SmartWalletClient = SmartAccountClient<EntryPoint, HttpTransport, Chain, SmartAccount<EntryPoint>>;\n","import { AdminMismatchError, ConfigError } from \"../../../error\";\nimport {\n type AccountAndSigner,\n type WalletCreationContext,\n isEOACreationContext,\n isPasskeyCreationContext,\n isPasskeyWalletParams,\n} from \"../../../types/internal\";\nimport { EOACreationStrategy } from \"./eoa\";\nimport { PasskeyCreationStrategy } from \"./passkey\";\n\nexport class AccountCreator {\n constructor(\n private readonly eoaStrategy: EOACreationStrategy,\n private readonly passkeyStrategy: PasskeyCreationStrategy\n ) {}\n\n public get(context: WalletCreationContext): Promise<AccountAndSigner> {\n if (isPasskeyCreationContext(context)) {\n return this.passkeyStrategy.create(context);\n }\n\n if (isEOACreationContext(context)) {\n return this.eoaStrategy.create(context);\n }\n\n if (context.existing == null) {\n throw new ConfigError(`Unsupported wallet params:\\n${context.walletParams}`);\n }\n\n const display = context.existing.signerConfig.display();\n const inputSignerType = isPasskeyWalletParams(context.walletParams) ? \"passkey\" : \"eoa\";\n throw new AdminMismatchError(\n `Cannot create wallet with ${inputSignerType} signer for user ${\n context.user.id\n }', they already have a wallet with signer:\\n'${JSON.stringify(display, null, 2)}'`,\n display\n );\n }\n}\n","import { signerToEcdsaValidator } from \"@zerodev/ecdsa-validator\";\nimport { createKernelAccount } from \"@zerodev/sdk\";\n\nimport { AdminMismatchError } from \"../../../error\";\nimport type { AccountAndSigner, EOACreationContext } from \"../../../types/internal\";\nimport { equalsIgnoreCase } from \"../../../utils/helpers\";\nimport { createOwnerSigner } from \"../../../utils/signer\";\nimport { EOASignerConfig } from \"./signer\";\nimport { AccountCreationStrategy } from \"./strategy\";\n\nexport class EOACreationStrategy implements AccountCreationStrategy {\n public async create({\n chain,\n publicClient,\n entryPoint,\n walletParams,\n kernelVersion,\n user,\n existing,\n }: EOACreationContext): Promise<AccountAndSigner> {\n const eoa = await createOwnerSigner({\n chain,\n walletParams,\n });\n\n if (existing != null && !equalsIgnoreCase(eoa.address, existing.signerConfig.data.eoaAddress)) {\n throw new AdminMismatchError(\n `User '${user.id}' has an existing wallet with an eoa signer '${existing.signerConfig.data.eoaAddress}', this does not match input eoa signer '${eoa.address}'.`,\n existing.signerConfig.display(),\n { type: \"eoa\", eoaAddress: existing.signerConfig.data.eoaAddress }\n );\n }\n\n const ecdsaValidator = await signerToEcdsaValidator(publicClient, {\n signer: eoa,\n entryPoint,\n kernelVersion,\n });\n const account = await createKernelAccount(publicClient, {\n plugins: {\n sudo: ecdsaValidator,\n },\n index: 0n,\n entryPoint,\n kernelVersion,\n deployedAccountAddress: existing?.address,\n });\n\n return { account, signerConfig: new EOASignerConfig({ eoaAddress: eoa.address, type: \"eoa\" }) };\n }\n}\n","export function isEmpty(str: string | undefined | null): str is undefined | null {\n return !str || str.length === 0 || str.trim().length === 0;\n}\n\nexport function equalsIgnoreCase(a?: string, b?: string): boolean {\n return a?.toLowerCase() === b?.toLowerCase();\n}\n","import { providerToSmartAccountSigner } from \"permissionless\";\nimport type { SmartAccountSigner } from \"permissionless/accounts\";\nimport { Address, EIP1193Provider } from \"viem\";\n\nimport { SmartWalletChain } from \"../blockchain/chains\";\nimport { SmartWalletError } from \"../error\";\nimport { ViemAccount, WalletParams } from \"../types/params\";\n\ntype CreateOwnerSignerInput = {\n chain: SmartWalletChain;\n walletParams: WalletParams;\n};\n\nexport async function createOwnerSigner({\n walletParams,\n}: CreateOwnerSignerInput): Promise<SmartAccountSigner<\"custom\", Address>> {\n if (isEIP1193Provider(walletParams.signer)) {\n return await providerToSmartAccountSigner(walletParams.signer);\n } else if (isAccount(walletParams.signer)) {\n return walletParams.signer.account;\n } else {\n const signer = walletParams.signer as any;\n throw new SmartWalletError(`The signer type ${signer.type} is not supported`);\n }\n}\n\nfunction isEIP1193Provider(signer: any): signer is EIP1193Provider {\n return signer && typeof signer.request === \"function\";\n}\n\nexport function isAccount(signer: any): signer is ViemAccount {\n return signer && signer.type === \"VIEM_ACCOUNT\";\n}\n","import { PasskeyValidatorContractVersion, WebAuthnMode, toPasskeyValidator } from \"@zerodev/passkey-validator\";\nimport { type KernelSmartAccount, type KernelValidator, createKernelAccount } from \"@zerodev/sdk\";\nimport { type WebAuthnKey, toWebAuthnKey } from \"@zerodev/webauthn-key\";\nimport type { SmartAccount } from \"permissionless/accounts\";\nimport type { EntryPoint } from \"permissionless/types/entrypoint\";\n\nimport {\n PasskeyIncompatibleAuthenticatorError,\n PasskeyMismatchError,\n PasskeyPromptError,\n PasskeyRegistrationError,\n} from \"../../../error\";\nimport type { AccountAndSigner, PasskeyCreationContext } from \"../../../types/internal\";\nimport type { UserParams } from \"../../../types/params\";\nimport type { PasskeySignerData, PasskeyValidatorSerializedData } from \"../../../types/service\";\nimport { PasskeySignerConfig } from \"./signer\";\nimport { AccountCreationStrategy } from \"./strategy\";\n\ntype PasskeyValidator = KernelValidator<EntryPoint, \"WebAuthnValidator\"> & {\n getSerializedData: () => string;\n};\nexport class PasskeyCreationStrategy implements AccountCreationStrategy {\n constructor(private readonly passkeyServerUrl: string, private readonly apiKey: string) {}\n\n public async create({\n user,\n publicClient,\n walletParams,\n entryPoint,\n kernelVersion,\n existing,\n }: PasskeyCreationContext): Promise<AccountAndSigner> {\n const inputPasskeyName = walletParams.signer.passkeyName ?? user.id;\n if (existing != null && existing.signerConfig.data.passkeyName !== inputPasskeyName) {\n throw new PasskeyMismatchError(\n `User '${user.id}' has an existing wallet created with a passkey named '${existing.signerConfig.data.passkeyName}', this does match input passkey name '${inputPasskeyName}'.`,\n existing.signerConfig.display()\n );\n }\n\n try {\n const passkey = await this.getPasskey(user, inputPasskeyName, existing?.signerConfig.data);\n\n const latestValidatorVersion = PasskeyValidatorContractVersion.V0_0_2;\n const validatorContractVersion =\n existing == null ? latestValidatorVersion : existing.signerConfig.data.validatorContractVersion;\n\n const validator = await toPasskeyValidator(publicClient, {\n webAuthnKey: passkey,\n entryPoint,\n validatorContractVersion,\n kernelVersion,\n });\n\n const kernelAccount = await createKernelAccount(publicClient, {\n plugins: { sudo: validator },\n entryPoint,\n kernelVersion,\n deployedAccountAddress: existing?.address,\n });\n\n return {\n signerConfig: this.getSignerConfig(validator, validatorContractVersion, inputPasskeyName),\n account: this.decorate(kernelAccount, inputPasskeyName),\n };\n } catch (error) {\n throw this.mapError(error, inputPasskeyName);\n }\n }\n\n private async getPasskey(\n user: UserParams,\n passkeyName: string,\n existing?: PasskeySignerData\n ): Promise<WebAuthnKey> {\n if (existing != null) {\n return {\n pubX: BigInt(existing.pubKeyX),\n pubY: BigInt(existing.pubKeyY),\n authenticatorId: existing.authenticatorId,\n authenticatorIdHash: existing.authenticatorIdHash,\n };\n }\n\n return toWebAuthnKey({\n passkeyName,\n passkeyServerUrl: this.passkeyServerUrl,\n mode: WebAuthnMode.Register,\n passkeyServerHeaders: this.createPasskeysServerHeaders(user),\n });\n }\n\n private getSignerConfig(\n validator: PasskeyValidator,\n validatorContractVersion: PasskeyValidatorContractVersion,\n passkeyName: string\n ): PasskeySignerConfig {\n return new PasskeySignerConfig({\n ...deserializePasskeyValidatorData(validator.getSerializedData()),\n passkeyName,\n validatorContractVersion,\n domain: window.location.hostname,\n type: \"passkeys\",\n });\n }\n\n private createPasskeysServerHeaders(user: UserParams) {\n return {\n \"x-api-key\": this.apiKey,\n Authorization: `Bearer ${user.jwt}`,\n };\n }\n\n private mapError(error: any, passkeyName: string) {\n if (error.code === 0 && error.name === \"DataError\") {\n return new PasskeyIncompatibleAuthenticatorError(passkeyName);\n }\n\n if (error.message === \"Registration not verified\") {\n return new PasskeyRegistrationError(passkeyName);\n }\n\n if (error.code === \"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY\" && error.name === \"NotAllowedError\") {\n return new PasskeyPromptError(passkeyName);\n }\n\n return error;\n }\n\n private decorate<Account extends KernelSmartAccount<EntryPoint>>(account: Account, passkeyName: string): Account {\n return new Proxy(account, {\n get: (target, prop, receiver) => {\n const original = Reflect.get(target, prop, receiver);\n if (typeof original !== \"function\" || typeof prop !== \"string\" || !isAccountSigningMethod(prop)) {\n return original;\n }\n\n return async (...args: any[]) => {\n try {\n return await original.call(target, ...args);\n } catch (error) {\n throw this.mapError(error, passkeyName);\n }\n };\n },\n });\n }\n}\n\nconst accountSigningMethods = [\n \"signMessage\",\n \"signTypedData\",\n \"signUserOperation\",\n \"signTransaction\",\n] as const satisfies readonly (keyof SmartAccount<EntryPoint>)[];\n\nfunction isAccountSigningMethod(method: string): method is (typeof accountSigningMethods)[number] {\n return accountSigningMethods.includes(method as any);\n}\n\nconst deserializePasskeyValidatorData = (params: string) => {\n const uint8Array = base64ToBytes(params);\n const jsonString = new TextDecoder().decode(uint8Array);\n\n return JSON.parse(jsonString) as PasskeyValidatorSerializedData;\n};\n\nfunction base64ToBytes(base64: string) {\n const binString = atob(base64);\n return Uint8Array.from(binString, (m) => m.codePointAt(0) as number);\n}\n","import type { SmartAccountClient } from \"permissionless\";\nimport type { EntryPoint } from \"permissionless/types/entrypoint\";\nimport { stringify } from \"viem\";\n\nimport { SmartWalletError } from \"../../error\";\nimport { ErrorProcessor } from \"../../error/processor\";\nimport { scwLogger } from \"../../services\";\nimport { usesGelatoBundler } from \"../../utils/blockchain\";\nimport { SmartWalletChain } from \"../chains\";\n\nconst transactionMethods = [\n \"sendTransaction\",\n \"writeContract\",\n \"sendUserOperation\",\n] as const satisfies readonly (keyof SmartAccountClient<EntryPoint>)[];\n\nconst signingMethods = [\n \"signMessage\",\n \"signTypedData\",\n] as const satisfies readonly (keyof SmartAccountClient<EntryPoint>)[];\n\ntype TxnMethod = (typeof transactionMethods)[number];\ntype SignMethod = (typeof signingMethods)[number];\n\nfunction isTxnMethod(method: string): method is TxnMethod {\n return transactionMethods.includes(method as any);\n}\n\nfunction isSignMethod(method: string): method is SignMethod {\n return signingMethods.includes(method as any);\n}\n\n/**\n * A decorator class for SmartAccountClient instances. It enhances the client with:\n * - Error handling & logging.\n * - Performance metrics.\n * - Automatic formatting of transactions for Gelato bundler compatibility.\n * */\nexport class ClientDecorator {\n constructor(private readonly errorProcessor: ErrorProcessor, protected logger = scwLogger) {}\n\n public decorate<Client extends SmartAccountClient<EntryPoint>>({\n crossmintChain,\n smartAccountClient,\n }: {\n crossmintChain: SmartWalletChain;\n smartAccountClient: Client;\n }): Client {\n return new Proxy(smartAccountClient, {\n get: (target, prop, receiver) => {\n const originalMethod = Reflect.get(target, prop, receiver);\n\n if (\n typeof originalMethod !== \"function\" ||\n typeof prop !== \"string\" ||\n !(isSignMethod(prop) || isTxnMethod(prop))\n ) {\n return originalMethod;\n }\n\n return (...args: any[]) =>\n this.logger.logPerformance(`CrossmintSmartWallet.${prop}`, () =>\n this.execute(target, prop, originalMethod, args, crossmintChain)\n );\n },\n }) as Client;\n }\n\n private async execute<M extends TxnMethod | SignMethod>(\n target: SmartAccountClient<EntryPoint>,\n prop: M,\n // eslint-disable-next-line @typescript-eslint/ban-types\n originalMethod: Function,\n args: any[],\n crossmintChain: SmartWalletChain\n ) {\n try {\n this.logger.log(`[CrossmintSmartWallet.${prop}] - params: ${stringify(args)}`);\n const processed = isTxnMethod(prop) ? this.processTxnArgs(prop, crossmintChain, args) : args;\n return await originalMethod.call(target, ...processed);\n } catch (error: any) {\n const description = isTxnMethod(prop) ? \"signing\" : \"sending transaction\";\n throw this.errorProcessor.map(\n error,\n new SmartWalletError(`Error ${description}: ${error.message}`, stringify(error))\n );\n }\n }\n\n private processTxnArgs(prop: TxnMethod, crossmintChain: SmartWalletChain, args: any[]): any[] {\n if (prop === \"sendUserOperation\") {\n const [{ userOperation, middleware, account }] = args as Parameters<\n SmartAccountClient<EntryPoint>[\"sendUserOperation\"]\n >;\n return [\n {\n middleware,\n account,\n userOperation: this.addGelatoBundlerProperties(crossmintChain, userOperation),\n },\n ...args.slice(1),\n ];\n }\n\n const [txn] = args as\n | Parameters<SmartAccountClient<EntryPoint>[\"sendTransaction\"]>\n | Parameters<SmartAccountClient<EntryPoint>[\"writeContract\"]>;\n\n return [this.addGelatoBundlerProperties(crossmintChain, txn), ...args.slice(1)];\n }\n\n /*\n * Chain that ZD uses Gelato as for bundler require special parameters:\n * https://docs.zerodev.app/sdk/faqs/use-with-gelato#transaction-configuration\n */\n private addGelatoBundlerProperties(\n crossmintChain: SmartWalletChain,\n txnParams: { maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint }\n ) {\n if (usesGelatoBundler(crossmintChain)) {\n return { ...txnParams, maxFeePerGas: \"0x0\" as any, maxPriorityFeePerGas: \"0x0\" as any };\n }\n\n return txnParams;\n }\n}\n","import { SmartWalletChain } from \"../blockchain/chains\";\n\nexport function usesGelatoBundler(chain: SmartWalletChain) {\n return false;\n}\n","import { createKernelAccountClient } from \"@zerodev/sdk\";\nimport { ENTRYPOINT_ADDRESS_V06, ENTRYPOINT_ADDRESS_V07 } from \"permissionless\";\nimport { createPublicClient, http } from \"viem\";\n\nimport { blockchainToChainId } from \"@crossmint/common-sdk-base\";\n\nimport type { CrossmintWalletService } from \"../../api/CrossmintWalletService\";\nimport type { SmartWalletClient } from \"../../types/internal\";\nimport type { UserParams, WalletParams } from \"../../types/params\";\nimport { CURRENT_VERSION, ZERO_DEV_TYPE } from \"../../utils/constants\";\nimport { type SmartWalletChain, getBundlerRPC, viemNetworks } from \"../chains\";\nimport { getAlchemyRPC } from \"../rpc\";\nimport { EVMSmartWallet } from \"./EVMSmartWallet\";\nimport type { AccountConfigService } from \"./account/config\";\nimport type { AccountCreator } from \"./account/creator\";\nimport type { ClientDecorator } from \"./clientDecorator\";\nimport { paymasterMiddleware, usePaymaster } from \"./paymaster\";\n\nexport class SmartWalletService {\n constructor(\n private readonly crossmintService: CrossmintWalletService,\n private readonly accountConfigService: AccountConfigService,\n private readonly accountCreator: AccountCreator,\n private readonly clientDecorator: ClientDecorator\n ) {}\n\n public async getOrCreate(\n user: UserParams,\n chain: SmartWalletChain,\n walletParams: WalletParams\n ): Promise<EVMSmartWallet> {\n const {\n config: { entryPointVersion, kernelVersion, existing, userWithId },\n cached,\n } = await this.accountConfigService.get(user, chain);\n\n const publicClient = createPublicClient({ transport: http(getAlchemyRPC(chain)) });\n\n const { account, signerConfig } = await this.accountCreator.get({\n chain,\n walletParams,\n publicClient,\n user: userWithId,\n entryPoint: entryPointVersion === \"v0.6\" ? ENTRYPOINT_ADDRESS_V06 : ENTRYPOINT_ADDRESS_V07,\n kernelVersion,\n existing,\n });\n\n if (existing == null) {\n await this.crossmintService.idempotentCreateSmartWallet(user, {\n type: ZERO_DEV_TYPE,\n smartContractWalletAddress: account.address,\n signerData: signerConfig.data,\n version: CURRENT_VERSION,\n baseLayer: \"evm\",\n chainId: blockchainToChainId(chain),\n entryPointVersion,\n kernelVersion,\n });\n }\n\n if (!cached) {\n this.accountConfigService.cache({\n entryPointVersion,\n kernelVersion,\n user: userWithId,\n existing: { address: account.address, signerConfig },\n });\n }\n\n const kernelAccountClient: SmartWalletClient = createKernelAccountClient({\n account,\n chain: viemNetworks[chain],\n entryPoint: account.entryPoint,\n bundlerTransport: http(getBundlerRPC(chain)),\n ...(usePaymaster(chain) &&\n paymasterMiddleware({\n entryPoint: account.entryPoint,\n chain,\n walletService: this.crossmintService,\n user,\n })),\n });\n\n const smartAccountClient = this.clientDecorator.decorate({\n crossmintChain: chain,\n smartAccountClient: kernelAccountClient,\n });\n\n return new EVMSmartWallet(this.crossmintService, smartAccountClient, publicClient, chain);\n }\n}\n","import {\n Chain,\n arbitrum,\n arbitrumSepolia,\n base,\n baseSepolia,\n optimism,\n optimismSepolia,\n polygon,\n polygonAmoy,\n} from \"viem/chains\";\n\nimport { BlockchainIncludingTestnet as Blockchain, ObjectValues, objectValues } from \"@crossmint/common-sdk-base\";\n\nimport { BUNDLER_RPC } from \"../utils/constants\";\n\nexport const SmartWalletTestnet = {\n BASE_SEPOLIA: Blockchain.BASE_SEPOLIA,\n POLYGON_AMOY: Blockchain.POLYGON_AMOY,\n OPTIMISM_SEPOLIA: Blockchain.OPTIMISM_SEPOLIA,\n ARBITRUM_SEPOLIA: Blockchain.ARBITRUM_SEPOLIA,\n} as const;\nexport type SmartWalletTestnet = ObjectValues<typeof SmartWalletTestnet>;\nexport const SMART_WALLET_TESTNETS = objectValues(SmartWalletTestnet);\n\nexport const SmartWalletMainnet = {\n BASE: Blockchain.BASE,\n POLYGON: Blockchain.POLYGON,\n OPTIMISM: Blockchain.OPTIMISM,\n ARBITRUM: Blockchain.ARBITRUM,\n} as const;\nexport type SmartWalletMainnet = ObjectValues<typeof SmartWalletMainnet>;\nexport const SMART_WALLET_MAINNETS = objectValues(SmartWalletMainnet);\n\nexport const SmartWalletChain = {\n ...SmartWalletTestnet,\n ...SmartWalletMainnet,\n} as const;\nexport type SmartWalletChain = ObjectValues<typeof SmartWalletChain>;\nexport const SMART_WALLET_CHAINS = objectValues(SmartWalletChain);\n\nexport const zerodevProjects: Record<SmartWalletChain, string> = {\n polygon: \"5c9f4865-ca8e-44bb-9b9e-3810b2b46f9f\",\n \"polygon-amoy\": \"3deef404-ca06-4a5d-9a58-907c99e7ef00\",\n \"base-sepolia\": \"5a127978-6473-4784-9dfb-f74395b220a6\",\n base: \"e8b3020f-4dde-4176-8a7d-be8102527a5c\",\n \"optimism-sepolia\": \"f8dd488e-eaed-467d-a5de-0184c160f3b1\",\n optimism: \"505950ab-ee07-4a9c-bd16-320ac71a9350\",\n arbitrum: \"a965100f-fedf-4e6b-a207-20f5687fcc4f\",\n \"arbitrum-sepolia\": \"76c860ca-af77-4fb1-8eac-07825952f6f4\",\n};\n\nexport const viemNetworks: Record<SmartWalletChain, Chain> = {\n polygon: polygon,\n \"polygon-amoy\": polygonAmoy,\n base: base,\n \"base-sepolia\": baseSepolia,\n optimism: optimism,\n \"optimism-sepolia\": optimismSepolia,\n arbitrum: arbitrum,\n \"arbitrum-sepolia\": arbitrumSepolia,\n};\n\nexport function getBundlerRPC(chain: SmartWalletChain) {\n return BUNDLER_RPC + zerodevProjects[chain];\n}\n","import { SmartWalletChain } from \"./chains\";\n\nconst ALCHEMY_API_KEY = \"-7M6vRDBDknwvMxnqah_jbcieWg0qad9\";\n\nexport const ALCHEMY_RPC_SUBDOMAIN: Record<SmartWalletChain, string> = {\n polygon: \"polygon-mainnet\",\n \"polygon-amoy\": \"polygon-amoy\",\n base: \"base-mainnet\",\n \"base-sepolia\": \"base-sepolia\",\n optimism: \"opt-mainnet\",\n \"optimism-sepolia\": \"opt-sepolia\",\n arbitrum: \"arb-mainnet\",\n \"arbitrum-sepolia\": \"arb-sepolia\",\n};\n\nexport function getAlchemyRPC(chain: SmartWalletChain): string {\n return `https://${ALCHEMY_RPC_SUBDOMAIN[chain]}.g.alchemy.com/v2/${ALCHEMY_API_KEY}`;\n}\n","import { CrossmintWalletService } from \"@/api/CrossmintWalletService\";\nimport { Middleware } from \"permissionless/actions/smartAccount\";\nimport { EntryPoint } from \"permissionless/types/entrypoint\";\n\nimport { UserParams } from \"../../types/params\";\nimport { usesGelatoBundler } from \"../../utils/blockchain\";\nimport { SmartWalletChain } from \"../chains\";\n\nexport function usePaymaster(chain: SmartWalletChain) {\n return !usesGelatoBundler(chain);\n}\n\nexport function paymasterMiddleware({\n entryPoint,\n chain,\n walletService,\n user,\n}: {\n entryPoint: EntryPoint;\n chain: SmartWalletChain;\n walletService: CrossmintWalletService;\n user: UserParams;\n}): Middleware<EntryPoint> {\n return {\n middleware: {\n sponsorUserOperation: async ({ userOperation }) => {\n const { sponsorUserOpParams } = await walletService.sponsorUserOperation(\n user,\n userOperation,\n entryPoint,\n chain\n );\n return sponsorUserOpParams;\n },\n },\n };\n}\n","import { BaseError, stringify } from \"viem\";\n\nimport { SDKLogger } from \"@crossmint/client-sdk-base\";\n\nimport { SmartWalletError } from \".\";\nimport { SDK_VERSION } from \"../utils/constants\";\n\nexport class ErrorProcessor {\n constructor(private readonly logger: SDKLogger) {}\n\n public map(error: unknown, fallback: SmartWalletError): SmartWalletError | BaseError {\n this.record(error);\n\n if (error instanceof SmartWalletError) {\n return error;\n }\n\n // Allow viem errors, which are generally pretty friendly.\n if (error instanceof BaseError) {\n return error;\n }\n\n return fallback;\n }\n\n private record(error: unknown) {\n const message = error instanceof Error ? error.message : String(error);\n this.logger.error(`Smart Wallet SDK Error: ${message}`, {\n stack: error instanceof Error ? error.stack : undefined,\n name: error instanceof Error ? error.name : \"UnknownError\",\n details: stringify(error),\n domain: window.location.hostname,\n sdk_version: SDK_VERSION,\n });\n }\n}\n","export function isClient() {\n return typeof window !== \"undefined\";\n}\n"],"mappings":"ubAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,2BAAAE,EAAA,uBAAAC,EAAA,2DAAAC,EAAA,+GAAAC,EAAA,0PAAAC,EAAA,yBAAAC,EAAA,uBAAAC,EAAA,6BAAAC,EAAA,qBAAAC,EAAA,mEAAAC,GAAA,gCAAAC,EAAA,oEAAAC,EAAA,gEAAAC,GAAAd,IAAA,IAAAe,GAA4E,sCCA5E,IAAAC,EAAgF,gBAEhFC,GAA8B,sCCF9B,IAAAC,EAA4C,sCCArC,IAAMC,GAAgB,UAEtB,IAAMC,EAAc,UACdC,EAAc,QACdC,EAAc,aACdC,GAAc,0CAEpB,IAAMC,GAA4B,CAAC,QAAS,QAAS,OAAO,EACtDC,GAAgC,CAAC,OAAQ,MAAM,EDJrD,IAAMC,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Y,EACvDJ,EACA,IAAIS,EAAgBnB,CAAc,CACtC,EAEA,OAAO,IAAIF,EAAeC,EAAoBC,CAAc,CAChE,CAWA,MAAM,kBACFoB,EACAC,EACAC,EAA6B,CAAE,OAAQ,CAAE,KAAM,SAAU,CAAE,EACpC,CACvB,OAAO,KAAK,OAAO,eAAe,uBAAwB,SAAY,CAClE,GAAI,CACA,OAAO,MAAM,KAAK,mBAAmB,YAAYF,EAAMC,EAAOC,CAAY,CAC9E,OAASC,EAAY,CACjB,MAAM,KAAK,eAAe,IACtBA,EACA,IAAIlB,EAAiB,2BAA2BkB,EAAM,OAAO,OAAK,cAAUA,CAAK,CAAC,CACtF,CACJ,CACJ,CAAC,CACL,CACJ","names":["src_exports","__export","AdminAlreadyUsedError","AdminMismatchError","ConfigError","EVMSmartWallet","PasskeyIncompatibleAuthenticatorError","PasskeyMismatchError","PasskeyPromptError","PasskeyRegistrationError","SmartWalletError","SmartWalletSDK","SmartWalletsNotEnabledError","UserWalletAlreadyCreatedError","__toCommonJS","import_common_sdk_base","import_viem","import_client_sdk_base","import_client_sdk_base","ZERO_DEV_TYPE","SCW_SERVICE","SDK_VERSION","API_VERSION","BUNDLER_RPC","SUPPORTED_KERNEL_VERSIONS","SUPPORTED_ENTRYPOINT_VERSIONS","scwLogger","SCW_SERVICE","scwDatadogLogger","import_viem","ERC1155_default","transferParams","contract","config","from","to","ERC1155_default","EVMSmartWallet","crossmintService","accountClient","publicClient","chain","logger","scwLogger","toAddress","config","tx","transferParams","client","request","hash","error","tokenIdString","import_client_sdk_base","SmartWalletError","message","details","code","AdminMismatchError","required","used","PasskeyMismatchError","UserWalletAlreadyCreatedError","userId","PasskeyPromptError","passkeyName","PasskeyRegistrationError","PasskeyIncompatibleAuthenticatorError","ConfigError","AdminAlreadyUsedError","SmartWalletsNotEnabledError","import_client_sdk_base","import_viem","import_common_sdk_base","import_client_sdk_base","import_common_sdk_base","import_passkey_validator","import_viem","import_zod","HexSchema","val","evmAddressSchema","EOASignerDataSchema","PasskeyValidatorSerializedDataSchema","PasskeySignerDataSchema","SignerDataSchema","SmartWalletConfigSchema","SUPPORTED_KERNEL_VERSIONS","_","ctx","SUPPORTED_ENTRYPOINT_VERSIONS","import_viem","mapObject","data","fn","result","item","key","value","bigintsToHex","parseBigintAPIResponse","CrossmintWalletService","scwLogger","userId","UserWalletAlreadyCreatedError","AdminAlreadyUsedError","SmartWalletsNotEnabledError","user","input","API_VERSION","userOp","entryPoint","chain","chainId","result","bigintsToHex","parseBigintAPIResponse","data","SmartWalletConfigSchema","address","import_viem","AccountConfigCache","keyPrefix","user","config","key","data","result","SmartWalletConfigSchema","i","PasskeySignerConfig","data","EOASignerConfig","AccountConfigService","crossmintService","configCache","user","chain","cached","config","entryPointVersion","kernelVersion","existing","signers","smartContractWalletAddress","userId","SmartWalletError","signerData","x","signer","data","EOASignerConfig","PasskeySignerConfig","isPasskeyWalletParams","params","isPasskeyCreationContext","signerIsPasskeyOrUndefined","isEOAWalletParams","isEOACreationContext","signerIsEOAOrUndefined","AccountCreator","eoaStrategy","passkeyStrategy","context","isPasskeyCreationContext","isEOACreationContext","ConfigError","display","inputSignerType","isPasskeyWalletParams","AdminMismatchError","import_ecdsa_validator","import_sdk","equalsIgnoreCase","a","b","import_permissionless","createOwnerSigner","walletParams","isEIP1193Provider","isAccount","signer","SmartWalletError","EOACreationStrategy","chain","publicClient","entryPoint","walletParams","kernelVersion","user","existing","eoa","createOwnerSigner","equalsIgnoreCase","AdminMismatchError","ecdsaValidator","EOASignerConfig","import_passkey_validator","import_sdk","import_webauthn_key","PasskeyCreationStrategy","passkeyServerUrl","apiKey","user","publicClient","walletParams","entryPoint","kernelVersion","existing","inputPasskeyName","PasskeyMismatchError","passkey","latestValidatorVersion","validatorContractVersion","validator","kernelAccount","error","passkeyName","PasskeySignerConfig","deserializePasskeyValidatorData","PasskeyIncompatibleAuthenticatorError","PasskeyRegistrationError","PasskeyPromptError","account","target","prop","receiver","original","isAccountSigningMethod","args","accountSigningMethods","method","params","uint8Array","base64ToBytes","jsonString","base64","binString","m","import_viem","usesGelatoBundler","chain","transactionMethods","signingMethods","isTxnMethod","method","isSignMethod","ClientDecorator","errorProcessor","logger","scwLogger","crossmintChain","smartAccountClient","target","prop","receiver","originalMethod","args","processed","error","description","SmartWalletError","userOperation","middleware","account","txn","txnParams","usesGelatoBundler","import_sdk","import_permissionless","import_viem","import_common_sdk_base","import_chains","import_common_sdk_base","SmartWalletTestnet","Blockchain","SMART_WALLET_TESTNETS","SmartWalletMainnet","SMART_WALLET_MAINNETS","SmartWalletChain","SMART_WALLET_CHAINS","zerodevProjects","viemNetworks","getBundlerRPC","chain","BUNDLER_RPC","ALCHEMY_API_KEY","ALCHEMY_RPC_SUBDOMAIN","getAlchemyRPC","chain","usePaymaster","chain","usesGelatoBundler","paymasterMiddleware","entryPoint","walletService","user","userOperation","sponsorUserOpParams","SmartWalletService","crossmintService","accountConfigService","accountCreator","clientDecorator","user","chain","walletParams","entryPointVersion","kernelVersion","existing","userWithId","cached","publicClient","getAlchemyRPC","account","signerConfig","ZERO_DEV_TYPE","kernelAccountClient","viemNetworks","getBundlerRPC","usePaymaster","paymasterMiddleware","smartAccountClient","EVMSmartWallet","import_viem","ErrorProcessor","logger","error","fallback","SmartWalletError","message","SDK_VERSION","isClient","SmartWalletSDK","_SmartWalletSDK","smartWalletService","errorProcessor","logger","scwLogger","clientApiKey","isClient","SmartWalletError","crossmintService","CrossmintWalletService","ErrorProcessor","scwDatadogLogger","accountCreator","AccountCreator","EOACreationStrategy","PasskeyCreationStrategy","accountCache","AccountConfigCache","SDK_VERSION","SmartWalletService","AccountConfigService","ClientDecorator","user","chain","walletParams","error"]}
|