@crossmint/client-sdk-smart-wallet 0.1.0 → 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.
package/dist/index.js.map CHANGED
@@ -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/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/BlockchainNetworks.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 { EVMBlockchainIncludingTestnet as Blockchain, 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\";\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 ZD_ETHEREUM_PROJECT_ID = \"9ee29857-8077-404b-9a9a-31eeea996a4a\";\nexport const ZD_POLYGON_PROJECT_ID = \"023d4a21-d801-4450-b629-24439ab1369d\";\nexport const ZD_BSC_PROJECT_ID = \"3d166617-da86-494b-9348-e8a13343bc04\";\nexport const ZD_OPTIMISM_PROJECT_ID = \"e9314f9e-a13d-414f-b965-c591a0248243\";\nexport const ZD_ARBITRUM_PROJECT_ID = \"1641cd99-c1ef-404a-9d26-a9dc67b1ba51\";\nexport const ZD_GOERLI_PROJECT_ID = \"3cfecfb6-9d7d-4ef6-acaa-ac8f79f6cd5a\";\nexport const ZD_SEPOLIA_PROJECT_ID = \"7ff22858-06f0-4f3a-8b46-5b41d8c75d0e\";\nexport const ZD_AMOY_PROJECT_ID = \"3b24773b-d91e-4c01-8ce5-04807463bbca\";\nexport const ZD_ZKATANA_PROJECT_ID = \"d54706a0-304b-419e-8a33-03c26ba3f0e9\";\nexport const ZD_ZKYOTO_PROJECT_ID = \"ce986d52-4f27-4a2b-b429-eb2322f15f32\";\nexport const ZD_ASTAR_PROJECT_ID = \"6204f336-643f-41af-94e1-f8d146c91675\";\nexport const ZD_BASE_SEPOLIA_PROJECT_ID = \"3eb830c5-f91b-48e0-bb7d-dc30103a60b2\";\nexport const ZD_OPTIMISM_SEPOLIA_PROJECT_ID = \"6188b92b-993e-4f39-be22-56e4806416a8\";\nexport const ZD_ARBITRUM_SEPOLIA_PROJECT_ID = \"8b8b6d1a-184c-4198-8f29-c07e63aad595\";\nexport const ZD_BASE_PROJECT_ID = \"5535aa3b-4f9c-45af-9c38-0072369564a3\";\nexport const ZD_ARBITRUM_NOVA_PROJECT_ID = \"b6a6db7c-65de-4f74-9d8f-f70d9c083531\";\nexport const RELAY_API_KEY = \"c8999b7e-8bb7-416d-a854-dac8632f9ee6_crossmint\";\nexport const SCW_SERVICE = \"SCW_SDK\";\nexport const SDK_VERSION = \"0.1.0\";\nexport const API_VERSION = \"2024-06-09\";\nexport const BUNDLER_RPC = \"https://rpc.zerodev.app/api/v2/bundler/\";\nexport const PAYMASTER_RPC = \"https://rpc.zerodev.app/api/v2/paymaster/\";\nexport const PM_BASE_SEPOLIA_RPC =\n \"https://api.developer.coinbase.com/rpc/v1/base-sepolia/6BTAmOQZ0x1YWtI24hIKKqdHWmVP1UXf\";\nexport const PM_BASE_RPC = \"https://api.developer.coinbase.com/rpc/v1/base/6BTAmOQZ0x1YWtI24hIKKqdHWmVP1UXf\";\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 { EVMBlockchainIncludingTestnet } from \"@crossmint/common-sdk-base\";\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 { 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: EVMBlockchainIncludingTestnet;\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: EVMBlockchainIncludingTestnet\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 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 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 { EVMBlockchainIncludingTestnet, validateAPIKey } from \"@crossmint/common-sdk-base\";\n\nimport { CrossmintWalletService } from \"./api/CrossmintWalletService\";\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: EVMBlockchainIncludingTestnet,\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 console.error(\"Error parsing response\", e);\n }\n\n throw new CrossmintServiceError(await response.text(), response.status);\n }\n}\n","import { SignerData, StoreSmartWalletParams } from \"@/types/API\";\nimport type { UserParams } from \"@/types/Config\";\nimport { API_VERSION } from \"@/utils/constants\";\n\nimport type { EVMBlockchainIncludingTestnet } from \"@crossmint/common-sdk-base\";\n\nimport { BaseCrossmintService } from \"./BaseCrossmintService\";\n\nexport { EVMBlockchainIncludingTestnet } from \"@crossmint/common-sdk-base\";\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: EVMBlockchainIncludingTestnet\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: EVMBlockchainIncludingTestnet) {\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 { EVMBlockchainIncludingTestnet } from \"@crossmint/common-sdk-base\";\n\nfunction isPolygonCDK(chain: EVMBlockchainIncludingTestnet) {\n const polygonCDKchains: EVMBlockchainIncludingTestnet[] = [\n EVMBlockchainIncludingTestnet.ZKYOTO,\n EVMBlockchainIncludingTestnet.ZKATANA,\n EVMBlockchainIncludingTestnet.ASTAR_ZKEVM,\n EVMBlockchainIncludingTestnet.HYPERSONIC_TESTNET,\n ];\n return polygonCDKchains.includes(chain);\n}\n\nexport function usesGelatoBundler(chain: EVMBlockchainIncludingTestnet) {\n return isPolygonCDK(chain);\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 { EVMBlockchainIncludingTestnet } from \"@crossmint/common-sdk-base\";\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: EVMBlockchainIncludingTestnet;\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: EVMBlockchainIncludingTestnet\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: EVMBlockchainIncludingTestnet, 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: EVMBlockchainIncludingTestnet,\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, EVMBlockchainIncludingTestnet } 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 { getBundlerRPC, getViemNetwork } from \"../BlockchainNetworks\";\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: EVMBlockchainIncludingTestnet,\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: getViemNetwork(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: EVMBlockchainIncludingTestnet\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 { EVMBlockchainIncludingTestnet } from \"@crossmint/common-sdk-base\";\n\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: EVMBlockchainIncludingTestnet;\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 {\n BUNDLER_RPC,\n PM_BASE_RPC,\n PM_BASE_SEPOLIA_RPC,\n ZD_AMOY_PROJECT_ID,\n ZD_ARBITRUM_NOVA_PROJECT_ID,\n ZD_ARBITRUM_PROJECT_ID,\n ZD_ARBITRUM_SEPOLIA_PROJECT_ID,\n ZD_ASTAR_PROJECT_ID,\n ZD_BASE_PROJECT_ID,\n ZD_BASE_SEPOLIA_PROJECT_ID,\n ZD_BSC_PROJECT_ID,\n ZD_ETHEREUM_PROJECT_ID,\n ZD_GOERLI_PROJECT_ID,\n ZD_OPTIMISM_PROJECT_ID,\n ZD_OPTIMISM_SEPOLIA_PROJECT_ID,\n ZD_POLYGON_PROJECT_ID,\n ZD_SEPOLIA_PROJECT_ID,\n ZD_ZKATANA_PROJECT_ID,\n ZD_ZKYOTO_PROJECT_ID,\n} from \"@/utils/constants\";\nimport {\n arbitrum,\n arbitrumNova,\n arbitrumSepolia,\n astarZkEVM,\n astarZkyoto,\n base,\n baseSepolia,\n bsc,\n goerli,\n mainnet,\n optimism,\n optimismSepolia,\n polygon,\n polygonAmoy,\n sepolia,\n} from \"viem/chains\";\n\nimport { EVMBlockchainIncludingTestnet } from \"@crossmint/common-sdk-base\";\n\nexport const getZeroDevProjectIdByBlockchain = (chain: EVMBlockchainIncludingTestnet) => {\n const zeroDevProjectId = new Map<EVMBlockchainIncludingTestnet, string | null>([\n [\"ethereum\", ZD_ETHEREUM_PROJECT_ID],\n [\"polygon\", ZD_POLYGON_PROJECT_ID],\n [\"bsc\", ZD_BSC_PROJECT_ID],\n [\"optimism\", ZD_OPTIMISM_PROJECT_ID],\n [\"arbitrum\", ZD_ARBITRUM_PROJECT_ID],\n [\"ethereum-goerli\", ZD_GOERLI_PROJECT_ID],\n [\"ethereum-sepolia\", ZD_SEPOLIA_PROJECT_ID],\n [\"polygon-amoy\", ZD_AMOY_PROJECT_ID],\n [\"zkatana\", ZD_ZKATANA_PROJECT_ID],\n [\"zkyoto\", ZD_ZKYOTO_PROJECT_ID],\n [\"arbitrum-sepolia\", ZD_ARBITRUM_SEPOLIA_PROJECT_ID],\n [\"base-goerli\", null],\n [\"base-sepolia\", ZD_BASE_SEPOLIA_PROJECT_ID],\n [\"bsc-testnet\", null],\n [\"optimism-goerli\", null],\n [\"optimism-sepolia\", ZD_OPTIMISM_SEPOLIA_PROJECT_ID],\n [\"zora-goerli\", null],\n [\"zora-sepolia\", null],\n [\"base\", ZD_BASE_PROJECT_ID],\n [\"zora\", null],\n [\"arbitrumnova\", ZD_ARBITRUM_NOVA_PROJECT_ID],\n [\"astar-zkevm\", ZD_ASTAR_PROJECT_ID],\n [\"apex\", null],\n ]).get(chain)!;\n\n if (zeroDevProjectId == null) {\n throw new Error(`ZeroDev project id not found for chain ${chain}`);\n }\n return zeroDevProjectId;\n};\n\nexport const getViemNetwork = (cmChain: EVMBlockchainIncludingTestnet) => {\n switch (cmChain) {\n case \"ethereum\":\n return mainnet;\n case \"ethereum-goerli\":\n return goerli;\n case \"ethereum-sepolia\":\n return sepolia;\n case \"polygon\":\n return polygon;\n case \"polygon-amoy\":\n return polygonAmoy;\n case \"optimism\":\n return optimism;\n case \"optimism-sepolia\":\n return optimismSepolia;\n case \"arbitrum\":\n return arbitrum;\n case \"arbitrumnova\":\n return arbitrumNova;\n case \"arbitrum-sepolia\":\n return arbitrumSepolia;\n case \"base\":\n return base;\n case \"base-sepolia\":\n return baseSepolia;\n case \"zkyoto\":\n return astarZkyoto;\n case \"astar-zkevm\":\n return astarZkEVM;\n case \"bsc\":\n return bsc;\n default:\n throw new Error(`Unsupported network: ${cmChain}`);\n }\n};\n\nexport const getBundlerRPC = (chain: EVMBlockchainIncludingTestnet) => {\n switch (chain) {\n case EVMBlockchainIncludingTestnet.BASE_SEPOLIA:\n return PM_BASE_SEPOLIA_RPC;\n case EVMBlockchainIncludingTestnet.BASE:\n return PM_BASE_RPC;\n default:\n return BUNDLER_RPC + getZeroDevProjectIdByBlockchain(chain) + \"?bundlerProvider=STACKUP\";\n }\n};\n","import { providerToSmartAccountSigner } from \"permissionless\";\nimport type { SmartAccountSigner } from \"permissionless/accounts\";\nimport { Address, EIP1193Provider } from \"viem\";\n\nimport { EVMBlockchainIncludingTestnet } from \"@crossmint/common-sdk-base\";\n\nimport { SmartWalletSDKError } from \"../error\";\nimport { ViemAccount, WalletParams } from \"../types/Config\";\nimport { logInputOutput } from \"./log\";\n\ntype CreateOwnerSignerInput = {\n chain: EVMBlockchainIncludingTestnet;\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, PM_BASE_RPC, PM_BASE_SEPOLIA_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 { EVMBlockchainIncludingTestnet } from \"@crossmint/common-sdk-base\";\n\nimport { usesGelatoBundler } from \"../../utils/blockchain\";\nimport { getViemNetwork, getZeroDevProjectIdByBlockchain } from \"../BlockchainNetworks\";\n\nexport function usePaymaster(chain: EVMBlockchainIncludingTestnet) {\n return !usesGelatoBundler(chain);\n}\n\nconst getPaymasterRPC = (chain: EVMBlockchainIncludingTestnet) => {\n switch (chain) {\n case EVMBlockchainIncludingTestnet.BASE_SEPOLIA:\n return PM_BASE_SEPOLIA_RPC;\n case EVMBlockchainIncludingTestnet.BASE:\n return PM_BASE_RPC;\n default:\n return PAYMASTER_RPC + getZeroDevProjectIdByBlockchain(chain) + \"?paymasterProvider=STACKUP\";\n }\n};\n\nexport function paymasterMiddleware({\n entryPoint,\n chain,\n}: {\n entryPoint: EntryPoint;\n chain: EVMBlockchainIncludingTestnet;\n}): Middleware<EntryPoint> {\n return {\n middleware: {\n sponsorUserOperation: async ({ userOperation }) => {\n const paymasterClient = createZeroDevPaymasterClient({\n chain: getViemNetwork(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":"0oBAAA,OAA0C,iCAAjCA,GAA6C,uBAAAC,OAA2B,6BCA1E,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,EAAN,KAAwD,CAC3D,QAAQC,EAAiBC,EAAkB,CACnCH,IACA,QAAQ,IAAIE,EAASC,CAAO,CAEpC,CAEA,SAASD,EAAiBC,EAAkB,CACpCH,IACA,QAAQ,MAAME,EAASC,CAAO,CAEtC,CAEA,QAAQD,EAAiBC,EAAkB,CACnCH,IACA,QAAQ,KAAKE,EAASC,CAAO,CAErC,CACJ,ECvBO,IAAMC,GAAgB,UAEtB,IAAMC,GAAuB,sCACvBC,GAAoB,4BACpBC,GAAoB,oCACpBC,GAAqB,gCACrBC,GAAyB,uCACzBC,GAAwB,uCACxBC,GAAoB,uCACpBC,GAAyB,uCACzBC,GAAyB,uCACzBC,GAAuB,uCACvBC,GAAwB,uCACxBC,GAAqB,uCACrBC,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O,SAAS,2BAA2BI,CAAO,GAAI,CACvD,MAAOJ,aAAiB,MAAQA,EAAM,MAAQ,OAC9C,KAAMA,aAAiB,MAAQA,EAAM,KAAO,eAC5C,QAASK,GAAUL,CAAK,EACxB,OAAQ,OAAO,SAAS,SACxB,YAAaM,EACjB,CAAC,CACL,CACJ,EdpBO,IAAMC,GAAN,MAAMC,UAAuBC,CAAc,CACtC,YACaC,EACAC,EACnB,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,CADqBC,GAAeH,CAAY,EAC9B,QAClB,MAAM,IAAI,MAAM,iBAAiB,EAGrC,IAAMI,EAAmB,IAAIC,EAAuBL,CAAY,EAC1DD,EAAiB,IAAIO,GAAe,IAAIC,CAAiB,EAC/D,OAAO,IAAIX,EACP,IAAIY,GAAmBJ,EAAkB,IAAIK,GAAgBV,CAAc,CAAC,EAC5EA,CACJ,CACJ,CAWM,kBACFW,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,IAAIf,EAAoB,2BAA2Be,EAAM,OAAO,IAAKC,GAAUD,CAAK,CAAC,CACzF,CACJ,CACJ,GACA,CAAE,KAAAJ,EAAM,MAAAC,CAAM,CAClB,CACJ,GACJ","names":["EVMBlockchainIncludingTestnet","blockchainToChainId","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","ZD_ETHEREUM_PROJECT_ID","ZD_POLYGON_PROJECT_ID","ZD_BSC_PROJECT_ID","ZD_OPTIMISM_PROJECT_ID","ZD_ARBITRUM_PROJECT_ID","ZD_GOERLI_PROJECT_ID","ZD_SEPOLIA_PROJECT_ID","ZD_AMOY_PROJECT_ID","ZD_ZKATANA_PROJECT_ID","ZD_ZKYOTO_PROJECT_ID","ZD_ASTAR_PROJECT_ID","ZD_BASE_SEPOLIA_PROJECT_ID","ZD_OPTIMISM_SEPOLIA_PROJECT_ID","ZD_ARBITRUM_SEPOLIA_PROJECT_ID","ZD_BASE_PROJECT_ID","ZD_ARBITRUM_NOVA_PROJECT_ID","SCW_SERVICE","SDK_VERSION","API_VERSION","BUNDLER_RPC","PAYMASTER_RPC","PM_BASE_SEPOLIA_RPC","PM_BASE_RPC","datadogLogs","DatadogProvider","message","context","log","loggerType","contextParam","_context","__spreadProps","__spreadValues","SCW_SERVICE","init","datadogLogs","DATADOG_CLIENT_TOKEN","getBrowserLogger","isClient","isLocalhost","ConsoleProvider","DatadogProvider","logInfo","logWarn","logError","isAddress","publicActions","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","uuidv4","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","erc20Abi","erc721Abi","ERC1155_default","transferParams","contract","config","from","to","erc20Abi","ERC1155_default","erc721Abi","EVMSmartWallet","LoggerWrapper","crossmintService","accountClient","publicClient","chain","toAddress","config","__async","isAddress","tx","transferParams","client","publicActions","request","error","logError","SCW_SERVICE","errorToJSON","tokenIdString","TransferError","stringify","validateAPIKey","validateAPIKey","APIErrorService","errors","JWTInvalidError","JWTDecryptionError","expiredAt","JWTExpiredError","identifierKey","JWTIdentifierError","userId","UserWalletAlreadyCreatedError","AdminAlreadyUsedError","NonCustodialWalletsNotEnabledError","_0","__async","response","onServerErrorMessage","CrossmintServiceError","OutOfCreditsError","body","code","e","_BaseCrossmintService","LoggerWrapper","apiKey","result","validateAPIKey","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","EVMBlockchainIncludingTestnet","CrossmintWalletService","BaseCrossmintService","user","input","__async","API_VERSION","chain","address","EVMBlockchainIncludingTestnet","isPolygonCDK","chain","usesGelatoBundler","stringify","transactionMethods","signingMethods","isTxnMethod","method","isSignMethod","ClientDecorator","errorProcessor","crossmintChain","smartAccountClient","target","prop","receiver","originalMethod","args","logPerformance","__async","logInfo","stringify","processed","error","description","SmartWalletSDKError","userOperation","middleware","account","txn","txnParams","usesGelatoBundler","__spreadProps","__spreadValues","displayPasskey","data","createKernelAccountClient","ENTRYPOINT_ADDRESS_V06","ENTRYPOINT_ADDRESS_V07","createPublicClient","getAddress","http","blockchainToChainId","SUPPORTED_KERNEL_VERSIONS","isSupportedKernelVersion","version","SUPPORTED_ENTRYPOINT_VERSIONS","isSupportedEntryPointVersion","arbitrum","arbitrumNova","arbitrumSepolia","astarZkEVM","astarZkyoto","base","baseSepolia","bsc","goerli","mainnet","optimism","optimismSepolia","polygon","polygonAmoy","sepolia","EVMBlockchainIncludingTestnet","getZeroDevProjectIdByBlockchain","chain","zeroDevProjectId","ZD_ETHEREUM_PROJECT_ID","ZD_POLYGON_PROJECT_ID","ZD_BSC_PROJECT_ID","ZD_OPTIMISM_PROJECT_ID","ZD_ARBITRUM_PROJECT_ID","ZD_GOERLI_PROJECT_ID","ZD_SEPOLIA_PROJECT_ID","ZD_AMOY_PROJECT_ID","ZD_ZKATANA_PROJECT_ID","ZD_ZKYOTO_PROJECT_ID","ZD_ARBITRUM_SEPOLIA_PROJECT_ID","ZD_BASE_SEPOLIA_PROJECT_ID","ZD_OPTIMISM_SEPOLIA_PROJECT_ID","ZD_BASE_PROJECT_ID","ZD_ARBITRUM_NOVA_PROJECT_ID","ZD_ASTAR_PROJECT_ID","getViemNetwork","cmChain","getBundlerRPC","PM_BASE_SEPOLIA_RPC","PM_BASE_RPC","BUNDLER_RPC","providerToSmartAccountSigner","createOwnerSigner","logInputOutput","_0","__async","walletParams","isEIP1193Provider","providerToSmartAccountSigner","isAccount","signer","SmartWalletSDKError","signerToEcdsaValidator","createKernelAccount","EOAAccountService","_0","_1","__async","chain","publicClient","entryPoint","walletParams","kernelVersion","user","existingSignerConfig","eoa","createOwnerSigner","equalsIgnoreCase","AdminMismatchError","ecdsaValidator","signerToEcdsaValidator","createKernelAccount","PasskeyValidatorContractVersion","WebAuthnMode","toPasskeyValidator","createKernelAccount","toWebAuthnKey","isPasskeyParams","params","PasskeyAccountService","crossmintService","_0","_1","__async","user","publicClient","walletParams","entryPoint","kernelVersion","existingSignerConfig","_a","inputPasskeyName","PasskeyMismatchError","displayPasskey","passkey","latestValidatorVersion","PasskeyValidatorContractVersion","validatorContractVersion","validator","toPasskeyValidator","kernelAccount","createKernelAccount","passkeyName","existing","toWebAuthnKey","WebAuthnMode","__spreadProps","__spreadValues","deserializePasskeyValidatorData","uint8Array","base64ToBytes","jsonString","base64","binString","m","createZeroDevPaymasterClient","http","EVMBlockchainIncludingTestnet","usePaymaster","chain","usesGelatoBundler","getPaymasterRPC","EVMBlockchainIncludingTestnet","PM_BASE_SEPOLIA_RPC","PM_BASE_RPC","PAYMASTER_RPC","getZeroDevProjectIdByBlockchain","paymasterMiddleware","entryPoint","_0","__async","userOperation","createZeroDevPaymasterClient","getViemNetwork","http","SmartWalletService","crossmintWalletService","clientDecorator","accountFactory","AccountFactory","EOAAccountService","PasskeyAccountService","user","chain","walletParams","__async","entryPoint","kernelVersion","existingSignerConfig","smartContractWalletAddress","userId","publicClient","createPublicClient","http","getBundlerRPC","account","signerData","__spreadProps","__spreadValues","equalsIgnoreCase","UserWalletAlreadyCreatedError","ZERO_DEV_TYPE","blockchainToChainId","kernelAccountClient","createKernelAccountClient","getViemNetwork","usePaymaster","paymasterMiddleware","smartAccountClient","EVMSmartWallet","entryPointVersion","signers","isSupportedKernelVersion","SmartWalletSDKError","SUPPORTED_KERNEL_VERSIONS","isSupportedEntryPointVersion","SUPPORTED_ENTRYPOINT_VERSIONS","ENTRYPOINT_ADDRESS_V06","ENTRYPOINT_ADDRESS_V07","getAddress","CrossmintServiceError","eoa","passkey","params","isPasskeyParams","AdminMismatchError","displayPasskey","BaseError","stringify","ErrorProcessor","logger","error","fallback","SmartWalletSDKError","BaseError","message","stringify","SDK_VERSION","SmartWalletSDK","_SmartWalletSDK","LoggerWrapper","smartWalletService","errorProcessor","clientApiKey","isClient","SmartWalletSDKError","validateAPIKey","crossmintService","CrossmintWalletService","ErrorProcessor","DatadogProvider","SmartWalletService","ClientDecorator","_0","_1","__async","user","chain","walletParams","logPerformance","error","stringify"]}
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":"0oBAAA,OAAS,uBAAAA,GAAsD,iCAAjCC,OAA8C,6BCArE,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,EAAN,KAAwD,CAC3D,QAAQC,EAAiBC,EAAkB,CACnCH,IACA,QAAQ,IAAIE,EAASC,CAAO,CAEpC,CAEA,SAASD,EAAiBC,EAAkB,CACpCH,IACA,QAAQ,MAAME,EAASC,CAAO,CAEtC,CAEA,QAAQD,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,2BAA2BI,CAAO,GAAI,CACvD,MAAOJ,aAAiB,MAAQA,EAAM,MAAQ,OAC9C,KAAMA,aAAiB,MAAQA,EAAM,KAAO,eAC5C,QAASK,GAAUL,CAAK,EACxB,OAAQ,OAAO,SAAS,SACxB,YAAaM,EACjB,CAAC,CACL,CACJ,EdnBO,IAAMC,GAAN,MAAMC,UAAuBC,CAAc,CACtC,YACaC,EACAC,EACnB,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,CADqBC,GAAeH,CAAY,EAC9B,QAClB,MAAM,IAAI,MAAM,iBAAiB,EAGrC,IAAMI,EAAmB,IAAIC,EAAuBL,CAAY,EAC1DD,EAAiB,IAAIO,GAAe,IAAIC,CAAiB,EAC/D,OAAO,IAAIX,EACP,IAAIY,GAAmBJ,EAAkB,IAAIK,GAAgBV,CAAc,CAAC,EAC5EA,CACJ,CACJ,CAWM,kBACFW,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,IAAIf,EAAoB,2BAA2Be,EAAM,OAAO,IAAKC,GAAUD,CAAK,CAAC,CACzF,CACJ,CACJ,GACA,CAAE,KAAAJ,EAAM,MAAAC,CAAM,CAClB,CACJ,GACJ","names":["blockchainToChainId","EVMBlockchainIncludingTestnet","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","datadogLogs","DatadogProvider","message","context","log","loggerType","contextParam","_context","__spreadProps","__spreadValues","SCW_SERVICE","init","datadogLogs","DATADOG_CLIENT_TOKEN","getBrowserLogger","isClient","isLocalhost","ConsoleProvider","DatadogProvider","logInfo","logWarn","logError","isAddress","publicActions","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","uuidv4","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","erc20Abi","erc721Abi","ERC1155_default","transferParams","contract","config","from","to","erc20Abi","ERC1155_default","erc721Abi","EVMSmartWallet","LoggerWrapper","crossmintService","accountClient","publicClient","chain","toAddress","config","__async","isAddress","tx","transferParams","client","publicActions","request","error","logError","SCW_SERVICE","errorToJSON","tokenIdString","TransferError","stringify","validateAPIKey","validateAPIKey","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","validateAPIKey","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","stringify","transactionMethods","signingMethods","isTxnMethod","method","isSignMethod","ClientDecorator","errorProcessor","crossmintChain","smartAccountClient","target","prop","receiver","originalMethod","args","logPerformance","__async","logInfo","stringify","processed","error","description","SmartWalletSDKError","userOperation","middleware","account","txn","txnParams","usesGelatoBundler","__spreadProps","__spreadValues","displayPasskey","data","createKernelAccountClient","ENTRYPOINT_ADDRESS_V06","ENTRYPOINT_ADDRESS_V07","createPublicClient","getAddress","http","blockchainToChainId","SUPPORTED_KERNEL_VERSIONS","isSupportedKernelVersion","version","SUPPORTED_ENTRYPOINT_VERSIONS","isSupportedEntryPointVersion","base","baseSepolia","polygon","polygonAmoy","Blockchain","objectValues","SmartWalletTestnet","Blockchain","SMART_WALLET_TESTNETS","objectValues","SmartWalletMainnet","SMART_WALLET_MAINNETS","SmartWalletChain","__spreadValues","SMART_WALLET_CHAINS","zerodevProjects","viemNetworks","polygon","polygonAmoy","base","baseSepolia","getBundlerRPC","chain","BUNDLER_RPC","providerToSmartAccountSigner","createOwnerSigner","logInputOutput","_0","__async","walletParams","isEIP1193Provider","providerToSmartAccountSigner","isAccount","signer","SmartWalletSDKError","signerToEcdsaValidator","createKernelAccount","EOAAccountService","_0","_1","__async","chain","publicClient","entryPoint","walletParams","kernelVersion","user","existingSignerConfig","eoa","createOwnerSigner","equalsIgnoreCase","AdminMismatchError","ecdsaValidator","signerToEcdsaValidator","createKernelAccount","PasskeyValidatorContractVersion","WebAuthnMode","toPasskeyValidator","createKernelAccount","toWebAuthnKey","isPasskeyParams","params","PasskeyAccountService","crossmintService","_0","_1","__async","user","publicClient","walletParams","entryPoint","kernelVersion","existingSignerConfig","_a","inputPasskeyName","PasskeyMismatchError","displayPasskey","passkey","latestValidatorVersion","PasskeyValidatorContractVersion","validatorContractVersion","validator","toPasskeyValidator","kernelAccount","createKernelAccount","error","passkeyName","existing","toWebAuthnKey","WebAuthnMode","__spreadProps","__spreadValues","deserializePasskeyValidatorData","PasskeyIncompatibleAuthenticatorError","PasskeyRegistrationError","PasskeyPromptError","account","target","prop","receiver","original","isAccountSigningMethod","args","accountSigningMethods","method","uint8Array","base64ToBytes","jsonString","base64","binString","m","createZeroDevPaymasterClient","http","usePaymaster","chain","usesGelatoBundler","getPaymasterRPC","PAYMASTER_RPC","zerodevProjects","paymasterMiddleware","entryPoint","_0","__async","userOperation","createZeroDevPaymasterClient","viemNetworks","http","SmartWalletService","crossmintWalletService","clientDecorator","accountFactory","AccountFactory","EOAAccountService","PasskeyAccountService","user","chain","walletParams","__async","entryPoint","kernelVersion","existingSignerConfig","smartContractWalletAddress","userId","publicClient","createPublicClient","http","getBundlerRPC","account","signerData","__spreadProps","__spreadValues","equalsIgnoreCase","UserWalletAlreadyCreatedError","ZERO_DEV_TYPE","blockchainToChainId","kernelAccountClient","createKernelAccountClient","viemNetworks","usePaymaster","paymasterMiddleware","smartAccountClient","EVMSmartWallet","entryPointVersion","signers","isSupportedKernelVersion","SmartWalletSDKError","SUPPORTED_KERNEL_VERSIONS","isSupportedEntryPointVersion","SUPPORTED_ENTRYPOINT_VERSIONS","ENTRYPOINT_ADDRESS_V06","ENTRYPOINT_ADDRESS_V07","getAddress","CrossmintServiceError","eoa","passkey","params","isPasskeyParams","AdminMismatchError","displayPasskey","BaseError","stringify","ErrorProcessor","logger","error","fallback","SmartWalletSDKError","BaseError","message","stringify","SDK_VERSION","SmartWalletSDK","_SmartWalletSDK","LoggerWrapper","smartWalletService","errorProcessor","clientApiKey","isClient","SmartWalletSDKError","validateAPIKey","crossmintService","CrossmintWalletService","ErrorProcessor","DatadogProvider","SmartWalletService","ClientDecorator","_0","_1","__async","user","chain","walletParams","logPerformance","error","stringify"]}