@nevermined-io/core-kit 0.5.22 → 0.5.23

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.
@@ -703,7 +703,7 @@ export class ContractBase extends Instantiable {
703
703
  if (!projectId && !isRelayerMode()) {
704
704
  throw new ContractsError('getBundlerRPC: zeroDevProjectId is required for non-relayer (production) mode');
705
705
  }
706
- return getBundlerRpcUrl(projectId ?? '', this.config.chainId);
706
+ return getBundlerRpcUrl(projectId ?? '', this.config.chainId, this.config.useUltraRelay);
707
707
  }
708
708
  getPaymasterRPC() {
709
709
  // Only ever consulted when `getPaymasterConfig` decides to attach a
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/contracts/ContractBase.ts"],"sourcesContent":["import { createKernelAccountClient, createZeroDevPaymasterClient } from '@zerodev/sdk'\nimport {\n estimateUserOperationFees,\n getBundlerRpcUrl,\n getPaymasterRpcUrl,\n isRelayerMode,\n} from '../nevermined/utils/BlockchainViemUtils.js'\nimport {\n Abi,\n Account,\n Address,\n BaseError,\n ContractFunctionRevertedError,\n encodeFunctionData,\n getContract,\n http,\n parseAbi,\n parseEventLogs,\n TransactionReceipt,\n} from 'viem'\nimport {\n createBundlerClient,\n getUserOperationHash,\n SmartAccount,\n UserOperationReceipt,\n} from 'viem/account-abstraction'\nimport { ContractsError, ContractSimulationError } from '../errors/index.js'\nimport { Instantiable, InstantiableConfig } from '../Instantiable.abstract.js'\nimport { TxParameters } from '../models/Transactions.js'\nimport { getInputsOfFunctionFormatted, getTransactionReceipt } from '../nevermined/index.js'\nimport { getRandomBigInt } from '../utils/helpers.js'\nimport { getChain } from '../utils/Network.js'\n\nexport interface MulticallEntry {\n contractName?: string\n contractAddress: Address\n abi: Abi\n functionName: string\n args: any[]\n}\n\n/**\n * When a testnet RPC (Base Sepolia) fails internally, some providers return\n * `eth_estimateGas` values equal to — or even above — the block gas limit\n * instead of a real error. Using that value causes the node to reject the tx\n * with `intrinsic gas too high` before it ever reaches the mempool.\n *\n * `writeContract` in viem re-estimates gas internally when `gas` isn't\n * already set on the request (viem's `simulateContract` only performs\n * `eth_call`, not `eth_estimateGas`). That means the naïve path has no\n * chance to intercept a bogus estimate. We run the estimation ourselves\n * here, sanity-check the result, and always pass an explicit gas value\n * into `writeContract` so it doesn't re-query the misbehaving RPC.\n */\nconst GAS_SANITY_THRESHOLD = 25_000_000n\nconst GAS_FALLBACK_CAP = 5_000_000n\n\n// EntryPoint v0.7: ZeroDev's `toKernelPluginManager` rejects `customNonceKey > maxUint16`.\n// 16 bits = 65 536 channels — collision probability for the SDK's expected concurrency\n// (k=2–5 parallel sends from one SCA) is negligible (< 0.02 %). High-fan-out callers\n// (k > 50) should consider a per-process monotonic counter instead. See issue #1579.\nconst ZERODEV_NONCE_KEY_BITS = 16\n\n// Client-side cap on `waitForUserOperationReceipt`. The userOp is already in the bundler\n// mempool when this fires — a client-side timeout does NOT cancel it. Callers that catch\n// the resulting `ContractsError` MUST poll `bundlerClient.getUserOperationReceipt(hash)`\n// before retrying; otherwise a retry can produce a duplicate on-chain op.\nconst USEROP_RECEIPT_TIMEOUT_MS = 90_000\n\nfunction capForBogusEstimate(\n estimatedGas: bigint,\n logger: { warn: (msg: string) => void },\n): bigint {\n if (estimatedGas < GAS_SANITY_THRESHOLD) return estimatedGas\n logger.warn(\n `Estimated gas (${estimatedGas}) exceeds sanity threshold ` +\n `(${GAS_SANITY_THRESHOLD}); overriding with ${GAS_FALLBACK_CAP} to bypass misbehaving RPC estimate.`,\n )\n return GAS_FALLBACK_CAP\n}\n\nexport interface SimulateMulticallEntry {\n functionName: string\n value?: bigint\n abi: Abi\n args: any[]\n to: Address\n}\n\nexport abstract class ContractBase extends Instantiable {\n public readonly contractName: string\n public contract: any\n public address: Address\n private _zeroDevPaymaster: ReturnType<typeof createZeroDevPaymasterClient> | null = null\n\n constructor(contractName: string, address: Address) {\n super()\n this.contractName = contractName\n this.address = address\n }\n\n protected async init(\n config: InstantiableConfig,\n contractConfig: { address: `0x${string}`; abi: Abi },\n ) {\n this.setInstanceConfig(config)\n this.address = contractConfig.address\n\n this.contract = getContract({\n address: contractConfig.address,\n abi: contractConfig.abi,\n client: { public: this.publicClient, wallet: this.walletClient },\n })\n }\n\n public async call<T>(functionName: string, args: any[], from?: string): Promise<T> {\n try {\n return (await this.client.public.readContract({\n address: this.address,\n abi: this.contract.abi,\n functionName: parseAbi([functionName]),\n args,\n ...(from && { account: from as `0x${string}` }),\n })) as T\n //return await this.contract[functionSignature](...args, { from })\n } catch (err) {\n throw new ContractsError(\n `Calling method \"${functionName}\" on contract \"${this.contractName}\" failed. Args: ${args} - ${err}`,\n )\n }\n }\n\n public async getTransactionReceipt(\n txHash: UserOperationReceipt | TransactionReceipt,\n ): Promise<TransactionReceipt> {\n // Get the transaction receipt depending on the type of txHash\n if ('transactionHash' in txHash) {\n // txHash is TransactionReceipt\n return txHash\n } else if ('userOpHash' in txHash) {\n // txHash is UserOperationReceipt, fetch the actual receipt using the utility function with retry logic\n const hash = txHash.receipt.transactionHash\n return await getTransactionReceipt({\n txHash: hash,\n publicClient: this.client.public,\n })\n } else {\n throw new Error('Unknown transaction type')\n }\n }\n\n public getTransactionLogs(\n txReceipt: TransactionReceipt | UserOperationReceipt,\n eventName?: string,\n ) {\n return parseEventLogs({\n abi: this.contract.abi,\n logs: txReceipt.logs,\n eventName,\n strict: false,\n }) as any[]\n }\n\n public async multicall(\n calls: MulticallEntry[],\n from: Account | SmartAccount,\n params: TxParameters = {},\n ) {\n if (from.type === 'local') {\n this.logger.debug(`Blockchain Multicall using Local account`)\n return await this.localAccountMulticall(calls, from, params, params.progress)\n } else if (from.type === 'json-rpc') {\n this.logger.debug(`Blockchain Multicall using JSON-RPC account`)\n return await this.localAccountMulticall(calls, from, params, params.progress)\n } else if (from.type === 'smart') {\n this.logger.debug(`Blockchain Multicall using ZeroDev account`)\n return await this.internalMulticallSmartAccount(calls, from, params, params.progress)\n } else {\n throw new ContractsError(`Account not supported`)\n }\n }\n\n public async simulateMulticall(\n calls: SimulateMulticallEntry[],\n from: Account | SmartAccount,\n params: TxParameters = {},\n ) {\n if (from.type === 'local') {\n this.logger.debug(`Simulating calls using Local account`)\n return await this.localAccountSimulateMulticall(calls, from, params)\n } else if (from.type === 'json-rpc') {\n this.logger.debug(`Simulating calls using JSON-RPC account`)\n return await this.localAccountSimulateMulticall(calls, from, params)\n } else if (from.type === 'smart') {\n this.logger.debug(`Simulating calls using Smart Account account`)\n return await this.internalSimulateMulticallSmartAccount(calls, from, params)\n } else {\n throw new ContractsError(`Account not supported`)\n }\n }\n\n public async simulate(\n functionName: string,\n from: Account | SmartAccount,\n args: any[],\n params: TxParameters = {},\n ) {\n if (from.type === 'local') {\n this.logger.debug(`Simulating calls using Local account`)\n return await this.localAccountSimulate(functionName, from, args, params)\n } else if (from.type === 'json-rpc') {\n this.logger.debug(`Simulating calls using JSON-RPC account`)\n return await this.localAccountSimulate(functionName, from, args, params)\n } else if (from.type === 'smart') {\n this.logger.debug(`Simulating calls using Smart Account account`)\n return await this.internalSimulateSmartAccount(functionName, from, args, params)\n } else {\n throw new ContractsError(`Account not supported`)\n }\n }\n\n public async send(\n functionName: string,\n from: Account | SmartAccount,\n args: any[],\n params: TxParameters = {},\n ): Promise<TransactionReceipt | UserOperationReceipt> {\n if (from.type === 'local') {\n this.logger.debug(\n `Blockchain Send using Local account with functionName: ${functionName} and following args: ${args}`,\n )\n return await this.localAccountSend(functionName, from, args, params, params.progress)\n } else if (from.type === 'json-rpc') {\n this.logger.debug(`Blockchain Send using JSON-RPC account to ${functionName}`)\n return await this.localAccountSend(functionName, from, args, params, params.progress)\n } else if (from.type === 'smart') {\n this.logger.debug(`Blockchain Send using ZeroDev account`)\n return await this.internalSendSmartAccount(functionName, from, args, params, params.progress)\n } else {\n throw new ContractsError(`Account not supported`)\n }\n }\n\n /**\n * Poll a previously-submitted UserOperation's receipt by hash WITHOUT\n * blocking. Returns the receipt once the bundler has mined it, or `null`\n * while it is still in the mempool / not yet known. A client-side\n * receipt-wait timeout does NOT cancel a submitted UserOp, so callers that\n * persist the hash (e.g. the onchain-mirror worker, nvm-monorepo#1508) use\n * this to confirm a prior submission instead of resubmitting a duplicate.\n */\n public async getUserOperationReceipt(hash: `0x${string}`): Promise<UserOperationReceipt | null> {\n try {\n const bundlerClient = createBundlerClient({\n chain: getChain(this.config.chainId),\n transport: http(this.getBundlerRPC()),\n client: this.client.public,\n })\n return (await bundlerClient.getUserOperationReceipt({ hash })) ?? null\n } catch (err) {\n // A genuinely-absent receipt (UserOp still in the mempool) is expected\n // and benign — some bundlers signal it by throwing rather than returning\n // null. Anything else (RPC/transport/config fault) must NOT masquerade as\n // \"still pending\": surface it at `warn` so a bundler outage is visible\n // instead of silently driving the caller's grace-window logic. Either\n // way we return null so the caller re-polls rather than consuming a retry.\n const message = err instanceof Error ? err.message : String(err)\n if (/not[\\s_]?found|UserOperationReceiptNotFound/i.test(message)) {\n this.logger.debug(`getUserOperationReceipt(${hash}): not yet mined`)\n } else {\n // Redact URLs before logging: the bundler RPC URL embeds the ZeroDev\n // project id, which should not leak into logs.\n const safeMessage = message.replace(/https?:\\/\\/[^\\s'\")]+/gi, '<redacted-url>')\n this.logger.warn(\n `getUserOperationReceipt(${hash}) lookup error (treating as not-yet-mined): ${safeMessage}`,\n )\n }\n return null\n }\n }\n\n private async internalMulticallSmartAccount(\n calls: MulticallEntry[],\n from: SmartAccount,\n txparams: any,\n progress: ((data: any) => void) | undefined,\n ) {\n if (progress) {\n progress({\n stage: 'multicall-sending',\n args: [],\n method: '',\n from: from,\n contractAddress: this.address,\n })\n }\n\n const kernelClient = createKernelAccountClient({\n account: from,\n chain: getChain(this.config.chainId),\n bundlerTransport: http(this.getBundlerRPC()),\n client: this.client.public,\n ...this.getPaymasterConfig(),\n userOperation: {\n estimateFeesPerGas: async ({ bundlerClient }) => {\n return estimateUserOperationFees(bundlerClient, this.client.public)\n },\n },\n })\n\n const encodedCalls: any[] = []\n calls.map((call) => {\n encodedCalls.push({\n to: call.contractAddress || this.address,\n value: txparams.value || 0n,\n data: encodeFunctionData({\n abi: call.abi,\n functionName: call.functionName,\n args: call.args,\n }),\n })\n })\n\n let userOpHash: `0x${string}` | undefined\n try {\n // Random nonce key per send so concurrent userOps from the same SCA\n // hit distinct EntryPoint nonce channels instead of colliding on the\n // default `customNonceKey=0n`. See issue #1579.\n const nonce = await from.getNonce({ key: getRandomBigInt(ZERODEV_NONCE_KEY_BITS) })\n userOpHash = await kernelClient.sendUserOperation({\n callData: await kernelClient.account.encodeCalls(encodedCalls),\n nonce,\n })\n\n if (progress) {\n progress({\n stage: 'multicall-sent',\n args: [],\n method: '',\n from: from,\n contractAddress: this.address,\n })\n }\n\n // Wait for the transaction to be mined\n this.logger.debug(`Waiting for transaction to be mined... ${userOpHash}`)\n const txReceipt = await kernelClient.waitForUserOperationReceipt({\n hash: userOpHash,\n timeout: USEROP_RECEIPT_TIMEOUT_MS,\n })\n this.logger.debug(`Transaction mined - UserOperationHash: ${userOpHash}`)\n this.logger.debug(\n `Transaction receipt - TransactionHash: ${txReceipt.receipt.transactionHash}`,\n )\n this.assertUserOpSucceeded(txReceipt, 'multicall', userOpHash)\n return txReceipt.receipt\n } catch (err) {\n if (err instanceof BaseError) {\n const revertError = err.walk((err) => err instanceof ContractFunctionRevertedError)\n this.logger.error(`revertError: ${String(revertError)}`)\n }\n // Surface userOpHash so callers can poll for eventual inclusion before\n // retrying — a client-side receipt-wait timeout does NOT cancel the userOp.\n const hashSuffix = userOpHash ? ` userOpHash=${userOpHash}` : ''\n throw new ContractsError(`Multicall failed:${hashSuffix} ${err}`)\n }\n }\n\n private assertUserOpSucceeded(\n txReceipt: UserOperationReceipt,\n method: string,\n userOpHash: string,\n ): void {\n if (txReceipt.success) return\n throw new ContractsError(\n `UserOp inner call reverted for \"${method}\" on \"${this.contractName}\". ` +\n `userOpHash=${userOpHash} txHash=${txReceipt.receipt.transactionHash} ` +\n `reason=${txReceipt.reason ?? 'unknown'}`,\n )\n }\n\n private async internalSendSmartAccount(\n name: string,\n from: SmartAccount,\n args: any[],\n txparams: any,\n progress: ((data: any) => void) | undefined,\n ): Promise<UserOperationReceipt> {\n const functionInputs = getInputsOfFunctionFormatted(this.contract.abi, name, args)\n\n const { gasLimit, value } = txparams\n if (progress) {\n progress({\n stage: 'sending',\n args: functionInputs,\n method: name,\n from: from,\n value,\n contractName: this.contractName,\n contractAddress: this.address,\n gasLimit,\n })\n }\n\n try {\n await this.client.public.simulateContract({\n address: this.address,\n abi: this.contract.abi,\n functionName: name,\n args,\n account: from,\n ...(txparams.value && { value: txparams.value }),\n })\n } catch (err) {\n if (err instanceof BaseError) {\n const revertError = err.walk((err) => err instanceof ContractFunctionRevertedError)\n this.logger.error(`revertError: ${String(revertError)}`)\n }\n throw new ContractsError(\n `Calling method \"${name}\" on contract \"${this.contractName}\" failed. Args: ${args} - ${err}`,\n )\n }\n\n const kernelClient = createKernelAccountClient({\n account: from,\n chain: getChain(this.config.chainId),\n bundlerTransport: http(this.getBundlerRPC()),\n client: this.client.public,\n ...this.getPaymasterConfig(),\n userOperation: {\n estimateFeesPerGas: async ({ bundlerClient }) => {\n return estimateUserOperationFees(bundlerClient, this.client.public)\n },\n },\n })\n const data = encodeFunctionData({ abi: this.contract.abi, functionName: name, args })\n\n let userOpHash\n try {\n // Random nonce key per send so concurrent userOps from the same SCA\n // hit distinct EntryPoint nonce channels instead of colliding on the\n // default `customNonceKey=0n`. See issue #1579.\n const nonce = await from.getNonce({ key: getRandomBigInt(ZERODEV_NONCE_KEY_BITS) })\n const callData = await kernelClient.account.encodeCalls([\n {\n to: this.address,\n value: txparams.value || 0n,\n data,\n },\n ])\n\n // When a caller supplies a `progress` callback it may need the UserOp\n // hash BEFORE the send completes — the onchain-mirror worker races the\n // send against a per-tick deadline and must persist the hash even if the\n // send is cut off mid-flight, otherwise it resubmits and double-burns\n // (#1508/#1904). So prepare the UserOp here, surface its hash via\n // `progress({stage:'prepared'})`, and send that exact prepared op so the\n // bundler-returned hash matches. Best-effort and GATED ON `progress`:\n // any failure falls back to the normal send, and callers that pass no\n // progress callback keep the original send path byte-for-byte.\n let preparedUserOp: Awaited<ReturnType<typeof kernelClient.prepareUserOperation>> | undefined\n let preparedHash: `0x${string}` | undefined\n if (progress) {\n try {\n preparedUserOp = await kernelClient.prepareUserOperation({ callData, nonce })\n preparedHash = getUserOperationHash({\n chainId: this.config.chainId,\n entryPointAddress: from.entryPoint.address,\n entryPointVersion: from.entryPoint.version,\n userOperation: preparedUserOp,\n })\n progress({\n stage: 'prepared',\n args: functionInputs,\n userOpHash: preparedHash,\n method: name,\n from: from,\n value,\n contractName: this.contractName,\n contractAddress: this.address,\n gasLimit,\n })\n } catch (prepErr) {\n this.logger.warn(\n `prepareUserOperation (pre-send hash) failed for \"${name}\"; ` +\n `sending without an early hash: ${prepErr}`,\n )\n preparedUserOp = undefined\n preparedHash = undefined\n }\n }\n\n userOpHash = await kernelClient.sendUserOperation(\n // Re-send the exact prepared op (stripping the estimation stub\n // signature so the kernel re-signs) so the bundler hash matches the one\n // emitted above. Falls back to the original {callData, nonce} path\n // (which prepares internally) when no early hash was prepared.\n preparedUserOp\n ? ({ ...preparedUserOp, signature: undefined } as Parameters<\n typeof kernelClient.sendUserOperation\n >[0])\n : { callData, nonce },\n )\n\n // Determinism guard: the 'prepared' hash should equal the bundler's. If a\n // paymaster re-request changed the op it won't — a caller that persisted\n // the 'prepared' hash then just fails to find it and reconciles safely\n // (never a double-burn), but we log so we can see whether the early-hash\n // path is actually holding in practice.\n if (preparedHash && userOpHash !== preparedHash) {\n this.logger.warn(\n `UserOp 'prepared' hash ${preparedHash} != sent hash ${userOpHash} for \"${name}\"; ` +\n `early-hash callers will reconcile via receipt-not-found`,\n )\n }\n } catch (err) {\n if (err instanceof BaseError) {\n const revertError = err.walk((err) => err instanceof ContractFunctionRevertedError)\n this.logger.error(`revertError: ${String(revertError)}`)\n }\n throw new ContractsError(\n `Calling method \"${name}\" on contract \"${this.contractName}\" failed. Args: ${args} - ${err}`,\n )\n }\n\n if (progress) {\n progress({\n stage: 'sent',\n args: functionInputs,\n userOpHash,\n method: name,\n from: from,\n value,\n contractName: this.contractName,\n contractAddress: this.address,\n gasLimit,\n })\n }\n\n let txReceipt: UserOperationReceipt\n try {\n txReceipt = await kernelClient.waitForUserOperationReceipt({\n hash: userOpHash,\n timeout: USEROP_RECEIPT_TIMEOUT_MS,\n })\n } catch (err) {\n // The userOp is already in the bundler mempool — a client-side timeout\n // does NOT cancel it. Surface userOpHash so callers can poll for eventual\n // inclusion before retrying, otherwise a retry can produce a duplicate\n // on-chain op. Wrap symmetric to `internalMulticallSmartAccount`.\n throw new ContractsError(\n `Calling method \"${name}\" on contract \"${this.contractName}\" timed out ` +\n `waiting for UserOp receipt. userOpHash=${userOpHash} — confirm on-chain ` +\n `inclusion before retrying. Underlying: ${err}`,\n )\n }\n\n this.assertUserOpSucceeded(txReceipt, name, userOpHash)\n\n if (progress) {\n progress({\n stage: 'receipt',\n args: functionInputs,\n txReceipt,\n method: name,\n from: from,\n value,\n contractName: this.contractName,\n contractAddress: this.address,\n gasLimit,\n })\n }\n\n return txReceipt\n }\n\n private async internalSimulateSmartAccount(\n name: string,\n from: SmartAccount,\n args: any[],\n txparams: any,\n ) {\n try {\n await this.client.public.simulateContract({\n address: this.address,\n abi: this.contract.abi,\n functionName: name,\n args,\n account: from.address,\n ...(txparams.value && { value: txparams.value }),\n })\n return true\n } catch (err) {\n throw new ContractSimulationError(\n `Error Simulating contract call \"${name}\" on contract \"${this.contractName}\" failed. Args: ${args} - ${err}`,\n )\n }\n }\n\n private async localAccountSimulate(\n name: string,\n from: Account | `0x${string}`,\n args: any[],\n txparams: any,\n ) {\n try {\n await this.client.public.simulateContract({\n address: this.address,\n abi: this.contract.abi,\n functionName: name,\n args,\n account: from,\n ...(txparams.value && { value: txparams.value }),\n })\n } catch (err) {\n throw new ContractSimulationError(\n `Error Simulating contract call \"${name}\" on contract \"${this.contractName}\" failed. Args: ${args} - ${err}`,\n )\n }\n return true\n }\n\n private async localAccountSend(\n name: string,\n from: Account | `0x${string}`,\n args: any[],\n txparams: any,\n progress: ((data: any) => void) | undefined,\n _contractAbi?: Abi,\n _contractAddress?: Address,\n _contractName?: string,\n ) {\n const abi = _contractAbi || this.contract.abi\n const contractAddress = _contractAddress || this.address\n const contractName = _contractName || this.contractName\n\n const functionInputs = getInputsOfFunctionFormatted(abi, name, args)\n // Uncomment to debug contract calls\n // if (name === 'order') {\n // const functionSignature = getSignatureOfFunction(this.contract.abi, name, args)\n // this.logger.info(`Making contract call ....: ${name} - ${from}`)\n // this.logger.info(`With args: `, JSON.stringify(args, jsonReplacer))\n // this.logger.info(`And signature: ${JSON.stringify(functionSignature, jsonReplacer)}`)\n // this.logger.info('And amount: ', txparams.value)\n // }\n // abi.filter(({name, inputs}) => name === 'closeSignals' && inputs.length === 1)\n // const abiFilter = this.contract.abi.filter((abi) => abi.name === name && abi.inputs.length === args.length)\n // const abiFilter = this.contract.abi.filter((abi) => abi.name === name && abi.type === 'function')\n // console.debug('abi', this.contract.abi.filter((abi) => abi.name === name))\n // console.debug('abiFilter', abiFilter)\n // if (!abiFilter)\n // throw new ContractsError(\n // `No ABI found for method \"${name}\" with ${args.length} arguments on contract \"${this.contractName}\"`,\n // )\n\n const { gasLimit, value } = txparams\n // make the call\n if (progress) {\n progress({\n stage: 'sending',\n args: functionInputs,\n method: name,\n from,\n value,\n contractName,\n contractAddress,\n gasLimit,\n })\n }\n\n let txHash: `0x${string}` | undefined\n try {\n const { request } = await this.client.public.simulateContract({\n address: contractAddress,\n abi,\n functionName: name,\n args,\n account: from,\n ...(txparams.value && { value: txparams.value }),\n })\n\n // Resolve gas ourselves so `writeContract` never falls back to its own\n // `eth_estimateGas`. An explicit caller `gasLimit` always wins; otherwise\n // we estimate, apply the block-limit sanity check, and pin the result.\n // If estimation itself fails we still honour any explicit cap.\n let resolvedGas: bigint | undefined = gasLimit\n if (resolvedGas === undefined) {\n try {\n const estimate = await this.client.public.estimateContractGas({\n address: contractAddress,\n abi,\n functionName: name,\n args,\n account: from,\n ...(txparams.value && { value: txparams.value }),\n })\n resolvedGas = capForBogusEstimate(estimate, this.logger)\n } catch (estErr) {\n this.logger.warn(\n `estimateContractGas for \"${name}\" on \"${contractName}\" failed (${estErr}); ` +\n `falling back to ${GAS_FALLBACK_CAP} to avoid a bogus RPC re-estimate in writeContract.`,\n )\n resolvedGas = GAS_FALLBACK_CAP\n }\n }\n\n txHash = await this.client.wallet.writeContract({\n ...request,\n account: from,\n gas: resolvedGas,\n })\n } catch (err) {\n if (err instanceof BaseError) {\n const revertError = err.walk((err) => err instanceof ContractFunctionRevertedError)\n this.logger.error(`revertError: ${String(revertError)}`)\n }\n throw new ContractsError(\n `Calling method \"${name}\" on contract \"${contractName}\" failed. Args: ${args} - ${err}`,\n )\n }\n\n if (progress) {\n progress({\n stage: 'sent',\n args: functionInputs,\n txHash,\n method: name,\n from,\n value,\n contractName,\n contractAddress,\n gasLimit,\n })\n }\n const txReceipt = getTransactionReceipt({ txHash, publicClient: this.client.public })\n\n if (progress) {\n progress({\n stage: 'receipt',\n args: functionInputs,\n txReceipt,\n method: name,\n from,\n value,\n contractName,\n contractAddress,\n gasLimit,\n })\n }\n\n return txReceipt\n }\n\n private async localAccountMulticall(\n calls: MulticallEntry[],\n from: Account,\n txparams: any,\n progress: ((data: any) => void) | undefined,\n ): Promise<TransactionReceipt> {\n const receipts: TransactionReceipt[] = []\n for (const call of calls) {\n receipts.push(\n await this.localAccountSend(\n call.functionName,\n from,\n call.args,\n txparams,\n progress,\n call.abi,\n call.contractAddress,\n call.contractName,\n ),\n )\n }\n if (receipts.length > 0) return receipts.pop() as TransactionReceipt\n else throw new ContractsError(`No receipts found for multicall`)\n }\n\n private async localAccountSimulateMulticall(\n calls: SimulateMulticallEntry[],\n from: Account,\n txparams: any,\n ) {\n try {\n const { results } = await this.client.public.simulateCalls({\n calls,\n account: from,\n })\n this.logger.debug(`Simulated multicall - ${results}`)\n return true\n } catch (err) {\n if (err instanceof BaseError) {\n const revertError = err.walk((err) => err instanceof ContractFunctionRevertedError)\n this.logger.error(`revertError: ${String(revertError)}`)\n }\n throw new ContractsError(`Error simulating multicall - ${err}`)\n }\n }\n\n private async internalSimulateMulticallSmartAccount(\n calls: SimulateMulticallEntry[],\n from: SmartAccount,\n txparams: any,\n ) {\n try {\n const kernelClient = createKernelAccountClient({\n account: from,\n chain: getChain(this.config.chainId),\n bundlerTransport: http(this.getBundlerRPC()),\n client: this.client.public,\n ...this.getPaymasterConfig(),\n userOperation: {\n estimateFeesPerGas: async ({ bundlerClient }) => {\n return estimateUserOperationFees(bundlerClient, this.client.public)\n },\n },\n })\n\n const encodedCalls = []\n for (const call of calls) {\n encodedCalls.push({\n to: call.to,\n value: call.value || 0n,\n data: encodeFunctionData({\n abi: call.abi,\n functionName: call.functionName,\n args: call.args,\n }),\n })\n }\n\n // DONT DELETE THE COMMENTED LINES - ARE NECESSARY FOR F***ING ZERODEV DEBUGGING\n\n // this.logger.info(`Encoded multicall - ${JSON.stringify(encodedCalls, jsonReplacer)}`)\n // const code = await this.client.public.getCode({ address: from.address })\n // const isDeployed = code !== undefined && code !== '0x'\n // this.logger.info(`++++++ Smart account ${from.address} deployment status: ${isDeployed ? 'DEPLOYED' : 'NOT DEPLOYED'}`)\n\n // // Log account details\n // this.logger.info(`Account type: ${from.type}`)\n // this.logger.info(`Account address: ${from.address}`)\n\n // // Log the calls being made\n // this.logger.info(`Number of calls: ${encodedCalls.length}`)\n // encodedCalls.forEach((call, index) => {\n // this.logger.info(`Call ${index}: to=${call.to}, value=${call.value}, data=${call.data.slice(0, 10)}...`)\n // })\n\n await kernelClient.prepareUserOperation({\n callData: await kernelClient.account.encodeCalls(encodedCalls),\n })\n\n return true\n } catch (err) {\n this.logger.error(`Error details: ${JSON.stringify(err, null, 2)}`)\n if (err instanceof BaseError) {\n const revertError = err.walk((e) => e instanceof ContractFunctionRevertedError)\n if (revertError) {\n this.logger.error(`Revert error: ${String(revertError)}`)\n }\n }\n throw new ContractSimulationError(`Error Simulating Multicalls - ${err}`)\n }\n }\n\n private getOrCreatePaymaster() {\n if (!this._zeroDevPaymaster) {\n this._zeroDevPaymaster = createZeroDevPaymasterClient({\n chain: getChain(this.config.chainId),\n transport: http(this.getPaymasterRPC()),\n })\n }\n return this._zeroDevPaymaster\n }\n\n /**\n * Builds the `paymaster` partial for `createKernelAccountClient`. In relayer\n * mode (e.g. local `ultra-relay` for tests) returns an empty object so the\n * kernel client submits UserOps without paymaster fields and the bundler\n * pays gas via its executor key. In production returns the ZeroDev paymaster\n * sponsorship callback.\n */\n private getPaymasterConfig() {\n if (isRelayerMode()) return {}\n const zerodevPaymaster = this.getOrCreatePaymaster()\n return {\n paymaster: {\n getPaymasterData: (userOperation: any) =>\n zerodevPaymaster.sponsorUserOperation({ userOperation }),\n },\n }\n }\n\n protected getBundlerRPC(): string {\n // In relayer mode `getBundlerRpcUrl` reads `BUNDLER_RPC_URL_OVERRIDE`\n // and never touches the project id, so an empty value is harmless. In\n // production callers must pass a project id — surface a clear error if\n // the SDK was instantiated without one and we need it.\n const projectId = this.config.zeroDevProjectId\n if (!projectId && !isRelayerMode()) {\n throw new ContractsError(\n 'getBundlerRPC: zeroDevProjectId is required for non-relayer (production) mode',\n )\n }\n return getBundlerRpcUrl(projectId ?? '', this.config.chainId)\n }\n\n private getPaymasterRPC(): string {\n // Only ever consulted when `getPaymasterConfig` decides to attach a\n // paymaster, which is gated on `!isRelayerMode()`. A missing project\n // id at this point is a configuration bug worth surfacing.\n const projectId = this.config.zeroDevProjectId\n if (!projectId) {\n throw new ContractsError(\n 'getPaymasterRPC: zeroDevProjectId is required to build the paymaster URL',\n )\n }\n return getPaymasterRpcUrl(projectId, this.config.chainId)\n }\n}\n"],"names":["createKernelAccountClient","createZeroDevPaymasterClient","estimateUserOperationFees","getBundlerRpcUrl","getPaymasterRpcUrl","isRelayerMode","BaseError","ContractFunctionRevertedError","encodeFunctionData","getContract","http","parseAbi","parseEventLogs","createBundlerClient","getUserOperationHash","ContractsError","ContractSimulationError","Instantiable","getInputsOfFunctionFormatted","getTransactionReceipt","getRandomBigInt","getChain","GAS_SANITY_THRESHOLD","GAS_FALLBACK_CAP","ZERODEV_NONCE_KEY_BITS","USEROP_RECEIPT_TIMEOUT_MS","capForBogusEstimate","estimatedGas","logger","warn","ContractBase","contractName","address","_zeroDevPaymaster","init","config","contractConfig","setInstanceConfig","contract","abi","client","public","publicClient","wallet","walletClient","call","functionName","args","from","readContract","account","err","txHash","hash","receipt","transactionHash","Error","getTransactionLogs","txReceipt","eventName","logs","strict","multicall","calls","params","type","debug","localAccountMulticall","progress","internalMulticallSmartAccount","simulateMulticall","localAccountSimulateMulticall","internalSimulateMulticallSmartAccount","simulate","localAccountSimulate","internalSimulateSmartAccount","send","localAccountSend","internalSendSmartAccount","getUserOperationReceipt","bundlerClient","chain","chainId","transport","getBundlerRPC","message","String","test","safeMessage","replace","txparams","stage","method","contractAddress","kernelClient","bundlerTransport","getPaymasterConfig","userOperation","estimateFeesPerGas","encodedCalls","map","push","to","value","data","userOpHash","nonce","getNonce","key","sendUserOperation","callData","encodeCalls","waitForUserOperationReceipt","timeout","assertUserOpSucceeded","revertError","walk","error","hashSuffix","success","reason","name","functionInputs","gasLimit","simulateContract","preparedUserOp","preparedHash","prepareUserOperation","entryPointAddress","entryPoint","entryPointVersion","version","prepErr","undefined","signature","_contractAbi","_contractAddress","_contractName","request","resolvedGas","estimate","estimateContractGas","estErr","writeContract","gas","receipts","length","pop","results","simulateCalls","JSON","stringify","e","getOrCreatePaymaster","getPaymasterRPC","zerodevPaymaster","paymaster","getPaymasterData","sponsorUserOperation","projectId","zeroDevProjectId"],"mappings":"AAAA,SAASA,yBAAyB,EAAEC,4BAA4B,QAAQ,eAAc;AACtF,SACEC,yBAAyB,EACzBC,gBAAgB,EAChBC,kBAAkB,EAClBC,aAAa,QACR,6CAA4C;AACnD,SAIEC,SAAS,EACTC,6BAA6B,EAC7BC,kBAA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U,eACR;QAEJ;QACA,OAAOZ,iBAAiB4J,aAAa,IAAI,IAAI,CAAC5H,MAAM,CAAC+C,OAAO;IAC9D;IAEQwE,kBAA0B;QAChC,oEAAoE;QACpE,qEAAqE;QACrE,2DAA2D;QAC3D,MAAMK,YAAY,IAAI,CAAC5H,MAAM,CAAC6H,gBAAgB;QAC9C,IAAI,CAACD,WAAW;YACd,MAAM,IAAIhJ,eACR;QAEJ;QACA,OAAOX,mBAAmB2J,WAAW,IAAI,CAAC5H,MAAM,CAAC+C,OAAO;IAC1D;AACF"}
1
+ {"version":3,"sources":["../../src/contracts/ContractBase.ts"],"sourcesContent":["import { createKernelAccountClient, createZeroDevPaymasterClient } from '@zerodev/sdk'\nimport {\n estimateUserOperationFees,\n getBundlerRpcUrl,\n getPaymasterRpcUrl,\n isRelayerMode,\n} from '../nevermined/utils/BlockchainViemUtils.js'\nimport {\n Abi,\n Account,\n Address,\n BaseError,\n ContractFunctionRevertedError,\n encodeFunctionData,\n getContract,\n http,\n parseAbi,\n parseEventLogs,\n TransactionReceipt,\n} from 'viem'\nimport {\n createBundlerClient,\n getUserOperationHash,\n SmartAccount,\n UserOperationReceipt,\n} from 'viem/account-abstraction'\nimport { ContractsError, ContractSimulationError } from '../errors/index.js'\nimport { Instantiable, InstantiableConfig } from '../Instantiable.abstract.js'\nimport { TxParameters } from '../models/Transactions.js'\nimport { getInputsOfFunctionFormatted, getTransactionReceipt } from '../nevermined/index.js'\nimport { getRandomBigInt } from '../utils/helpers.js'\nimport { getChain } from '../utils/Network.js'\n\nexport interface MulticallEntry {\n contractName?: string\n contractAddress: Address\n abi: Abi\n functionName: string\n args: any[]\n}\n\n/**\n * When a testnet RPC (Base Sepolia) fails internally, some providers return\n * `eth_estimateGas` values equal to — or even above — the block gas limit\n * instead of a real error. Using that value causes the node to reject the tx\n * with `intrinsic gas too high` before it ever reaches the mempool.\n *\n * `writeContract` in viem re-estimates gas internally when `gas` isn't\n * already set on the request (viem's `simulateContract` only performs\n * `eth_call`, not `eth_estimateGas`). That means the naïve path has no\n * chance to intercept a bogus estimate. We run the estimation ourselves\n * here, sanity-check the result, and always pass an explicit gas value\n * into `writeContract` so it doesn't re-query the misbehaving RPC.\n */\nconst GAS_SANITY_THRESHOLD = 25_000_000n\nconst GAS_FALLBACK_CAP = 5_000_000n\n\n// EntryPoint v0.7: ZeroDev's `toKernelPluginManager` rejects `customNonceKey > maxUint16`.\n// 16 bits = 65 536 channels — collision probability for the SDK's expected concurrency\n// (k=2–5 parallel sends from one SCA) is negligible (< 0.02 %). High-fan-out callers\n// (k > 50) should consider a per-process monotonic counter instead. See issue #1579.\nconst ZERODEV_NONCE_KEY_BITS = 16\n\n// Client-side cap on `waitForUserOperationReceipt`. The userOp is already in the bundler\n// mempool when this fires — a client-side timeout does NOT cancel it. Callers that catch\n// the resulting `ContractsError` MUST poll `bundlerClient.getUserOperationReceipt(hash)`\n// before retrying; otherwise a retry can produce a duplicate on-chain op.\nconst USEROP_RECEIPT_TIMEOUT_MS = 90_000\n\nfunction capForBogusEstimate(\n estimatedGas: bigint,\n logger: { warn: (msg: string) => void },\n): bigint {\n if (estimatedGas < GAS_SANITY_THRESHOLD) return estimatedGas\n logger.warn(\n `Estimated gas (${estimatedGas}) exceeds sanity threshold ` +\n `(${GAS_SANITY_THRESHOLD}); overriding with ${GAS_FALLBACK_CAP} to bypass misbehaving RPC estimate.`,\n )\n return GAS_FALLBACK_CAP\n}\n\nexport interface SimulateMulticallEntry {\n functionName: string\n value?: bigint\n abi: Abi\n args: any[]\n to: Address\n}\n\nexport abstract class ContractBase extends Instantiable {\n public readonly contractName: string\n public contract: any\n public address: Address\n private _zeroDevPaymaster: ReturnType<typeof createZeroDevPaymasterClient> | null = null\n\n constructor(contractName: string, address: Address) {\n super()\n this.contractName = contractName\n this.address = address\n }\n\n protected async init(\n config: InstantiableConfig,\n contractConfig: { address: `0x${string}`; abi: Abi },\n ) {\n this.setInstanceConfig(config)\n this.address = contractConfig.address\n\n this.contract = getContract({\n address: contractConfig.address,\n abi: contractConfig.abi,\n client: { public: this.publicClient, wallet: this.walletClient },\n })\n }\n\n public async call<T>(functionName: string, args: any[], from?: string): Promise<T> {\n try {\n return (await this.client.public.readContract({\n address: this.address,\n abi: this.contract.abi,\n functionName: parseAbi([functionName]),\n args,\n ...(from && { account: from as `0x${string}` }),\n })) as T\n //return await this.contract[functionSignature](...args, { from })\n } catch (err) {\n throw new ContractsError(\n `Calling method \"${functionName}\" on contract \"${this.contractName}\" failed. Args: ${args} - ${err}`,\n )\n }\n }\n\n public async getTransactionReceipt(\n txHash: UserOperationReceipt | TransactionReceipt,\n ): Promise<TransactionReceipt> {\n // Get the transaction receipt depending on the type of txHash\n if ('transactionHash' in txHash) {\n // txHash is TransactionReceipt\n return txHash\n } else if ('userOpHash' in txHash) {\n // txHash is UserOperationReceipt, fetch the actual receipt using the utility function with retry logic\n const hash = txHash.receipt.transactionHash\n return await getTransactionReceipt({\n txHash: hash,\n publicClient: this.client.public,\n })\n } else {\n throw new Error('Unknown transaction type')\n }\n }\n\n public getTransactionLogs(\n txReceipt: TransactionReceipt | UserOperationReceipt,\n eventName?: string,\n ) {\n return parseEventLogs({\n abi: this.contract.abi,\n logs: txReceipt.logs,\n eventName,\n strict: false,\n }) as any[]\n }\n\n public async multicall(\n calls: MulticallEntry[],\n from: Account | SmartAccount,\n params: TxParameters = {},\n ) {\n if (from.type === 'local') {\n this.logger.debug(`Blockchain Multicall using Local account`)\n return await this.localAccountMulticall(calls, from, params, params.progress)\n } else if (from.type === 'json-rpc') {\n this.logger.debug(`Blockchain Multicall using JSON-RPC account`)\n return await this.localAccountMulticall(calls, from, params, params.progress)\n } else if (from.type === 'smart') {\n this.logger.debug(`Blockchain Multicall using ZeroDev account`)\n return await this.internalMulticallSmartAccount(calls, from, params, params.progress)\n } else {\n throw new ContractsError(`Account not supported`)\n }\n }\n\n public async simulateMulticall(\n calls: SimulateMulticallEntry[],\n from: Account | SmartAccount,\n params: TxParameters = {},\n ) {\n if (from.type === 'local') {\n this.logger.debug(`Simulating calls using Local account`)\n return await this.localAccountSimulateMulticall(calls, from, params)\n } else if (from.type === 'json-rpc') {\n this.logger.debug(`Simulating calls using JSON-RPC account`)\n return await this.localAccountSimulateMulticall(calls, from, params)\n } else if (from.type === 'smart') {\n this.logger.debug(`Simulating calls using Smart Account account`)\n return await this.internalSimulateMulticallSmartAccount(calls, from, params)\n } else {\n throw new ContractsError(`Account not supported`)\n }\n }\n\n public async simulate(\n functionName: string,\n from: Account | SmartAccount,\n args: any[],\n params: TxParameters = {},\n ) {\n if (from.type === 'local') {\n this.logger.debug(`Simulating calls using Local account`)\n return await this.localAccountSimulate(functionName, from, args, params)\n } else if (from.type === 'json-rpc') {\n this.logger.debug(`Simulating calls using JSON-RPC account`)\n return await this.localAccountSimulate(functionName, from, args, params)\n } else if (from.type === 'smart') {\n this.logger.debug(`Simulating calls using Smart Account account`)\n return await this.internalSimulateSmartAccount(functionName, from, args, params)\n } else {\n throw new ContractsError(`Account not supported`)\n }\n }\n\n public async send(\n functionName: string,\n from: Account | SmartAccount,\n args: any[],\n params: TxParameters = {},\n ): Promise<TransactionReceipt | UserOperationReceipt> {\n if (from.type === 'local') {\n this.logger.debug(\n `Blockchain Send using Local account with functionName: ${functionName} and following args: ${args}`,\n )\n return await this.localAccountSend(functionName, from, args, params, params.progress)\n } else if (from.type === 'json-rpc') {\n this.logger.debug(`Blockchain Send using JSON-RPC account to ${functionName}`)\n return await this.localAccountSend(functionName, from, args, params, params.progress)\n } else if (from.type === 'smart') {\n this.logger.debug(`Blockchain Send using ZeroDev account`)\n return await this.internalSendSmartAccount(functionName, from, args, params, params.progress)\n } else {\n throw new ContractsError(`Account not supported`)\n }\n }\n\n /**\n * Poll a previously-submitted UserOperation's receipt by hash WITHOUT\n * blocking. Returns the receipt once the bundler has mined it, or `null`\n * while it is still in the mempool / not yet known. A client-side\n * receipt-wait timeout does NOT cancel a submitted UserOp, so callers that\n * persist the hash (e.g. the onchain-mirror worker, nvm-monorepo#1508) use\n * this to confirm a prior submission instead of resubmitting a duplicate.\n */\n public async getUserOperationReceipt(hash: `0x${string}`): Promise<UserOperationReceipt | null> {\n try {\n const bundlerClient = createBundlerClient({\n chain: getChain(this.config.chainId),\n transport: http(this.getBundlerRPC()),\n client: this.client.public,\n })\n return (await bundlerClient.getUserOperationReceipt({ hash })) ?? null\n } catch (err) {\n // A genuinely-absent receipt (UserOp still in the mempool) is expected\n // and benign — some bundlers signal it by throwing rather than returning\n // null. Anything else (RPC/transport/config fault) must NOT masquerade as\n // \"still pending\": surface it at `warn` so a bundler outage is visible\n // instead of silently driving the caller's grace-window logic. Either\n // way we return null so the caller re-polls rather than consuming a retry.\n const message = err instanceof Error ? err.message : String(err)\n if (/not[\\s_]?found|UserOperationReceiptNotFound/i.test(message)) {\n this.logger.debug(`getUserOperationReceipt(${hash}): not yet mined`)\n } else {\n // Redact URLs before logging: the bundler RPC URL embeds the ZeroDev\n // project id, which should not leak into logs.\n const safeMessage = message.replace(/https?:\\/\\/[^\\s'\")]+/gi, '<redacted-url>')\n this.logger.warn(\n `getUserOperationReceipt(${hash}) lookup error (treating as not-yet-mined): ${safeMessage}`,\n )\n }\n return null\n }\n }\n\n private async internalMulticallSmartAccount(\n calls: MulticallEntry[],\n from: SmartAccount,\n txparams: any,\n progress: ((data: any) => void) | undefined,\n ) {\n if (progress) {\n progress({\n stage: 'multicall-sending',\n args: [],\n method: '',\n from: from,\n contractAddress: this.address,\n })\n }\n\n const kernelClient = createKernelAccountClient({\n account: from,\n chain: getChain(this.config.chainId),\n bundlerTransport: http(this.getBundlerRPC()),\n client: this.client.public,\n ...this.getPaymasterConfig(),\n userOperation: {\n estimateFeesPerGas: async ({ bundlerClient }) => {\n return estimateUserOperationFees(bundlerClient, this.client.public)\n },\n },\n })\n\n const encodedCalls: any[] = []\n calls.map((call) => {\n encodedCalls.push({\n to: call.contractAddress || this.address,\n value: txparams.value || 0n,\n data: encodeFunctionData({\n abi: call.abi,\n functionName: call.functionName,\n args: call.args,\n }),\n })\n })\n\n let userOpHash: `0x${string}` | undefined\n try {\n // Random nonce key per send so concurrent userOps from the same SCA\n // hit distinct EntryPoint nonce channels instead of colliding on the\n // default `customNonceKey=0n`. See issue #1579.\n const nonce = await from.getNonce({ key: getRandomBigInt(ZERODEV_NONCE_KEY_BITS) })\n userOpHash = await kernelClient.sendUserOperation({\n callData: await kernelClient.account.encodeCalls(encodedCalls),\n nonce,\n })\n\n if (progress) {\n progress({\n stage: 'multicall-sent',\n args: [],\n method: '',\n from: from,\n contractAddress: this.address,\n })\n }\n\n // Wait for the transaction to be mined\n this.logger.debug(`Waiting for transaction to be mined... ${userOpHash}`)\n const txReceipt = await kernelClient.waitForUserOperationReceipt({\n hash: userOpHash,\n timeout: USEROP_RECEIPT_TIMEOUT_MS,\n })\n this.logger.debug(`Transaction mined - UserOperationHash: ${userOpHash}`)\n this.logger.debug(\n `Transaction receipt - TransactionHash: ${txReceipt.receipt.transactionHash}`,\n )\n this.assertUserOpSucceeded(txReceipt, 'multicall', userOpHash)\n return txReceipt.receipt\n } catch (err) {\n if (err instanceof BaseError) {\n const revertError = err.walk((err) => err instanceof ContractFunctionRevertedError)\n this.logger.error(`revertError: ${String(revertError)}`)\n }\n // Surface userOpHash so callers can poll for eventual inclusion before\n // retrying — a client-side receipt-wait timeout does NOT cancel the userOp.\n const hashSuffix = userOpHash ? ` userOpHash=${userOpHash}` : ''\n throw new ContractsError(`Multicall failed:${hashSuffix} ${err}`)\n }\n }\n\n private assertUserOpSucceeded(\n txReceipt: UserOperationReceipt,\n method: string,\n userOpHash: string,\n ): void {\n if (txReceipt.success) return\n throw new ContractsError(\n `UserOp inner call reverted for \"${method}\" on \"${this.contractName}\". ` +\n `userOpHash=${userOpHash} txHash=${txReceipt.receipt.transactionHash} ` +\n `reason=${txReceipt.reason ?? 'unknown'}`,\n )\n }\n\n private async internalSendSmartAccount(\n name: string,\n from: SmartAccount,\n args: any[],\n txparams: any,\n progress: ((data: any) => void) | undefined,\n ): Promise<UserOperationReceipt> {\n const functionInputs = getInputsOfFunctionFormatted(this.contract.abi, name, args)\n\n const { gasLimit, value } = txparams\n if (progress) {\n progress({\n stage: 'sending',\n args: functionInputs,\n method: name,\n from: from,\n value,\n contractName: this.contractName,\n contractAddress: this.address,\n gasLimit,\n })\n }\n\n try {\n await this.client.public.simulateContract({\n address: this.address,\n abi: this.contract.abi,\n functionName: name,\n args,\n account: from,\n ...(txparams.value && { value: txparams.value }),\n })\n } catch (err) {\n if (err instanceof BaseError) {\n const revertError = err.walk((err) => err instanceof ContractFunctionRevertedError)\n this.logger.error(`revertError: ${String(revertError)}`)\n }\n throw new ContractsError(\n `Calling method \"${name}\" on contract \"${this.contractName}\" failed. Args: ${args} - ${err}`,\n )\n }\n\n const kernelClient = createKernelAccountClient({\n account: from,\n chain: getChain(this.config.chainId),\n bundlerTransport: http(this.getBundlerRPC()),\n client: this.client.public,\n ...this.getPaymasterConfig(),\n userOperation: {\n estimateFeesPerGas: async ({ bundlerClient }) => {\n return estimateUserOperationFees(bundlerClient, this.client.public)\n },\n },\n })\n const data = encodeFunctionData({ abi: this.contract.abi, functionName: name, args })\n\n let userOpHash\n try {\n // Random nonce key per send so concurrent userOps from the same SCA\n // hit distinct EntryPoint nonce channels instead of colliding on the\n // default `customNonceKey=0n`. See issue #1579.\n const nonce = await from.getNonce({ key: getRandomBigInt(ZERODEV_NONCE_KEY_BITS) })\n const callData = await kernelClient.account.encodeCalls([\n {\n to: this.address,\n value: txparams.value || 0n,\n data,\n },\n ])\n\n // When a caller supplies a `progress` callback it may need the UserOp\n // hash BEFORE the send completes — the onchain-mirror worker races the\n // send against a per-tick deadline and must persist the hash even if the\n // send is cut off mid-flight, otherwise it resubmits and double-burns\n // (#1508/#1904). So prepare the UserOp here, surface its hash via\n // `progress({stage:'prepared'})`, and send that exact prepared op so the\n // bundler-returned hash matches. Best-effort and GATED ON `progress`:\n // any failure falls back to the normal send, and callers that pass no\n // progress callback keep the original send path byte-for-byte.\n let preparedUserOp: Awaited<ReturnType<typeof kernelClient.prepareUserOperation>> | undefined\n let preparedHash: `0x${string}` | undefined\n if (progress) {\n try {\n preparedUserOp = await kernelClient.prepareUserOperation({ callData, nonce })\n preparedHash = getUserOperationHash({\n chainId: this.config.chainId,\n entryPointAddress: from.entryPoint.address,\n entryPointVersion: from.entryPoint.version,\n userOperation: preparedUserOp,\n })\n progress({\n stage: 'prepared',\n args: functionInputs,\n userOpHash: preparedHash,\n method: name,\n from: from,\n value,\n contractName: this.contractName,\n contractAddress: this.address,\n gasLimit,\n })\n } catch (prepErr) {\n this.logger.warn(\n `prepareUserOperation (pre-send hash) failed for \"${name}\"; ` +\n `sending without an early hash: ${prepErr}`,\n )\n preparedUserOp = undefined\n preparedHash = undefined\n }\n }\n\n userOpHash = await kernelClient.sendUserOperation(\n // Re-send the exact prepared op (stripping the estimation stub\n // signature so the kernel re-signs) so the bundler hash matches the one\n // emitted above. Falls back to the original {callData, nonce} path\n // (which prepares internally) when no early hash was prepared.\n preparedUserOp\n ? ({ ...preparedUserOp, signature: undefined } as Parameters<\n typeof kernelClient.sendUserOperation\n >[0])\n : { callData, nonce },\n )\n\n // Determinism guard: the 'prepared' hash should equal the bundler's. If a\n // paymaster re-request changed the op it won't — a caller that persisted\n // the 'prepared' hash then just fails to find it and reconciles safely\n // (never a double-burn), but we log so we can see whether the early-hash\n // path is actually holding in practice.\n if (preparedHash && userOpHash !== preparedHash) {\n this.logger.warn(\n `UserOp 'prepared' hash ${preparedHash} != sent hash ${userOpHash} for \"${name}\"; ` +\n `early-hash callers will reconcile via receipt-not-found`,\n )\n }\n } catch (err) {\n if (err instanceof BaseError) {\n const revertError = err.walk((err) => err instanceof ContractFunctionRevertedError)\n this.logger.error(`revertError: ${String(revertError)}`)\n }\n throw new ContractsError(\n `Calling method \"${name}\" on contract \"${this.contractName}\" failed. Args: ${args} - ${err}`,\n )\n }\n\n if (progress) {\n progress({\n stage: 'sent',\n args: functionInputs,\n userOpHash,\n method: name,\n from: from,\n value,\n contractName: this.contractName,\n contractAddress: this.address,\n gasLimit,\n })\n }\n\n let txReceipt: UserOperationReceipt\n try {\n txReceipt = await kernelClient.waitForUserOperationReceipt({\n hash: userOpHash,\n timeout: USEROP_RECEIPT_TIMEOUT_MS,\n })\n } catch (err) {\n // The userOp is already in the bundler mempool — a client-side timeout\n // does NOT cancel it. Surface userOpHash so callers can poll for eventual\n // inclusion before retrying, otherwise a retry can produce a duplicate\n // on-chain op. Wrap symmetric to `internalMulticallSmartAccount`.\n throw new ContractsError(\n `Calling method \"${name}\" on contract \"${this.contractName}\" timed out ` +\n `waiting for UserOp receipt. userOpHash=${userOpHash} — confirm on-chain ` +\n `inclusion before retrying. Underlying: ${err}`,\n )\n }\n\n this.assertUserOpSucceeded(txReceipt, name, userOpHash)\n\n if (progress) {\n progress({\n stage: 'receipt',\n args: functionInputs,\n txReceipt,\n method: name,\n from: from,\n value,\n contractName: this.contractName,\n contractAddress: this.address,\n gasLimit,\n })\n }\n\n return txReceipt\n }\n\n private async internalSimulateSmartAccount(\n name: string,\n from: SmartAccount,\n args: any[],\n txparams: any,\n ) {\n try {\n await this.client.public.simulateContract({\n address: this.address,\n abi: this.contract.abi,\n functionName: name,\n args,\n account: from.address,\n ...(txparams.value && { value: txparams.value }),\n })\n return true\n } catch (err) {\n throw new ContractSimulationError(\n `Error Simulating contract call \"${name}\" on contract \"${this.contractName}\" failed. Args: ${args} - ${err}`,\n )\n }\n }\n\n private async localAccountSimulate(\n name: string,\n from: Account | `0x${string}`,\n args: any[],\n txparams: any,\n ) {\n try {\n await this.client.public.simulateContract({\n address: this.address,\n abi: this.contract.abi,\n functionName: name,\n args,\n account: from,\n ...(txparams.value && { value: txparams.value }),\n })\n } catch (err) {\n throw new ContractSimulationError(\n `Error Simulating contract call \"${name}\" on contract \"${this.contractName}\" failed. Args: ${args} - ${err}`,\n )\n }\n return true\n }\n\n private async localAccountSend(\n name: string,\n from: Account | `0x${string}`,\n args: any[],\n txparams: any,\n progress: ((data: any) => void) | undefined,\n _contractAbi?: Abi,\n _contractAddress?: Address,\n _contractName?: string,\n ) {\n const abi = _contractAbi || this.contract.abi\n const contractAddress = _contractAddress || this.address\n const contractName = _contractName || this.contractName\n\n const functionInputs = getInputsOfFunctionFormatted(abi, name, args)\n // Uncomment to debug contract calls\n // if (name === 'order') {\n // const functionSignature = getSignatureOfFunction(this.contract.abi, name, args)\n // this.logger.info(`Making contract call ....: ${name} - ${from}`)\n // this.logger.info(`With args: `, JSON.stringify(args, jsonReplacer))\n // this.logger.info(`And signature: ${JSON.stringify(functionSignature, jsonReplacer)}`)\n // this.logger.info('And amount: ', txparams.value)\n // }\n // abi.filter(({name, inputs}) => name === 'closeSignals' && inputs.length === 1)\n // const abiFilter = this.contract.abi.filter((abi) => abi.name === name && abi.inputs.length === args.length)\n // const abiFilter = this.contract.abi.filter((abi) => abi.name === name && abi.type === 'function')\n // console.debug('abi', this.contract.abi.filter((abi) => abi.name === name))\n // console.debug('abiFilter', abiFilter)\n // if (!abiFilter)\n // throw new ContractsError(\n // `No ABI found for method \"${name}\" with ${args.length} arguments on contract \"${this.contractName}\"`,\n // )\n\n const { gasLimit, value } = txparams\n // make the call\n if (progress) {\n progress({\n stage: 'sending',\n args: functionInputs,\n method: name,\n from,\n value,\n contractName,\n contractAddress,\n gasLimit,\n })\n }\n\n let txHash: `0x${string}` | undefined\n try {\n const { request } = await this.client.public.simulateContract({\n address: contractAddress,\n abi,\n functionName: name,\n args,\n account: from,\n ...(txparams.value && { value: txparams.value }),\n })\n\n // Resolve gas ourselves so `writeContract` never falls back to its own\n // `eth_estimateGas`. An explicit caller `gasLimit` always wins; otherwise\n // we estimate, apply the block-limit sanity check, and pin the result.\n // If estimation itself fails we still honour any explicit cap.\n let resolvedGas: bigint | undefined = gasLimit\n if (resolvedGas === undefined) {\n try {\n const estimate = await this.client.public.estimateContractGas({\n address: contractAddress,\n abi,\n functionName: name,\n args,\n account: from,\n ...(txparams.value && { value: txparams.value }),\n })\n resolvedGas = capForBogusEstimate(estimate, this.logger)\n } catch (estErr) {\n this.logger.warn(\n `estimateContractGas for \"${name}\" on \"${contractName}\" failed (${estErr}); ` +\n `falling back to ${GAS_FALLBACK_CAP} to avoid a bogus RPC re-estimate in writeContract.`,\n )\n resolvedGas = GAS_FALLBACK_CAP\n }\n }\n\n txHash = await this.client.wallet.writeContract({\n ...request,\n account: from,\n gas: resolvedGas,\n })\n } catch (err) {\n if (err instanceof BaseError) {\n const revertError = err.walk((err) => err instanceof ContractFunctionRevertedError)\n this.logger.error(`revertError: ${String(revertError)}`)\n }\n throw new ContractsError(\n `Calling method \"${name}\" on contract \"${contractName}\" failed. Args: ${args} - ${err}`,\n )\n }\n\n if (progress) {\n progress({\n stage: 'sent',\n args: functionInputs,\n txHash,\n method: name,\n from,\n value,\n contractName,\n contractAddress,\n gasLimit,\n })\n }\n const txReceipt = getTransactionReceipt({ txHash, publicClient: this.client.public })\n\n if (progress) {\n progress({\n stage: 'receipt',\n args: functionInputs,\n txReceipt,\n method: name,\n from,\n value,\n contractName,\n contractAddress,\n gasLimit,\n })\n }\n\n return txReceipt\n }\n\n private async localAccountMulticall(\n calls: MulticallEntry[],\n from: Account,\n txparams: any,\n progress: ((data: any) => void) | undefined,\n ): Promise<TransactionReceipt> {\n const receipts: TransactionReceipt[] = []\n for (const call of calls) {\n receipts.push(\n await this.localAccountSend(\n call.functionName,\n from,\n call.args,\n txparams,\n progress,\n call.abi,\n call.contractAddress,\n call.contractName,\n ),\n )\n }\n if (receipts.length > 0) return receipts.pop() as TransactionReceipt\n else throw new ContractsError(`No receipts found for multicall`)\n }\n\n private async localAccountSimulateMulticall(\n calls: SimulateMulticallEntry[],\n from: Account,\n txparams: any,\n ) {\n try {\n const { results } = await this.client.public.simulateCalls({\n calls,\n account: from,\n })\n this.logger.debug(`Simulated multicall - ${results}`)\n return true\n } catch (err) {\n if (err instanceof BaseError) {\n const revertError = err.walk((err) => err instanceof ContractFunctionRevertedError)\n this.logger.error(`revertError: ${String(revertError)}`)\n }\n throw new ContractsError(`Error simulating multicall - ${err}`)\n }\n }\n\n private async internalSimulateMulticallSmartAccount(\n calls: SimulateMulticallEntry[],\n from: SmartAccount,\n txparams: any,\n ) {\n try {\n const kernelClient = createKernelAccountClient({\n account: from,\n chain: getChain(this.config.chainId),\n bundlerTransport: http(this.getBundlerRPC()),\n client: this.client.public,\n ...this.getPaymasterConfig(),\n userOperation: {\n estimateFeesPerGas: async ({ bundlerClient }) => {\n return estimateUserOperationFees(bundlerClient, this.client.public)\n },\n },\n })\n\n const encodedCalls = []\n for (const call of calls) {\n encodedCalls.push({\n to: call.to,\n value: call.value || 0n,\n data: encodeFunctionData({\n abi: call.abi,\n functionName: call.functionName,\n args: call.args,\n }),\n })\n }\n\n // DONT DELETE THE COMMENTED LINES - ARE NECESSARY FOR F***ING ZERODEV DEBUGGING\n\n // this.logger.info(`Encoded multicall - ${JSON.stringify(encodedCalls, jsonReplacer)}`)\n // const code = await this.client.public.getCode({ address: from.address })\n // const isDeployed = code !== undefined && code !== '0x'\n // this.logger.info(`++++++ Smart account ${from.address} deployment status: ${isDeployed ? 'DEPLOYED' : 'NOT DEPLOYED'}`)\n\n // // Log account details\n // this.logger.info(`Account type: ${from.type}`)\n // this.logger.info(`Account address: ${from.address}`)\n\n // // Log the calls being made\n // this.logger.info(`Number of calls: ${encodedCalls.length}`)\n // encodedCalls.forEach((call, index) => {\n // this.logger.info(`Call ${index}: to=${call.to}, value=${call.value}, data=${call.data.slice(0, 10)}...`)\n // })\n\n await kernelClient.prepareUserOperation({\n callData: await kernelClient.account.encodeCalls(encodedCalls),\n })\n\n return true\n } catch (err) {\n this.logger.error(`Error details: ${JSON.stringify(err, null, 2)}`)\n if (err instanceof BaseError) {\n const revertError = err.walk((e) => e instanceof ContractFunctionRevertedError)\n if (revertError) {\n this.logger.error(`Revert error: ${String(revertError)}`)\n }\n }\n throw new ContractSimulationError(`Error Simulating Multicalls - ${err}`)\n }\n }\n\n private getOrCreatePaymaster() {\n if (!this._zeroDevPaymaster) {\n this._zeroDevPaymaster = createZeroDevPaymasterClient({\n chain: getChain(this.config.chainId),\n transport: http(this.getPaymasterRPC()),\n })\n }\n return this._zeroDevPaymaster\n }\n\n /**\n * Builds the `paymaster` partial for `createKernelAccountClient`. In relayer\n * mode (e.g. local `ultra-relay` for tests) returns an empty object so the\n * kernel client submits UserOps without paymaster fields and the bundler\n * pays gas via its executor key. In production returns the ZeroDev paymaster\n * sponsorship callback.\n */\n private getPaymasterConfig() {\n if (isRelayerMode()) return {}\n const zerodevPaymaster = this.getOrCreatePaymaster()\n return {\n paymaster: {\n getPaymasterData: (userOperation: any) =>\n zerodevPaymaster.sponsorUserOperation({ userOperation }),\n },\n }\n }\n\n protected getBundlerRPC(): string {\n // In relayer mode `getBundlerRpcUrl` reads `BUNDLER_RPC_URL_OVERRIDE`\n // and never touches the project id, so an empty value is harmless. In\n // production callers must pass a project id — surface a clear error if\n // the SDK was instantiated without one and we need it.\n const projectId = this.config.zeroDevProjectId\n if (!projectId && !isRelayerMode()) {\n throw new ContractsError(\n 'getBundlerRPC: zeroDevProjectId is required for non-relayer (production) mode',\n )\n }\n return getBundlerRpcUrl(projectId ?? '', this.config.chainId, this.config.useUltraRelay)\n }\n\n private getPaymasterRPC(): string {\n // Only ever consulted when `getPaymasterConfig` decides to attach a\n // paymaster, which is gated on `!isRelayerMode()`. A missing project\n // id at this point is a configuration bug worth surfacing.\n const projectId = this.config.zeroDevProjectId\n if (!projectId) {\n throw new ContractsError(\n 'getPaymasterRPC: zeroDevProjectId is required to build the paymaster URL',\n )\n }\n return getPaymasterRpcUrl(projectId, this.config.chainId)\n }\n}\n"],"names":["createKernelAccountClient","createZeroDevPaymasterClient","estimateUserOperationFees","getBundlerRpcUrl","getPaymasterRpcUrl","isRelayerMode","BaseError","ContractFunctionRevertedError","encodeFunctionData","getContract","http","parseAbi","parseEventLogs","createBundlerClient","getUserOperationHash","ContractsError","ContractSimulationError","Instantiable","getInputsOfFunctionFormatted","getTransactionReceipt","getRandomBigInt","getChain","GAS_SANITY_THRESHOLD","GAS_FALLBACK_CAP","ZERODEV_NONCE_KEY_BITS","USEROP_RECEIPT_TIMEOUT_MS","capForBogusEstimate","estimatedGas","logger","warn","ContractBase","contractName","address","_zeroDevPaymaster","init","config","contractConfig","setInstanceConfig","contract","abi","client","public","publicClient","wallet","walletClient","call","functionName","args","from","readContract","account","err","txHash","hash","receipt","transactionHash","Error","getTransactionLogs","txReceipt","eventName","logs","strict","multicall","calls","params","type","debug","localAccountMulticall","progress","internalMulticallSmartAccount","simulateMulticall","localAccountSimulateMulticall","internalSimulateMulticallSmartAccount","simulate","localAccountSimulate","internalSimulateSmartAccount","send","localAccountSend","internalSendSmartAccount","getUserOperationReceipt","bundlerClient","chain","chainId","transport","getBundlerRPC","message","String","test","safeMessage","replace","txparams","stage","method","contractAddress","kernelClient","bundlerTransport","getPaymasterConfig","userOperation","estimateFeesPerGas","encodedCalls","map","push","to","value","data","userOpHash","nonce","getNonce","key","sendUserOperation","callData","encodeCalls","waitForUserOperationReceipt","timeout","assertUserOpSucceeded","revertError","walk","error","hashSuffix","success","reason","name","functionInputs","gasLimit","simulateContract","preparedUserOp","preparedHash","prepareUserOperation","entryPointAddress","entryPoint","entryPointVersion","version","prepErr","undefined","signature","_contractAbi","_contractAddress","_contractName","request","resolvedGas","estimate","estimateContractGas","estErr","writeContract","gas","receipts","length","pop","results","simulateCalls","JSON","stringify","e","getOrCreatePaymaster","getPaymasterRPC","zerodevPaymaster","paymaster","getPaymasterData","sponsorUserOperation","projectId","zeroDevProjectId","useUltraRelay"],"mappings":"AAAA,SAASA,yBAAyB,EAAEC,4BAA4B,QAAQ,eAAc;AACtF,SACEC,yBAAyB,EACzBC,gBAAgB,EAChBC,kBAAkB,EAClBC,aAAa,QACR,6CAA4C;AACnD,SAIEC,SAAS,EACTC,6BAA6B,EAC7BC,kBAAkB,EAClBC,WAAW,EACXC,IAAI,EACJC,QAAQ,EACRC,cAAc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AI,CAAC5H,MAAM,CAAC+C,OAAO,EAAE,IAAI,CAAC/C,MAAM,CAAC8H,aAAa;IACzF;IAEQP,kBAA0B;QAChC,oEAAoE;QACpE,qEAAqE;QACrE,2DAA2D;QAC3D,MAAMK,YAAY,IAAI,CAAC5H,MAAM,CAAC6H,gBAAgB;QAC9C,IAAI,CAACD,WAAW;YACd,MAAM,IAAIhJ,eACR;QAEJ;QACA,OAAOX,mBAAmB2J,WAAW,IAAI,CAAC5H,MAAM,CAAC+C,OAAO;IAC1D;AACF"}
@@ -22,6 +22,11 @@ export interface NeverminedOptions {
22
22
  * ZeroDev project id
23
23
  */
24
24
  zeroDevProjectId?: string;
25
+ /**
26
+ * Route the production bundler through ZeroDev's UltraRelay
27
+ * (`?provider=ULTRA_RELAY`). No effect when `BUNDLER_RPC_URL_OVERRIDE` is set.
28
+ */
29
+ useUltraRelay?: boolean;
25
30
  /**
26
31
  * Contracts version
27
32
  */
@@ -1 +1 @@
1
- {"version":3,"file":"NeverminedOptions.d.ts","sourceRoot":"","sources":["../../src/models/NeverminedOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAE9B,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAA;IACf;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IAExB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IAEf,UAAU,CAAC,EAAE,MAAM,CAAA;IAEnB,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IAEjB,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAA;IAEpB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAA;IAEzB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAC1B"}
1
+ {"version":3,"file":"NeverminedOptions.d.ts","sourceRoot":"","sources":["../../src/models/NeverminedOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAE9B,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAA;IACf;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IAExB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IAEf,UAAU,CAAC,EAAE,MAAM,CAAA;IAEnB,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IAEjB,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAA;IAEpB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAA;IAEzB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;IAEvB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAC1B"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/models/NeverminedOptions.ts"],"sourcesContent":["import { Account } from 'viem'\n\nexport interface NeverminedOptions {\n chainId: number\n /**\n * Ethereum Web3 Provider URL. This Url allows the SDK to connect to a blockchain.\n * This provider depends on the network where you want to connect (Ethereum Mainnet, Rinkeby, Polygon Matic, etc).\n * It's possible to use a public available provider or a private/paid one like Infura, Alchemy, etc.\n */\n web3ProviderUri?: string\n\n /**\n * The Nevermined App URL.\n */\n appUrl?: string\n\n backendUrl?: string\n\n agentsProxy?: string\n\n /**\n * Log level. Defaults to `'info'` when consumed by `Instantiable.abstract.ts`.\n */\n logLevel?: string\n\n accounts?: Account[]\n\n /**\n * ZeroDev project id\n */\n zeroDevProjectId?: string\n\n /**\n * Contracts version\n */\n contractsVersion?: string\n}\n"],"names":[],"mappings":"AAEA,WAkCC"}
1
+ {"version":3,"sources":["../../src/models/NeverminedOptions.ts"],"sourcesContent":["import { Account } from 'viem'\n\nexport interface NeverminedOptions {\n chainId: number\n /**\n * Ethereum Web3 Provider URL. This Url allows the SDK to connect to a blockchain.\n * This provider depends on the network where you want to connect (Ethereum Mainnet, Rinkeby, Polygon Matic, etc).\n * It's possible to use a public available provider or a private/paid one like Infura, Alchemy, etc.\n */\n web3ProviderUri?: string\n\n /**\n * The Nevermined App URL.\n */\n appUrl?: string\n\n backendUrl?: string\n\n agentsProxy?: string\n\n /**\n * Log level. Defaults to `'info'` when consumed by `Instantiable.abstract.ts`.\n */\n logLevel?: string\n\n accounts?: Account[]\n\n /**\n * ZeroDev project id\n */\n zeroDevProjectId?: string\n\n /**\n * Route the production bundler through ZeroDev's UltraRelay\n * (`?provider=ULTRA_RELAY`). No effect when `BUNDLER_RPC_URL_OVERRIDE` is set.\n */\n useUltraRelay?: boolean\n\n /**\n * Contracts version\n */\n contractsVersion?: string\n}\n"],"names":[],"mappings":"AAEA,WAwCC"}
@@ -251,9 +251,14 @@ export declare function keccak256Packed(types: any[], values: any[]): string;
251
251
  /**
252
252
  * Returns the bundler RPC URL. When `BUNDLER_RPC_URL_OVERRIDE` is set
253
253
  * (used by tests against a local Alto + anvil-fork stack), it takes precedence
254
- * over the canonical ZeroDev URL.
254
+ * over the canonical ZeroDev URL. When `useUltraRelay` is true, the production
255
+ * URL is routed through ZeroDev's UltraRelay (`?provider=ULTRA_RELAY`); the
256
+ * override branch is left untouched.
257
+ * @param useUltraRelay - when true, append `?provider=ULTRA_RELAY` to route the
258
+ * UserOperation through ZeroDev's UltraRelay bundler tier. Ignored when
259
+ * `BUNDLER_RPC_URL_OVERRIDE` is set.
255
260
  */
256
- export declare function getBundlerRpcUrl(zeroDevProjectId: string, chainId: number): string;
261
+ export declare function getBundlerRpcUrl(zeroDevProjectId: string, chainId: number, useUltraRelay?: boolean): string;
257
262
  /**
258
263
  * Returns the paymaster RPC URL (ZeroDev-only; the local fork stack uses
259
264
  * `ultra-relay` which sponsors via the bundler's executor key without a
@@ -284,9 +289,12 @@ export declare function estimateUserOperationFees(bundlerClient: any, _publicCli
284
289
  * @param signer the signer account
285
290
  * @param chainId the chain id
286
291
  * @param zeroDevProjectId the zero dev project id, you can get it from the ZeroDev dashboard
292
+ * @param useUltraRelay forwarded straight to `getBundlerRpcUrl` — when true the
293
+ * bundler RPC is routed through ZeroDev's UltraRelay. Ignored when
294
+ * `BUNDLER_RPC_URL_OVERRIDE` is set.
287
295
  * @returns the kernel client
288
296
  */
289
- export declare function createKernelClient(kernelAccount: SmartAccount, chainId: number, zeroDevProjectId: string, publicClient: any): Promise<KernelAccountClient>;
297
+ export declare function createKernelClient(kernelAccount: SmartAccount, chainId: number, zeroDevProjectId: string, publicClient: any, useUltraRelay?: boolean): Promise<KernelAccountClient>;
290
298
  export declare function createKernelSmartAccount(signer: Signer, publicClient: PublicClient): Promise<SmartAccount>;
291
299
  export declare function getApproval(signer: Signer, publicClient: any, policies: any[]): Promise<string>;
292
300
  export declare function useSessionKey(approval: string, signer: Signer, publicClient: any): Promise<import("@zerodev/sdk").CreateKernelAccountReturnType<"0.7">>;
@@ -1 +1 @@
1
- {"version":3,"file":"BlockchainViemUtils.d.ts","sourceRoot":"","sources":["../../../src/nevermined/utils/BlockchainViemUtils.ts"],"names":[],"mappings":"AAOA,OAAO,EAML,mBAAmB,EAEpB,MAAM,cAAc,CAAA;AAErB,OAAO,EACL,OAAO,EAYP,KAAK,GAAG,EACR,KAAK,QAAQ,EACb,KAAK,WAAW,EAChB,KAAK,OAAO,EACZ,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACxB,MAAM,MAAM,CAAA;AACb,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAQvD,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAA;AAG9F,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAI3C;;;GAGG;AACH,qBAAa,mBAAoB,SAAQ,YAAY;gBACvC,MAAM,EAAE,kBAAkB;CAIvC;AAaD;;;;;;;GAOG;AACH,wBAAsB,qBAAqB,CAAC,EAC1C,MAAM,EACN,YAA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C3B,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,GAAG,EAAE,GACd,OAAO,CAAC,MAAM,CAAC,CAsCjB;AAED,eAAO,MAAM,WAAW;;;;;CAKvB,CAAA"}
@@ -236,12 +236,18 @@ const TRANSACTION_RECEIPT_POLLING_INTERVAL_MS = 1_500;
236
236
  /**
237
237
  * Returns the bundler RPC URL. When `BUNDLER_RPC_URL_OVERRIDE` is set
238
238
  * (used by tests against a local Alto + anvil-fork stack), it takes precedence
239
- * over the canonical ZeroDev URL.
240
- */ export function getBundlerRpcUrl(zeroDevProjectId, chainId) {
239
+ * over the canonical ZeroDev URL. When `useUltraRelay` is true, the production
240
+ * URL is routed through ZeroDev's UltraRelay (`?provider=ULTRA_RELAY`); the
241
+ * override branch is left untouched.
242
+ * @param useUltraRelay - when true, append `?provider=ULTRA_RELAY` to route the
243
+ * UserOperation through ZeroDev's UltraRelay bundler tier. Ignored when
244
+ * `BUNDLER_RPC_URL_OVERRIDE` is set.
245
+ */ export function getBundlerRpcUrl(zeroDevProjectId, chainId, useUltraRelay = false) {
246
+ const base = `https://rpc.zerodev.app/api/v3/${zeroDevProjectId}/chain/${chainId}`;
241
247
  // `||` (not `??`) because Vite replaces missing browser env vars with the
242
248
  // empty string at build time; an empty override is equivalent to "no
243
249
  // override" for our purposes.
244
- return process.env.BUNDLER_RPC_URL_OVERRIDE || `https://rpc.zerodev.app/api/v3/${zeroDevProjectId}/chain/${chainId}`;
250
+ return process.env.BUNDLER_RPC_URL_OVERRIDE || (useUltraRelay ? `${base}?provider=ULTRA_RELAY` : base);
245
251
  }
246
252
  /**
247
253
  * Returns the paymaster RPC URL (ZeroDev-only; the local fork stack uses
@@ -279,9 +285,12 @@ const TRANSACTION_RECEIPT_POLLING_INTERVAL_MS = 1_500;
279
285
  * @param signer the signer account
280
286
  * @param chainId the chain id
281
287
  * @param zeroDevProjectId the zero dev project id, you can get it from the ZeroDev dashboard
288
+ * @param useUltraRelay forwarded straight to `getBundlerRpcUrl` — when true the
289
+ * bundler RPC is routed through ZeroDev's UltraRelay. Ignored when
290
+ * `BUNDLER_RPC_URL_OVERRIDE` is set.
282
291
  * @returns the kernel client
283
- */ export async function createKernelClient(kernelAccount, chainId, zeroDevProjectId, publicClient) {
284
- const bundlerRpc = getBundlerRpcUrl(zeroDevProjectId, chainId);
292
+ */ export async function createKernelClient(kernelAccount, chainId, zeroDevProjectId, publicClient, useUltraRelay = false) {
293
+ const bundlerRpc = getBundlerRpcUrl(zeroDevProjectId, chainId, useUltraRelay);
285
294
  const paymasterRpc = getPaymasterRpcUrl(zeroDevProjectId, chainId);
286
295
  return createKernelAccountClient({
287
296
  account: kernelAccount,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/nevermined/utils/BlockchainViemUtils.ts"],"sourcesContent":["import { signerToEcdsaValidator } from '@zerodev/ecdsa-validator'\nimport {\n deserializePermissionAccount,\n serializePermissionAccount,\n toPermissionValidator,\n} from '@zerodev/permissions'\nimport { toECDSASigner } from '@zerodev/permissions/signers'\nimport {\n addressToEmptyAccount,\n createKernelAccount,\n createKernelAccountClient,\n createZeroDevPaymasterClient,\n getUserOperationGasPrice,\n KernelAccountClient,\n type KernelSmartAccountImplementation,\n} from '@zerodev/sdk'\nimport { KERNEL_V3_1, getEntryPoint } from '@zerodev/sdk/constants'\nimport {\n Address,\n encodeAbiParameters,\n getAbiItem,\n getAddress,\n getContract,\n http,\n isAddress,\n pad,\n stringToBytes,\n stringToHex,\n toBytes,\n keccak256 as viemKeccak256,\n type Abi,\n type AbiEvent,\n type AbiFunction,\n type Account,\n type PublicClient,\n type TransactionReceipt,\n} from 'viem'\nimport { SmartAccount } from 'viem/account-abstraction'\nimport {\n english,\n generateMnemonic,\n generatePrivateKey,\n mnemonicToAccount,\n privateKeyToAccount,\n} from 'viem/accounts'\nimport { Instantiable, InstantiableConfig, Web3Clients } from '../../Instantiable.abstract.js'\nimport { ContractsError } from '../../errors/NeverminedErrors.js'\nimport { getChain } from '../../utils/Network.js'\nimport { Signer } from '@zerodev/sdk/types'\n\nconst ENTRY_POINT_VERSION = '0.7'\n\n/**\n * Utility class with methods that allow the interaction with the blockchain.\n * This class uses Viem library to interact with the blockchain.\n */\nexport class BlockchainViemUtils extends Instantiable {\n constructor(config: InstantiableConfig) {\n super()\n this.setInstanceConfig(config)\n }\n}\n\n//////////////////////////\n///// UTILITIES //////////\n//////////////////////////\n\n///// CONTRACTS\n\n// Wait budget for an L2 block to be mined and the receipt to surface.\n// Base / Base Sepolia block time is ~2s; 30s ≈ 15 blocks of headroom.\nconst TRANSACTION_RECEIPT_TIMEOUT_MS = 30_000\nconst TRANSACTION_RECEIPT_POLLING_INTERVAL_MS = 1_500\n\n/**\n * Given a transaction hash, it returns the transaction receipt.\n * Uses viem's `waitForTransactionReceipt` which polls until the receipt is\n * available, retrying on `TransactionReceiptNotFoundError` and handling\n * tx-replacement / reorgs natively.\n * @param txHash - the transaction hash\n * @returns the transaction receipt\n */\nexport async function getTransactionReceipt({\n txHash,\n publicClient,\n}: {\n txHash: `0x${string}`\n publicClient: PublicClient\n iteration?: number\n}): Promise<TransactionReceipt> {\n try {\n return await publicClient.waitForTransactionReceipt({\n hash: txHash,\n timeout: TRANSACTION_RECEIPT_TIMEOUT_MS,\n pollingInterval: TRANSACTION_RECEIPT_POLLING_INTERVAL_MS,\n confirmations: 1,\n })\n } catch (error) {\n throw new ContractsError(\n `Unable to get transaction receipt with hash: ${txHash}. Error: ${error}`,\n )\n }\n}\n\n/**\n * Given an already deployed contract address and the ABI, it returns the contract instance.\n *\n * @param contractAddress - the contract address\n * @param abi - the contract artifact\n * @param client - the client to interact with the blockchain\n * @returns a contract instance\n */\nexport async function getContractInstance(contractAddress: string, abi: Abi, client: Web3Clients) {\n return getContract({\n abi,\n address: contractAddress as `0x${string}`,\n client: { wallet: client.wallet, public: client.public },\n })\n}\n\n///// ABIs\n\n/**\n * It searchs an ABI function in the ABI.\n * @param abi the ABI of the contract\n * @param funcName the function name\n * @param args the args of the function\n * @returns the function found\n */\nexport function searchAbiFunction(abi: Abi, funcName: string, args: any[] = []): AbiFunction {\n const func = getAbiItem({ abi, name: funcName, args })\n if (!func || func.type !== 'function') {\n throw new ContractsError(`Function \"${funcName}\" is not part of contract`)\n }\n return func as AbiFunction\n}\n\n/**\n * It searchs an ABI event in the ABI.\n * @param abi the ABI of the contract\n * @param funcName the event name\n * @returns the event found\n */\nexport function searchAbiEvent(abi: Abi, eventName: string): AbiEvent {\n const event = getAbiItem({\n abi,\n name: eventName,\n })\n if (!event || event.type !== 'event') {\n throw new ContractsError(`Event \"${event}\" is not part of contract`)\n }\n return event as AbiEvent\n}\n\n/**\n * It searchs an ABI function in the ABI.\n * @param abi the ABI of the contract\n * @param funcName the function name\n * @param args the args of the function\n * @returns the function found\n */\nexport function getSignatureOfFunction(abi: Abi, funcName: string, args: any[] = []): AbiFunction {\n return searchAbiFunction(abi, funcName, args)\n}\n\n/**\n * It searchs an ABI function in the ABI and return the inputs.\n * @param abi the ABI of the contract\n * @param funcName the function name\n * @param args the args of the function\n * @returns the function found\n */\nexport function getInputsOfFunction(abi: Abi, funcName: string, args: any[] = []) {\n return searchAbiFunction(abi, funcName, args).inputs\n}\n\n/**\n * It searchs an ABI function in the ABI and return the inputs formatted.\n * @param abi the ABI of the contract\n * @param funcName the function name\n * @param args the args of the function\n * @returns the function found\n */\nexport function getInputsOfFunctionFormatted(abi: Abi, funcName: string, args: any[] = []) {\n return searchAbiFunction(abi, funcName, args).inputs.map((input, i) => {\n return {\n name: input.name,\n value: args[i],\n }\n })\n}\n\n//////// UTILS\n\n/**\n * Given an address it returns that address in checksum format.\n * @param address the address\n * @returns the same address in checksum format\n */\nexport function getChecksumAddress(address: string): string {\n return getAddress(address)\n}\n\n/**\n * It checks if the address is a valid address.\n * @param address the address to check\n * @returns true of the address is valid\n */\nexport function isValidAddress(address: string): boolean {\n return isAddress(address)\n}\n\n/**\n * Encodes a UTF-8 string into a byte array.\n\n * @param message the string to encode\n * @returns the encoded byte array\n */\nexport function getBytes(message: string): Uint8Array {\n return stringToBytes(message)\n}\n\n/**\n * It pads a value with zeros.\n * @param value the value to pad\n * @param length the expected longitutde of the value\n * @returns the padded value\n */\nexport function zeroPadValue(value: `0x${string}` | Uint8Array, length: number): string {\n return pad(value, { size: length }) as `0x${string}`\n}\n\n/**\n * Encodes a UTF-8 string into a hex string\n * @param message the string to encode\n * @returns the hex string\n */\nexport function encodeBytes32String(message: string) {\n return stringToHex(message, { size: 32 })\n}\n\n////// ACCOUNTS\n/**\n * Given a seedphrase, it returns an account.\n * @param seedphrase - the seedphrase to be used to generate the account\n * @param addressIndex - the address index\n * @returns an account\n */\nexport function makeWallet(seedphrase: string, addressIndex = 0): Account {\n return mnemonicToAccount(seedphrase, { addressIndex })\n}\n\n/**\n * Given a seedphrase generates multiple accounts\n * @param seedphrase - the seedphrase to be used to generate the account\n * @param numAccounts - the number of accounts to create\n * @returns the array of accounts\n */\nexport function makeWallets(seedphrase: string, numAccounts = 10) {\n const accounts: Account[] = []\n for (let i = 0; i < numAccounts; i++) {\n accounts.push(makeWallet(seedphrase, i))\n }\n return accounts\n}\n\n/**\n * It generates a random account.\n * @returns a new account\n */\nexport function makeRandomWallet(): Account {\n const mnemonic = generateMnemonic(english)\n return makeWallet(mnemonic)\n}\n\n/**\n * It generates a list of random accounts\n * @param numAccounts - the number of accounts to create\n * @returns the array of accounts\n */\nexport function makeRandomWallets(numAccounts = 10): Account[] {\n const mnemonic = generateMnemonic(english)\n return makeWallets(mnemonic, numAccounts)\n}\n\n/////// HASHES\n\n/**\n * It hashes a string using keccak256.\n * @param seed the string to hash\n * @returns the hash\n */\nexport function keccak256(seed: string): string {\n return viemKeccak256(toBytes(seed))\n}\n\n/**\n * It encodes and hashes a list of primitive values into an ABI-encoded hex value.\n * @param types the types of the values\n * @param values the values to encode\n * @returns the hash\n */\nexport function keccak256WithEncode(types: any[], values: any[]): string {\n const encoded = encodeAbiParameters(types, values as never)\n return keccak256(encoded)\n}\n\n/**\n * It encodes and hashes a list of primitive values into an ABI-encoded hex value.\n * @param types the types of the values\n * @param values the values to encode\n * @returns the hash\n */\nexport function keccak256Packed(types: any[], values: any[]): string {\n return keccak256WithEncode(types, values)\n}\n\n/////// ZERO DEV\n\n/**\n * Returns the bundler RPC URL. When `BUNDLER_RPC_URL_OVERRIDE` is set\n * (used by tests against a local Alto + anvil-fork stack), it takes precedence\n * over the canonical ZeroDev URL.\n */\nexport function getBundlerRpcUrl(zeroDevProjectId: string, chainId: number): string {\n // `||` (not `??`) because Vite replaces missing browser env vars with the\n // empty string at build time; an empty override is equivalent to \"no\n // override\" for our purposes.\n return (\n process.env.BUNDLER_RPC_URL_OVERRIDE ||\n `https://rpc.zerodev.app/api/v3/${zeroDevProjectId}/chain/${chainId}`\n )\n}\n\n/**\n * Returns the paymaster RPC URL (ZeroDev-only; the local fork stack uses\n * `ultra-relay` which sponsors via the bundler's executor key without a\n * paymaster, so this URL is not consulted when `BUNDLER_RPC_URL_OVERRIDE` is\n * set).\n */\nexport function getPaymasterRpcUrl(zeroDevProjectId: string, chainId: number): string {\n return `https://rpc.zerodev.app/api/v3/${zeroDevProjectId}/chain/${chainId}`\n}\n\n/**\n * Returns true when the kernel client should run in \"relayer mode\" — no\n * paymaster, gas fees zeroed out. Used by tests against a local\n * `ultra-relay` (ZeroDev's fork of Alto) on top of an anvil-fork. The relayer's\n * executor key pays gas directly via `EntryPoint.handleOps`, avoiding the\n * paymaster sponsorship handshake altogether.\n */\nexport function isRelayerMode(): boolean {\n return Boolean(process.env.BUNDLER_RPC_URL_OVERRIDE)\n}\n\n/**\n * Returns gas prices for UserOperation fee estimation. ZeroDev's bundler\n * exposes a custom `zd_getUserOperationGasPrice` method; standard ERC-4337\n * bundlers do not. In relayer mode the bundler accepts UserOps with zeroed\n * `maxFeePerGas`/`maxPriorityFeePerGas` and pays gas itself.\n */\nexport async function estimateUserOperationFees(\n bundlerClient: any,\n _publicClient: any,\n): Promise<{ maxFeePerGas: bigint; maxPriorityFeePerGas: bigint }> {\n if (isRelayerMode()) {\n return { maxFeePerGas: 0n, maxPriorityFeePerGas: 0n }\n }\n return getUserOperationGasPrice(bundlerClient)\n}\n\n/**\n * It creates a ZeroDev Kernel client.\n * @param signer the signer account\n * @param chainId the chain id\n * @param zeroDevProjectId the zero dev project id, you can get it from the ZeroDev dashboard\n * @returns the kernel client\n */\nexport async function createKernelClient(\n kernelAccount: SmartAccount,\n chainId: number,\n zeroDevProjectId: string,\n publicClient: any,\n): Promise<KernelAccountClient> {\n const bundlerRpc = getBundlerRpcUrl(zeroDevProjectId, chainId)\n const paymasterRpc = getPaymasterRpcUrl(zeroDevProjectId, chainId)\n\n return createKernelAccountClient({\n account: kernelAccount,\n chain: getChain(chainId),\n bundlerTransport: http(bundlerRpc),\n client: publicClient,\n ...(isRelayerMode()\n ? {}\n : {\n paymaster: {\n getPaymasterData: (userOperation: any) => {\n const zerodevPaymaster = createZeroDevPaymasterClient({\n chain: getChain(chainId),\n transport: http(paymasterRpc),\n })\n return zerodevPaymaster.sponsorUserOperation({ userOperation })\n },\n },\n }),\n userOperation: {\n estimateFeesPerGas: async ({ bundlerClient }) => {\n return estimateUserOperationFees(bundlerClient, publicClient)\n },\n },\n })\n}\n\nexport async function createKernelSmartAccount(\n signer: Signer,\n publicClient: PublicClient,\n): Promise<SmartAccount> {\n const ecdsaValidator = await signerToEcdsaValidator(publicClient, {\n signer: signer,\n entryPoint: getEntryPoint(ENTRY_POINT_VERSION),\n kernelVersion: KERNEL_V3_1,\n })\n\n return await createKernelAccount(publicClient, {\n plugins: {\n sudo: ecdsaValidator,\n },\n entryPoint: getEntryPoint(ENTRY_POINT_VERSION),\n kernelVersion: KERNEL_V3_1,\n })\n}\n\nexport async function getApproval(signer: Signer, publicClient: any, policies: any[]) {\n const ecdsaValidator = await signerToEcdsaValidator(publicClient, {\n entryPoint: getEntryPoint(ENTRY_POINT_VERSION),\n signer,\n kernelVersion: KERNEL_V3_1,\n })\n const emptyAccount = addressToEmptyAccount(signer.address as Address)\n const emptySessionKeySigner = await toECDSASigner({ signer: emptyAccount })\n\n const permissionPlugin = await toPermissionValidator(publicClient, {\n entryPoint: getEntryPoint(ENTRY_POINT_VERSION),\n signer: emptySessionKeySigner,\n policies: policies,\n kernelVersion: KERNEL_V3_1,\n })\n const sessionKeyAccount = await createKernelAccount(publicClient, {\n entryPoint: getEntryPoint(ENTRY_POINT_VERSION),\n plugins: {\n sudo: ecdsaValidator,\n regular: permissionPlugin,\n },\n kernelVersion: KERNEL_V3_1,\n })\n\n return await serializePermissionAccount(sessionKeyAccount)\n}\n\nexport async function useSessionKey(approval: string, signer: Signer, publicClient: any) {\n const sessionKeySigner = await toECDSASigner({\n signer,\n })\n const sessionKeyAccount = await deserializePermissionAccount(\n publicClient,\n getEntryPoint(ENTRY_POINT_VERSION),\n KERNEL_V3_1,\n approval,\n sessionKeySigner,\n )\n\n return sessionKeyAccount\n}\n\nexport async function createSessionKey(signer: Signer, publicClient: any, policies: any[]) {\n const ecdsaValidator = await signerToEcdsaValidator(publicClient, {\n entryPoint: getEntryPoint(ENTRY_POINT_VERSION),\n signer,\n kernelVersion: KERNEL_V3_1,\n })\n const sessionPrivateKey = generatePrivateKey()\n const masterAccount = privateKeyToAccount(sessionPrivateKey)\n const sessionKeySigner = await toECDSASigner({\n signer: masterAccount,\n })\n\n const permissionPlugin = await toPermissionValidator(publicClient, {\n entryPoint: getEntryPoint(ENTRY_POINT_VERSION),\n signer: sessionKeySigner,\n policies: policies,\n kernelVersion: KERNEL_V3_1,\n })\n\n const sessionKeyAccount = await createKernelAccount(publicClient, {\n entryPoint: getEntryPoint(ENTRY_POINT_VERSION),\n plugins: {\n sudo: ecdsaValidator,\n regular: permissionPlugin,\n },\n kernelVersion: KERNEL_V3_1,\n })\n\n return serializePermissionAccount(sessionKeyAccount, sessionPrivateKey)\n}\n\nexport async function getSessionKey(serializedSessionKey: string, publicClient: any) {\n const sessionKeyAccount = await deserializePermissionAccount(\n publicClient,\n getEntryPoint(ENTRY_POINT_VERSION),\n KERNEL_V3_1,\n serializedSessionKey,\n )\n\n return sessionKeyAccount\n}\n\n/**\n * Creates a delegated session key for an existing kernel account.\n * The resulting serialized session key can be deserialized into a SmartAccount\n * that shares the same address as the kernel account but enforces the given policies.\n *\n * @param kernelAccount The existing SmartAccount (kernel) to delegate from\n * @param publicClient Viem PublicClient instance\n * @param policies Array of policies to enforce for this session key\n * @returns Serialized session key string\n */\nexport async function createDelegatedSessionKeyFromKernel(\n kernelAccount: SmartAccount,\n publicClient: PublicClient,\n policies: any[],\n): Promise<string> {\n // 1) Generate ephemeral session private key (used only for the permission plugin)\n const sessionPrivateKey = generatePrivateKey()\n const sessionAccount = privateKeyToAccount(sessionPrivateKey)\n\n // 2) Wrap ephemeral key as ECDSA signer for permissions\n const sessionKeySigner = await toECDSASigner({ signer: sessionAccount })\n\n // 3) Create the permission validator plugin\n const permissionValidator = await toPermissionValidator(publicClient, {\n entryPoint: getEntryPoint(ENTRY_POINT_VERSION),\n signer: sessionKeySigner,\n policies,\n kernelVersion: KERNEL_V3_1,\n })\n\n // 4) Extract the sudo validator from the existing kernel account\n const kernelAccountTyped = kernelAccount as SmartAccount<KernelSmartAccountImplementation>\n const sudoValidator = kernelAccountTyped.kernelPluginManager.sudoValidator\n\n if (!sudoValidator) {\n throw new Error('Kernel account does not have a sudo validator')\n }\n\n // 5) Create a new kernel account with both sudo (from original) and permission validator\n const sessionKeyAccount = await createKernelAccount(publicClient, {\n entryPoint: getEntryPoint(ENTRY_POINT_VERSION),\n plugins: {\n sudo: sudoValidator, // Use existing sudo validator\n regular: permissionValidator,\n },\n kernelVersion: KERNEL_V3_1,\n })\n\n // 6) Serialize the session key account with the ephemeral private key\n const serialized = await serializePermissionAccount(sessionKeyAccount, sessionPrivateKey)\n\n return serialized\n}\n\nexport const WalletUtils = {\n makeWallet,\n makeWallets,\n makeRandomWallet,\n makeRandomWallets,\n}\n"],"names":["signerToEcdsaValidator","deserializePermissionAccount","serializePermissionAccount","toPermissionValidator","toECDSASigner","addressToEmptyAccount","createKernelAccount","createKernelAccountClient","createZeroDevPaymasterClient","getUserOperationGasPrice","KERNEL_V3_1","getEntryPoint","encodeAbiParameters","getAbiItem","getAddress","getContract","http","isAddress","pad","stringToBytes","stringToHex","toBytes","keccak256","viemKeccak256","english","generateMnemonic","generatePrivateKey","mnemonicToAccount","privateKeyToAccount","Instantiable","ContractsError","getChain","ENTRY_POINT_VERSION","BlockchainViemUtils","config","setInstanceConfig","TRANSACTION_RECEIPT_TIMEOUT_MS","TRANSACTION_RECEIPT_POLLING_INTERVAL_MS","getTransactionReceipt","txHash","publicClient","waitForTransactionReceipt","hash","timeout","pollingInterval","confirmations","error","getContractInstance","contractAddress","abi","client","address","wallet","public","searchAbiFunction","funcName","args","func","name","type","searchAbiEvent","eventName","event","getSignatureOfFunction","getInputsOfFunction","inputs","getInputsOfFunctionFormatted","map","input","i","value","getChecksumAddress","isValidAddress","getBytes","message","zeroPadValue","length","size","encodeBytes32String","makeWallet","seedphrase","addressIndex","makeWallets","numAccounts","accounts","push","makeRandomWallet","mnemonic","makeRandomWallets","seed","keccak256WithEncode","types","values","encoded","keccak256Packed","getBundlerRpcUrl","zeroDevProjectId","chainId","process","env","BUNDLER_RPC_URL_OVERRIDE","getPaymasterRpcUrl","isRelayerMode","Boolean","estimateUserOperationFees","bundlerClient","_publicClient","maxFeePerGas","maxPriorityFeePerGas","createKernelClient","kernelAccount","bundlerRpc","paymasterRpc","account","chain","bundlerTransport","paymaster","getPaymasterData","userOperation","zerodevPaymaster","transport","sponsorUserOperation","estimateFeesPerGas","createKernelSmartAccount","signer","ecdsaValidator","entryPoint","kernelVersion","plugins","sudo","getApproval","policies","emptyAccount","emptySessionKeySigner","permissionPlugin","sessionKeyAccount","regular","useSessionKey","approval","sessionKeySigner","createSessionKey","sessionPrivateKey","masterAccount","getSessionKey","serializedSessionKey","createDelegatedSessionKeyFromKernel","sessionAccount","permissionValidator","kernelAccountTyped","sudoValidator","kernelPlugin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E,mBAAmB,CAACD,aAAa;IAE1E,IAAI,CAACA,eAAe;QAClB,MAAM,IAAIE,MAAM;IAClB;IAEA,yFAAyF;IACzF,MAAMhB,oBAAoB,MAAMjI,oBAAoBkC,cAAc;QAChEsF,YAAYnH,cAAcqB;QAC1BgG,SAAS;YACPC,MAAMoB;YACNb,SAASW;QACX;QACApB,eAAerH;IACjB;IAEA,sEAAsE;IACtE,MAAM8I,aAAa,MAAMtJ,2BAA2BqI,mBAAmBM;IAEvE,OAAOW;AACT;AAEA,OAAO,MAAMC,cAAc;IACzB1E;IACAG;IACAI;IACAE;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/nevermined/utils/BlockchainViemUtils.ts"],"sourcesContent":["import { signerToEcdsaValidator } from '@zerodev/ecdsa-validator'\nimport {\n deserializePermissionAccount,\n serializePermissionAccount,\n toPermissionValidator,\n} from '@zerodev/permissions'\nimport { toECDSASigner } from '@zerodev/permissions/signers'\nimport {\n addressToEmptyAccount,\n createKernelAccount,\n createKernelAccountClient,\n createZeroDevPaymasterClient,\n getUserOperationGasPrice,\n KernelAccountClient,\n type KernelSmartAccountImplementation,\n} from '@zerodev/sdk'\nimport { KERNEL_V3_1, getEntryPoint } from '@zerodev/sdk/constants'\nimport {\n Address,\n encodeAbiParameters,\n getAbiItem,\n getAddress,\n getContract,\n http,\n isAddress,\n pad,\n stringToBytes,\n stringToHex,\n toBytes,\n keccak256 as viemKeccak256,\n type Abi,\n type AbiEvent,\n type AbiFunction,\n type Account,\n type PublicClient,\n type TransactionReceipt,\n} from 'viem'\nimport { SmartAccount } from 'viem/account-abstraction'\nimport {\n english,\n generateMnemonic,\n generatePrivateKey,\n mnemonicToAccount,\n privateKeyToAccount,\n} from 'viem/accounts'\nimport { Instantiable, InstantiableConfig, Web3Clients } from '../../Instantiable.abstract.js'\nimport { ContractsError } from '../../errors/NeverminedErrors.js'\nimport { getChain } from '../../utils/Network.js'\nimport { Signer } from '@zerodev/sdk/types'\n\nconst ENTRY_POINT_VERSION = '0.7'\n\n/**\n * Utility class with methods that allow the interaction with the blockchain.\n * This class uses Viem library to interact with the blockchain.\n */\nexport class BlockchainViemUtils extends Instantiable {\n constructor(config: InstantiableConfig) {\n super()\n this.setInstanceConfig(config)\n }\n}\n\n//////////////////////////\n///// UTILITIES //////////\n//////////////////////////\n\n///// CONTRACTS\n\n// Wait budget for an L2 block to be mined and the receipt to surface.\n// Base / Base Sepolia block time is ~2s; 30s ≈ 15 blocks of headroom.\nconst TRANSACTION_RECEIPT_TIMEOUT_MS = 30_000\nconst TRANSACTION_RECEIPT_POLLING_INTERVAL_MS = 1_500\n\n/**\n * Given a transaction hash, it returns the transaction receipt.\n * Uses viem's `waitForTransactionReceipt` which polls until the receipt is\n * available, retrying on `TransactionReceiptNotFoundError` and handling\n * tx-replacement / reorgs natively.\n * @param txHash - the transaction hash\n * @returns the transaction receipt\n */\nexport async function getTransactionReceipt({\n txHash,\n publicClient,\n}: {\n txHash: `0x${string}`\n publicClient: PublicClient\n iteration?: number\n}): Promise<TransactionReceipt> {\n try {\n return await publicClient.waitForTransactionReceipt({\n hash: txHash,\n timeout: TRANSACTION_RECEIPT_TIMEOUT_MS,\n pollingInterval: TRANSACTION_RECEIPT_POLLING_INTERVAL_MS,\n confirmations: 1,\n })\n } catch (error) {\n throw new ContractsError(\n `Unable to get transaction receipt with hash: ${txHash}. Error: ${error}`,\n )\n }\n}\n\n/**\n * Given an already deployed contract address and the ABI, it returns the contract instance.\n *\n * @param contractAddress - the contract address\n * @param abi - the contract artifact\n * @param client - the client to interact with the blockchain\n * @returns a contract instance\n */\nexport async function getContractInstance(contractAddress: string, abi: Abi, client: Web3Clients) {\n return getContract({\n abi,\n address: contractAddress as `0x${string}`,\n client: { wallet: client.wallet, public: client.public },\n })\n}\n\n///// ABIs\n\n/**\n * It searchs an ABI function in the ABI.\n * @param abi the ABI of the contract\n * @param funcName the function name\n * @param args the args of the function\n * @returns the function found\n */\nexport function searchAbiFunction(abi: Abi, funcName: string, args: any[] = []): AbiFunction {\n const func = getAbiItem({ abi, name: funcName, args })\n if (!func || func.type !== 'function') {\n throw new ContractsError(`Function \"${funcName}\" is not part of contract`)\n }\n return func as AbiFunction\n}\n\n/**\n * It searchs an ABI event in the ABI.\n * @param abi the ABI of the contract\n * @param funcName the event name\n * @returns the event found\n */\nexport function searchAbiEvent(abi: Abi, eventName: string): AbiEvent {\n const event = getAbiItem({\n abi,\n name: eventName,\n })\n if (!event || event.type !== 'event') {\n throw new ContractsError(`Event \"${event}\" is not part of contract`)\n }\n return event as AbiEvent\n}\n\n/**\n * It searchs an ABI function in the ABI.\n * @param abi the ABI of the contract\n * @param funcName the function name\n * @param args the args of the function\n * @returns the function found\n */\nexport function getSignatureOfFunction(abi: Abi, funcName: string, args: any[] = []): AbiFunction {\n return searchAbiFunction(abi, funcName, args)\n}\n\n/**\n * It searchs an ABI function in the ABI and return the inputs.\n * @param abi the ABI of the contract\n * @param funcName the function name\n * @param args the args of the function\n * @returns the function found\n */\nexport function getInputsOfFunction(abi: Abi, funcName: string, args: any[] = []) {\n return searchAbiFunction(abi, funcName, args).inputs\n}\n\n/**\n * It searchs an ABI function in the ABI and return the inputs formatted.\n * @param abi the ABI of the contract\n * @param funcName the function name\n * @param args the args of the function\n * @returns the function found\n */\nexport function getInputsOfFunctionFormatted(abi: Abi, funcName: string, args: any[] = []) {\n return searchAbiFunction(abi, funcName, args).inputs.map((input, i) => {\n return {\n name: input.name,\n value: args[i],\n }\n })\n}\n\n//////// UTILS\n\n/**\n * Given an address it returns that address in checksum format.\n * @param address the address\n * @returns the same address in checksum format\n */\nexport function getChecksumAddress(address: string): string {\n return getAddress(address)\n}\n\n/**\n * It checks if the address is a valid address.\n * @param address the address to check\n * @returns true of the address is valid\n */\nexport function isValidAddress(address: string): boolean {\n return isAddress(address)\n}\n\n/**\n * Encodes a UTF-8 string into a byte array.\n\n * @param message the string to encode\n * @returns the encoded byte array\n */\nexport function getBytes(message: string): Uint8Array {\n return stringToBytes(message)\n}\n\n/**\n * It pads a value with zeros.\n * @param value the value to pad\n * @param length the expected longitutde of the value\n * @returns the padded value\n */\nexport function zeroPadValue(value: `0x${string}` | Uint8Array, length: number): string {\n return pad(value, { size: length }) as `0x${string}`\n}\n\n/**\n * Encodes a UTF-8 string into a hex string\n * @param message the string to encode\n * @returns the hex string\n */\nexport function encodeBytes32String(message: string) {\n return stringToHex(message, { size: 32 })\n}\n\n////// ACCOUNTS\n/**\n * Given a seedphrase, it returns an account.\n * @param seedphrase - the seedphrase to be used to generate the account\n * @param addressIndex - the address index\n * @returns an account\n */\nexport function makeWallet(seedphrase: string, addressIndex = 0): Account {\n return mnemonicToAccount(seedphrase, { addressIndex })\n}\n\n/**\n * Given a seedphrase generates multiple accounts\n * @param seedphrase - the seedphrase to be used to generate the account\n * @param numAccounts - the number of accounts to create\n * @returns the array of accounts\n */\nexport function makeWallets(seedphrase: string, numAccounts = 10) {\n const accounts: Account[] = []\n for (let i = 0; i < numAccounts; i++) {\n accounts.push(makeWallet(seedphrase, i))\n }\n return accounts\n}\n\n/**\n * It generates a random account.\n * @returns a new account\n */\nexport function makeRandomWallet(): Account {\n const mnemonic = generateMnemonic(english)\n return makeWallet(mnemonic)\n}\n\n/**\n * It generates a list of random accounts\n * @param numAccounts - the number of accounts to create\n * @returns the array of accounts\n */\nexport function makeRandomWallets(numAccounts = 10): Account[] {\n const mnemonic = generateMnemonic(english)\n return makeWallets(mnemonic, numAccounts)\n}\n\n/////// HASHES\n\n/**\n * It hashes a string using keccak256.\n * @param seed the string to hash\n * @returns the hash\n */\nexport function keccak256(seed: string): string {\n return viemKeccak256(toBytes(seed))\n}\n\n/**\n * It encodes and hashes a list of primitive values into an ABI-encoded hex value.\n * @param types the types of the values\n * @param values the values to encode\n * @returns the hash\n */\nexport function keccak256WithEncode(types: any[], values: any[]): string {\n const encoded = encodeAbiParameters(types, values as never)\n return keccak256(encoded)\n}\n\n/**\n * It encodes and hashes a list of primitive values into an ABI-encoded hex value.\n * @param types the types of the values\n * @param values the values to encode\n * @returns the hash\n */\nexport function keccak256Packed(types: any[], values: any[]): string {\n return keccak256WithEncode(types, values)\n}\n\n/////// ZERO DEV\n\n/**\n * Returns the bundler RPC URL. When `BUNDLER_RPC_URL_OVERRIDE` is set\n * (used by tests against a local Alto + anvil-fork stack), it takes precedence\n * over the canonical ZeroDev URL. When `useUltraRelay` is true, the production\n * URL is routed through ZeroDev's UltraRelay (`?provider=ULTRA_RELAY`); the\n * override branch is left untouched.\n * @param useUltraRelay - when true, append `?provider=ULTRA_RELAY` to route the\n * UserOperation through ZeroDev's UltraRelay bundler tier. Ignored when\n * `BUNDLER_RPC_URL_OVERRIDE` is set.\n */\nexport function getBundlerRpcUrl(\n zeroDevProjectId: string,\n chainId: number,\n useUltraRelay = false,\n): string {\n const base = `https://rpc.zerodev.app/api/v3/${zeroDevProjectId}/chain/${chainId}`\n // `||` (not `??`) because Vite replaces missing browser env vars with the\n // empty string at build time; an empty override is equivalent to \"no\n // override\" for our purposes.\n return (\n process.env.BUNDLER_RPC_URL_OVERRIDE || (useUltraRelay ? `${base}?provider=ULTRA_RELAY` : base)\n )\n}\n\n/**\n * Returns the paymaster RPC URL (ZeroDev-only; the local fork stack uses\n * `ultra-relay` which sponsors via the bundler's executor key without a\n * paymaster, so this URL is not consulted when `BUNDLER_RPC_URL_OVERRIDE` is\n * set).\n */\nexport function getPaymasterRpcUrl(zeroDevProjectId: string, chainId: number): string {\n return `https://rpc.zerodev.app/api/v3/${zeroDevProjectId}/chain/${chainId}`\n}\n\n/**\n * Returns true when the kernel client should run in \"relayer mode\" — no\n * paymaster, gas fees zeroed out. Used by tests against a local\n * `ultra-relay` (ZeroDev's fork of Alto) on top of an anvil-fork. The relayer's\n * executor key pays gas directly via `EntryPoint.handleOps`, avoiding the\n * paymaster sponsorship handshake altogether.\n */\nexport function isRelayerMode(): boolean {\n return Boolean(process.env.BUNDLER_RPC_URL_OVERRIDE)\n}\n\n/**\n * Returns gas prices for UserOperation fee estimation. ZeroDev's bundler\n * exposes a custom `zd_getUserOperationGasPrice` method; standard ERC-4337\n * bundlers do not. In relayer mode the bundler accepts UserOps with zeroed\n * `maxFeePerGas`/`maxPriorityFeePerGas` and pays gas itself.\n */\nexport async function estimateUserOperationFees(\n bundlerClient: any,\n _publicClient: any,\n): Promise<{ maxFeePerGas: bigint; maxPriorityFeePerGas: bigint }> {\n if (isRelayerMode()) {\n return { maxFeePerGas: 0n, maxPriorityFeePerGas: 0n }\n }\n return getUserOperationGasPrice(bundlerClient)\n}\n\n/**\n * It creates a ZeroDev Kernel client.\n * @param signer the signer account\n * @param chainId the chain id\n * @param zeroDevProjectId the zero dev project id, you can get it from the ZeroDev dashboard\n * @param useUltraRelay forwarded straight to `getBundlerRpcUrl` — when true the\n * bundler RPC is routed through ZeroDev's UltraRelay. Ignored when\n * `BUNDLER_RPC_URL_OVERRIDE` is set.\n * @returns the kernel client\n */\nexport async function createKernelClient(\n kernelAccount: SmartAccount,\n chainId: number,\n zeroDevProjectId: string,\n publicClient: any,\n useUltraRelay = false,\n): Promise<KernelAccountClient> {\n const bundlerRpc = getBundlerRpcUrl(zeroDevProjectId, chainId, useUltraRelay)\n const paymasterRpc = getPaymasterRpcUrl(zeroDevProjectId, chainId)\n\n return createKernelAccountClient({\n account: kernelAccount,\n chain: getChain(chainId),\n bundlerTransport: http(bundlerRpc),\n client: publicClient,\n ...(isRelayerMode()\n ? {}\n : {\n paymaster: {\n getPaymasterData: (userOperation: any) => {\n const zerodevPaymaster = createZeroDevPaymasterClient({\n chain: getChain(chainId),\n transport: http(paymasterRpc),\n })\n return zerodevPaymaster.sponsorUserOperation({ userOperation })\n },\n },\n }),\n userOperation: {\n estimateFeesPerGas: async ({ bundlerClient }) => {\n return estimateUserOperationFees(bundlerClient, publicClient)\n },\n },\n })\n}\n\nexport async function createKernelSmartAccount(\n signer: Signer,\n publicClient: PublicClient,\n): Promise<SmartAccount> {\n const ecdsaValidator = await signerToEcdsaValidator(publicClient, {\n signer: signer,\n entryPoint: getEntryPoint(ENTRY_POINT_VERSION),\n kernelVersion: KERNEL_V3_1,\n })\n\n return await createKernelAccount(publicClient, {\n plugins: {\n sudo: ecdsaValidator,\n },\n entryPoint: getEntryPoint(ENTRY_POINT_VERSION),\n kernelVersion: KERNEL_V3_1,\n })\n}\n\nexport async function getApproval(signer: Signer, publicClient: any, policies: any[]) {\n const ecdsaValidator = await signerToEcdsaValidator(publicClient, {\n entryPoint: getEntryPoint(ENTRY_POINT_VERSION),\n signer,\n kernelVersion: KERNEL_V3_1,\n })\n const emptyAccount = addressToEmptyAccount(signer.address as Address)\n const emptySessionKeySigner = await toECDSASigner({ signer: emptyAccount })\n\n const permissionPlugin = await toPermissionValidator(publicClient, {\n entryPoint: getEntryPoint(ENTRY_POINT_VERSION),\n signer: emptySessionKeySigner,\n policies: policies,\n kernelVersion: KERNEL_V3_1,\n })\n const sessionKeyAccount = await createKernelAccount(publicClient, {\n entryPoint: getEntryPoint(ENTRY_POINT_VERSION),\n plugins: {\n sudo: ecdsaValidator,\n regular: permissionPlugin,\n },\n kernelVersion: KERNEL_V3_1,\n })\n\n return await serializePermissionAccount(sessionKeyAccount)\n}\n\nexport async function useSessionKey(approval: string, signer: Signer, publicClient: any) {\n const sessionKeySigner = await toECDSASigner({\n signer,\n })\n const sessionKeyAccount = await deserializePermissionAccount(\n publicClient,\n getEntryPoint(ENTRY_POINT_VERSION),\n KERNEL_V3_1,\n approval,\n sessionKeySigner,\n )\n\n return sessionKeyAccount\n}\n\nexport async function createSessionKey(signer: Signer, publicClient: any, policies: any[]) {\n const ecdsaValidator = await signerToEcdsaValidator(publicClient, {\n entryPoint: getEntryPoint(ENTRY_POINT_VERSION),\n signer,\n kernelVersion: KERNEL_V3_1,\n })\n const sessionPrivateKey = generatePrivateKey()\n const masterAccount = privateKeyToAccount(sessionPrivateKey)\n const sessionKeySigner = await toECDSASigner({\n signer: masterAccount,\n })\n\n const permissionPlugin = await toPermissionValidator(publicClient, {\n entryPoint: getEntryPoint(ENTRY_POINT_VERSION),\n signer: sessionKeySigner,\n policies: policies,\n kernelVersion: KERNEL_V3_1,\n })\n\n const sessionKeyAccount = await createKernelAccount(publicClient, {\n entryPoint: getEntryPoint(ENTRY_POINT_VERSION),\n plugins: {\n sudo: ecdsaValidator,\n regular: permissionPlugin,\n },\n kernelVersion: KERNEL_V3_1,\n })\n\n return serializePermissionAccount(sessionKeyAccount, sessionPrivateKey)\n}\n\nexport async function getSessionKey(serializedSessionKey: string, publicClient: any) {\n const sessionKeyAccount = await deserializePermissionAccount(\n publicClient,\n getEntryPoint(ENTRY_POINT_VERSION),\n KERNEL_V3_1,\n serializedSessionKey,\n )\n\n return sessionKeyAccount\n}\n\n/**\n * Creates a delegated session key for an existing kernel account.\n * The resulting serialized session key can be deserialized into a SmartAccount\n * that shares the same address as the kernel account but enforces the given policies.\n *\n * @param kernelAccount The existing SmartAccount (kernel) to delegate from\n * @param publicClient Viem PublicClient instance\n * @param policies Array of policies to enforce for this session key\n * @returns Serialized session key string\n */\nexport async function createDelegatedSessionKeyFromKernel(\n kernelAccount: SmartAccount,\n publicClient: PublicClient,\n policies: any[],\n): Promise<string> {\n // 1) Generate ephemeral session private key (used only for the permission plugin)\n const sessionPrivateKey = generatePrivateKey()\n const sessionAccount = privateKeyToAccount(sessionPrivateKey)\n\n // 2) Wrap ephemeral key as ECDSA signer for permissions\n const sessionKeySigner = await toECDSASigner({ signer: sessionAccount })\n\n // 3) Create the permission validator plugin\n const permissionValidator = await toPermissionValidator(publicClient, {\n entryPoint: getEntryPoint(ENTRY_POINT_VERSION),\n signer: sessionKeySigner,\n policies,\n kernelVersion: KERNEL_V3_1,\n })\n\n // 4) Extract the sudo validator from the existing kernel account\n const kernelAccountTyped = kernelAccount as SmartAccount<KernelSmartAccountImplementation>\n const sudoValidator = kernelAccountTyped.kernelPluginManager.sudoValidator\n\n if (!sudoValidator) {\n throw new Error('Kernel account does not have a sudo validator')\n }\n\n // 5) Create a new kernel account with both sudo (from original) and permission validator\n const sessionKeyAccount = await createKernelAccount(publicClient, {\n entryPoint: getEntryPoint(ENTRY_POINT_VERSION),\n plugins: {\n sudo: sudoValidator, // Use existing sudo validator\n regular: permissionValidator,\n },\n kernelVersion: KERNEL_V3_1,\n })\n\n // 6) Serialize the session key account with the ephemeral private key\n const serialized = await serializePermissionAccount(sessionKeyAccount, sessionPrivateKey)\n\n return serialized\n}\n\nexport const WalletUtils = {\n makeWallet,\n makeWallets,\n makeRandomWallet,\n makeRandomWallets,\n}\n"],"names":["signerToEcdsaValidator","deserializePermissionAccount","serializePermissionAccount","toPermissionValidator","toECDSASigner","addressToEmptyAccount","createKernelAccount","createKernelAccountClient","createZeroDevPaymasterClient","getUserOperationGasPrice","KERNEL_V3_1","getEntryPoint","encodeAbiParameters","getAbiItem","getAddress","getContract","http","isAddress","pad","stringToBytes","stringToHex","toBytes","keccak256","viemKeccak256","english","generateMnemonic","generatePrivateKey","mnemonicToAccount","privateKeyToAccount","Instantiable","ContractsError","getChain","ENTRY_POINT_VERSION","BlockchainViemUtils","config","setInstanceConfig","TRANSACTION_RECEIPT_TIMEOUT_MS","TRANSACTION_RECEIPT_POLLING_INTERVAL_MS","getTransactionReceipt","txHash","publicClient","waitForTransactionReceipt","hash","timeout","pollingInterval","confirmations","error","getContractInstance","contractAddress","abi","client","address","wallet","public","searchAbiFunction","funcName","args","func","name","type","searchAbiEvent","eventName","event","getSignatureOfFunction","getInputsOfFunction","inputs","getInputsOfFunctionFormatted","map","input","i","value","getChecksumAddress","isValidAddress","getBytes","message","zeroPadValue","length","size","encodeBytes32String","makeWallet","seedphrase","addressIndex","makeWallets","numAccounts","accounts","push","makeRandomWallet","mnemonic","makeRandomWallets","seed","keccak256WithEncode","types","values","encoded","keccak256Packed","getBundlerRpcUrl","zeroDevProjectId","chainId","useUltraRelay","base","process","env","BUNDLER_RPC_URL_OVERRIDE","getPaymasterRpcUrl","isRelayerMode","Boolean","estimateUserOperationFees","bundlerClient","_publicClient","maxFeePerGas","maxPriorityFeePerGas","createKernelClient","kernelAccount","bundlerRpc","paymasterRpc","account","chain","bundlerTransport","paymaster","getPaymasterData","userOperation","zerodevPaymaster","transport","sponsorUserOperation","estimateFeesPerGas","createKernelSmartAccount","signer","ecdsaValidator","entryPoint","kernelVersion","plugins","sudo","getApproval","policies","emptyAccount","emptySessionKeySigner","permissionPlugin","sessionKeyAccount","regular","useSessionKey","approval","sessionKeySigner","createSessionKey","sessionPrivateKey","masterAccount","getSessionKey","serializedSessionKey","createDelegatedSessionKeyFromKernel","sessionAccount","permissionValidator","kernelAccountTyped","sudoValidator","kernelPluginManager","Error","serialized","WalletUtils"],"mappings":"AAAA,SAASA,sBAAsB,QAAQ,2BAA0B;AACjE,SACEC,4BAA4B,EAC5BC,0BAA0B,EAC1BC,qBAAqB,QAChB,uBAAsB;AAC7B,SAASC,aAAa,QAAQ,+BAA8B;AAC5D,SACEC,qBAAqB,EACrBC,mBAAmB,EACnBC,yBAAyB,EACzBC,4BAA4B,EAC5BC,wBAAwB,QAGnB,eAAc;AACrB,SAASC,WAAW,EAAEC,aAAa,QAAQ,yBAAwB;AACnE,SAEEC,mBAAmB,EACnBC,UAAU,EACVC,UAAU,EACVC,WAAW,EACXC,IAAI,EACJC,SAAS,EACTC,GAAG,EACHC,aAAa,EACbC,WAAW,EACXC,OAAO,EACPC,aAAaC,aAAa,QAOrB,OAAM;AAEb,SACEC,OAAO,EACPC,gBAAgB,EAChBC,kBAAkB,EAClBC,iBAAiB,EACjBC,mBAAmB,QACd,gBAAe;AACtB,SAASC,YAAY,QAAyC,iCAAgC;AAC9F,SAASC,cAAc,QAAQ,mCAAkC;AACjE,SAASC,QAAQ,QAAQ,yBAAwB;AAGjD,MAAMC,sBAAsB;AAE5B;;;CAGC,GACD,OAAO,MAAMC,4BAA4BJ;IACvC,YAAYK,MAA0B,CAAE;QACtC,KAAK;QACL,IAAI,CAACC,iBAAiB,CAACD;IACzB;AACF;AAEA,0BAA0B;AAC1B,0BAA0B;AAC1B,0BAA0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9BuC,cACA7B,cAAcqB,sBACdtB,aACAwI;IAGF,OAAOT;AACT;AAEA;;;;;;;;;CASC,GACD,OAAO,eAAeU,oCACpBnC,aAA2B,EAC3BxE,YAA0B,EAC1B6F,QAAe;IAEf,kFAAkF;IAClF,MAAMU,oBAAoBrH;IAC1B,MAAM0H,iBAAiBxH,oBAAoBmH;IAE3C,wDAAwD;IACxD,MAAMF,mBAAmB,MAAMzI,cAAc;QAAE0H,QAAQsB;IAAe;IAEtE,4CAA4C;IAC5C,MAAMC,sBAAsB,MAAMlJ,sBAAsBqC,cAAc;QACpEwF,YAAYrH,cAAcqB;QAC1B8F,QAAQe;QACRR;QACAJ,eAAevH;IACjB;IAEA,iEAAiE;IACjE,MAAM4I,qBAAqBtC;IAC3B,MAAMuC,gBAAgBD,mBAAmBE,mBAAmB,CAACD,aAAa;IAE1E,IAAI,CAACA,eAAe;QAClB,MAAM,IAAIE,MAAM;IAClB;IAEA,yFAAyF;IACzF,MAAMhB,oBAAoB,MAAMnI,oBAAoBkC,cAAc;QAChEwF,YAAYrH,cAAcqB;QAC1BkG,SAAS;YACPC,MAAMoB;YACNb,SAASW;QACX;QACApB,eAAevH;IACjB;IAEA,sEAAsE;IACtE,MAAMgJ,aAAa,MAAMxJ,2BAA2BuI,mBAAmBM;IAEvE,OAAOW;AACT;AAEA,OAAO,MAAMC,cAAc;IACzB5E;IACAG;IACAI;IACAE;AACF,EAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nevermined-io/core-kit",
3
- "version": "0.5.22",
3
+ "version": "0.5.23",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",