@lumiapassport/core 1.17.2 → 1.17.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -224,6 +224,18 @@ var LumiaPassportError = class extends Error {
224
224
  }
225
225
  }
226
226
  };
227
+ var BundlerNetworkError = class extends LumiaPassportError {
228
+ /** Bundler URL that was unreachable */
229
+ bundlerUrl;
230
+ /** Original error that caused the network failure */
231
+ originalError;
232
+ constructor(message, bundlerUrl, originalError) {
233
+ super(message, "BUNDLER_NETWORK_ERROR");
234
+ this.name = "BundlerNetworkError";
235
+ this.bundlerUrl = bundlerUrl;
236
+ this.originalError = originalError;
237
+ }
238
+ };
227
239
 
228
240
  // src/read/errors.ts
229
241
  var ReadLayerError = class extends LumiaPassportError {
@@ -343,11 +355,22 @@ async function bundlerRpc(method, params, bundlerUrl) {
343
355
  const body = { jsonrpc: "2.0", id: 1, method, params: cleanParams };
344
356
  const bodyStr = JSON.stringify(body, (_k, v) => typeof v === "bigint" ? `0x${v.toString(16)}` : v);
345
357
  console.log("[Bundler][RPC] ->", method, bodyStr);
346
- const res = await fetch(bundlerUrl, {
347
- method: "POST",
348
- headers: { "content-type": "application/json" },
349
- body: bodyStr
350
- });
358
+ let res;
359
+ try {
360
+ res = await fetch(bundlerUrl, {
361
+ method: "POST",
362
+ headers: { "content-type": "application/json" },
363
+ body: bodyStr
364
+ });
365
+ } catch (error) {
366
+ const errorMsg = error?.message || String(error);
367
+ console.log("[Bundler][RPC] <- NETWORK ERROR:", errorMsg);
368
+ throw new BundlerNetworkError(
369
+ `Bundler unreachable: ${errorMsg}`,
370
+ bundlerUrl,
371
+ error
372
+ );
373
+ }
351
374
  const json = await res.json();
352
375
  if (json.error) {
353
376
  console.log("[Bundler][RPC] <- ERROR:", JSON.stringify(json.error));
@@ -359,6 +382,22 @@ async function bundlerRpc(method, params, bundlerUrl) {
359
382
  }
360
383
 
361
384
  // src/bundler/submission.ts
385
+ var NETWORK_ERROR_PATTERNS = [
386
+ /unreachable/i,
387
+ /fetch failed/i,
388
+ /network error/i,
389
+ /ECONNREFUSED/i,
390
+ /ENOTFOUND/i,
391
+ /ETIMEDOUT/i,
392
+ /ECONNRESET/i,
393
+ /socket hang up/i,
394
+ /bundler.*unreachable/i,
395
+ /connection.*refused/i,
396
+ /getaddrinfo/i
397
+ ];
398
+ function isNetworkError(errorMsg) {
399
+ return NETWORK_ERROR_PATTERNS.some((pattern) => pattern.test(errorMsg));
400
+ }
362
401
  async function sendUserOperationRaw(userOp, options) {
363
402
  if (!options || typeof options.chainId !== "number") {
364
403
  throw new Error("sendUserOperationRaw requires options with chainId parameter. Usage: sendUserOperationRaw(userOp, { chainId: 2030232745 })");
@@ -376,7 +415,7 @@ async function sendUserOperationWithRetry(userOp, resigner, options) {
376
415
  if (!options || typeof options.chainId !== "number") {
377
416
  throw new Error("sendUserOperationWithRetry requires options with chainId parameter. Usage: sendUserOperationWithRetry(userOp, resigner, { chainId: 2030232745, maxRetries: 3 })");
378
417
  }
379
- const { chainId, maxRetries = 1 } = options;
418
+ const { chainId, maxRetries = 3 } = options;
380
419
  const chainConfig = getChainConfig(chainId);
381
420
  if (!chainConfig) {
382
421
  throw new Error(`[sendUserOperationWithRetry] ChainConfig is not found (chainId:${chainId})`);
@@ -391,6 +430,11 @@ async function sendUserOperationWithRetry(userOp, resigner, options) {
391
430
  attempts++;
392
431
  const errorMsg = String(error?.message || error);
393
432
  if (attempts >= maxRetries) throw error;
433
+ if (isNetworkError(errorMsg)) {
434
+ console.log(`[Bundler] Network error detected, retrying (attempt ${attempts}/${maxRetries})...`);
435
+ await new Promise((r) => setTimeout(r, 1e3 * attempts));
436
+ continue;
437
+ }
394
438
  if (/nonce too low|nonce.*invalid/i.test(errorMsg)) {
395
439
  const newNonce = await fetchEntryPointNonce(
396
440
  userOp.sender,
@@ -846,6 +890,7 @@ exports.getFeeEstimates = getFeeEstimates;
846
890
  exports.getPublicClient = getPublicClient2;
847
891
  exports.getUserOperationReceipt = getUserOperationReceipt;
848
892
  exports.hasPublicClient = hasPublicClient;
893
+ exports.isNetworkError = isNetworkError;
849
894
  exports.packUserOperationV07 = packUserOperationV07;
850
895
  exports.sendUserOperationRaw = sendUserOperationRaw;
851
896
  exports.sendUserOperationWithRetry = sendUserOperationWithRetry;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/bundler/constants.ts","../../src/config/networks/arbitrum-sepolia.ts","../../src/config/networks/base-sepolia.ts","../../src/config/networks/bsc-testnet.ts","../../src/config/networks/mainnet.ts","../../src/config/networks/testnet.ts","../../src/config/networks/sepolia.ts","../../src/config/networks/index.ts","../../src/lib/errors.ts","../../src/read/errors.ts","../../src/read/client-factories.ts","../../src/utils/helpers.ts","../../src/bundler/submission.ts","../../src/utils/env.ts","../../src/bundler/fee-calculation.ts","../../src/bundler/utils.ts","../../src/bundler/gas-estimation.ts","../../src/bundler/simulation.ts","../../src/bundler/client-provider.ts"],"names":["defineChain","MULTICALL3_ADDRESS","createPublicClient","http","fallback","getPublicClient"],"mappings":";;;;;;AAGO,IAAM,cAAA,GAAiB;AACvB,IAAM,UAAA,GAAa;ACQnB,IAAM,yBAAA,GAA4B,MAAA;AAKlC,IAAM,mCAAA,GAA+C,4CAAA;AAKrD,IAAM,gBAAA,GAAgC;AAAA,EAC3C,EAAA,EAAI,yBAAA;AAAA,EACJ,IAAA,EAAM,kBAAA;AAAA,EACN,IAAA,EAAM,UAAA;AAAA,EACN,WAAA,EAAa,EAAA;AAAA,EACb,OAAA,EAAS,CAAC,6CAA6C,CAAA;AAAA,EACvD,gBAAA,EAAkB,6BAAA;AAAA,EAClB,gBAAgB,EAAE,IAAA,EAAM,OAAO,MAAA,EAAQ,KAAA,EAAO,UAAU,EAAA,EAAG;AAAA,EAC3D,UAAA,EAAY,mCAAA;AAAA,EACZ,SAAA,EAAW,CAAA;AAAA,EACX,UAAA,EAAY,wDAAA;AAAA;AAAA,EAEZ,cAAA,EAAgB,4CAAA;AAAA,EAChB,oBAAA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,SAAS,CAAA;AAC/E,IAAA,IAAI,OAAO,KAAA,EAAO;AAChB,MAAA,OAAO,EAAE,KAAA,EAAO,KAAA,EAAO,KAAA,EAAO,MAAA,CAAO,MAAM,OAAA,EAAQ;AAAA,IACrD;AACA,IAAA,OAAO,EAAE,OAAO,IAAA,EAAK;AAAA,EACvB,SAAS,KAAA,EAAO;AACd,IAAA,MAAM,WAAW,KAAA,YAAiB,KAAA,GAAQ,KAAA,CAAM,OAAA,GAAU,OAAO,KAAK,CAAA;AACtE,IAAA,OAAO,EAAE,KAAA,EAAO,KAAA,EAAO,KAAA,EAAO,QAAA,EAAS;AAAA,EACzC;AACF;;;AC5CA,IAAI,kBAAA,GAAiC,IAAA;AAM9B,SAAS,gBAAgB,MAAA,EAAmB;AACjD,EAAA,kBAAA,GAAqB,MAAA;AACvB;AAMO,SAASC,gBAAAA,GAAuB;AACrC,EAAA,IAAI,CAAC,kBAAA,EAAoB;AACvB,IAAA,MAAM,IAAI,KAAA;AAAA,MACR;AAAA,KAEF;AAAA,EACF;AACA,EAAA,OAAO,kBAAA;AACT;AAKO,SAAS,eAAA,GAA2B;AACzC,EAAA,OAAO,kBAAA,KAAuB,IAAA;AAChC","file":"index.cjs","sourcesContent":["/**\n * ERC-4337 EntryPoint contract address (v0.7)\n */\nexport const ENTRYPOINT_V07 = '0x0000000071727De22E5E9d8BAf0edAc6f37da032' as const;\nexport const ENTRYPOINT = ENTRYPOINT_V07;\n","/**\n * Arbitrum Sepolia Testnet Configuration\n */\n\nimport type { Address, Chain } from 'viem'\nimport { defineChain } from 'viem'\n\nimport type { ChainConfig } from '../../read/types'\n\n/**\n * Arbitrum Sepolia chain ID\n */\nexport const ARBITRUM_SEPOLIA_CHAIN_ID = 421614\n\n/**\n * Well-known Multicall3 contract address\n */\nexport const ARBITRUM_SEPOLIA_MULTICALL3_ADDRESS: Address = '0xcA11bde05977b3631167028862bE2a173976CA11'\n\n/**\n * Arbitrum Sepolia configuration\n */\nexport const ARBITRUM_SEPOLIA: ChainConfig = {\n id: ARBITRUM_SEPOLIA_CHAIN_ID,\n name: 'Arbitrum Sepolia',\n logo: 'arbitrum',\n logoDataUri: '',\n rpcUrls: ['https://arbitrum-sepolia-rpc.publicnode.com'],\n blockExplorerUrl: 'https://sepolia.arbiscan.io',\n nativeCurrency: { name: 'ETH', symbol: 'ETH', decimals: 18 },\n multicall3: ARBITRUM_SEPOLIA_MULTICALL3_ADDRESS,\n blockTime: 1,\n bundlerUrl: 'https://api.lumiapassport.com/rundler-arbitrum-sepolia',\n // EVM version: shanghai\n factoryAddress: '0x4be18A5ff553A881b2a272d0Ce4b3E82d763574f',\n entryPointV07Address: '0x0000000071727De22E5E9d8BAf0edAc6f37da032',\n paymasterAddress: '0x536b6F1Db43AA3D537376E40f73cFdcFf8930244',\n}\n\n/**\n * Viem chain definition for Arbitrum Sepolia\n */\nexport const arbitrumSepoliaChain: Chain = defineChain({\n id: ARBITRUM_SEPOLIA_CHAIN_ID,\n name: 'Arbitrum Sepolia',\n nativeCurrency: ARBITRUM_SEPOLIA.nativeCurrency,\n rpcUrls: {\n default: { http: ARBITRUM_SEPOLIA.rpcUrls },\n public: { http: ARBITRUM_SEPOLIA.rpcUrls },\n },\n blockExplorers: {\n default: { name: 'Arbiscan', url: ARBITRUM_SEPOLIA.blockExplorerUrl },\n },\n})\n","/**\n * Base Sepolia Testnet Configuration\n */\n\nimport type { Address, Chain } from 'viem'\nimport { defineChain } from 'viem'\n\nimport type { ChainConfig } from '../../read/types'\n\n/**\n * Base Sepolia chain ID\n */\nexport const BASE_SEPOLIA_CHAIN_ID = 84532\n\n/**\n * Well-known Multicall3 contract address\n */\nexport const BASE_SEPOLIA_MULTICALL3_ADDRESS: Address = '0xcA11bde05977b3631167028862bE2a173976CA11'\n\n/**\n * Base Sepolia configuration\n */\nexport const BASE_SEPOLIA: ChainConfig = {\n id: BASE_SEPOLIA_CHAIN_ID,\n name: 'Base Sepolia',\n logo: 'base',\n logoDataUri: '',\n rpcUrls: ['https://base-sepolia-rpc.publicnode.com'],\n blockExplorerUrl: 'https://sepolia.basescan.org',\n nativeCurrency: { name: 'ETH', symbol: 'ETH', decimals: 18 },\n multicall3: BASE_SEPOLIA_MULTICALL3_ADDRESS,\n blockTime: 2,\n bundlerUrl: 'https://api.lumiapassport.com/rundler-base-sepolia',\n // EVM version: shanghai\n factoryAddress: '0x4be18A5ff553A881b2a272d0Ce4b3E82d763574f',\n entryPointV07Address: '0x0000000071727De22E5E9d8BAf0edAc6f37da032',\n paymasterAddress: '0x536b6F1Db43AA3D537376E40f73cFdcFf8930244',\n}\n\n/**\n * Viem chain definition for Base Sepolia\n */\nexport const baseSepoliaChain: Chain = defineChain({\n id: BASE_SEPOLIA_CHAIN_ID,\n name: 'Base Sepolia',\n nativeCurrency: BASE_SEPOLIA.nativeCurrency,\n rpcUrls: {\n default: { http: BASE_SEPOLIA.rpcUrls },\n public: { http: BASE_SEPOLIA.rpcUrls },\n },\n blockExplorers: {\n default: { name: 'BaseScan', url: BASE_SEPOLIA.blockExplorerUrl },\n },\n})\n","/**\n * BSC Testnet Configuration\n */\n\nimport type { Address, Chain } from 'viem'\nimport { defineChain } from 'viem'\n\nimport type { ChainConfig } from '../../read/types'\n\n/**\n * BSC Testnet chain ID\n */\nexport const BSC_TESTNET_CHAIN_ID = 97\n\n/**\n * Well-known Multicall3 contract address\n */\nexport const BSC_TESTNET_MULTICALL3_ADDRESS: Address = '0xcA11bde05977b3631167028862bE2a173976CA11'\n\n/**\n * BSC Testnet configuration\n */\nexport const BSC_TESTNET: ChainConfig = {\n id: BSC_TESTNET_CHAIN_ID,\n name: 'BSC Testnet',\n logo: 'bnb',\n logoDataUri: '',\n rpcUrls: ['https://bsc-testnet-rpc.publicnode.com'],\n blockExplorerUrl: 'https://testnet.bscscan.com',\n nativeCurrency: { name: 'BNB', symbol: 'BNB', decimals: 18 },\n multicall3: BSC_TESTNET_MULTICALL3_ADDRESS,\n blockTime: 3,\n bundlerUrl: 'https://api.lumiapassport.com/rundler-bnb-testnet',\n // EVM version: shanghai\n factoryAddress: '0x4be18A5ff553A881b2a272d0Ce4b3E82d763574f',\n entryPointV07Address: '0x0000000071727De22E5E9d8BAf0edAc6f37da032',\n paymasterAddress: '0x536b6F1Db43AA3D537376E40f73cFdcFf8930244',\n}\n\n/**\n * Viem chain definition for BSC Testnet\n */\nexport const bscTestnetChain: Chain = defineChain({\n id: BSC_TESTNET_CHAIN_ID,\n name: 'BSC Testnet',\n nativeCurrency: BSC_TESTNET.nativeCurrency,\n rpcUrls: {\n default: { http: BSC_TESTNET.rpcUrls },\n public: { http: BSC_TESTNET.rpcUrls },\n },\n blockExplorers: {\n default: { name: 'BscScan Testnet', url: BSC_TESTNET.blockExplorerUrl },\n },\n})\n","/**\n * Lumia Mainnet Configuration\n */\n\nimport type { Address, Chain } from 'viem';\nimport { defineChain } from 'viem';\nimport type { ChainConfig } from '../../read/types';\n\n/**\n * Lumia Mainnet chain ID\n */\nexport const LUMIA_MAINNET_CHAIN_ID = 994873017;\n\n/**\n * Well-known Multicall3 contract address\n */\nexport const MULTICALL3_ADDRESS: Address = '0xcA11bde05977b3631167028862bE2a173976CA11';\n\n/**\n * Lumia Mainnet configuration\n */\nexport const LUMIA_MAINNET: ChainConfig = {\n id: LUMIA_MAINNET_CHAIN_ID,\n name: 'Lumia Prism Mainnet',\n logo: 'lumia',\n logoDataUri: '',\n rpcUrls: ['https://mainnet-rpc.lumia.org'],\n blockExplorerUrl: 'https://explorer.lumia.org',\n multicall3: MULTICALL3_ADDRESS,\n blockTime: 2,\n bundlerUrl: 'https://api.lumiapassport.com/rundler-prism',\n nativeCurrency: { name: 'LUMIA', symbol: 'LUMIA', decimals: 18 },\n // EVM version: shanghai (no MCOPY opcode)\n factoryAddress: '0x9Db2Ed382E6E627d548204483fB588FDc0d664B0',\n entryPointV07Address: '0x0000000071727De22E5E9d8BAf0edAc6f37da032',\n paymasterAddress: '0x1A8692fC7135CA59AF157C33C015F601FE4B3B7b',\n};\n\n/**\n * Viem chain definition for Lumia Mainnet\n */\nexport const lumiaMainnetChain: Chain = defineChain({\n id: LUMIA_MAINNET_CHAIN_ID,\n name: 'Lumia Prism Mainnet',\n nativeCurrency: LUMIA_MAINNET.nativeCurrency,\n rpcUrls: {\n default: { http: LUMIA_MAINNET.rpcUrls },\n public: { http: LUMIA_MAINNET.rpcUrls },\n },\n blockExplorers: {\n default: { name: 'Lumia Explorer', url: LUMIA_MAINNET.blockExplorerUrl },\n },\n});",";\n/**\n * Lumia Testnet (Beam) Configuration\n */\n\nimport type { Address, Chain } from 'viem'\nimport { defineChain } from 'viem';\n\n\n\nimport type { ChainConfig } from '../../read/types';\n\n\n/**\n * Lumia Testnet chain ID\n */\nexport const LUMIA_TESTNET_CHAIN_ID = 2030232745;\n\n/**\n * Well-known Multicall3 contract address\n */\nexport const MULTICALL3_ADDRESS: Address = '0xcA11bde05977b3631167028862bE2a173976CA11';\n\n/**\n * Lumia Testnet configuration\n */\nexport const LUMIA_TESTNET: ChainConfig = {\n id: LUMIA_TESTNET_CHAIN_ID,\n name: 'Lumia Beam',\n logo: 'lumia',\n logoDataUri: '',\n rpcUrls: ['https://beam-rpc.lumia.org'],\n blockExplorerUrl: 'https://beam-explorer.lumia.org',\n nativeCurrency: { name: 'LUMIA', symbol: 'LUMIA', decimals: 18 },\n multicall3: MULTICALL3_ADDRESS,\n blockTime: 2,\n bundlerUrl: 'https://api.lumiapassport.com/rundler',\n factoryAddress: '0x37053B3C6fb47B92355B95E7bEfa6dDf04Cc9981',\n entryPointV07Address: '0x0000000071727De22E5E9d8BAf0edAc6f37da032',\n paymasterAddress: '0x9Dca693bdDc09d6B10c7ad3C86BBC0C704571Ec5',\n};\n\n/**\n * Viem chain definition for Lumia Testnet\n */\nexport const lumiaTestnetChain: Chain = defineChain({\n id: LUMIA_TESTNET_CHAIN_ID,\n name: 'Lumia Beam Testnet',\n nativeCurrency: LUMIA_TESTNET.nativeCurrency,\n rpcUrls: {\n default: { http: LUMIA_TESTNET.rpcUrls },\n public: { http: LUMIA_TESTNET.rpcUrls },\n },\n blockExplorers: {\n default: { name: 'Lumia Beam Explorer', url: LUMIA_TESTNET.blockExplorerUrl },\n },\n logo: 'lumia'\n});","/**\n * Sepolia Testnet Configuration\n */\n\nimport type { Address, Chain } from 'viem';\nimport { defineChain } from 'viem';\nimport type { ChainConfig } from '../../read/types';\n\n/**\n * Sepolia Testnet chain ID\n */\nexport const SEPOLIA_CHAIN_ID = 11155111;\n\n/**\n * Well-known Multicall3 contract address\n */\nexport const MULTICALL3_ADDRESS: Address = '0xcA11bde05977b3631167028862bE2a173976CA11';\n\n/**\n * Sepolia Testnet configuration\n */\nexport const SEPOLIA: ChainConfig = {\n id: SEPOLIA_CHAIN_ID,\n name: 'Sepolia',\n logo: 'ethereum',\n logoDataUri: '',\n rpcUrls: ['https://ethereum-sepolia-rpc.publicnode.com'],\n blockExplorerUrl: 'https://sepolia.etherscan.io',\n multicall3: MULTICALL3_ADDRESS,\n blockTime: 12,\n bundlerUrl: 'https://api.lumiapassport.com/rundler-sepolia',\n nativeCurrency: { name: 'Sepolia Ether', symbol: 'ETH', decimals: 18 },\n factoryAddress: '0x4be18A5ff553A881b2a272d0Ce4b3E82d763574f',\n entryPointV07Address: '0x0000000071727De22E5E9d8BAf0edAc6f37da032',\n paymasterAddress: '0x536b6F1Db43AA3D537376E40f73cFdcFf8930244',\n};\n\n/**\n * Viem chain definition for Sepolia Testnet\n */\nexport const sepoliaChain: Chain = defineChain({\n id: SEPOLIA_CHAIN_ID,\n name: 'Sepolia',\n nativeCurrency: SEPOLIA.nativeCurrency,\n rpcUrls: {\n default: { http: SEPOLIA.rpcUrls },\n public: { http: SEPOLIA.rpcUrls },\n },\n blockExplorers: {\n default: { name: 'Etherscan', url: SEPOLIA.blockExplorerUrl },\n },\n testnet: true,\n});\n",";\n/**\n * Blockchain Read Layer - Constants and Chain Configurations\n * @module @lumiapassport/core/read/constants\n */\n\nimport type { Chain } from 'viem';\n\n\n\nimport type { ChainConfig } from '../../read/types';\nimport { ARBITRUM_SEPOLIA, ARBITRUM_SEPOLIA_CHAIN_ID, arbitrumSepoliaChain } from './arbitrum-sepolia';\nimport { BASE_SEPOLIA, BASE_SEPOLIA_CHAIN_ID, baseSepoliaChain } from './base-sepolia';\nimport { BSC_TESTNET, BSC_TESTNET_CHAIN_ID, bscTestnetChain } from './bsc-testnet';\nimport { LUMIA_MAINNET, LUMIA_MAINNET_CHAIN_ID, lumiaMainnetChain } from './mainnet';\nimport { LUMIA_TESTNET, LUMIA_TESTNET_CHAIN_ID, lumiaTestnetChain } from './testnet';\nimport { SEPOLIA, SEPOLIA_CHAIN_ID, sepoliaChain } from './sepolia';\n\n\n// Re-export from mainnet\nexport {\n LUMIA_MAINNET_CHAIN_ID,\n LUMIA_MAINNET,\n lumiaMainnetChain,\n} from './mainnet';\n\n// Re-export from testnet\nexport {\n LUMIA_TESTNET_CHAIN_ID,\n LUMIA_TESTNET,\n lumiaTestnetChain,\n} from './testnet';\n\n// Re-export from sepolia\nexport {\n SEPOLIA_CHAIN_ID,\n SEPOLIA,\n sepoliaChain,\n} from './sepolia';\n\n// Re-export from bsc-testnet\nexport {\n BSC_TESTNET_CHAIN_ID,\n BSC_TESTNET,\n bscTestnetChain,\n} from './bsc-testnet';\n\n// Re-export from arbitrum-sepolia\nexport {\n ARBITRUM_SEPOLIA_CHAIN_ID,\n ARBITRUM_SEPOLIA,\n arbitrumSepoliaChain,\n} from './arbitrum-sepolia';\n\n// Re-export from base-sepolia\nexport {\n BASE_SEPOLIA_CHAIN_ID,\n BASE_SEPOLIA,\n baseSepoliaChain,\n} from './base-sepolia';\n\n// Re-export MULTICALL3_ADDRESS from testnet (same on all chains)\nexport { MULTICALL3_ADDRESS } from './testnet';\n\n\n\n\n/**\n * Default chain ID used when no chain is explicitly selected\n * Currently set to TESTNET for safety during development\n */\nexport const DEFAULT_CHAIN_ID = LUMIA_TESTNET_CHAIN_ID;\n\n/**\n * All supported chains with built-in configurations\n */\nexport const SUPPORTED_CHAINS: Map<number, ChainConfig> = new Map([\n [LUMIA_MAINNET_CHAIN_ID, LUMIA_MAINNET],\n [LUMIA_TESTNET_CHAIN_ID, LUMIA_TESTNET],\n [SEPOLIA_CHAIN_ID, SEPOLIA],\n [BSC_TESTNET_CHAIN_ID, BSC_TESTNET],\n [ARBITRUM_SEPOLIA_CHAIN_ID, ARBITRUM_SEPOLIA],\n [BASE_SEPOLIA_CHAIN_ID, BASE_SEPOLIA],\n]);\n\nexport const VIEM_CHAINS: Map<number, Chain> = new Map([\n [LUMIA_MAINNET_CHAIN_ID, lumiaMainnetChain],\n [LUMIA_TESTNET_CHAIN_ID, lumiaTestnetChain],\n [SEPOLIA_CHAIN_ID, sepoliaChain],\n [BSC_TESTNET_CHAIN_ID, bscTestnetChain],\n [ARBITRUM_SEPOLIA_CHAIN_ID, arbitrumSepoliaChain],\n [BASE_SEPOLIA_CHAIN_ID, baseSepoliaChain],\n]);\n\n/**\n * Get chain configuration by chain ID\n * Returns undefined for unsupported chains\n */\nexport function getChainConfig(chainId: number): ChainConfig | undefined {\n return SUPPORTED_CHAINS.get(chainId);\n}\n\n/**\n * Check if a chain is supported with built-in configuration\n */\nexport function isChainSupported(chainId: number): boolean {\n return SUPPORTED_CHAINS.has(chainId);\n}\n\n/**\n * Get viem chain definition by chain ID\n * Returns undefined for unsupported chains\n */\nexport function getViemChain(chainId: number): Chain | undefined {\n return VIEM_CHAINS.get(chainId);\n}\n\n/**\n * Default cache TTL in milliseconds (12 seconds, ~1 block)\n */\nexport const DEFAULT_CACHE_TTL = 12000;\n\n/**\n * Default maximum cache entries\n */\nexport const DEFAULT_CACHE_MAX_SIZE = 1000;\n\n/**\n * Default maximum calls per multicall batch\n */\nexport const DEFAULT_MULTICALL_BATCH_SIZE = 100;\n\n/**\n * Default block range for getLogs queries (to avoid RPC limits)\n */\nexport const DEFAULT_LOGS_BLOCK_RANGE = 2000n;\n\n/**\n * Maximum block range for a single getLogs query\n */\nexport const MAX_LOGS_BLOCK_RANGE = 10000n;","/**\n * Base error classes for Lumia Passport SDK\n * @module @lumiapassport/core/lib/errors\n */\n\n/**\n * Base error class for all Lumia Passport errors\n *\n * Contains a machine-readable error code for programmatic handling.\n * All SDK errors should extend this class for consistent error handling.\n */\nexport class LumiaPassportError extends Error {\n /** Machine-readable error code for programmatic handling */\n readonly code: string;\n\n constructor(message: string, code: string) {\n super(message);\n this.code = code;\n this.name = 'LumiaPassportError';\n\n // Maintain proper stack trace for where our error was thrown (only available on V8)\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, this.constructor);\n }\n }\n}","/**\n * Blockchain Read Layer - Error Classes\n * @module @lumiapassport/core/read\n */\n\nimport type { Address } from 'viem';\nimport { LumiaPassportError } from '../lib/errors';\n\n/**\n * Base error class for read layer errors\n * Extends LumiaPassportError for consistent SDK error handling\n */\nexport class ReadLayerError extends LumiaPassportError {\n constructor(message: string, code: string) {\n super(message, code);\n this.name = 'ReadLayerError';\n }\n}\n\n/**\n * Contract does not exist at the specified address\n */\nexport class ContractNotFoundError extends ReadLayerError {\n constructor(\n public readonly address: Address,\n public readonly chainId: number,\n ) {\n super(\n `Contract not found at ${address} on chain ${chainId}`,\n 'CONTRACT_NOT_FOUND',\n );\n this.name = 'ContractNotFoundError';\n }\n}\n\n/**\n * Contract call reverted with a reason\n */\nexport class ContractRevertError extends ReadLayerError {\n constructor(\n public readonly address: Address,\n public readonly functionName: string,\n public readonly reason: string,\n ) {\n super(\n `Contract call to ${functionName} at ${address} reverted: ${reason}`,\n 'CONTRACT_REVERTED',\n );\n this.name = 'ContractRevertError';\n }\n}\n\n/**\n * Failed to connect to RPC endpoint\n */\nexport class RpcConnectionError extends ReadLayerError {\n constructor(\n public readonly url: string,\n public readonly cause?: Error,\n ) {\n super(`Failed to connect to RPC: ${url}`, 'RPC_CONNECTION_FAILED');\n this.name = 'RpcConnectionError';\n }\n}\n\n/**\n * All configured RPC endpoints failed\n */\nexport class AllRpcsFailedError extends ReadLayerError {\n constructor(\n public readonly urls: string[],\n public readonly errors: Error[],\n ) {\n super(\n `All ${urls.length} RPC endpoint(s) failed`,\n 'ALL_RPCS_FAILED',\n );\n this.name = 'AllRpcsFailedError';\n }\n}\n\n/**\n * RPC returned rate limit response\n */\nexport class RateLimitedError extends ReadLayerError {\n constructor(\n public readonly url: string,\n public readonly retryAfter?: number,\n ) {\n super(\n `Rate limited by RPC: ${url}${retryAfter ? `, retry after ${retryAfter}s` : ''}`,\n 'RATE_LIMITED',\n );\n this.name = 'RateLimitedError';\n }\n}\n\n/**\n * Requested block has been pruned from RPC node\n */\nexport class BlockPrunedError extends ReadLayerError {\n constructor(public readonly blockNumber: bigint) {\n super(\n `Block ${blockNumber} has been pruned and is not available`,\n 'BLOCK_PRUNED',\n );\n this.name = 'BlockPrunedError';\n }\n}\n\n/**\n * Invalid ABI provided - function not found\n */\nexport class InvalidAbiError extends ReadLayerError {\n constructor(\n public readonly functionName: string,\n public readonly address: Address,\n ) {\n super(\n `Function '${functionName}' not found in ABI for contract at ${address}`,\n 'INVALID_ABI',\n );\n this.name = 'InvalidAbiError';\n }\n}\n\n/**\n * Chain configuration not found\n *\n * @example\n * ```typescript\n * import { createPublicClientForChain } from '@lumiapassport/core/read'\n *\n * try {\n * const client = createPublicClientForChain(999999)\n * } catch (error) {\n * if (error instanceof ChainNotSupportedError) {\n * console.error('Unsupported chain:', error.chainId)\n * console.log('Supported chains:', error.supportedChains)\n * }\n * }\n * ```\n */\nexport class ChainNotSupportedError extends ReadLayerError {\n /** List of supported chain IDs */\n public readonly supportedChains: number[];\n\n constructor(chainId: number, supportedChains: number[] = []) {\n const chainList = supportedChains.length > 0\n ? `Supported chains: ${supportedChains.join(', ')}`\n : 'Please provide an RPC URL.';\n\n super(\n `Chain ${chainId} is not supported. ${chainList}`,\n 'CHAIN_NOT_SUPPORTED',\n );\n this.name = 'ChainNotSupportedError';\n this.supportedChains = supportedChains;\n }\n}\n\n/**\n * Transaction receipt not found within timeout period\n */\nexport class TransactionReceiptTimeoutError extends ReadLayerError {\n constructor(\n public readonly hash: string,\n public readonly timeout: number,\n ) {\n super(\n `Transaction receipt not found within ${timeout}ms: ${hash}`,\n 'TRANSACTION_RECEIPT_TIMEOUT',\n );\n this.name = 'TransactionReceiptTimeoutError';\n }\n}\n",";\n/**\n * Client Factories - Multi-Chain Support\n * @module @lumiapassport/core/read\n *\n * Stateless factory functions for creating viem clients for specific chains.\n * Each call creates a fresh client instance (no caching) - this is intentional\n * as viem clients are lightweight (<10ms creation time).\n */\n\nimport { createPublicClient, defineChain, http, type Chain, type PublicClient } from 'viem';\nimport { createBundlerClient, type BundlerClient } from 'viem/account-abstraction'\n\nimport { getChainConfig, getViemChain, SUPPORTED_CHAINS } from '../config/networks'\nimport { ChainNotSupportedError } from './errors';\nimport type { ChainConfig } from './types';\n\n\n/**\n * Create a viem Chain object from ChainConfig\n *\n * @param chainConfig - Chain configuration with RPC URLs and metadata\n * @returns Viem Chain object ready for client creation\n *\n * @example\n * ```typescript\n * import { LUMIA_TESTNET, createChainFromConfig } from '@lumiapassport/core/read'\n *\n * const chain = createChainFromConfig(LUMIA_TESTNET)\n * // chain.id === 2030232745\n * // chain.name === 'Lumia Beam'\n * ```\n */\nexport function createChainFromConfig(chainConfig: ChainConfig): Chain {\n return defineChain({\n id: chainConfig.id,\n name: chainConfig.name,\n nativeCurrency: {\n name: 'LUMIA',\n symbol: 'LUMIA',\n decimals: 18,\n },\n rpcUrls: {\n default: { http: chainConfig.rpcUrls },\n public: { http: chainConfig.rpcUrls },\n },\n });\n}\n\n/**\n * Create a PublicClient for reading blockchain data from a specific chain\n *\n * Creates a new client instance on each call (no caching).\n * Client creation is lightweight (<10ms) so caching is unnecessary.\n *\n * @param chainId - Numeric chain ID (must be in SUPPORTED_CHAINS)\n * @returns Configured PublicClient for the specified chain\n * @throws {ChainNotSupportedError} If chainId is not in SUPPORTED_CHAINS\n *\n * @example\n * ```typescript\n * import { createPublicClientForChain, LUMIA_TESTNET_CHAIN_ID } from '@lumiapassport/core/read'\n *\n * const client = createPublicClientForChain(LUMIA_TESTNET_CHAIN_ID)\n *\n * const balance = await client.getBalance({ address: '0x...' })\n * const code = await client.getCode({ address: '0x...' })\n * ```\n *\n * @example\n * ```typescript\n * // Error handling\n * try {\n * const client = createPublicClientForChain(999999) // Invalid chainId\n * } catch (error) {\n * console.error(error.message)\n * // \"Chain 999999 is not supported. Supported chains: 994873017, 2030232745\"\n * }\n * ```\n */\nexport function createPublicClientForChain(chainId: number): PublicClient {\n const chainConfig = getChainConfig(chainId);\n\n if (!chainConfig) {\n const supportedChainIds = Array.from(SUPPORTED_CHAINS.keys());\n throw new ChainNotSupportedError(chainId, supportedChainIds);\n }\n const viemChain = getViemChain(chainId)\n\n return createPublicClient({\n chain: viemChain,\n transport: http(chainConfig.rpcUrls[0], {\n timeout: 10_000,\n retryCount: 2,\n fetchOptions: { mode: 'cors' },\n }),\n });\n}\n\n/**\n * Create a BundlerClient for submitting UserOperations to a specific chain\n *\n * Creates a new client instance on each call (no caching).\n * Requires the chain to have a bundlerUrl configured.\n *\n * @param chainId - Numeric chain ID (must be in SUPPORTED_CHAINS)\n * @returns Configured BundlerClient for the specified chain\n * @throws {ChainNotSupportedError} If chainId is not in SUPPORTED_CHAINS\n * @throws {Error} If chain configuration lacks bundlerUrl\n *\n * @example\n * ```typescript\n * import { createBundlerClientForChain, LUMIA_MAINNET_CHAIN_ID } from '@lumiapassport/core/read'\n *\n * const bundler = createBundlerClientForChain(LUMIA_MAINNET_CHAIN_ID)\n *\n * const userOpHash = await bundler.sendUserOperation({\n * userOperation,\n * entryPoint: ENTRYPOINT_V07\n * })\n * ```\n *\n * @example\n * ```typescript\n * // Error: Missing bundlerUrl\n * try {\n * const bundler = createBundlerClientForChain(LUMIA_MAINNET_CHAIN_ID)\n * } catch (error) {\n * console.error(error.message)\n * // \"Chain 994873017 (Lumia) has no bundlerUrl configured\"\n * }\n * ```\n */\nexport function createBundlerClientForChain(chainId: number): BundlerClient {\n const chainConfig = getChainConfig(chainId);\n\n if (!chainConfig) {\n const supportedChainIds = Array.from(SUPPORTED_CHAINS.keys());\n throw new ChainNotSupportedError(chainId, supportedChainIds);\n }\n\n if (!chainConfig.bundlerUrl) {\n throw new Error(\n `Chain ${chainId} (${chainConfig.name}) has no bundlerUrl configured`\n );\n }\n\n const viemChain = getViemChain(chainId)\n\n return createBundlerClient({\n chain: viemChain,\n transport: http(chainConfig.bundlerUrl, {\n timeout: 10_000,\n retryCount: 0,\n fetchOptions: { mode: 'cors' },\n }),\n });\n}\n","/**\n * Account Abstraction helper utilities\n * Adapted from lumia-passport-ui-kit/src/internal/akHelpers.ts\n */\n\nimport type { ChainContext } from '../bundler/types';\n\n/**\n * Precompile address for ecrecover\n * @internal\n */\n// const ECRECOVER_PRECOMPILE = '0x0000000000000000000000000000000000000001' as const;\n\n/**\n * ABI for ecrecover precompile\n * @internal\n */\n// const ECRECOVER_ABI = [\n// {\n// name: 'ecrecover',\n// type: 'function',\n// inputs: [\n// { name: 'hash', type: 'bytes32' },\n// { name: 'v', type: 'uint8' },\n// { name: 'r', type: 'bytes32' },\n// { name: 's', type: 'bytes32' }\n// ],\n// outputs: [{ name: 'addr', type: 'address' }]\n// },\n// ] as const;\n\n/**\n * Safely convert value to BigInt with fallback\n * @param val - Value to convert\n * @param fallback - Fallback value if conversion fails\n */\nexport const safeToBigInt = (val: any, fallback = '0x0'): bigint => {\n try {\n return BigInt(val || fallback);\n } catch {\n return BigInt(fallback);\n }\n};\n\n/**\n * Pack two 128-bit values into single 256-bit value\n * Used for packing gas limits in ERC-4337 v0.7\n * @param hi - High 128 bits\n * @param lo - Low 128 bits\n * @returns Packed 256-bit value as bigint\n */\nexport const pack2x128 = (hi: bigint, lo: bigint): bigint => {\n return (hi << 128n) | (lo & ((1n << 128n) - 1n));\n};\n\n/**\n * Verify signature against expected owner address\n * @param opHash - Operation hash that was signed\n * @param signature - Signature to verify\n * @param expectedOwner - Expected owner address\n */\nexport async function verifySignatureAgainstOwner(\n opHash: `0x${string}`,\n signature: `0x${string}`,\n expectedOwner?: `0x${string}`\n): Promise<void> {\n if (!signature || signature === '0x') return;\n\n try {\n // This will be implemented after we have publicClient from clients module\n // For now, this is a placeholder\n console.log('[AA][sign] Signature verification:', {\n opHash,\n signature,\n expectedOwner,\n });\n } catch (error) {\n console.error('[AA][sign][ERROR] Could not verify signature:', error);\n }\n}\n\n/**\n * Fetch nonce from EntryPoint contract\n * @param account - Account address\n * @param _entryPoint - EntryPoint contract address (unused in placeholder)\n * @param _context - Chain context with blockchain client (unused in placeholder)\n */\nexport async function fetchEntryPointNonce(\n account: `0x${string}`,\n _entryPoint: `0x${string}`,\n _context: ChainContext\n): Promise<`0x${string}`> {\n // This will be implemented after we have publicClient from clients module\n // For now, return 0x0 as placeholder\n console.log('[AA] fetchEntryPointNonce called for:', account);\n return '0x0';\n}\n\n/**\n * Sanitize UserOperation object by fixing common issues\n * @param userOp - UserOperation to sanitize\n */\nfunction sanitizeUserOperation(userOp: any): any {\n const sanitized = { ...userOp };\n\n // Fix sender field if it's an object (extract address and factory fields)\n if (typeof sanitized.sender === 'object' && sanitized.sender) {\n const senderObj = sanitized.sender;\n\n // Extract the actual sender address\n sanitized.sender = senderObj.sender || senderObj.address || senderObj.smartAccountAddress;\n\n // Extract factory fields if they exist\n if (senderObj.factory) {\n sanitized.factory = senderObj.factory;\n }\n if (senderObj.factoryData) {\n sanitized.factoryData = senderObj.factoryData;\n }\n }\n\n // Ensure all hex fields are valid and properly formatted\n const hexFields = [\n 'sender', 'nonce', 'callData', 'callGasLimit', 'verificationGasLimit',\n 'preVerificationGas', 'maxFeePerGas', 'maxPriorityFeePerGas', 'signature',\n 'factory', 'factoryData', 'paymaster', 'paymasterData',\n 'paymasterVerificationGasLimit', 'paymasterPostOpGasLimit'\n ];\n\n for (const field of hexFields) {\n const value = sanitized[field];\n if (value !== undefined && value !== null) {\n if (typeof value === 'string') {\n if (value === '0x' || value === '') {\n // Convert empty hex to 0x0 for numeric fields, 0x for data fields\n if (['callData', 'factoryData', 'paymasterData', 'signature'].includes(field)) {\n sanitized[field] = '0x';\n } else {\n sanitized[field] = '0x0';\n }\n } else if (field === 'sender' || field === 'factory' || field === 'paymaster') {\n // Address fields should have 0x prefix\n if (!value.startsWith('0x')) {\n sanitized[field] = `0x${value}`;\n }\n } else if (!value.startsWith('0x')) {\n sanitized[field] = `0x${value}`;\n }\n }\n }\n }\n\n // Remove undefined/null fields for v0.7\n Object.keys(sanitized).forEach(key => {\n if (sanitized[key] === undefined || sanitized[key] === null) {\n delete sanitized[key];\n }\n });\n\n // Ensure required fields exist with proper defaults\n if (!sanitized.callData) sanitized.callData = '0x';\n if (!sanitized.signature) sanitized.signature = '0x';\n\n return sanitized;\n}\n\n/**\n * Make RPC call to bundler\n * @param method - RPC method name\n * @param params - RPC method parameters\n * @param bundlerUrl - Bundler URL (required)\n */\nexport async function bundlerRpc(\n method: string,\n params: any[],\n bundlerUrl: string\n): Promise<any> {\n // Sanitize UserOperation if this is eth_sendUserOperation\n let cleanParams = params;\n if (method === 'eth_sendUserOperation' && params[0]) {\n cleanParams = [sanitizeUserOperation(params[0]), params[1]];\n }\n\n const body = { jsonrpc: '2.0', id: 1, method, params: cleanParams };\n const bodyStr = JSON.stringify(body, (_k, v) => (typeof v === 'bigint' ? `0x${v.toString(16)}` : v));\n\n console.log('[Bundler][RPC] ->', method, bodyStr);\n\n const res = await fetch(bundlerUrl, {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: bodyStr\n });\n\n const json: any = await res.json();\n\n if (json.error) {\n console.log('[Bundler][RPC] <- ERROR:', JSON.stringify(json.error));\n const detail = json.error?.data ? ` | data: ${JSON.stringify(json.error.data)}` : '';\n throw new Error((json.error.message || JSON.stringify(json.error)) + detail);\n }\n\n console.log('[Bundler][RPC] <- SUCCESS:', JSON.stringify(json.result));\n return json.result;\n}\n","import { createPublicClientForChain, getChainConfig } from '../read'\nimport { bundlerRpc, fetchEntryPointNonce } from '../utils/helpers';\nimport type { UserOperationV07 } from './types';\n\n\nexport async function sendUserOperationRaw(userOp: UserOperationV07, options: { chainId: number }): Promise<`0x${string}`> {\n if (!options || typeof options.chainId !== 'number') {\n throw new Error('sendUserOperationRaw requires options with chainId parameter. Usage: sendUserOperationRaw(userOp, { chainId: 2030232745 })')\n }\n const chainConfig = getChainConfig(options.chainId)\n if (!chainConfig) throw new Error(`Chain ID ${options.chainId} is not supported.`)\n const hash = await bundlerRpc(\n 'eth_sendUserOperation',\n [userOp, chainConfig?.entryPointV07Address],\n chainConfig?.bundlerUrl\n );\n return hash;\n}\n\nexport async function sendUserOperationWithRetry(\n userOp: UserOperationV07,\n resigner: (nonce: `0x${string}`) => Promise<UserOperationV07>,\n options: { chainId: number, maxRetries: number },\n): Promise<`0x${string}`> {\n if (!options || typeof options.chainId !== 'number') {\n throw new Error('sendUserOperationWithRetry requires options with chainId parameter. Usage: sendUserOperationWithRetry(userOp, resigner, { chainId: 2030232745, maxRetries: 3 })')\n }\n const { chainId, maxRetries = 1 } = options;\n const chainConfig = getChainConfig(chainId);\n\n if (!chainConfig) {\n throw new Error(`[sendUserOperationWithRetry] ChainConfig is not found (chainId:${chainId})`)\n }\n const publicClient = createPublicClientForChain(chainId);\n\n let attempts = 0;\n let currentUserOp = userOp;\n\n while (attempts < maxRetries) {\n try {\n return await sendUserOperationRaw(currentUserOp, { chainId });\n } catch (error: any) {\n attempts++;\n const errorMsg = String(error?.message || error);\n if (attempts >= maxRetries) throw error;\n\n if (/nonce too low|nonce.*invalid/i.test(errorMsg)) {\n const newNonce = await fetchEntryPointNonce(\n userOp.sender,\n chainConfig.entryPointV07Address,\n { client: publicClient }\n )\n currentUserOp = await resigner(newNonce);\n } else if (/replacement.*underpriced/i.test(errorMsg)) {\n const increasedMaxFeePerGas = `0x${((BigInt(currentUserOp.maxFeePerGas) * 110n) / 100n).toString(16)}` as `0x${string}`;\n const increasedMaxPriorityFeePerGas = `0x${((BigInt(currentUserOp.maxPriorityFeePerGas) * 110n) / 100n).toString(16)}` as `0x${string}`;\n currentUserOp = { ...currentUserOp, maxFeePerGas: increasedMaxFeePerGas, maxPriorityFeePerGas: increasedMaxPriorityFeePerGas };\n currentUserOp = await resigner(currentUserOp.nonce);\n } else {\n const newNonce = await fetchEntryPointNonce(\n userOp.sender,\n chainConfig.entryPointV07Address,\n { client: publicClient }\n );\n currentUserOp = await resigner(newNonce);\n }\n\n await new Promise(r => setTimeout(r, 1000 * attempts));\n }\n }\n throw new Error(`Failed to send UserOperation after ${maxRetries} attempts`);\n}\n\n/**\n * Get UserOperation receipt by hash (low-level, requires bundlerUrl)\n * @param userOpHash - UserOperation hash\n * @param bundlerUrl - Bundler RPC URL\n */\nexport async function getUserOperationReceipt(userOpHash: `0x${string}`, bundlerUrl: string): Promise<any> {\n const receipt = await bundlerRpc('eth_getUserOperationReceipt', [userOpHash], bundlerUrl);\n return receipt;\n}\n","/**\n * Universal environment variable access that works in both browser and Node.js\n */\n\ninterface EnvVars {\n [key: string]: string | undefined;\n}\n\n/**\n * Get environment variables from various sources\n * Priority: 1. window.__LUMIA_ENV__ (browser), 2. import.meta.env (Vite), 3. process.env (Node.js)\n */\nfunction getEnvironmentVars(): EnvVars {\n // Try browser environment first (injected by LumiaPassportProvider)\n // @ts-ignore - accessing global window object\n const win = typeof globalThis !== 'undefined' && (globalThis as any).window;\n if (win && win.__LUMIA_ENV__) {\n return win.__LUMIA_ENV__;\n }\n\n // Try import.meta.env (ESM/Vite)\n try {\n // @ts-ignore - import.meta may not be available in all environments\n if (import.meta?.env) {\n // @ts-ignore\n return import.meta.env as EnvVars;\n }\n } catch {\n // import.meta not available in this environment\n }\n\n // Try process.env (Node.js/CJS)\n if (typeof process !== 'undefined' && process.env) {\n return process.env;\n }\n\n // Fallback to empty object\n return {};\n}\n\n/**\n * Get a single environment variable\n * @param name - The environment variable name\n * @returns The environment variable value or undefined\n */\nexport function getEnvVar(name: string): string | undefined {\n const env = getEnvironmentVars();\n return env[name];\n}\n\n/**\n * Get an environment variable as boolean\n * @param name - The environment variable name\n * @returns true if value is 'true' or '1', false otherwise\n */\nexport function getEnvVarBool(name: string): boolean {\n const value = getEnvVar(name);\n return value === 'true' || value === '1';\n}\n\n/**\n * Get an environment variable as array\n * @param name - The environment variable name\n * @param separator - Separator character (default: ',')\n * @returns Array of trimmed non-empty strings\n */\nexport function getEnvVarArray(name: string, separator = ','): string[] {\n const value = getEnvVar(name);\n return value ? value.split(separator).map(s => s.trim()).filter(Boolean) : [];\n}\n\n/**\n * Get all environment variables\n * @returns Object containing all environment variables\n */\nexport function getAllEnvVars(): EnvVars {\n return getEnvironmentVars();\n}\n\n/**\n * Check if running in development mode\n * @returns true if NODE_ENV or MODE is 'development'\n */\nexport function isDevelopment(): boolean {\n const env = getEnvironmentVars();\n return env.NODE_ENV === 'development' || env.MODE === 'development';\n}\n\n/**\n * Check if running in production mode\n * @returns true if NODE_ENV or MODE is 'production'\n */\nexport function isProduction(): boolean {\n const env = getEnvironmentVars();\n return env.NODE_ENV === 'production' || env.MODE === 'production';\n}\n","import { bundlerRpc } from '../utils/helpers';\nimport { getEnvVar, getEnvVarBool } from '../utils/env';\nimport type { ChainContext, FeeChainContext } from './types';\nimport type { PublicClient } from 'viem'\n\nexport interface FeeConfig {\n baseFeeBuffer: number;\n priorityFeeBuffer: number;\n fallbackMaxFeePerGas?: bigint;\n fallbackMaxPriorityFeePerGas?: bigint;\n}\n\nexport interface CalculatedFees {\n maxFeePerGas: `0x${string}`;\n maxPriorityFeePerGas: `0x${string}`;\n baseFee?: bigint;\n priorityFee?: bigint;\n bufferedBaseFee?: bigint;\n bufferedPriorityFee?: bigint;\n}\n\n// Hardcoded fallback values (used when env vars not set and network calls fail)\nconst HARDCODED_FALLBACK_MAX_FEE = 3_000_000_000n; // 3 gwei\nconst HARDCODED_FALLBACK_PRIORITY_FEE = 3_000_000_000n; // 3 gwei\n\n/**\n * Get minimum maxFeePerGas from environment or use hardcoded fallback\n * Env vars: MIN_MAX_FEE_PER_GAS or VITE_MIN_MAX_FEE_PER_GAS (in wei)\n */\nexport function getMinMaxFeePerGas(): bigint {\n const envValue = getEnvVar('MIN_MAX_FEE_PER_GAS') || getEnvVar('VITE_MIN_MAX_FEE_PER_GAS');\n if (envValue) {\n try {\n return BigInt(envValue);\n } catch {\n console.warn('[Fees] Invalid MIN_MAX_FEE_PER_GAS value:', envValue);\n }\n }\n return HARDCODED_FALLBACK_MAX_FEE;\n}\n\n/**\n * Get minimum maxPriorityFeePerGas from environment or use hardcoded fallback\n * Env vars: MIN_PRIORITY_FEE_PER_GAS or VITE_MIN_PRIORITY_FEE_PER_GAS (in wei)\n */\nexport function getMinPriorityFeePerGas(): bigint {\n const envValue = getEnvVar('MIN_PRIORITY_FEE_PER_GAS') || getEnvVar('VITE_MIN_PRIORITY_FEE_PER_GAS');\n if (envValue) {\n try {\n return BigInt(envValue);\n } catch {\n console.warn('[Fees] Invalid MIN_PRIORITY_FEE_PER_GAS value:', envValue);\n }\n }\n return HARDCODED_FALLBACK_PRIORITY_FEE;\n}\n\n/**\n * Get default maxFeePerGas as hex string (for dummy user operations)\n */\nexport function getDefaultMaxFeePerGasHex(): `0x${string}` {\n return `0x${getMinMaxFeePerGas().toString(16)}`;\n}\n\n/**\n * Get default maxPriorityFeePerGas as hex string (for dummy user operations)\n */\nexport function getDefaultPriorityFeePerGasHex(): `0x${string}` {\n return `0x${getMinPriorityFeePerGas().toString(16)}`;\n}\n\nexport const DEFAULT_FEE_CONFIG: FeeConfig = { baseFeeBuffer: 0.5, priorityFeeBuffer: 0.05, fallbackMaxFeePerGas: HARDCODED_FALLBACK_MAX_FEE, fallbackMaxPriorityFeePerGas: HARDCODED_FALLBACK_PRIORITY_FEE };\nexport const CONSERVATIVE_FEE_CONFIG: FeeConfig = { baseFeeBuffer: 1.0, priorityFeeBuffer: 0.25, fallbackMaxFeePerGas: 5_000_000_000n, fallbackMaxPriorityFeePerGas: 3_000_000_000n };\n\n/**\n * Check if the current chain requires legacy gas pricing to avoid BASEFEE opcode errors\n */\nfunction shouldUseLegacyGasForChain(options: { publicClient: PublicClient }): boolean {\n try {\n const { publicClient } = options;\n // Get environment variable for legacy chain IDs (comma-separated list)\n const legacyChainIds = getEnvVar('VITE_LEGACY_GAS_CHAIN_IDS') || getEnvVar('LEGACY_GAS_CHAIN_IDS') || '';\n\n console.log('[Fees] Environment check:', {\n LEGACY_GAS_CHAIN_IDS: legacyChainIds,\n });\n\n // Default to Lumia Beam testnet if no env var is set\n const defaultLegacyChains = '2030232745'; // Lumia Beam testnet\n const chainIdsString = legacyChainIds || defaultLegacyChains;\n\n // Parse chain IDs\n const legacyChains = chainIdsString.split(',').map(id => parseInt(id.trim())).filter(id => !isNaN(id));\n\n // Get current chain ID from public client\n const currentChainId = publicClient?.chain?.id;\n\n if (!currentChainId) return false;\n\n const shouldUseLegacy = legacyChains.includes(currentChainId);\n\n if (shouldUseLegacy) {\n console.log('[Fees] Chain requires legacy gas pricing:', {\n chainId: currentChainId,\n legacyChains,\n configuredVia: legacyChainIds ? 'LEGACY_GAS_CHAIN_IDS env var' : 'default'\n });\n }\n\n return shouldUseLegacy;\n } catch (error) {\n console.warn('[Fees] Error checking legacy gas chain configuration:', error);\n return false;\n }\n}\n\nexport async function getCurrentBaseFee(context: ChainContext): Promise<bigint> {\n const block = await context.client.getBlock({ blockTag: 'latest' });\n if (block.baseFeePerGas) return block.baseFeePerGas;\n const gasPriceHex = await context.client.getGasPrice();\n const gasPrice = BigInt(gasPriceHex);\n const estimatedBaseFee = (gasPrice * 9n) / 10n;\n return estimatedBaseFee;\n}\n\nexport async function getCurrentPriorityFee(\n bundlerUrl: string,\n context: ChainContext\n): Promise<bigint> {\n try {\n const priorityFeeHex = await bundlerRpc('rundler_maxPriorityFeePerGas', [], bundlerUrl);\n const priorityFee = BigInt(priorityFeeHex);\n if (priorityFee === 0n) {\n return await getFallbackPriorityFee(context);\n }\n return priorityFee;\n } catch {\n return await getFallbackPriorityFee(context);\n }\n}\n\nasync function getFallbackPriorityFee(context: ChainContext): Promise<bigint> {\n try {\n const gasPriceHex = await context.client.getGasPrice();\n const gasPrice = BigInt(gasPriceHex);\n return gasPrice / 10n;\n } catch {\n return 100_000_000n;\n }\n}\n\nexport async function calculateLegacyFees(\n bufferPercent: number,\n context: ChainContext\n): Promise<CalculatedFees> {\n const minMaxFee = getMinMaxFeePerGas();\n const minPriorityFee = getMinPriorityFeePerGas();\n\n try {\n // Always get current gas price from network for legacy chains\n const gasPriceHex = await context.client.getGasPrice();\n const networkGasPrice = BigInt(gasPriceHex);\n\n // Add buffer to network gas price (bundler typically requires ~30% buffer)\n const bufferedGasPrice = networkGasPrice + (networkGasPrice * BigInt(bufferPercent)) / 100n;\n\n // Enforce minimum fee\n const effectiveGasPrice = bufferedGasPrice < minMaxFee ? minMaxFee : bufferedGasPrice;\n\n // For legacy chains, set both maxFeePerGas and maxPriorityFeePerGas to the same value\n // This prevents BASEFEE opcode usage\n const result: CalculatedFees = {\n maxFeePerGas: `0x${effectiveGasPrice.toString(16)}`,\n maxPriorityFeePerGas: `0x${effectiveGasPrice.toString(16)}`,\n };\n\n console.log('[Fees] Using legacy gas pricing (avoid BASEFEE opcode):', {\n networkGasPrice: networkGasPrice.toString(),\n bufferPercent,\n bufferedGasPrice: bufferedGasPrice.toString(),\n minFee: minMaxFee.toString(),\n effectiveGasPrice: effectiveGasPrice.toString(),\n maxFeePerGas: result.maxFeePerGas,\n maxPriorityFeePerGas: result.maxPriorityFeePerGas,\n });\n\n return result;\n } catch (error) {\n console.warn('[Fees] Legacy fee calculation failed, using min fee fallback:', error);\n return {\n maxFeePerGas: `0x${minMaxFee.toString(16)}`,\n maxPriorityFeePerGas: `0x${minPriorityFee.toString(16)}`,\n };\n }\n}\n\nexport async function calculateDynamicFees(\n config: FeeConfig = DEFAULT_FEE_CONFIG,\n context: FeeChainContext\n): Promise<CalculatedFees> {\n const { client, bundlerUrl } = context;\n const minMaxFee = getMinMaxFeePerGas();\n const minPriorityFee = getMinPriorityFeePerGas();\n\n try {\n // Check environment variable for forced legacy mode\n const forceLegacy = getEnvVarBool('VITE_FORCE_LEGACY_GAS') || getEnvVarBool('FORCE_LEGACY_GAS');\n\n // Check if current chain should use legacy gas pricing\n const shouldUseLegacy = forceLegacy || shouldUseLegacyGasForChain({ publicClient: client});\n\n if (shouldUseLegacy) {\n console.log('[Fees] Using legacy gas pricing', forceLegacy ? '(forced by FORCE_LEGACY_GAS env var)' : '(chain requires legacy gas)');\n return await calculateLegacyFees(30, { client });\n }\n const baseFee = await getCurrentBaseFee({ client });\n const bufferedBaseFee = baseFee + (baseFee * BigInt(Math.floor(config.baseFeeBuffer * 1000))) / 1000n;\n const priorityFee = await getCurrentPriorityFee(bundlerUrl, { client });\n const bufferedPriorityFee = priorityFee + (priorityFee * BigInt(Math.floor(config.priorityFeeBuffer * 1000))) / 1000n;\n\n // Calculate fees\n let maxFeePerGas = bufferedBaseFee + bufferedPriorityFee;\n let maxPriorityFeePerGas = bufferedPriorityFee;\n\n // Enforce minimum fees\n if (maxFeePerGas < minMaxFee) {\n console.log('[Fees] Calculated maxFeePerGas below minimum, using minimum:', { calculated: maxFeePerGas.toString(), min: minMaxFee.toString() });\n maxFeePerGas = minMaxFee;\n }\n if (maxPriorityFeePerGas < minPriorityFee) {\n console.log('[Fees] Calculated maxPriorityFeePerGas below minimum, using minimum:', { calculated: maxPriorityFeePerGas.toString(), min: minPriorityFee.toString() });\n maxPriorityFeePerGas = minPriorityFee;\n }\n\n return { maxFeePerGas: `0x${maxFeePerGas.toString(16)}`, maxPriorityFeePerGas: `0x${maxPriorityFeePerGas.toString(16)}`, baseFee, priorityFee, bufferedBaseFee, bufferedPriorityFee };\n } catch { return await calculateLegacyFees(30, { client }); }\n}\n\nexport async function calculateFastFees(\n context: FeeChainContext\n): Promise<CalculatedFees> {\n const { client } = context;\n const forceLegacy = getEnvVarBool('VITE_FORCE_LEGACY_GAS') || getEnvVarBool('FORCE_LEGACY_GAS');\n const shouldUseLegacy = forceLegacy || shouldUseLegacyGasForChain({ publicClient: client});\n\n if (shouldUseLegacy) return await calculateLegacyFees(50, { client }); // 50% buffer for fast\n return calculateDynamicFees({ baseFeeBuffer: 0.75, priorityFeeBuffer: 0.5, fallbackMaxFeePerGas: 3_000_000_000n, fallbackMaxPriorityFeePerGas: 2_000_000_000n }, context);\n}\n\nexport async function calculateEconomyFees(\n context: FeeChainContext\n): Promise<CalculatedFees> {\n const { client } = context;\n const forceLegacy = getEnvVarBool('VITE_FORCE_LEGACY_GAS') || getEnvVarBool('FORCE_LEGACY_GAS');\n const shouldUseLegacy = forceLegacy || shouldUseLegacyGasForChain({ publicClient: client});\n\n if (shouldUseLegacy) return await calculateLegacyFees(30, { client }); // 30% buffer for economy\n return calculateDynamicFees({ baseFeeBuffer: 0.27, priorityFeeBuffer: 0.01, fallbackMaxFeePerGas: 1_000_000_000n, fallbackMaxPriorityFeePerGas: 500_000_000n }, context);\n}\n\nexport async function getFeeEstimates(context: FeeChainContext): Promise<{ economy: CalculatedFees; standard: CalculatedFees; fast: CalculatedFees; }> {\n const [economy, standard, fast] = await Promise.all([\n calculateEconomyFees(context),\n calculateDynamicFees(undefined, context),\n calculateFastFees(context)\n ]);\n return { economy, standard, fast };\n}\n","import { pack2x128, safeToBigInt } from '../utils/helpers';\nimport { calculateDynamicFees, calculateEconomyFees, calculateFastFees, getDefaultMaxFeePerGasHex, getDefaultPriorityFeePerGasHex } from './fee-calculation';\nimport type { UserOperationV07, PackedUserOperationV07, UserOperationParams, FeeChainContext } from './types';\n\n// Re-export types for external use\nexport type { UserOperationParams, FeeChainContext };\n\n// Dummy signature for gas estimation\n// Must be a valid ECDSA format (65 bytes: r[32] + s[32] + v[1])\n// OpenZeppelin ECDSA requires:\n// - r != 0\n// - s in lower half of curve order (s < secp256k1n/2 = 0x7FFFFFFF...)\n// - v = 27 or 28\n// Using s = 0x01 (minimal valid s) to avoid ECDSAInvalidSignatureS error\n// r = 0x01 (minimal valid r) to avoid ECDSAInvalidSignature error\n// v = 0x1b (27) for valid recovery id\n// This signature will recover to an invalid address but won't revert during estimation\nconst DUMMY_R = '0000000000000000000000000000000000000000000000000000000000000001';\nconst DUMMY_S = '0000000000000000000000000000000000000000000000000000000000000001';\nconst DUMMY_V = '1b'; // 27\nexport const DUMMY_SIGNATURE = `0x${DUMMY_R}${DUMMY_S}${DUMMY_V}` as `0x${string}`;\n\nexport function packUserOperationV07(\n userOp: UserOperationV07,\n includeFactory: boolean,\n factoryAddress?: `0x${string}`,\n factoryData?: `0x${string}`\n): PackedUserOperationV07 {\n const initCode = includeFactory && factoryAddress && factoryData ? (((factoryAddress as string) + (factoryData as string).slice(2)) as `0x${string}`) : ('0x' as `0x${string}`);\n const accountGasLimits = pack2x128(safeToBigInt(userOp.verificationGasLimit, '0x1e8480'), safeToBigInt(userOp.callGasLimit, '0x0f4240'));\n const defaultMaxFee = getDefaultMaxFeePerGasHex();\n const defaultPriorityFee = getDefaultPriorityFeePerGasHex();\n const gasFees = pack2x128(safeToBigInt(userOp.maxPriorityFeePerGas, defaultPriorityFee), safeToBigInt(userOp.maxFeePerGas, defaultMaxFee));\n\n // Create paymasterAndData from paymaster and paymasterData fields (V07 format)\n let paymasterAndData: `0x${string}` = '0x';\n if (userOp.paymaster && userOp.paymaster !== '0x') {\n const paymasterAddr = userOp.paymaster.startsWith('0x') ? userOp.paymaster.slice(2) : userOp.paymaster;\n const paymasterData = userOp.paymasterData ? (userOp.paymasterData.startsWith('0x') ? userOp.paymasterData.slice(2) : userOp.paymasterData) : '';\n paymasterAndData = `0x${paymasterAddr}${paymasterData}` as `0x${string}`;\n }\n\n return { sender: userOp.sender, nonce: BigInt(userOp.nonce), initCode, callData: userOp.callData, accountGasLimits, preVerificationGas: safeToBigInt(userOp.preVerificationGas, '0x1d4c0'), gasFees, paymasterAndData, signature: userOp.signature };\n}\n\nexport function createDummyUserOperation(\n sender: `0x${string}`,\n nonce: `0x${string}`,\n callData: `0x${string}`,\n includeFactory: boolean = false,\n factoryAddress?: `0x${string}`,\n factoryData?: `0x${string}`,\n customMaxFeePerGas?: `0x${string}`,\n customMaxPriorityFeePerGas?: `0x${string}`\n): UserOperationV07 {\n const userOp: UserOperationV07 = {\n sender,\n nonce,\n callData,\n callGasLimit: '0x0', // Zero - bundler will calculate real value\n verificationGasLimit: '0x0', // Zero - bundler will calculate real value\n preVerificationGas: '0x0', // Zero - bundler will calculate real value\n maxFeePerGas: customMaxFeePerGas || getDefaultMaxFeePerGasHex(),\n maxPriorityFeePerGas: customMaxPriorityFeePerGas || getDefaultPriorityFeePerGasHex(),\n signature: DUMMY_SIGNATURE,\n };\n if (includeFactory && factoryAddress && factoryData) { userOp.factory = factoryAddress; userOp.factoryData = factoryData; }\n return userOp;\n}\n\nexport async function createUserOperationWithDynamicFees(\n params: UserOperationParams,\n context: FeeChainContext\n): Promise<UserOperationV07> {\n const { sender, nonce, callData, includeFactory = false, factoryAddress, factoryData, feeType = 'standard' } = params;\n\n let fees;\n switch (feeType) {\n case 'economy': fees = await calculateEconomyFees(context); break;\n case 'fast': fees = await calculateFastFees(context); break;\n default: fees = await calculateDynamicFees(undefined, context);\n }\n\n return createDummyUserOperation(sender, nonce, callData, includeFactory, factoryAddress, factoryData, fees.maxFeePerGas, fees.maxPriorityFeePerGas);\n}\n","import { getChainConfig } from '../read';\nimport { bundlerRpc } from '../utils/helpers'\nimport type { FeeChainContext, GasEstimationResult, UserOperationV07 } from './types'\nimport { createUserOperationWithDynamicFees, DUMMY_SIGNATURE, type UserOperationParams } from './utils';\n\n\n// Known ERC-4337 validation errors that can use fallback gas estimation\n// These are errors from EntryPoint validation, not from contract execution\nconst VALIDATION_ERROR_PATTERNS = [\n /AA20/i, // account not deployed\n /AA21/i, // didn't pay prefund\n /AA22/i, // expired or not due\n /AA23/i, // reverted (signature validation failed - expected with dummy sig)\n /AA24/i, // signature error\n /AA25/i, // invalid account nonce\n /AA10/i, // sender already constructed\n /AA13/i, // initCode failed or OOG\n /AA14/i, // initCode must return sender\n /AA15/i, // initCode must create sender\n];\n\n// Errors that indicate the transaction WILL fail - no point in sending\nconst EXECUTION_REVERT_PATTERNS = [\n /execution reverted/i,\n /ERC20InsufficientBalance/i,\n /ERC20InsufficientAllowance/i,\n /transfer amount exceeds balance/i,\n /insufficient funds/i,\n /not operator/i,\n /not authorized/i,\n /access denied/i,\n /ownable.*caller is not/i,\n];\n\nfunction isValidationError(errorMsg: string): boolean {\n return VALIDATION_ERROR_PATTERNS.some(pattern => pattern.test(errorMsg));\n}\n\nfunction isExecutionRevert(errorMsg: string): boolean {\n return EXECUTION_REVERT_PATTERNS.some(pattern => pattern.test(errorMsg));\n}\n\nexport async function estimateUserOperationGas(\n userOp: UserOperationV07,\n options: { chainId: number, retryWithoutFactory: boolean, }\n): Promise<GasEstimationResult> {\n const chainConfig = getChainConfig(options.chainId)\n if (!chainConfig) throw new Error(`Chain ID ${options.chainId} is not supported.`)\n try {\n const gas = await bundlerRpc(\n 'eth_estimateUserOperationGas',\n [userOp, chainConfig.entryPointV07Address],\n chainConfig.bundlerUrl\n );\n return gas;\n } catch (error) {\n const errorMsg = String(error);\n\n // Retry without factory if account is already deployed\n if (options.retryWithoutFactory && (userOp.factory || userOp.factoryData)) {\n if (/AA10 sender already constructed/i.test(errorMsg) || /sender.*is an existing contract.*but initCode is nonempty/i.test(errorMsg)) {\n const userOpWithoutFactory: UserOperationV07 = { ...userOp };\n delete userOpWithoutFactory.factory;\n delete userOpWithoutFactory.factoryData;\n try {\n const gas = await bundlerRpc(\n 'eth_estimateUserOperationGas',\n [userOpWithoutFactory, chainConfig.entryPointV07Address],\n chainConfig.bundlerUrl\n );\n return gas;\n } catch {}\n }\n }\n\n // If this is an execution revert (not validation), the transaction WILL fail\n // Don't waste gas - throw the error so caller can handle it\n if (isExecutionRevert(errorMsg)) {\n throw new Error(`Transaction will fail: ${errorMsg}`);\n }\n\n // For validation errors (AA20, AA23, etc.), use fallback gas estimates\n // These are expected when using dummy signature for estimation\n if (!isValidationError(errorMsg)) {\n // Unknown error - rethrow it\n throw error;\n }\n\n // Fallback to reasonable gas estimates for validation errors\n const isEmptyCallData = !userOp.callData || userOp.callData === '0x';\n const hasFactory = !!(userOp.factory && userOp.factoryData);\n\n // callGasLimit: 500K should cover most contract calls\n const fallbackCallGas = isEmptyCallData ? '0x0' : '0x7A120'; // 500,000\n\n // verificationGasLimit: depends on whether account needs to be deployed\n const fallbackVerificationGas = hasFactory ? '0x16E360' : '0x7A120'; // 1,500,000 or 500,000\n\n // preVerificationGas: 50K is typical for most operations\n const fallbackPreVerificationGas = '0xC350'; // 50,000\n\n return {\n callGasLimit: fallbackCallGas,\n verificationGasLimit: fallbackVerificationGas,\n preVerificationGas: fallbackPreVerificationGas\n };\n }\n}\n\nexport async function estimateUserOperationGasWithSignature(\n userOp: UserOperationV07,\n _getSignature: (opHash: `0x${string}`) => Promise<`0x${string}` | null>,\n _getUserOpHash: (packedOp: any) => Promise<`0x${string}`>,\n options: { chainId: number, retryWithoutFactory: boolean},\n): Promise<GasEstimationResult> {\n const userOpForEstimation: UserOperationV07 = { ...userOp, signature: DUMMY_SIGNATURE };\n return estimateUserOperationGas(\n userOpForEstimation,\n {\n chainId: options.chainId,\n retryWithoutFactory: options.retryWithoutFactory\n });\n}\n\nexport async function estimateUserOperationGasWithDynamicFees(\n params: UserOperationParams,\n context: FeeChainContext,\n retryWithoutFactory: boolean = true\n): Promise<GasEstimationResult & { calculatedFees?: any }> {\n const userOp = await createUserOperationWithDynamicFees(params, context);\n const gasResult = await estimateUserOperationGas(\n userOp,\n { retryWithoutFactory, chainId: context.chainConfig.id}\n );\n return { ...gasResult, calculatedFees: { maxFeePerGas: userOp.maxFeePerGas, maxPriorityFeePerGas: userOp.maxPriorityFeePerGas, feeType: params.feeType || 'standard' } };\n}\n","import { bundlerRpc } from '../utils/helpers';\nimport type { UserOperationV07, SimulationResult } from './types';\nimport { getChainConfig } from '../read'\n\n/**\n * Simulate a UserOperation using Lumia's lumia_simulateUserOperation method\n * Returns asset changes that would occur if the operation is executed\n *\n * @experimental This method uses Lumia-specific bundler extension\n * @param userOp - The UserOperation to simulate\n * @param options - options with Chain ID (required)\n * @returns Simulation result with asset changes\n */\nexport async function simulateUserOperation(userOp: UserOperationV07, options: { chainId: number }): Promise<SimulationResult> {\n const chainConfig = getChainConfig(options.chainId)\n if (!chainConfig) throw new Error(`Chain ID ${options.chainId} is not supported.`)\n try {\n // Lumia bundler expects params as: [{ userOperation, entryPoint }]\n const result = await bundlerRpc('lumia_simulateUserOperation', [{\n userOperation: userOp,\n entryPoint: chainConfig.entryPointV07Address,\n }], chainConfig?.bundlerUrl);\n return result;\n } catch (error) {\n // If simulation fails, return error in the expected format\n const errorMsg = error instanceof Error ? error.message : String(error);\n return {\n changes: [],\n error: {\n message: errorMsg,\n code: -1\n }\n };\n }\n}\n\n/**\n * Validate a UserOperation by simulating it\n * Returns true if simulation succeeds without errors\n */\nexport async function validateUserOperation(userOp: UserOperationV07, options: { chainId: number }): Promise<{ valid: boolean; error?: string }> {\n try {\n const result = await simulateUserOperation(userOp, { chainId: options.chainId });\n if (result.error) {\n return { valid: false, error: result.error.message };\n }\n return { valid: true };\n } catch (error) {\n const errorMsg = error instanceof Error ? error.message : String(error);\n return { valid: false, error: errorMsg };\n }\n}\n","/**\n * Provider for viem PublicClient\n * Allows fee-calculation and other modules to access the configured client\n */\n\n// Using 'any' type to avoid direct viem dependency in this file\n// Actual type should be PublicClient from viem\nlet globalPublicClient: any | null = null;\n\n/**\n * Set the global public client for blockchain interactions\n * Should be called during initialization with a viem PublicClient\n */\nexport function setPublicClient(client: any): void {\n globalPublicClient = client;\n}\n\n/**\n * Get the configured public client\n * Throws if not configured\n */\nexport function getPublicClient(): any {\n if (!globalPublicClient) {\n throw new Error(\n '[LumiaPassport] PublicClient not configured. Please provide a publicClient in config ' +\n 'or call setPublicClient() before using fee calculation functions.'\n );\n }\n return globalPublicClient;\n}\n\n/**\n * Check if public client is configured\n */\nexport function hasPublicClient(): boolean {\n return globalPublicClient !== null;\n}\n"]}
1
+ {"version":3,"sources":["../../src/bundler/constants.ts","../../src/config/networks/arbitrum-sepolia.ts","../../src/config/networks/base-sepolia.ts","../../src/config/networks/bsc-testnet.ts","../../src/config/networks/mainnet.ts","../../src/config/networks/testnet.ts","../../src/config/networks/sepolia.ts","../../src/config/networks/index.ts","../../src/lib/errors.ts","../../src/read/errors.ts","../../src/read/client-factories.ts","../../src/utils/helpers.ts","../../src/bundler/submission.ts","../../src/utils/env.ts","../../src/bundler/fee-calculation.ts","../../src/bundler/utils.ts","../../src/bundler/gas-estimation.ts","../../src/bundler/simulation.ts","../../src/bundler/client-provider.ts"],"names":["defineChain","MULTICALL3_ADDRESS","createPublicClient","http","fallback","getPublicClient"],"mappings":";;;;;;AAGO,IAAM,cAAA,GAAiB;AACvB,IAAM,UAAA,GAAa;ACQnB,IAAM,yBAAA,GAA4B,MAAA;AAKlC,IAAM,mCAAA,GAA+C,4CAAA;AAKrD,IAAM,gBAAA,GAAgC;AAAA,EAC3C,EAAA,EAAI,yBAAA;AAAA,EACJ,IAAA,EAAM,kBAAA;AAAA,EACN,IAAA,EAAM,UAAA;AAAA,EACN,WAAA,EAAa,EAAA;AAAA,EACb,OAAA,EAAS,CAAC,6CAA6C,CAAA;AAAA,EACvD,gBAAA,EAAkB,6BAAA;AAAA,EAClB,gBAAgB,EAAE,IAAA,EAAM,OAAO,MAAA,EAAQ,KAAA,EAAO,UAAU,EAAA,EAAG;AAAA,EAC3D,UAAA,EAAY,mCAAA;AAAA,EACZ,SAAA,EAAW,CAAA;AAAA,EACX,UAAA,EAAY,wDAAA;AAAA;AAAA,EAEZ,cAAA,EAAgB,4CAAA;AAAA,EAChB,oBAAA,EAAsB,4CAAA;AAAA,EACtB,gBAAA,EAAkB;AACpB,CAAA;AAKO,IAAM,uBAA8BA,gBAAA,CAAY;AAAA,EACrD,EAAA,EAAI,yBAAA;AAAA,EACJ,IAAA,EAAM,kBAAA;AAAA,EACN,gBAAgB,gBAAA,CAAiB,cAAA;AAAA,E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AA,EAAO,MAAA,CAAO,MAAM,OAAA,EAAQ;AAAA,IACrD;AACA,IAAA,OAAO,EAAE,OAAO,IAAA,EAAK;AAAA,EACvB,SAAS,KAAA,EAAO;AACd,IAAA,MAAM,WAAW,KAAA,YAAiB,KAAA,GAAQ,KAAA,CAAM,OAAA,GAAU,OAAO,KAAK,CAAA;AACtE,IAAA,OAAO,EAAE,KAAA,EAAO,KAAA,EAAO,KAAA,EAAO,QAAA,EAAS;AAAA,EACzC;AACF;;;AC5CA,IAAI,kBAAA,GAAiC,IAAA;AAM9B,SAAS,gBAAgB,MAAA,EAAmB;AACjD,EAAA,kBAAA,GAAqB,MAAA;AACvB;AAMO,SAASC,gBAAAA,GAAuB;AACrC,EAAA,IAAI,CAAC,kBAAA,EAAoB;AACvB,IAAA,MAAM,IAAI,KAAA;AAAA,MACR;AAAA,KAEF;AAAA,EACF;AACA,EAAA,OAAO,kBAAA;AACT;AAKO,SAAS,eAAA,GAA2B;AACzC,EAAA,OAAO,kBAAA,KAAuB,IAAA;AAChC","file":"index.cjs","sourcesContent":["/**\n * ERC-4337 EntryPoint contract address (v0.7)\n */\nexport const ENTRYPOINT_V07 = '0x0000000071727De22E5E9d8BAf0edAc6f37da032' as const;\nexport const ENTRYPOINT = ENTRYPOINT_V07;\n","/**\n * Arbitrum Sepolia Testnet Configuration\n */\n\nimport type { Address, Chain } from 'viem'\nimport { defineChain } from 'viem'\n\nimport type { ChainConfig } from '../../read/types'\n\n/**\n * Arbitrum Sepolia chain ID\n */\nexport const ARBITRUM_SEPOLIA_CHAIN_ID = 421614\n\n/**\n * Well-known Multicall3 contract address\n */\nexport const ARBITRUM_SEPOLIA_MULTICALL3_ADDRESS: Address = '0xcA11bde05977b3631167028862bE2a173976CA11'\n\n/**\n * Arbitrum Sepolia configuration\n */\nexport const ARBITRUM_SEPOLIA: ChainConfig = {\n id: ARBITRUM_SEPOLIA_CHAIN_ID,\n name: 'Arbitrum Sepolia',\n logo: 'arbitrum',\n logoDataUri: '',\n rpcUrls: ['https://arbitrum-sepolia-rpc.publicnode.com'],\n blockExplorerUrl: 'https://sepolia.arbiscan.io',\n nativeCurrency: { name: 'ETH', symbol: 'ETH', decimals: 18 },\n multicall3: ARBITRUM_SEPOLIA_MULTICALL3_ADDRESS,\n blockTime: 1,\n bundlerUrl: 'https://api.lumiapassport.com/rundler-arbitrum-sepolia',\n // EVM version: shanghai\n factoryAddress: '0x4be18A5ff553A881b2a272d0Ce4b3E82d763574f',\n entryPointV07Address: '0x0000000071727De22E5E9d8BAf0edAc6f37da032',\n paymasterAddress: '0x536b6F1Db43AA3D537376E40f73cFdcFf8930244',\n}\n\n/**\n * Viem chain definition for Arbitrum Sepolia\n */\nexport const arbitrumSepoliaChain: Chain = defineChain({\n id: ARBITRUM_SEPOLIA_CHAIN_ID,\n name: 'Arbitrum Sepolia',\n nativeCurrency: ARBITRUM_SEPOLIA.nativeCurrency,\n rpcUrls: {\n default: { http: ARBITRUM_SEPOLIA.rpcUrls },\n public: { http: ARBITRUM_SEPOLIA.rpcUrls },\n },\n blockExplorers: {\n default: { name: 'Arbiscan', url: ARBITRUM_SEPOLIA.blockExplorerUrl },\n },\n})\n","/**\n * Base Sepolia Testnet Configuration\n */\n\nimport type { Address, Chain } from 'viem'\nimport { defineChain } from 'viem'\n\nimport type { ChainConfig } from '../../read/types'\n\n/**\n * Base Sepolia chain ID\n */\nexport const BASE_SEPOLIA_CHAIN_ID = 84532\n\n/**\n * Well-known Multicall3 contract address\n */\nexport const BASE_SEPOLIA_MULTICALL3_ADDRESS: Address = '0xcA11bde05977b3631167028862bE2a173976CA11'\n\n/**\n * Base Sepolia configuration\n */\nexport const BASE_SEPOLIA: ChainConfig = {\n id: BASE_SEPOLIA_CHAIN_ID,\n name: 'Base Sepolia',\n logo: 'base',\n logoDataUri: '',\n rpcUrls: ['https://base-sepolia-rpc.publicnode.com'],\n blockExplorerUrl: 'https://sepolia.basescan.org',\n nativeCurrency: { name: 'ETH', symbol: 'ETH', decimals: 18 },\n multicall3: BASE_SEPOLIA_MULTICALL3_ADDRESS,\n blockTime: 2,\n bundlerUrl: 'https://api.lumiapassport.com/rundler-base-sepolia',\n // EVM version: shanghai\n factoryAddress: '0x4be18A5ff553A881b2a272d0Ce4b3E82d763574f',\n entryPointV07Address: '0x0000000071727De22E5E9d8BAf0edAc6f37da032',\n paymasterAddress: '0x536b6F1Db43AA3D537376E40f73cFdcFf8930244',\n}\n\n/**\n * Viem chain definition for Base Sepolia\n */\nexport const baseSepoliaChain: Chain = defineChain({\n id: BASE_SEPOLIA_CHAIN_ID,\n name: 'Base Sepolia',\n nativeCurrency: BASE_SEPOLIA.nativeCurrency,\n rpcUrls: {\n default: { http: BASE_SEPOLIA.rpcUrls },\n public: { http: BASE_SEPOLIA.rpcUrls },\n },\n blockExplorers: {\n default: { name: 'BaseScan', url: BASE_SEPOLIA.blockExplorerUrl },\n },\n})\n","/**\n * BSC Testnet Configuration\n */\n\nimport type { Address, Chain } from 'viem'\nimport { defineChain } from 'viem'\n\nimport type { ChainConfig } from '../../read/types'\n\n/**\n * BSC Testnet chain ID\n */\nexport const BSC_TESTNET_CHAIN_ID = 97\n\n/**\n * Well-known Multicall3 contract address\n */\nexport const BSC_TESTNET_MULTICALL3_ADDRESS: Address = '0xcA11bde05977b3631167028862bE2a173976CA11'\n\n/**\n * BSC Testnet configuration\n */\nexport const BSC_TESTNET: ChainConfig = {\n id: BSC_TESTNET_CHAIN_ID,\n name: 'BSC Testnet',\n logo: 'bnb',\n logoDataUri: '',\n rpcUrls: ['https://bsc-testnet-rpc.publicnode.com'],\n blockExplorerUrl: 'https://testnet.bscscan.com',\n nativeCurrency: { name: 'BNB', symbol: 'BNB', decimals: 18 },\n multicall3: BSC_TESTNET_MULTICALL3_ADDRESS,\n blockTime: 3,\n bundlerUrl: 'https://api.lumiapassport.com/rundler-bnb-testnet',\n // EVM version: shanghai\n factoryAddress: '0x4be18A5ff553A881b2a272d0Ce4b3E82d763574f',\n entryPointV07Address: '0x0000000071727De22E5E9d8BAf0edAc6f37da032',\n paymasterAddress: '0x536b6F1Db43AA3D537376E40f73cFdcFf8930244',\n}\n\n/**\n * Viem chain definition for BSC Testnet\n */\nexport const bscTestnetChain: Chain = defineChain({\n id: BSC_TESTNET_CHAIN_ID,\n name: 'BSC Testnet',\n nativeCurrency: BSC_TESTNET.nativeCurrency,\n rpcUrls: {\n default: { http: BSC_TESTNET.rpcUrls },\n public: { http: BSC_TESTNET.rpcUrls },\n },\n blockExplorers: {\n default: { name: 'BscScan Testnet', url: BSC_TESTNET.blockExplorerUrl },\n },\n})\n","/**\n * Lumia Mainnet Configuration\n */\n\nimport type { Address, Chain } from 'viem';\nimport { defineChain } from 'viem';\nimport type { ChainConfig } from '../../read/types';\n\n/**\n * Lumia Mainnet chain ID\n */\nexport const LUMIA_MAINNET_CHAIN_ID = 994873017;\n\n/**\n * Well-known Multicall3 contract address\n */\nexport const MULTICALL3_ADDRESS: Address = '0xcA11bde05977b3631167028862bE2a173976CA11';\n\n/**\n * Lumia Mainnet configuration\n */\nexport const LUMIA_MAINNET: ChainConfig = {\n id: LUMIA_MAINNET_CHAIN_ID,\n name: 'Lumia Prism Mainnet',\n logo: 'lumia',\n logoDataUri: '',\n rpcUrls: ['https://mainnet-rpc.lumia.org'],\n blockExplorerUrl: 'https://explorer.lumia.org',\n multicall3: MULTICALL3_ADDRESS,\n blockTime: 2,\n bundlerUrl: 'https://api.lumiapassport.com/rundler-prism',\n nativeCurrency: { name: 'LUMIA', symbol: 'LUMIA', decimals: 18 },\n // EVM version: shanghai (no MCOPY opcode)\n factoryAddress: '0x9Db2Ed382E6E627d548204483fB588FDc0d664B0',\n entryPointV07Address: '0x0000000071727De22E5E9d8BAf0edAc6f37da032',\n paymasterAddress: '0x1A8692fC7135CA59AF157C33C015F601FE4B3B7b',\n};\n\n/**\n * Viem chain definition for Lumia Mainnet\n */\nexport const lumiaMainnetChain: Chain = defineChain({\n id: LUMIA_MAINNET_CHAIN_ID,\n name: 'Lumia Prism Mainnet',\n nativeCurrency: LUMIA_MAINNET.nativeCurrency,\n rpcUrls: {\n default: { http: LUMIA_MAINNET.rpcUrls },\n public: { http: LUMIA_MAINNET.rpcUrls },\n },\n blockExplorers: {\n default: { name: 'Lumia Explorer', url: LUMIA_MAINNET.blockExplorerUrl },\n },\n});",";\n/**\n * Lumia Testnet (Beam) Configuration\n */\n\nimport type { Address, Chain } from 'viem'\nimport { defineChain } from 'viem';\n\n\n\nimport type { ChainConfig } from '../../read/types';\n\n\n/**\n * Lumia Testnet chain ID\n */\nexport const LUMIA_TESTNET_CHAIN_ID = 2030232745;\n\n/**\n * Well-known Multicall3 contract address\n */\nexport const MULTICALL3_ADDRESS: Address = '0xcA11bde05977b3631167028862bE2a173976CA11';\n\n/**\n * Lumia Testnet configuration\n */\nexport const LUMIA_TESTNET: ChainConfig = {\n id: LUMIA_TESTNET_CHAIN_ID,\n name: 'Lumia Beam',\n logo: 'lumia',\n logoDataUri: '',\n rpcUrls: ['https://beam-rpc.lumia.org'],\n blockExplorerUrl: 'https://beam-explorer.lumia.org',\n nativeCurrency: { name: 'LUMIA', symbol: 'LUMIA', decimals: 18 },\n multicall3: MULTICALL3_ADDRESS,\n blockTime: 2,\n bundlerUrl: 'https://api.lumiapassport.com/rundler',\n factoryAddress: '0x37053B3C6fb47B92355B95E7bEfa6dDf04Cc9981',\n entryPointV07Address: '0x0000000071727De22E5E9d8BAf0edAc6f37da032',\n paymasterAddress: '0x9Dca693bdDc09d6B10c7ad3C86BBC0C704571Ec5',\n};\n\n/**\n * Viem chain definition for Lumia Testnet\n */\nexport const lumiaTestnetChain: Chain = defineChain({\n id: LUMIA_TESTNET_CHAIN_ID,\n name: 'Lumia Beam Testnet',\n nativeCurrency: LUMIA_TESTNET.nativeCurrency,\n rpcUrls: {\n default: { http: LUMIA_TESTNET.rpcUrls },\n public: { http: LUMIA_TESTNET.rpcUrls },\n },\n blockExplorers: {\n default: { name: 'Lumia Beam Explorer', url: LUMIA_TESTNET.blockExplorerUrl },\n },\n logo: 'lumia'\n});","/**\n * Sepolia Testnet Configuration\n */\n\nimport type { Address, Chain } from 'viem';\nimport { defineChain } from 'viem';\nimport type { ChainConfig } from '../../read/types';\n\n/**\n * Sepolia Testnet chain ID\n */\nexport const SEPOLIA_CHAIN_ID = 11155111;\n\n/**\n * Well-known Multicall3 contract address\n */\nexport const MULTICALL3_ADDRESS: Address = '0xcA11bde05977b3631167028862bE2a173976CA11';\n\n/**\n * Sepolia Testnet configuration\n */\nexport const SEPOLIA: ChainConfig = {\n id: SEPOLIA_CHAIN_ID,\n name: 'Sepolia',\n logo: 'ethereum',\n logoDataUri: '',\n rpcUrls: ['https://ethereum-sepolia-rpc.publicnode.com'],\n blockExplorerUrl: 'https://sepolia.etherscan.io',\n multicall3: MULTICALL3_ADDRESS,\n blockTime: 12,\n bundlerUrl: 'https://api.lumiapassport.com/rundler-sepolia',\n nativeCurrency: { name: 'Sepolia Ether', symbol: 'ETH', decimals: 18 },\n factoryAddress: '0x4be18A5ff553A881b2a272d0Ce4b3E82d763574f',\n entryPointV07Address: '0x0000000071727De22E5E9d8BAf0edAc6f37da032',\n paymasterAddress: '0x536b6F1Db43AA3D537376E40f73cFdcFf8930244',\n};\n\n/**\n * Viem chain definition for Sepolia Testnet\n */\nexport const sepoliaChain: Chain = defineChain({\n id: SEPOLIA_CHAIN_ID,\n name: 'Sepolia',\n nativeCurrency: SEPOLIA.nativeCurrency,\n rpcUrls: {\n default: { http: SEPOLIA.rpcUrls },\n public: { http: SEPOLIA.rpcUrls },\n },\n blockExplorers: {\n default: { name: 'Etherscan', url: SEPOLIA.blockExplorerUrl },\n },\n testnet: true,\n});\n",";\n/**\n * Blockchain Read Layer - Constants and Chain Configurations\n * @module @lumiapassport/core/read/constants\n */\n\nimport type { Chain } from 'viem';\n\n\n\nimport type { ChainConfig } from '../../read/types';\nimport { ARBITRUM_SEPOLIA, ARBITRUM_SEPOLIA_CHAIN_ID, arbitrumSepoliaChain } from './arbitrum-sepolia';\nimport { BASE_SEPOLIA, BASE_SEPOLIA_CHAIN_ID, baseSepoliaChain } from './base-sepolia';\nimport { BSC_TESTNET, BSC_TESTNET_CHAIN_ID, bscTestnetChain } from './bsc-testnet';\nimport { LUMIA_MAINNET, LUMIA_MAINNET_CHAIN_ID, lumiaMainnetChain } from './mainnet';\nimport { LUMIA_TESTNET, LUMIA_TESTNET_CHAIN_ID, lumiaTestnetChain } from './testnet';\nimport { SEPOLIA, SEPOLIA_CHAIN_ID, sepoliaChain } from './sepolia';\n\n\n// Re-export from mainnet\nexport {\n LUMIA_MAINNET_CHAIN_ID,\n LUMIA_MAINNET,\n lumiaMainnetChain,\n} from './mainnet';\n\n// Re-export from testnet\nexport {\n LUMIA_TESTNET_CHAIN_ID,\n LUMIA_TESTNET,\n lumiaTestnetChain,\n} from './testnet';\n\n// Re-export from sepolia\nexport {\n SEPOLIA_CHAIN_ID,\n SEPOLIA,\n sepoliaChain,\n} from './sepolia';\n\n// Re-export from bsc-testnet\nexport {\n BSC_TESTNET_CHAIN_ID,\n BSC_TESTNET,\n bscTestnetChain,\n} from './bsc-testnet';\n\n// Re-export from arbitrum-sepolia\nexport {\n ARBITRUM_SEPOLIA_CHAIN_ID,\n ARBITRUM_SEPOLIA,\n arbitrumSepoliaChain,\n} from './arbitrum-sepolia';\n\n// Re-export from base-sepolia\nexport {\n BASE_SEPOLIA_CHAIN_ID,\n BASE_SEPOLIA,\n baseSepoliaChain,\n} from './base-sepolia';\n\n// Re-export MULTICALL3_ADDRESS from testnet (same on all chains)\nexport { MULTICALL3_ADDRESS } from './testnet';\n\n\n\n\n/**\n * Default chain ID used when no chain is explicitly selected\n * Currently set to TESTNET for safety during development\n */\nexport const DEFAULT_CHAIN_ID = LUMIA_TESTNET_CHAIN_ID;\n\n/**\n * All supported chains with built-in configurations\n */\nexport const SUPPORTED_CHAINS: Map<number, ChainConfig> = new Map([\n [LUMIA_MAINNET_CHAIN_ID, LUMIA_MAINNET],\n [LUMIA_TESTNET_CHAIN_ID, LUMIA_TESTNET],\n [SEPOLIA_CHAIN_ID, SEPOLIA],\n [BSC_TESTNET_CHAIN_ID, BSC_TESTNET],\n [ARBITRUM_SEPOLIA_CHAIN_ID, ARBITRUM_SEPOLIA],\n [BASE_SEPOLIA_CHAIN_ID, BASE_SEPOLIA],\n]);\n\nexport const VIEM_CHAINS: Map<number, Chain> = new Map([\n [LUMIA_MAINNET_CHAIN_ID, lumiaMainnetChain],\n [LUMIA_TESTNET_CHAIN_ID, lumiaTestnetChain],\n [SEPOLIA_CHAIN_ID, sepoliaChain],\n [BSC_TESTNET_CHAIN_ID, bscTestnetChain],\n [ARBITRUM_SEPOLIA_CHAIN_ID, arbitrumSepoliaChain],\n [BASE_SEPOLIA_CHAIN_ID, baseSepoliaChain],\n]);\n\n/**\n * Get chain configuration by chain ID\n * Returns undefined for unsupported chains\n */\nexport function getChainConfig(chainId: number): ChainConfig | undefined {\n return SUPPORTED_CHAINS.get(chainId);\n}\n\n/**\n * Check if a chain is supported with built-in configuration\n */\nexport function isChainSupported(chainId: number): boolean {\n return SUPPORTED_CHAINS.has(chainId);\n}\n\n/**\n * Get viem chain definition by chain ID\n * Returns undefined for unsupported chains\n */\nexport function getViemChain(chainId: number): Chain | undefined {\n return VIEM_CHAINS.get(chainId);\n}\n\n/**\n * Default cache TTL in milliseconds (12 seconds, ~1 block)\n */\nexport const DEFAULT_CACHE_TTL = 12000;\n\n/**\n * Default maximum cache entries\n */\nexport const DEFAULT_CACHE_MAX_SIZE = 1000;\n\n/**\n * Default maximum calls per multicall batch\n */\nexport const DEFAULT_MULTICALL_BATCH_SIZE = 100;\n\n/**\n * Default block range for getLogs queries (to avoid RPC limits)\n */\nexport const DEFAULT_LOGS_BLOCK_RANGE = 2000n;\n\n/**\n * Maximum block range for a single getLogs query\n */\nexport const MAX_LOGS_BLOCK_RANGE = 10000n;","/**\n * Base error classes for Lumia Passport SDK\n * @module @lumiapassport/core/lib/errors\n */\n\n/**\n * Base error class for all Lumia Passport errors\n *\n * Contains a machine-readable error code for programmatic handling.\n * All SDK errors should extend this class for consistent error handling.\n */\nexport class LumiaPassportError extends Error {\n /** Machine-readable error code for programmatic handling */\n readonly code: string;\n\n constructor(message: string, code: string) {\n super(message);\n this.code = code;\n this.name = 'LumiaPassportError';\n\n // Maintain proper stack trace for where our error was thrown (only available on V8)\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, this.constructor);\n }\n }\n}\n\n/**\n * Error thrown when bundler RPC is unreachable due to network issues\n *\n * This error indicates a temporary network problem that may be resolved by retry.\n * Contains the bundler URL and original error for debugging.\n */\nexport class BundlerNetworkError extends LumiaPassportError {\n /** Bundler URL that was unreachable */\n readonly bundlerUrl: string;\n /** Original error that caused the network failure */\n readonly originalError?: Error;\n\n constructor(message: string, bundlerUrl: string, originalError?: Error) {\n super(message, 'BUNDLER_NETWORK_ERROR');\n this.name = 'BundlerNetworkError';\n this.bundlerUrl = bundlerUrl;\n this.originalError = originalError;\n }\n}","/**\n * Blockchain Read Layer - Error Classes\n * @module @lumiapassport/core/read\n */\n\nimport type { Address } from 'viem';\nimport { LumiaPassportError } from '../lib/errors';\n\n/**\n * Base error class for read layer errors\n * Extends LumiaPassportError for consistent SDK error handling\n */\nexport class ReadLayerError extends LumiaPassportError {\n constructor(message: string, code: string) {\n super(message, code);\n this.name = 'ReadLayerError';\n }\n}\n\n/**\n * Contract does not exist at the specified address\n */\nexport class ContractNotFoundError extends ReadLayerError {\n constructor(\n public readonly address: Address,\n public readonly chainId: number,\n ) {\n super(\n `Contract not found at ${address} on chain ${chainId}`,\n 'CONTRACT_NOT_FOUND',\n );\n this.name = 'ContractNotFoundError';\n }\n}\n\n/**\n * Contract call reverted with a reason\n */\nexport class ContractRevertError extends ReadLayerError {\n constructor(\n public readonly address: Address,\n public readonly functionName: string,\n public readonly reason: string,\n ) {\n super(\n `Contract call to ${functionName} at ${address} reverted: ${reason}`,\n 'CONTRACT_REVERTED',\n );\n this.name = 'ContractRevertError';\n }\n}\n\n/**\n * Failed to connect to RPC endpoint\n */\nexport class RpcConnectionError extends ReadLayerError {\n constructor(\n public readonly url: string,\n public readonly cause?: Error,\n ) {\n super(`Failed to connect to RPC: ${url}`, 'RPC_CONNECTION_FAILED');\n this.name = 'RpcConnectionError';\n }\n}\n\n/**\n * All configured RPC endpoints failed\n */\nexport class AllRpcsFailedError extends ReadLayerError {\n constructor(\n public readonly urls: string[],\n public readonly errors: Error[],\n ) {\n super(\n `All ${urls.length} RPC endpoint(s) failed`,\n 'ALL_RPCS_FAILED',\n );\n this.name = 'AllRpcsFailedError';\n }\n}\n\n/**\n * RPC returned rate limit response\n */\nexport class RateLimitedError extends ReadLayerError {\n constructor(\n public readonly url: string,\n public readonly retryAfter?: number,\n ) {\n super(\n `Rate limited by RPC: ${url}${retryAfter ? `, retry after ${retryAfter}s` : ''}`,\n 'RATE_LIMITED',\n );\n this.name = 'RateLimitedError';\n }\n}\n\n/**\n * Requested block has been pruned from RPC node\n */\nexport class BlockPrunedError extends ReadLayerError {\n constructor(public readonly blockNumber: bigint) {\n super(\n `Block ${blockNumber} has been pruned and is not available`,\n 'BLOCK_PRUNED',\n );\n this.name = 'BlockPrunedError';\n }\n}\n\n/**\n * Invalid ABI provided - function not found\n */\nexport class InvalidAbiError extends ReadLayerError {\n constructor(\n public readonly functionName: string,\n public readonly address: Address,\n ) {\n super(\n `Function '${functionName}' not found in ABI for contract at ${address}`,\n 'INVALID_ABI',\n );\n this.name = 'InvalidAbiError';\n }\n}\n\n/**\n * Chain configuration not found\n *\n * @example\n * ```typescript\n * import { createPublicClientForChain } from '@lumiapassport/core/read'\n *\n * try {\n * const client = createPublicClientForChain(999999)\n * } catch (error) {\n * if (error instanceof ChainNotSupportedError) {\n * console.error('Unsupported chain:', error.chainId)\n * console.log('Supported chains:', error.supportedChains)\n * }\n * }\n * ```\n */\nexport class ChainNotSupportedError extends ReadLayerError {\n /** List of supported chain IDs */\n public readonly supportedChains: number[];\n\n constructor(chainId: number, supportedChains: number[] = []) {\n const chainList = supportedChains.length > 0\n ? `Supported chains: ${supportedChains.join(', ')}`\n : 'Please provide an RPC URL.';\n\n super(\n `Chain ${chainId} is not supported. ${chainList}`,\n 'CHAIN_NOT_SUPPORTED',\n );\n this.name = 'ChainNotSupportedError';\n this.supportedChains = supportedChains;\n }\n}\n\n/**\n * Transaction receipt not found within timeout period\n */\nexport class TransactionReceiptTimeoutError extends ReadLayerError {\n constructor(\n public readonly hash: string,\n public readonly timeout: number,\n ) {\n super(\n `Transaction receipt not found within ${timeout}ms: ${hash}`,\n 'TRANSACTION_RECEIPT_TIMEOUT',\n );\n this.name = 'TransactionReceiptTimeoutError';\n }\n}\n",";\n/**\n * Client Factories - Multi-Chain Support\n * @module @lumiapassport/core/read\n *\n * Stateless factory functions for creating viem clients for specific chains.\n * Each call creates a fresh client instance (no caching) - this is intentional\n * as viem clients are lightweight (<10ms creation time).\n */\n\nimport { createPublicClient, defineChain, http, type Chain, type PublicClient } from 'viem';\nimport { createBundlerClient, type BundlerClient } from 'viem/account-abstraction'\n\nimport { getChainConfig, getViemChain, SUPPORTED_CHAINS } from '../config/networks'\nimport { ChainNotSupportedError } from './errors';\nimport type { ChainConfig } from './types';\n\n\n/**\n * Create a viem Chain object from ChainConfig\n *\n * @param chainConfig - Chain configuration with RPC URLs and metadata\n * @returns Viem Chain object ready for client creation\n *\n * @example\n * ```typescript\n * import { LUMIA_TESTNET, createChainFromConfig } from '@lumiapassport/core/read'\n *\n * const chain = createChainFromConfig(LUMIA_TESTNET)\n * // chain.id === 2030232745\n * // chain.name === 'Lumia Beam'\n * ```\n */\nexport function createChainFromConfig(chainConfig: ChainConfig): Chain {\n return defineChain({\n id: chainConfig.id,\n name: chainConfig.name,\n nativeCurrency: {\n name: 'LUMIA',\n symbol: 'LUMIA',\n decimals: 18,\n },\n rpcUrls: {\n default: { http: chainConfig.rpcUrls },\n public: { http: chainConfig.rpcUrls },\n },\n });\n}\n\n/**\n * Create a PublicClient for reading blockchain data from a specific chain\n *\n * Creates a new client instance on each call (no caching).\n * Client creation is lightweight (<10ms) so caching is unnecessary.\n *\n * @param chainId - Numeric chain ID (must be in SUPPORTED_CHAINS)\n * @returns Configured PublicClient for the specified chain\n * @throws {ChainNotSupportedError} If chainId is not in SUPPORTED_CHAINS\n *\n * @example\n * ```typescript\n * import { createPublicClientForChain, LUMIA_TESTNET_CHAIN_ID } from '@lumiapassport/core/read'\n *\n * const client = createPublicClientForChain(LUMIA_TESTNET_CHAIN_ID)\n *\n * const balance = await client.getBalance({ address: '0x...' })\n * const code = await client.getCode({ address: '0x...' })\n * ```\n *\n * @example\n * ```typescript\n * // Error handling\n * try {\n * const client = createPublicClientForChain(999999) // Invalid chainId\n * } catch (error) {\n * console.error(error.message)\n * // \"Chain 999999 is not supported. Supported chains: 994873017, 2030232745\"\n * }\n * ```\n */\nexport function createPublicClientForChain(chainId: number): PublicClient {\n const chainConfig = getChainConfig(chainId);\n\n if (!chainConfig) {\n const supportedChainIds = Array.from(SUPPORTED_CHAINS.keys());\n throw new ChainNotSupportedError(chainId, supportedChainIds);\n }\n const viemChain = getViemChain(chainId)\n\n return createPublicClient({\n chain: viemChain,\n transport: http(chainConfig.rpcUrls[0], {\n timeout: 10_000,\n retryCount: 2,\n fetchOptions: { mode: 'cors' },\n }),\n });\n}\n\n/**\n * Create a BundlerClient for submitting UserOperations to a specific chain\n *\n * Creates a new client instance on each call (no caching).\n * Requires the chain to have a bundlerUrl configured.\n *\n * @param chainId - Numeric chain ID (must be in SUPPORTED_CHAINS)\n * @returns Configured BundlerClient for the specified chain\n * @throws {ChainNotSupportedError} If chainId is not in SUPPORTED_CHAINS\n * @throws {Error} If chain configuration lacks bundlerUrl\n *\n * @example\n * ```typescript\n * import { createBundlerClientForChain, LUMIA_MAINNET_CHAIN_ID } from '@lumiapassport/core/read'\n *\n * const bundler = createBundlerClientForChain(LUMIA_MAINNET_CHAIN_ID)\n *\n * const userOpHash = await bundler.sendUserOperation({\n * userOperation,\n * entryPoint: ENTRYPOINT_V07\n * })\n * ```\n *\n * @example\n * ```typescript\n * // Error: Missing bundlerUrl\n * try {\n * const bundler = createBundlerClientForChain(LUMIA_MAINNET_CHAIN_ID)\n * } catch (error) {\n * console.error(error.message)\n * // \"Chain 994873017 (Lumia) has no bundlerUrl configured\"\n * }\n * ```\n */\nexport function createBundlerClientForChain(chainId: number): BundlerClient {\n const chainConfig = getChainConfig(chainId);\n\n if (!chainConfig) {\n const supportedChainIds = Array.from(SUPPORTED_CHAINS.keys());\n throw new ChainNotSupportedError(chainId, supportedChainIds);\n }\n\n if (!chainConfig.bundlerUrl) {\n throw new Error(\n `Chain ${chainId} (${chainConfig.name}) has no bundlerUrl configured`\n );\n }\n\n const viemChain = getViemChain(chainId)\n\n return createBundlerClient({\n chain: viemChain,\n transport: http(chainConfig.bundlerUrl, {\n timeout: 10_000,\n retryCount: 0,\n fetchOptions: { mode: 'cors' },\n }),\n });\n}\n","/**\n * Account Abstraction helper utilities\n * Adapted from lumia-passport-ui-kit/src/internal/akHelpers.ts\n */\n\nimport type { ChainContext } from '../bundler/types';\nimport { BundlerNetworkError } from '../lib/errors';\n\n/**\n * Precompile address for ecrecover\n * @internal\n */\n// const ECRECOVER_PRECOMPILE = '0x0000000000000000000000000000000000000001' as const;\n\n/**\n * ABI for ecrecover precompile\n * @internal\n */\n// const ECRECOVER_ABI = [\n// {\n// name: 'ecrecover',\n// type: 'function',\n// inputs: [\n// { name: 'hash', type: 'bytes32' },\n// { name: 'v', type: 'uint8' },\n// { name: 'r', type: 'bytes32' },\n// { name: 's', type: 'bytes32' }\n// ],\n// outputs: [{ name: 'addr', type: 'address' }]\n// },\n// ] as const;\n\n/**\n * Safely convert value to BigInt with fallback\n * @param val - Value to convert\n * @param fallback - Fallback value if conversion fails\n */\nexport const safeToBigInt = (val: any, fallback = '0x0'): bigint => {\n try {\n return BigInt(val || fallback);\n } catch {\n return BigInt(fallback);\n }\n};\n\n/**\n * Pack two 128-bit values into single 256-bit value\n * Used for packing gas limits in ERC-4337 v0.7\n * @param hi - High 128 bits\n * @param lo - Low 128 bits\n * @returns Packed 256-bit value as bigint\n */\nexport const pack2x128 = (hi: bigint, lo: bigint): bigint => {\n return (hi << 128n) | (lo & ((1n << 128n) - 1n));\n};\n\n/**\n * Verify signature against expected owner address\n * @param opHash - Operation hash that was signed\n * @param signature - Signature to verify\n * @param expectedOwner - Expected owner address\n */\nexport async function verifySignatureAgainstOwner(\n opHash: `0x${string}`,\n signature: `0x${string}`,\n expectedOwner?: `0x${string}`\n): Promise<void> {\n if (!signature || signature === '0x') return;\n\n try {\n // This will be implemented after we have publicClient from clients module\n // For now, this is a placeholder\n console.log('[AA][sign] Signature verification:', {\n opHash,\n signature,\n expectedOwner,\n });\n } catch (error) {\n console.error('[AA][sign][ERROR] Could not verify signature:', error);\n }\n}\n\n/**\n * Fetch nonce from EntryPoint contract\n * @param account - Account address\n * @param _entryPoint - EntryPoint contract address (unused in placeholder)\n * @param _context - Chain context with blockchain client (unused in placeholder)\n */\nexport async function fetchEntryPointNonce(\n account: `0x${string}`,\n _entryPoint: `0x${string}`,\n _context: ChainContext\n): Promise<`0x${string}`> {\n // This will be implemented after we have publicClient from clients module\n // For now, return 0x0 as placeholder\n console.log('[AA] fetchEntryPointNonce called for:', account);\n return '0x0';\n}\n\n/**\n * Sanitize UserOperation object by fixing common issues\n * @param userOp - UserOperation to sanitize\n */\nfunction sanitizeUserOperation(userOp: any): any {\n const sanitized = { ...userOp };\n\n // Fix sender field if it's an object (extract address and factory fields)\n if (typeof sanitized.sender === 'object' && sanitized.sender) {\n const senderObj = sanitized.sender;\n\n // Extract the actual sender address\n sanitized.sender = senderObj.sender || senderObj.address || senderObj.smartAccountAddress;\n\n // Extract factory fields if they exist\n if (senderObj.factory) {\n sanitized.factory = senderObj.factory;\n }\n if (senderObj.factoryData) {\n sanitized.factoryData = senderObj.factoryData;\n }\n }\n\n // Ensure all hex fields are valid and properly formatted\n const hexFields = [\n 'sender', 'nonce', 'callData', 'callGasLimit', 'verificationGasLimit',\n 'preVerificationGas', 'maxFeePerGas', 'maxPriorityFeePerGas', 'signature',\n 'factory', 'factoryData', 'paymaster', 'paymasterData',\n 'paymasterVerificationGasLimit', 'paymasterPostOpGasLimit'\n ];\n\n for (const field of hexFields) {\n const value = sanitized[field];\n if (value !== undefined && value !== null) {\n if (typeof value === 'string') {\n if (value === '0x' || value === '') {\n // Convert empty hex to 0x0 for numeric fields, 0x for data fields\n if (['callData', 'factoryData', 'paymasterData', 'signature'].includes(field)) {\n sanitized[field] = '0x';\n } else {\n sanitized[field] = '0x0';\n }\n } else if (field === 'sender' || field === 'factory' || field === 'paymaster') {\n // Address fields should have 0x prefix\n if (!value.startsWith('0x')) {\n sanitized[field] = `0x${value}`;\n }\n } else if (!value.startsWith('0x')) {\n sanitized[field] = `0x${value}`;\n }\n }\n }\n }\n\n // Remove undefined/null fields for v0.7\n Object.keys(sanitized).forEach(key => {\n if (sanitized[key] === undefined || sanitized[key] === null) {\n delete sanitized[key];\n }\n });\n\n // Ensure required fields exist with proper defaults\n if (!sanitized.callData) sanitized.callData = '0x';\n if (!sanitized.signature) sanitized.signature = '0x';\n\n return sanitized;\n}\n\n/**\n * Make RPC call to bundler\n * @param method - RPC method name\n * @param params - RPC method parameters\n * @param bundlerUrl - Bundler URL (required)\n */\nexport async function bundlerRpc(\n method: string,\n params: any[],\n bundlerUrl: string\n): Promise<any> {\n // Sanitize UserOperation if this is eth_sendUserOperation\n let cleanParams = params;\n if (method === 'eth_sendUserOperation' && params[0]) {\n cleanParams = [sanitizeUserOperation(params[0]), params[1]];\n }\n\n const body = { jsonrpc: '2.0', id: 1, method, params: cleanParams };\n const bodyStr = JSON.stringify(body, (_k, v) => (typeof v === 'bigint' ? `0x${v.toString(16)}` : v));\n\n console.log('[Bundler][RPC] ->', method, bodyStr);\n\n let res: Response;\n try {\n res = await fetch(bundlerUrl, {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: bodyStr\n });\n } catch (error: any) {\n const errorMsg = error?.message || String(error);\n console.log('[Bundler][RPC] <- NETWORK ERROR:', errorMsg);\n throw new BundlerNetworkError(\n `Bundler unreachable: ${errorMsg}`,\n bundlerUrl,\n error\n );\n }\n\n const json: any = await res.json();\n\n if (json.error) {\n console.log('[Bundler][RPC] <- ERROR:', JSON.stringify(json.error));\n const detail = json.error?.data ? ` | data: ${JSON.stringify(json.error.data)}` : '';\n throw new Error((json.error.message || JSON.stringify(json.error)) + detail);\n }\n\n console.log('[Bundler][RPC] <- SUCCESS:', JSON.stringify(json.result));\n return json.result;\n}\n","import { createPublicClientForChain, getChainConfig } from '../read'\nimport { bundlerRpc, fetchEntryPointNonce } from '../utils/helpers';\nimport type { UserOperationV07 } from './types';\n\n/**\n * Network error patterns that indicate temporary network issues\n * These errors should trigger retry logic\n */\nconst NETWORK_ERROR_PATTERNS = [\n /unreachable/i,\n /fetch failed/i,\n /network error/i,\n /ECONNREFUSED/i,\n /ENOTFOUND/i,\n /ETIMEDOUT/i,\n /ECONNRESET/i,\n /socket hang up/i,\n /bundler.*unreachable/i,\n /connection.*refused/i,\n /getaddrinfo/i,\n];\n\n/**\n * Check if error message indicates a temporary network error\n * Exported for client-side error classification\n * @param errorMsg - Error message to check\n * @returns true if error is a network error that should trigger retry\n */\nexport function isNetworkError(errorMsg: string): boolean {\n return NETWORK_ERROR_PATTERNS.some(pattern => pattern.test(errorMsg));\n}\n\nexport async function sendUserOperationRaw(userOp: UserOperationV07, options: { chainId: number }): Promise<`0x${string}`> {\n if (!options || typeof options.chainId !== 'number') {\n throw new Error('sendUserOperationRaw requires options with chainId parameter. Usage: sendUserOperationRaw(userOp, { chainId: 2030232745 })')\n }\n const chainConfig = getChainConfig(options.chainId)\n if (!chainConfig) throw new Error(`Chain ID ${options.chainId} is not supported.`)\n const hash = await bundlerRpc(\n 'eth_sendUserOperation',\n [userOp, chainConfig?.entryPointV07Address],\n chainConfig?.bundlerUrl\n );\n return hash;\n}\n\nexport async function sendUserOperationWithRetry(\n userOp: UserOperationV07,\n resigner: (nonce: `0x${string}`) => Promise<UserOperationV07>,\n options: { chainId: number, maxRetries: number },\n): Promise<`0x${string}`> {\n if (!options || typeof options.chainId !== 'number') {\n throw new Error('sendUserOperationWithRetry requires options with chainId parameter. Usage: sendUserOperationWithRetry(userOp, resigner, { chainId: 2030232745, maxRetries: 3 })')\n }\n const { chainId, maxRetries = 3 } = options;\n const chainConfig = getChainConfig(chainId);\n\n if (!chainConfig) {\n throw new Error(`[sendUserOperationWithRetry] ChainConfig is not found (chainId:${chainId})`)\n }\n const publicClient = createPublicClientForChain(chainId);\n\n let attempts = 0;\n let currentUserOp = userOp;\n\n while (attempts < maxRetries) {\n try {\n return await sendUserOperationRaw(currentUserOp, { chainId });\n } catch (error: any) {\n attempts++;\n const errorMsg = String(error?.message || error);\n if (attempts >= maxRetries) throw error;\n\n // Handle network errors - just wait and retry without modifying the operation\n if (isNetworkError(errorMsg)) {\n console.log(`[Bundler] Network error detected, retrying (attempt ${attempts}/${maxRetries})...`);\n await new Promise(r => setTimeout(r, 1000 * attempts));\n continue;\n }\n\n if (/nonce too low|nonce.*invalid/i.test(errorMsg)) {\n const newNonce = await fetchEntryPointNonce(\n userOp.sender,\n chainConfig.entryPointV07Address,\n { client: publicClient }\n )\n currentUserOp = await resigner(newNonce);\n } else if (/replacement.*underpriced/i.test(errorMsg)) {\n const increasedMaxFeePerGas = `0x${((BigInt(currentUserOp.maxFeePerGas) * 110n) / 100n).toString(16)}` as `0x${string}`;\n const increasedMaxPriorityFeePerGas = `0x${((BigInt(currentUserOp.maxPriorityFeePerGas) * 110n) / 100n).toString(16)}` as `0x${string}`;\n currentUserOp = { ...currentUserOp, maxFeePerGas: increasedMaxFeePerGas, maxPriorityFeePerGas: increasedMaxPriorityFeePerGas };\n currentUserOp = await resigner(currentUserOp.nonce);\n } else {\n const newNonce = await fetchEntryPointNonce(\n userOp.sender,\n chainConfig.entryPointV07Address,\n { client: publicClient }\n );\n currentUserOp = await resigner(newNonce);\n }\n\n await new Promise(r => setTimeout(r, 1000 * attempts));\n }\n }\n throw new Error(`Failed to send UserOperation after ${maxRetries} attempts`);\n}\n\n/**\n * Get UserOperation receipt by hash (low-level, requires bundlerUrl)\n * @param userOpHash - UserOperation hash\n * @param bundlerUrl - Bundler RPC URL\n */\nexport async function getUserOperationReceipt(userOpHash: `0x${string}`, bundlerUrl: string): Promise<any> {\n const receipt = await bundlerRpc('eth_getUserOperationReceipt', [userOpHash], bundlerUrl);\n return receipt;\n}\n","/**\n * Universal environment variable access that works in both browser and Node.js\n */\n\ninterface EnvVars {\n [key: string]: string | undefined;\n}\n\n/**\n * Get environment variables from various sources\n * Priority: 1. window.__LUMIA_ENV__ (browser), 2. import.meta.env (Vite), 3. process.env (Node.js)\n */\nfunction getEnvironmentVars(): EnvVars {\n // Try browser environment first (injected by LumiaPassportProvider)\n // @ts-ignore - accessing global window object\n const win = typeof globalThis !== 'undefined' && (globalThis as any).window;\n if (win && win.__LUMIA_ENV__) {\n return win.__LUMIA_ENV__;\n }\n\n // Try import.meta.env (ESM/Vite)\n try {\n // @ts-ignore - import.meta may not be available in all environments\n if (import.meta?.env) {\n // @ts-ignore\n return import.meta.env as EnvVars;\n }\n } catch {\n // import.meta not available in this environment\n }\n\n // Try process.env (Node.js/CJS)\n if (typeof process !== 'undefined' && process.env) {\n return process.env;\n }\n\n // Fallback to empty object\n return {};\n}\n\n/**\n * Get a single environment variable\n * @param name - The environment variable name\n * @returns The environment variable value or undefined\n */\nexport function getEnvVar(name: string): string | undefined {\n const env = getEnvironmentVars();\n return env[name];\n}\n\n/**\n * Get an environment variable as boolean\n * @param name - The environment variable name\n * @returns true if value is 'true' or '1', false otherwise\n */\nexport function getEnvVarBool(name: string): boolean {\n const value = getEnvVar(name);\n return value === 'true' || value === '1';\n}\n\n/**\n * Get an environment variable as array\n * @param name - The environment variable name\n * @param separator - Separator character (default: ',')\n * @returns Array of trimmed non-empty strings\n */\nexport function getEnvVarArray(name: string, separator = ','): string[] {\n const value = getEnvVar(name);\n return value ? value.split(separator).map(s => s.trim()).filter(Boolean) : [];\n}\n\n/**\n * Get all environment variables\n * @returns Object containing all environment variables\n */\nexport function getAllEnvVars(): EnvVars {\n return getEnvironmentVars();\n}\n\n/**\n * Check if running in development mode\n * @returns true if NODE_ENV or MODE is 'development'\n */\nexport function isDevelopment(): boolean {\n const env = getEnvironmentVars();\n return env.NODE_ENV === 'development' || env.MODE === 'development';\n}\n\n/**\n * Check if running in production mode\n * @returns true if NODE_ENV or MODE is 'production'\n */\nexport function isProduction(): boolean {\n const env = getEnvironmentVars();\n return env.NODE_ENV === 'production' || env.MODE === 'production';\n}\n","import { bundlerRpc } from '../utils/helpers';\nimport { getEnvVar, getEnvVarBool } from '../utils/env';\nimport type { ChainContext, FeeChainContext } from './types';\nimport type { PublicClient } from 'viem'\n\nexport interface FeeConfig {\n baseFeeBuffer: number;\n priorityFeeBuffer: number;\n fallbackMaxFeePerGas?: bigint;\n fallbackMaxPriorityFeePerGas?: bigint;\n}\n\nexport interface CalculatedFees {\n maxFeePerGas: `0x${string}`;\n maxPriorityFeePerGas: `0x${string}`;\n baseFee?: bigint;\n priorityFee?: bigint;\n bufferedBaseFee?: bigint;\n bufferedPriorityFee?: bigint;\n}\n\n// Hardcoded fallback values (used when env vars not set and network calls fail)\nconst HARDCODED_FALLBACK_MAX_FEE = 3_000_000_000n; // 3 gwei\nconst HARDCODED_FALLBACK_PRIORITY_FEE = 3_000_000_000n; // 3 gwei\n\n/**\n * Get minimum maxFeePerGas from environment or use hardcoded fallback\n * Env vars: MIN_MAX_FEE_PER_GAS or VITE_MIN_MAX_FEE_PER_GAS (in wei)\n */\nexport function getMinMaxFeePerGas(): bigint {\n const envValue = getEnvVar('MIN_MAX_FEE_PER_GAS') || getEnvVar('VITE_MIN_MAX_FEE_PER_GAS');\n if (envValue) {\n try {\n return BigInt(envValue);\n } catch {\n console.warn('[Fees] Invalid MIN_MAX_FEE_PER_GAS value:', envValue);\n }\n }\n return HARDCODED_FALLBACK_MAX_FEE;\n}\n\n/**\n * Get minimum maxPriorityFeePerGas from environment or use hardcoded fallback\n * Env vars: MIN_PRIORITY_FEE_PER_GAS or VITE_MIN_PRIORITY_FEE_PER_GAS (in wei)\n */\nexport function getMinPriorityFeePerGas(): bigint {\n const envValue = getEnvVar('MIN_PRIORITY_FEE_PER_GAS') || getEnvVar('VITE_MIN_PRIORITY_FEE_PER_GAS');\n if (envValue) {\n try {\n return BigInt(envValue);\n } catch {\n console.warn('[Fees] Invalid MIN_PRIORITY_FEE_PER_GAS value:', envValue);\n }\n }\n return HARDCODED_FALLBACK_PRIORITY_FEE;\n}\n\n/**\n * Get default maxFeePerGas as hex string (for dummy user operations)\n */\nexport function getDefaultMaxFeePerGasHex(): `0x${string}` {\n return `0x${getMinMaxFeePerGas().toString(16)}`;\n}\n\n/**\n * Get default maxPriorityFeePerGas as hex string (for dummy user operations)\n */\nexport function getDefaultPriorityFeePerGasHex(): `0x${string}` {\n return `0x${getMinPriorityFeePerGas().toString(16)}`;\n}\n\nexport const DEFAULT_FEE_CONFIG: FeeConfig = { baseFeeBuffer: 0.5, priorityFeeBuffer: 0.05, fallbackMaxFeePerGas: HARDCODED_FALLBACK_MAX_FEE, fallbackMaxPriorityFeePerGas: HARDCODED_FALLBACK_PRIORITY_FEE };\nexport const CONSERVATIVE_FEE_CONFIG: FeeConfig = { baseFeeBuffer: 1.0, priorityFeeBuffer: 0.25, fallbackMaxFeePerGas: 5_000_000_000n, fallbackMaxPriorityFeePerGas: 3_000_000_000n };\n\n/**\n * Check if the current chain requires legacy gas pricing to avoid BASEFEE opcode errors\n */\nfunction shouldUseLegacyGasForChain(options: { publicClient: PublicClient }): boolean {\n try {\n const { publicClient } = options;\n // Get environment variable for legacy chain IDs (comma-separated list)\n const legacyChainIds = getEnvVar('VITE_LEGACY_GAS_CHAIN_IDS') || getEnvVar('LEGACY_GAS_CHAIN_IDS') || '';\n\n console.log('[Fees] Environment check:', {\n LEGACY_GAS_CHAIN_IDS: legacyChainIds,\n });\n\n // Default to Lumia Beam testnet if no env var is set\n const defaultLegacyChains = '2030232745'; // Lumia Beam testnet\n const chainIdsString = legacyChainIds || defaultLegacyChains;\n\n // Parse chain IDs\n const legacyChains = chainIdsString.split(',').map(id => parseInt(id.trim())).filter(id => !isNaN(id));\n\n // Get current chain ID from public client\n const currentChainId = publicClient?.chain?.id;\n\n if (!currentChainId) return false;\n\n const shouldUseLegacy = legacyChains.includes(currentChainId);\n\n if (shouldUseLegacy) {\n console.log('[Fees] Chain requires legacy gas pricing:', {\n chainId: currentChainId,\n legacyChains,\n configuredVia: legacyChainIds ? 'LEGACY_GAS_CHAIN_IDS env var' : 'default'\n });\n }\n\n return shouldUseLegacy;\n } catch (error) {\n console.warn('[Fees] Error checking legacy gas chain configuration:', error);\n return false;\n }\n}\n\nexport async function getCurrentBaseFee(context: ChainContext): Promise<bigint> {\n const block = await context.client.getBlock({ blockTag: 'latest' });\n if (block.baseFeePerGas) return block.baseFeePerGas;\n const gasPriceHex = await context.client.getGasPrice();\n const gasPrice = BigInt(gasPriceHex);\n const estimatedBaseFee = (gasPrice * 9n) / 10n;\n return estimatedBaseFee;\n}\n\nexport async function getCurrentPriorityFee(\n bundlerUrl: string,\n context: ChainContext\n): Promise<bigint> {\n try {\n const priorityFeeHex = await bundlerRpc('rundler_maxPriorityFeePerGas', [], bundlerUrl);\n const priorityFee = BigInt(priorityFeeHex);\n if (priorityFee === 0n) {\n return await getFallbackPriorityFee(context);\n }\n return priorityFee;\n } catch {\n return await getFallbackPriorityFee(context);\n }\n}\n\nasync function getFallbackPriorityFee(context: ChainContext): Promise<bigint> {\n try {\n const gasPriceHex = await context.client.getGasPrice();\n const gasPrice = BigInt(gasPriceHex);\n return gasPrice / 10n;\n } catch {\n return 100_000_000n;\n }\n}\n\nexport async function calculateLegacyFees(\n bufferPercent: number,\n context: ChainContext\n): Promise<CalculatedFees> {\n const minMaxFee = getMinMaxFeePerGas();\n const minPriorityFee = getMinPriorityFeePerGas();\n\n try {\n // Always get current gas price from network for legacy chains\n const gasPriceHex = await context.client.getGasPrice();\n const networkGasPrice = BigInt(gasPriceHex);\n\n // Add buffer to network gas price (bundler typically requires ~30% buffer)\n const bufferedGasPrice = networkGasPrice + (networkGasPrice * BigInt(bufferPercent)) / 100n;\n\n // Enforce minimum fee\n const effectiveGasPrice = bufferedGasPrice < minMaxFee ? minMaxFee : bufferedGasPrice;\n\n // For legacy chains, set both maxFeePerGas and maxPriorityFeePerGas to the same value\n // This prevents BASEFEE opcode usage\n const result: CalculatedFees = {\n maxFeePerGas: `0x${effectiveGasPrice.toString(16)}`,\n maxPriorityFeePerGas: `0x${effectiveGasPrice.toString(16)}`,\n };\n\n console.log('[Fees] Using legacy gas pricing (avoid BASEFEE opcode):', {\n networkGasPrice: networkGasPrice.toString(),\n bufferPercent,\n bufferedGasPrice: bufferedGasPrice.toString(),\n minFee: minMaxFee.toString(),\n effectiveGasPrice: effectiveGasPrice.toString(),\n maxFeePerGas: result.maxFeePerGas,\n maxPriorityFeePerGas: result.maxPriorityFeePerGas,\n });\n\n return result;\n } catch (error) {\n console.warn('[Fees] Legacy fee calculation failed, using min fee fallback:', error);\n return {\n maxFeePerGas: `0x${minMaxFee.toString(16)}`,\n maxPriorityFeePerGas: `0x${minPriorityFee.toString(16)}`,\n };\n }\n}\n\nexport async function calculateDynamicFees(\n config: FeeConfig = DEFAULT_FEE_CONFIG,\n context: FeeChainContext\n): Promise<CalculatedFees> {\n const { client, bundlerUrl } = context;\n const minMaxFee = getMinMaxFeePerGas();\n const minPriorityFee = getMinPriorityFeePerGas();\n\n try {\n // Check environment variable for forced legacy mode\n const forceLegacy = getEnvVarBool('VITE_FORCE_LEGACY_GAS') || getEnvVarBool('FORCE_LEGACY_GAS');\n\n // Check if current chain should use legacy gas pricing\n const shouldUseLegacy = forceLegacy || shouldUseLegacyGasForChain({ publicClient: client});\n\n if (shouldUseLegacy) {\n console.log('[Fees] Using legacy gas pricing', forceLegacy ? '(forced by FORCE_LEGACY_GAS env var)' : '(chain requires legacy gas)');\n return await calculateLegacyFees(30, { client });\n }\n const baseFee = await getCurrentBaseFee({ client });\n const bufferedBaseFee = baseFee + (baseFee * BigInt(Math.floor(config.baseFeeBuffer * 1000))) / 1000n;\n const priorityFee = await getCurrentPriorityFee(bundlerUrl, { client });\n const bufferedPriorityFee = priorityFee + (priorityFee * BigInt(Math.floor(config.priorityFeeBuffer * 1000))) / 1000n;\n\n // Calculate fees\n let maxFeePerGas = bufferedBaseFee + bufferedPriorityFee;\n let maxPriorityFeePerGas = bufferedPriorityFee;\n\n // Enforce minimum fees\n if (maxFeePerGas < minMaxFee) {\n console.log('[Fees] Calculated maxFeePerGas below minimum, using minimum:', { calculated: maxFeePerGas.toString(), min: minMaxFee.toString() });\n maxFeePerGas = minMaxFee;\n }\n if (maxPriorityFeePerGas < minPriorityFee) {\n console.log('[Fees] Calculated maxPriorityFeePerGas below minimum, using minimum:', { calculated: maxPriorityFeePerGas.toString(), min: minPriorityFee.toString() });\n maxPriorityFeePerGas = minPriorityFee;\n }\n\n return { maxFeePerGas: `0x${maxFeePerGas.toString(16)}`, maxPriorityFeePerGas: `0x${maxPriorityFeePerGas.toString(16)}`, baseFee, priorityFee, bufferedBaseFee, bufferedPriorityFee };\n } catch { return await calculateLegacyFees(30, { client }); }\n}\n\nexport async function calculateFastFees(\n context: FeeChainContext\n): Promise<CalculatedFees> {\n const { client } = context;\n const forceLegacy = getEnvVarBool('VITE_FORCE_LEGACY_GAS') || getEnvVarBool('FORCE_LEGACY_GAS');\n const shouldUseLegacy = forceLegacy || shouldUseLegacyGasForChain({ publicClient: client});\n\n if (shouldUseLegacy) return await calculateLegacyFees(50, { client }); // 50% buffer for fast\n return calculateDynamicFees({ baseFeeBuffer: 0.75, priorityFeeBuffer: 0.5, fallbackMaxFeePerGas: 3_000_000_000n, fallbackMaxPriorityFeePerGas: 2_000_000_000n }, context);\n}\n\nexport async function calculateEconomyFees(\n context: FeeChainContext\n): Promise<CalculatedFees> {\n const { client } = context;\n const forceLegacy = getEnvVarBool('VITE_FORCE_LEGACY_GAS') || getEnvVarBool('FORCE_LEGACY_GAS');\n const shouldUseLegacy = forceLegacy || shouldUseLegacyGasForChain({ publicClient: client});\n\n if (shouldUseLegacy) return await calculateLegacyFees(30, { client }); // 30% buffer for economy\n return calculateDynamicFees({ baseFeeBuffer: 0.27, priorityFeeBuffer: 0.01, fallbackMaxFeePerGas: 1_000_000_000n, fallbackMaxPriorityFeePerGas: 500_000_000n }, context);\n}\n\nexport async function getFeeEstimates(context: FeeChainContext): Promise<{ economy: CalculatedFees; standard: CalculatedFees; fast: CalculatedFees; }> {\n const [economy, standard, fast] = await Promise.all([\n calculateEconomyFees(context),\n calculateDynamicFees(undefined, context),\n calculateFastFees(context)\n ]);\n return { economy, standard, fast };\n}\n","import { pack2x128, safeToBigInt } from '../utils/helpers';\nimport { calculateDynamicFees, calculateEconomyFees, calculateFastFees, getDefaultMaxFeePerGasHex, getDefaultPriorityFeePerGasHex } from './fee-calculation';\nimport type { UserOperationV07, PackedUserOperationV07, UserOperationParams, FeeChainContext } from './types';\n\n// Re-export types for external use\nexport type { UserOperationParams, FeeChainContext };\n\n// Dummy signature for gas estimation\n// Must be a valid ECDSA format (65 bytes: r[32] + s[32] + v[1])\n// OpenZeppelin ECDSA requires:\n// - r != 0\n// - s in lower half of curve order (s < secp256k1n/2 = 0x7FFFFFFF...)\n// - v = 27 or 28\n// Using s = 0x01 (minimal valid s) to avoid ECDSAInvalidSignatureS error\n// r = 0x01 (minimal valid r) to avoid ECDSAInvalidSignature error\n// v = 0x1b (27) for valid recovery id\n// This signature will recover to an invalid address but won't revert during estimation\nconst DUMMY_R = '0000000000000000000000000000000000000000000000000000000000000001';\nconst DUMMY_S = '0000000000000000000000000000000000000000000000000000000000000001';\nconst DUMMY_V = '1b'; // 27\nexport const DUMMY_SIGNATURE = `0x${DUMMY_R}${DUMMY_S}${DUMMY_V}` as `0x${string}`;\n\nexport function packUserOperationV07(\n userOp: UserOperationV07,\n includeFactory: boolean,\n factoryAddress?: `0x${string}`,\n factoryData?: `0x${string}`\n): PackedUserOperationV07 {\n const initCode = includeFactory && factoryAddress && factoryData ? (((factoryAddress as string) + (factoryData as string).slice(2)) as `0x${string}`) : ('0x' as `0x${string}`);\n const accountGasLimits = pack2x128(safeToBigInt(userOp.verificationGasLimit, '0x1e8480'), safeToBigInt(userOp.callGasLimit, '0x0f4240'));\n const defaultMaxFee = getDefaultMaxFeePerGasHex();\n const defaultPriorityFee = getDefaultPriorityFeePerGasHex();\n const gasFees = pack2x128(safeToBigInt(userOp.maxPriorityFeePerGas, defaultPriorityFee), safeToBigInt(userOp.maxFeePerGas, defaultMaxFee));\n\n // Create paymasterAndData from paymaster and paymasterData fields (V07 format)\n let paymasterAndData: `0x${string}` = '0x';\n if (userOp.paymaster && userOp.paymaster !== '0x') {\n const paymasterAddr = userOp.paymaster.startsWith('0x') ? userOp.paymaster.slice(2) : userOp.paymaster;\n const paymasterData = userOp.paymasterData ? (userOp.paymasterData.startsWith('0x') ? userOp.paymasterData.slice(2) : userOp.paymasterData) : '';\n paymasterAndData = `0x${paymasterAddr}${paymasterData}` as `0x${string}`;\n }\n\n return { sender: userOp.sender, nonce: BigInt(userOp.nonce), initCode, callData: userOp.callData, accountGasLimits, preVerificationGas: safeToBigInt(userOp.preVerificationGas, '0x1d4c0'), gasFees, paymasterAndData, signature: userOp.signature };\n}\n\nexport function createDummyUserOperation(\n sender: `0x${string}`,\n nonce: `0x${string}`,\n callData: `0x${string}`,\n includeFactory: boolean = false,\n factoryAddress?: `0x${string}`,\n factoryData?: `0x${string}`,\n customMaxFeePerGas?: `0x${string}`,\n customMaxPriorityFeePerGas?: `0x${string}`\n): UserOperationV07 {\n const userOp: UserOperationV07 = {\n sender,\n nonce,\n callData,\n callGasLimit: '0x0', // Zero - bundler will calculate real value\n verificationGasLimit: '0x0', // Zero - bundler will calculate real value\n preVerificationGas: '0x0', // Zero - bundler will calculate real value\n maxFeePerGas: customMaxFeePerGas || getDefaultMaxFeePerGasHex(),\n maxPriorityFeePerGas: customMaxPriorityFeePerGas || getDefaultPriorityFeePerGasHex(),\n signature: DUMMY_SIGNATURE,\n };\n if (includeFactory && factoryAddress && factoryData) { userOp.factory = factoryAddress; userOp.factoryData = factoryData; }\n return userOp;\n}\n\nexport async function createUserOperationWithDynamicFees(\n params: UserOperationParams,\n context: FeeChainContext\n): Promise<UserOperationV07> {\n const { sender, nonce, callData, includeFactory = false, factoryAddress, factoryData, feeType = 'standard' } = params;\n\n let fees;\n switch (feeType) {\n case 'economy': fees = await calculateEconomyFees(context); break;\n case 'fast': fees = await calculateFastFees(context); break;\n default: fees = await calculateDynamicFees(undefined, context);\n }\n\n return createDummyUserOperation(sender, nonce, callData, includeFactory, factoryAddress, factoryData, fees.maxFeePerGas, fees.maxPriorityFeePerGas);\n}\n","import { getChainConfig } from '../read';\nimport { bundlerRpc } from '../utils/helpers'\nimport type { FeeChainContext, GasEstimationResult, UserOperationV07 } from './types'\nimport { createUserOperationWithDynamicFees, DUMMY_SIGNATURE, type UserOperationParams } from './utils';\n\n\n// Known ERC-4337 validation errors that can use fallback gas estimation\n// These are errors from EntryPoint validation, not from contract execution\nconst VALIDATION_ERROR_PATTERNS = [\n /AA20/i, // account not deployed\n /AA21/i, // didn't pay prefund\n /AA22/i, // expired or not due\n /AA23/i, // reverted (signature validation failed - expected with dummy sig)\n /AA24/i, // signature error\n /AA25/i, // invalid account nonce\n /AA10/i, // sender already constructed\n /AA13/i, // initCode failed or OOG\n /AA14/i, // initCode must return sender\n /AA15/i, // initCode must create sender\n];\n\n// Errors that indicate the transaction WILL fail - no point in sending\nconst EXECUTION_REVERT_PATTERNS = [\n /execution reverted/i,\n /ERC20InsufficientBalance/i,\n /ERC20InsufficientAllowance/i,\n /transfer amount exceeds balance/i,\n /insufficient funds/i,\n /not operator/i,\n /not authorized/i,\n /access denied/i,\n /ownable.*caller is not/i,\n];\n\nfunction isValidationError(errorMsg: string): boolean {\n return VALIDATION_ERROR_PATTERNS.some(pattern => pattern.test(errorMsg));\n}\n\nfunction isExecutionRevert(errorMsg: string): boolean {\n return EXECUTION_REVERT_PATTERNS.some(pattern => pattern.test(errorMsg));\n}\n\nexport async function estimateUserOperationGas(\n userOp: UserOperationV07,\n options: { chainId: number, retryWithoutFactory: boolean, }\n): Promise<GasEstimationResult> {\n const chainConfig = getChainConfig(options.chainId)\n if (!chainConfig) throw new Error(`Chain ID ${options.chainId} is not supported.`)\n try {\n const gas = await bundlerRpc(\n 'eth_estimateUserOperationGas',\n [userOp, chainConfig.entryPointV07Address],\n chainConfig.bundlerUrl\n );\n return gas;\n } catch (error) {\n const errorMsg = String(error);\n\n // Retry without factory if account is already deployed\n if (options.retryWithoutFactory && (userOp.factory || userOp.factoryData)) {\n if (/AA10 sender already constructed/i.test(errorMsg) || /sender.*is an existing contract.*but initCode is nonempty/i.test(errorMsg)) {\n const userOpWithoutFactory: UserOperationV07 = { ...userOp };\n delete userOpWithoutFactory.factory;\n delete userOpWithoutFactory.factoryData;\n try {\n const gas = await bundlerRpc(\n 'eth_estimateUserOperationGas',\n [userOpWithoutFactory, chainConfig.entryPointV07Address],\n chainConfig.bundlerUrl\n );\n return gas;\n } catch {}\n }\n }\n\n // If this is an execution revert (not validation), the transaction WILL fail\n // Don't waste gas - throw the error so caller can handle it\n if (isExecutionRevert(errorMsg)) {\n throw new Error(`Transaction will fail: ${errorMsg}`);\n }\n\n // For validation errors (AA20, AA23, etc.), use fallback gas estimates\n // These are expected when using dummy signature for estimation\n if (!isValidationError(errorMsg)) {\n // Unknown error - rethrow it\n throw error;\n }\n\n // Fallback to reasonable gas estimates for validation errors\n const isEmptyCallData = !userOp.callData || userOp.callData === '0x';\n const hasFactory = !!(userOp.factory && userOp.factoryData);\n\n // callGasLimit: 500K should cover most contract calls\n const fallbackCallGas = isEmptyCallData ? '0x0' : '0x7A120'; // 500,000\n\n // verificationGasLimit: depends on whether account needs to be deployed\n const fallbackVerificationGas = hasFactory ? '0x16E360' : '0x7A120'; // 1,500,000 or 500,000\n\n // preVerificationGas: 50K is typical for most operations\n const fallbackPreVerificationGas = '0xC350'; // 50,000\n\n return {\n callGasLimit: fallbackCallGas,\n verificationGasLimit: fallbackVerificationGas,\n preVerificationGas: fallbackPreVerificationGas\n };\n }\n}\n\nexport async function estimateUserOperationGasWithSignature(\n userOp: UserOperationV07,\n _getSignature: (opHash: `0x${string}`) => Promise<`0x${string}` | null>,\n _getUserOpHash: (packedOp: any) => Promise<`0x${string}`>,\n options: { chainId: number, retryWithoutFactory: boolean},\n): Promise<GasEstimationResult> {\n const userOpForEstimation: UserOperationV07 = { ...userOp, signature: DUMMY_SIGNATURE };\n return estimateUserOperationGas(\n userOpForEstimation,\n {\n chainId: options.chainId,\n retryWithoutFactory: options.retryWithoutFactory\n });\n}\n\nexport async function estimateUserOperationGasWithDynamicFees(\n params: UserOperationParams,\n context: FeeChainContext,\n retryWithoutFactory: boolean = true\n): Promise<GasEstimationResult & { calculatedFees?: any }> {\n const userOp = await createUserOperationWithDynamicFees(params, context);\n const gasResult = await estimateUserOperationGas(\n userOp,\n { retryWithoutFactory, chainId: context.chainConfig.id}\n );\n return { ...gasResult, calculatedFees: { maxFeePerGas: userOp.maxFeePerGas, maxPriorityFeePerGas: userOp.maxPriorityFeePerGas, feeType: params.feeType || 'standard' } };\n}\n","import { bundlerRpc } from '../utils/helpers';\nimport type { UserOperationV07, SimulationResult } from './types';\nimport { getChainConfig } from '../read'\n\n/**\n * Simulate a UserOperation using Lumia's lumia_simulateUserOperation method\n * Returns asset changes that would occur if the operation is executed\n *\n * @experimental This method uses Lumia-specific bundler extension\n * @param userOp - The UserOperation to simulate\n * @param options - options with Chain ID (required)\n * @returns Simulation result with asset changes\n */\nexport async function simulateUserOperation(userOp: UserOperationV07, options: { chainId: number }): Promise<SimulationResult> {\n const chainConfig = getChainConfig(options.chainId)\n if (!chainConfig) throw new Error(`Chain ID ${options.chainId} is not supported.`)\n try {\n // Lumia bundler expects params as: [{ userOperation, entryPoint }]\n const result = await bundlerRpc('lumia_simulateUserOperation', [{\n userOperation: userOp,\n entryPoint: chainConfig.entryPointV07Address,\n }], chainConfig?.bundlerUrl);\n return result;\n } catch (error) {\n // If simulation fails, return error in the expected format\n const errorMsg = error instanceof Error ? error.message : String(error);\n return {\n changes: [],\n error: {\n message: errorMsg,\n code: -1\n }\n };\n }\n}\n\n/**\n * Validate a UserOperation by simulating it\n * Returns true if simulation succeeds without errors\n */\nexport async function validateUserOperation(userOp: UserOperationV07, options: { chainId: number }): Promise<{ valid: boolean; error?: string }> {\n try {\n const result = await simulateUserOperation(userOp, { chainId: options.chainId });\n if (result.error) {\n return { valid: false, error: result.error.message };\n }\n return { valid: true };\n } catch (error) {\n const errorMsg = error instanceof Error ? error.message : String(error);\n return { valid: false, error: errorMsg };\n }\n}\n","/**\n * Provider for viem PublicClient\n * Allows fee-calculation and other modules to access the configured client\n */\n\n// Using 'any' type to avoid direct viem dependency in this file\n// Actual type should be PublicClient from viem\nlet globalPublicClient: any | null = null;\n\n/**\n * Set the global public client for blockchain interactions\n * Should be called during initialization with a viem PublicClient\n */\nexport function setPublicClient(client: any): void {\n globalPublicClient = client;\n}\n\n/**\n * Get the configured public client\n * Throws if not configured\n */\nexport function getPublicClient(): any {\n if (!globalPublicClient) {\n throw new Error(\n '[LumiaPassport] PublicClient not configured. Please provide a publicClient in config ' +\n 'or call setPublicClient() before using fee calculation functions.'\n );\n }\n return globalPublicClient;\n}\n\n/**\n * Check if public client is configured\n */\nexport function hasPublicClient(): boolean {\n return globalPublicClient !== null;\n}\n"]}
@@ -9,6 +9,13 @@ import '../types-Cl4_gFZq.cjs';
9
9
  declare const ENTRYPOINT_V07: "0x0000000071727De22E5E9d8BAf0edAc6f37da032";
10
10
  declare const ENTRYPOINT: "0x0000000071727De22E5E9d8BAf0edAc6f37da032";
11
11
 
12
+ /**
13
+ * Check if error message indicates a temporary network error
14
+ * Exported for client-side error classification
15
+ * @param errorMsg - Error message to check
16
+ * @returns true if error is a network error that should trigger retry
17
+ */
18
+ declare function isNetworkError(errorMsg: string): boolean;
12
19
  declare function sendUserOperationRaw(userOp: UserOperationV07, options: {
13
20
  chainId: number;
14
21
  }): Promise<`0x${string}`>;
@@ -110,4 +117,4 @@ declare function getPublicClient(): any;
110
117
  */
111
118
  declare function hasPublicClient(): boolean;
112
119
 
113
- export { CONSERVATIVE_FEE_CONFIG, type CalculatedFees, ChainContext, DEFAULT_FEE_CONFIG, DUMMY_SIGNATURE, ENTRYPOINT, ENTRYPOINT_V07, FeeChainContext, type FeeConfig, GasEstimationResult, PackedUserOperationV07, SimulationResult, UserOperationV07, calculateDynamicFees, calculateEconomyFees, calculateFastFees, calculateLegacyFees, createDummyUserOperation, createUserOperationWithDynamicFees, estimateUserOperationGas, estimateUserOperationGasWithDynamicFees, estimateUserOperationGasWithSignature, getCurrentBaseFee, getCurrentPriorityFee, getFeeEstimates, getPublicClient, getUserOperationReceipt, hasPublicClient, packUserOperationV07, sendUserOperationRaw, sendUserOperationWithRetry, setPublicClient, simulateUserOperation, validateUserOperation };
120
+ export { CONSERVATIVE_FEE_CONFIG, type CalculatedFees, ChainContext, DEFAULT_FEE_CONFIG, DUMMY_SIGNATURE, ENTRYPOINT, ENTRYPOINT_V07, FeeChainContext, type FeeConfig, GasEstimationResult, PackedUserOperationV07, SimulationResult, UserOperationV07, calculateDynamicFees, calculateEconomyFees, calculateFastFees, calculateLegacyFees, createDummyUserOperation, createUserOperationWithDynamicFees, estimateUserOperationGas, estimateUserOperationGasWithDynamicFees, estimateUserOperationGasWithSignature, getCurrentBaseFee, getCurrentPriorityFee, getFeeEstimates, getPublicClient, getUserOperationReceipt, hasPublicClient, isNetworkError, packUserOperationV07, sendUserOperationRaw, sendUserOperationWithRetry, setPublicClient, simulateUserOperation, validateUserOperation };
@@ -9,6 +9,13 @@ import '../types-Cl4_gFZq.js';
9
9
  declare const ENTRYPOINT_V07: "0x0000000071727De22E5E9d8BAf0edAc6f37da032";
10
10
  declare const ENTRYPOINT: "0x0000000071727De22E5E9d8BAf0edAc6f37da032";
11
11
 
12
+ /**
13
+ * Check if error message indicates a temporary network error
14
+ * Exported for client-side error classification
15
+ * @param errorMsg - Error message to check
16
+ * @returns true if error is a network error that should trigger retry
17
+ */
18
+ declare function isNetworkError(errorMsg: string): boolean;
12
19
  declare function sendUserOperationRaw(userOp: UserOperationV07, options: {
13
20
  chainId: number;
14
21
  }): Promise<`0x${string}`>;
@@ -110,4 +117,4 @@ declare function getPublicClient(): any;
110
117
  */
111
118
  declare function hasPublicClient(): boolean;
112
119
 
113
- export { CONSERVATIVE_FEE_CONFIG, type CalculatedFees, ChainContext, DEFAULT_FEE_CONFIG, DUMMY_SIGNATURE, ENTRYPOINT, ENTRYPOINT_V07, FeeChainContext, type FeeConfig, GasEstimationResult, PackedUserOperationV07, SimulationResult, UserOperationV07, calculateDynamicFees, calculateEconomyFees, calculateFastFees, calculateLegacyFees, createDummyUserOperation, createUserOperationWithDynamicFees, estimateUserOperationGas, estimateUserOperationGasWithDynamicFees, estimateUserOperationGasWithSignature, getCurrentBaseFee, getCurrentPriorityFee, getFeeEstimates, getPublicClient, getUserOperationReceipt, hasPublicClient, packUserOperationV07, sendUserOperationRaw, sendUserOperationWithRetry, setPublicClient, simulateUserOperation, validateUserOperation };
120
+ export { CONSERVATIVE_FEE_CONFIG, type CalculatedFees, ChainContext, DEFAULT_FEE_CONFIG, DUMMY_SIGNATURE, ENTRYPOINT, ENTRYPOINT_V07, FeeChainContext, type FeeConfig, GasEstimationResult, PackedUserOperationV07, SimulationResult, UserOperationV07, calculateDynamicFees, calculateEconomyFees, calculateFastFees, calculateLegacyFees, createDummyUserOperation, createUserOperationWithDynamicFees, estimateUserOperationGas, estimateUserOperationGasWithDynamicFees, estimateUserOperationGasWithSignature, getCurrentBaseFee, getCurrentPriorityFee, getFeeEstimates, getPublicClient, getUserOperationReceipt, hasPublicClient, isNetworkError, packUserOperationV07, sendUserOperationRaw, sendUserOperationWithRetry, setPublicClient, simulateUserOperation, validateUserOperation };