@crossmint/client-sdk-smart-wallet 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +4 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +262 -112
- package/dist/index.d.ts +262 -112
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -11
- package/src/SmartWalletSDK.test.ts +12 -13
- package/src/SmartWalletSDK.ts +33 -26
- package/src/api/APIErrorService.ts +10 -7
- package/src/api/BaseCrossmintService.ts +3 -4
- package/src/api/CrossmintWalletService.test.ts +9 -9
- package/src/api/CrossmintWalletService.ts +39 -16
- package/src/blockchain/chains.ts +25 -2
- package/src/blockchain/transfer.ts +1 -1
- package/src/blockchain/wallets/EVMSmartWallet.ts +49 -42
- package/src/blockchain/wallets/account/config.ts +60 -0
- package/src/blockchain/wallets/account/creator.ts +36 -0
- package/src/blockchain/wallets/account/eoa.ts +50 -0
- package/src/blockchain/wallets/account/passkey.ts +172 -0
- package/src/blockchain/wallets/account/signer.ts +44 -0
- package/src/blockchain/wallets/account/strategy.ts +5 -0
- package/src/blockchain/wallets/clientDecorator.ts +6 -6
- package/src/blockchain/wallets/paymaster.ts +12 -15
- package/src/blockchain/wallets/service.ts +38 -143
- package/src/error/index.ts +45 -95
- package/src/error/processor.ts +5 -6
- package/src/index.ts +20 -14
- package/src/services/logging/ConsoleProvider.ts +3 -12
- package/src/services/logging/DatadogProvider.ts +1 -1
- package/src/types/internal.ts +42 -21
- package/src/types/{Config.ts → params.ts} +0 -5
- package/src/types/schema.ts +63 -0
- package/src/types/service.ts +31 -0
- package/src/types/{Tokens.ts → token.ts} +1 -1
- package/src/utils/api.ts +39 -0
- package/src/utils/blockchain.ts +1 -1
- package/src/utils/constants.ts +2 -0
- package/src/utils/log.ts +1 -109
- package/src/utils/signer.ts +15 -17
- package/src/blockchain/token/index.ts +0 -1
- package/src/blockchain/wallets/eoa.ts +0 -49
- package/src/blockchain/wallets/passkey.ts +0 -117
- package/src/types/API.ts +0 -40
- package/src/utils/log.test.ts +0 -76
package/dist/index.cjs.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/blockchain/chains.ts","../src/SmartWalletSDK.ts","../src/api/BaseCrossmintService.ts","../src/api/APIErrorService.ts","../src/api/CrossmintWalletService.ts","../src/utils/blockchain.ts","../src/blockchain/wallets/clientDecorator.ts","../src/types/API.ts","../src/blockchain/wallets/service.ts","../src/types/internal.ts","../src/utils/signer.ts","../src/blockchain/wallets/eoa.ts","../src/blockchain/wallets/passkey.ts","../src/blockchain/wallets/paymaster.ts","../src/error/processor.ts"],"sourcesContent":["export { blockchainToChainId } from \"@crossmint/common-sdk-base\";\n\nexport { EVMSmartWallet } from \"./blockchain/wallets/EVMSmartWallet\";\n\nexport type {\n SmartWalletSDKInitParams,\n UserParams,\n ViemAccount,\n PasskeySigner,\n EOASigner,\n WalletParams,\n} from \"./types/Config\";\n\nexport type { TransferType, ERC20TransferType, NFTTransferType, SFTTransferType } from \"./types/Tokens\";\nexport { SmartWalletChain } from \"./blockchain/chains\";\n\nexport {\n TransferError,\n CrossmintServiceError,\n SmartWalletSDKError,\n JWTDecryptionError,\n JWTExpiredError,\n JWTIdentifierError,\n JWTInvalidError,\n NotAuthorizedError,\n UserWalletAlreadyCreatedError,\n OutOfCreditsError,\n AdminAlreadyUsedError,\n AdminMismatchError,\n PasskeyMismatchError,\n ConfigError,\n NonCustodialWalletsNotEnabledError,\n} from \"./error\";\n\nexport { SmartWalletSDK } from \"./SmartWalletSDK\";\n","export function isClient() {\n return typeof window !== \"undefined\";\n}\n","export function isLocalhost() {\n if (process.env.NODE_ENV === \"test\") {\n return false;\n }\n\n return window.location.origin.includes(\"localhost\");\n}\n\nexport function isEmpty(str: string | undefined | null): str is undefined | null {\n return !str || str.length === 0 || str.trim().length === 0;\n}\n\nexport function equalsIgnoreCase(a?: string, b?: string): boolean {\n return a?.toLowerCase() === b?.toLowerCase();\n}\n","import { BrowserLoggerInterface } from \"./BrowserLoggerInterface\";\n\n// Set to true to enable logging on local development\nconst LOG_IN_LOCALHOST = false;\n\nexport class ConsoleProvider implements BrowserLoggerInterface {\n logInfo(message: string, context?: object) {\n if (LOG_IN_LOCALHOST) {\n console.log(message, context);\n }\n }\n\n logError(message: string, context?: object) {\n if (LOG_IN_LOCALHOST) {\n console.error(message, context);\n }\n }\n\n logWarn(message: string, context?: object) {\n if (LOG_IN_LOCALHOST) {\n console.warn(message, context);\n }\n }\n}\n","export const ZERO_DEV_TYPE = \"ZeroDev\";\nexport const CURRENT_VERSION = 0;\nexport const DATADOG_CLIENT_TOKEN = \"pub035be8a594b35be1887b6ba76c4029ca\";\nexport const CROSSMINT_DEV_URL = \"http://localhost:3000/api\";\nexport const CROSSMINT_STG_URL = \"https://staging.crossmint.com/api\";\nexport const CROSSMINT_PROD_URL = \"https://www.crossmint.com/api\";\nexport const SCW_SERVICE = \"SCW_SDK\";\nexport const SDK_VERSION = \"0.1.0\";\nexport const API_VERSION = \"2024-06-09\";\nexport const BUNDLER_RPC = \"https://rpc.zerodev.app/api/v2/bundler/\";\nexport const PAYMASTER_RPC = \"https://rpc.zerodev.app/api/v2/paymaster/\";\n","import { DATADOG_CLIENT_TOKEN, SCW_SERVICE } from \"@/utils/constants\";\nimport { datadogLogs } from \"@datadog/browser-logs\";\n\nimport { BrowserLoggerInterface } from \"./BrowserLoggerInterface\";\n\nexport class DatadogProvider implements BrowserLoggerInterface {\n logInfo(message: string, context?: object) {\n log(message, \"info\", context);\n }\n\n logError(message: string, context?: object) {\n log(message, \"error\", context);\n }\n\n logWarn(message: string, context?: object) {\n log(message, \"warn\", context);\n }\n}\n\nfunction log(message: string, loggerType: \"info\" | \"error\" | \"warn\", contextParam?: object) {\n const _context = contextParam ? { ...contextParam, service: SCW_SERVICE } : { service: SCW_SERVICE };\n\n init();\n datadogLogs.logger[loggerType](message, _context);\n}\n\nfunction init() {\n const isDatadogInitialized = datadogLogs.getInternalContext() != null;\n if (isDatadogInitialized) {\n return;\n }\n\n datadogLogs.init({\n clientToken: DATADOG_CLIENT_TOKEN,\n site: \"datadoghq.com\",\n forwardErrorsToLogs: false,\n sampleRate: 100,\n });\n}\n","import { isClient } from \"../../utils/environment\";\nimport { isLocalhost } from \"../../utils/helpers\";\nimport { ConsoleProvider } from \"./ConsoleProvider\";\nimport { DatadogProvider } from \"./DatadogProvider\";\n\nfunction getBrowserLogger() {\n if (isClient() && isLocalhost()) {\n return new ConsoleProvider();\n }\n\n return new DatadogProvider();\n}\n\nconst { logInfo, logWarn, logError } = getBrowserLogger();\n\nexport { logInfo, logWarn, logError };\n","import { logError } from \"@/services/logging\";\nimport { type HttpTransport, type PublicClient, isAddress, publicActions } from \"viem\";\n\nimport type { CrossmintWalletService } from \"../../api/CrossmintWalletService\";\nimport { TransferError } from \"../../error\";\nimport type { TransferType } from \"../../types/Tokens\";\nimport { SmartWalletClient } from \"../../types/internal\";\nimport { SCW_SERVICE } from \"../../utils/constants\";\nimport { LoggerWrapper, errorToJSON } from \"../../utils/log\";\nimport { SmartWalletChain } from \"../chains\";\nimport { transferParams } from \"../transfer\";\n\n/**\n * Smart wallet interface for EVM chains enhanced with Crossmint capabilities.\n * Core functionality is exposed via [viem](https://viem.sh/) clients within the `client` property of the class.\n */\nexport class EVMSmartWallet extends LoggerWrapper {\n public readonly chain: SmartWalletChain;\n\n /**\n * [viem](https://viem.sh/) clients that provide an interface for core wallet functionality.\n */\n public readonly client: {\n /**\n * An interface to interact with the smart wallet, execute transactions, sign messages, etc.\n */\n wallet: SmartWalletClient;\n\n /**\n * An interface to read onchain data, fetch transactions, retrieve account balances, etc. Corresponds to public [JSON-RPC API](https://ethereum.org/en/developers/docs/apis/json-rpc/) methods.\n */\n public: PublicClient;\n };\n\n constructor(\n private readonly crossmintService: CrossmintWalletService,\n private readonly accountClient: SmartWalletClient,\n publicClient: PublicClient<HttpTransport>,\n chain: SmartWalletChain\n ) {\n super(\"EVMSmartWallet\", { chain, address: accountClient.account.address });\n this.chain = chain;\n this.client = {\n wallet: accountClient,\n public: publicClient,\n };\n }\n\n /**\n * The address of the smart wallet.\n */\n public get address() {\n return this.accountClient.account.address;\n }\n\n /**\n * @returns The transaction hash.\n */\n public async transferToken(toAddress: string, config: TransferType): Promise<string> {\n return this.logPerformance(\"TRANSFER\", async () => {\n if (this.chain !== config.token.chain) {\n throw new Error(\n `Chain mismatch: Expected ${config.token.chain}, but got ${this.chain}. Ensure you are interacting with the correct blockchain.`\n );\n }\n\n if (!isAddress(toAddress)) {\n throw new Error(`Invalid recipient address: '${toAddress}' is not a valid EVM address.`);\n }\n\n if (!isAddress(config.token.contractAddress)) {\n throw new Error(\n `Invalid contract address: '${config.token.contractAddress}' is not a valid EVM address.`\n );\n }\n\n const tx = transferParams({\n contract: config.token.contractAddress,\n to: toAddress,\n from: this.accountClient.account,\n config,\n });\n\n try {\n const client = this.accountClient.extend(publicActions);\n const { request } = await client.simulateContract(tx);\n return await client.writeContract(request);\n } catch (error) {\n logError(\"[TRANSFER] - ERROR_TRANSFERRING_TOKEN\", {\n service: SCW_SERVICE,\n error: errorToJSON(error),\n tokenId: tx.tokenId,\n contractAddress: config.token.contractAddress,\n chain: config.token.chain,\n });\n const tokenIdString = tx.tokenId == null ? \"\" : `:${tx.tokenId}}`;\n throw new TransferError(`Error transferring token ${config.token.contractAddress}${tokenIdString}`);\n }\n });\n }\n\n /**\n * @returns A list of NFTs owned by the wallet.\n */\n public async nfts() {\n return this.crossmintService.fetchNFTs(this.address, this.chain);\n }\n}\n","import { PasskeyDisplay, SignerDisplay } from \"@/types/API\";\n\nexport const SmartWalletErrors = {\n NOT_AUTHORIZED: \"smart-wallet:not-authorized\",\n TRANSFER: \"smart-wallet:transfer.error\",\n CROSSMINT_SERVICE: \"smart-wallet:crossmint-service.error\",\n ERROR_JWT_EXPIRED: \"smart-wallet:not-authorized.jwt-expired\",\n ERROR_JWT_INVALID: \"smart-wallet:not-authorized.jwt-invalid\",\n ERROR_JWT_DECRYPTION: \"smart-wallet:not-authorized.jwt-decryption\",\n ERROR_JWT_IDENTIFIER: \"smart-wallet:not-authorized.jwt-identifier\",\n ERROR_USER_WALLET_ALREADY_CREATED: \"smart-wallet:user-wallet-already-created.error\",\n ERROR_OUT_OF_CREDITS: \"smart-wallet:out-of-credits.error\",\n ERROR_WALLET_CONFIG: \"smart-wallet:wallet-config.error\",\n ERROR_ADMIN_MISMATCH: \"smart-wallet:wallet-config.admin-mismatch\",\n ERROR_PASSKEY_MISMATCH: \"smart-wallet:wallet-config.passkey-mismatch\",\n ERROR_ADMIN_SIGNER_ALREADY_USED: \"smart-wallet:wallet-config.admin-signer-already-used\",\n ERROR_PROJECT_NONCUSTODIAL_WALLETS_NOT_ENABLED: \"smart-wallet:wallet-config.non-custodial-wallets-not-enabled\",\n UNCATEGORIZED: \"smart-wallet:uncategorized\", // catch-all error code\n} as const;\nexport type SmartWalletErrorCode = (typeof SmartWalletErrors)[keyof typeof SmartWalletErrors];\n\nexport class SmartWalletSDKError extends Error {\n public readonly code: SmartWalletErrorCode;\n public readonly details?: string;\n\n constructor(message: string, details?: string, code: SmartWalletErrorCode = SmartWalletErrors.UNCATEGORIZED) {\n super(message);\n this.details = details;\n this.code = code;\n }\n}\n\nexport class TransferError extends SmartWalletSDKError {\n constructor(message: string) {\n super(message, undefined, SmartWalletErrors.TRANSFER);\n }\n}\n\nexport class CrossmintServiceError extends SmartWalletSDKError {\n public status?: number;\n\n constructor(message: string, status?: number) {\n super(message, undefined, SmartWalletErrors.CROSSMINT_SERVICE);\n this.status = status;\n }\n}\n\nexport class AdminMismatchError extends SmartWalletSDKError {\n public readonly required: SignerDisplay;\n public readonly used?: SignerDisplay;\n\n constructor(message: string, required: SignerDisplay, used?: SignerDisplay) {\n super(message, SmartWalletErrors.ERROR_ADMIN_MISMATCH);\n this.required = required;\n this.used = used;\n }\n}\n\nexport class PasskeyMismatchError extends SmartWalletSDKError {\n public readonly required: PasskeyDisplay;\n public readonly used?: PasskeyDisplay;\n\n constructor(message: string, required: PasskeyDisplay, used?: PasskeyDisplay) {\n super(message, SmartWalletErrors.ERROR_PASSKEY_MISMATCH);\n this.required = required;\n this.used = used;\n }\n}\n\nexport class NotAuthorizedError extends SmartWalletSDKError {\n constructor(message: string) {\n super(message, undefined, SmartWalletErrors.NOT_AUTHORIZED);\n }\n}\n\nexport class JWTExpiredError extends NotAuthorizedError {\n public readonly code = SmartWalletErrors.ERROR_JWT_EXPIRED;\n\n /**\n * The expiry time of the JWT as an ISO 8601 timestamp.\n */\n public readonly expiredAt: string;\n\n constructor(expiredAt: Date) {\n super(`JWT provided expired at timestamp ${expiredAt}`);\n this.expiredAt = expiredAt.toISOString();\n }\n}\n\nexport class JWTInvalidError extends NotAuthorizedError {\n public readonly code = SmartWalletErrors.ERROR_JWT_INVALID;\n constructor() {\n super(\"Invalid JWT provided\");\n }\n}\n\nexport class JWTDecryptionError extends NotAuthorizedError {\n public readonly code = SmartWalletErrors.ERROR_JWT_DECRYPTION;\n constructor() {\n super(\"Error decrypting JWT\");\n }\n}\n\nexport class JWTIdentifierError extends NotAuthorizedError {\n public readonly code = SmartWalletErrors.ERROR_JWT_IDENTIFIER;\n public readonly identifierKey: string;\n\n constructor(identifierKey: string) {\n super(`Missing required identifier '${identifierKey}' in the JWT`);\n this.identifierKey = identifierKey;\n }\n}\n\nexport class UserWalletAlreadyCreatedError extends SmartWalletSDKError {\n public readonly code = SmartWalletErrors.ERROR_USER_WALLET_ALREADY_CREATED;\n\n constructor(userId: string) {\n super(`The user with userId ${userId.toString()} already has a wallet created for this project`);\n }\n}\n\nexport class OutOfCreditsError extends SmartWalletSDKError {\n constructor(message?: string) {\n super(\n \"You've run out of Crossmint API credits. Visit https://docs.crossmint.com/docs/errors for more information\",\n undefined,\n SmartWalletErrors.ERROR_OUT_OF_CREDITS\n );\n }\n}\n\nexport class ConfigError extends SmartWalletSDKError {\n constructor(message: string) {\n super(message, undefined, SmartWalletErrors.ERROR_WALLET_CONFIG);\n }\n}\n\nexport class AdminAlreadyUsedError extends ConfigError {\n public readonly code = SmartWalletErrors.ERROR_ADMIN_SIGNER_ALREADY_USED;\n constructor() {\n super(\"This signer was already used to create another wallet. Please use a different signer.\");\n }\n}\n\nexport class NonCustodialWalletsNotEnabledError extends ConfigError {\n public readonly code = SmartWalletErrors.ERROR_PROJECT_NONCUSTODIAL_WALLETS_NOT_ENABLED;\n constructor() {\n super(\"Non-custodial wallets are not enabled for this project\");\n }\n}\n","import { v4 as uuidv4 } from \"uuid\";\n\nimport { logError, logInfo } from \"../services/logging\";\nimport { SCW_SERVICE } from \"./constants\";\nimport { isLocalhost } from \"./helpers\";\n\nexport class LoggerWrapper {\n constructor(className: string, private extraInfo = {}, private logIdempotencyKey = uuidv4()) {\n return new Proxy(this, {\n get: (target: any, propKey: PropertyKey, receiver: any) => {\n const origMethod = target[propKey];\n const identifierTag = `[${SCW_SERVICE} - ${className} - ${String(propKey)}]`;\n\n if (typeof origMethod === \"function\") {\n return (...args: any[]) => {\n this.logInput(args, identifierTag);\n\n const result = origMethod.apply(target, args);\n if (result instanceof Promise) {\n return result\n .then((res: any) => {\n this.logOutput(res, identifierTag);\n return res;\n })\n .catch((err: any) => {\n this.logError(err, identifierTag);\n throw err;\n });\n } else {\n this.logOutput(result, identifierTag);\n return result;\n }\n };\n }\n return Reflect.get(target, propKey, receiver);\n },\n });\n }\n\n private logInput(args: object, identifierTag: string) {\n logInfoIfNotInLocalhost(\n `${identifierTag} input - ${beautify(args)} - extra_info - ${beautify(\n this.extraInfo\n )} - log_idempotency_key - ${this.logIdempotencyKey}`,\n { args, ...this.extraInfo, logIdempotencyKey: this.logIdempotencyKey }\n );\n }\n\n private logOutput(res: object, identifierTag: string) {\n logInfoIfNotInLocalhost(\n `${identifierTag} output - ${beautify(res)} - extra_info - ${beautify(\n this.extraInfo\n )} - log_idempotency_key - ${this.logIdempotencyKey}`,\n {\n res,\n ...this.extraInfo,\n logIdempotencyKey: this.logIdempotencyKey,\n }\n );\n }\n\n private logError(err: object, identifierTag: string) {\n logError(\n `${identifierTag} threw_error - ${err} - extra_info - ${beautify(this.extraInfo)} - log_idempotency_key - ${\n this.logIdempotencyKey\n }`,\n { err, ...this.extraInfo }\n );\n }\n\n protected logPerformance<T>(name: string, cb: () => Promise<T>) {\n return logPerformance(name, cb, this.extraInfo);\n }\n}\n\nexport async function logPerformance<T>(name: string, cb: () => Promise<T>, extraInfo?: object) {\n const start = new Date().getTime();\n const result = await cb();\n const durationInMs = new Date().getTime() - start;\n const args = { durationInMs, ...extraInfo };\n logInfoIfNotInLocalhost(`[${SCW_SERVICE} - ${name} - TIME] - ${beautify(args)}`, { args });\n return result;\n}\n\nexport function logInputOutput<T, A extends any[]>(fn: (...args: A) => T, functionName: string): (...args: A) => T {\n return function (this: any, ...args: A): T {\n const identifierTag = `[${SCW_SERVICE} - function: ${functionName}]`;\n logInfoIfNotInLocalhost(`${identifierTag} input: ${beautify(args)}`, { args });\n\n try {\n const result = fn.apply(this, args);\n if (result instanceof Promise) {\n return result\n .then((res) => {\n logInfoIfNotInLocalhost(`${identifierTag} output: ${beautify(res)}`, { res });\n return res;\n })\n .catch((err) => {\n logError(`${identifierTag} threw_error: ${beautify(err)}`, { err });\n throw err;\n }) as T;\n } else {\n logInfoIfNotInLocalhost(`${identifierTag} output: ${beautify(result)}`, { res: result });\n return result;\n }\n } catch (err) {\n logError(`${identifierTag} threw_error: ${beautify(err)}`, { err });\n throw err;\n }\n };\n}\n\nfunction beautify(json: any) {\n try {\n return json != null ? JSON.stringify(json, null, 2) : json;\n } catch (error) {\n return stringifyAvoidingCircular(json);\n }\n}\n\nfunction stringifyAvoidingCircular(json: any) {\n // stringify an object, avoiding circular structures\n // https://stackoverflow.com/a/31557814\n const simpleObject: { [key: string]: any } = {};\n for (const prop in json) {\n if (!Object.prototype.hasOwnProperty.call(json, prop)) {\n continue;\n }\n if (typeof json[prop] == \"object\") {\n continue;\n }\n if (typeof json[prop] == \"function\") {\n continue;\n }\n simpleObject[prop] = json[prop];\n }\n return JSON.stringify(simpleObject, null, 2); // returns cleaned up JSON\n}\n\nfunction logInfoIfNotInLocalhost(message: string, context?: object) {\n if (isLocalhost()) {\n console.log(message);\n return;\n }\n logInfo(message, context);\n}\n\nexport function errorToJSON(error: Error | unknown) {\n const errorToLog = error instanceof Error ? error : { message: \"Unknown error\", name: \"Unknown error\" };\n\n if (!(errorToLog instanceof Error) && (errorToLog as any).constructor?.name !== \"SyntheticBaseEvent\") {\n logError(\"ERROR_TO_JSON_FAILED\", { error: errorToLog });\n throw new Error(\"[errorToJSON] err is not instanceof Error nor SyntheticBaseEvent\");\n }\n\n return JSON.parse(JSON.stringify(errorToLog, Object.getOwnPropertyNames(errorToLog)));\n}\n","import { Abi, Account, Address, erc20Abi, erc721Abi } from \"viem\";\n\nimport erc1155Abi from \"../ABI/ERC1155.json\";\nimport type { ERC20TransferType, SFTTransferType, TransferType } from \"../types/Tokens\";\n\ntype TransferInputParams = {\n from: Account;\n contract: Address;\n to: Address;\n config: TransferType;\n};\n\ntype TransferSimulationParams = {\n account: Account;\n address: Address;\n abi: Abi;\n functionName: string;\n args: any[];\n tokenId?: string;\n};\n\nexport function transferParams({ contract, config, from, to }: TransferInputParams): TransferSimulationParams {\n switch (config.token.type) {\n case \"ft\": {\n return {\n account: from,\n address: contract,\n abi: erc20Abi,\n functionName: \"transfer\",\n args: [to, (config as ERC20TransferType).amount],\n };\n }\n case \"sft\": {\n return {\n account: from,\n address: contract,\n abi: erc1155Abi as Abi,\n functionName: \"safeTransferFrom\",\n args: [from.address, to, config.token.tokenId, (config as SFTTransferType).quantity, \"0x00\"],\n tokenId: config.token.tokenId,\n };\n }\n case \"nft\": {\n return {\n account: from,\n address: contract,\n abi: erc721Abi,\n functionName: \"safeTransferFrom\",\n args: [from.address, to, config.token.tokenId],\n tokenId: config.token.tokenId,\n };\n }\n }\n}\n","[\n {\n \"inputs\": [\n {\n \"internalType\": \"string\",\n \"name\": \"uri_\",\n \"type\": \"string\"\n }\n ],\n \"stateMutability\": \"nonpayable\",\n \"type\": \"constructor\"\n },\n {\n \"anonymous\": false,\n \"inputs\": [\n {\n \"indexed\": true,\n \"internalType\": \"address\",\n \"name\": \"account\",\n \"type\": \"address\"\n },\n {\n \"indexed\": true,\n \"internalType\": \"address\",\n \"name\": \"operator\",\n \"type\": \"address\"\n },\n {\n \"indexed\": false,\n \"internalType\": \"bool\",\n \"name\": \"approved\",\n \"type\": \"bool\"\n }\n ],\n \"name\": \"ApprovalForAll\",\n \"type\": \"event\"\n },\n {\n \"anonymous\": false,\n \"inputs\": [\n {\n \"indexed\": true,\n \"internalType\": \"address\",\n \"name\": \"operator\",\n \"type\": \"address\"\n },\n {\n \"indexed\": true,\n \"internalType\": \"address\",\n \"name\": \"from\",\n \"type\": \"address\"\n },\n {\n \"indexed\": true,\n \"internalType\": \"address\",\n \"name\": \"to\",\n \"type\": \"address\"\n },\n {\n \"indexed\": false,\n \"internalType\": \"uint256[]\",\n \"name\": \"ids\",\n \"type\": \"uint256[]\"\n },\n {\n \"indexed\": false,\n \"internalType\": \"uint256[]\",\n \"name\": \"values\",\n \"type\": \"uint256[]\"\n }\n ],\n \"name\": \"TransferBatch\",\n \"type\": \"event\"\n },\n {\n \"anonymous\": false,\n \"inputs\": [\n {\n \"indexed\": true,\n \"internalType\": \"address\",\n \"name\": \"operator\",\n \"type\": \"address\"\n },\n {\n \"indexed\": true,\n \"internalType\": \"address\",\n \"name\": \"from\",\n \"type\": \"address\"\n },\n {\n \"indexed\": true,\n \"internalType\": \"address\",\n \"name\": \"to\",\n \"type\": \"address\"\n },\n {\n \"indexed\": false,\n \"internalType\": \"uint256\",\n \"name\": \"id\",\n \"type\": \"uint256\"\n },\n {\n \"indexed\": false,\n \"internalType\": \"uint256\",\n \"name\": \"value\",\n \"type\": \"uint256\"\n }\n ],\n \"name\": \"TransferSingle\",\n \"type\": \"event\"\n },\n {\n \"anonymous\": false,\n \"inputs\": [\n {\n \"indexed\": false,\n \"internalType\": \"string\",\n \"name\": \"value\",\n \"type\": \"string\"\n },\n {\n \"indexed\": true,\n \"internalType\": \"uint256\",\n \"name\": \"id\",\n \"type\": \"uint256\"\n }\n ],\n \"name\": \"URI\",\n \"type\": \"event\"\n },\n {\n \"inputs\": [\n {\n \"internalType\": \"address\",\n \"name\": \"account\",\n \"type\": \"address\"\n },\n {\n \"internalType\": \"uint256\",\n \"name\": \"id\",\n \"type\": \"uint256\"\n }\n ],\n \"name\": \"balanceOf\",\n \"outputs\": [\n {\n \"internalType\": \"uint256\",\n \"name\": \"\",\n \"type\": \"uint256\"\n }\n ],\n \"stateMutability\": \"view\",\n \"type\": \"function\"\n },\n {\n \"inputs\": [\n {\n \"internalType\": \"address[]\",\n \"name\": \"accounts\",\n \"type\": \"address[]\"\n },\n {\n \"internalType\": \"uint256[]\",\n \"name\": \"ids\",\n \"type\": \"uint256[]\"\n }\n ],\n \"name\": \"balanceOfBatch\",\n \"outputs\": [\n {\n \"internalType\": \"uint256[]\",\n \"name\": \"\",\n \"type\": \"uint256[]\"\n }\n ],\n \"stateMutability\": \"view\",\n \"type\": \"function\"\n },\n {\n \"inputs\": [\n {\n \"internalType\": \"address\",\n \"name\": \"account\",\n \"type\": \"address\"\n },\n {\n \"internalType\": \"address\",\n \"name\": \"operator\",\n \"type\": \"address\"\n }\n ],\n \"name\": \"isApprovedForAll\",\n \"outputs\": [\n {\n \"internalType\": \"bool\",\n \"name\": \"\",\n \"type\": \"bool\"\n }\n ],\n \"stateMutability\": \"view\",\n \"type\": \"function\"\n },\n {\n \"inputs\": [\n {\n \"internalType\": \"address\",\n \"name\": \"from\",\n \"type\": \"address\"\n },\n {\n \"internalType\": \"address\",\n \"name\": \"to\",\n \"type\": \"address\"\n },\n {\n \"internalType\": \"uint256[]\",\n \"name\": \"ids\",\n \"type\": \"uint256[]\"\n },\n {\n \"internalType\": \"uint256[]\",\n \"name\": \"amounts\",\n \"type\": \"uint256[]\"\n },\n {\n \"internalType\": \"bytes\",\n \"name\": \"data\",\n \"type\": \"bytes\"\n }\n ],\n \"name\": \"safeBatchTransferFrom\",\n \"outputs\": [],\n \"stateMutability\": \"nonpayable\",\n \"type\": \"function\"\n },\n {\n \"inputs\": [\n {\n \"internalType\": \"address\",\n \"name\": \"from\",\n \"type\": \"address\"\n },\n {\n \"internalType\": \"address\",\n \"name\": \"to\",\n \"type\": \"address\"\n },\n {\n \"internalType\": \"uint256\",\n \"name\": \"id\",\n \"type\": \"uint256\"\n },\n {\n \"internalType\": \"uint256\",\n \"name\": \"amount\",\n \"type\": \"uint256\"\n },\n {\n \"internalType\": \"bytes\",\n \"name\": \"data\",\n \"type\": \"bytes\"\n }\n ],\n \"name\": \"safeTransferFrom\",\n \"outputs\": [],\n \"stateMutability\": \"nonpayable\",\n \"type\": \"function\"\n },\n {\n \"inputs\": [\n {\n \"internalType\": \"address\",\n \"name\": \"operator\",\n \"type\": \"address\"\n },\n {\n \"internalType\": \"bool\",\n \"name\": \"approved\",\n \"type\": \"bool\"\n }\n ],\n \"name\": \"setApprovalForAll\",\n \"outputs\": [],\n \"stateMutability\": \"nonpayable\",\n \"type\": \"function\"\n },\n {\n \"inputs\": [\n {\n \"internalType\": \"bytes4\",\n \"name\": \"interfaceId\",\n \"type\": \"bytes4\"\n }\n ],\n \"name\": \"supportsInterface\",\n \"outputs\": [\n {\n \"internalType\": \"bool\",\n \"name\": \"\",\n \"type\": \"bool\"\n }\n ],\n \"stateMutability\": \"view\",\n \"type\": \"function\"\n },\n {\n \"inputs\": [\n {\n \"internalType\": \"uint256\",\n \"name\": \"\",\n \"type\": \"uint256\"\n }\n ],\n \"name\": \"uri\",\n \"outputs\": [\n {\n \"internalType\": \"string\",\n \"name\": \"\",\n \"type\": \"string\"\n }\n ],\n \"stateMutability\": \"view\",\n \"type\": \"function\"\n }\n]\n","import { BUNDLER_RPC } from \"@/utils/constants\";\nimport { Chain, base, baseSepolia, polygon, polygonAmoy } from \"viem/chains\";\n\nimport { BlockchainIncludingTestnet as Blockchain, ObjectValues, objectValues } from \"@crossmint/common-sdk-base\";\n\nexport const SmartWalletTestnet = {\n BASE_SEPOLIA: Blockchain.BASE_SEPOLIA,\n POLYGON_AMOY: Blockchain.POLYGON_AMOY,\n} as const;\nexport type SmartWalletTestnet = ObjectValues<typeof SmartWalletTestnet>;\nexport const SMART_WALLET_TESTNETS = objectValues(SmartWalletTestnet);\n\nexport const SmartWalletMainnet = {\n BASE: Blockchain.BASE,\n POLYGON: Blockchain.POLYGON,\n} as const;\nexport type SmartWalletMainnet = ObjectValues<typeof SmartWalletMainnet>;\nexport const SMART_WALLET_MAINNETS = objectValues(SmartWalletMainnet);\n\nexport const SmartWalletChain = {\n ...SmartWalletTestnet,\n ...SmartWalletMainnet,\n} as const;\nexport type SmartWalletChain = ObjectValues<typeof SmartWalletChain>;\nexport const SMART_WALLET_CHAINS = objectValues(SmartWalletChain);\n\nexport const zerodevProjects: Record<SmartWalletChain, string> = {\n polygon: \"5c9f4865-ca8e-44bb-9b9e-3810b2b46f9f\",\n \"polygon-amoy\": \"3deef404-ca06-4a5d-9a58-907c99e7ef00\",\n \"base-sepolia\": \"5a127978-6473-4784-9dfb-f74395b220a6\",\n base: \"e8b3020f-4dde-4176-8a7d-be8102527a5c\",\n};\n\nexport const viemNetworks: Record<SmartWalletChain, Chain> = {\n polygon: polygon,\n \"polygon-amoy\": polygonAmoy,\n base: base,\n \"base-sepolia\": baseSepolia,\n};\n\nexport const getBundlerRPC = (chain: SmartWalletChain) => {\n return BUNDLER_RPC + zerodevProjects[chain];\n};\n","import { stringify } from \"viem\";\n\nimport { validateAPIKey } from \"@crossmint/common-sdk-base\";\n\nimport { CrossmintWalletService } from \"./api/CrossmintWalletService\";\nimport { SmartWalletChain } from \"./blockchain/chains\";\nimport type { EVMSmartWallet } from \"./blockchain/wallets\";\nimport { ClientDecorator } from \"./blockchain/wallets/clientDecorator\";\nimport { SmartWalletService } from \"./blockchain/wallets/service\";\nimport { SmartWalletSDKError } from \"./error\";\nimport { ErrorProcessor } from \"./error/processor\";\nimport { DatadogProvider } from \"./services/logging/DatadogProvider\";\nimport type { SmartWalletSDKInitParams, UserParams, WalletParams } from \"./types/Config\";\nimport { isClient } from \"./utils/environment\";\nimport { LoggerWrapper, logPerformance } from \"./utils/log\";\n\nexport class SmartWalletSDK extends LoggerWrapper {\n private constructor(\n private readonly smartWalletService: SmartWalletService,\n private readonly errorProcessor: ErrorProcessor\n ) {\n super(\"SmartWalletSDK\");\n }\n\n /**\n * Initializes the SDK with the **client side** API key obtained from the Crossmint console.\n * @throws error if the api key is not formatted correctly.\n */\n static init({ clientApiKey }: SmartWalletSDKInitParams): SmartWalletSDK {\n if (!isClient()) {\n throw new SmartWalletSDKError(\"Smart Wallet SDK should only be used client side.\");\n }\n\n const validationResult = validateAPIKey(clientApiKey);\n if (!validationResult.isValid) {\n throw new Error(\"API key invalid\");\n }\n\n const crossmintService = new CrossmintWalletService(clientApiKey);\n const errorProcessor = new ErrorProcessor(new DatadogProvider());\n return new SmartWalletSDK(\n new SmartWalletService(crossmintService, new ClientDecorator(errorProcessor)),\n errorProcessor\n );\n }\n\n /**\n * Retrieves or creates a wallet for the specified user.\n * The default configuration is a `PasskeySigner` with the name, which is displayed to the user during creation or signing prompts, derived from the provided jwt.\n *\n * Example using the default passkey signer:\n * ```ts\n * const wallet = await smartWalletSDK.getOrCreateWallet({ jwt: \"xxx\" }, \"base\");\n * ```\n */\n async getOrCreateWallet(\n user: UserParams,\n chain: SmartWalletChain,\n walletParams: WalletParams = { signer: { type: \"PASSKEY\" } }\n ): Promise<EVMSmartWallet> {\n return logPerformance(\n \"GET_OR_CREATE_WALLET\",\n async () => {\n try {\n return await this.smartWalletService.getOrCreate(user, chain, walletParams);\n } catch (error: any) {\n throw this.errorProcessor.map(\n error,\n new SmartWalletSDKError(`Wallet creation failed: ${error.message}.`, stringify(error))\n );\n }\n },\n { user, chain }\n );\n }\n}\n","import { validateAPIKey } from \"@crossmint/common-sdk-base\";\n\nimport { CrossmintServiceError } from \"../error\";\nimport { CROSSMINT_DEV_URL, CROSSMINT_PROD_URL, CROSSMINT_STG_URL } from \"../utils/constants\";\nimport { LoggerWrapper, logPerformance } from \"../utils/log\";\nimport { APIErrorService } from \"./APIErrorService\";\n\nexport abstract class BaseCrossmintService extends LoggerWrapper {\n public crossmintAPIHeaders: Record<string, string>;\n protected crossmintBaseUrl: string;\n protected apiErrorService: APIErrorService;\n private static urlMap: Record<string, string> = {\n development: CROSSMINT_DEV_URL,\n staging: CROSSMINT_STG_URL,\n production: CROSSMINT_PROD_URL,\n };\n\n constructor(apiKey: string) {\n super(\"BaseCrossmintService\");\n const result = validateAPIKey(apiKey);\n if (!result.isValid) {\n throw new Error(\"API key invalid\");\n }\n this.crossmintAPIHeaders = {\n accept: \"application/json\",\n \"content-type\": \"application/json\",\n \"x-api-key\": apiKey,\n };\n this.crossmintBaseUrl = this.getUrlFromEnv(result.environment);\n this.apiErrorService = new APIErrorService();\n }\n\n protected async fetchCrossmintAPI(\n endpoint: string,\n options: { body?: string; method: string } = { method: \"GET\" },\n onServerErrorMessage: string,\n authToken?: string\n ) {\n return logPerformance(\n \"FETCH_CROSSMINT_API\",\n async () => {\n const url = `${this.crossmintBaseUrl}/${endpoint}`;\n const { body, method } = options;\n\n let response: Response;\n try {\n response = await fetch(url, {\n body,\n method,\n headers: {\n ...this.crossmintAPIHeaders,\n ...(authToken != null && {\n Authorization: `Bearer ${authToken}`,\n }),\n },\n });\n } catch (error) {\n throw new CrossmintServiceError(`Error fetching Crossmint API: ${error}`);\n }\n\n if (!response.ok) {\n await this.apiErrorService.throwErrorFromResponse({\n response,\n onServerErrorMessage,\n });\n }\n\n return await response.json();\n },\n { endpoint }\n );\n }\n\n protected getUrlFromEnv(environment: string) {\n const url = BaseCrossmintService.urlMap[environment];\n if (!url) {\n console.log(\" CrossmintService.urlMap: \", BaseCrossmintService.urlMap);\n throw new Error(`URL not found for environment: ${environment}`);\n }\n return url;\n }\n}\n","import {\n AdminAlreadyUsedError,\n CrossmintServiceError,\n JWTDecryptionError,\n JWTExpiredError,\n JWTIdentifierError,\n JWTInvalidError,\n NonCustodialWalletsNotEnabledError,\n OutOfCreditsError,\n SmartWalletSDKError,\n UserWalletAlreadyCreatedError,\n} from \"@/error\";\n\nexport type CrossmintAPIErrorCodes =\n | \"ERROR_JWT_INVALID\"\n | \"ERROR_JWT_DECRYPTION\"\n | \"ERROR_JWT_IDENTIFIER\"\n | \"ERROR_JWT_EXPIRED\"\n | \"ERROR_USER_WALLET_ALREADY_CREATED\"\n | \"ERROR_ADMIN_SIGNER_ALREADY_USED\"\n | \"ERROR_PROJECT_NONCUSTODIAL_WALLETS_NOT_ENABLED\";\n\nexport class APIErrorService {\n constructor(\n private errors: Partial<Record<CrossmintAPIErrorCodes, (apiResponse: any) => SmartWalletSDKError>> = {\n ERROR_JWT_INVALID: () => new JWTInvalidError(),\n ERROR_JWT_DECRYPTION: () => new JWTDecryptionError(),\n ERROR_JWT_EXPIRED: ({ expiredAt }: { expiredAt: string }) => new JWTExpiredError(new Date(expiredAt)),\n ERROR_JWT_IDENTIFIER: ({ identifierKey }: { identifierKey: string }) =>\n new JWTIdentifierError(identifierKey),\n ERROR_USER_WALLET_ALREADY_CREATED: ({ userId }: { userId: string }) =>\n new UserWalletAlreadyCreatedError(userId),\n ERROR_ADMIN_SIGNER_ALREADY_USED: () => new AdminAlreadyUsedError(),\n ERROR_PROJECT_NONCUSTODIAL_WALLETS_NOT_ENABLED: () => new NonCustodialWalletsNotEnabledError(),\n }\n ) {}\n\n async throwErrorFromResponse({\n response,\n onServerErrorMessage,\n }: {\n response: Response;\n onServerErrorMessage: string;\n }) {\n if (response.ok) {\n return;\n }\n\n if (response.status >= 500) {\n throw new CrossmintServiceError(onServerErrorMessage, response.status);\n }\n\n if (response.status === 402) {\n throw new OutOfCreditsError();\n }\n\n try {\n const body = await response.json();\n const code = body.code as CrossmintAPIErrorCodes | undefined;\n if (code != null && this.errors[code] != null) {\n throw this.errors[code](body);\n }\n if (body.message != null) {\n throw new CrossmintServiceError(body.message, response.status);\n }\n } catch (e) {\n if (e instanceof SmartWalletSDKError) {\n throw e;\n }\n console.error(\"Error parsing response\", e);\n }\n\n throw new CrossmintServiceError(await response.text(), response.status);\n }\n}\n","import { SmartWalletChain } from \"@/blockchain/chains\";\nimport { SignerData, StoreSmartWalletParams } from \"@/types/API\";\nimport type { UserParams } from \"@/types/Config\";\nimport { API_VERSION } from \"@/utils/constants\";\n\nimport { BaseCrossmintService } from \"./BaseCrossmintService\";\n\nexport class CrossmintWalletService extends BaseCrossmintService {\n async idempotentCreateSmartWallet(user: UserParams, input: StoreSmartWalletParams) {\n return this.fetchCrossmintAPI(\n `${API_VERSION}/sdk/smart-wallet`,\n { method: \"PUT\", body: JSON.stringify(input) },\n \"Error creating abstract wallet. Please contact support\",\n user.jwt\n );\n }\n\n async getSmartWalletConfig(\n user: UserParams,\n chain: SmartWalletChain\n ): Promise<{\n kernelVersion: string;\n entryPointVersion: string;\n userId: string;\n signers: { signerData: SignerData }[];\n smartContractWalletAddress?: string;\n }> {\n return this.fetchCrossmintAPI(\n `${API_VERSION}/sdk/smart-wallet/config?chain=${chain}`,\n { method: \"GET\" },\n \"Error getting smart wallet version configuration. Please contact support\",\n user.jwt\n );\n }\n\n async fetchNFTs(address: string, chain: SmartWalletChain) {\n return this.fetchCrossmintAPI(\n `v1-alpha1/wallets/${chain}:${address}/nfts`,\n { method: \"GET\" },\n `Error fetching NFTs for wallet: ${address}`\n );\n }\n\n public getPasskeyServerUrl(): string {\n return this.crossmintBaseUrl + \"/internal/passkeys\";\n }\n}\n","import { SmartWalletChain } from \"..\";\n\nexport function usesGelatoBundler(chain: SmartWalletChain) {\n return false;\n}\n","import { SmartWalletSDKError } from \"@/error\";\nimport { ErrorProcessor } from \"@/error/processor\";\nimport { logInfo } from \"@/services/logging\";\nimport { usesGelatoBundler } from \"@/utils/blockchain\";\nimport { logPerformance } from \"@/utils/log\";\nimport type { SmartAccountClient } from \"permissionless\";\nimport type { EntryPoint } from \"permissionless/types/entrypoint\";\nimport { stringify } from \"viem\";\n\nimport { SmartWalletChain } from \"../chains\";\n\nconst transactionMethods = [\n \"sendTransaction\",\n \"writeContract\",\n \"sendUserOperation\",\n] as const satisfies readonly (keyof SmartAccountClient<EntryPoint>)[];\n\nconst signingMethods = [\n \"signMessage\",\n \"signTypedData\",\n] as const satisfies readonly (keyof SmartAccountClient<EntryPoint>)[];\n\ntype TxnMethod = (typeof transactionMethods)[number];\ntype SignMethod = (typeof signingMethods)[number];\n\nfunction isTxnMethod(method: string): method is TxnMethod {\n return transactionMethods.includes(method as any);\n}\n\nfunction isSignMethod(method: string): method is SignMethod {\n return signingMethods.includes(method as any);\n}\n\n/**\n * A decorator class for SmartAccountClient instances. It enhances the client with:\n * - Error handling & logging.\n * - Performance metrics.\n * - Automatic formatting of transactions for Gelato bundler compatibility.\n * */\nexport class ClientDecorator {\n constructor(private readonly errorProcessor: ErrorProcessor) {}\n\n public decorate<Client extends SmartAccountClient<EntryPoint>>({\n crossmintChain,\n smartAccountClient,\n }: {\n crossmintChain: SmartWalletChain;\n smartAccountClient: Client;\n }): Client {\n return new Proxy(smartAccountClient, {\n get: (target, prop, receiver) => {\n const originalMethod = Reflect.get(target, prop, receiver);\n\n if (\n typeof originalMethod !== \"function\" ||\n typeof prop !== \"string\" ||\n !(isSignMethod(prop) || isTxnMethod(prop))\n ) {\n return originalMethod;\n }\n\n return (...args: any[]) =>\n logPerformance(`CrossmintSmartWallet.${prop}`, () =>\n this.execute(target, prop, originalMethod, args, crossmintChain)\n );\n },\n }) as Client;\n }\n\n private async execute<M extends TxnMethod | SignMethod>(\n target: SmartAccountClient<EntryPoint>,\n prop: M,\n // eslint-disable-next-line @typescript-eslint/ban-types\n originalMethod: Function,\n args: any[],\n crossmintChain: SmartWalletChain\n ) {\n try {\n logInfo(`[CrossmintSmartWallet.${prop}] - params: ${stringify(args)}`);\n const processed = isTxnMethod(prop) ? this.processTxnArgs(prop, crossmintChain, args) : args;\n return await originalMethod.call(target, ...processed);\n } catch (error: any) {\n const description = isTxnMethod(prop) ? \"signing\" : \"sending transaction\";\n throw this.errorProcessor.map(\n error,\n new SmartWalletSDKError(`Error ${description}: ${error.message}`, stringify(error))\n );\n }\n }\n\n private processTxnArgs(prop: TxnMethod, crossmintChain: SmartWalletChain, args: any[]): any[] {\n if (prop === \"sendUserOperation\") {\n const [{ userOperation, middleware, account }] = args as Parameters<\n SmartAccountClient<EntryPoint>[\"sendUserOperation\"]\n >;\n return [\n {\n middleware,\n account,\n userOperation: this.addGelatoBundlerProperties(crossmintChain, userOperation),\n },\n ...args.slice(1),\n ];\n }\n\n const [txn] = args as\n | Parameters<SmartAccountClient<EntryPoint>[\"sendTransaction\"]>\n | Parameters<SmartAccountClient<EntryPoint>[\"writeContract\"]>;\n\n return [this.addGelatoBundlerProperties(crossmintChain, txn), ...args.slice(1)];\n }\n\n /*\n * Chain that ZD uses Gelato as for bundler require special parameters:\n * https://docs.zerodev.app/sdk/faqs/use-with-gelato#transaction-configuration\n */\n private addGelatoBundlerProperties(\n crossmintChain: SmartWalletChain,\n txnParams: { maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint }\n ) {\n if (usesGelatoBundler(crossmintChain)) {\n return { ...txnParams, maxFeePerGas: \"0x0\" as any, maxPriorityFeePerGas: \"0x0\" as any };\n }\n\n return txnParams;\n }\n}\n","import { PasskeyValidatorContractVersion } from \"@zerodev/passkey-validator\";\n\nimport { PasskeyValidatorSerializedData, SupportedEntryPointVersion, SupportedKernelVersion } from \"./internal\";\n\nexport type StoreSmartWalletParams = {\n type: string;\n smartContractWalletAddress: string;\n signerData: SignerData;\n sessionKeySignerAddress?: string;\n version: number;\n baseLayer: string;\n chainId: number;\n entryPointVersion: SupportedEntryPointVersion;\n kernelVersion: SupportedKernelVersion;\n};\n\nexport type SignerData = EOASignerData | PasskeySignerData;\n\nexport interface EOASignerData {\n eoaAddress: string;\n type: \"eoa\";\n}\n\nexport type PasskeySignerData = PasskeyValidatorSerializedData & {\n passkeyName: string;\n validatorContractVersion: PasskeyValidatorContractVersion;\n domain: string;\n type: \"passkeys\";\n};\n\nexport type PasskeyDisplay = Pick<PasskeySignerData, \"type\" | \"passkeyName\" | \"pubKeyX\" | \"pubKeyY\">;\nexport type SignerDisplay = EOASignerData | PasskeyDisplay;\nexport function displayPasskey(data: PasskeySignerData): PasskeyDisplay {\n return {\n pubKeyX: data.pubKeyX,\n pubKeyY: data.pubKeyY,\n passkeyName: data.passkeyName,\n type: \"passkeys\",\n };\n}\n","import { type SignerData, displayPasskey } from \"@/types/API\";\nimport { equalsIgnoreCase } from \"@/utils/helpers\";\nimport { type KernelSmartAccount, createKernelAccountClient } from \"@zerodev/sdk\";\nimport { ENTRYPOINT_ADDRESS_V06, ENTRYPOINT_ADDRESS_V07 } from \"permissionless\";\nimport type { EntryPoint } from \"permissionless/types/entrypoint\";\nimport { Address, type HttpTransport, createPublicClient, getAddress, http } from \"viem\";\n\nimport { blockchainToChainId } from \"@crossmint/common-sdk-base\";\n\nimport type { CrossmintWalletService } from \"../../api/CrossmintWalletService\";\nimport {\n AdminMismatchError,\n CrossmintServiceError,\n SmartWalletSDKError,\n UserWalletAlreadyCreatedError,\n} from \"../../error\";\nimport type { EntryPointDetails, UserParams, WalletParams } from \"../../types/Config\";\nimport {\n SUPPORTED_ENTRYPOINT_VERSIONS,\n SUPPORTED_KERNEL_VERSIONS,\n SmartWalletClient,\n type SupportedKernelVersion,\n type WalletCreationParams,\n isSupportedEntryPointVersion,\n isSupportedKernelVersion,\n} from \"../../types/internal\";\nimport { CURRENT_VERSION, ZERO_DEV_TYPE } from \"../../utils/constants\";\nimport { SmartWalletChain, getBundlerRPC, viemNetworks } from \"../chains\";\nimport { EVMSmartWallet } from \"./EVMSmartWallet\";\nimport { ClientDecorator } from \"./clientDecorator\";\nimport { EOAAccountService, type EOAWalletParams } from \"./eoa\";\nimport { PasskeyAccountService, isPasskeyParams } from \"./passkey\";\nimport { paymasterMiddleware, usePaymaster } from \"./paymaster\";\n\nexport class SmartWalletService {\n constructor(\n private readonly crossmintWalletService: CrossmintWalletService,\n private readonly clientDecorator: ClientDecorator,\n private readonly accountFactory = new AccountFactory(\n new EOAAccountService(),\n new PasskeyAccountService(crossmintWalletService)\n )\n ) {}\n\n public async getOrCreate(\n user: UserParams,\n chain: SmartWalletChain,\n walletParams: WalletParams\n ): Promise<EVMSmartWallet> {\n const { entryPoint, kernelVersion, existingSignerConfig, smartContractWalletAddress, userId } =\n await this.fetchConfig(user, chain);\n const publicClient = createPublicClient({ transport: http(getBundlerRPC(chain)) });\n\n const { account, signerData } = await this.accountFactory.get(\n {\n chain,\n walletParams,\n publicClient,\n user: { ...user, id: userId },\n entryPoint,\n kernelVersion,\n },\n existingSignerConfig\n );\n\n if (smartContractWalletAddress != null && !equalsIgnoreCase(smartContractWalletAddress, account.address)) {\n throw new UserWalletAlreadyCreatedError(userId);\n }\n\n if (existingSignerConfig == null) {\n await this.crossmintWalletService.idempotentCreateSmartWallet(user, {\n type: ZERO_DEV_TYPE,\n smartContractWalletAddress: account.address,\n signerData: signerData,\n version: CURRENT_VERSION,\n baseLayer: \"evm\",\n chainId: blockchainToChainId(chain),\n entryPointVersion: entryPoint.version,\n kernelVersion,\n });\n }\n\n const kernelAccountClient: SmartWalletClient = createKernelAccountClient({\n account,\n chain: viemNetworks[chain],\n entryPoint: account.entryPoint,\n bundlerTransport: http(getBundlerRPC(chain)),\n ...(usePaymaster(chain) && paymasterMiddleware({ entryPoint: account.entryPoint, chain })),\n });\n\n const smartAccountClient = this.clientDecorator.decorate({\n crossmintChain: chain,\n smartAccountClient: kernelAccountClient,\n });\n\n return new EVMSmartWallet(this.crossmintWalletService, smartAccountClient, publicClient, chain);\n }\n\n private async fetchConfig(\n user: UserParams,\n chain: SmartWalletChain\n ): Promise<{\n entryPoint: EntryPointDetails;\n kernelVersion: SupportedKernelVersion;\n userId: string;\n existingSignerConfig?: SignerData;\n smartContractWalletAddress?: Address;\n }> {\n const { entryPointVersion, kernelVersion, signers, smartContractWalletAddress, userId } =\n await this.crossmintWalletService.getSmartWalletConfig(user, chain);\n\n if (!isSupportedKernelVersion(kernelVersion)) {\n throw new SmartWalletSDKError(\n `Unsupported kernel version. Supported versions: ${SUPPORTED_KERNEL_VERSIONS.join(\n \", \"\n )}. Version used: ${kernelVersion}, Please contact support`\n );\n }\n\n if (!isSupportedEntryPointVersion(entryPointVersion)) {\n throw new SmartWalletSDKError(\n `Unsupported entry point version. Supported versions: ${SUPPORTED_ENTRYPOINT_VERSIONS.join(\n \", \"\n )}. Version used: ${entryPointVersion}. Please contact support`\n );\n }\n\n if (\n (entryPointVersion === \"v0.7\" && kernelVersion.startsWith(\"0.2\")) ||\n (entryPointVersion === \"v0.6\" && kernelVersion.startsWith(\"0.3\"))\n ) {\n throw new SmartWalletSDKError(\n `Unsupported combination: entryPoint ${entryPointVersion} and kernel version ${kernelVersion}. Please contact support`\n );\n }\n\n return {\n entryPoint: {\n version: entryPointVersion,\n address: entryPointVersion === \"v0.6\" ? ENTRYPOINT_ADDRESS_V06 : ENTRYPOINT_ADDRESS_V07,\n },\n kernelVersion,\n userId,\n existingSignerConfig: this.getSigner(signers),\n smartContractWalletAddress:\n smartContractWalletAddress != null ? getAddress(smartContractWalletAddress) : undefined,\n };\n }\n\n private getSigner(signers: any[]): SignerData | undefined {\n if (signers.length === 0) {\n return undefined;\n }\n\n if (signers.length > 1) {\n throw new CrossmintServiceError(\"Invalid wallet signer configuration. Please contact support\");\n }\n\n return signers[0].signerData;\n }\n}\n\nclass AccountFactory {\n constructor(private readonly eoa: EOAAccountService, private readonly passkey: PasskeyAccountService) {}\n\n public get(\n params: WalletCreationParams,\n existingSignerConfig?: SignerData\n ): Promise<{\n signerData: SignerData;\n account: KernelSmartAccount<EntryPoint, HttpTransport>;\n }> {\n if (isPasskeyParams(params)) {\n if (existingSignerConfig != null && existingSignerConfig?.type !== \"passkeys\") {\n throw new AdminMismatchError(\n `Cannot create wallet with passkey signer for user '${params.user.id}', they have an existing wallet with eoa signer '${existingSignerConfig.eoaAddress}.'`,\n existingSignerConfig\n );\n }\n\n return this.passkey.get(params, existingSignerConfig);\n }\n\n if (existingSignerConfig != null && existingSignerConfig?.type !== \"eoa\") {\n throw new AdminMismatchError(\n `Cannot create wallet with eoa signer for user '${params.user.id}', they already have a wallet with a passkey named '${existingSignerConfig.passkeyName}' as it's signer.`,\n displayPasskey(existingSignerConfig)\n );\n }\n\n return this.eoa.get(params as EOAWalletParams, existingSignerConfig);\n }\n}\n","import type { KernelSmartAccount } from \"@zerodev/sdk\";\nimport type { SmartAccountClient } from \"permissionless\";\nimport type { SmartAccount } from \"permissionless/accounts\";\nimport type { EntryPoint } from \"permissionless/types/entrypoint\";\nimport type { Chain, Hex, HttpTransport, PublicClient } from \"viem\";\n\nimport { SmartWalletChain } from \"..\";\nimport type { SignerData } from \"./API\";\nimport type { EntryPointDetails, UserParams, WalletParams } from \"./Config\";\n\nexport const SUPPORTED_KERNEL_VERSIONS = [\"0.3.1\", \"0.3.0\", \"0.2.4\"] as const;\nexport type SupportedKernelVersion = (typeof SUPPORTED_KERNEL_VERSIONS)[number];\n\nexport function isSupportedKernelVersion(version: string): version is SupportedKernelVersion {\n return SUPPORTED_KERNEL_VERSIONS.includes(version as any);\n}\n\nexport const SUPPORTED_ENTRYPOINT_VERSIONS = [\"v0.6\", \"v0.7\"] as const;\nexport type SupportedEntryPointVersion = (typeof SUPPORTED_ENTRYPOINT_VERSIONS)[number];\n\nexport function isSupportedEntryPointVersion(version: string): version is SupportedEntryPointVersion {\n return SUPPORTED_ENTRYPOINT_VERSIONS.includes(version as any);\n}\n\nexport interface WalletCreationParams {\n user: UserParams & { id: string };\n chain: SmartWalletChain;\n publicClient: PublicClient<HttpTransport>;\n walletParams: WalletParams;\n entryPoint: EntryPointDetails;\n kernelVersion: SupportedKernelVersion;\n}\n\nexport interface AccountAndSigner {\n account: KernelSmartAccount<EntryPoint, HttpTransport>;\n signerData: SignerData;\n}\n\nexport type PasskeyValidatorSerializedData = {\n passkeyServerUrl: string;\n entryPoint: Hex;\n validatorAddress: Hex;\n pubKeyX: string;\n pubKeyY: string;\n authenticatorIdHash: Hex;\n authenticatorId: string;\n};\n\nexport type SmartWalletClient = SmartAccountClient<EntryPoint, HttpTransport, Chain, SmartAccount<EntryPoint>>;\n","import { providerToSmartAccountSigner } from \"permissionless\";\nimport type { SmartAccountSigner } from \"permissionless/accounts\";\nimport { Address, EIP1193Provider } from \"viem\";\n\nimport { SmartWalletChain } from \"..\";\nimport { SmartWalletSDKError } from \"../error\";\nimport { ViemAccount, WalletParams } from \"../types/Config\";\nimport { logInputOutput } from \"./log\";\n\ntype CreateOwnerSignerInput = {\n chain: SmartWalletChain;\n walletParams: WalletParams;\n};\n\nexport const createOwnerSigner = logInputOutput(\n async ({ walletParams }: CreateOwnerSignerInput): Promise<SmartAccountSigner<\"custom\", Address>> => {\n if (isEIP1193Provider(walletParams.signer)) {\n return await providerToSmartAccountSigner(walletParams.signer);\n } else if (isAccount(walletParams.signer)) {\n return walletParams.signer.account;\n } else {\n const signer = walletParams.signer as any;\n throw new SmartWalletSDKError(`The signer type ${signer.type} is not supported`);\n }\n },\n \"createOwnerSigner\"\n);\n\nfunction isEIP1193Provider(signer: any): signer is EIP1193Provider {\n return signer && typeof signer.request === \"function\";\n}\n\nexport function isAccount(signer: any): signer is ViemAccount {\n return signer && signer.type === \"VIEM_ACCOUNT\";\n}\n","import { EOASignerData } from \"@/types/API\";\nimport type { EOASigner, WalletParams } from \"@/types/Config\";\nimport { AccountAndSigner, WalletCreationParams } from \"@/types/internal\";\nimport { equalsIgnoreCase } from \"@/utils/helpers\";\nimport { createOwnerSigner } from \"@/utils/signer\";\nimport { signerToEcdsaValidator } from \"@zerodev/ecdsa-validator\";\nimport { createKernelAccount } from \"@zerodev/sdk\";\n\nimport { AdminMismatchError } from \"../../error\";\n\nexport interface EOAWalletParams extends WalletCreationParams {\n walletParams: WalletParams & { signer: EOASigner };\n}\n\nexport class EOAAccountService {\n public async get(\n { chain, publicClient, entryPoint, walletParams, kernelVersion, user }: EOAWalletParams,\n existingSignerConfig?: EOASignerData\n ): Promise<AccountAndSigner> {\n const eoa = await createOwnerSigner({\n chain,\n walletParams,\n });\n\n if (existingSignerConfig != null && !equalsIgnoreCase(eoa.address, existingSignerConfig.eoaAddress)) {\n throw new AdminMismatchError(\n `User '${user.id}' has an existing wallet with an eoa signer '${existingSignerConfig.eoaAddress}', this does not match input eoa signer '${eoa.address}'.`,\n existingSignerConfig,\n { type: \"eoa\", eoaAddress: existingSignerConfig.eoaAddress }\n );\n }\n\n const ecdsaValidator = await signerToEcdsaValidator(publicClient, {\n signer: eoa,\n entryPoint: entryPoint.address,\n kernelVersion,\n });\n const account = await createKernelAccount(publicClient, {\n plugins: {\n sudo: ecdsaValidator,\n },\n index: BigInt(0),\n entryPoint: entryPoint.address,\n kernelVersion,\n });\n\n return { account, signerData: { eoaAddress: eoa.address, type: \"eoa\" } };\n }\n}\n","import type { CrossmintWalletService } from \"@/api/CrossmintWalletService\";\nimport { type PasskeySignerData, displayPasskey } from \"@/types/API\";\nimport type { PasskeySigner, UserParams, WalletParams } from \"@/types/Config\";\nimport type { AccountAndSigner, PasskeyValidatorSerializedData, WalletCreationParams } from \"@/types/internal\";\nimport { PasskeyValidatorContractVersion, WebAuthnMode, toPasskeyValidator } from \"@zerodev/passkey-validator\";\nimport { type KernelValidator, createKernelAccount } from \"@zerodev/sdk\";\nimport { WebAuthnKey, toWebAuthnKey } from \"@zerodev/webauthn-key\";\nimport type { EntryPoint } from \"permissionless/types/entrypoint\";\n\nimport { PasskeyMismatchError } from \"../../error\";\n\nexport interface PasskeyWalletParams extends WalletCreationParams {\n walletParams: WalletParams & { signer: PasskeySigner };\n}\n\nexport function isPasskeyParams(params: WalletCreationParams): params is PasskeyWalletParams {\n return (params.walletParams.signer as PasskeySigner).type === \"PASSKEY\";\n}\n\ntype PasskeyValidator = KernelValidator<EntryPoint, \"WebAuthnValidator\"> & {\n getSerializedData: () => string;\n};\n\nexport class PasskeyAccountService {\n constructor(private readonly crossmintService: CrossmintWalletService) {}\n\n public async get(\n { user, publicClient, walletParams, entryPoint, kernelVersion }: PasskeyWalletParams,\n existingSignerConfig?: PasskeySignerData\n ): Promise<AccountAndSigner> {\n const inputPasskeyName = walletParams.signer.passkeyName ?? user.id;\n if (existingSignerConfig != null && existingSignerConfig.passkeyName !== inputPasskeyName) {\n throw new PasskeyMismatchError(\n `User '${user.id}' has an existing wallet created with a passkey named '${existingSignerConfig.passkeyName}', this does match input passkey name '${inputPasskeyName}'.`,\n displayPasskey(existingSignerConfig)\n );\n }\n\n const passkey = await this.getPasskey(user, inputPasskeyName, existingSignerConfig);\n\n const latestValidatorVersion = PasskeyValidatorContractVersion.V0_0_2;\n const validatorContractVersion =\n existingSignerConfig == null ? latestValidatorVersion : existingSignerConfig.validatorContractVersion;\n const validator = await toPasskeyValidator(publicClient, {\n webAuthnKey: passkey,\n entryPoint: entryPoint.address,\n validatorContractVersion,\n kernelVersion,\n });\n\n const kernelAccount = await createKernelAccount(publicClient, {\n plugins: { sudo: validator },\n entryPoint: entryPoint.address,\n kernelVersion,\n });\n\n return {\n signerData: this.getSignerData(validator, validatorContractVersion, inputPasskeyName),\n account: kernelAccount,\n };\n }\n\n private async getPasskey(\n user: UserParams,\n passkeyName: string,\n existing?: PasskeySignerData\n ): Promise<WebAuthnKey> {\n if (existing != null) {\n return {\n pubX: BigInt(existing.pubKeyX),\n pubY: BigInt(existing.pubKeyY),\n authenticatorId: existing.authenticatorId,\n authenticatorIdHash: existing.authenticatorIdHash,\n };\n }\n\n return toWebAuthnKey({\n passkeyName,\n passkeyServerUrl: this.crossmintService.getPasskeyServerUrl(),\n mode: WebAuthnMode.Register,\n passkeyServerHeaders: this.createPasskeysServerHeaders(user),\n });\n }\n\n private getSignerData(\n validator: PasskeyValidator,\n validatorContractVersion: PasskeyValidatorContractVersion,\n passkeyName: string\n ): PasskeySignerData {\n return {\n ...deserializePasskeyValidatorData(validator.getSerializedData()),\n passkeyName,\n validatorContractVersion,\n domain: window.location.hostname,\n type: \"passkeys\",\n };\n }\n\n private createPasskeysServerHeaders(user: UserParams) {\n return {\n \"x-api-key\": this.crossmintService.crossmintAPIHeaders[\"x-api-key\"],\n Authorization: `Bearer ${user.jwt}`,\n };\n }\n}\n\nconst deserializePasskeyValidatorData = (params: string) => {\n const uint8Array = base64ToBytes(params);\n const jsonString = new TextDecoder().decode(uint8Array);\n\n return JSON.parse(jsonString) as PasskeyValidatorSerializedData;\n};\n\nfunction base64ToBytes(base64: string) {\n const binString = atob(base64);\n return Uint8Array.from(binString, (m) => m.codePointAt(0) as number);\n}\n","import { PAYMASTER_RPC } from \"@/utils/constants\";\nimport { createZeroDevPaymasterClient } from \"@zerodev/sdk\";\nimport { Middleware } from \"permissionless/actions/smartAccount\";\nimport { EntryPoint } from \"permissionless/types/entrypoint\";\nimport { http } from \"viem\";\n\nimport { usesGelatoBundler } from \"../../utils/blockchain\";\nimport { SmartWalletChain, viemNetworks, zerodevProjects } from \"../chains\";\n\nexport function usePaymaster(chain: SmartWalletChain) {\n return !usesGelatoBundler(chain);\n}\n\nconst getPaymasterRPC = (chain: SmartWalletChain) => {\n return PAYMASTER_RPC + zerodevProjects[chain];\n};\n\nexport function paymasterMiddleware({\n entryPoint,\n chain,\n}: {\n entryPoint: EntryPoint;\n chain: SmartWalletChain;\n}): Middleware<EntryPoint> {\n return {\n middleware: {\n sponsorUserOperation: async ({ userOperation }) => {\n const paymasterClient = createZeroDevPaymasterClient({\n chain: viemNetworks[chain],\n transport: http(getPaymasterRPC(chain)),\n entryPoint,\n });\n return paymasterClient.sponsorUserOperation({\n userOperation,\n entryPoint,\n });\n },\n },\n };\n}\n","import { logError } from \"@/services/logging\";\nimport { DatadogProvider } from \"@/services/logging/DatadogProvider\";\nimport { SDK_VERSION } from \"@/utils/constants\";\nimport { BaseError, stringify } from \"viem\";\n\nimport { SmartWalletSDKError } from \".\";\n\nexport class ErrorProcessor {\n constructor(private readonly logger: DatadogProvider) {}\n\n public map(error: unknown, fallback: SmartWalletSDKError): SmartWalletSDKError | BaseError {\n this.record(error);\n\n if (error instanceof SmartWalletSDKError) {\n return error;\n }\n\n // Allow viem errors, which are generally pretty friendly.\n if (error instanceof BaseError) {\n return error;\n }\n\n return fallback;\n }\n\n private record(error: unknown) {\n const message = error instanceof Error ? error.message : String(error);\n this.logger.logError(`Smart Wallet SDK Error: ${message}`, {\n stack: error instanceof Error ? error.stack : undefined,\n name: error instanceof Error ? error.name : \"UnknownError\",\n details: stringify(error),\n domain: window.location.hostname,\n sdk_version: SDK_VERSION,\n });\n }\n}\n"],"mappings":"w+BAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,2BAAAE,EAAA,uBAAAC,EAAA,gBAAAC,EAAA,0BAAAC,EAAA,mBAAAC,EAAA,uBAAAC,EAAA,oBAAAC,EAAA,uBAAAC,EAAA,oBAAAC,EAAA,uCAAAC,EAAA,uBAAAC,EAAA,sBAAAC,EAAA,yBAAAC,EAAA,qBAAAC,GAAA,mBAAAC,GAAA,wBAAAC,EAAA,kBAAAC,EAAA,kCAAAC,EAAA,gEAAAC,GAAApB,IAAA,IAAAqB,GAAoC,sCCA7B,SAASC,GAAW,CACvB,OAAO,OAAO,QAAW,WAC7B,CCFO,SAASC,GAAc,CAC1B,OAAI,QAAQ,IAAI,WAAa,OAClB,GAGJ,OAAO,SAAS,OAAO,SAAS,WAAW,CACtD,CAMO,SAASC,EAAiBC,EAAYC,EAAqB,CAC9D,OAAOD,GAAA,YAAAA,EAAG,kBAAkBC,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B,CACE,MAAM,gBAAgB,EAHL,wBAAAD,EACA,oBAAAC,CAGrB,CAMA,OAAO,KAAK,CAAE,aAAAC,CAAa,EAA6C,CACpE,GAAI,CAACC,EAAS,EACV,MAAM,IAAIC,EAAoB,mDAAmD,EAIrF,GAAI,IADqB,mBAAeF,CAAY,EAC9B,QAClB,MAAM,IAAI,MAAM,iBAAiB,EAGrC,IAAMG,EAAmB,IAAIC,GAAuBJ,CAAY,EAC1DD,EAAiB,IAAIM,GAAe,IAAIC,CAAiB,EAC/D,OAAO,IAAIV,EACP,IAAIW,GAAmBJ,EAAkB,IAAIK,GAAgBT,CAAc,CAAC,EAC5EA,CACJ,CACJ,CAWM,kBACFU,EACAC,EAEuB,QAAAC,EAAA,yBAHvBC,EACAC,EACAC,EAA6B,CAAE,OAAQ,CAAE,KAAM,SAAU,CAAE,EACpC,CACvB,OAAOC,EACH,uBACA,IAAYJ,EAAA,sBACR,GAAI,CACA,OAAO,MAAM,KAAK,mBAAmB,YAAYC,EAAMC,EAAOC,CAAY,CAC9E,OAASE,EAAY,CACjB,MAAM,KAAK,eAAe,IACtBA,EACA,IAAId,EAAoB,2BAA2Bc,EAAM,OAAO,OAAK,cAAUA,CAAK,CAAC,CACzF,CACJ,CACJ,GACA,CAAE,KAAAJ,EAAM,MAAAC,CAAM,CAClB,CACJ,GACJ","names":["src_exports","__export","AdminAlreadyUsedError","AdminMismatchError","ConfigError","CrossmintServiceError","EVMSmartWallet","JWTDecryptionError","JWTExpiredError","JWTIdentifierError","JWTInvalidError","NonCustodialWalletsNotEnabledError","NotAuthorizedError","OutOfCreditsError","PasskeyMismatchError","SmartWalletChain","SmartWalletSDK","SmartWalletSDKError","TransferError","UserWalletAlreadyCreatedError","__toCommonJS","import_common_sdk_base","isClient","isLocalhost","equalsIgnoreCase","a","b","LOG_IN_LOCALHOST","ConsoleProvider","message","context","ZERO_DEV_TYPE","DATADOG_CLIENT_TOKEN","CROSSMINT_DEV_URL","CROSSMINT_STG_URL","CROSSMINT_PROD_URL","SCW_SERVICE","SDK_VERSION","API_VERSION","BUNDLER_RPC","PAYMASTER_RPC","import_browser_logs","DatadogProvider","message","context","log","loggerType","contextParam","_context","__spreadProps","__spreadValues","SCW_SERVICE","init","DATADOG_CLIENT_TOKEN","getBrowserLogger","isClient","isLocalhost","ConsoleProvider","DatadogProvider","logInfo","logWarn","logError","import_viem","SmartWalletErrors","SmartWalletSDKError","message","details","code","TransferError","CrossmintServiceError","status","AdminMismatchError","required","used","PasskeyMismatchError","NotAuthorizedError","JWTExpiredError","expiredAt","JWTInvalidError","JWTDecryptionError","JWTIdentifierError","identifierKey","UserWalletAlreadyCreatedError","userId","OutOfCreditsError","ConfigError","AdminAlreadyUsedError","NonCustodialWalletsNotEnabledError","import_uuid","LoggerWrapper","className","extraInfo","logIdempotencyKey","uuidv4","target","propKey","receiver","origMethod","identifierTag","SCW_SERVICE","args","result","res","err","logInfoIfNotInLocalhost","beautify","__spreadProps","__spreadValues","logError","name","cb","logPerformance","__async","start","durationInMs","logInputOutput","fn","functionName","json","error","stringifyAvoidingCircular","simpleObject","prop","message","context","isLocalhost","logInfo","errorToJSON","_a","errorToLog","import_viem","ERC1155_default","transferParams","contract","config","from","to","ERC1155_default","EVMSmartWallet","LoggerWrapper","crossmintService","accountClient","publicClient","chain","toAddress","config","__async","tx","transferParams","client","request","error","logError","SCW_SERVICE","errorToJSON","tokenIdString","TransferError","import_chains","import_common_sdk_base","SmartWalletTestnet","Blockchain","SMART_WALLET_TESTNETS","SmartWalletMainnet","SMART_WALLET_MAINNETS","SmartWalletChain","__spreadValues","SMART_WALLET_CHAINS","zerodevProjects","viemNetworks","getBundlerRPC","chain","BUNDLER_RPC","import_viem","import_common_sdk_base","import_common_sdk_base","APIErrorService","errors","JWTInvalidError","JWTDecryptionError","expiredAt","JWTExpiredError","identifierKey","JWTIdentifierError","userId","UserWalletAlreadyCreatedError","AdminAlreadyUsedError","NonCustodialWalletsNotEnabledError","_0","__async","response","onServerErrorMessage","CrossmintServiceError","OutOfCreditsError","body","code","e","SmartWalletSDKError","_BaseCrossmintService","LoggerWrapper","apiKey","result","APIErrorService","_0","__async","endpoint","options","onServerErrorMessage","authToken","logPerformance","url","body","method","response","__spreadValues","error","CrossmintServiceError","environment","CROSSMINT_DEV_URL","CROSSMINT_STG_URL","CROSSMINT_PROD_URL","BaseCrossmintService","CrossmintWalletService","BaseCrossmintService","user","input","__async","API_VERSION","chain","address","usesGelatoBundler","chain","import_viem","transactionMethods","signingMethods","isTxnMethod","method","isSignMethod","ClientDecorator","errorProcessor","crossmintChain","smartAccountClient","target","prop","receiver","originalMethod","args","logPerformance","__async","logInfo","processed","error","description","SmartWalletSDKError","userOperation","middleware","account","txn","txnParams","usesGelatoBundler","__spreadProps","__spreadValues","displayPasskey","data","import_sdk","import_permissionless","import_viem","import_common_sdk_base","SUPPORTED_KERNEL_VERSIONS","isSupportedKernelVersion","version","SUPPORTED_ENTRYPOINT_VERSIONS","isSupportedEntryPointVersion","import_permissionless","createOwnerSigner","logInputOutput","_0","__async","walletParams","isEIP1193Provider","isAccount","signer","SmartWalletSDKError","import_ecdsa_validator","import_sdk","EOAAccountService","_0","_1","__async","chain","publicClient","entryPoint","walletParams","kernelVersion","user","existingSignerConfig","eoa","createOwnerSigner","equalsIgnoreCase","AdminMismatchError","ecdsaValidator","import_passkey_validator","import_sdk","import_webauthn_key","isPasskeyParams","params","PasskeyAccountService","crossmintService","_0","_1","__async","user","publicClient","walletParams","entryPoint","kernelVersion","existingSignerConfig","_a","inputPasskeyName","PasskeyMismatchError","displayPasskey","passkey","latestValidatorVersion","validatorContractVersion","validator","kernelAccount","passkeyName","existing","__spreadProps","__spreadValues","deserializePasskeyValidatorData","uint8Array","base64ToBytes","jsonString","base64","binString","m","import_sdk","import_viem","usePaymaster","chain","usesGelatoBundler","getPaymasterRPC","PAYMASTER_RPC","zerodevProjects","paymasterMiddleware","entryPoint","_0","__async","userOperation","viemNetworks","SmartWalletService","crossmintWalletService","clientDecorator","accountFactory","AccountFactory","EOAAccountService","PasskeyAccountService","user","chain","walletParams","__async","entryPoint","kernelVersion","existingSignerConfig","smartContractWalletAddress","userId","publicClient","getBundlerRPC","account","signerData","__spreadProps","__spreadValues","equalsIgnoreCase","UserWalletAlreadyCreatedError","ZERO_DEV_TYPE","kernelAccountClient","viemNetworks","usePaymaster","paymasterMiddleware","smartAccountClient","EVMSmartWallet","entryPointVersion","signers","isSupportedKernelVersion","SmartWalletSDKError","SUPPORTED_KERNEL_VERSIONS","isSupportedEntryPointVersion","SUPPORTED_ENTRYPOINT_VERSIONS","CrossmintServiceError","eoa","passkey","params","isPasskeyParams","AdminMismatchError","displayPasskey","import_viem","ErrorProcessor","logger","error","fallback","SmartWalletSDKError","message","SDK_VERSION","SmartWalletSDK","_SmartWalletSDK","LoggerWrapper","smartWalletService","errorProcessor","clientApiKey","isClient","SmartWalletSDKError","crossmintService","CrossmintWalletService","ErrorProcessor","DatadogProvider","SmartWalletService","ClientDecorator","_0","_1","__async","user","chain","walletParams","logPerformance","error"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/blockchain/wallets/EVMSmartWallet.ts","../src/utils/environment.ts","../src/utils/helpers.ts","../src/services/logging/ConsoleProvider.ts","../src/services/logging/DatadogProvider.ts","../src/utils/constants.ts","../src/services/logging/index.ts","../src/utils/log.ts","../src/blockchain/transfer.ts","../src/ABI/ERC1155.json","../src/error/index.ts","../src/SmartWalletSDK.ts","../src/api/CrossmintWalletService.ts","../src/api/BaseCrossmintService.ts","../src/api/APIErrorService.ts","../src/types/schema.ts","../src/utils/api.ts","../src/blockchain/wallets/account/signer.ts","../src/blockchain/wallets/account/config.ts","../src/types/internal.ts","../src/blockchain/wallets/account/creator.ts","../src/blockchain/wallets/account/eoa.ts","../src/utils/signer.ts","../src/blockchain/wallets/account/passkey.ts","../src/blockchain/wallets/clientDecorator.ts","../src/utils/blockchain.ts","../src/blockchain/wallets/service.ts","../src/blockchain/chains.ts","../src/blockchain/wallets/paymaster.ts","../src/error/processor.ts"],"sourcesContent":["export { blockchainToChainId, EVMBlockchainIncludingTestnet as Chain } from \"@crossmint/common-sdk-base\";\n\nexport { EVMSmartWallet } from \"./blockchain/wallets/EVMSmartWallet\";\n\nexport type {\n SmartWalletSDKInitParams,\n UserParams,\n ViemAccount,\n PasskeySigner,\n EOASigner,\n WalletParams,\n} from \"./types/params\";\n\nexport type { TransferType, ERC20TransferType, NFTTransferType, SFTTransferType } from \"./types/token\";\n\nexport {\n SmartWalletError,\n UserWalletAlreadyCreatedError,\n AdminAlreadyUsedError,\n AdminMismatchError,\n PasskeyMismatchError,\n PasskeyPromptError,\n PasskeyRegistrationError,\n PasskeyIncompatibleAuthenticatorError,\n ConfigError,\n SmartWalletsNotEnabledError,\n} from \"./error\";\n\nexport {\n SmartWalletErrorCode,\n CrossmintSDKError,\n CrossmintServiceError,\n TransferError,\n JWTDecryptionError,\n JWTExpiredError,\n JWTIdentifierError,\n JWTInvalidError,\n NotAuthorizedError,\n} from \"@crossmint/client-sdk-base\";\n\nexport { SmartWalletSDK } from \"./SmartWalletSDK\";\n","import { type HttpTransport, type PublicClient, isAddress, publicActions } from \"viem\";\n\nimport { TransferError } from \"@crossmint/client-sdk-base\";\n\nimport type { CrossmintWalletService } from \"../../api/CrossmintWalletService\";\nimport { logError, logInfo } from \"../../services/logging\";\nimport { SmartWalletClient } from \"../../types/internal\";\nimport type { TransferType } from \"../../types/token\";\nimport { SCW_SERVICE } from \"../../utils/constants\";\nimport { errorToJSON, logPerformance } 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 {\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 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 logPerformance(\n \"TRANSFER\",\n async () => {\n if (this.chain !== config.token.chain) {\n throw new Error(\n `Chain mismatch: Expected ${config.token.chain}, but got ${this.chain}. Ensure you are interacting with the correct blockchain.`\n );\n }\n\n if (!isAddress(toAddress)) {\n throw new Error(`Invalid recipient address: '${toAddress}' is not a valid EVM address.`);\n }\n\n if (!isAddress(config.token.contractAddress)) {\n throw new Error(\n `Invalid contract address: '${config.token.contractAddress}' is not a valid EVM address.`\n );\n }\n\n const tx = transferParams({\n contract: config.token.contractAddress,\n to: toAddress,\n from: this.accountClient.account,\n config,\n });\n\n try {\n const client = this.accountClient.extend(publicActions);\n const { request } = await client.simulateContract(tx);\n const hash = await client.writeContract(request);\n logInfo(`[TRANSFER] - Transaction hash from transfer: ${hash}`);\n\n return hash;\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 { toAddress, config }\n );\n }\n\n /**\n * @returns A list of NFTs owned by the wallet.\n */\n public async nfts() {\n return this.crossmintService.fetchNFTs(this.address, this.chain);\n }\n}\n","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\nexport class ConsoleProvider implements BrowserLoggerInterface {\n logInfo(message: string, context?: object) {\n console.log(message, context);\n }\n\n logError(message: string, context?: object) {\n console.error(message, context);\n }\n\n logWarn(message: string, context?: object) {\n console.warn(message, context);\n }\n}\n","import { datadogLogs } from \"@datadog/browser-logs\";\n\nimport { DATADOG_CLIENT_TOKEN, SCW_SERVICE } from \"../../utils/constants\";\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","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/\";\nexport const SUPPORTED_KERNEL_VERSIONS = [\"0.3.1\", \"0.3.0\", \"0.2.4\"] as const;\nexport const SUPPORTED_ENTRYPOINT_VERSIONS = [\"v0.6\", \"v0.7\"] as const;\n","import { 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, logInfo } from \"../services/logging\";\nimport { SCW_SERVICE } from \"./constants\";\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 logInfo(`[${SCW_SERVICE} - ${name} - TIME] - ${beautify(args)}`, { args });\n return result;\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\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/token\";\n\ntype TransferInputParams = {\n from: Account;\n contract: Address;\n to: Address;\n config: TransferType;\n};\n\ntype TransferSimulationParams = {\n account: Account;\n address: Address;\n abi: Abi;\n functionName: string;\n args: any[];\n tokenId?: string;\n};\n\nexport function transferParams({ contract, config, from, to }: TransferInputParams): TransferSimulationParams {\n switch (config.token.type) {\n case \"ft\": {\n return {\n account: from,\n address: contract,\n abi: erc20Abi,\n functionName: \"transfer\",\n args: [to, (config as ERC20TransferType).amount],\n };\n }\n case \"sft\": {\n return {\n account: from,\n address: contract,\n abi: erc1155Abi as Abi,\n functionName: \"safeTransferFrom\",\n args: [from.address, to, config.token.tokenId, (config as SFTTransferType).quantity, \"0x00\"],\n tokenId: config.token.tokenId,\n };\n }\n case \"nft\": {\n return {\n account: from,\n address: contract,\n abi: erc721Abi,\n functionName: \"safeTransferFrom\",\n args: [from.address, to, config.token.tokenId],\n tokenId: config.token.tokenId,\n };\n }\n }\n}\n","[\n {\n \"inputs\": [\n {\n \"internalType\": \"string\",\n \"name\": \"uri_\",\n \"type\": \"string\"\n }\n ],\n \"stateMutability\": \"nonpayable\",\n \"type\": \"constructor\"\n },\n {\n \"anonymous\": false,\n \"inputs\": [\n {\n \"indexed\": true,\n \"internalType\": \"address\",\n \"name\": \"account\",\n \"type\": \"address\"\n },\n {\n \"indexed\": true,\n \"internalType\": \"address\",\n \"name\": \"operator\",\n \"type\": \"address\"\n },\n {\n \"indexed\": false,\n \"internalType\": \"bool\",\n \"name\": \"approved\",\n \"type\": \"bool\"\n }\n ],\n \"name\": \"ApprovalForAll\",\n \"type\": \"event\"\n },\n {\n \"anonymous\": false,\n \"inputs\": [\n {\n \"indexed\": true,\n \"internalType\": \"address\",\n \"name\": \"operator\",\n \"type\": \"address\"\n },\n {\n \"indexed\": true,\n \"internalType\": \"address\",\n \"name\": \"from\",\n \"type\": \"address\"\n },\n {\n \"indexed\": true,\n \"internalType\": \"address\",\n \"name\": \"to\",\n \"type\": \"address\"\n },\n {\n \"indexed\": false,\n \"internalType\": \"uint256[]\",\n \"name\": \"ids\",\n \"type\": \"uint256[]\"\n },\n {\n \"indexed\": false,\n \"internalType\": \"uint256[]\",\n \"name\": \"values\",\n \"type\": \"uint256[]\"\n }\n ],\n \"name\": \"TransferBatch\",\n \"type\": \"event\"\n },\n {\n \"anonymous\": false,\n \"inputs\": [\n {\n \"indexed\": true,\n \"internalType\": \"address\",\n \"name\": \"operator\",\n \"type\": \"address\"\n },\n {\n \"indexed\": true,\n \"internalType\": \"address\",\n \"name\": \"from\",\n \"type\": \"address\"\n },\n {\n \"indexed\": true,\n \"internalType\": \"address\",\n \"name\": \"to\",\n \"type\": \"address\"\n },\n {\n \"indexed\": false,\n \"internalType\": \"uint256\",\n \"name\": \"id\",\n \"type\": \"uint256\"\n },\n {\n \"indexed\": false,\n \"internalType\": \"uint256\",\n \"name\": \"value\",\n \"type\": \"uint256\"\n }\n ],\n \"name\": \"TransferSingle\",\n \"type\": \"event\"\n },\n {\n \"anonymous\": false,\n \"inputs\": [\n {\n \"indexed\": false,\n \"internalType\": \"string\",\n \"name\": \"value\",\n \"type\": \"string\"\n },\n {\n \"indexed\": true,\n \"internalType\": \"uint256\",\n \"name\": \"id\",\n \"type\": \"uint256\"\n }\n ],\n \"name\": \"URI\",\n \"type\": \"event\"\n },\n {\n \"inputs\": [\n {\n \"internalType\": \"address\",\n \"name\": \"account\",\n \"type\": \"address\"\n },\n {\n \"internalType\": \"uint256\",\n \"name\": \"id\",\n \"type\": \"uint256\"\n }\n ],\n \"name\": \"balanceOf\",\n \"outputs\": [\n {\n \"internalType\": \"uint256\",\n \"name\": \"\",\n \"type\": \"uint256\"\n }\n ],\n \"stateMutability\": \"view\",\n \"type\": \"function\"\n },\n {\n \"inputs\": [\n {\n \"internalType\": \"address[]\",\n \"name\": \"accounts\",\n \"type\": \"address[]\"\n },\n {\n \"internalType\": \"uint256[]\",\n \"name\": \"ids\",\n \"type\": \"uint256[]\"\n }\n ],\n \"name\": \"balanceOfBatch\",\n \"outputs\": [\n {\n \"internalType\": \"uint256[]\",\n \"name\": \"\",\n \"type\": \"uint256[]\"\n }\n ],\n \"stateMutability\": \"view\",\n \"type\": \"function\"\n },\n {\n \"inputs\": [\n {\n \"internalType\": \"address\",\n \"name\": \"account\",\n \"type\": \"address\"\n },\n {\n \"internalType\": \"address\",\n \"name\": \"operator\",\n \"type\": \"address\"\n }\n ],\n \"name\": \"isApprovedForAll\",\n \"outputs\": [\n {\n \"internalType\": \"bool\",\n \"name\": \"\",\n \"type\": \"bool\"\n }\n ],\n \"stateMutability\": \"view\",\n \"type\": \"function\"\n },\n {\n \"inputs\": [\n {\n \"internalType\": \"address\",\n \"name\": \"from\",\n \"type\": \"address\"\n },\n {\n \"internalType\": \"address\",\n \"name\": \"to\",\n \"type\": \"address\"\n },\n {\n \"internalType\": \"uint256[]\",\n \"name\": \"ids\",\n \"type\": \"uint256[]\"\n },\n {\n \"internalType\": \"uint256[]\",\n \"name\": \"amounts\",\n \"type\": \"uint256[]\"\n },\n {\n \"internalType\": \"bytes\",\n \"name\": \"data\",\n \"type\": \"bytes\"\n }\n ],\n \"name\": \"safeBatchTransferFrom\",\n \"outputs\": [],\n \"stateMutability\": \"nonpayable\",\n \"type\": \"function\"\n },\n {\n \"inputs\": [\n {\n \"internalType\": \"address\",\n \"name\": \"from\",\n \"type\": \"address\"\n },\n {\n \"internalType\": \"address\",\n \"name\": \"to\",\n \"type\": \"address\"\n },\n {\n \"internalType\": \"uint256\",\n \"name\": \"id\",\n \"type\": \"uint256\"\n },\n {\n \"internalType\": \"uint256\",\n \"name\": \"amount\",\n \"type\": \"uint256\"\n },\n {\n \"internalType\": \"bytes\",\n \"name\": \"data\",\n \"type\": \"bytes\"\n }\n ],\n \"name\": \"safeTransferFrom\",\n \"outputs\": [],\n \"stateMutability\": \"nonpayable\",\n \"type\": \"function\"\n },\n {\n \"inputs\": [\n {\n \"internalType\": \"address\",\n \"name\": \"operator\",\n \"type\": \"address\"\n },\n {\n \"internalType\": \"bool\",\n \"name\": \"approved\",\n \"type\": \"bool\"\n }\n ],\n \"name\": \"setApprovalForAll\",\n \"outputs\": [],\n \"stateMutability\": \"nonpayable\",\n \"type\": \"function\"\n },\n {\n \"inputs\": [\n {\n \"internalType\": \"bytes4\",\n \"name\": \"interfaceId\",\n \"type\": \"bytes4\"\n }\n ],\n \"name\": \"supportsInterface\",\n \"outputs\": [\n {\n \"internalType\": \"bool\",\n \"name\": \"\",\n \"type\": \"bool\"\n }\n ],\n \"stateMutability\": \"view\",\n \"type\": \"function\"\n },\n {\n \"inputs\": [\n {\n \"internalType\": \"uint256\",\n \"name\": \"\",\n \"type\": \"uint256\"\n }\n ],\n \"name\": \"uri\",\n \"outputs\": [\n {\n \"internalType\": \"string\",\n \"name\": \"\",\n \"type\": \"string\"\n }\n ],\n \"stateMutability\": \"view\",\n \"type\": \"function\"\n }\n]\n","import { CrossmintSDKError, SmartWalletErrorCode } from \"@crossmint/client-sdk-base\";\n\nimport { PasskeyDisplay, SignerDisplay } from \"../types/service\";\n\nexport class SmartWalletError extends CrossmintSDKError {\n constructor(message: string, details?: string, code: SmartWalletErrorCode = SmartWalletErrorCode.UNCATEGORIZED) {\n super(message, code, details);\n }\n}\n\nexport class AdminMismatchError extends SmartWalletError {\n public readonly required: SignerDisplay;\n public readonly used?: SignerDisplay;\n\n constructor(message: string, required: SignerDisplay, used?: SignerDisplay) {\n super(message, SmartWalletErrorCode.ADMIN_MISMATCH);\n this.required = required;\n this.used = used;\n }\n}\n\nexport class PasskeyMismatchError extends SmartWalletError {\n public readonly required: PasskeyDisplay;\n public readonly used?: PasskeyDisplay;\n\n constructor(message: string, required: PasskeyDisplay, used?: PasskeyDisplay) {\n super(message, SmartWalletErrorCode.PASSKEY_MISMATCH);\n this.required = required;\n this.used = used;\n }\n}\n\nexport class UserWalletAlreadyCreatedError extends SmartWalletError {\n public readonly code = SmartWalletErrorCode.USER_WALLET_ALREADY_CREATED;\n\n constructor(userId: string) {\n super(`The user with userId ${userId.toString()} already has a wallet created for this project`);\n }\n}\n\nexport class PasskeyPromptError extends SmartWalletError {\n public passkeyName: string;\n\n constructor(passkeyName: string) {\n super(\n `Prompt was either cancelled or timed out for passkey ${passkeyName}`,\n undefined,\n SmartWalletErrorCode.PASSKEY_PROMPT\n );\n this.passkeyName = passkeyName;\n }\n}\n\nexport class PasskeyRegistrationError extends SmartWalletError {\n public passkeyName: string;\n\n constructor(passkeyName: string) {\n super(\n `Registration for passkey ${passkeyName} failed, either the registration took too long, or passkey signature vaildation failed.`,\n undefined,\n SmartWalletErrorCode.PASSKEY_REGISTRATION\n );\n this.passkeyName = passkeyName;\n }\n}\n\nexport class PasskeyIncompatibleAuthenticatorError extends SmartWalletError {\n public passkeyName: string;\n\n constructor(passkeyName: string) {\n super(\n `User selected authenticator for passkey ${passkeyName} is not compatible with Crossmint's Smart Wallets.`,\n undefined,\n SmartWalletErrorCode.PASSKEY_INCOMPATIBLE_AUTHENTICATOR\n );\n this.passkeyName = passkeyName;\n }\n}\n\nexport class ConfigError extends SmartWalletError {\n constructor(message: string) {\n super(message, undefined, SmartWalletErrorCode.WALLET_CONFIG);\n }\n}\n\nexport class AdminAlreadyUsedError extends ConfigError {\n public readonly code = SmartWalletErrorCode.ADMIN_SIGNER_ALREADY_USED;\n constructor() {\n super(\"This signer was already used to create another wallet. Please use a different signer.\");\n }\n}\n\nexport class SmartWalletsNotEnabledError extends ConfigError {\n public readonly code = SmartWalletErrorCode.SMART_WALLETS_NOT_ENABLED;\n constructor() {\n super(\n \"Smart wallets are not enabled for this project. They can be enabled on the project settings page in the developer console.\"\n );\n }\n}\n","import { stringify } from \"viem\";\n\nimport { validateAPIKey } from \"@crossmint/common-sdk-base\";\n\nimport { CrossmintWalletService } from \"./api/CrossmintWalletService\";\nimport type { SmartWalletChain } from \"./blockchain/chains\";\nimport type { EVMSmartWallet } from \"./blockchain/wallets\";\nimport { AccountConfigFacade } from \"./blockchain/wallets/account/config\";\nimport { AccountCreator } from \"./blockchain/wallets/account/creator\";\nimport { EOACreationStrategy } from \"./blockchain/wallets/account/eoa\";\nimport { PasskeyCreationStrategy } from \"./blockchain/wallets/account/passkey\";\nimport { ClientDecorator } from \"./blockchain/wallets/clientDecorator\";\nimport { SmartWalletService } from \"./blockchain/wallets/service\";\nimport { SmartWalletError } from \"./error\";\nimport { ErrorProcessor } from \"./error/processor\";\nimport { DatadogProvider } from \"./services/logging/DatadogProvider\";\nimport type { SmartWalletSDKInitParams, UserParams, WalletParams } from \"./types/params\";\nimport { isClient } from \"./utils/environment\";\nimport { logPerformance } from \"./utils/log\";\n\nexport class SmartWalletSDK {\n private constructor(\n private readonly smartWalletService: SmartWalletService,\n private readonly errorProcessor: ErrorProcessor\n ) {}\n\n /**\n * Initializes the SDK with the **client side** API key obtained from the Crossmint console.\n * @throws error if the api key is not formatted correctly.\n */\n static init({ clientApiKey }: SmartWalletSDKInitParams): SmartWalletSDK {\n if (!isClient()) {\n throw new SmartWalletError(\"Smart Wallet SDK should only be used client side.\");\n }\n\n const validationResult = validateAPIKey(clientApiKey);\n if (!validationResult.isValid) {\n throw new Error(\"API key invalid\");\n }\n\n const crossmintService = new CrossmintWalletService(clientApiKey);\n const errorProcessor = new ErrorProcessor(new DatadogProvider());\n const accountCreator = new AccountCreator(\n new EOACreationStrategy(),\n new PasskeyCreationStrategy(crossmintService.getPasskeyServerUrl(), clientApiKey)\n );\n\n const smartWalletService = new SmartWalletService(\n crossmintService,\n new AccountConfigFacade(crossmintService),\n accountCreator,\n new ClientDecorator(errorProcessor)\n );\n\n return new SmartWalletSDK(smartWalletService, errorProcessor);\n }\n\n /**\n * Retrieves or creates a wallet for the specified user.\n * The default configuration is a `PasskeySigner` with the name, which is displayed to the user during creation or signing prompts, derived from the provided jwt.\n *\n * Example using the default passkey signer:\n * ```ts\n * const wallet = await smartWalletSDK.getOrCreateWallet({ jwt: \"xxx\" }, \"base\");\n * ```\n */\n async getOrCreateWallet(\n user: UserParams,\n chain: SmartWalletChain,\n walletParams: WalletParams = { signer: { type: \"PASSKEY\" } }\n ): Promise<EVMSmartWallet> {\n return logPerformance(\"GET_OR_CREATE_WALLET\", async () => {\n try {\n return await this.smartWalletService.getOrCreate(user, chain, walletParams);\n } catch (error: any) {\n throw this.errorProcessor.map(\n error,\n new SmartWalletError(`Wallet creation failed: ${error.message}.`, stringify(error))\n );\n }\n });\n }\n}\n","import type { UserOperation } from \"permissionless\";\nimport type { EntryPoint, GetEntryPointVersion } from \"permissionless/types/entrypoint\";\n\nimport { CrossmintServiceError } from \"@crossmint/client-sdk-base\";\nimport { blockchainToChainId } from \"@crossmint/common-sdk-base\";\n\nimport { BaseCrossmintService } from \"../api/BaseCrossmintService\";\nimport type { SmartWalletChain } from \"../blockchain/chains\";\nimport type { UserParams } from \"../types/params\";\nimport { SmartWalletConfigSchema } from \"../types/schema\";\nimport type { SmartWalletConfig, StoreSmartWalletParams } from \"../types/service\";\nimport { bigintsToHex, parseBigintAPIResponse } from \"../utils/api\";\nimport { API_VERSION } from \"../utils/constants\";\n\nexport class CrossmintWalletService extends BaseCrossmintService {\n async idempotentCreateSmartWallet(user: UserParams, input: StoreSmartWalletParams): Promise<void> {\n await this.fetchCrossmintAPI(\n `${API_VERSION}/sdk/smart-wallet`,\n { method: \"PUT\", body: JSON.stringify(input) },\n \"Error creating abstract wallet. Please contact support\",\n user.jwt\n );\n }\n\n async sponsorUserOperation<E extends EntryPoint>(\n user: UserParams,\n userOp: UserOperation<GetEntryPointVersion<E>>,\n entryPoint: E,\n chain: SmartWalletChain\n ): Promise<{ sponsorUserOpParams: UserOperation<GetEntryPointVersion<E>> }> {\n const chainId = blockchainToChainId(chain);\n const result = await this.fetchCrossmintAPI(\n `${API_VERSION}/sdk/paymaster`,\n { method: \"POST\", body: JSON.stringify({ userOp: bigintsToHex(userOp), entryPoint, chainId }) },\n \"Error sponsoring user operation. Please contact support\",\n user.jwt\n );\n return parseBigintAPIResponse(result);\n }\n\n async getSmartWalletConfig(user: UserParams, chain: SmartWalletChain): Promise<SmartWalletConfig> {\n const data: unknown = await this.fetchCrossmintAPI(\n `${API_VERSION}/sdk/smart-wallet/config?chain=${chain}`,\n { method: \"GET\" },\n \"Error getting smart wallet version configuration. Please contact support\",\n user.jwt\n );\n\n const result = SmartWalletConfigSchema.safeParse(data);\n if (result.success) {\n return result.data;\n }\n\n throw new CrossmintServiceError(\n `Invalid smart wallet config, please contact support. Details below:\\n${result.error.toString()}`\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 { CrossmintServiceError } from \"@crossmint/client-sdk-base\";\nimport { validateAPIKey } from \"@crossmint/common-sdk-base\";\n\nimport { CROSSMINT_DEV_URL, CROSSMINT_PROD_URL, CROSSMINT_STG_URL } from \"../utils/constants\";\nimport { logPerformance } from \"../utils/log\";\nimport { APIErrorService } from \"./APIErrorService\";\n\nexport abstract class BaseCrossmintService {\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 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 CrossmintServiceError,\n JWTDecryptionError,\n JWTExpiredError,\n JWTIdentifierError,\n JWTInvalidError,\n OutOfCreditsError,\n} from \"@crossmint/client-sdk-base\";\n\nimport {\n AdminAlreadyUsedError,\n SmartWalletError,\n SmartWalletsNotEnabledError,\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: Record<CrossmintAPIErrorCodes, (apiResponse: any) => SmartWalletError> = {\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 SmartWalletsNotEnabledError(),\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 SmartWalletError) {\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 { PasskeyValidatorContractVersion } from \"@zerodev/passkey-validator\";\nimport { isAddress, isHex } from \"viem\";\nimport { z } from \"zod\";\n\nimport { SUPPORTED_ENTRYPOINT_VERSIONS, SUPPORTED_KERNEL_VERSIONS } from \"../utils/constants\";\n\nconst HexSchema = z.custom<`0x${string}`>((val): val is `0x${string}` => isHex(val as string), {\n message: \"Invalid hex string\",\n});\n\nconst evmAddressSchema = z.custom<`0x${string}`>((val): val is `0x${string}` => isAddress(val as string), {\n message: \"Invalid evm address\",\n});\n\nexport const EOASignerDataSchema = z.object({\n eoaAddress: evmAddressSchema,\n type: z.literal(\"eoa\"),\n});\n\nexport const PasskeyValidatorSerializedDataSchema = z.object({\n entryPoint: evmAddressSchema,\n validatorAddress: evmAddressSchema,\n pubKeyX: z.string(),\n pubKeyY: z.string(),\n authenticatorIdHash: HexSchema,\n authenticatorId: z.string(),\n});\n\nexport const PasskeySignerDataSchema = PasskeyValidatorSerializedDataSchema.extend({\n passkeyName: z.string(),\n validatorContractVersion: z.nativeEnum(PasskeyValidatorContractVersion),\n domain: z.string(),\n type: z.literal(\"passkeys\"),\n});\n\nexport const SignerDataSchema = z.discriminatedUnion(\"type\", [PasskeySignerDataSchema, EOASignerDataSchema]);\n\nexport const SmartWalletConfigSchema = z.object({\n kernelVersion: z.enum(SUPPORTED_KERNEL_VERSIONS, {\n errorMap: (_, ctx) => ({\n message: `Unsupported kernel version. Supported versions: ${SUPPORTED_KERNEL_VERSIONS.join(\n \", \"\n )}. Version used: ${ctx.data}. Please contact support`,\n }),\n }),\n entryPointVersion: z.enum(SUPPORTED_ENTRYPOINT_VERSIONS, {\n errorMap: (_, ctx) => ({\n message: `Unsupported entry point version. Supported versions: ${SUPPORTED_ENTRYPOINT_VERSIONS.join(\n \", \"\n )}. Version used: ${ctx.data}. Please contact support`,\n }),\n }),\n userId: z.string().min(1),\n signers: z\n .array(\n z.object({\n signerData: SignerDataSchema,\n })\n )\n .min(0)\n .max(1, \"Invalid wallet signer configuration. Please contact support\"),\n smartContractWalletAddress: evmAddressSchema.optional(),\n});\n","import { toHex } from \"viem\";\n\nfunction mapObject(data: any, fn: (value: unknown) => { value: unknown; replace: boolean }): any {\n const result = fn(data);\n if (result.replace) {\n return result.value;\n }\n if (Array.isArray(data)) {\n return data.map((item) => mapObject(item, fn));\n } else if (data !== null && typeof data === \"object\") {\n return Object.fromEntries(Object.entries(data).map(([key, value]) => [key, mapObject(value, fn)]));\n }\n return result.value;\n}\n\nexport function bigintsToHex(data: any): any {\n return mapObject(data, (value) => {\n if (typeof value === \"bigint\") {\n return { value: toHex(value), replace: true };\n }\n return { value, replace: false };\n });\n}\n\nexport function parseBigintAPIResponse(data: any): any {\n return mapObject(data, (value) => {\n if (\n value != null &&\n typeof value == \"object\" &&\n \"__xm_serializedType\" in value &&\n \"value\" in value &&\n value.__xm_serializedType === \"bigint\" &&\n typeof value.value === \"string\"\n ) {\n return { value: BigInt(value.value), replace: true };\n }\n return { value, replace: false };\n });\n}\n","import type {\n EOASignerData,\n PasskeyDisplay,\n PasskeySignerData,\n SignerData,\n SignerDisplay,\n} from \"../../../types/service\";\n\nexport interface SignerConfig {\n readonly type: \"passkeys\" | \"eoa\";\n display(): SignerDisplay;\n readonly data: SignerData;\n}\n\nexport class PasskeySignerConfig implements SignerConfig {\n public readonly data: PasskeySignerData;\n public readonly type = \"passkeys\";\n\n constructor(data: PasskeySignerData) {\n this.data = data;\n }\n\n public display(): PasskeyDisplay {\n return {\n pubKeyX: this.data.pubKeyX,\n pubKeyY: this.data.pubKeyY,\n passkeyName: this.data.passkeyName,\n type: this.type,\n };\n }\n}\n\nexport class EOASignerConfig implements SignerConfig {\n public readonly data: EOASignerData;\n public readonly type = \"eoa\";\n\n constructor(data: EOASignerData) {\n this.data = data;\n }\n\n public display() {\n return this.data;\n }\n}\n","import type { Address } from \"viem\";\n\nimport type { CrossmintWalletService } from \"../../../api/CrossmintWalletService\";\nimport type { SmartWalletChain } from \"../../../blockchain/chains\";\nimport { SmartWalletError } from \"../../../error\";\nimport type { SupportedEntryPointVersion, SupportedKernelVersion } from \"../../../types/internal\";\nimport type { UserParams } from \"../../../types/params\";\nimport type { SignerData } from \"../../../types/service\";\nimport { EOASignerConfig, PasskeySignerConfig, type SignerConfig } from \"./signer\";\n\nexport class AccountConfigFacade {\n constructor(private readonly crossmintService: CrossmintWalletService) {}\n\n public async get(\n user: UserParams,\n chain: SmartWalletChain\n ): Promise<{\n entryPointVersion: SupportedEntryPointVersion;\n kernelVersion: SupportedKernelVersion;\n userId: string;\n existingSignerConfig?: SignerConfig;\n smartContractWalletAddress?: Address;\n }> {\n const { entryPointVersion, kernelVersion, signers, smartContractWalletAddress, userId } =\n await this.crossmintService.getSmartWalletConfig(user, chain);\n\n if (\n (entryPointVersion === \"v0.7\" && kernelVersion.startsWith(\"0.2\")) ||\n (entryPointVersion === \"v0.6\" && kernelVersion.startsWith(\"0.3\"))\n ) {\n throw new SmartWalletError(\n `Unsupported combination: entryPoint ${entryPointVersion} and kernel version ${kernelVersion}. Please contact support`\n );\n }\n\n return {\n entryPointVersion,\n kernelVersion,\n userId,\n existingSignerConfig: this.getSigner(signers.map((x) => x.signerData)),\n smartContractWalletAddress,\n };\n }\n\n private getSigner(signers: SignerData[]): SignerConfig | undefined {\n if (signers.length === 0) {\n return undefined;\n }\n\n const data = signers[0];\n\n if (data.type === \"eoa\") {\n return new EOASignerConfig(data);\n }\n\n if (data.type === \"passkeys\") {\n return new PasskeySignerConfig(data);\n }\n }\n}\n","import type { KernelSmartAccount } from \"@zerodev/sdk\";\nimport type { SmartAccountClient } from \"permissionless\";\nimport type { SmartAccount } from \"permissionless/accounts\";\nimport type { EntryPoint } from \"permissionless/types/entrypoint\";\nimport type { Chain, HttpTransport, PublicClient } from \"viem\";\n\nimport type { SmartWalletChain } from \"../blockchain/chains\";\nimport type { EOASignerConfig, PasskeySignerConfig, SignerConfig } from \"../blockchain/wallets/account/signer\";\nimport { SUPPORTED_ENTRYPOINT_VERSIONS, SUPPORTED_KERNEL_VERSIONS } from \"../utils/constants\";\nimport type { EOASigner, PasskeySigner, UserParams, WalletParams } from \"./params\";\n\nexport type SupportedKernelVersion = (typeof SUPPORTED_KERNEL_VERSIONS)[number];\nexport function isSupportedKernelVersion(version: string): version is SupportedKernelVersion {\n return SUPPORTED_KERNEL_VERSIONS.includes(version as any);\n}\n\nexport type SupportedEntryPointVersion = (typeof SUPPORTED_ENTRYPOINT_VERSIONS)[number];\nexport function isSupportedEntryPointVersion(version: string): version is SupportedEntryPointVersion {\n return SUPPORTED_ENTRYPOINT_VERSIONS.includes(version as any);\n}\n\nexport interface WalletCreationParams {\n user: UserParams & { id: string };\n chain: SmartWalletChain;\n publicClient: PublicClient<HttpTransport>;\n walletParams: WalletParams;\n entryPoint: { version: SupportedEntryPointVersion; address: EntryPoint };\n kernelVersion: SupportedKernelVersion;\n existingSignerConfig?: SignerConfig;\n}\n\nexport interface PasskeyCreationParams extends WalletCreationParams {\n walletParams: WalletParams & { signer: PasskeySigner };\n existingSignerConfig?: PasskeySignerConfig;\n}\n\nexport interface EOACreationParams extends WalletCreationParams {\n walletParams: WalletParams & { signer: EOASigner };\n existingSignerConfig?: EOASignerConfig;\n}\n\nexport function isPasskeyCreationParams(params: WalletCreationParams): params is PasskeyCreationParams {\n const hasPasskeyWalletParams =\n \"signer\" in params.walletParams &&\n \"type\" in params.walletParams.signer &&\n params.walletParams.signer.type === \"PASSKEY\";\n\n const signerIsPasskeyOrUndefined =\n params.existingSignerConfig == null || params.existingSignerConfig.type === \"passkeys\";\n\n return hasPasskeyWalletParams && signerIsPasskeyOrUndefined;\n}\n\nexport function isEOACreationParams(params: WalletCreationParams): params is EOACreationParams {\n const hasEOAWalletParams =\n \"signer\" in params.walletParams &&\n ((\"type\" in params.walletParams.signer && params.walletParams.signer.type === \"VIEM_ACCOUNT\") ||\n (\"request\" in params.walletParams.signer && typeof params.walletParams.signer.request === \"function\"));\n\n const signerIsEOAOrUndefined = params.existingSignerConfig == null || params.existingSignerConfig.type === \"eoa\";\n\n return hasEOAWalletParams && signerIsEOAOrUndefined;\n}\n\nexport interface AccountAndSigner {\n account: KernelSmartAccount<EntryPoint, HttpTransport>;\n signerConfig: SignerConfig;\n}\n\nexport type SmartWalletClient = SmartAccountClient<EntryPoint, HttpTransport, Chain, SmartAccount<EntryPoint>>;\n","import { AdminMismatchError, ConfigError } from \"../../../error\";\nimport {\n AccountAndSigner,\n type WalletCreationParams,\n isEOACreationParams,\n isPasskeyCreationParams,\n} from \"../../../types/internal\";\nimport { EOACreationStrategy } from \"./eoa\";\nimport { PasskeyCreationStrategy } from \"./passkey\";\n\nexport class AccountCreator {\n constructor(\n private readonly eoaStrategy: EOACreationStrategy,\n private readonly passkeyStrategy: PasskeyCreationStrategy\n ) {}\n\n public get(params: WalletCreationParams): Promise<AccountAndSigner> {\n if (isPasskeyCreationParams(params)) {\n return this.passkeyStrategy.create(params);\n }\n\n if (isEOACreationParams(params)) {\n return this.eoaStrategy.create(params);\n }\n\n if (params.existingSignerConfig == null) {\n throw new ConfigError(`Unsupported wallet params:\\n${params.walletParams}`);\n }\n\n const signerDisplay = params.existingSignerConfig.display();\n throw new AdminMismatchError(\n `Cannot create wallet with ${params.existingSignerConfig.type} signer for user ${params.user.id}', they already have a wallet with signer:\\n'${signerDisplay}'`,\n signerDisplay\n );\n }\n}\n","import { signerToEcdsaValidator } from \"@zerodev/ecdsa-validator\";\nimport { createKernelAccount } from \"@zerodev/sdk\";\n\nimport { AdminMismatchError } from \"../../../error\";\nimport type { AccountAndSigner, EOACreationParams } from \"../../../types/internal\";\nimport { equalsIgnoreCase } from \"../../../utils/helpers\";\nimport { createOwnerSigner } from \"../../../utils/signer\";\nimport { EOASignerConfig } from \"./signer\";\nimport { AccountCreationStrategy } from \"./strategy\";\n\nexport class EOACreationStrategy implements AccountCreationStrategy {\n public async create({\n chain,\n publicClient,\n entryPoint,\n walletParams,\n kernelVersion,\n user,\n existingSignerConfig,\n }: EOACreationParams): Promise<AccountAndSigner> {\n const eoa = await createOwnerSigner({\n chain,\n walletParams,\n });\n\n if (existingSignerConfig != null && !equalsIgnoreCase(eoa.address, existingSignerConfig.data.eoaAddress)) {\n throw new AdminMismatchError(\n `User '${user.id}' has an existing wallet with an eoa signer '${existingSignerConfig.data.eoaAddress}', this does not match input eoa signer '${eoa.address}'.`,\n existingSignerConfig.display(),\n { type: \"eoa\", eoaAddress: existingSignerConfig.data.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: 0n,\n entryPoint: entryPoint.address,\n kernelVersion,\n });\n\n return { account, signerConfig: new EOASignerConfig({ eoaAddress: eoa.address, type: \"eoa\" }) };\n }\n}\n","import { providerToSmartAccountSigner } from \"permissionless\";\nimport type { SmartAccountSigner } from \"permissionless/accounts\";\nimport { Address, EIP1193Provider } from \"viem\";\n\nimport { SmartWalletChain } from \"../blockchain/chains\";\nimport { SmartWalletError } from \"../error\";\nimport { ViemAccount, WalletParams } from \"../types/params\";\n\ntype CreateOwnerSignerInput = {\n chain: SmartWalletChain;\n walletParams: WalletParams;\n};\n\nexport async function createOwnerSigner({\n walletParams,\n}: CreateOwnerSignerInput): Promise<SmartAccountSigner<\"custom\", Address>> {\n if (isEIP1193Provider(walletParams.signer)) {\n return await providerToSmartAccountSigner(walletParams.signer);\n } else if (isAccount(walletParams.signer)) {\n return walletParams.signer.account;\n } else {\n const signer = walletParams.signer as any;\n throw new SmartWalletError(`The signer type ${signer.type} is not supported`);\n }\n}\n\nfunction isEIP1193Provider(signer: any): signer is EIP1193Provider {\n return signer && typeof signer.request === \"function\";\n}\n\nexport function isAccount(signer: any): signer is ViemAccount {\n return signer && signer.type === \"VIEM_ACCOUNT\";\n}\n","import { PasskeyValidatorContractVersion, WebAuthnMode, toPasskeyValidator } from \"@zerodev/passkey-validator\";\nimport { type KernelSmartAccount, type KernelValidator, createKernelAccount } from \"@zerodev/sdk\";\nimport { type WebAuthnKey, toWebAuthnKey } from \"@zerodev/webauthn-key\";\nimport type { SmartAccount } from \"permissionless/accounts\";\nimport type { EntryPoint } from \"permissionless/types/entrypoint\";\n\nimport {\n PasskeyIncompatibleAuthenticatorError,\n PasskeyMismatchError,\n PasskeyPromptError,\n PasskeyRegistrationError,\n} from \"../../../error\";\nimport type { AccountAndSigner, PasskeyCreationParams } from \"../../../types/internal\";\nimport type { UserParams } from \"../../../types/params\";\nimport type { PasskeySignerData, PasskeyValidatorSerializedData } from \"../../../types/service\";\nimport { PasskeySignerConfig } from \"./signer\";\nimport { AccountCreationStrategy } from \"./strategy\";\n\ntype PasskeyValidator = KernelValidator<EntryPoint, \"WebAuthnValidator\"> & {\n getSerializedData: () => string;\n};\nexport class PasskeyCreationStrategy implements AccountCreationStrategy {\n constructor(private readonly passkeyServerUrl: string, private readonly apiKey: string) {}\n\n public async create({\n user,\n publicClient,\n walletParams,\n entryPoint,\n kernelVersion,\n existingSignerConfig,\n }: PasskeyCreationParams): Promise<AccountAndSigner> {\n const inputPasskeyName = walletParams.signer.passkeyName ?? user.id;\n if (existingSignerConfig != null && existingSignerConfig.data.passkeyName !== inputPasskeyName) {\n throw new PasskeyMismatchError(\n `User '${user.id}' has an existing wallet created with a passkey named '${existingSignerConfig.data.passkeyName}', this does match input passkey name '${inputPasskeyName}'.`,\n existingSignerConfig.display()\n );\n }\n\n try {\n const passkey = await this.getPasskey(user, inputPasskeyName, existingSignerConfig?.data);\n\n const latestValidatorVersion = PasskeyValidatorContractVersion.V0_0_2;\n const validatorContractVersion =\n existingSignerConfig == null\n ? latestValidatorVersion\n : existingSignerConfig.data.validatorContractVersion;\n\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 signerConfig: this.getSignerConfig(validator, validatorContractVersion, inputPasskeyName),\n account: this.decorate(kernelAccount, inputPasskeyName),\n };\n } catch (error) {\n throw this.mapError(error, inputPasskeyName);\n }\n }\n\n private async getPasskey(\n user: UserParams,\n passkeyName: string,\n existing?: PasskeySignerData\n ): Promise<WebAuthnKey> {\n if (existing != null) {\n return {\n pubX: BigInt(existing.pubKeyX),\n pubY: BigInt(existing.pubKeyY),\n authenticatorId: existing.authenticatorId,\n authenticatorIdHash: existing.authenticatorIdHash,\n };\n }\n\n return toWebAuthnKey({\n passkeyName,\n passkeyServerUrl: this.passkeyServerUrl,\n mode: WebAuthnMode.Register,\n passkeyServerHeaders: this.createPasskeysServerHeaders(user),\n });\n }\n\n private getSignerConfig(\n validator: PasskeyValidator,\n validatorContractVersion: PasskeyValidatorContractVersion,\n passkeyName: string\n ): PasskeySignerConfig {\n return new PasskeySignerConfig({\n ...deserializePasskeyValidatorData(validator.getSerializedData()),\n passkeyName,\n validatorContractVersion,\n domain: window.location.hostname,\n type: \"passkeys\",\n });\n }\n\n private createPasskeysServerHeaders(user: UserParams) {\n return {\n \"x-api-key\": this.apiKey,\n Authorization: `Bearer ${user.jwt}`,\n };\n }\n\n private mapError(error: any, passkeyName: string) {\n if (error.code === 0 && error.name === \"DataError\") {\n return new PasskeyIncompatibleAuthenticatorError(passkeyName);\n }\n\n if (error.message === \"Registration not verified\") {\n return new PasskeyRegistrationError(passkeyName);\n }\n\n if (error.code === \"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY\" && error.name === \"NotAllowedError\") {\n return new PasskeyPromptError(passkeyName);\n }\n\n return error;\n }\n\n private decorate<Account extends KernelSmartAccount<EntryPoint>>(account: Account, passkeyName: string): Account {\n return new Proxy(account, {\n get: (target, prop, receiver) => {\n const original = Reflect.get(target, prop, receiver);\n if (typeof original !== \"function\" || typeof prop !== \"string\" || !isAccountSigningMethod(prop)) {\n return original;\n }\n\n return async (...args: any[]) => {\n try {\n return await original.call(target, ...args);\n } catch (error) {\n throw this.mapError(error, passkeyName);\n }\n };\n },\n });\n }\n}\n\nconst accountSigningMethods = [\n \"signMessage\",\n \"signTypedData\",\n \"signUserOperation\",\n \"signTransaction\",\n] as const satisfies readonly (keyof SmartAccount<EntryPoint>)[];\n\nfunction isAccountSigningMethod(method: string): method is (typeof accountSigningMethods)[number] {\n return accountSigningMethods.includes(method as any);\n}\n\nconst deserializePasskeyValidatorData = (params: string) => {\n const uint8Array = base64ToBytes(params);\n const jsonString = new TextDecoder().decode(uint8Array);\n\n return JSON.parse(jsonString) as PasskeyValidatorSerializedData;\n};\n\nfunction base64ToBytes(base64: string) {\n const binString = atob(base64);\n return Uint8Array.from(binString, (m) => m.codePointAt(0) as number);\n}\n","import type { SmartAccountClient } from \"permissionless\";\nimport type { EntryPoint } from \"permissionless/types/entrypoint\";\nimport { stringify } from \"viem\";\n\nimport { SmartWalletError } from \"../../error\";\nimport { ErrorProcessor } from \"../../error/processor\";\nimport { logInfo } from \"../../services/logging\";\nimport { usesGelatoBundler } from \"../../utils/blockchain\";\nimport { logPerformance } from \"../../utils/log\";\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 SmartWalletError(`Error ${description}: ${error.message}`, stringify(error))\n );\n }\n }\n\n private processTxnArgs(prop: TxnMethod, crossmintChain: SmartWalletChain, args: any[]): any[] {\n if (prop === \"sendUserOperation\") {\n const [{ userOperation, middleware, account }] = args as Parameters<\n SmartAccountClient<EntryPoint>[\"sendUserOperation\"]\n >;\n return [\n {\n middleware,\n account,\n userOperation: this.addGelatoBundlerProperties(crossmintChain, userOperation),\n },\n ...args.slice(1),\n ];\n }\n\n const [txn] = args as\n | Parameters<SmartAccountClient<EntryPoint>[\"sendTransaction\"]>\n | Parameters<SmartAccountClient<EntryPoint>[\"writeContract\"]>;\n\n return [this.addGelatoBundlerProperties(crossmintChain, txn), ...args.slice(1)];\n }\n\n /*\n * Chain that ZD uses Gelato as for bundler require special parameters:\n * https://docs.zerodev.app/sdk/faqs/use-with-gelato#transaction-configuration\n */\n private addGelatoBundlerProperties(\n crossmintChain: SmartWalletChain,\n txnParams: { maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint }\n ) {\n if (usesGelatoBundler(crossmintChain)) {\n return { ...txnParams, maxFeePerGas: \"0x0\" as any, maxPriorityFeePerGas: \"0x0\" as any };\n }\n\n return txnParams;\n }\n}\n","import { SmartWalletChain } from \"../blockchain/chains\";\n\nexport function usesGelatoBundler(chain: SmartWalletChain) {\n return false;\n}\n","import { createKernelAccountClient } from \"@zerodev/sdk\";\nimport { ENTRYPOINT_ADDRESS_V06, ENTRYPOINT_ADDRESS_V07 } from \"permissionless\";\nimport { createPublicClient, http } from \"viem\";\n\nimport { blockchainToChainId } from \"@crossmint/common-sdk-base\";\n\nimport type { CrossmintWalletService } from \"../../api/CrossmintWalletService\";\nimport { UserWalletAlreadyCreatedError } from \"../../error\";\nimport type { SmartWalletClient } from \"../../types/internal\";\nimport type { UserParams, WalletParams } from \"../../types/params\";\nimport { CURRENT_VERSION, ZERO_DEV_TYPE } from \"../../utils/constants\";\nimport { equalsIgnoreCase } from \"../../utils/helpers\";\nimport { type SmartWalletChain, getBundlerRPC, viemNetworks } from \"../chains\";\nimport { EVMSmartWallet } from \"./EVMSmartWallet\";\nimport type { AccountConfigFacade } from \"./account/config\";\nimport type { AccountCreator } from \"./account/creator\";\nimport type { ClientDecorator } from \"./clientDecorator\";\nimport { paymasterMiddleware, usePaymaster } from \"./paymaster\";\n\nexport class SmartWalletService {\n constructor(\n private readonly crossmintService: CrossmintWalletService,\n private readonly accountConfigFacade: AccountConfigFacade,\n private readonly accountCreator: AccountCreator,\n private readonly clientDecorator: ClientDecorator\n ) {}\n\n public async getOrCreate(\n user: UserParams,\n chain: SmartWalletChain,\n walletParams: WalletParams\n ): Promise<EVMSmartWallet> {\n const { entryPointVersion, kernelVersion, existingSignerConfig, smartContractWalletAddress, userId } =\n await this.accountConfigFacade.get(user, chain);\n const publicClient = createPublicClient({ transport: http(getBundlerRPC(chain)) });\n\n const { account, signerConfig } = await this.accountCreator.get({\n chain,\n walletParams,\n publicClient,\n user: { ...user, id: userId },\n entryPoint: {\n version: entryPointVersion,\n address: entryPointVersion === \"v0.6\" ? ENTRYPOINT_ADDRESS_V06 : ENTRYPOINT_ADDRESS_V07,\n },\n kernelVersion,\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.crossmintService.idempotentCreateSmartWallet(user, {\n type: ZERO_DEV_TYPE,\n smartContractWalletAddress: account.address,\n signerData: signerConfig.data,\n version: CURRENT_VERSION,\n baseLayer: \"evm\",\n chainId: blockchainToChainId(chain),\n entryPointVersion,\n kernelVersion,\n });\n }\n\n const kernelAccountClient: SmartWalletClient = createKernelAccountClient({\n account,\n chain: viemNetworks[chain],\n entryPoint: account.entryPoint,\n bundlerTransport: http(getBundlerRPC(chain)),\n ...(usePaymaster(chain) &&\n paymasterMiddleware({\n entryPoint: account.entryPoint,\n chain,\n walletService: this.crossmintService,\n user,\n })),\n });\n\n const smartAccountClient = this.clientDecorator.decorate({\n crossmintChain: chain,\n smartAccountClient: kernelAccountClient,\n });\n\n return new EVMSmartWallet(this.crossmintService, smartAccountClient, publicClient, chain);\n }\n}\n","import {\n Chain,\n arbitrum,\n arbitrumSepolia,\n base,\n baseSepolia,\n optimism,\n optimismSepolia,\n polygon,\n polygonAmoy,\n} from \"viem/chains\";\n\nimport { BlockchainIncludingTestnet as Blockchain, ObjectValues, objectValues } from \"@crossmint/common-sdk-base\";\n\nimport { BUNDLER_RPC } from \"../utils/constants\";\n\nexport const SmartWalletTestnet = {\n BASE_SEPOLIA: Blockchain.BASE_SEPOLIA,\n POLYGON_AMOY: Blockchain.POLYGON_AMOY,\n OPTIMISM_SEPOLIA: Blockchain.OPTIMISM_SEPOLIA,\n ARBITRUM_SEPOLIA: Blockchain.ARBITRUM_SEPOLIA,\n} as const;\nexport type SmartWalletTestnet = ObjectValues<typeof SmartWalletTestnet>;\nexport const SMART_WALLET_TESTNETS = objectValues(SmartWalletTestnet);\n\nexport const SmartWalletMainnet = {\n BASE: Blockchain.BASE,\n POLYGON: Blockchain.POLYGON,\n OPTIMISM: Blockchain.OPTIMISM,\n ARBITRUM: Blockchain.ARBITRUM,\n} as const;\nexport type SmartWalletMainnet = ObjectValues<typeof SmartWalletMainnet>;\nexport const SMART_WALLET_MAINNETS = objectValues(SmartWalletMainnet);\n\nexport const SmartWalletChain = {\n ...SmartWalletTestnet,\n ...SmartWalletMainnet,\n} as const;\nexport type SmartWalletChain = ObjectValues<typeof SmartWalletChain>;\nexport const SMART_WALLET_CHAINS = objectValues(SmartWalletChain);\n\nexport const zerodevProjects: Record<SmartWalletChain, string> = {\n polygon: \"5c9f4865-ca8e-44bb-9b9e-3810b2b46f9f\",\n \"polygon-amoy\": \"3deef404-ca06-4a5d-9a58-907c99e7ef00\",\n \"base-sepolia\": \"5a127978-6473-4784-9dfb-f74395b220a6\",\n base: \"e8b3020f-4dde-4176-8a7d-be8102527a5c\",\n \"optimism-sepolia\": \"f8dd488e-eaed-467d-a5de-0184c160f3b1\",\n optimism: \"505950ab-ee07-4a9c-bd16-320ac71a9350\",\n arbitrum: \"a965100f-fedf-4e6b-a207-20f5687fcc4f\",\n \"arbitrum-sepolia\": \"76c860ca-af77-4fb1-8eac-07825952f6f4\",\n};\n\nexport const viemNetworks: Record<SmartWalletChain, Chain> = {\n polygon: polygon,\n \"polygon-amoy\": polygonAmoy,\n base: base,\n \"base-sepolia\": baseSepolia,\n optimism: optimism,\n \"optimism-sepolia\": optimismSepolia,\n arbitrum: arbitrum,\n \"arbitrum-sepolia\": arbitrumSepolia,\n};\n\nexport const getBundlerRPC = (chain: SmartWalletChain) => {\n return BUNDLER_RPC + zerodevProjects[chain];\n};\n","import { CrossmintWalletService } from \"@/api/CrossmintWalletService\";\nimport { Middleware } from \"permissionless/actions/smartAccount\";\nimport { EntryPoint } from \"permissionless/types/entrypoint\";\n\nimport { UserParams } from \"../../types/params\";\nimport { usesGelatoBundler } from \"../../utils/blockchain\";\nimport { SmartWalletChain } from \"../chains\";\n\nexport function usePaymaster(chain: SmartWalletChain) {\n return !usesGelatoBundler(chain);\n}\n\nexport function paymasterMiddleware({\n entryPoint,\n chain,\n walletService,\n user,\n}: {\n entryPoint: EntryPoint;\n chain: SmartWalletChain;\n walletService: CrossmintWalletService;\n user: UserParams;\n}): Middleware<EntryPoint> {\n return {\n middleware: {\n sponsorUserOperation: async ({ userOperation }) => {\n const { sponsorUserOpParams } = await walletService.sponsorUserOperation(\n user,\n userOperation,\n entryPoint,\n chain\n );\n return sponsorUserOpParams;\n },\n },\n };\n}\n","import { BaseError, stringify } from \"viem\";\n\nimport { SmartWalletError } from \".\";\nimport { DatadogProvider } from \"../services/logging/DatadogProvider\";\nimport { SDK_VERSION } from \"../utils/constants\";\n\nexport class ErrorProcessor {\n constructor(private readonly logger: DatadogProvider) {}\n\n public map(error: unknown, fallback: SmartWalletError): SmartWalletError | BaseError {\n this.record(error);\n\n if (error instanceof SmartWalletError) {\n return error;\n }\n\n // Allow viem errors, which are generally pretty friendly.\n if (error instanceof BaseError) {\n return error;\n }\n\n return fallback;\n }\n\n private record(error: unknown) {\n const message = error instanceof Error ? error.message : String(error);\n this.logger.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":"ubAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,2BAAAE,EAAA,uBAAAC,EAAA,2DAAAC,EAAA,+GAAAC,EAAA,0PAAAC,EAAA,yBAAAC,EAAA,uBAAAC,EAAA,6BAAAC,EAAA,qBAAAC,EAAA,mEAAAC,GAAA,gCAAAC,EAAA,oEAAAC,EAAA,gEAAAC,GAAAd,IAAA,I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MC,EAAOC,CAAY,CAC9E,OAASE,EAAY,CACjB,MAAM,KAAK,eAAe,IACtBA,EACA,IAAIhB,EAAiB,2BAA2BgB,EAAM,OAAO,OAAK,cAAUA,CAAK,CAAC,CACtF,CACJ,CACJ,CAAC,CACL,CACJ","names":["src_exports","__export","AdminAlreadyUsedError","AdminMismatchError","ConfigError","EVMSmartWallet","PasskeyIncompatibleAuthenticatorError","PasskeyMismatchError","PasskeyPromptError","PasskeyRegistrationError","SmartWalletError","SmartWalletSDK","SmartWalletsNotEnabledError","UserWalletAlreadyCreatedError","__toCommonJS","import_common_sdk_base","import_viem","import_client_sdk_base","isClient","isLocalhost","equalsIgnoreCase","a","b","ConsoleProvider","message","context","import_browser_logs","ZERO_DEV_TYPE","DATADOG_CLIENT_TOKEN","CROSSMINT_DEV_URL","CROSSMINT_STG_URL","CROSSMINT_PROD_URL","SCW_SERVICE","SDK_VERSION","API_VERSION","BUNDLER_RPC","SUPPORTED_KERNEL_VERSIONS","SUPPORTED_ENTRYPOINT_VERSIONS","DatadogProvider","message","context","log","loggerType","contextParam","_context","SCW_SERVICE","init","DATADOG_CLIENT_TOKEN","getBrowserLogger","isClient","isLocalhost","ConsoleProvider","DatadogProvider","logInfo","logWarn","logError","logPerformance","name","cb","extraInfo","start","result","args","logInfo","SCW_SERVICE","beautify","json","stringifyAvoidingCircular","simpleObject","prop","errorToJSON","error","errorToLog","logError","import_viem","ERC1155_default","transferParams","contract","config","from","to","ERC1155_default","EVMSmartWallet","crossmintService","accountClient","publicClient","chain","toAddress","config","logPerformance","tx","transferParams","client","request","hash","logInfo","error","logError","SCW_SERVICE","errorToJSON","tokenIdString","import_client_sdk_base","SmartWalletError","message","details","code","AdminMismatchError","required","used","PasskeyMismatchError","UserWalletAlreadyCreatedError","userId","PasskeyPromptError","passkeyName","PasskeyRegistrationError","PasskeyIncompatibleAuthenticatorError","ConfigError","AdminAlreadyUsedError","SmartWalletsNotEnabledError","import_client_sdk_base","import_viem","import_common_sdk_base","import_client_sdk_base","import_common_sdk_base","import_client_sdk_base","import_common_sdk_base","import_client_sdk_base","APIErrorService","errors","expiredAt","identifierKey","userId","UserWalletAlreadyCreatedError","AdminAlreadyUsedError","SmartWalletsNotEnabledError","response","onServerErrorMessage","body","code","e","SmartWalletError","_BaseCrossmintService","apiKey","result","APIErrorService","endpoint","options","onServerErrorMessage","authToken","logPerformance","url","body","method","response","error","environment","CROSSMINT_DEV_URL","CROSSMINT_STG_URL","CROSSMINT_PROD_URL","BaseCrossmintService","import_passkey_validator","import_viem","import_zod","HexSchema","val","evmAddressSchema","EOASignerDataSchema","PasskeyValidatorSerializedDataSchema","PasskeySignerDataSchema","SignerDataSchema","SmartWalletConfigSchema","SUPPORTED_KERNEL_VERSIONS","_","ctx","SUPPORTED_ENTRYPOINT_VERSIONS","import_viem","mapObject","data","fn","result","item","key","value","bigintsToHex","parseBigintAPIResponse","CrossmintWalletService","BaseCrossmintService","user","input","API_VERSION","userOp","entryPoint","chain","chainId","result","bigintsToHex","parseBigintAPIResponse","data","SmartWalletConfigSchema","address","PasskeySignerConfig","data","EOASignerConfig","AccountConfigFacade","crossmintService","user","chain","entryPointVersion","kernelVersion","signers","smartContractWalletAddress","userId","SmartWalletError","x","data","EOASignerConfig","PasskeySignerConfig","isPasskeyCreationParams","params","hasPasskeyWalletParams","signerIsPasskeyOrUndefined","isEOACreationParams","hasEOAWalletParams","signerIsEOAOrUndefined","AccountCreator","eoaStrategy","passkeyStrategy","params","isPasskeyCreationParams","isEOACreationParams","ConfigError","signerDisplay","AdminMismatchError","import_ecdsa_validator","import_sdk","import_permissionless","createOwnerSigner","walletParams","isEIP1193Provider","isAccount","signer","SmartWalletError","EOACreationStrategy","chain","publicClient","entryPoint","walletParams","kernelVersion","user","existingSignerConfig","eoa","createOwnerSigner","equalsIgnoreCase","AdminMismatchError","ecdsaValidator","EOASignerConfig","import_passkey_validator","import_sdk","import_webauthn_key","PasskeyCreationStrategy","passkeyServerUrl","apiKey","user","publicClient","walletParams","entryPoint","kernelVersion","existingSignerConfig","inputPasskeyName","PasskeyMismatchError","passkey","latestValidatorVersion","validatorContractVersion","validator","kernelAccount","error","passkeyName","existing","PasskeySignerConfig","deserializePasskeyValidatorData","PasskeyIncompatibleAuthenticatorError","PasskeyRegistrationError","PasskeyPromptError","account","target","prop","receiver","original","isAccountSigningMethod","args","accountSigningMethods","method","params","uint8Array","base64ToBytes","jsonString","base64","binString","m","import_viem","usesGelatoBundler","chain","transactionMethods","signingMethods","isTxnMethod","method","isSignMethod","ClientDecorator","errorProcessor","crossmintChain","smartAccountClient","target","prop","receiver","originalMethod","args","logPerformance","logInfo","processed","error","description","SmartWalletError","userOperation","middleware","account","txn","txnParams","usesGelatoBundler","import_sdk","import_permissionless","import_viem","import_common_sdk_base","import_chains","import_common_sdk_base","SmartWalletTestnet","Blockchain","SMART_WALLET_TESTNETS","SmartWalletMainnet","SMART_WALLET_MAINNETS","SmartWalletChain","SMART_WALLET_CHAINS","zerodevProjects","viemNetworks","getBundlerRPC","chain","BUNDLER_RPC","usePaymaster","chain","usesGelatoBundler","paymasterMiddleware","entryPoint","walletService","user","userOperation","sponsorUserOpParams","SmartWalletService","crossmintService","accountConfigFacade","accountCreator","clientDecorator","user","chain","walletParams","entryPointVersion","kernelVersion","existingSignerConfig","smartContractWalletAddress","userId","publicClient","getBundlerRPC","account","signerConfig","equalsIgnoreCase","UserWalletAlreadyCreatedError","ZERO_DEV_TYPE","kernelAccountClient","viemNetworks","usePaymaster","paymasterMiddleware","smartAccountClient","EVMSmartWallet","import_viem","ErrorProcessor","logger","error","fallback","SmartWalletError","message","SDK_VERSION","SmartWalletSDK","_SmartWalletSDK","smartWalletService","errorProcessor","clientApiKey","isClient","SmartWalletError","crossmintService","CrossmintWalletService","ErrorProcessor","DatadogProvider","accountCreator","AccountCreator","EOACreationStrategy","PasskeyCreationStrategy","SmartWalletService","AccountConfigFacade","ClientDecorator","user","chain","walletParams","logPerformance","error"]}
|