@crossmint/client-sdk-smart-wallet 0.1.1 → 0.1.2

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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/utils/environment.ts","../src/utils/helpers.ts","../src/services/logging/ConsoleProvider.ts","../src/utils/constants.ts","../src/services/logging/DatadogProvider.ts","../src/services/logging/index.ts","../src/blockchain/wallets/EVMSmartWallet.ts","../src/error/index.ts","../src/utils/log.ts","../src/blockchain/transfer.ts","../src/ABI/ERC1155.json","../src/blockchain/chains.ts","../src/SmartWalletSDK.ts","../src/api/BaseCrossmintService.ts","../src/api/APIErrorService.ts","../src/api/CrossmintWalletService.ts","../src/utils/blockchain.ts","../src/blockchain/wallets/clientDecorator.ts","../src/types/API.ts","../src/blockchain/wallets/service.ts","../src/types/internal.ts","../src/utils/signer.ts","../src/blockchain/wallets/eoa.ts","../src/blockchain/wallets/passkey.ts","../src/blockchain/wallets/paymaster.ts","../src/error/processor.ts"],"sourcesContent":["export { blockchainToChainId } 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/Config\";\n\nexport type { TransferType, ERC20TransferType, NFTTransferType, SFTTransferType } from \"./types/Tokens\";\nexport { SmartWalletChain } from \"./blockchain/chains\";\n\nexport {\n TransferError,\n CrossmintServiceError,\n SmartWalletSDKError,\n JWTDecryptionError,\n JWTExpiredError,\n JWTIdentifierError,\n JWTInvalidError,\n NotAuthorizedError,\n UserWalletAlreadyCreatedError,\n OutOfCreditsError,\n AdminAlreadyUsedError,\n AdminMismatchError,\n PasskeyMismatchError,\n ConfigError,\n NonCustodialWalletsNotEnabledError,\n} from \"./error\";\n\nexport { SmartWalletSDK } from \"./SmartWalletSDK\";\n","export function isClient() {\n return typeof window !== \"undefined\";\n}\n","export function isLocalhost() {\n if (process.env.NODE_ENV === \"test\") {\n return false;\n }\n\n return window.location.origin.includes(\"localhost\");\n}\n\nexport 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 { BrowserLoggerInterface } from \"./BrowserLoggerInterface\";\n\n// Set to true to enable logging on local development\nconst LOG_IN_LOCALHOST = false;\n\nexport class ConsoleProvider implements BrowserLoggerInterface {\n logInfo(message: string, context?: object) {\n if (LOG_IN_LOCALHOST) {\n console.log(message, context);\n }\n }\n\n logError(message: string, context?: object) {\n if (LOG_IN_LOCALHOST) {\n console.error(message, context);\n }\n }\n\n logWarn(message: string, context?: object) {\n if (LOG_IN_LOCALHOST) {\n console.warn(message, context);\n }\n }\n}\n","export const ZERO_DEV_TYPE = \"ZeroDev\";\nexport const CURRENT_VERSION = 0;\nexport const DATADOG_CLIENT_TOKEN = \"pub035be8a594b35be1887b6ba76c4029ca\";\nexport const CROSSMINT_DEV_URL = \"http://localhost:3000/api\";\nexport const CROSSMINT_STG_URL = \"https://staging.crossmint.com/api\";\nexport const CROSSMINT_PROD_URL = \"https://www.crossmint.com/api\";\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/\";\n","import { DATADOG_CLIENT_TOKEN, SCW_SERVICE } from \"@/utils/constants\";\nimport { datadogLogs } from \"@datadog/browser-logs\";\n\nimport { BrowserLoggerInterface } from \"./BrowserLoggerInterface\";\n\nexport class DatadogProvider implements BrowserLoggerInterface {\n logInfo(message: string, context?: object) {\n log(message, \"info\", context);\n }\n\n logError(message: string, context?: object) {\n log(message, \"error\", context);\n }\n\n logWarn(message: string, context?: object) {\n log(message, \"warn\", context);\n }\n}\n\nfunction log(message: string, loggerType: \"info\" | \"error\" | \"warn\", contextParam?: object) {\n const _context = contextParam ? { ...contextParam, service: SCW_SERVICE } : { service: SCW_SERVICE };\n\n init();\n datadogLogs.logger[loggerType](message, _context);\n}\n\nfunction init() {\n const isDatadogInitialized = datadogLogs.getInternalContext() != null;\n if (isDatadogInitialized) {\n return;\n }\n\n datadogLogs.init({\n clientToken: DATADOG_CLIENT_TOKEN,\n site: \"datadoghq.com\",\n forwardErrorsToLogs: false,\n sampleRate: 100,\n });\n}\n","import { isClient } from \"../../utils/environment\";\nimport { isLocalhost } from \"../../utils/helpers\";\nimport { ConsoleProvider } from \"./ConsoleProvider\";\nimport { DatadogProvider } from \"./DatadogProvider\";\n\nfunction getBrowserLogger() {\n if (isClient() && isLocalhost()) {\n return new ConsoleProvider();\n }\n\n return new DatadogProvider();\n}\n\nconst { logInfo, logWarn, logError } = getBrowserLogger();\n\nexport { logInfo, logWarn, logError };\n","import { logError } from \"@/services/logging\";\nimport { type HttpTransport, type PublicClient, isAddress, publicActions } from \"viem\";\n\nimport type { CrossmintWalletService } from \"../../api/CrossmintWalletService\";\nimport { TransferError } from \"../../error\";\nimport type { TransferType } from \"../../types/Tokens\";\nimport { SmartWalletClient } from \"../../types/internal\";\nimport { SCW_SERVICE } from \"../../utils/constants\";\nimport { LoggerWrapper, errorToJSON } from \"../../utils/log\";\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 extends LoggerWrapper {\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 ) {\n super(\"EVMSmartWallet\", { chain, address: accountClient.account.address });\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.logPerformance(\"TRANSFER\", 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 return await client.writeContract(request);\n } catch (error) {\n logError(\"[TRANSFER] - ERROR_TRANSFERRING_TOKEN\", {\n service: SCW_SERVICE,\n error: errorToJSON(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 }\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 { PasskeyDisplay, SignerDisplay } from \"@/types/API\";\n\nexport const SmartWalletErrors = {\n NOT_AUTHORIZED: \"smart-wallet:not-authorized\",\n TRANSFER: \"smart-wallet:transfer.error\",\n CROSSMINT_SERVICE: \"smart-wallet:crossmint-service.error\",\n ERROR_JWT_EXPIRED: \"smart-wallet:not-authorized.jwt-expired\",\n ERROR_JWT_INVALID: \"smart-wallet:not-authorized.jwt-invalid\",\n ERROR_JWT_DECRYPTION: \"smart-wallet:not-authorized.jwt-decryption\",\n ERROR_JWT_IDENTIFIER: \"smart-wallet:not-authorized.jwt-identifier\",\n ERROR_USER_WALLET_ALREADY_CREATED: \"smart-wallet:user-wallet-already-created.error\",\n ERROR_OUT_OF_CREDITS: \"smart-wallet:out-of-credits.error\",\n ERROR_WALLET_CONFIG: \"smart-wallet:wallet-config.error\",\n ERROR_ADMIN_MISMATCH: \"smart-wallet:wallet-config.admin-mismatch\",\n ERROR_PASSKEY_MISMATCH: \"smart-wallet:wallet-config.passkey-mismatch\",\n ERROR_ADMIN_SIGNER_ALREADY_USED: \"smart-wallet:wallet-config.admin-signer-already-used\",\n ERROR_PROJECT_NONCUSTODIAL_WALLETS_NOT_ENABLED: \"smart-wallet:wallet-config.non-custodial-wallets-not-enabled\",\n UNCATEGORIZED: \"smart-wallet:uncategorized\", // catch-all error code\n} as const;\nexport type SmartWalletErrorCode = (typeof SmartWalletErrors)[keyof typeof SmartWalletErrors];\n\nexport class SmartWalletSDKError extends Error {\n public readonly code: SmartWalletErrorCode;\n public readonly details?: string;\n\n constructor(message: string, details?: string, code: SmartWalletErrorCode = SmartWalletErrors.UNCATEGORIZED) {\n super(message);\n this.details = details;\n this.code = code;\n }\n}\n\nexport class TransferError extends SmartWalletSDKError {\n constructor(message: string) {\n super(message, undefined, SmartWalletErrors.TRANSFER);\n }\n}\n\nexport class CrossmintServiceError extends SmartWalletSDKError {\n public status?: number;\n\n constructor(message: string, status?: number) {\n super(message, undefined, SmartWalletErrors.CROSSMINT_SERVICE);\n this.status = status;\n }\n}\n\nexport class AdminMismatchError extends SmartWalletSDKError {\n public readonly required: SignerDisplay;\n public readonly used?: SignerDisplay;\n\n constructor(message: string, required: SignerDisplay, used?: SignerDisplay) {\n super(message, SmartWalletErrors.ERROR_ADMIN_MISMATCH);\n this.required = required;\n this.used = used;\n }\n}\n\nexport class PasskeyMismatchError extends SmartWalletSDKError {\n public readonly required: PasskeyDisplay;\n public readonly used?: PasskeyDisplay;\n\n constructor(message: string, required: PasskeyDisplay, used?: PasskeyDisplay) {\n super(message, SmartWalletErrors.ERROR_PASSKEY_MISMATCH);\n this.required = required;\n this.used = used;\n }\n}\n\nexport class NotAuthorizedError extends SmartWalletSDKError {\n constructor(message: string) {\n super(message, undefined, SmartWalletErrors.NOT_AUTHORIZED);\n }\n}\n\nexport class JWTExpiredError extends NotAuthorizedError {\n public readonly code = SmartWalletErrors.ERROR_JWT_EXPIRED;\n\n /**\n * The expiry time of the JWT as an ISO 8601 timestamp.\n */\n public readonly expiredAt: string;\n\n constructor(expiredAt: Date) {\n super(`JWT provided expired at timestamp ${expiredAt}`);\n this.expiredAt = expiredAt.toISOString();\n }\n}\n\nexport class JWTInvalidError extends NotAuthorizedError {\n public readonly code = SmartWalletErrors.ERROR_JWT_INVALID;\n constructor() {\n super(\"Invalid JWT provided\");\n }\n}\n\nexport class JWTDecryptionError extends NotAuthorizedError {\n public readonly code = SmartWalletErrors.ERROR_JWT_DECRYPTION;\n constructor() {\n super(\"Error decrypting JWT\");\n }\n}\n\nexport class JWTIdentifierError extends NotAuthorizedError {\n public readonly code = SmartWalletErrors.ERROR_JWT_IDENTIFIER;\n public readonly identifierKey: string;\n\n constructor(identifierKey: string) {\n super(`Missing required identifier '${identifierKey}' in the JWT`);\n this.identifierKey = identifierKey;\n }\n}\n\nexport class UserWalletAlreadyCreatedError extends SmartWalletSDKError {\n public readonly code = SmartWalletErrors.ERROR_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 OutOfCreditsError extends SmartWalletSDKError {\n constructor(message?: string) {\n super(\n \"You've run out of Crossmint API credits. Visit https://docs.crossmint.com/docs/errors for more information\",\n undefined,\n SmartWalletErrors.ERROR_OUT_OF_CREDITS\n );\n }\n}\n\nexport class ConfigError extends SmartWalletSDKError {\n constructor(message: string) {\n super(message, undefined, SmartWalletErrors.ERROR_WALLET_CONFIG);\n }\n}\n\nexport class AdminAlreadyUsedError extends ConfigError {\n public readonly code = SmartWalletErrors.ERROR_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 NonCustodialWalletsNotEnabledError extends ConfigError {\n public readonly code = SmartWalletErrors.ERROR_PROJECT_NONCUSTODIAL_WALLETS_NOT_ENABLED;\n constructor() {\n super(\"Non-custodial wallets are not enabled for this project\");\n }\n}\n","import { v4 as uuidv4 } from \"uuid\";\n\nimport { logError, logInfo } from \"../services/logging\";\nimport { SCW_SERVICE } from \"./constants\";\nimport { isLocalhost } from \"./helpers\";\n\nexport class LoggerWrapper {\n constructor(className: string, private extraInfo = {}, private logIdempotencyKey = uuidv4()) {\n return new Proxy(this, {\n get: (target: any, propKey: PropertyKey, receiver: any) => {\n const origMethod = target[propKey];\n const identifierTag = `[${SCW_SERVICE} - ${className} - ${String(propKey)}]`;\n\n if (typeof origMethod === \"function\") {\n return (...args: any[]) => {\n this.logInput(args, identifierTag);\n\n const result = origMethod.apply(target, args);\n if (result instanceof Promise) {\n return result\n .then((res: any) => {\n this.logOutput(res, identifierTag);\n return res;\n })\n .catch((err: any) => {\n this.logError(err, identifierTag);\n throw err;\n });\n } else {\n this.logOutput(result, identifierTag);\n return result;\n }\n };\n }\n return Reflect.get(target, propKey, receiver);\n },\n });\n }\n\n private logInput(args: object, identifierTag: string) {\n logInfoIfNotInLocalhost(\n `${identifierTag} input - ${beautify(args)} - extra_info - ${beautify(\n this.extraInfo\n )} - log_idempotency_key - ${this.logIdempotencyKey}`,\n { args, ...this.extraInfo, logIdempotencyKey: this.logIdempotencyKey }\n );\n }\n\n private logOutput(res: object, identifierTag: string) {\n logInfoIfNotInLocalhost(\n `${identifierTag} output - ${beautify(res)} - extra_info - ${beautify(\n this.extraInfo\n )} - log_idempotency_key - ${this.logIdempotencyKey}`,\n {\n res,\n ...this.extraInfo,\n logIdempotencyKey: this.logIdempotencyKey,\n }\n );\n }\n\n private logError(err: object, identifierTag: string) {\n logError(\n `${identifierTag} threw_error - ${err} - extra_info - ${beautify(this.extraInfo)} - log_idempotency_key - ${\n this.logIdempotencyKey\n }`,\n { err, ...this.extraInfo }\n );\n }\n\n protected logPerformance<T>(name: string, cb: () => Promise<T>) {\n return logPerformance(name, cb, this.extraInfo);\n }\n}\n\nexport async function logPerformance<T>(name: string, cb: () => Promise<T>, extraInfo?: object) {\n const start = new Date().getTime();\n const result = await cb();\n const durationInMs = new Date().getTime() - start;\n const args = { durationInMs, ...extraInfo };\n logInfoIfNotInLocalhost(`[${SCW_SERVICE} - ${name} - TIME] - ${beautify(args)}`, { args });\n return result;\n}\n\nexport function logInputOutput<T, A extends any[]>(fn: (...args: A) => T, functionName: string): (...args: A) => T {\n return function (this: any, ...args: A): T {\n const identifierTag = `[${SCW_SERVICE} - function: ${functionName}]`;\n logInfoIfNotInLocalhost(`${identifierTag} input: ${beautify(args)}`, { args });\n\n try {\n const result = fn.apply(this, args);\n if (result instanceof Promise) {\n return result\n .then((res) => {\n logInfoIfNotInLocalhost(`${identifierTag} output: ${beautify(res)}`, { res });\n return res;\n })\n .catch((err) => {\n logError(`${identifierTag} threw_error: ${beautify(err)}`, { err });\n throw err;\n }) as T;\n } else {\n logInfoIfNotInLocalhost(`${identifierTag} output: ${beautify(result)}`, { res: result });\n return result;\n }\n } catch (err) {\n logError(`${identifierTag} threw_error: ${beautify(err)}`, { err });\n throw err;\n }\n };\n}\n\nfunction beautify(json: any) {\n try {\n return json != null ? JSON.stringify(json, null, 2) : json;\n } catch (error) {\n return stringifyAvoidingCircular(json);\n }\n}\n\nfunction stringifyAvoidingCircular(json: any) {\n // stringify an object, avoiding circular structures\n // https://stackoverflow.com/a/31557814\n const simpleObject: { [key: string]: any } = {};\n for (const prop in json) {\n if (!Object.prototype.hasOwnProperty.call(json, prop)) {\n continue;\n }\n if (typeof json[prop] == \"object\") {\n continue;\n }\n if (typeof json[prop] == \"function\") {\n continue;\n }\n simpleObject[prop] = json[prop];\n }\n return JSON.stringify(simpleObject, null, 2); // returns cleaned up JSON\n}\n\nfunction logInfoIfNotInLocalhost(message: string, context?: object) {\n if (isLocalhost()) {\n console.log(message);\n return;\n }\n logInfo(message, context);\n}\n\nexport function errorToJSON(error: Error | unknown) {\n const errorToLog = error instanceof Error ? error : { message: \"Unknown error\", name: \"Unknown error\" };\n\n if (!(errorToLog instanceof Error) && (errorToLog as any).constructor?.name !== \"SyntheticBaseEvent\") {\n logError(\"ERROR_TO_JSON_FAILED\", { error: errorToLog });\n throw new Error(\"[errorToJSON] err is not instanceof Error nor SyntheticBaseEvent\");\n }\n\n return JSON.parse(JSON.stringify(errorToLog, Object.getOwnPropertyNames(errorToLog)));\n}\n","import { Abi, Account, Address, erc20Abi, erc721Abi } from \"viem\";\n\nimport erc1155Abi from \"../ABI/ERC1155.json\";\nimport type { ERC20TransferType, SFTTransferType, TransferType } from \"../types/Tokens\";\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 { BUNDLER_RPC } from \"@/utils/constants\";\nimport { Chain, base, baseSepolia, polygon, polygonAmoy } from \"viem/chains\";\n\nimport { BlockchainIncludingTestnet as Blockchain, ObjectValues, objectValues } from \"@crossmint/common-sdk-base\";\n\nexport const SmartWalletTestnet = {\n BASE_SEPOLIA: Blockchain.BASE_SEPOLIA,\n POLYGON_AMOY: Blockchain.POLYGON_AMOY,\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} 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};\n\nexport const viemNetworks: Record<SmartWalletChain, Chain> = {\n polygon: polygon,\n \"polygon-amoy\": polygonAmoy,\n base: base,\n \"base-sepolia\": baseSepolia,\n};\n\nexport const getBundlerRPC = (chain: SmartWalletChain) => {\n return BUNDLER_RPC + zerodevProjects[chain];\n};\n","import { stringify } from \"viem\";\n\nimport { validateAPIKey } from \"@crossmint/common-sdk-base\";\n\nimport { CrossmintWalletService } from \"./api/CrossmintWalletService\";\nimport { SmartWalletChain } from \"./blockchain/chains\";\nimport type { EVMSmartWallet } from \"./blockchain/wallets\";\nimport { ClientDecorator } from \"./blockchain/wallets/clientDecorator\";\nimport { SmartWalletService } from \"./blockchain/wallets/service\";\nimport { SmartWalletSDKError } from \"./error\";\nimport { ErrorProcessor } from \"./error/processor\";\nimport { DatadogProvider } from \"./services/logging/DatadogProvider\";\nimport type { SmartWalletSDKInitParams, UserParams, WalletParams } from \"./types/Config\";\nimport { isClient } from \"./utils/environment\";\nimport { LoggerWrapper, logPerformance } from \"./utils/log\";\n\nexport class SmartWalletSDK extends LoggerWrapper {\n private constructor(\n private readonly smartWalletService: SmartWalletService,\n private readonly errorProcessor: ErrorProcessor\n ) {\n super(\"SmartWalletSDK\");\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 SmartWalletSDKError(\"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(new DatadogProvider());\n return new SmartWalletSDK(\n new SmartWalletService(crossmintService, new ClientDecorator(errorProcessor)),\n errorProcessor\n );\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 logPerformance(\n \"GET_OR_CREATE_WALLET\",\n 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 SmartWalletSDKError(`Wallet creation failed: ${error.message}.`, stringify(error))\n );\n }\n },\n { user, chain }\n );\n }\n}\n","import { validateAPIKey } from \"@crossmint/common-sdk-base\";\n\nimport { CrossmintServiceError } from \"../error\";\nimport { CROSSMINT_DEV_URL, CROSSMINT_PROD_URL, CROSSMINT_STG_URL } from \"../utils/constants\";\nimport { LoggerWrapper, logPerformance } from \"../utils/log\";\nimport { APIErrorService } from \"./APIErrorService\";\n\nexport abstract class BaseCrossmintService extends LoggerWrapper {\n public crossmintAPIHeaders: Record<string, string>;\n protected crossmintBaseUrl: string;\n protected apiErrorService: APIErrorService;\n private static urlMap: Record<string, string> = {\n development: CROSSMINT_DEV_URL,\n staging: CROSSMINT_STG_URL,\n production: CROSSMINT_PROD_URL,\n };\n\n constructor(apiKey: string) {\n super(\"BaseCrossmintService\");\n const result = validateAPIKey(apiKey);\n if (!result.isValid) {\n throw new Error(\"API key invalid\");\n }\n this.crossmintAPIHeaders = {\n accept: \"application/json\",\n \"content-type\": \"application/json\",\n \"x-api-key\": apiKey,\n };\n this.crossmintBaseUrl = this.getUrlFromEnv(result.environment);\n this.apiErrorService = new APIErrorService();\n }\n\n protected async fetchCrossmintAPI(\n endpoint: string,\n options: { body?: string; method: string } = { method: \"GET\" },\n onServerErrorMessage: string,\n authToken?: string\n ) {\n return logPerformance(\n \"FETCH_CROSSMINT_API\",\n async () => {\n const url = `${this.crossmintBaseUrl}/${endpoint}`;\n const { body, method } = options;\n\n let response: Response;\n try {\n response = await fetch(url, {\n body,\n method,\n headers: {\n ...this.crossmintAPIHeaders,\n ...(authToken != null && {\n Authorization: `Bearer ${authToken}`,\n }),\n },\n });\n } catch (error) {\n throw new CrossmintServiceError(`Error fetching Crossmint API: ${error}`);\n }\n\n if (!response.ok) {\n await this.apiErrorService.throwErrorFromResponse({\n response,\n onServerErrorMessage,\n });\n }\n\n return await response.json();\n },\n { endpoint }\n );\n }\n\n protected getUrlFromEnv(environment: string) {\n const url = BaseCrossmintService.urlMap[environment];\n if (!url) {\n console.log(\" CrossmintService.urlMap: \", BaseCrossmintService.urlMap);\n throw new Error(`URL not found for environment: ${environment}`);\n }\n return url;\n }\n}\n","import {\n AdminAlreadyUsedError,\n CrossmintServiceError,\n JWTDecryptionError,\n JWTExpiredError,\n JWTIdentifierError,\n JWTInvalidError,\n NonCustodialWalletsNotEnabledError,\n OutOfCreditsError,\n SmartWalletSDKError,\n UserWalletAlreadyCreatedError,\n} from \"@/error\";\n\nexport type CrossmintAPIErrorCodes =\n | \"ERROR_JWT_INVALID\"\n | \"ERROR_JWT_DECRYPTION\"\n | \"ERROR_JWT_IDENTIFIER\"\n | \"ERROR_JWT_EXPIRED\"\n | \"ERROR_USER_WALLET_ALREADY_CREATED\"\n | \"ERROR_ADMIN_SIGNER_ALREADY_USED\"\n | \"ERROR_PROJECT_NONCUSTODIAL_WALLETS_NOT_ENABLED\";\n\nexport class APIErrorService {\n constructor(\n private errors: Partial<Record<CrossmintAPIErrorCodes, (apiResponse: any) => SmartWalletSDKError>> = {\n ERROR_JWT_INVALID: () => new JWTInvalidError(),\n ERROR_JWT_DECRYPTION: () => new JWTDecryptionError(),\n ERROR_JWT_EXPIRED: ({ expiredAt }: { expiredAt: string }) => new JWTExpiredError(new Date(expiredAt)),\n ERROR_JWT_IDENTIFIER: ({ identifierKey }: { identifierKey: string }) =>\n new JWTIdentifierError(identifierKey),\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 NonCustodialWalletsNotEnabledError(),\n }\n ) {}\n\n async throwErrorFromResponse({\n response,\n onServerErrorMessage,\n }: {\n response: Response;\n onServerErrorMessage: string;\n }) {\n if (response.ok) {\n return;\n }\n\n if (response.status >= 500) {\n throw new CrossmintServiceError(onServerErrorMessage, response.status);\n }\n\n if (response.status === 402) {\n throw new OutOfCreditsError();\n }\n\n try {\n const body = await response.json();\n const code = body.code as CrossmintAPIErrorCodes | undefined;\n if (code != null && this.errors[code] != null) {\n throw this.errors[code](body);\n }\n if (body.message != null) {\n throw new CrossmintServiceError(body.message, response.status);\n }\n } catch (e) {\n if (e instanceof SmartWalletSDKError) {\n throw e;\n }\n console.error(\"Error parsing response\", e);\n }\n\n throw new CrossmintServiceError(await response.text(), response.status);\n }\n}\n","import { SmartWalletChain } from \"@/blockchain/chains\";\nimport { SignerData, StoreSmartWalletParams } from \"@/types/API\";\nimport type { UserParams } from \"@/types/Config\";\nimport { API_VERSION } from \"@/utils/constants\";\n\nimport { BaseCrossmintService } from \"./BaseCrossmintService\";\n\nexport class CrossmintWalletService extends BaseCrossmintService {\n async idempotentCreateSmartWallet(user: UserParams, input: StoreSmartWalletParams) {\n return 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 getSmartWalletConfig(\n user: UserParams,\n chain: SmartWalletChain\n ): Promise<{\n kernelVersion: string;\n entryPointVersion: string;\n userId: string;\n signers: { signerData: SignerData }[];\n smartContractWalletAddress?: string;\n }> {\n return 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\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 { SmartWalletChain } from \"..\";\n\nexport function usesGelatoBundler(chain: SmartWalletChain) {\n return false;\n}\n","import { SmartWalletSDKError } from \"@/error\";\nimport { ErrorProcessor } from \"@/error/processor\";\nimport { logInfo } from \"@/services/logging\";\nimport { usesGelatoBundler } from \"@/utils/blockchain\";\nimport { logPerformance } from \"@/utils/log\";\nimport type { SmartAccountClient } from \"permissionless\";\nimport type { EntryPoint } from \"permissionless/types/entrypoint\";\nimport { stringify } from \"viem\";\n\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) {}\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 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 logInfo(`[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 SmartWalletSDKError(`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 { PasskeyValidatorContractVersion } from \"@zerodev/passkey-validator\";\n\nimport { PasskeyValidatorSerializedData, SupportedEntryPointVersion, SupportedKernelVersion } from \"./internal\";\n\nexport type StoreSmartWalletParams = {\n type: string;\n smartContractWalletAddress: string;\n signerData: SignerData;\n sessionKeySignerAddress?: string;\n version: number;\n baseLayer: string;\n chainId: number;\n entryPointVersion: SupportedEntryPointVersion;\n kernelVersion: SupportedKernelVersion;\n};\n\nexport type SignerData = EOASignerData | PasskeySignerData;\n\nexport interface EOASignerData {\n eoaAddress: string;\n type: \"eoa\";\n}\n\nexport type PasskeySignerData = PasskeyValidatorSerializedData & {\n passkeyName: string;\n validatorContractVersion: PasskeyValidatorContractVersion;\n domain: string;\n type: \"passkeys\";\n};\n\nexport type PasskeyDisplay = Pick<PasskeySignerData, \"type\" | \"passkeyName\" | \"pubKeyX\" | \"pubKeyY\">;\nexport type SignerDisplay = EOASignerData | PasskeyDisplay;\nexport function displayPasskey(data: PasskeySignerData): PasskeyDisplay {\n return {\n pubKeyX: data.pubKeyX,\n pubKeyY: data.pubKeyY,\n passkeyName: data.passkeyName,\n type: \"passkeys\",\n };\n}\n","import { type SignerData, displayPasskey } from \"@/types/API\";\nimport { equalsIgnoreCase } from \"@/utils/helpers\";\nimport { type KernelSmartAccount, createKernelAccountClient } from \"@zerodev/sdk\";\nimport { ENTRYPOINT_ADDRESS_V06, ENTRYPOINT_ADDRESS_V07 } from \"permissionless\";\nimport type { EntryPoint } from \"permissionless/types/entrypoint\";\nimport { Address, type HttpTransport, createPublicClient, getAddress, http } from \"viem\";\n\nimport { blockchainToChainId } from \"@crossmint/common-sdk-base\";\n\nimport type { CrossmintWalletService } from \"../../api/CrossmintWalletService\";\nimport {\n AdminMismatchError,\n CrossmintServiceError,\n SmartWalletSDKError,\n UserWalletAlreadyCreatedError,\n} from \"../../error\";\nimport type { EntryPointDetails, UserParams, WalletParams } from \"../../types/Config\";\nimport {\n SUPPORTED_ENTRYPOINT_VERSIONS,\n SUPPORTED_KERNEL_VERSIONS,\n SmartWalletClient,\n type SupportedKernelVersion,\n type WalletCreationParams,\n isSupportedEntryPointVersion,\n isSupportedKernelVersion,\n} from \"../../types/internal\";\nimport { CURRENT_VERSION, ZERO_DEV_TYPE } from \"../../utils/constants\";\nimport { SmartWalletChain, getBundlerRPC, viemNetworks } from \"../chains\";\nimport { EVMSmartWallet } from \"./EVMSmartWallet\";\nimport { ClientDecorator } from \"./clientDecorator\";\nimport { EOAAccountService, type EOAWalletParams } from \"./eoa\";\nimport { PasskeyAccountService, isPasskeyParams } from \"./passkey\";\nimport { paymasterMiddleware, usePaymaster } from \"./paymaster\";\n\nexport class SmartWalletService {\n constructor(\n private readonly crossmintWalletService: CrossmintWalletService,\n private readonly clientDecorator: ClientDecorator,\n private readonly accountFactory = new AccountFactory(\n new EOAAccountService(),\n new PasskeyAccountService(crossmintWalletService)\n )\n ) {}\n\n public async getOrCreate(\n user: UserParams,\n chain: SmartWalletChain,\n walletParams: WalletParams\n ): Promise<EVMSmartWallet> {\n const { entryPoint, kernelVersion, existingSignerConfig, smartContractWalletAddress, userId } =\n await this.fetchConfig(user, chain);\n const publicClient = createPublicClient({ transport: http(getBundlerRPC(chain)) });\n\n const { account, signerData } = await this.accountFactory.get(\n {\n chain,\n walletParams,\n publicClient,\n user: { ...user, id: userId },\n entryPoint,\n kernelVersion,\n },\n existingSignerConfig\n );\n\n if (smartContractWalletAddress != null && !equalsIgnoreCase(smartContractWalletAddress, account.address)) {\n throw new UserWalletAlreadyCreatedError(userId);\n }\n\n if (existingSignerConfig == null) {\n await this.crossmintWalletService.idempotentCreateSmartWallet(user, {\n type: ZERO_DEV_TYPE,\n smartContractWalletAddress: account.address,\n signerData: signerData,\n version: CURRENT_VERSION,\n baseLayer: \"evm\",\n chainId: blockchainToChainId(chain),\n entryPointVersion: entryPoint.version,\n kernelVersion,\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) && paymasterMiddleware({ entryPoint: account.entryPoint, chain })),\n });\n\n const smartAccountClient = this.clientDecorator.decorate({\n crossmintChain: chain,\n smartAccountClient: kernelAccountClient,\n });\n\n return new EVMSmartWallet(this.crossmintWalletService, smartAccountClient, publicClient, chain);\n }\n\n private async fetchConfig(\n user: UserParams,\n chain: SmartWalletChain\n ): Promise<{\n entryPoint: EntryPointDetails;\n kernelVersion: SupportedKernelVersion;\n userId: string;\n existingSignerConfig?: SignerData;\n smartContractWalletAddress?: Address;\n }> {\n const { entryPointVersion, kernelVersion, signers, smartContractWalletAddress, userId } =\n await this.crossmintWalletService.getSmartWalletConfig(user, chain);\n\n if (!isSupportedKernelVersion(kernelVersion)) {\n throw new SmartWalletSDKError(\n `Unsupported kernel version. Supported versions: ${SUPPORTED_KERNEL_VERSIONS.join(\n \", \"\n )}. Version used: ${kernelVersion}, Please contact support`\n );\n }\n\n if (!isSupportedEntryPointVersion(entryPointVersion)) {\n throw new SmartWalletSDKError(\n `Unsupported entry point version. Supported versions: ${SUPPORTED_ENTRYPOINT_VERSIONS.join(\n \", \"\n )}. Version used: ${entryPointVersion}. Please contact support`\n );\n }\n\n if (\n (entryPointVersion === \"v0.7\" && kernelVersion.startsWith(\"0.2\")) ||\n (entryPointVersion === \"v0.6\" && kernelVersion.startsWith(\"0.3\"))\n ) {\n throw new SmartWalletSDKError(\n `Unsupported combination: entryPoint ${entryPointVersion} and kernel version ${kernelVersion}. Please contact support`\n );\n }\n\n return {\n entryPoint: {\n version: entryPointVersion,\n address: entryPointVersion === \"v0.6\" ? ENTRYPOINT_ADDRESS_V06 : ENTRYPOINT_ADDRESS_V07,\n },\n kernelVersion,\n userId,\n existingSignerConfig: this.getSigner(signers),\n smartContractWalletAddress:\n smartContractWalletAddress != null ? getAddress(smartContractWalletAddress) : undefined,\n };\n }\n\n private getSigner(signers: any[]): SignerData | undefined {\n if (signers.length === 0) {\n return undefined;\n }\n\n if (signers.length > 1) {\n throw new CrossmintServiceError(\"Invalid wallet signer configuration. Please contact support\");\n }\n\n return signers[0].signerData;\n }\n}\n\nclass AccountFactory {\n constructor(private readonly eoa: EOAAccountService, private readonly passkey: PasskeyAccountService) {}\n\n public get(\n params: WalletCreationParams,\n existingSignerConfig?: SignerData\n ): Promise<{\n signerData: SignerData;\n account: KernelSmartAccount<EntryPoint, HttpTransport>;\n }> {\n if (isPasskeyParams(params)) {\n if (existingSignerConfig != null && existingSignerConfig?.type !== \"passkeys\") {\n throw new AdminMismatchError(\n `Cannot create wallet with passkey signer for user '${params.user.id}', they have an existing wallet with eoa signer '${existingSignerConfig.eoaAddress}.'`,\n existingSignerConfig\n );\n }\n\n return this.passkey.get(params, existingSignerConfig);\n }\n\n if (existingSignerConfig != null && existingSignerConfig?.type !== \"eoa\") {\n throw new AdminMismatchError(\n `Cannot create wallet with eoa signer for user '${params.user.id}', they already have a wallet with a passkey named '${existingSignerConfig.passkeyName}' as it's signer.`,\n displayPasskey(existingSignerConfig)\n );\n }\n\n return this.eoa.get(params as EOAWalletParams, existingSignerConfig);\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 { Chain, Hex, HttpTransport, PublicClient } from \"viem\";\n\nimport { SmartWalletChain } from \"..\";\nimport type { SignerData } from \"./API\";\nimport type { EntryPointDetails, UserParams, WalletParams } from \"./Config\";\n\nexport const SUPPORTED_KERNEL_VERSIONS = [\"0.3.1\", \"0.3.0\", \"0.2.4\"] as const;\nexport type SupportedKernelVersion = (typeof SUPPORTED_KERNEL_VERSIONS)[number];\n\nexport function isSupportedKernelVersion(version: string): version is SupportedKernelVersion {\n return SUPPORTED_KERNEL_VERSIONS.includes(version as any);\n}\n\nexport const SUPPORTED_ENTRYPOINT_VERSIONS = [\"v0.6\", \"v0.7\"] as const;\nexport type SupportedEntryPointVersion = (typeof SUPPORTED_ENTRYPOINT_VERSIONS)[number];\n\nexport function isSupportedEntryPointVersion(version: string): version is SupportedEntryPointVersion {\n return SUPPORTED_ENTRYPOINT_VERSIONS.includes(version as any);\n}\n\nexport interface WalletCreationParams {\n user: UserParams & { id: string };\n chain: SmartWalletChain;\n publicClient: PublicClient<HttpTransport>;\n walletParams: WalletParams;\n entryPoint: EntryPointDetails;\n kernelVersion: SupportedKernelVersion;\n}\n\nexport interface AccountAndSigner {\n account: KernelSmartAccount<EntryPoint, HttpTransport>;\n signerData: SignerData;\n}\n\nexport type PasskeyValidatorSerializedData = {\n passkeyServerUrl: string;\n entryPoint: Hex;\n validatorAddress: Hex;\n pubKeyX: string;\n pubKeyY: string;\n authenticatorIdHash: Hex;\n authenticatorId: string;\n};\n\nexport type SmartWalletClient = SmartAccountClient<EntryPoint, HttpTransport, Chain, SmartAccount<EntryPoint>>;\n","import { providerToSmartAccountSigner } from \"permissionless\";\nimport type { SmartAccountSigner } from \"permissionless/accounts\";\nimport { Address, EIP1193Provider } from \"viem\";\n\nimport { SmartWalletChain } from \"..\";\nimport { SmartWalletSDKError } from \"../error\";\nimport { ViemAccount, WalletParams } from \"../types/Config\";\nimport { logInputOutput } from \"./log\";\n\ntype CreateOwnerSignerInput = {\n chain: SmartWalletChain;\n walletParams: WalletParams;\n};\n\nexport const createOwnerSigner = logInputOutput(\n async ({ walletParams }: 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 SmartWalletSDKError(`The signer type ${signer.type} is not supported`);\n }\n },\n \"createOwnerSigner\"\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 { EOASignerData } from \"@/types/API\";\nimport type { EOASigner, WalletParams } from \"@/types/Config\";\nimport { AccountAndSigner, WalletCreationParams } from \"@/types/internal\";\nimport { equalsIgnoreCase } from \"@/utils/helpers\";\nimport { createOwnerSigner } from \"@/utils/signer\";\nimport { signerToEcdsaValidator } from \"@zerodev/ecdsa-validator\";\nimport { createKernelAccount } from \"@zerodev/sdk\";\n\nimport { AdminMismatchError } from \"../../error\";\n\nexport interface EOAWalletParams extends WalletCreationParams {\n walletParams: WalletParams & { signer: EOASigner };\n}\n\nexport class EOAAccountService {\n public async get(\n { chain, publicClient, entryPoint, walletParams, kernelVersion, user }: EOAWalletParams,\n existingSignerConfig?: EOASignerData\n ): Promise<AccountAndSigner> {\n const eoa = await createOwnerSigner({\n chain,\n walletParams,\n });\n\n if (existingSignerConfig != null && !equalsIgnoreCase(eoa.address, existingSignerConfig.eoaAddress)) {\n throw new AdminMismatchError(\n `User '${user.id}' has an existing wallet with an eoa signer '${existingSignerConfig.eoaAddress}', this does not match input eoa signer '${eoa.address}'.`,\n existingSignerConfig,\n { type: \"eoa\", eoaAddress: existingSignerConfig.eoaAddress }\n );\n }\n\n const ecdsaValidator = await signerToEcdsaValidator(publicClient, {\n signer: eoa,\n entryPoint: entryPoint.address,\n kernelVersion,\n });\n const account = await createKernelAccount(publicClient, {\n plugins: {\n sudo: ecdsaValidator,\n },\n index: BigInt(0),\n entryPoint: entryPoint.address,\n kernelVersion,\n });\n\n return { account, signerData: { eoaAddress: eoa.address, type: \"eoa\" } };\n }\n}\n","import type { CrossmintWalletService } from \"@/api/CrossmintWalletService\";\nimport { type PasskeySignerData, displayPasskey } from \"@/types/API\";\nimport type { PasskeySigner, UserParams, WalletParams } from \"@/types/Config\";\nimport type { AccountAndSigner, PasskeyValidatorSerializedData, WalletCreationParams } from \"@/types/internal\";\nimport { PasskeyValidatorContractVersion, WebAuthnMode, toPasskeyValidator } from \"@zerodev/passkey-validator\";\nimport { type KernelValidator, createKernelAccount } from \"@zerodev/sdk\";\nimport { WebAuthnKey, toWebAuthnKey } from \"@zerodev/webauthn-key\";\nimport type { EntryPoint } from \"permissionless/types/entrypoint\";\n\nimport { PasskeyMismatchError } from \"../../error\";\n\nexport interface PasskeyWalletParams extends WalletCreationParams {\n walletParams: WalletParams & { signer: PasskeySigner };\n}\n\nexport function isPasskeyParams(params: WalletCreationParams): params is PasskeyWalletParams {\n return (params.walletParams.signer as PasskeySigner).type === \"PASSKEY\";\n}\n\ntype PasskeyValidator = KernelValidator<EntryPoint, \"WebAuthnValidator\"> & {\n getSerializedData: () => string;\n};\n\nexport class PasskeyAccountService {\n constructor(private readonly crossmintService: CrossmintWalletService) {}\n\n public async get(\n { user, publicClient, walletParams, entryPoint, kernelVersion }: PasskeyWalletParams,\n existingSignerConfig?: PasskeySignerData\n ): Promise<AccountAndSigner> {\n const inputPasskeyName = walletParams.signer.passkeyName ?? user.id;\n if (existingSignerConfig != null && existingSignerConfig.passkeyName !== inputPasskeyName) {\n throw new PasskeyMismatchError(\n `User '${user.id}' has an existing wallet created with a passkey named '${existingSignerConfig.passkeyName}', this does match input passkey name '${inputPasskeyName}'.`,\n displayPasskey(existingSignerConfig)\n );\n }\n\n const passkey = await this.getPasskey(user, inputPasskeyName, existingSignerConfig);\n\n const latestValidatorVersion = PasskeyValidatorContractVersion.V0_0_2;\n const validatorContractVersion =\n existingSignerConfig == null ? latestValidatorVersion : existingSignerConfig.validatorContractVersion;\n const validator = await toPasskeyValidator(publicClient, {\n webAuthnKey: passkey,\n entryPoint: entryPoint.address,\n validatorContractVersion,\n kernelVersion,\n });\n\n const kernelAccount = await createKernelAccount(publicClient, {\n plugins: { sudo: validator },\n entryPoint: entryPoint.address,\n kernelVersion,\n });\n\n return {\n signerData: this.getSignerData(validator, validatorContractVersion, inputPasskeyName),\n account: kernelAccount,\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.crossmintService.getPasskeyServerUrl(),\n mode: WebAuthnMode.Register,\n passkeyServerHeaders: this.createPasskeysServerHeaders(user),\n });\n }\n\n private getSignerData(\n validator: PasskeyValidator,\n validatorContractVersion: PasskeyValidatorContractVersion,\n passkeyName: string\n ): PasskeySignerData {\n return {\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.crossmintService.crossmintAPIHeaders[\"x-api-key\"],\n Authorization: `Bearer ${user.jwt}`,\n };\n }\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 { PAYMASTER_RPC } from \"@/utils/constants\";\nimport { createZeroDevPaymasterClient } from \"@zerodev/sdk\";\nimport { Middleware } from \"permissionless/actions/smartAccount\";\nimport { EntryPoint } from \"permissionless/types/entrypoint\";\nimport { http } from \"viem\";\n\nimport { usesGelatoBundler } from \"../../utils/blockchain\";\nimport { SmartWalletChain, viemNetworks, zerodevProjects } from \"../chains\";\n\nexport function usePaymaster(chain: SmartWalletChain) {\n return !usesGelatoBundler(chain);\n}\n\nconst getPaymasterRPC = (chain: SmartWalletChain) => {\n return PAYMASTER_RPC + zerodevProjects[chain];\n};\n\nexport function paymasterMiddleware({\n entryPoint,\n chain,\n}: {\n entryPoint: EntryPoint;\n chain: SmartWalletChain;\n}): Middleware<EntryPoint> {\n return {\n middleware: {\n sponsorUserOperation: async ({ userOperation }) => {\n const paymasterClient = createZeroDevPaymasterClient({\n chain: viemNetworks[chain],\n transport: http(getPaymasterRPC(chain)),\n entryPoint,\n });\n return paymasterClient.sponsorUserOperation({\n userOperation,\n entryPoint,\n });\n },\n },\n };\n}\n","import { logError } from \"@/services/logging\";\nimport { DatadogProvider } from \"@/services/logging/DatadogProvider\";\nimport { SDK_VERSION } from \"@/utils/constants\";\nimport { BaseError, stringify } from \"viem\";\n\nimport { SmartWalletSDKError } from \".\";\n\nexport class ErrorProcessor {\n constructor(private readonly logger: DatadogProvider) {}\n\n public map(error: unknown, fallback: SmartWalletSDKError): SmartWalletSDKError | BaseError {\n this.record(error);\n\n if (error instanceof SmartWalletSDKError) {\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.logError(`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"],"mappings":"w+BAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,2BAAAE,EAAA,uBAAAC,EAAA,gBAAAC,EAAA,0BAAAC,EAAA,mBAAAC,EAAA,uBAAAC,EAAA,oBAAAC,EAAA,uBAAAC,EAAA,oBAAAC,EAAA,uCAAAC,EAAA,uBAAAC,EAAA,sBAAAC,EAAA,yBAAAC,EAAA,qBAAAC,GAAA,mBAAAC,GAAA,wBAAAC,EAAA,kBAAAC,EAAA,kCAAAC,EAAA,gEAAAC,GAAApB,IAAA,IAAAqB,GAAoC,sCCA7B,SAASC,GAAW,CACvB,OAAO,OAAO,QAAW,WAC7B,CCFO,SAASC,GAAc,CAC1B,OAAI,QAAQ,IAAI,WAAa,OAClB,GAGJ,OAAO,SAAS,OAAO,SAAS,WAAW,CACtD,CAMO,SAASC,EAAiBC,EAAYC,EAAqB,CAC9D,OAAOD,GAAA,YAAAA,EAAG,kBAAkBC,GA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CACE,MAAM,gBAAgB,EAHL,wBAAAD,EACA,oBAAAC,CAGrB,CAMA,OAAO,KAAK,CAAE,aAAAC,CAAa,EAA6C,CACpE,GAAI,CAACC,EAAS,EACV,MAAM,IAAIC,EAAoB,mDAAmD,EAIrF,GAAI,IADqB,mBAAeF,CAAY,EAC9B,QAClB,MAAM,IAAI,MAAM,iBAAiB,EAGrC,IAAMG,EAAmB,IAAIC,GAAuBJ,CAAY,EAC1DD,EAAiB,IAAIM,GAAe,IAAIC,CAAiB,EAC/D,OAAO,IAAIV,EACP,IAAIW,GAAmBJ,EAAkB,IAAIK,GAAgBT,CAAc,CAAC,EAC5EA,CACJ,CACJ,CAWM,kBACFU,EACAC,EAEuB,QAAAC,EAAA,yBAHvBC,EACAC,EACAC,EAA6B,CAAE,OAAQ,CAAE,KAAM,SAAU,CAAE,EACpC,CACvB,OAAOC,EACH,uBACA,IAAYJ,EAAA,sBACR,GAAI,CACA,OAAO,MAAM,KAAK,mBAAmB,YAAYC,EAAMC,EAAOC,CAAY,CAC9E,OAASE,EAAY,CACjB,MAAM,KAAK,eAAe,IACtBA,EACA,IAAId,EAAoB,2BAA2Bc,EAAM,OAAO,OAAK,cAAUA,CAAK,CAAC,CACzF,CACJ,CACJ,GACA,CAAE,KAAAJ,EAAM,MAAAC,CAAM,CAClB,CACJ,GACJ","names":["src_exports","__export","AdminAlreadyUsedError","AdminMismatchError","ConfigError","CrossmintServiceError","EVMSmartWallet","JWTDecryptionError","JWTExpiredError","JWTIdentifierError","JWTInvalidError","NonCustodialWalletsNotEnabledError","NotAuthorizedError","OutOfCreditsError","PasskeyMismatchError","SmartWalletChain","SmartWalletSDK","SmartWalletSDKError","TransferError","UserWalletAlreadyCreatedError","__toCommonJS","import_common_sdk_base","isClient","isLocalhost","equalsIgnoreCase","a","b","LOG_IN_LOCALHOST","ConsoleProvider","message","context","ZERO_DEV_TYPE","DATADOG_CLIENT_TOKEN","CROSSMINT_DEV_URL","CROSSMINT_STG_URL","CROSSMINT_PROD_URL","SCW_SERVICE","SDK_VERSION","API_VERSION","BUNDLER_RPC","PAYMASTER_RPC","import_browser_logs","DatadogProvider","message","context","log","loggerType","contextParam","_context","__spreadProps","__spreadValues","SCW_SERVICE","init","DATADOG_CLIENT_TOKEN","getBrowserLogger","isClient","isLocalhost","ConsoleProvider","DatadogProvider","logInfo","logWarn","logError","import_viem","SmartWalletErrors","SmartWalletSDKError","message","details","code","TransferError","CrossmintServiceError","status","AdminMismatchError","required","used","PasskeyMismatchError","NotAuthorizedError","JWTExpiredError","expiredAt","JWTInvalidError","JWTDecryptionError","JWTIdentifierError","identifierKey","UserWalletAlreadyCreatedError","userId","OutOfCreditsError","ConfigError","AdminAlreadyUsedError","NonCustodialWalletsNotEnabledError","import_uuid","LoggerWrapper","className","extraInfo","logIdempotencyKey","uuidv4","target","propKey","receiver","origMethod","identifierTag","SCW_SERVICE","args","result","res","err","logInfoIfNotInLocalhost","beautify","__spreadProps","__spreadValues","logError","name","cb","logPerformance","__async","start","durationInMs","logInputOutput","fn","functionName","json","error","stringifyAvoidingCircular","simpleObject","prop","message","context","isLocalhost","logInfo","errorToJSON","_a","errorToLog","import_viem","ERC1155_default","transferParams","contract","config","from","to","ERC1155_default","EVMSmartWallet","LoggerWrapper","crossmintService","accountClient","publicClient","chain","toAddress","config","__async","tx","transferParams","client","request","error","logError","SCW_SERVICE","errorToJSON","tokenIdString","TransferError","import_chains","import_common_sdk_base","SmartWalletTestnet","Blockchain","SMART_WALLET_TESTNETS","SmartWalletMainnet","SMART_WALLET_MAINNETS","SmartWalletChain","__spreadValues","SMART_WALLET_CHAINS","zerodevProjects","viemNetworks","getBundlerRPC","chain","BUNDLER_RPC","import_viem","import_common_sdk_base","import_common_sdk_base","APIErrorService","errors","JWTInvalidError","JWTDecryptionError","expiredAt","JWTExpiredError","identifierKey","JWTIdentifierError","userId","UserWalletAlreadyCreatedError","AdminAlreadyUsedError","NonCustodialWalletsNotEnabledError","_0","__async","response","onServerErrorMessage","CrossmintServiceError","OutOfCreditsError","body","code","e","SmartWalletSDKError","_BaseCrossmintService","LoggerWrapper","apiKey","result","APIErrorService","_0","__async","endpoint","options","onServerErrorMessage","authToken","logPerformance","url","body","method","response","__spreadValues","error","CrossmintServiceError","environment","CROSSMINT_DEV_URL","CROSSMINT_STG_URL","CROSSMINT_PROD_URL","BaseCrossmintService","CrossmintWalletService","BaseCrossmintService","user","input","__async","API_VERSION","chain","address","usesGelatoBundler","chain","import_viem","transactionMethods","signingMethods","isTxnMethod","method","isSignMethod","ClientDecorator","errorProcessor","crossmintChain","smartAccountClient","target","prop","receiver","originalMethod","args","logPerformance","__async","logInfo","processed","error","description","SmartWalletSDKError","userOperation","middleware","account","txn","txnParams","usesGelatoBundler","__spreadProps","__spreadValues","displayPasskey","data","import_sdk","import_permissionless","import_viem","import_common_sdk_base","SUPPORTED_KERNEL_VERSIONS","isSupportedKernelVersion","version","SUPPORTED_ENTRYPOINT_VERSIONS","isSupportedEntryPointVersion","import_permissionless","createOwnerSigner","logInputOutput","_0","__async","walletParams","isEIP1193Provider","isAccount","signer","SmartWalletSDKError","import_ecdsa_validator","import_sdk","EOAAccountService","_0","_1","__async","chain","publicClient","entryPoint","walletParams","kernelVersion","user","existingSignerConfig","eoa","createOwnerSigner","equalsIgnoreCase","AdminMismatchError","ecdsaValidator","import_passkey_validator","import_sdk","import_webauthn_key","isPasskeyParams","params","PasskeyAccountService","crossmintService","_0","_1","__async","user","publicClient","walletParams","entryPoint","kernelVersion","existingSignerConfig","_a","inputPasskeyName","PasskeyMismatchError","displayPasskey","passkey","latestValidatorVersion","validatorContractVersion","validator","kernelAccount","passkeyName","existing","__spreadProps","__spreadValues","deserializePasskeyValidatorData","uint8Array","base64ToBytes","jsonString","base64","binString","m","import_sdk","import_viem","usePaymaster","chain","usesGelatoBundler","getPaymasterRPC","PAYMASTER_RPC","zerodevProjects","paymasterMiddleware","entryPoint","_0","__async","userOperation","viemNetworks","SmartWalletService","crossmintWalletService","clientDecorator","accountFactory","AccountFactory","EOAAccountService","PasskeyAccountService","user","chain","walletParams","__async","entryPoint","kernelVersion","existingSignerConfig","smartContractWalletAddress","userId","publicClient","getBundlerRPC","account","signerData","__spreadProps","__spreadValues","equalsIgnoreCase","UserWalletAlreadyCreatedError","ZERO_DEV_TYPE","kernelAccountClient","viemNetworks","usePaymaster","paymasterMiddleware","smartAccountClient","EVMSmartWallet","entryPointVersion","signers","isSupportedKernelVersion","SmartWalletSDKError","SUPPORTED_KERNEL_VERSIONS","isSupportedEntryPointVersion","SUPPORTED_ENTRYPOINT_VERSIONS","CrossmintServiceError","eoa","passkey","params","isPasskeyParams","AdminMismatchError","displayPasskey","import_viem","ErrorProcessor","logger","error","fallback","SmartWalletSDKError","message","SDK_VERSION","SmartWalletSDK","_SmartWalletSDK","LoggerWrapper","smartWalletService","errorProcessor","clientApiKey","isClient","SmartWalletSDKError","crossmintService","CrossmintWalletService","ErrorProcessor","DatadogProvider","SmartWalletService","ClientDecorator","_0","_1","__async","user","chain","walletParams","logPerformance","error"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/utils/environment.ts","../src/utils/helpers.ts","../src/services/logging/ConsoleProvider.ts","../src/utils/constants.ts","../src/services/logging/DatadogProvider.ts","../src/services/logging/index.ts","../src/blockchain/wallets/EVMSmartWallet.ts","../src/error/index.ts","../src/utils/log.ts","../src/blockchain/transfer.ts","../src/ABI/ERC1155.json","../src/SmartWalletSDK.ts","../src/api/BaseCrossmintService.ts","../src/api/APIErrorService.ts","../src/api/CrossmintWalletService.ts","../src/utils/blockchain.ts","../src/blockchain/wallets/clientDecorator.ts","../src/types/API.ts","../src/blockchain/wallets/service.ts","../src/types/internal.ts","../src/blockchain/chains.ts","../src/utils/signer.ts","../src/blockchain/wallets/eoa.ts","../src/blockchain/wallets/passkey.ts","../src/blockchain/wallets/paymaster.ts","../src/error/processor.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/Config\";\n\nexport type { TransferType, ERC20TransferType, NFTTransferType, SFTTransferType } from \"./types/Tokens\";\n\nexport {\n TransferError,\n CrossmintServiceError,\n SmartWalletSDKError,\n JWTDecryptionError,\n JWTExpiredError,\n JWTIdentifierError,\n JWTInvalidError,\n NotAuthorizedError,\n UserWalletAlreadyCreatedError,\n OutOfCreditsError,\n AdminAlreadyUsedError,\n AdminMismatchError,\n PasskeyMismatchError,\n PasskeyPromptError,\n PasskeyRegistrationError,\n PasskeyIncompatibleAuthenticatorError,\n ConfigError,\n NonCustodialWalletsNotEnabledError,\n} from \"./error\";\n\nexport { SmartWalletSDK } from \"./SmartWalletSDK\";\n","export function isClient() {\n return typeof window !== \"undefined\";\n}\n","export function isLocalhost() {\n if (process.env.NODE_ENV === \"test\") {\n return false;\n }\n\n return window.location.origin.includes(\"localhost\");\n}\n\nexport 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 { BrowserLoggerInterface } from \"./BrowserLoggerInterface\";\n\n// Set to true to enable logging on local development\nconst LOG_IN_LOCALHOST = false;\n\nexport class ConsoleProvider implements BrowserLoggerInterface {\n logInfo(message: string, context?: object) {\n if (LOG_IN_LOCALHOST) {\n console.log(message, context);\n }\n }\n\n logError(message: string, context?: object) {\n if (LOG_IN_LOCALHOST) {\n console.error(message, context);\n }\n }\n\n logWarn(message: string, context?: object) {\n if (LOG_IN_LOCALHOST) {\n console.warn(message, context);\n }\n }\n}\n","export const ZERO_DEV_TYPE = \"ZeroDev\";\nexport const CURRENT_VERSION = 0;\nexport const DATADOG_CLIENT_TOKEN = \"pub035be8a594b35be1887b6ba76c4029ca\";\nexport const CROSSMINT_DEV_URL = \"http://localhost:3000/api\";\nexport const CROSSMINT_STG_URL = \"https://staging.crossmint.com/api\";\nexport const CROSSMINT_PROD_URL = \"https://www.crossmint.com/api\";\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/\";\n","import { DATADOG_CLIENT_TOKEN, SCW_SERVICE } from \"@/utils/constants\";\nimport { datadogLogs } from \"@datadog/browser-logs\";\n\nimport { BrowserLoggerInterface } from \"./BrowserLoggerInterface\";\n\nexport class DatadogProvider implements BrowserLoggerInterface {\n logInfo(message: string, context?: object) {\n log(message, \"info\", context);\n }\n\n logError(message: string, context?: object) {\n log(message, \"error\", context);\n }\n\n logWarn(message: string, context?: object) {\n log(message, \"warn\", context);\n }\n}\n\nfunction log(message: string, loggerType: \"info\" | \"error\" | \"warn\", contextParam?: object) {\n const _context = contextParam ? { ...contextParam, service: SCW_SERVICE } : { service: SCW_SERVICE };\n\n init();\n datadogLogs.logger[loggerType](message, _context);\n}\n\nfunction init() {\n const isDatadogInitialized = datadogLogs.getInternalContext() != null;\n if (isDatadogInitialized) {\n return;\n }\n\n datadogLogs.init({\n clientToken: DATADOG_CLIENT_TOKEN,\n site: \"datadoghq.com\",\n forwardErrorsToLogs: false,\n sampleRate: 100,\n });\n}\n","import { isClient } from \"../../utils/environment\";\nimport { isLocalhost } from \"../../utils/helpers\";\nimport { ConsoleProvider } from \"./ConsoleProvider\";\nimport { DatadogProvider } from \"./DatadogProvider\";\n\nfunction getBrowserLogger() {\n if (isClient() && isLocalhost()) {\n return new ConsoleProvider();\n }\n\n return new DatadogProvider();\n}\n\nconst { logInfo, logWarn, logError } = getBrowserLogger();\n\nexport { logInfo, logWarn, logError };\n","import { logError } from \"@/services/logging\";\nimport { type HttpTransport, type PublicClient, isAddress, publicActions } from \"viem\";\n\nimport type { CrossmintWalletService } from \"../../api/CrossmintWalletService\";\nimport { TransferError } from \"../../error\";\nimport type { TransferType } from \"../../types/Tokens\";\nimport { SmartWalletClient } from \"../../types/internal\";\nimport { SCW_SERVICE } from \"../../utils/constants\";\nimport { LoggerWrapper, errorToJSON } from \"../../utils/log\";\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 extends LoggerWrapper {\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 ) {\n super(\"EVMSmartWallet\", { chain, address: accountClient.account.address });\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.logPerformance(\"TRANSFER\", 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 return await client.writeContract(request);\n } catch (error) {\n logError(\"[TRANSFER] - ERROR_TRANSFERRING_TOKEN\", {\n service: SCW_SERVICE,\n error: errorToJSON(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 }\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 { PasskeyDisplay, SignerDisplay } from \"@/types/API\";\n\nexport const SmartWalletErrors = {\n NOT_AUTHORIZED: \"smart-wallet:not-authorized\",\n TRANSFER: \"smart-wallet:transfer.error\",\n CROSSMINT_SERVICE: \"smart-wallet:crossmint-service.error\",\n ERROR_JWT_EXPIRED: \"smart-wallet:not-authorized.jwt-expired\",\n ERROR_JWT_INVALID: \"smart-wallet:not-authorized.jwt-invalid\",\n ERROR_JWT_DECRYPTION: \"smart-wallet:not-authorized.jwt-decryption\",\n ERROR_JWT_IDENTIFIER: \"smart-wallet:not-authorized.jwt-identifier\",\n ERROR_USER_WALLET_ALREADY_CREATED: \"smart-wallet:user-wallet-already-created.error\",\n ERROR_OUT_OF_CREDITS: \"smart-wallet:out-of-credits.error\",\n ERROR_WALLET_CONFIG: \"smart-wallet:wallet-config.error\",\n ERROR_ADMIN_MISMATCH: \"smart-wallet:wallet-config.admin-mismatch\",\n ERROR_PASSKEY_MISMATCH: \"smart-wallet:wallet-config.passkey-mismatch\",\n ERROR_PASSKEY_PROMPT: \"smart-wallet:passkey.prompt\",\n ERROR_PASSKEY_INCOMPATIBLE_AUTHENTICATOR: \"smart-wallet.passkey.incompatible-authenticator\",\n ERROR_PASSKEY_REGISTRATION: \"smart-wallet:passkey.registration\",\n ERROR_ADMIN_SIGNER_ALREADY_USED: \"smart-wallet:wallet-config.admin-signer-already-used\",\n ERROR_PROJECT_NONCUSTODIAL_WALLETS_NOT_ENABLED: \"smart-wallet:wallet-config.non-custodial-wallets-not-enabled\",\n UNCATEGORIZED: \"smart-wallet:uncategorized\", // catch-all error code\n} as const;\nexport type SmartWalletErrorCode = (typeof SmartWalletErrors)[keyof typeof SmartWalletErrors];\n\nexport class SmartWalletSDKError extends Error {\n public readonly code: SmartWalletErrorCode;\n public readonly details?: string;\n\n constructor(message: string, details?: string, code: SmartWalletErrorCode = SmartWalletErrors.UNCATEGORIZED) {\n super(message);\n this.details = details;\n this.code = code;\n }\n}\n\nexport class TransferError extends SmartWalletSDKError {\n constructor(message: string) {\n super(message, undefined, SmartWalletErrors.TRANSFER);\n }\n}\n\nexport class CrossmintServiceError extends SmartWalletSDKError {\n public status?: number;\n\n constructor(message: string, status?: number) {\n super(message, undefined, SmartWalletErrors.CROSSMINT_SERVICE);\n this.status = status;\n }\n}\n\nexport class AdminMismatchError extends SmartWalletSDKError {\n public readonly required: SignerDisplay;\n public readonly used?: SignerDisplay;\n\n constructor(message: string, required: SignerDisplay, used?: SignerDisplay) {\n super(message, SmartWalletErrors.ERROR_ADMIN_MISMATCH);\n this.required = required;\n this.used = used;\n }\n}\n\nexport class PasskeyMismatchError extends SmartWalletSDKError {\n public readonly required: PasskeyDisplay;\n public readonly used?: PasskeyDisplay;\n\n constructor(message: string, required: PasskeyDisplay, used?: PasskeyDisplay) {\n super(message, SmartWalletErrors.ERROR_PASSKEY_MISMATCH);\n this.required = required;\n this.used = used;\n }\n}\n\nexport class NotAuthorizedError extends SmartWalletSDKError {\n constructor(message: string) {\n super(message, undefined, SmartWalletErrors.NOT_AUTHORIZED);\n }\n}\n\nexport class JWTExpiredError extends NotAuthorizedError {\n public readonly code = SmartWalletErrors.ERROR_JWT_EXPIRED;\n\n /**\n * The expiry time of the JWT as an ISO 8601 timestamp.\n */\n public readonly expiredAt: string;\n\n constructor(expiredAt: Date) {\n super(`JWT provided expired at timestamp ${expiredAt}`);\n this.expiredAt = expiredAt.toISOString();\n }\n}\n\nexport class JWTInvalidError extends NotAuthorizedError {\n public readonly code = SmartWalletErrors.ERROR_JWT_INVALID;\n constructor() {\n super(\"Invalid JWT provided\");\n }\n}\n\nexport class JWTDecryptionError extends NotAuthorizedError {\n public readonly code = SmartWalletErrors.ERROR_JWT_DECRYPTION;\n constructor() {\n super(\"Error decrypting JWT\");\n }\n}\n\nexport class JWTIdentifierError extends NotAuthorizedError {\n public readonly code = SmartWalletErrors.ERROR_JWT_IDENTIFIER;\n public readonly identifierKey: string;\n\n constructor(identifierKey: string) {\n super(`Missing required identifier '${identifierKey}' in the JWT`);\n this.identifierKey = identifierKey;\n }\n}\n\nexport class UserWalletAlreadyCreatedError extends SmartWalletSDKError {\n public readonly code = SmartWalletErrors.ERROR_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 SmartWalletSDKError {\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 SmartWalletErrors.ERROR_PASSKEY_PROMPT\n );\n this.passkeyName = passkeyName;\n }\n}\n\nexport class PasskeyRegistrationError extends SmartWalletSDKError {\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 SmartWalletErrors.ERROR_PASSKEY_REGISTRATION\n );\n this.passkeyName = passkeyName;\n }\n}\n\nexport class PasskeyIncompatibleAuthenticatorError extends SmartWalletSDKError {\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 SmartWalletErrors.ERROR_PASSKEY_INCOMPATIBLE_AUTHENTICATOR\n );\n this.passkeyName = passkeyName;\n }\n}\n\nexport class OutOfCreditsError extends SmartWalletSDKError {\n constructor(message?: string) {\n super(\n \"You've run out of Crossmint API credits. Visit https://docs.crossmint.com/docs/errors for more information\",\n undefined,\n SmartWalletErrors.ERROR_OUT_OF_CREDITS\n );\n }\n}\n\nexport class ConfigError extends SmartWalletSDKError {\n constructor(message: string) {\n super(message, undefined, SmartWalletErrors.ERROR_WALLET_CONFIG);\n }\n}\n\nexport class AdminAlreadyUsedError extends ConfigError {\n public readonly code = SmartWalletErrors.ERROR_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 NonCustodialWalletsNotEnabledError extends ConfigError {\n public readonly code = SmartWalletErrors.ERROR_PROJECT_NONCUSTODIAL_WALLETS_NOT_ENABLED;\n constructor() {\n super(\"Non-custodial wallets are not enabled for this project\");\n }\n}\n","import { v4 as uuidv4 } from \"uuid\";\n\nimport { logError, logInfo } from \"../services/logging\";\nimport { SCW_SERVICE } from \"./constants\";\nimport { isLocalhost } from \"./helpers\";\n\nexport class LoggerWrapper {\n constructor(className: string, private extraInfo = {}, private logIdempotencyKey = uuidv4()) {\n return new Proxy(this, {\n get: (target: any, propKey: PropertyKey, receiver: any) => {\n const origMethod = target[propKey];\n const identifierTag = `[${SCW_SERVICE} - ${className} - ${String(propKey)}]`;\n\n if (typeof origMethod === \"function\") {\n return (...args: any[]) => {\n this.logInput(args, identifierTag);\n\n const result = origMethod.apply(target, args);\n if (result instanceof Promise) {\n return result\n .then((res: any) => {\n this.logOutput(res, identifierTag);\n return res;\n })\n .catch((err: any) => {\n this.logError(err, identifierTag);\n throw err;\n });\n } else {\n this.logOutput(result, identifierTag);\n return result;\n }\n };\n }\n return Reflect.get(target, propKey, receiver);\n },\n });\n }\n\n private logInput(args: object, identifierTag: string) {\n logInfoIfNotInLocalhost(\n `${identifierTag} input - ${beautify(args)} - extra_info - ${beautify(\n this.extraInfo\n )} - log_idempotency_key - ${this.logIdempotencyKey}`,\n { args, ...this.extraInfo, logIdempotencyKey: this.logIdempotencyKey }\n );\n }\n\n private logOutput(res: object, identifierTag: string) {\n logInfoIfNotInLocalhost(\n `${identifierTag} output - ${beautify(res)} - extra_info - ${beautify(\n this.extraInfo\n )} - log_idempotency_key - ${this.logIdempotencyKey}`,\n {\n res,\n ...this.extraInfo,\n logIdempotencyKey: this.logIdempotencyKey,\n }\n );\n }\n\n private logError(err: object, identifierTag: string) {\n logError(\n `${identifierTag} threw_error - ${err} - extra_info - ${beautify(this.extraInfo)} - log_idempotency_key - ${\n this.logIdempotencyKey\n }`,\n { err, ...this.extraInfo }\n );\n }\n\n protected logPerformance<T>(name: string, cb: () => Promise<T>) {\n return logPerformance(name, cb, this.extraInfo);\n }\n}\n\nexport async function logPerformance<T>(name: string, cb: () => Promise<T>, extraInfo?: object) {\n const start = new Date().getTime();\n const result = await cb();\n const durationInMs = new Date().getTime() - start;\n const args = { durationInMs, ...extraInfo };\n logInfoIfNotInLocalhost(`[${SCW_SERVICE} - ${name} - TIME] - ${beautify(args)}`, { args });\n return result;\n}\n\nexport function logInputOutput<T, A extends any[]>(fn: (...args: A) => T, functionName: string): (...args: A) => T {\n return function (this: any, ...args: A): T {\n const identifierTag = `[${SCW_SERVICE} - function: ${functionName}]`;\n logInfoIfNotInLocalhost(`${identifierTag} input: ${beautify(args)}`, { args });\n\n try {\n const result = fn.apply(this, args);\n if (result instanceof Promise) {\n return result\n .then((res) => {\n logInfoIfNotInLocalhost(`${identifierTag} output: ${beautify(res)}`, { res });\n return res;\n })\n .catch((err) => {\n logError(`${identifierTag} threw_error: ${beautify(err)}`, { err });\n throw err;\n }) as T;\n } else {\n logInfoIfNotInLocalhost(`${identifierTag} output: ${beautify(result)}`, { res: result });\n return result;\n }\n } catch (err) {\n logError(`${identifierTag} threw_error: ${beautify(err)}`, { err });\n throw err;\n }\n };\n}\n\nfunction beautify(json: any) {\n try {\n return json != null ? JSON.stringify(json, null, 2) : json;\n } catch (error) {\n return stringifyAvoidingCircular(json);\n }\n}\n\nfunction stringifyAvoidingCircular(json: any) {\n // stringify an object, avoiding circular structures\n // https://stackoverflow.com/a/31557814\n const simpleObject: { [key: string]: any } = {};\n for (const prop in json) {\n if (!Object.prototype.hasOwnProperty.call(json, prop)) {\n continue;\n }\n if (typeof json[prop] == \"object\") {\n continue;\n }\n if (typeof json[prop] == \"function\") {\n continue;\n }\n simpleObject[prop] = json[prop];\n }\n return JSON.stringify(simpleObject, null, 2); // returns cleaned up JSON\n}\n\nfunction logInfoIfNotInLocalhost(message: string, context?: object) {\n if (isLocalhost()) {\n console.log(message);\n return;\n }\n logInfo(message, context);\n}\n\nexport function errorToJSON(error: Error | unknown) {\n const errorToLog = error instanceof Error ? error : { message: \"Unknown error\", name: \"Unknown error\" };\n\n if (!(errorToLog instanceof Error) && (errorToLog as any).constructor?.name !== \"SyntheticBaseEvent\") {\n logError(\"ERROR_TO_JSON_FAILED\", { error: errorToLog });\n throw new Error(\"[errorToJSON] err is not instanceof Error nor SyntheticBaseEvent\");\n }\n\n return JSON.parse(JSON.stringify(errorToLog, Object.getOwnPropertyNames(errorToLog)));\n}\n","import { Abi, Account, Address, erc20Abi, erc721Abi } from \"viem\";\n\nimport erc1155Abi from \"../ABI/ERC1155.json\";\nimport type { ERC20TransferType, SFTTransferType, TransferType } from \"../types/Tokens\";\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 { stringify } from \"viem\";\n\nimport { validateAPIKey } from \"@crossmint/common-sdk-base\";\n\nimport { CrossmintWalletService } from \"./api/CrossmintWalletService\";\nimport { SmartWalletChain } from \"./blockchain/chains\";\nimport type { EVMSmartWallet } from \"./blockchain/wallets\";\nimport { ClientDecorator } from \"./blockchain/wallets/clientDecorator\";\nimport { SmartWalletService } from \"./blockchain/wallets/service\";\nimport { SmartWalletSDKError } from \"./error\";\nimport { ErrorProcessor } from \"./error/processor\";\nimport { DatadogProvider } from \"./services/logging/DatadogProvider\";\nimport type { SmartWalletSDKInitParams, UserParams, WalletParams } from \"./types/Config\";\nimport { isClient } from \"./utils/environment\";\nimport { LoggerWrapper, logPerformance } from \"./utils/log\";\n\nexport class SmartWalletSDK extends LoggerWrapper {\n private constructor(\n private readonly smartWalletService: SmartWalletService,\n private readonly errorProcessor: ErrorProcessor\n ) {\n super(\"SmartWalletSDK\");\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 SmartWalletSDKError(\"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(new DatadogProvider());\n return new SmartWalletSDK(\n new SmartWalletService(crossmintService, new ClientDecorator(errorProcessor)),\n errorProcessor\n );\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 logPerformance(\n \"GET_OR_CREATE_WALLET\",\n 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 SmartWalletSDKError(`Wallet creation failed: ${error.message}.`, stringify(error))\n );\n }\n },\n { user, chain }\n );\n }\n}\n","import { validateAPIKey } from \"@crossmint/common-sdk-base\";\n\nimport { CrossmintServiceError } from \"../error\";\nimport { CROSSMINT_DEV_URL, CROSSMINT_PROD_URL, CROSSMINT_STG_URL } from \"../utils/constants\";\nimport { LoggerWrapper, logPerformance } from \"../utils/log\";\nimport { APIErrorService } from \"./APIErrorService\";\n\nexport abstract class BaseCrossmintService extends LoggerWrapper {\n public crossmintAPIHeaders: Record<string, string>;\n protected crossmintBaseUrl: string;\n protected apiErrorService: APIErrorService;\n private static urlMap: Record<string, string> = {\n development: CROSSMINT_DEV_URL,\n staging: CROSSMINT_STG_URL,\n production: CROSSMINT_PROD_URL,\n };\n\n constructor(apiKey: string) {\n super(\"BaseCrossmintService\");\n const result = validateAPIKey(apiKey);\n if (!result.isValid) {\n throw new Error(\"API key invalid\");\n }\n this.crossmintAPIHeaders = {\n accept: \"application/json\",\n \"content-type\": \"application/json\",\n \"x-api-key\": apiKey,\n };\n this.crossmintBaseUrl = this.getUrlFromEnv(result.environment);\n this.apiErrorService = new APIErrorService();\n }\n\n protected async fetchCrossmintAPI(\n endpoint: string,\n options: { body?: string; method: string } = { method: \"GET\" },\n onServerErrorMessage: string,\n authToken?: string\n ) {\n return logPerformance(\n \"FETCH_CROSSMINT_API\",\n async () => {\n const url = `${this.crossmintBaseUrl}/${endpoint}`;\n const { body, method } = options;\n\n let response: Response;\n try {\n response = await fetch(url, {\n body,\n method,\n headers: {\n ...this.crossmintAPIHeaders,\n ...(authToken != null && {\n Authorization: `Bearer ${authToken}`,\n }),\n },\n });\n } catch (error) {\n throw new CrossmintServiceError(`Error fetching Crossmint API: ${error}`);\n }\n\n if (!response.ok) {\n await this.apiErrorService.throwErrorFromResponse({\n response,\n onServerErrorMessage,\n });\n }\n\n return await response.json();\n },\n { endpoint }\n );\n }\n\n protected getUrlFromEnv(environment: string) {\n const url = BaseCrossmintService.urlMap[environment];\n if (!url) {\n console.log(\" CrossmintService.urlMap: \", BaseCrossmintService.urlMap);\n throw new Error(`URL not found for environment: ${environment}`);\n }\n return url;\n }\n}\n","import {\n AdminAlreadyUsedError,\n CrossmintServiceError,\n JWTDecryptionError,\n JWTExpiredError,\n JWTIdentifierError,\n JWTInvalidError,\n NonCustodialWalletsNotEnabledError,\n OutOfCreditsError,\n SmartWalletSDKError,\n UserWalletAlreadyCreatedError,\n} from \"@/error\";\n\nexport type CrossmintAPIErrorCodes =\n | \"ERROR_JWT_INVALID\"\n | \"ERROR_JWT_DECRYPTION\"\n | \"ERROR_JWT_IDENTIFIER\"\n | \"ERROR_JWT_EXPIRED\"\n | \"ERROR_USER_WALLET_ALREADY_CREATED\"\n | \"ERROR_ADMIN_SIGNER_ALREADY_USED\"\n | \"ERROR_PROJECT_NONCUSTODIAL_WALLETS_NOT_ENABLED\";\n\nexport class APIErrorService {\n constructor(\n private errors: Partial<Record<CrossmintAPIErrorCodes, (apiResponse: any) => SmartWalletSDKError>> = {\n ERROR_JWT_INVALID: () => new JWTInvalidError(),\n ERROR_JWT_DECRYPTION: () => new JWTDecryptionError(),\n ERROR_JWT_EXPIRED: ({ expiredAt }: { expiredAt: string }) => new JWTExpiredError(new Date(expiredAt)),\n ERROR_JWT_IDENTIFIER: ({ identifierKey }: { identifierKey: string }) =>\n new JWTIdentifierError(identifierKey),\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 NonCustodialWalletsNotEnabledError(),\n }\n ) {}\n\n async throwErrorFromResponse({\n response,\n onServerErrorMessage,\n }: {\n response: Response;\n onServerErrorMessage: string;\n }) {\n if (response.ok) {\n return;\n }\n\n if (response.status >= 500) {\n throw new CrossmintServiceError(onServerErrorMessage, response.status);\n }\n\n if (response.status === 402) {\n throw new OutOfCreditsError();\n }\n\n try {\n const body = await response.json();\n const code = body.code as CrossmintAPIErrorCodes | undefined;\n if (code != null && this.errors[code] != null) {\n throw this.errors[code](body);\n }\n if (body.message != null) {\n throw new CrossmintServiceError(body.message, response.status);\n }\n } catch (e) {\n if (e instanceof SmartWalletSDKError) {\n throw e;\n }\n console.error(\"Error parsing response\", e);\n }\n\n throw new CrossmintServiceError(await response.text(), response.status);\n }\n}\n","import { SmartWalletChain } from \"@/blockchain/chains\";\nimport { SignerData, StoreSmartWalletParams } from \"@/types/API\";\nimport type { UserParams } from \"@/types/Config\";\nimport { API_VERSION } from \"@/utils/constants\";\n\nimport { BaseCrossmintService } from \"./BaseCrossmintService\";\n\nexport class CrossmintWalletService extends BaseCrossmintService {\n async idempotentCreateSmartWallet(user: UserParams, input: StoreSmartWalletParams) {\n return 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 getSmartWalletConfig(\n user: UserParams,\n chain: SmartWalletChain\n ): Promise<{\n kernelVersion: string;\n entryPointVersion: string;\n userId: string;\n signers: { signerData: SignerData }[];\n smartContractWalletAddress?: string;\n }> {\n return 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\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 { SmartWalletChain } from \"../blockchain/chains\";\n\nexport function usesGelatoBundler(chain: SmartWalletChain) {\n return false;\n}\n","import { SmartWalletSDKError } from \"@/error\";\nimport { ErrorProcessor } from \"@/error/processor\";\nimport { logInfo } from \"@/services/logging\";\nimport { usesGelatoBundler } from \"@/utils/blockchain\";\nimport { logPerformance } from \"@/utils/log\";\nimport type { SmartAccountClient } from \"permissionless\";\nimport type { EntryPoint } from \"permissionless/types/entrypoint\";\nimport { stringify } from \"viem\";\n\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) {}\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 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 logInfo(`[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 SmartWalletSDKError(`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 { PasskeyValidatorContractVersion } from \"@zerodev/passkey-validator\";\n\nimport { PasskeyValidatorSerializedData, SupportedEntryPointVersion, SupportedKernelVersion } from \"./internal\";\n\nexport type StoreSmartWalletParams = {\n type: string;\n smartContractWalletAddress: string;\n signerData: SignerData;\n sessionKeySignerAddress?: string;\n version: number;\n baseLayer: string;\n chainId: number;\n entryPointVersion: SupportedEntryPointVersion;\n kernelVersion: SupportedKernelVersion;\n};\n\nexport type SignerData = EOASignerData | PasskeySignerData;\n\nexport interface EOASignerData {\n eoaAddress: string;\n type: \"eoa\";\n}\n\nexport type PasskeySignerData = PasskeyValidatorSerializedData & {\n passkeyName: string;\n validatorContractVersion: PasskeyValidatorContractVersion;\n domain: string;\n type: \"passkeys\";\n};\n\nexport type PasskeyDisplay = Pick<PasskeySignerData, \"type\" | \"passkeyName\" | \"pubKeyX\" | \"pubKeyY\">;\nexport type SignerDisplay = EOASignerData | PasskeyDisplay;\nexport function displayPasskey(data: PasskeySignerData): PasskeyDisplay {\n return {\n pubKeyX: data.pubKeyX,\n pubKeyY: data.pubKeyY,\n passkeyName: data.passkeyName,\n type: \"passkeys\",\n };\n}\n","import { type SignerData, displayPasskey } from \"@/types/API\";\nimport { equalsIgnoreCase } from \"@/utils/helpers\";\nimport { type KernelSmartAccount, createKernelAccountClient } from \"@zerodev/sdk\";\nimport { ENTRYPOINT_ADDRESS_V06, ENTRYPOINT_ADDRESS_V07 } from \"permissionless\";\nimport type { EntryPoint } from \"permissionless/types/entrypoint\";\nimport { Address, type HttpTransport, createPublicClient, getAddress, http } from \"viem\";\n\nimport { blockchainToChainId } from \"@crossmint/common-sdk-base\";\n\nimport type { CrossmintWalletService } from \"../../api/CrossmintWalletService\";\nimport {\n AdminMismatchError,\n CrossmintServiceError,\n SmartWalletSDKError,\n UserWalletAlreadyCreatedError,\n} from \"../../error\";\nimport type { EntryPointDetails, UserParams, WalletParams } from \"../../types/Config\";\nimport {\n SUPPORTED_ENTRYPOINT_VERSIONS,\n SUPPORTED_KERNEL_VERSIONS,\n SmartWalletClient,\n type SupportedKernelVersion,\n type WalletCreationParams,\n isSupportedEntryPointVersion,\n isSupportedKernelVersion,\n} from \"../../types/internal\";\nimport { CURRENT_VERSION, ZERO_DEV_TYPE } from \"../../utils/constants\";\nimport { SmartWalletChain, getBundlerRPC, viemNetworks } from \"../chains\";\nimport { EVMSmartWallet } from \"./EVMSmartWallet\";\nimport { ClientDecorator } from \"./clientDecorator\";\nimport { EOAAccountService, type EOAWalletParams } from \"./eoa\";\nimport { PasskeyAccountService, isPasskeyParams } from \"./passkey\";\nimport { paymasterMiddleware, usePaymaster } from \"./paymaster\";\n\nexport class SmartWalletService {\n constructor(\n private readonly crossmintWalletService: CrossmintWalletService,\n private readonly clientDecorator: ClientDecorator,\n private readonly accountFactory = new AccountFactory(\n new EOAAccountService(),\n new PasskeyAccountService(crossmintWalletService)\n )\n ) {}\n\n public async getOrCreate(\n user: UserParams,\n chain: SmartWalletChain,\n walletParams: WalletParams\n ): Promise<EVMSmartWallet> {\n const { entryPoint, kernelVersion, existingSignerConfig, smartContractWalletAddress, userId } =\n await this.fetchConfig(user, chain);\n const publicClient = createPublicClient({ transport: http(getBundlerRPC(chain)) });\n\n const { account, signerData } = await this.accountFactory.get(\n {\n chain,\n walletParams,\n publicClient,\n user: { ...user, id: userId },\n entryPoint,\n kernelVersion,\n },\n existingSignerConfig\n );\n\n if (smartContractWalletAddress != null && !equalsIgnoreCase(smartContractWalletAddress, account.address)) {\n throw new UserWalletAlreadyCreatedError(userId);\n }\n\n if (existingSignerConfig == null) {\n await this.crossmintWalletService.idempotentCreateSmartWallet(user, {\n type: ZERO_DEV_TYPE,\n smartContractWalletAddress: account.address,\n signerData: signerData,\n version: CURRENT_VERSION,\n baseLayer: \"evm\",\n chainId: blockchainToChainId(chain),\n entryPointVersion: entryPoint.version,\n kernelVersion,\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) && paymasterMiddleware({ entryPoint: account.entryPoint, chain })),\n });\n\n const smartAccountClient = this.clientDecorator.decorate({\n crossmintChain: chain,\n smartAccountClient: kernelAccountClient,\n });\n\n return new EVMSmartWallet(this.crossmintWalletService, smartAccountClient, publicClient, chain);\n }\n\n private async fetchConfig(\n user: UserParams,\n chain: SmartWalletChain\n ): Promise<{\n entryPoint: EntryPointDetails;\n kernelVersion: SupportedKernelVersion;\n userId: string;\n existingSignerConfig?: SignerData;\n smartContractWalletAddress?: Address;\n }> {\n const { entryPointVersion, kernelVersion, signers, smartContractWalletAddress, userId } =\n await this.crossmintWalletService.getSmartWalletConfig(user, chain);\n\n if (!isSupportedKernelVersion(kernelVersion)) {\n throw new SmartWalletSDKError(\n `Unsupported kernel version. Supported versions: ${SUPPORTED_KERNEL_VERSIONS.join(\n \", \"\n )}. Version used: ${kernelVersion}, Please contact support`\n );\n }\n\n if (!isSupportedEntryPointVersion(entryPointVersion)) {\n throw new SmartWalletSDKError(\n `Unsupported entry point version. Supported versions: ${SUPPORTED_ENTRYPOINT_VERSIONS.join(\n \", \"\n )}. Version used: ${entryPointVersion}. Please contact support`\n );\n }\n\n if (\n (entryPointVersion === \"v0.7\" && kernelVersion.startsWith(\"0.2\")) ||\n (entryPointVersion === \"v0.6\" && kernelVersion.startsWith(\"0.3\"))\n ) {\n throw new SmartWalletSDKError(\n `Unsupported combination: entryPoint ${entryPointVersion} and kernel version ${kernelVersion}. Please contact support`\n );\n }\n\n return {\n entryPoint: {\n version: entryPointVersion,\n address: entryPointVersion === \"v0.6\" ? ENTRYPOINT_ADDRESS_V06 : ENTRYPOINT_ADDRESS_V07,\n },\n kernelVersion,\n userId,\n existingSignerConfig: this.getSigner(signers),\n smartContractWalletAddress:\n smartContractWalletAddress != null ? getAddress(smartContractWalletAddress) : undefined,\n };\n }\n\n private getSigner(signers: any[]): SignerData | undefined {\n if (signers.length === 0) {\n return undefined;\n }\n\n if (signers.length > 1) {\n throw new CrossmintServiceError(\"Invalid wallet signer configuration. Please contact support\");\n }\n\n return signers[0].signerData;\n }\n}\n\nclass AccountFactory {\n constructor(private readonly eoa: EOAAccountService, private readonly passkey: PasskeyAccountService) {}\n\n public get(\n params: WalletCreationParams,\n existingSignerConfig?: SignerData\n ): Promise<{\n signerData: SignerData;\n account: KernelSmartAccount<EntryPoint, HttpTransport>;\n }> {\n if (isPasskeyParams(params)) {\n if (existingSignerConfig != null && existingSignerConfig?.type !== \"passkeys\") {\n throw new AdminMismatchError(\n `Cannot create wallet with passkey signer for user '${params.user.id}', they have an existing wallet with eoa signer '${existingSignerConfig.eoaAddress}.'`,\n existingSignerConfig\n );\n }\n\n return this.passkey.get(params, existingSignerConfig);\n }\n\n if (existingSignerConfig != null && existingSignerConfig?.type !== \"eoa\") {\n throw new AdminMismatchError(\n `Cannot create wallet with eoa signer for user '${params.user.id}', they already have a wallet with a passkey named '${existingSignerConfig.passkeyName}' as it's signer.`,\n displayPasskey(existingSignerConfig)\n );\n }\n\n return this.eoa.get(params as EOAWalletParams, existingSignerConfig);\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 { Chain, Hex, HttpTransport, PublicClient } from \"viem\";\n\nimport type { SmartWalletChain } from \"../blockchain/chains\";\nimport type { SignerData } from \"./API\";\nimport type { EntryPointDetails, UserParams, WalletParams } from \"./Config\";\n\nexport const SUPPORTED_KERNEL_VERSIONS = [\"0.3.1\", \"0.3.0\", \"0.2.4\"] as const;\nexport type SupportedKernelVersion = (typeof SUPPORTED_KERNEL_VERSIONS)[number];\n\nexport function isSupportedKernelVersion(version: string): version is SupportedKernelVersion {\n return SUPPORTED_KERNEL_VERSIONS.includes(version as any);\n}\n\nexport const SUPPORTED_ENTRYPOINT_VERSIONS = [\"v0.6\", \"v0.7\"] as const;\nexport type SupportedEntryPointVersion = (typeof SUPPORTED_ENTRYPOINT_VERSIONS)[number];\n\nexport function isSupportedEntryPointVersion(version: string): version is SupportedEntryPointVersion {\n return SUPPORTED_ENTRYPOINT_VERSIONS.includes(version as any);\n}\n\nexport interface WalletCreationParams {\n user: UserParams & { id: string };\n chain: SmartWalletChain;\n publicClient: PublicClient<HttpTransport>;\n walletParams: WalletParams;\n entryPoint: EntryPointDetails;\n kernelVersion: SupportedKernelVersion;\n}\n\nexport interface AccountAndSigner {\n account: KernelSmartAccount<EntryPoint, HttpTransport>;\n signerData: SignerData;\n}\n\nexport type PasskeyValidatorSerializedData = {\n passkeyServerUrl: string;\n entryPoint: Hex;\n validatorAddress: Hex;\n pubKeyX: string;\n pubKeyY: string;\n authenticatorIdHash: Hex;\n authenticatorId: string;\n};\n\nexport type SmartWalletClient = SmartAccountClient<EntryPoint, HttpTransport, Chain, SmartAccount<EntryPoint>>;\n","import { BUNDLER_RPC } from \"@/utils/constants\";\nimport { Chain, base, baseSepolia, polygon, polygonAmoy } from \"viem/chains\";\n\nimport { BlockchainIncludingTestnet as Blockchain, ObjectValues, objectValues } from \"@crossmint/common-sdk-base\";\n\nexport const SmartWalletTestnet = {\n BASE_SEPOLIA: Blockchain.BASE_SEPOLIA,\n POLYGON_AMOY: Blockchain.POLYGON_AMOY,\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} 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};\n\nexport const viemNetworks: Record<SmartWalletChain, Chain> = {\n polygon: polygon,\n \"polygon-amoy\": polygonAmoy,\n base: base,\n \"base-sepolia\": baseSepolia,\n};\n\nexport const getBundlerRPC = (chain: SmartWalletChain) => {\n return BUNDLER_RPC + zerodevProjects[chain];\n};\n","import { providerToSmartAccountSigner } from \"permissionless\";\nimport type { SmartAccountSigner } from \"permissionless/accounts\";\nimport { Address, EIP1193Provider } from \"viem\";\n\nimport { SmartWalletChain } from \"../blockchain/chains\";\nimport { SmartWalletSDKError } from \"../error\";\nimport { ViemAccount, WalletParams } from \"../types/Config\";\nimport { logInputOutput } from \"./log\";\n\ntype CreateOwnerSignerInput = {\n chain: SmartWalletChain;\n walletParams: WalletParams;\n};\n\nexport const createOwnerSigner = logInputOutput(\n async ({ walletParams }: 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 SmartWalletSDKError(`The signer type ${signer.type} is not supported`);\n }\n },\n \"createOwnerSigner\"\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 { EOASignerData } from \"@/types/API\";\nimport type { EOASigner, WalletParams } from \"@/types/Config\";\nimport { AccountAndSigner, WalletCreationParams } from \"@/types/internal\";\nimport { equalsIgnoreCase } from \"@/utils/helpers\";\nimport { createOwnerSigner } from \"@/utils/signer\";\nimport { signerToEcdsaValidator } from \"@zerodev/ecdsa-validator\";\nimport { createKernelAccount } from \"@zerodev/sdk\";\n\nimport { AdminMismatchError } from \"../../error\";\n\nexport interface EOAWalletParams extends WalletCreationParams {\n walletParams: WalletParams & { signer: EOASigner };\n}\n\nexport class EOAAccountService {\n public async get(\n { chain, publicClient, entryPoint, walletParams, kernelVersion, user }: EOAWalletParams,\n existingSignerConfig?: EOASignerData\n ): Promise<AccountAndSigner> {\n const eoa = await createOwnerSigner({\n chain,\n walletParams,\n });\n\n if (existingSignerConfig != null && !equalsIgnoreCase(eoa.address, existingSignerConfig.eoaAddress)) {\n throw new AdminMismatchError(\n `User '${user.id}' has an existing wallet with an eoa signer '${existingSignerConfig.eoaAddress}', this does not match input eoa signer '${eoa.address}'.`,\n existingSignerConfig,\n { type: \"eoa\", eoaAddress: existingSignerConfig.eoaAddress }\n );\n }\n\n const ecdsaValidator = await signerToEcdsaValidator(publicClient, {\n signer: eoa,\n entryPoint: entryPoint.address,\n kernelVersion,\n });\n const account = await createKernelAccount(publicClient, {\n plugins: {\n sudo: ecdsaValidator,\n },\n index: BigInt(0),\n entryPoint: entryPoint.address,\n kernelVersion,\n });\n\n return { account, signerData: { eoaAddress: eoa.address, type: \"eoa\" } };\n }\n}\n","import type { CrossmintWalletService } from \"@/api/CrossmintWalletService\";\nimport { type PasskeySignerData, displayPasskey } from \"@/types/API\";\nimport type { PasskeySigner, UserParams, WalletParams } from \"@/types/Config\";\nimport type { AccountAndSigner, PasskeyValidatorSerializedData, WalletCreationParams } from \"@/types/internal\";\nimport { 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\";\n\nexport interface PasskeyWalletParams extends WalletCreationParams {\n walletParams: WalletParams & { signer: PasskeySigner };\n}\n\nexport function isPasskeyParams(params: WalletCreationParams): params is PasskeyWalletParams {\n return (params.walletParams.signer as PasskeySigner).type === \"PASSKEY\";\n}\n\ntype PasskeyValidator = KernelValidator<EntryPoint, \"WebAuthnValidator\"> & {\n getSerializedData: () => string;\n};\nexport class PasskeyAccountService {\n constructor(private readonly crossmintService: CrossmintWalletService) {}\n\n public async get(\n { user, publicClient, walletParams, entryPoint, kernelVersion }: PasskeyWalletParams,\n existingSignerConfig?: PasskeySignerData\n ): Promise<AccountAndSigner> {\n const inputPasskeyName = walletParams.signer.passkeyName ?? user.id;\n if (existingSignerConfig != null && existingSignerConfig.passkeyName !== inputPasskeyName) {\n throw new PasskeyMismatchError(\n `User '${user.id}' has an existing wallet created with a passkey named '${existingSignerConfig.passkeyName}', this does match input passkey name '${inputPasskeyName}'.`,\n displayPasskey(existingSignerConfig)\n );\n }\n\n try {\n const passkey = await this.getPasskey(user, inputPasskeyName, existingSignerConfig);\n\n const latestValidatorVersion = PasskeyValidatorContractVersion.V0_0_2;\n const validatorContractVersion =\n existingSignerConfig == null ? latestValidatorVersion : existingSignerConfig.validatorContractVersion;\n const validator = await toPasskeyValidator(publicClient, {\n webAuthnKey: passkey,\n entryPoint: entryPoint.address,\n validatorContractVersion,\n kernelVersion,\n });\n\n const kernelAccount = await createKernelAccount(publicClient, {\n plugins: { sudo: validator },\n entryPoint: entryPoint.address,\n kernelVersion,\n });\n\n return {\n signerData: this.getSignerData(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.crossmintService.getPasskeyServerUrl(),\n mode: WebAuthnMode.Register,\n passkeyServerHeaders: this.createPasskeysServerHeaders(user),\n });\n }\n\n private getSignerData(\n validator: PasskeyValidator,\n validatorContractVersion: PasskeyValidatorContractVersion,\n passkeyName: string\n ): PasskeySignerData {\n return {\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.crossmintService.crossmintAPIHeaders[\"x-api-key\"],\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 { PAYMASTER_RPC } from \"@/utils/constants\";\nimport { createZeroDevPaymasterClient } from \"@zerodev/sdk\";\nimport { Middleware } from \"permissionless/actions/smartAccount\";\nimport { EntryPoint } from \"permissionless/types/entrypoint\";\nimport { http } from \"viem\";\n\nimport { usesGelatoBundler } from \"../../utils/blockchain\";\nimport { SmartWalletChain, viemNetworks, zerodevProjects } from \"../chains\";\n\nexport function usePaymaster(chain: SmartWalletChain) {\n return !usesGelatoBundler(chain);\n}\n\nconst getPaymasterRPC = (chain: SmartWalletChain) => {\n return PAYMASTER_RPC + zerodevProjects[chain];\n};\n\nexport function paymasterMiddleware({\n entryPoint,\n chain,\n}: {\n entryPoint: EntryPoint;\n chain: SmartWalletChain;\n}): Middleware<EntryPoint> {\n return {\n middleware: {\n sponsorUserOperation: async ({ userOperation }) => {\n const paymasterClient = createZeroDevPaymasterClient({\n chain: viemNetworks[chain],\n transport: http(getPaymasterRPC(chain)),\n entryPoint,\n });\n return paymasterClient.sponsorUserOperation({\n userOperation,\n entryPoint,\n });\n },\n },\n };\n}\n","import { logError } from \"@/services/logging\";\nimport { DatadogProvider } from \"@/services/logging/DatadogProvider\";\nimport { SDK_VERSION } from \"@/utils/constants\";\nimport { BaseError, stringify } from \"viem\";\n\nimport { SmartWalletSDKError } from \".\";\n\nexport class ErrorProcessor {\n constructor(private readonly logger: DatadogProvider) {}\n\n public map(error: unknown, fallback: SmartWalletSDKError): SmartWalletSDKError | BaseError {\n this.record(error);\n\n if (error instanceof SmartWalletSDKError) {\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.logError(`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"],"mappings":"w+BAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,2BAAAE,EAAA,uBAAAC,EAAA,2DAAAC,EAAA,0BAAAC,EAAA,mBAAAC,EAAA,uBAAAC,EAAA,oBAAAC,EAAA,uBAAAC,EAAA,oBAAAC,EAAA,uCAAAC,EAAA,uBAAAC,EAAA,sBAAAC,EAAA,0CAAAC,EAAA,yBAAAC,EAAA,uBAAAC,EAAA,6BAAAC,EAAA,mBAAAC,GAAA,wBAAAC,EAAA,kBAAAC,EAAA,kCAAAC,EAAA,gEAAAC,GAAAtB,IAAA,IAAAuB,GAA4E,sCCArE,SAASC,GAAW,CACvB,OAAO,OAAO,QAAW,WAC7B,CCFO,SAASC,GAAc,CAC1B,OAAI,QAAQ,IAAI,WAAa,OAClB,GAGJ,OAAO,SAAS,OAAO,SAAS,WAAW,CACtD,CAMO,SAASC,EAAiBC,EAAYC,EAAqB,CAC9D,OAAOD,GAAA,YAAAA,EAAG,kBAAkBC,GAAA,YAAAA,EAAG,cACnC,CCXA,IAAMC,GAAmB,GAEZC,GAAN,KAAwD,CAC3D,QAAQC,EAAiBC,EAAkB,CACnCH,IACA,QAAQ,IAAIE,EAASC,CAAO,CAEpC,CAEA,SAASD,EAAiBC,EAAkB,CACpCH,IACA,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GrB,CAMA,OAAO,KAAK,CAAE,aAAAC,CAAa,EAA6C,CACpE,GAAI,CAACC,EAAS,EACV,MAAM,IAAIC,EAAoB,mDAAmD,EAIrF,GAAI,IADqB,mBAAeF,CAAY,EAC9B,QAClB,MAAM,IAAI,MAAM,iBAAiB,EAGrC,IAAMG,EAAmB,IAAIC,GAAuBJ,CAAY,EAC1DD,EAAiB,IAAIM,GAAe,IAAIC,CAAiB,EAC/D,OAAO,IAAIV,EACP,IAAIW,GAAmBJ,EAAkB,IAAIK,GAAgBT,CAAc,CAAC,EAC5EA,CACJ,CACJ,CAWM,kBACFU,EACAC,EAEuB,QAAAC,EAAA,yBAHvBC,EACAC,EACAC,EAA6B,CAAE,OAAQ,CAAE,KAAM,SAAU,CAAE,EACpC,CACvB,OAAOC,EACH,uBACA,IAAYJ,EAAA,sBACR,GAAI,CACA,OAAO,MAAM,KAAK,mBAAmB,YAAYC,EAAMC,EAAOC,CAAY,CAC9E,OAASE,EAAY,CACjB,MAAM,KAAK,eAAe,IACtBA,EACA,IAAId,EAAoB,2BAA2Bc,EAAM,OAAO,OAAK,cAAUA,CAAK,CAAC,CACzF,CACJ,CACJ,GACA,CAAE,KAAAJ,EAAM,MAAAC,CAAM,CAClB,CACJ,GACJ","names":["src_exports","__export","AdminAlreadyUsedError","AdminMismatchError","ConfigError","CrossmintServiceError","EVMSmartWallet","JWTDecryptionError","JWTExpiredError","JWTIdentifierError","JWTInvalidError","NonCustodialWalletsNotEnabledError","NotAuthorizedError","OutOfCreditsError","PasskeyIncompatibleAuthenticatorError","PasskeyMismatchError","PasskeyPromptError","PasskeyRegistrationError","SmartWalletSDK","SmartWalletSDKError","TransferError","UserWalletAlreadyCreatedError","__toCommonJS","import_common_sdk_base","isClient","isLocalhost","equalsIgnoreCase","a","b","LOG_IN_LOCALHOST","ConsoleProvider","message","context","ZERO_DEV_TYPE","DATADOG_CLIENT_TOKEN","CROSSMINT_DEV_URL","CROSSMINT_STG_URL","CROSSMINT_PROD_URL","SCW_SERVICE","SDK_VERSION","API_VERSION","BUNDLER_RPC","PAYMASTER_RPC","import_browser_logs","DatadogProvider","message","context","log","loggerType","contextParam","_context","__spreadProps","__spreadValues","SCW_SERVICE","init","DATADOG_CLIENT_TOKEN","getBrowserLogger","isClient","isLocalhost","ConsoleProvider","DatadogProvider","logInfo","logWarn","logError","import_viem","SmartWalletErrors","SmartWalletSDKError","message","details","code","TransferError","CrossmintServiceError","status","AdminMismatchError","required","used","PasskeyMismatchError","NotAuthorizedError","JWTExpiredError","expiredAt","JWTInvalidError","JWTDecryptionError","JWTIdentifierError","identifierKey","UserWalletAlreadyCreatedError","userId","PasskeyPromptError","passkeyName","PasskeyRegistrationError","PasskeyIncompatibleAuthenticatorError","OutOfCreditsError","ConfigError","AdminAlreadyUsedError","NonCustodialWalletsNotEnabledError","import_uuid","LoggerWrapper","className","extraInfo","logIdempotencyKey","uuidv4","target","propKey","receiver","origMethod","identifierTag","SCW_SERVICE","args","result","res","err","logInfoIfNotInLocalhost","beautify","__spreadProps","__spreadValues","logError","name","cb","logPerformance","__async","start","durationInMs","logInputOutput","fn","functionName","json","error","stringifyAvoidingCircular","simpleObject","prop","message","context","isLocalhost","logInfo","errorToJSON","_a","errorToLog","import_viem","ERC1155_default","transferParams","contract","config","from","to","ERC1155_default","EVMSmartWallet","LoggerWrapper","crossmintService","accountClient","publicClient","chain","toAddress","config","__async","tx","transferParams","client","request","error","logError","SCW_SERVICE","errorToJSON","tokenIdString","TransferError","import_viem","import_common_sdk_base","import_common_sdk_base","APIErrorService","errors","JWTInvalidError","JWTDecryptionError","expiredAt","JWTExpiredError","identifierKey","JWTIdentifierError","userId","UserWalletAlreadyCreatedError","AdminAlreadyUsedError","NonCustodialWalletsNotEnabledError","_0","__async","response","onServerErrorMessage","CrossmintServiceError","OutOfCreditsError","body","code","e","SmartWalletSDKError","_BaseCrossmintService","LoggerWrapper","apiKey","result","APIErrorService","_0","__async","endpoint","options","onServerErrorMessage","authToken","logPerformance","url","body","method","response","__spreadValues","error","CrossmintServiceError","environment","CROSSMINT_DEV_URL","CROSSMINT_STG_URL","CROSSMINT_PROD_URL","BaseCrossmintService","CrossmintWalletService","BaseCrossmintService","user","input","__async","API_VERSION","chain","address","usesGelatoBundler","chain","import_viem","transactionMethods","signingMethods","isTxnMethod","method","isSignMethod","ClientDecorator","errorProcessor","crossmintChain","smartAccountClient","target","prop","receiver","originalMethod","args","logPerformance","__async","logInfo","processed","error","description","SmartWalletSDKError","userOperation","middleware","account","txn","txnParams","usesGelatoBundler","__spreadProps","__spreadValues","displayPasskey","data","import_sdk","import_permissionless","import_viem","import_common_sdk_base","SUPPORTED_KERNEL_VERSIONS","isSupportedKernelVersion","version","SUPPORTED_ENTRYPOINT_VERSIONS","isSupportedEntryPointVersion","import_chains","import_common_sdk_base","SmartWalletTestnet","Blockchain","SMART_WALLET_TESTNETS","SmartWalletMainnet","SMART_WALLET_MAINNETS","SmartWalletChain","__spreadValues","SMART_WALLET_CHAINS","zerodevProjects","viemNetworks","getBundlerRPC","chain","BUNDLER_RPC","import_permissionless","createOwnerSigner","logInputOutput","_0","__async","walletParams","isEIP1193Provider","isAccount","signer","SmartWalletSDKError","import_ecdsa_validator","import_sdk","EOAAccountService","_0","_1","__async","chain","publicClient","entryPoint","walletParams","kernelVersion","user","existingSignerConfig","eoa","createOwnerSigner","equalsIgnoreCase","AdminMismatchError","ecdsaValidator","import_passkey_validator","import_sdk","import_webauthn_key","isPasskeyParams","params","PasskeyAccountService","crossmintService","_0","_1","__async","user","publicClient","walletParams","entryPoint","kernelVersion","existingSignerConfig","_a","inputPasskeyName","PasskeyMismatchError","displayPasskey","passkey","latestValidatorVersion","validatorContractVersion","validator","kernelAccount","error","passkeyName","existing","__spreadProps","__spreadValues","deserializePasskeyValidatorData","PasskeyIncompatibleAuthenticatorError","PasskeyRegistrationError","PasskeyPromptError","account","target","prop","receiver","original","isAccountSigningMethod","args","accountSigningMethods","method","uint8Array","base64ToBytes","jsonString","base64","binString","m","import_sdk","import_viem","usePaymaster","chain","usesGelatoBundler","getPaymasterRPC","PAYMASTER_RPC","zerodevProjects","paymasterMiddleware","entryPoint","_0","__async","userOperation","viemNetworks","SmartWalletService","crossmintWalletService","clientDecorator","accountFactory","AccountFactory","EOAAccountService","PasskeyAccountService","user","chain","walletParams","__async","entryPoint","kernelVersion","existingSignerConfig","smartContractWalletAddress","userId","publicClient","getBundlerRPC","account","signerData","__spreadProps","__spreadValues","equalsIgnoreCase","UserWalletAlreadyCreatedError","ZERO_DEV_TYPE","kernelAccountClient","viemNetworks","usePaymaster","paymasterMiddleware","smartAccountClient","EVMSmartWallet","entryPointVersion","signers","isSupportedKernelVersion","SmartWalletSDKError","SUPPORTED_KERNEL_VERSIONS","isSupportedEntryPointVersion","SUPPORTED_ENTRYPOINT_VERSIONS","CrossmintServiceError","eoa","passkey","params","isPasskeyParams","AdminMismatchError","displayPasskey","import_viem","ErrorProcessor","logger","error","fallback","SmartWalletSDKError","message","SDK_VERSION","SmartWalletSDK","_SmartWalletSDK","LoggerWrapper","smartWalletService","errorProcessor","clientApiKey","isClient","SmartWalletSDKError","crossmintService","CrossmintWalletService","ErrorProcessor","DatadogProvider","SmartWalletService","ClientDecorator","_0","_1","__async","user","chain","walletParams","logPerformance","error"]}
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ObjectValues } from '@crossmint/common-sdk-base';
2
- export { blockchainToChainId } from '@crossmint/common-sdk-base';
2
+ export { EVMBlockchainIncludingTestnet as Chain, blockchainToChainId } from '@crossmint/common-sdk-base';
3
3
  import { LocalAccount, EIP1193Provider, HttpTransport, Chain, Hex, PublicClient } from 'viem';
4
4
  import { PasskeyValidatorContractVersion } from '@zerodev/passkey-validator';
5
5
  import { SmartAccountClient } from 'permissionless';
@@ -103,6 +103,9 @@ declare const SmartWalletErrors: {
103
103
  readonly ERROR_WALLET_CONFIG: "smart-wallet:wallet-config.error";
104
104
  readonly ERROR_ADMIN_MISMATCH: "smart-wallet:wallet-config.admin-mismatch";
105
105
  readonly ERROR_PASSKEY_MISMATCH: "smart-wallet:wallet-config.passkey-mismatch";
106
+ readonly ERROR_PASSKEY_PROMPT: "smart-wallet:passkey.prompt";
107
+ readonly ERROR_PASSKEY_INCOMPATIBLE_AUTHENTICATOR: "smart-wallet.passkey.incompatible-authenticator";
108
+ readonly ERROR_PASSKEY_REGISTRATION: "smart-wallet:passkey.registration";
106
109
  readonly ERROR_ADMIN_SIGNER_ALREADY_USED: "smart-wallet:wallet-config.admin-signer-already-used";
107
110
  readonly ERROR_PROJECT_NONCUSTODIAL_WALLETS_NOT_ENABLED: "smart-wallet:wallet-config.non-custodial-wallets-not-enabled";
108
111
  readonly UNCATEGORIZED: "smart-wallet:uncategorized";
@@ -158,6 +161,18 @@ declare class UserWalletAlreadyCreatedError extends SmartWalletSDKError {
158
161
  readonly code: "smart-wallet:user-wallet-already-created.error";
159
162
  constructor(userId: string);
160
163
  }
164
+ declare class PasskeyPromptError extends SmartWalletSDKError {
165
+ passkeyName: string;
166
+ constructor(passkeyName: string);
167
+ }
168
+ declare class PasskeyRegistrationError extends SmartWalletSDKError {
169
+ passkeyName: string;
170
+ constructor(passkeyName: string);
171
+ }
172
+ declare class PasskeyIncompatibleAuthenticatorError extends SmartWalletSDKError {
173
+ passkeyName: string;
174
+ constructor(passkeyName: string);
175
+ }
161
176
  declare class OutOfCreditsError extends SmartWalletSDKError {
162
177
  constructor(message?: string);
163
178
  }
@@ -296,4 +311,4 @@ declare class SmartWalletSDK extends LoggerWrapper {
296
311
  getOrCreateWallet(user: UserParams, chain: SmartWalletChain, walletParams?: WalletParams): Promise<EVMSmartWallet>;
297
312
  }
298
313
 
299
- export { AdminAlreadyUsedError, AdminMismatchError, ConfigError, CrossmintServiceError, type EOASigner, type ERC20TransferType, EVMSmartWallet, JWTDecryptionError, JWTExpiredError, JWTIdentifierError, JWTInvalidError, type NFTTransferType, NonCustodialWalletsNotEnabledError, NotAuthorizedError, OutOfCreditsError, PasskeyMismatchError, type PasskeySigner, type SFTTransferType, SmartWalletChain, SmartWalletSDK, SmartWalletSDKError, type SmartWalletSDKInitParams, TransferError, type TransferType, type UserParams, UserWalletAlreadyCreatedError, type ViemAccount, type WalletParams };
314
+ export { AdminAlreadyUsedError, AdminMismatchError, ConfigError, CrossmintServiceError, type EOASigner, type ERC20TransferType, EVMSmartWallet, JWTDecryptionError, JWTExpiredError, JWTIdentifierError, JWTInvalidError, type NFTTransferType, NonCustodialWalletsNotEnabledError, NotAuthorizedError, OutOfCreditsError, PasskeyIncompatibleAuthenticatorError, PasskeyMismatchError, PasskeyPromptError, PasskeyRegistrationError, type PasskeySigner, type SFTTransferType, SmartWalletSDK, SmartWalletSDKError, type SmartWalletSDKInitParams, TransferError, type TransferType, type UserParams, UserWalletAlreadyCreatedError, type ViemAccount, type WalletParams };