@mentaproject/client 0.1.38 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -13,37 +13,7 @@ import {
13
13
  getTransactionCount,
14
14
  traceFilter
15
15
  } from "@mentaproject/core/actions";
16
-
17
- // src/structures/Action.ts
18
- import { simulateCalls } from "@mentaproject/core/actions";
19
- var Action = class {
20
- constructor(client, _call) {
21
- this.client = client;
22
- this._call = _call;
23
- }
24
- /**
25
- * Returns the Call object for use with TransactionBuilder.
26
- */
27
- call() {
28
- return this._call;
29
- }
30
- /**
31
- * Simulates the action without executing.
32
- */
33
- async simulate() {
34
- return simulateCalls(this.client, { calls: [this._call] });
35
- }
36
- /**
37
- * Executes the action directly.
38
- *
39
- * @returns Transaction hash
40
- */
41
- async execute() {
42
- return this.client.sendTransaction(this._call);
43
- }
44
- };
45
-
46
- // src/structures/Account.ts
16
+ import { Transaction } from "@mentaproject/transactions";
47
17
  import { toHex } from "@mentaproject/core/utils";
48
18
  import { getContractType } from "@mentaproject/contracts";
49
19
 
@@ -133,22 +103,23 @@ var Account = class {
133
103
  return await getContractType(this.client.rpc, this.address);
134
104
  }
135
105
  /**
136
- * Creates an Action to send ETH to this account.
106
+ * Creates a Transaction to send ETH to this account.
137
107
  *
138
108
  * @param amount The amount of ETH to send, in wei.
139
- * @returns An Action with .call(), .simulate(), and .execute() methods.
109
+ * @returns A Transaction with .call(), .simulate(), and .execute() methods.
140
110
  *
141
111
  * @example
142
112
  * ```ts
143
113
  * // Direct execution
144
- * await account.sendEth(parseEther("1")).execute();
114
+ * const pending = await account.sendEth(parseEther("1")).execute();
115
+ * const receipt = await pending.confirm();
145
116
  *
146
- * // Batch with TransactionBuilder
147
- * builder.addCall(account.sendEth(parseEther("1")));
117
+ * // Batch with MulticallTransaction
118
+ * multicall.addCall(account.sendEth(parseEther("1")));
148
119
  * ```
149
120
  */
150
121
  sendEth(amount) {
151
- return new Action(this.client.rpc, {
122
+ return new Transaction(this.client.rpc, {
152
123
  to: this.address,
153
124
  value: amount
154
125
  });
@@ -228,7 +199,7 @@ var Account = class {
228
199
  // src/structures/Transaction.ts
229
200
  import { getBlock, getTransactionReceipt, traceTransaction, waitForTransactionReceipt } from "@mentaproject/core/actions";
230
201
  import { hexToBigInt } from "@mentaproject/core/utils";
231
- var Transaction = class {
202
+ var Transaction2 = class {
232
203
  /**
233
204
  * Creates an instance of Transaction.
234
205
  * @description Initializes a new Transaction instance with the provided RPC client and transaction data.
@@ -372,7 +343,7 @@ var Block = class {
372
343
  this.withdrawalsRoot = data.withdrawalsRoot;
373
344
  this.miner = new Account(this.client, { address: data.miner });
374
345
  if (!data.transactions || data.transactions.length === 0) {
375
- const parsed = data.transactions.map((data2) => typeof data2 === "string" ? data2 : new Transaction(this.client, data2));
346
+ const parsed = data.transactions.map((data2) => typeof data2 === "string" ? data2 : new Transaction2(this.client, data2));
376
347
  this.transactions = parsed;
377
348
  }
378
349
  }
@@ -446,6 +417,7 @@ var BlockManager = class {
446
417
  };
447
418
 
448
419
  // src/managers/TransactionManager.ts
420
+ import { MulticallTransaction } from "@mentaproject/transactions";
449
421
  import { getTransaction, sendTransaction } from "@mentaproject/core/actions";
450
422
 
451
423
  // src/utils/bigint.ts
@@ -502,36 +474,49 @@ function parseBingints(obj) {
502
474
 
503
475
  // src/managers/TransactionManager.ts
504
476
  var TransactionManager = class {
505
- /**
506
- * Creates an instance of `TransactionManager`.
507
- * @constructor
508
- * @param {MentaClient} client - The instance of MentaClient used to interact with the blockchain.
509
- */
510
477
  constructor(client) {
511
478
  this.client = client;
512
479
  }
513
480
  /**
514
- * Retrieves a transaction by its hash or block number and index.
515
- * @description This method fetches detailed information about a specific transaction
516
- * from the blockchain using the provided parameters.
517
- * @param {GetTransactionParameters} params - The parameters for retrieving the transaction,
518
- * typically including `hash` or `blockNumber` and `index`.
519
- * @returns {Promise<Transaction>} A promise that resolves to a {@link Transaction} instance
520
- * containing the retrieved transaction data.
481
+ * Creates a new MulticallTransaction for batching multiple calls.
482
+ *
483
+ * @returns A MulticallTransaction builder
484
+ *
521
485
  * @example
522
- * const txHash = '0x...'; // Replace with a valid transaction hash
523
- * const transaction = await client.transactions.get({ hash: txHash });
524
- * console.log(transaction);
486
+ * ```ts
487
+ * const pending = await client.transactions.create()
488
+ * .addCall(account.sendEth(parseEther("1")))
489
+ * .addCall(erc20.transfer(to, amount))
490
+ * .execute();
491
+ * ```
492
+ */
493
+ create() {
494
+ return new MulticallTransaction(this.client.rpc);
495
+ }
496
+ /**
497
+ * Retrieves a rich transaction by its hash.
498
+ *
499
+ * @param hash - The transaction hash
500
+ * @returns A rich Transaction with receipt, block, etc.
501
+ *
502
+ * @example
503
+ * ```ts
504
+ * const tx = await client.transactions.fromHash(hash);
505
+ * console.log(tx.from, tx.to, tx.value);
506
+ * ```
507
+ */
508
+ async fromHash(hash) {
509
+ return this.get({ hash });
510
+ }
511
+ /**
512
+ * Retrieves a transaction by its hash or block number and index.
525
513
  */
526
514
  async get(params) {
527
515
  const data = await getTransaction(this.client.rpc, params);
528
- return new Transaction(this.client, data);
516
+ return new Transaction2(this.client, data);
529
517
  }
530
518
  /**
531
519
  * Parse a transaction object from a JSON converted transaction data object.
532
- *
533
- * @param {J} data - The JSON converted transaction data object.
534
- * @returns {Transaction} A Transaction instance representing the parsed transaction.
535
520
  */
536
521
  parse(data) {
537
522
  const parsed = parseBingints(data);
@@ -540,32 +525,11 @@ var TransactionManager = class {
540
525
  from: parsed.from.address,
541
526
  to: parsed.to ? parsed.to.address : null
542
527
  };
543
- return new Transaction(this.client, rawData);
528
+ return new Transaction2(this.client, rawData);
544
529
  }
545
530
  /**
546
531
  * Sends a transaction to the blockchain network.
547
- * @description This method submits a new transaction to the blockchain. After the transaction
548
- * is successfully sent, it retrieves and returns the full transaction details.
549
- * @param {SendTransactionParameters} params - The parameters required to send the transaction,
550
- * such as `to`, `value`, `data`, `gasLimit`, etc.
551
- * @returns {Promise<Transaction>} A promise that resolves to a {@link Transaction} instance
552
- * representing the sent transaction, including its hash and other details.
553
- * @example
554
- * import { MentaClient } from '@mentaproject/client';
555
- * import { http } from '@mentaproject/core';
556
- *
557
- * // This example assumes you have an account with funds, which is available to the client.
558
- * const client = new MentaClient({
559
- * chain: 'mainnet',
560
- * transport: http('http://rpcurlhere.com')
561
- * });
562
- *
563
- * const transactionResult = await client.transactions.send({
564
- * to: '0xRecipientAddress...', // Replace with a valid recipient address
565
- * value: 1000000000000000000n, // 1 ETH in wei
566
- * });
567
- *
568
- * console.log('Transaction sent with hash:', transactionResult.hash);
532
+ * @deprecated Use client.transactions.create() for new transactions
569
533
  */
570
534
  async send(params) {
571
535
  const hash = await sendTransaction(this.client.rpc, params);
@@ -960,13 +924,12 @@ var MemoryCache = class {
960
924
  export {
961
925
  Account,
962
926
  AccountManager,
963
- Action,
964
927
  Block,
965
928
  BlockManager,
966
929
  ContractManager,
967
930
  MemoryCache,
968
931
  MentaClient,
969
- Transaction,
932
+ Transaction2 as Transaction,
970
933
  TransactionManager,
971
934
  bigIntMax,
972
935
  bigIntMin,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/structures/Account.ts","../src/structures/Action.ts","../src/utils/toJSON.ts","../src/structures/Transaction.ts","../src/structures/Block.ts","../src/structures/MentaClient.ts","../src/managers/BlockManager.ts","../src/managers/TransactionManager.ts","../src/utils/bigint.ts","../src/managers/ContractManager.ts","../src/managers/AccountManager.ts","../src/managers/PersistenceManager.ts","../src/types/MentaClient.ts","../src/utils/withCache.ts","../src/structures/Cache.ts"],"sourcesContent":["import {\n fetchByBlockRange,\n getBalance,\n getBlockNumber,\n getCode,\n getTransactionCount,\n traceFilter,\n} from \"@mentaproject/core/actions\";\nimport type {\n Address,\n Hash,\n onBlockRangeCallback,\n} from \"@mentaproject/core/types\";\nimport { Transaction } from \"./Transaction\";\nimport { Action } from \"./Action\";\nimport { toHex } from \"@mentaproject/core/utils\";\nimport {\n AccountData,\n FetchTransactionParams,\n GetTransactionsParams,\n JSONAccount,\n} from \"../types/Account\";\nimport { getContractType } from \"@mentaproject/contracts\";\nimport { toJSON } from \"../utils/toJSON\";\nimport { PersistenceManager } from \"../managers/PersistenceManager\";\nimport { MentaClient } from \"./MentaClient\";\n\n/**\n * Represents a blockchain account with functionalities to interact with the Menta blockchain.\n */\nexport class Account implements AccountData {\n public address: Address;\n private persistenceManager?: PersistenceManager;\n\n constructor(\n public client: MentaClient,\n data: AccountData,\n persistenceManager?: PersistenceManager,\n ) {\n this.address = data.address;\n this.persistenceManager = persistenceManager;\n }\n\n async isContract(): Promise<boolean> {\n const code = await getCode(this.client.rpc, { address: this.address });\n if (!code || code === \"0x\") return false;\n return true;\n }\n\n async contractType(): Promise<any> {\n const isContract = await this.isContract();\n if (!isContract) return undefined;\n return await getContractType(this.client.rpc, this.address);\n }\n\n /**\n * Creates an Action to send ETH to this account.\n *\n * @param amount The amount of ETH to send, in wei.\n * @returns An Action with .call(), .simulate(), and .execute() methods.\n *\n * @example\n * ```ts\n * // Direct execution\n * await account.sendEth(parseEther(\"1\")).execute();\n *\n * // Batch with TransactionBuilder\n * builder.addCall(account.sendEth(parseEther(\"1\")));\n * ```\n */\n sendEth(amount: bigint): Action {\n return new Action(this.client.rpc, {\n to: this.address,\n value: amount,\n });\n }\n\n async ETHBalance(): Promise<bigint> {\n return await getBalance(this.client.rpc, { address: this.address });\n }\n\n async transactionCount(): Promise<number> {\n return await getTransactionCount(this.client.rpc, { address: this.address });\n }\n\n async transactions(\n params: GetTransactionsParams,\n forceFetch = false,\n ): Promise<Transaction[]> {\n if (!this.persistenceManager || forceFetch) {\n const hashes = await this._fetchTransactions(params);\n const transactions = await Promise.all(\n hashes.map((hash) => this.client.transactions.get({ hash })),\n );\n return transactions;\n }\n\n const jsons = await this.persistenceManager.getTransactions(\n this.address,\n params,\n );\n return jsons.map((j) => this.client.transactions.parse(j));\n }\n\n async syncTransactions(limit: number = 1000): Promise<void> {\n if (!this.persistenceManager)\n throw new Error(\"The persistence module is not configured.\");\n await this.persistenceManager.syncTransactions(this, limit);\n }\n\n async tokenTransactions(tokenAddress: Address): Promise<any> {\n if (!this.persistenceManager)\n throw new Error(\"The persistence module is not configured.\");\n return {};\n }\n\n async toJSON<D extends number = 1>(depth: D): Promise<JSONAccount<D>> {\n return await toJSON({\n obj: {\n address: this.address,\n isContract: this.isContract.bind(this),\n contractType: this.contractType.bind(this),\n ETHBalance: this.ETHBalance.bind(this),\n transactionCount: this.transactionCount.bind(this),\n },\n depth,\n });\n }\n\n protected async _fetchTransactions({\n fromBlock,\n toBlock,\n limit = 50,\n }: FetchTransactionParams): Promise<Hash[]> {\n const lastBlock = await getBlockNumber(this.client.rpc);\n\n const onBlockRange: onBlockRangeCallback = async (\n { fromBlock, toBlock },\n stop,\n ) => {\n const outgoing = await traceFilter(this.client.rpc, {\n fromBlock: toHex(fromBlock),\n toBlock: toHex(toBlock),\n fromAddress: this.address,\n });\n\n const incoming = await traceFilter(this.client.rpc, {\n fromBlock: toHex(fromBlock),\n toBlock: toHex(toBlock),\n toAddress: this.address,\n });\n\n const traces = outgoing\n .concat(incoming)\n .sort((a, b) => a.blockNumber - b.blockNumber);\n\n return traces.map((t) => t.transactionHash as Hash);\n };\n\n return await fetchByBlockRange({\n toBlock: BigInt(toBlock !== undefined ? toBlock : 0),\n fromBlock: BigInt(fromBlock !== undefined ? fromBlock : lastBlock),\n direction: \"backward\",\n itemLimit: limit,\n onBlockRange,\n });\n }\n}\n","import { Call, Hex } from \"@mentaproject/core\";\nimport { MentaAccountClient } from \"@mentaproject/core/types\";\nimport { simulateCalls } from \"@mentaproject/core/actions\";\n\n/**\n * Generic action object that wraps a single call.\n *\n * Provides `.call()` for batching with TransactionBuilder\n * and `.execute()` for direct execution.\n *\n * @example\n * ```ts\n * // Direct execution\n * await account.sendEth(parseEther(\"1\")).execute();\n *\n * // Batching with TransactionBuilder\n * new TransactionBuilder(client.rpc)\n * .addCall(account.sendEth(parseEther(\"1\")))\n * .addCall(token.transfer(to, amount))\n * .execute();\n * ```\n */\nexport class Action {\n constructor(\n private client: MentaAccountClient,\n private _call: Call,\n ) {}\n\n /**\n * Returns the Call object for use with TransactionBuilder.\n */\n call(): Call {\n return this._call;\n }\n\n /**\n * Simulates the action without executing.\n */\n async simulate() {\n return simulateCalls(this.client, { calls: [this._call] });\n }\n\n /**\n * Executes the action directly.\n *\n * @returns Transaction hash\n */\n async execute(): Promise<Hex> {\n return this.client.sendTransaction(this._call as any);\n }\n}\n","/**\n * @module toJSON\n */\n\n/**\n * Interface for parameters passed to the toJSON function.\n * @template T The type of the object to be converted to JSON.\n */\nexport interface IToJSONParams<T extends { [key: string]: any } = { [key: string]: any }> {\n /** The object to convert. */\n obj: T;\n /** The depth for recursive conversion. Defaults to 0. */\n depth?: number;\n}\n\n/**\n * Checks if an object is a class instance (not a native JavaScript object like Array, Date, etc.).\n * @param {any} obj The object to check.\n * @returns {boolean} True if the object is a class instance, false otherwise.\n */\nfunction isClassInstance(obj: any): boolean {\n if (!obj) return false;\n\n const constructor = obj.constructor;\n const nativeConstructors = [Array, Date, RegExp, Map, Set, Promise, Function, Number, String, Boolean, Error, Object];\n\n if (nativeConstructors.includes(constructor)) {\n return false;\n }\n\n return true\n};\n\n/**\n * Recursively converts BigInt values in an object to strings.\n * @param {any} obj The object to convert.\n * @returns {any} The object with BigInts converted to strings.\n */\nfunction convertBigintsToStrings(obj: any): any {\n if (typeof obj === 'bigint') {\n return obj.toString() + \"n\";\n }\n\n if (typeof obj === 'object') {\n for (const key in obj) {\n obj[key] = convertBigintsToStrings(obj[key]);\n }\n }\n\n if (Array.isArray(obj)) {\n for (let i = 0; i < obj.length; i++) {\n obj[i] = convertBigintsToStrings(obj[i]);\n }\n }\n\n return obj;\n}\n\n/**\n * Converts an object, including its nested class instances and getter methods, into a plain JSON object.\n * BigInt values are converted to strings.\n *\n * @param params - The parameters for conversion.\n * @param params.obj - The object to convert.\n * @param [params.depth=0] - The depth for recursive conversion. Defaults to 0.\n * @returns A promise that resolves to the JSON representation of the object.\n */\nexport async function toJSON({ obj, depth = 0 }: IToJSONParams) {\n const data: any = {};\n const promises: Promise<any>[] = [];\n\n for (const key in obj) {\n // skip class related properties\n if (key === \"toJSON\" || key === \"constructor\" || key === \"client\" || key === \"persistenceManager\") continue;\n\n const prop: any = obj[key];\n\n if (typeof prop === \"function\") {\n // do not fetch getters if depth is 0\n if (depth === 0) continue;\n\n const promise = async () => {\n const value = await obj[key]();\n\n // if the value is a class instance, convert it to JSON recursively\n if (typeof value === \"object\" && isClassInstance(value)) return data[key] = await toJSON({ obj: value, depth: depth - 1 });\n\n data[key] = value;\n };\n\n promises.push(promise());\n };\n\n if (typeof prop === \"object\" && isClassInstance(prop)) {\n // If depth is 0, just flatten the object using recursion\n if (depth === 0) {\n const promise = async () => {\n data[key] = await toJSON({\n obj: prop,\n depth: depth - 1\n });\n };\n promises.push(promise());\n\n continue;\n };\n \n // If depth is not 0, fetch the object\n const promise = async () => {\n data[key] = await prop.toJSON({ depth: depth - 1 });\n };\n promises.push(promise());\n\n continue;\n };\n\n data[key] = prop;\n };\n\n await Promise.all(promises);\n\n return convertBigintsToStrings(data);\n};","import { AccessList, Address, Hash, Hex, Transaction as RawTransaction, WaitForTransactionReceiptReturnType } from '@mentaproject/core/types';\nimport { getBlock, getTransactionReceipt, traceTransaction, waitForTransactionReceipt } from '@mentaproject/core/actions';\nimport { hexToBigInt } from '@mentaproject/core/utils';\nimport { TransactionReceiptNotFoundError } from 'viem';\n\nimport { Account } from './Account';\nimport { Block } from './Block';\nimport { MentaClient } from './MentaClient';\n\nimport { toJSON } from '../utils/toJSON';\nimport { JSONTransaction, TransactionCall } from '../types';\n\n/**\n * Represents a blockchain transaction with its properties and methods.\n *\n * @description This class encapsulates the data and functionalities related to an Ethereum-like transaction,\n * providing methods to interact with the blockchain to retrieve transaction-related information such as\n * internal calls, receipts, and the block it belongs to.\n */\nexport class Transaction implements Omit<RawTransaction, \"from\" | \"to\"> {\n /**\n * @description The access list for the transaction.\n */\n public accessList?: AccessList;\n /**\n * @description The blob versioned hashes.\n */\n public blobVersionedHashes?: readonly Hex[];\n /**\n * @description The gas limit for the transaction.\n */\n public gas: bigint;\n /**\n * @description The gas price for the transaction.\n */\n public gasPrice?: bigint;\n /**\n * @description The hash of the transaction.\n */\n public hash: Hash;\n /**\n * @description The input data for the transaction.\n */\n public input: Hex;\n /**\n * @description The maximum fee per gas.\n */\n public maxFeePerGas?: bigint;\n /**\n * @description The maximum priority fee per gas.\n */\n public maxPriorityFeePerGas?: bigint;\n /**\n * @description The nonce of the transaction.\n */\n public nonce: number;\n /**\n * @description The r value of the signature.\n */\n public r: Hex;\n /**\n * @description The s value of the signature.\n */\n public s: Hex;\n /**\n * @description The index of the transaction within the block.\n */\n public transactionIndex: number | null;\n /**\n * @description The type of the transaction.\n */\n public type: \"legacy\" | \"eip2930\" | \"eip1559\" | \"eip4844\" | \"eip7702\";\n /**\n * @description The v value of the signature.\n */\n public v: bigint;\n /**\n * @description The value transferred in the transaction.\n */\n public value: bigint;\n /**\n * @description The y parity of the signature.\n */\n public yParity?: number;\n /**\n * @description The hash of the block containing this transaction.\n */\n public blockHash: Hash | null;\n /**\n * @description The number of the block containing this transaction.\n */\n public blockNumber: bigint | null;\n /**\n * @description The hex representation of the type of the transaction.\n */\n public typeHex: `0x${string}` | null;\n\n /**\n * @description The sender account of the transaction.\n */\n public from?: Account;\n /**\n * @description The recipient account of the transaction.\n */\n public to?: Account;\n\n\n /**\n * Creates an instance of Transaction.\n * @description Initializes a new Transaction instance with the provided RPC client and transaction data.\n * @param {MentaClient} client - The instance of MentaClient used to interact with the blockchain.\n * @param {ITransactionData} data The raw transaction data.\n */\n constructor(protected client: MentaClient, data: RawTransaction) {\n this.accessList = data.accessList;\n this.blobVersionedHashes = data.blobVersionedHashes;\n this.gas = data.gas;\n this.gasPrice = data.gasPrice;\n this.hash = data.hash;\n this.input = data.input;\n this.maxFeePerGas = data.maxFeePerGas;\n this.maxPriorityFeePerGas = data.maxPriorityFeePerGas;\n this.nonce = data.nonce;\n this.r = data.r;\n this.s = data.s;\n this.transactionIndex = data.transactionIndex;\n this.type = data.type;\n this.v = data.v;\n this.value = data.value;\n this.yParity = data.yParity;\n this.blockHash = data.blockHash;\n this.blockNumber = data.blockNumber;\n this.typeHex = data.typeHex;\n\n this.from = data.from ? this.client.accounts.get(data.from) : undefined;\n this.to = data.to ? this.client.accounts.get(data.to) : undefined;\n };\n\n /**\n * Retrieves the internal calls made by this transaction.\n * @description Fetches and processes the transaction traces to extract internal call details.\n * @returns {Promise<TransactionCall[] | undefined>} A promise that resolves to an array of call objects, each representing an internal call with sender, recipient, value, input data, gas used, and call type.\n */\n public async calls(): Promise<TransactionCall[] | undefined> {\n const traces = await traceTransaction(this.client.rpc, this.hash);\n if (!traces) return undefined;\n\n const calls = traces.filter(t => t.type === \"call\" && t.action !== undefined);\n\n return calls.map(c => ({\n from: new Account(this.client, { address: c.action!.from as Address }),\n to: new Account(this.client, { address: c.action!.to as Address }),\n value: hexToBigInt(c.action!.value as Hex),\n input: c.action!.input as Hex,\n gas: hexToBigInt(c.action!.gas as Hex),\n callType: c.action!.callType,\n })) as TransactionCall[];\n }\n\n /**\n * Waits for the transaction receipt to be available.\n * @description Asynchronously waits for the transaction to be confirmed on the blockchain and its receipt to be available.\n * @param {number} [confirmations] The number of confirmations to wait for. Defaults to 1.\n * @returns {Promise<WaitForTransactionReceiptReturnType>} A promise that resolves to the transaction receipt once the specified number of confirmations are met.\n */\n async waitForReceipt(confirmations?: number): Promise<WaitForTransactionReceiptReturnType> {\n return await waitForTransactionReceipt(this.client.rpc, {\n hash: this.hash,\n confirmations: confirmations || 1,\n });\n };\n\n /**\n * Retrieves the transaction receipt.\n * @description Fetches the transaction receipt for the current transaction hash.\n * @returns {Promise<WaitForTransactionReceiptReturnType>} A promise that resolves to the transaction receipt.\n */\n async receipt(): Promise<WaitForTransactionReceiptReturnType | undefined> {\n try {\n return await getTransactionReceipt(this.client.rpc, { hash: this.hash });\n } catch (error) {\n if (error instanceof TransactionReceiptNotFoundError) {\n return undefined;\n }\n }\n };\n\n /**\n * Retrieves the block containing this transaction.\n * @description Fetches the block data using the transaction's block hash and returns a Block instance.\n * @returns {Promise<Block>} A promise that resolves to a Block instance representing the block that includes this transaction.\n */\n async block(): Promise<Block> {\n const data = await getBlock(this.client.rpc, { blockHash: this.blockHash! });\n return new Block(this.client, data);\n };\n\n /**\n * Converts the Transaction instance to a JSON representation.\n * @description Serializes the transaction instance into a JSON object, including nested representations of related entities like block, receipt, and internal calls based on the specified depth.\n * @param {number} [depth=1] The depth of the conversion. Controls how deeply nested objects are serialized.\n * @returns {Promise<object>} A promise that resolves to the JSON representation of the transaction.\n */\n async toJSON<D extends number = 1>(depth: D): Promise<JSONTransaction<D>> {\n return await toJSON({\n obj: {\n ...this,\n block: this.block,\n receipt: this.receipt,\n calls: async () => {\n const calls = await this.calls();\n if (!calls) return undefined;\n\n return Promise.all(calls.map(async c => await toJSON({ obj: c, depth: depth })));\n }\n },\n depth\n });\n }\n};","import { Block as RawBlock, Hash, Hex, Withdrawal } from \"@mentaproject/core\";\n\nimport { Account } from \"./Account\";\nimport { Transaction } from \"./Transaction\";\nimport { JSONBlock } from \"../types/Block\";\nimport { toJSON } from \"../utils/toJSON\";\nimport { MentaClient } from \"./MentaClient\";\n\n/**\n * @description Represents a blockchain block with its properties and methods.\n * This class provides a structured way to access block-related data and interact with the blockchain client.\n */\nexport class Block implements Omit<RawBlock, \"miner\" | \"transactions\"> {\n /**\n * @description The base fee per gas for the block.\n */\n baseFeePerGas: bigint | null\n /**\n * @description The gas used for blobs in the block.\n */\n blobGasUsed: bigint\n /**\n * @description The block's difficulty.\n */\n difficulty: bigint\n /**\n * @description The excess blob gas in the block.\n */\n excessBlobGas: bigint\n /**\n * @description Extra data included in the block.\n */\n extraData: Hex\n /**\n * @description The gas limit for the block.\n */\n gasLimit: bigint\n /**\n * @description The gas used in the block.\n */\n gasUsed: bigint\n /**\n * @description The hash of the block.\n */\n hash: Hash | null\n /**\n * @description The logs bloom filter for the block.\n */\n logsBloom: Hex | null\n /**\n * @description The mix hash of the block.\n */\n mixHash: Hash\n /**\n * @description The nonce of the block.\n */\n nonce: Hex | null\n /**\n * @description The block number.\n */\n number: bigint | null\n /**\n * @description The parent beacon block root.\n */\n parentBeaconBlockRoot?: Hex\n /**\n * @description The hash of the parent block.\n */\n parentHash: Hash\n /**\n * @description The root of the receipts trie.\n */\n receiptsRoot: Hex\n /**\n * @description The seal fields of the block.\n */\n sealFields: Hex[]\n /**\n * @description The SHA3 uncles hash.\n */\n sha3Uncles: Hash\n /**\n * @description The size of the block in bytes.\n */\n size: bigint\n /**\n * @description The state root of the block.\n */\n stateRoot: Hash\n /**\n * @description The timestamp of the block.\n */\n timestamp: bigint\n /**\n * @description The total difficulty of the chain up to this block.\n */\n totalDifficulty: bigint | null\n /**\n * @description The root of the transactions trie.\n */\n transactionsRoot: Hash\n /**\n * @description The list of uncle hashes.\n */\n uncles: Hash[]\n /**\n * @description The list of withdrawals.\n */\n withdrawals?: Withdrawal[]\n /**\n * @description The root of the withdrawals trie.\n */\n withdrawalsRoot?: Hex\n\n /**\n * @description The miner of the block, represented as an Account instance.\n */\n miner: Account\n /**\n * @description The transactions included in the block, represented as an array of Transaction instances.\n */\n transactions?: Transaction[] | Hash[]\n\n /**\n * @description Creates an instance of Block.\n * @param client - The instance of MentaClient used to interact with the blockchain.\n * @param data The raw block data conforming to IBlockData.\n * @param includeTransactions Whether to include full transaction objects. Defaults to false.\n */\n constructor(public client: MentaClient, data: RawBlock) {\n this.baseFeePerGas = data.baseFeePerGas;\n this.blobGasUsed = data.blobGasUsed;\n this.difficulty = data.difficulty;\n this.excessBlobGas = data.excessBlobGas;\n this.extraData = data.extraData;\n this.gasLimit = data.gasLimit;\n this.gasUsed = data.gasUsed;\n this.hash = data.hash;\n this.logsBloom = data.logsBloom;\n this.mixHash = data.mixHash;\n this.nonce = data.nonce;\n this.number = data.number;\n this.parentBeaconBlockRoot = data.parentBeaconBlockRoot;\n this.parentHash = data.parentHash;\n this.receiptsRoot = data.receiptsRoot;\n this.sealFields = data.sealFields;\n this.sha3Uncles = data.sha3Uncles;\n this.size = data.size;\n this.stateRoot = data.stateRoot;\n this.timestamp = data.timestamp;\n this.totalDifficulty = data.totalDifficulty;\n this.transactionsRoot = data.transactionsRoot;\n this.uncles = data.uncles;\n this.withdrawals = data.withdrawals;\n this.withdrawalsRoot = data.withdrawalsRoot;\n\n this.miner = new Account(this.client, { address: data.miner});\n \n if (!data.transactions || data.transactions.length === 0) {\n const parsed = data.transactions.map((data) => typeof data === \"string\" ? data : new Transaction(this.client, data))\n this.transactions = parsed as Transaction[] | Hash[];\n }\n };\n\n protected includeTransactions(): this is this & { transactions: Transaction[] } {\n if (!this.transactions || this.transactions.length === 0) return false;\n return true\n }\n\n /**\n * @description Converts the Block instance to a JSON representation.\n * This method serializes the block's properties into a plain JavaScript object,\n * suitable for JSON serialization.\n * @param depth The depth of the conversion. Defaults to 1.\n * @returns A promise that resolves to the JSON representation of the block.\n */\n async toJSON<D extends number = 1>(depth: D): Promise<JSONBlock<D>> {\n return await toJSON({\n obj: {\n ...this,\n },\n depth\n });\n }\n};","/**\n * @module MentaClient\n */\nimport type { MentaAccountClient } from \"@mentaproject/core/types\";\nimport { createMentaAccount } from \"@mentaproject/core/clients\";\nimport { createClient } from \"@mentaproject/core\";\n\nimport { BlockManager } from \"../managers/BlockManager\";\nimport { TransactionManager } from \"../managers/TransactionManager\";\nimport { ContractManager } from \"../managers/ContractManager\";\nimport { AccountManager } from \"../managers/AccountManager\";\nimport { PersistenceManager } from \"../managers/PersistenceManager\";\nimport {\n ClientEvents,\n GetListenerCallback,\n MentaClientConfig,\n} from \"../types/MentaClient\";\nimport { withCache } from \"../utils/withCache\";\nimport { Account } from \"./Account\";\n\n/**\n * The main client for interacting with the Menta API.\n * It provides managers for blocks, transactions, contracts, and accounts.\n *\n * @description This class serves as the primary entry point for interacting with the Menta blockchain.\n * It encapsulates the core RPC client and provides specialized managers for various blockchain entities,\n * simplifying common operations.\n */\nexport class MentaClient {\n protected _rpc?: MentaAccountClient;\n protected _account?: Account;\n /**\n * The underlying RPC client used for blockchain interactions.\n * @description This client is responsible for low-level communication with the RPC node.\n */\n public get rpc(): MentaAccountClient {\n if (!this._rpc) {\n throw new Error(\"RPC client not initialized\");\n }\n return this._rpc;\n }\n\n /**\n * The account associated with the client.\n * @description This account is used for signing transactions and interacting with the blockchain.\n */\n public get account(): Account {\n if (!this._account) {\n throw new Error(\"Account not initialized\");\n }\n return this._account;\n }\n\n /**\n * Manager for block-related operations.\n * @description Provides methods to query and interact with blockchain blocks.\n */\n public blocks!: BlockManager;\n /**\n * Manager for transaction-related operations.\n * @description Provides methods to send, query, and manage blockchain transactions.\n */\n public transactions!: TransactionManager;\n /**\n * Manager for contract-related operations.\n * @description Provides methods to deploy, interact with, and query smart contracts.\n */\n public contracts!: ContractManager;\n /**\n * Manager for account-related operations.\n * @description Provides methods to manage and interact with blockchain accounts.\n */\n public accounts!: AccountManager;\n\n /**\n * Subscribes to a specific client event.\n * @template TEvent The type of the event to listen for.\n * @param {TEvent} event - The event to listen for (e.g., 'block', 'transaction').\n * @param {GetListenerCallback<TEvent>} callback - The callback function to execute when the event is triggered.\n * @returns {() => void} An unsubscribe function to stop listening to the event.\n * @description This method allows the client to listen for real-time events from the blockchain, such as new blocks or transactions.\n * @example\n * import { MentaClient } from '@mentaproject/client';\n *\n * const client = new MentaClient({ url: 'http://rpcurlhere.com' });\n *\n * // Subscribe to new blocks\n * const unsubscribe = client.on('block', (block) => {\n * console.log('New block received:', block);\n * });\n *\n * // To stop listening\n * // unsubscribe();\n */\n on<TEvent extends keyof typeof ClientEvents>(\n event: TEvent,\n callback: GetListenerCallback<TEvent>,\n ) {\n const eventFunction = ClientEvents[event];\n const capitalizedEvent = event.charAt(0).toUpperCase() + event.slice(1);\n const params = {\n [`on${capitalizedEvent}`]: callback,\n pollingInterval: 1000,\n };\n\n return (eventFunction as any)(this.rpc, params);\n }\n\n /**\n * Creates an instance of MentaClient.\n * @param {MentaClientConfig} params - The configuration parameters for the client.\n * @description The constructor initializes the RPC client and the various managers based on the provided configuration.\n * It also applies caching and persistence if specified in the configuration.\n * @example\n * import { MentaClient } from '@mentaproject/client';\n *\n * // Basic initialization\n * const client = new MentaClient({\n * url: 'http://rpcurlhere.com',\n * });\n *\n * // Initialization with a persistent cache\n * const clientWithCache = new MentaClient({\n * url: 'http://rpcurlhere.com',\n * cache: {\n * ttl: 60000, // 1 minute\n * },\n * });\n */\n constructor(protected params: MentaClientConfig) {\n this.blocks = new BlockManager(this);\n this.transactions = new TransactionManager(this);\n this.contracts = new ContractManager(this);\n\n if (params.persistenceAdapter) {\n this.persistenceManager = new PersistenceManager(\n this,\n params.persistenceAdapter,\n );\n this.accounts = new AccountManager(this, this.persistenceManager);\n } else {\n this.accounts = new AccountManager(this);\n }\n }\n\n async init() {\n let coreClient = createClient(this.params);\n\n if (this.params.cache) {\n coreClient = withCache(coreClient, this.params.cache);\n }\n\n this._rpc = await createMentaAccount(coreClient as any, {\n bundlerTransport: this.params.bundlerTransport,\n publicTransport: this.params.transport,\n signer: this.params.signer,\n validatorAddress: this.params.validatorAddress,\n });\n\n this._account = this.accounts.get(this.rpc.account.address);\n }\n\n /**\n * Optional manager for persistence-related operations.\n * @description This manager is initialized if a persistence adapter is provided in the client configuration,\n * allowing for data storage and retrieval.\n */\n public persistenceManager?: PersistenceManager;\n}\n","/**\n * @module BlockManager\n */\nimport { BlockTag, GetBlockParameters } from \"@mentaproject/core/types\";\nimport { Block } from \"../structures/Block\";\nimport { getBlock } from \"@mentaproject/core/actions\";\nimport { MentaClient } from \"../structures\";\n\n/**\n * Manages blockchain block-related operations, providing methods to interact with and retrieve block data.\n */\nexport class BlockManager {\n /**\n * Creates an instance of BlockManager.\n * @param client - The instance of MentaClient used to interact with the blockchain.\n */\n constructor(public client: MentaClient) {};\n\n /**\n * Retrieves a block from the blockchain based on the provided parameters.\n * This method uses the underlying RPC client to fetch block data and then\n * encapsulates it within a {@link Block} instance.\n * @param params The parameters for retrieving the block, including block hash, block number, or block tag.\n * @returns A promise that resolves to a {@link Block} instance representing the retrieved block.\n * @example\n * import { http } from '@mentaproject/core';\n * import { mainnet } from '@mentaproject/core/chains';\n * import { MentaClient } from '@mentaproject/client';\n *\n * // Initialize the MentaClient\n * const mentaClient = new MentaClient({ chain: mainnet, transport: http(\"http://rpcurlhere.com\") });\n *\n * async function fetchBlock() {\n * // Retrieve the latest block\n * const latestBlock = await mentaClient.blocks.get({ blockTag: 'latest' });\n * console.log('Latest block number:', latestBlock.number);\n *\n * // Retrieve a specific block by its number\n * if (latestBlock.number) {\n * const specificBlock = await mentaClient.blocks.get({ blockNumber: latestBlock.number - 10n });\n * console.log('Specific block hash:', specificBlock.hash);\n * }\n * }\n *\n * fetchBlock();\n */\n async get(params: GetBlockParameters<boolean, BlockTag>): Promise<Block> {\n const data = await getBlock(this.client.rpc, params);\n return new Block(this.client, data);\n };\n}","/**\n * @module TransactionManager\n */\nimport { GetTransactionParameters, Transaction as RawTransaction, SendTransactionParameters } from \"@mentaproject/core/types\";\nimport { Transaction } from \"../structures/Transaction\";\nimport { getTransaction, sendTransaction } from \"@mentaproject/core/actions\";\nimport { MentaClient } from \"../structures\";\nimport { JSONTransaction } from \"../types\";\nimport { parseBingints } from \"../utils/bigint\";\n\n/**\n * Manages blockchain transaction-related operations, providing methods to retrieve and send transactions.\n * @class\n * @description This class provides an interface to interact with blockchain transactions,\n * allowing for retrieval of transaction details and submission of new transactions\n * to the network via an RPC client.\n */\nexport class TransactionManager {\n /**\n * Creates an instance of `TransactionManager`.\n * @constructor\n * @param {MentaClient} client - The instance of MentaClient used to interact with the blockchain.\n */\n constructor(public client: MentaClient) {};\n\n /**\n * Retrieves a transaction by its hash or block number and index.\n * @description This method fetches detailed information about a specific transaction\n * from the blockchain using the provided parameters.\n * @param {GetTransactionParameters} params - The parameters for retrieving the transaction,\n * typically including `hash` or `blockNumber` and `index`.\n * @returns {Promise<Transaction>} A promise that resolves to a {@link Transaction} instance\n * containing the retrieved transaction data.\n * @example\n * const txHash = '0x...'; // Replace with a valid transaction hash\n * const transaction = await client.transactions.get({ hash: txHash });\n * console.log(transaction);\n */\n async get(params: GetTransactionParameters): Promise<Transaction> {\n const data = await getTransaction(this.client.rpc, params);\n return new Transaction(this.client, data);\n };\n\n /**\n * Parse a transaction object from a JSON converted transaction data object.\n * \n * @param {J} data - The JSON converted transaction data object.\n * @returns {Transaction} A Transaction instance representing the parsed transaction.\n */\n parse<J extends JSONTransaction<0>>(data: J): Transaction {\n const parsed = parseBingints(data);\n\n const rawData = {\n ...parsed,\n from: parsed.from.address,\n to: parsed.to ? parsed.to.address : null,\n };\n \n return new Transaction(this.client, rawData as RawTransaction);\n };\n\n /**\n * Sends a transaction to the blockchain network.\n * @description This method submits a new transaction to the blockchain. After the transaction\n * is successfully sent, it retrieves and returns the full transaction details.\n * @param {SendTransactionParameters} params - The parameters required to send the transaction,\n * such as `to`, `value`, `data`, `gasLimit`, etc.\n * @returns {Promise<Transaction>} A promise that resolves to a {@link Transaction} instance\n * representing the sent transaction, including its hash and other details.\n * @example\n * import { MentaClient } from '@mentaproject/client';\n * import { http } from '@mentaproject/core';\n *\n * // This example assumes you have an account with funds, which is available to the client.\n * const client = new MentaClient({\n * chain: 'mainnet',\n * transport: http('http://rpcurlhere.com')\n * });\n *\n * const transactionResult = await client.transactions.send({\n * to: '0xRecipientAddress...', // Replace with a valid recipient address\n * value: 1000000000000000000n, // 1 ETH in wei\n * });\n *\n * console.log('Transaction sent with hash:', transactionResult.hash);\n */\n async send(params: SendTransactionParameters): Promise<Transaction> {\n const hash = await sendTransaction(this.client.rpc, params);\n \n return await this.get({ hash });\n };\n};","import { WithoutBigintStringified } from \"../types/Utils\";\n\nexport const bigIntMax = (...args: bigint[]) => args.reduce((m, e) => e > m ? e : m);\nexport const bigIntMin = (...args: bigint[]) => args.reduce((m, e) => e < m ? e : m);\n\nexport function bigIntReviver(key: string, value: any) {\n if (typeof value === 'string') {\n if (value.endsWith('n')) {\n try {\n return BigInt(value.slice(0, -1));\n } catch (e) {\n return value;\n }\n };\n };\n\n return value;\n};\n\nexport function stringifyBingints(obj: any) {\n if (typeof obj === 'bigint') {\n return obj.toString() + \"n\";\n }\n\n if (typeof obj === 'object') {\n for (const key in obj) {\n obj[key] = stringifyBingints(obj[key]);\n }\n }\n\n if (Array.isArray(obj)) {\n for (let i = 0; i < obj.length; i++) {\n obj[i] = stringifyBingints(obj[i]);\n }\n }\n\n return obj;\n};\n\nexport function parseBingints<T extends { [key: string]: any }>(obj: T): WithoutBigintStringified<T> {\n if (typeof obj !== 'object' || obj === null) {\n return obj;\n }\n\n if (Array.isArray(obj)) {\n return obj.map((item, index) => bigIntReviver(index.toString(), parseBingints(item))) as WithoutBigintStringified<T>;\n }\n\n const newObj: { [key: string]: any } = {};\n for (const key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n const value = obj[key];\n const processedValue = parseBingints(value);\n newObj[key] = bigIntReviver(key, processedValue);\n }\n };\n\n return newObj as WithoutBigintStringified<T>;\n};","/**\n * @module ContractManager\n */\nimport type { AbiItem } from \"@mentaproject/core/types\";\nimport { getContract, GetContractParameters } from \"@mentaproject/contracts\";\nimport { MentaClient } from \"../structures\";\n\n/**\n * Manages smart contract-related operations within the Menta client.\n * This class provides methods to interact with smart contracts deployed on the blockchain,\n * facilitating the retrieval of contract instances for various operations.\n */\nexport class ContractManager {\n /**\n * Creates an instance of ContractManager.\n * @description Initializes the ContractManager with a CoreClient instance, which is used for RPC communication.\n * @param client - The instance of MentaClient used to interact with the blockchain.\n */\n constructor(protected client: MentaClient) {};\n\n /**\n * Retrieves a contract instance to interact with it.\n * @description This method fetches a contract instance based on the provided parameters, allowing for interaction with its methods and events.\n * @template P The type of the contract retrieval parameters, extending `GetContractParameters` with `AbiItem` array.\n * @param {P} params The parameters for retrieving the contract, including its Application Binary Interface (ABI) and address.\n * @returns {ReturnType<typeof getContract<ReadonlyArray<AbiItem>, P>>} A contract instance that can be used to call contract methods or listen to events.\n * @example\n * import { MentaClient } from '@mentaproject/client';\n * import { http } from '@mentaproject/core';\n *\n * // Initialize the MentaClient with a transport\n * const client = new MentaClient({\n * transport: http('http://rpcurlhere.com'),\n * });\n *\n * // Define the ABI and address for the smart contract\n * const abi = [\n * {\n * \"type\": \"function\",\n * \"name\": \"greet\",\n * \"stateMutability\": \"view\",\n * \"inputs\": [],\n * \"outputs\": [{ \"name\": \"\", \"type\": \"string\" }]\n * }\n * ] as const;\n * const contractAddress = '0x...'; // Replace with your contract address\n *\n * // Retrieve the contract instance\n * const contract = client.contracts.get({\n * abi,\n * address: contractAddress,\n * });\n *\n * // Example of interacting with the contract\n * const greeting = await contract.greet();\n */\n get<P extends GetContractParameters<ReadonlyArray<AbiItem>>>(params: P) {\n return getContract(this.client.rpc, params);\n };\n};","/**\n * @module AccountManager\n */\nimport { Address } from \"@mentaproject/core/types\";\nimport { Account } from \"../structures/Account\";\nimport { PersistenceManager } from \"./PersistenceManager\";\nimport { MentaClient } from \"../structures\";\n\n/**\n * Manages blockchain account operations.\n * This class provides methods to interact with accounts,\n * including retrieving and managing them via an RPC client and a persistence manager.\n *\n * @class AccountManager\n */\nexport class AccountManager {\n /**\n * Creates an instance of AccountManager.\n *\n * @param {MentaClient} client - The instance of MentaClient used to interact with the blockchain.\n * @param {persistenceManager} persistenceManager - The optional persistence manager to store and retrieve account data.\n */\n constructor(public client: MentaClient, private persistenceManager?: PersistenceManager) { };\n\n /**\n * Retrieves an account instance by its blockchain address.\n * @param address - The blockchain address of the account to retrieve.\n * @returns An instance of the `Account` class.\n * @example\n * ```typescript\n * import { MentaClient } from '@mentaproject/client';\n * import { http } from '@mentaproject/core';\n *\n * // Initialize the MentaClient\n * const client = new MentaClient({\n * transport: http('http://rpcurlhere.com'),\n * });\n *\n * // The address of the account to retrieve\n * const accountAddress = '0x1234567890123456789012345678901234567890';\n *\n * // Retrieve the account instance using the account manager from the client\n * const account = client.accounts.get(accountAddress);\n *\n * console.log(account.address); // 0x1234567890123456789012345678901234567890\n * ```\n */\n get(address: Address): Account {\n return new Account(this.client, { address: address }, this.persistenceManager);\n };\n}","import { getBlockNumber } from '@mentaproject/core/actions';\nimport { Address } from '@mentaproject/core/types';\n\nimport { Account } from '../structures/Account';\nimport { MentaClient, Transaction } from '../structures';\nimport { bigIntMax } from '../utils/bigint';\nimport { GetTransactionsParams, IPersistenceAdapter, JSONTransaction } from 'src/types';\n\n/**\n * Manages the persistence of data, including transactions, using a specified persistence adapter.\n * It handles fetching data from both local storage and remote sources, and synchronizing them.\n */\nexport class PersistenceManager {\n /**\n * Creates an instance of PersistenceManager.\n * @param client - The instance of MentaClient used to interact with the blockchain.\n * @param persistenceAdapter - The adapter responsible for actual data persistence operations.\n */\n constructor(\n private client: MentaClient,\n private persistenceAdapter: IPersistenceAdapter\n ) {}\n\n /**\n * Retrieves transactions for a given account, applying a \"stale-while-revalidate\" strategy.\n * @param params - Parameters for retrieving transactions.\n * @returns A promise that resolves to an array of transactions with associated account information.\n */\n public async getTransactions(address: Address, params: GetTransactionsParams): Promise<JSONTransaction<0>[]> {\n return await this.persistenceAdapter.getTransactions(address, params);\n }\n\n /**\n * Synchronizes an account's transactions from the remote source to the local persistence.\n * It fetches new transactions starting from the last synced block and updates the local storage.\n * @param account - The account whose transactions are to be synchronized.\n * @param limit - The maximum number of transactions to fetch.\n * @returns A promise that resolves when the synchronization is complete.\n */\n public async syncTransactions(account: Account, limit: number = 100_000): Promise<void> {\n const lastSyncedBlock = await this.persistenceAdapter.getLastSyncedBlock(account.address);\n const lastBlock = lastSyncedBlock ?? 0n;\n\n const fromBlock = lastSyncedBlock ? lastSyncedBlock + 1n : (await getBlockNumber(this.client.rpc));\n\n const newTransactions = await account.transactions({\n fromBlock: fromBlock,\n toBlock: lastBlock,\n limit: limit\n }, true)\n\n if (newTransactions.length > 0) {\n await this.persistenceAdapter.upsertTransactions(newTransactions);\n \n const latestBlock = bigIntMax(...newTransactions.map(t => t.blockNumber || 0n));\n await this.persistenceAdapter.setLastSyncedBlock(account.address, latestBlock);\n }\n }\n}","/**\n * @module MentaClientTypes\n */\nimport { Address, CoreClientConfig, Transport } from \"@mentaproject/core/types\";\nimport { ICache } from \"./Cache\";\nimport { watchBlockNumber, watchBlocks } from \"@mentaproject/core/actions\";\nimport { IPersistenceAdapter } from \"./PersistenceAdapter\";\nimport { WebAuthnAccount } from \"@mentaproject/core/account-abstraction\";\n\n/**\n * Configuration for the client's cache.\n * @interface CacheConfig\n */\nexport interface CacheConfig {\n /**\n * Time-to-live policies for different RPC methods.\n * Keys are RPC method names (e.g., \"eth_getBlockByNumber\"), and values are\n * the TTL in milliseconds for caching responses from those methods.\n */\n ttl_policies: Record<string, number>;\n}\n\n/**\n * Configuration options for the MentaClient.\n * Extends {@link CoreClientConfig} from `@mentaproject/core`.\n * @interface MentaClientConfig\n */\nexport interface MentaClientConfig extends CoreClientConfig {\n /**\n * Optional cache implementation for the client.\n * If provided, the client will use this cache for RPC responses.\n */\n cache?: ICache;\n /**\n * Optional persistence adapter for local data storage.\n * If provided, the client will use this adapter to persist and retrieve data.\n */\n persistenceAdapter?: IPersistenceAdapter;\n /**\n * Bundler transport used for userOperations\n */\n bundlerTransport: Transport;\n /**\n * Passkey compatible signer used for signing user operations\n */\n signer: WebAuthnAccount;\n /**\n * Validator address used for userOperations\n */\n validatorAddress: Address;\n}\n\n/**\n * Defines the available client events and their corresponding watch functions.\n * These functions are used to subscribe to real-time updates from the client.\n */\nexport const ClientEvents = {\n /**\n * Event for new blocks.\n * Uses the {@link watchBlocks} function from `@mentaproject/core`.\n */\n block: watchBlocks,\n /**\n * Event for new block numbers.\n * Uses the {@link watchBlockNumber} function from `@mentaproject/core`.\n */\n blockNumber: watchBlockNumber,\n};\n\n/**\n * Utility type to extract the callback function type for a given event.\n * This type dynamically determines the expected callback signature for a specific client event.\n * @template TEvent The name of the event (e.g., 'block' or 'blockNumber') for which to get the listener callback type.\n */\nexport type GetListenerCallback<TEvent extends keyof typeof ClientEvents> =\n Parameters<(typeof ClientEvents)[TEvent]>[1] extends infer P\n ? P extends { [K in `on${Capitalize<TEvent>}`]: infer TCallback }\n ? TCallback\n : never\n : never;\n","/**\n * @module withCache\n */\nimport { watchBlockNumber } from \"@mentaproject/core/actions\";\nimport type { CoreClient } from \"@mentaproject/core/types\";\nimport { ICache } from \"../types/Cache\";\nimport { Methods } from \"../types/JsonRPC\";\n\n// EntryPoint.getNonce selector - must never be cached to avoid nonce reuse\nconst GET_NONCE_SELECTOR = \"0x35567e1a\";\n\n/**\n * Checks if an eth_call is a getNonce call to the EntryPoint.\n * These calls must not be cached to ensure fresh nonce values for each UserOperation.\n */\nfunction isNonceCall(method: Methods, params: any): boolean {\n if (method !== \"eth_call\") return false;\n const callData = params?.[0]?.data;\n return typeof callData === \"string\" && callData.startsWith(GET_NONCE_SELECTOR);\n}\n\n/**\n * A higher-order function that enhances a class method with caching capabilities.\n * It intercepts RPC requests made through the client and caches their responses\n * based on the provided cache implementation.\n *\n * @param client The CoreClient instance to enhance with caching.\n * @param cache The cache implementation (ICache) to use for storing and retrieving responses.\n * @returns The enhanced CoreClient instance with caching enabled.\n */\nexport function withCache<T extends CoreClient>(client: T, cache: ICache): T {\n watchBlockNumber(client, {\n onBlockNumber: (blockNumber) => {\n cache.setBlockNumber(blockNumber);\n },\n pollingInterval: 1000,\n });\n // 2. We keep a reference to the original request method\n const originalRequest = client.request;\n\n // 3. We replace the client's `request` method\n client.request = (async (args: { method: Methods, params: any }) => {\n const { method, params } = args;\n\n // Never cache nonce calls - they must always return fresh values\n const shouldSkipCache = method === \"eth_blockNumber\" || isNonceCall(method, params);\n\n const cacheKey = `${client.chain!.id}:${method}:${JSON.stringify(params || [], (_, v) => typeof v === 'bigint' ? v.toString() : v)}`;\n\n let result;\n if (!shouldSkipCache) {\n result = cache.get(cacheKey);\n }\n\n if (!result) {\n result = await originalRequest(args as any);\n };\n\n if (result !== null && result !== undefined && !shouldSkipCache) {\n const ttl = cache.config.ttlPolicies[method] || cache.config.defaultTtl;\n await cache.set(cacheKey, result, ttl);\n }\n\n return result;\n }) as any;\n\n return client;\n}\n","/**\n * @module MemoryCache\n */\nimport { ICache, ICacheEntry, ICacheConfig } from '../types/Cache';\n\n/**\n/**\n * @class MemoryCache\n * @description A simple in-memory cache implementation that adheres to the ICache interface.\n * It stores key-value pairs with an associated time-to-live (TTL) based on block numbers.\n * The cache automatically evicts the oldest entries when its maximum size is reached.\n */\nexport class MemoryCache implements ICache {\n /**\n * @property {Map<string, ICacheEntry<any>>} cache - The internal Map used to store cache entries.\n * @private\n */\n private cache = new Map<string, ICacheEntry<any>>();\n /**\n * @property {ICacheConfig} config - The configuration object for the cache, including maxSize, defaultTtl, and ttlPolicies.\n */\n public config: ICacheConfig;\n /**\n * @property {bigint} blockNumber - The current block number used for TTL calculations.\n * @private\n */\n private blockNumber: bigint;\n\n /**\n * @constructor\n * @description Creates an instance of MemoryCache.\n * @param {bigint} blockNumber - The current block number to use for TTL calculations.\n * @param {Partial<ICacheConfig>} [options] - Optional configuration for the cache.\n * @param {number} [options.maxSize=500] - The maximum number of entries the cache can hold.\n * @param {number} [options.defaultTtl=1] - The default time-to-live in blocks for cache entries if not specified.\n * @param {Object.<string, number>} [options.ttlPolicies={}] - A map of specific TTL policies for different keys.\n */\n constructor(blockNumber: bigint, options?: Partial<ICacheConfig>) {\n this.blockNumber = blockNumber;\n this.config = {\n maxSize: 500,\n defaultTtl: 1,\n ttlPolicies: options?.ttlPolicies || {},\n ...options,\n };\n };\n\n /**\n * @method isExpired\n * @description Checks if a cache entry has expired based on the current block number and the entry's expiry block.\n * @param {bigint} expiry - The expiry block number of the cache entry.\n * @returns {boolean} `true` if the entry has expired, `false` otherwise.\n * @protected\n */\n protected isExpired(expiry: bigint): boolean {\n return this.blockNumber > expiry;\n };\n\n /**\n * @method setBlockNumber\n * @description Sets the current block number for TTL calculations. This is crucial for managing cache entry expiry.\n * @param {bigint} blockNumber - The new current block number.\n * @returns {void}\n */\n setBlockNumber(blockNumber: bigint): void {\n this.blockNumber = blockNumber;\n }\n\n /**\n * @method set\n * @description Sets a value in the cache. If the key already exists, its entry will be updated.\n * If the cache reaches its maximum size, the oldest entry will be evicted before adding the new one.\n * @template T - The type of the value being stored.\n * @param {string} key - The unique key for the cache entry.\n * @param {T} value - The value to store in the cache.\n * @param {number} [ttl=this.config.defaultTtl] - The time-to-live (in blocks) for this specific entry. Defaults to the cache's `defaultTtl`.\n * @returns {void}\n */\n set<T>(key: string, value: T, ttl: number = this.config.defaultTtl): void {\n if (this.cache.has(key)) {\n this.cache.delete(key);\n }\n\n if (this.cache.size >= this.config.maxSize) this.evict();\n \n const expiry = this.blockNumber + BigInt(ttl);\n this.cache.set(key, { value, expiry });\n }\n\n /**\n * @method get\n * @description Retrieves a value from the cache. If the entry is found and has not expired,\n * it is moved to the end of the cache (making it the most recently used) to prevent premature eviction.\n * @template T - The expected type of the value.\n * @param {string} key - The key of the cache entry to retrieve.\n * @returns {T | undefined} The cached value if found and not expired, otherwise `undefined`.\n */\n get<T>(key: string): T | undefined {\n const entry = this.cache.get(key);\n if (!entry) return undefined;\n\n if (this.isExpired(entry.expiry)) {\n this.cache.delete(key);\n return undefined;\n }\n\n this.cache.delete(key);\n this.cache.set(key, entry);\n\n return entry.value as T;\n }\n\n /**\n * @method evict\n * @description Evicts the oldest entry from the cache. This method is called internally when the cache\n * reaches its `maxSize` to make room for new entries.\n * @returns {void}\n * @private\n */\n private evict(): void {\n const oldestKey = this.cache.keys().next().value;\n if (!oldestKey) return;\n\n this.cache.delete(oldestKey);\n }\n}"],"mappings":";;;;;;;AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACLP,SAAS,qBAAqB;AAoBvB,IAAM,SAAN,MAAa;AAAA,EAClB,YACU,QACA,OACR;AA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AK,KAAK;AAEzB,WAAO,MAAM;AAAA,EACf;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASO,QAAc;AACpB,UAAM,YAAY,KAAK,MAAM,KAAK,EAAE,KAAK,EAAE;AAC3C,QAAI,CAAC,UAAW;AAEf,SAAK,MAAM,OAAO,SAAS;AAAA,EAC7B;AACF;","names":["promise","fromBlock","toBlock","data","getBlock","getBlockNumber","getBlockNumber","watchBlockNumber"]}
1
+ {"version":3,"sources":["../src/structures/Account.ts","../src/utils/toJSON.ts","../src/structures/Transaction.ts","../src/structures/Block.ts","../src/structures/MentaClient.ts","../src/managers/BlockManager.ts","../src/managers/TransactionManager.ts","../src/utils/bigint.ts","../src/managers/ContractManager.ts","../src/managers/AccountManager.ts","../src/managers/PersistenceManager.ts","../src/types/MentaClient.ts","../src/utils/withCache.ts","../src/structures/Cache.ts"],"sourcesContent":["import {\n fetchByBlockRange,\n getBalance,\n getBlockNumber,\n getCode,\n getTransactionCount,\n traceFilter,\n} from \"@mentaproject/core/actions\";\nimport type {\n Address,\n Hash,\n onBlockRangeCallback,\n} from \"@mentaproject/core/types\";\nimport { Transaction as RichTransaction } from \"./Transaction\";\nimport { Transaction } from \"@mentaproject/transactions\";\nimport { toHex } from \"@mentaproject/core/utils\";\nimport {\n AccountData,\n FetchTransactionParams,\n GetTransactionsParams,\n JSONAccount,\n} from \"../types/Account\";\nimport { getContractType } from \"@mentaproject/contracts\";\nimport { toJSON } from \"../utils/toJSON\";\nimport { PersistenceManager } from \"../managers/PersistenceManager\";\nimport { MentaClient } from \"./MentaClient\";\n\n/**\n * Represents a blockchain account with functionalities to interact with the Menta blockchain.\n */\nexport class Account implements AccountData {\n public address: Address;\n private persistenceManager?: PersistenceManager;\n\n constructor(\n public client: MentaClient,\n data: AccountData,\n persistenceManager?: PersistenceManager,\n ) {\n this.address = data.address;\n this.persistenceManager = persistenceManager;\n }\n\n async isContract(): Promise<boolean> {\n const code = await getCode(this.client.rpc, { address: this.address });\n if (!code || code === \"0x\") return false;\n return true;\n }\n\n async contractType(): Promise<any> {\n const isContract = await this.isContract();\n if (!isContract) return undefined;\n return await getContractType(this.client.rpc, this.address);\n }\n\n /**\n * Creates a Transaction to send ETH to this account.\n *\n * @param amount The amount of ETH to send, in wei.\n * @returns A Transaction with .call(), .simulate(), and .execute() methods.\n *\n * @example\n * ```ts\n * // Direct execution\n * const pending = await account.sendEth(parseEther(\"1\")).execute();\n * const receipt = await pending.confirm();\n *\n * // Batch with MulticallTransaction\n * multicall.addCall(account.sendEth(parseEther(\"1\")));\n * ```\n */\n sendEth(amount: bigint): Transaction {\n return new Transaction(this.client.rpc, {\n to: this.address,\n value: amount,\n });\n }\n\n async ETHBalance(): Promise<bigint> {\n return await getBalance(this.client.rpc, { address: this.address });\n }\n\n async transactionCount(): Promise<number> {\n return await getTransactionCount(this.client.rpc, { address: this.address });\n }\n\n async transactions(\n params: GetTransactionsParams,\n forceFetch = false,\n ): Promise<RichTransaction[]> {\n if (!this.persistenceManager || forceFetch) {\n const hashes = await this._fetchTransactions(params);\n const transactions = await Promise.all(\n hashes.map((hash) => this.client.transactions.get({ hash })),\n );\n return transactions;\n }\n\n const jsons = await this.persistenceManager.getTransactions(\n this.address,\n params,\n );\n return jsons.map((j) => this.client.transactions.parse(j));\n }\n\n async syncTransactions(limit: number = 1000): Promise<void> {\n if (!this.persistenceManager)\n throw new Error(\"The persistence module is not configured.\");\n await this.persistenceManager.syncTransactions(this, limit);\n }\n\n async tokenTransactions(tokenAddress: Address): Promise<any> {\n if (!this.persistenceManager)\n throw new Error(\"The persistence module is not configured.\");\n return {};\n }\n\n async toJSON<D extends number = 1>(depth: D): Promise<JSONAccount<D>> {\n return await toJSON({\n obj: {\n address: this.address,\n isContract: this.isContract.bind(this),\n contractType: this.contractType.bind(this),\n ETHBalance: this.ETHBalance.bind(this),\n transactionCount: this.transactionCount.bind(this),\n },\n depth,\n });\n }\n\n protected async _fetchTransactions({\n fromBlock,\n toBlock,\n limit = 50,\n }: FetchTransactionParams): Promise<Hash[]> {\n const lastBlock = await getBlockNumber(this.client.rpc);\n\n const onBlockRange: onBlockRangeCallback = async (\n { fromBlock, toBlock },\n stop,\n ) => {\n const outgoing = await traceFilter(this.client.rpc, {\n fromBlock: toHex(fromBlock),\n toBlock: toHex(toBlock),\n fromAddress: this.address,\n });\n\n const incoming = await traceFilter(this.client.rpc, {\n fromBlock: toHex(fromBlock),\n toBlock: toHex(toBlock),\n toAddress: this.address,\n });\n\n const traces = outgoing\n .concat(incoming)\n .sort((a, b) => a.blockNumber - b.blockNumber);\n\n return traces.map((t) => t.transactionHash as Hash);\n };\n\n return await fetchByBlockRange({\n toBlock: BigInt(toBlock !== undefined ? toBlock : 0),\n fromBlock: BigInt(fromBlock !== undefined ? fromBlock : lastBlock),\n direction: \"backward\",\n itemLimit: limit,\n onBlockRange,\n });\n }\n}\n","/**\n * @module toJSON\n */\n\n/**\n * Interface for parameters passed to the toJSON function.\n * @template T The type of the object to be converted to JSON.\n */\nexport interface IToJSONParams<T extends { [key: string]: any } = { [key: string]: any }> {\n /** The object to convert. */\n obj: T;\n /** The depth for recursive conversion. Defaults to 0. */\n depth?: number;\n}\n\n/**\n * Checks if an object is a class instance (not a native JavaScript object like Array, Date, etc.).\n * @param {any} obj The object to check.\n * @returns {boolean} True if the object is a class instance, false otherwise.\n */\nfunction isClassInstance(obj: any): boolean {\n if (!obj) return false;\n\n const constructor = obj.constructor;\n const nativeConstructors = [Array, Date, RegExp, Map, Set, Promise, Function, Number, String, Boolean, Error, Object];\n\n if (nativeConstructors.includes(constructor)) {\n return false;\n }\n\n return true\n};\n\n/**\n * Recursively converts BigInt values in an object to strings.\n * @param {any} obj The object to convert.\n * @returns {any} The object with BigInts converted to strings.\n */\nfunction convertBigintsToStrings(obj: any): any {\n if (typeof obj === 'bigint') {\n return obj.toString() + \"n\";\n }\n\n if (typeof obj === 'object') {\n for (const key in obj) {\n obj[key] = convertBigintsToStrings(obj[key]);\n }\n }\n\n if (Array.isArray(obj)) {\n for (let i = 0; i < obj.length; i++) {\n obj[i] = convertBigintsToStrings(obj[i]);\n }\n }\n\n return obj;\n}\n\n/**\n * Converts an object, including its nested class instances and getter methods, into a plain JSON object.\n * BigInt values are converted to strings.\n *\n * @param params - The parameters for conversion.\n * @param params.obj - The object to convert.\n * @param [params.depth=0] - The depth for recursive conversion. Defaults to 0.\n * @returns A promise that resolves to the JSON representation of the object.\n */\nexport async function toJSON({ obj, depth = 0 }: IToJSONParams) {\n const data: any = {};\n const promises: Promise<any>[] = [];\n\n for (const key in obj) {\n // skip class related properties\n if (key === \"toJSON\" || key === \"constructor\" || key === \"client\" || key === \"persistenceManager\") continue;\n\n const prop: any = obj[key];\n\n if (typeof prop === \"function\") {\n // do not fetch getters if depth is 0\n if (depth === 0) continue;\n\n const promise = async () => {\n const value = await obj[key]();\n\n // if the value is a class instance, convert it to JSON recursively\n if (typeof value === \"object\" && isClassInstance(value)) return data[key] = await toJSON({ obj: value, depth: depth - 1 });\n\n data[key] = value;\n };\n\n promises.push(promise());\n };\n\n if (typeof prop === \"object\" && isClassInstance(prop)) {\n // If depth is 0, just flatten the object using recursion\n if (depth === 0) {\n const promise = async () => {\n data[key] = await toJSON({\n obj: prop,\n depth: depth - 1\n });\n };\n promises.push(promise());\n\n continue;\n };\n \n // If depth is not 0, fetch the object\n const promise = async () => {\n data[key] = await prop.toJSON({ depth: depth - 1 });\n };\n promises.push(promise());\n\n continue;\n };\n\n data[key] = prop;\n };\n\n await Promise.all(promises);\n\n return convertBigintsToStrings(data);\n};","import { AccessList, Address, Hash, Hex, Transaction as RawTransaction, WaitForTransactionReceiptReturnType } from '@mentaproject/core/types';\nimport { getBlock, getTransactionReceipt, traceTransaction, waitForTransactionReceipt } from '@mentaproject/core/actions';\nimport { hexToBigInt } from '@mentaproject/core/utils';\nimport { TransactionReceiptNotFoundError } from 'viem';\n\nimport { Account } from './Account';\nimport { Block } from './Block';\nimport { MentaClient } from './MentaClient';\n\nimport { toJSON } from '../utils/toJSON';\nimport { JSONTransaction, TransactionCall } from '../types';\n\n/**\n * Represents a blockchain transaction with its properties and methods.\n *\n * @description This class encapsulates the data and functionalities related to an Ethereum-like transaction,\n * providing methods to interact with the blockchain to retrieve transaction-related information such as\n * internal calls, receipts, and the block it belongs to.\n */\nexport class Transaction implements Omit<RawTransaction, \"from\" | \"to\"> {\n /**\n * @description The access list for the transaction.\n */\n public accessList?: AccessList;\n /**\n * @description The blob versioned hashes.\n */\n public blobVersionedHashes?: readonly Hex[];\n /**\n * @description The gas limit for the transaction.\n */\n public gas: bigint;\n /**\n * @description The gas price for the transaction.\n */\n public gasPrice?: bigint;\n /**\n * @description The hash of the transaction.\n */\n public hash: Hash;\n /**\n * @description The input data for the transaction.\n */\n public input: Hex;\n /**\n * @description The maximum fee per gas.\n */\n public maxFeePerGas?: bigint;\n /**\n * @description The maximum priority fee per gas.\n */\n public maxPriorityFeePerGas?: bigint;\n /**\n * @description The nonce of the transaction.\n */\n public nonce: number;\n /**\n * @description The r value of the signature.\n */\n public r: Hex;\n /**\n * @description The s value of the signature.\n */\n public s: Hex;\n /**\n * @description The index of the transaction within the block.\n */\n public transactionIndex: number | null;\n /**\n * @description The type of the transaction.\n */\n public type: \"legacy\" | \"eip2930\" | \"eip1559\" | \"eip4844\" | \"eip7702\";\n /**\n * @description The v value of the signature.\n */\n public v: bigint;\n /**\n * @description The value transferred in the transaction.\n */\n public value: bigint;\n /**\n * @description The y parity of the signature.\n */\n public yParity?: number;\n /**\n * @description The hash of the block containing this transaction.\n */\n public blockHash: Hash | null;\n /**\n * @description The number of the block containing this transaction.\n */\n public blockNumber: bigint | null;\n /**\n * @description The hex representation of the type of the transaction.\n */\n public typeHex: `0x${string}` | null;\n\n /**\n * @description The sender account of the transaction.\n */\n public from?: Account;\n /**\n * @description The recipient account of the transaction.\n */\n public to?: Account;\n\n\n /**\n * Creates an instance of Transaction.\n * @description Initializes a new Transaction instance with the provided RPC client and transaction data.\n * @param {MentaClient} client - The instance of MentaClient used to interact with the blockchain.\n * @param {ITransactionData} data The raw transaction data.\n */\n constructor(protected client: MentaClient, data: RawTransaction) {\n this.accessList = data.accessList;\n this.blobVersionedHashes = data.blobVersionedHashes;\n this.gas = data.gas;\n this.gasPrice = data.gasPrice;\n this.hash = data.hash;\n this.input = data.input;\n this.maxFeePerGas = data.maxFeePerGas;\n this.maxPriorityFeePerGas = data.maxPriorityFeePerGas;\n this.nonce = data.nonce;\n this.r = data.r;\n this.s = data.s;\n this.transactionIndex = data.transactionIndex;\n this.type = data.type;\n this.v = data.v;\n this.value = data.value;\n this.yParity = data.yParity;\n this.blockHash = data.blockHash;\n this.blockNumber = data.blockNumber;\n this.typeHex = data.typeHex;\n\n this.from = data.from ? this.client.accounts.get(data.from) : undefined;\n this.to = data.to ? this.client.accounts.get(data.to) : undefined;\n };\n\n /**\n * Retrieves the internal calls made by this transaction.\n * @description Fetches and processes the transaction traces to extract internal call details.\n * @returns {Promise<TransactionCall[] | undefined>} A promise that resolves to an array of call objects, each representing an internal call with sender, recipient, value, input data, gas used, and call type.\n */\n public async calls(): Promise<TransactionCall[] | undefined> {\n const traces = await traceTransaction(this.client.rpc, this.hash);\n if (!traces) return undefined;\n\n const calls = traces.filter(t => t.type === \"call\" && t.action !== undefined);\n\n return calls.map(c => ({\n from: new Account(this.client, { address: c.action!.from as Address }),\n to: new Account(this.client, { address: c.action!.to as Address }),\n value: hexToBigInt(c.action!.value as Hex),\n input: c.action!.input as Hex,\n gas: hexToBigInt(c.action!.gas as Hex),\n callType: c.action!.callType,\n })) as TransactionCall[];\n }\n\n /**\n * Waits for the transaction receipt to be available.\n * @description Asynchronously waits for the transaction to be confirmed on the blockchain and its receipt to be available.\n * @param {number} [confirmations] The number of confirmations to wait for. Defaults to 1.\n * @returns {Promise<WaitForTransactionReceiptReturnType>} A promise that resolves to the transaction receipt once the specified number of confirmations are met.\n */\n async waitForReceipt(confirmations?: number): Promise<WaitForTransactionReceiptReturnType> {\n return await waitForTransactionReceipt(this.client.rpc, {\n hash: this.hash,\n confirmations: confirmations || 1,\n });\n };\n\n /**\n * Retrieves the transaction receipt.\n * @description Fetches the transaction receipt for the current transaction hash.\n * @returns {Promise<WaitForTransactionReceiptReturnType>} A promise that resolves to the transaction receipt.\n */\n async receipt(): Promise<WaitForTransactionReceiptReturnType | undefined> {\n try {\n return await getTransactionReceipt(this.client.rpc, { hash: this.hash });\n } catch (error) {\n if (error instanceof TransactionReceiptNotFoundError) {\n return undefined;\n }\n }\n };\n\n /**\n * Retrieves the block containing this transaction.\n * @description Fetches the block data using the transaction's block hash and returns a Block instance.\n * @returns {Promise<Block>} A promise that resolves to a Block instance representing the block that includes this transaction.\n */\n async block(): Promise<Block> {\n const data = await getBlock(this.client.rpc, { blockHash: this.blockHash! });\n return new Block(this.client, data);\n };\n\n /**\n * Converts the Transaction instance to a JSON representation.\n * @description Serializes the transaction instance into a JSON object, including nested representations of related entities like block, receipt, and internal calls based on the specified depth.\n * @param {number} [depth=1] The depth of the conversion. Controls how deeply nested objects are serialized.\n * @returns {Promise<object>} A promise that resolves to the JSON representation of the transaction.\n */\n async toJSON<D extends number = 1>(depth: D): Promise<JSONTransaction<D>> {\n return await toJSON({\n obj: {\n ...this,\n block: this.block,\n receipt: this.receipt,\n calls: async () => {\n const calls = await this.calls();\n if (!calls) return undefined;\n\n return Promise.all(calls.map(async c => await toJSON({ obj: c, depth: depth })));\n }\n },\n depth\n });\n }\n};","import { Block as RawBlock, Hash, Hex, Withdrawal } from \"@mentaproject/core\";\n\nimport { Account } from \"./Account\";\nimport { Transaction } from \"./Transaction\";\nimport { JSONBlock } from \"../types/Block\";\nimport { toJSON } from \"../utils/toJSON\";\nimport { MentaClient } from \"./MentaClient\";\n\n/**\n * @description Represents a blockchain block with its properties and methods.\n * This class provides a structured way to access block-related data and interact with the blockchain client.\n */\nexport class Block implements Omit<RawBlock, \"miner\" | \"transactions\"> {\n /**\n * @description The base fee per gas for the block.\n */\n baseFeePerGas: bigint | null\n /**\n * @description The gas used for blobs in the block.\n */\n blobGasUsed: bigint\n /**\n * @description The block's difficulty.\n */\n difficulty: bigint\n /**\n * @description The excess blob gas in the block.\n */\n excessBlobGas: bigint\n /**\n * @description Extra data included in the block.\n */\n extraData: Hex\n /**\n * @description The gas limit for the block.\n */\n gasLimit: bigint\n /**\n * @description The gas used in the block.\n */\n gasUsed: bigint\n /**\n * @description The hash of the block.\n */\n hash: Hash | null\n /**\n * @description The logs bloom filter for the block.\n */\n logsBloom: Hex | null\n /**\n * @description The mix hash of the block.\n */\n mixHash: Hash\n /**\n * @description The nonce of the block.\n */\n nonce: Hex | null\n /**\n * @description The block number.\n */\n number: bigint | null\n /**\n * @description The parent beacon block root.\n */\n parentBeaconBlockRoot?: Hex\n /**\n * @description The hash of the parent block.\n */\n parentHash: Hash\n /**\n * @description The root of the receipts trie.\n */\n receiptsRoot: Hex\n /**\n * @description The seal fields of the block.\n */\n sealFields: Hex[]\n /**\n * @description The SHA3 uncles hash.\n */\n sha3Uncles: Hash\n /**\n * @description The size of the block in bytes.\n */\n size: bigint\n /**\n * @description The state root of the block.\n */\n stateRoot: Hash\n /**\n * @description The timestamp of the block.\n */\n timestamp: bigint\n /**\n * @description The total difficulty of the chain up to this block.\n */\n totalDifficulty: bigint | null\n /**\n * @description The root of the transactions trie.\n */\n transactionsRoot: Hash\n /**\n * @description The list of uncle hashes.\n */\n uncles: Hash[]\n /**\n * @description The list of withdrawals.\n */\n withdrawals?: Withdrawal[]\n /**\n * @description The root of the withdrawals trie.\n */\n withdrawalsRoot?: Hex\n\n /**\n * @description The miner of the block, represented as an Account instance.\n */\n miner: Account\n /**\n * @description The transactions included in the block, represented as an array of Transaction instances.\n */\n transactions?: Transaction[] | Hash[]\n\n /**\n * @description Creates an instance of Block.\n * @param client - The instance of MentaClient used to interact with the blockchain.\n * @param data The raw block data conforming to IBlockData.\n * @param includeTransactions Whether to include full transaction objects. Defaults to false.\n */\n constructor(public client: MentaClient, data: RawBlock) {\n this.baseFeePerGas = data.baseFeePerGas;\n this.blobGasUsed = data.blobGasUsed;\n this.difficulty = data.difficulty;\n this.excessBlobGas = data.excessBlobGas;\n this.extraData = data.extraData;\n this.gasLimit = data.gasLimit;\n this.gasUsed = data.gasUsed;\n this.hash = data.hash;\n this.logsBloom = data.logsBloom;\n this.mixHash = data.mixHash;\n this.nonce = data.nonce;\n this.number = data.number;\n this.parentBeaconBlockRoot = data.parentBeaconBlockRoot;\n this.parentHash = data.parentHash;\n this.receiptsRoot = data.receiptsRoot;\n this.sealFields = data.sealFields;\n this.sha3Uncles = data.sha3Uncles;\n this.size = data.size;\n this.stateRoot = data.stateRoot;\n this.timestamp = data.timestamp;\n this.totalDifficulty = data.totalDifficulty;\n this.transactionsRoot = data.transactionsRoot;\n this.uncles = data.uncles;\n this.withdrawals = data.withdrawals;\n this.withdrawalsRoot = data.withdrawalsRoot;\n\n this.miner = new Account(this.client, { address: data.miner});\n \n if (!data.transactions || data.transactions.length === 0) {\n const parsed = data.transactions.map((data) => typeof data === \"string\" ? data : new Transaction(this.client, data))\n this.transactions = parsed as Transaction[] | Hash[];\n }\n };\n\n protected includeTransactions(): this is this & { transactions: Transaction[] } {\n if (!this.transactions || this.transactions.length === 0) return false;\n return true\n }\n\n /**\n * @description Converts the Block instance to a JSON representation.\n * This method serializes the block's properties into a plain JavaScript object,\n * suitable for JSON serialization.\n * @param depth The depth of the conversion. Defaults to 1.\n * @returns A promise that resolves to the JSON representation of the block.\n */\n async toJSON<D extends number = 1>(depth: D): Promise<JSONBlock<D>> {\n return await toJSON({\n obj: {\n ...this,\n },\n depth\n });\n }\n};","/**\n * @module MentaClient\n */\nimport type { MentaAccountClient } from \"@mentaproject/core/types\";\nimport { createMentaAccount } from \"@mentaproject/core/clients\";\nimport { createClient } from \"@mentaproject/core\";\n\nimport { BlockManager } from \"../managers/BlockManager\";\nimport { TransactionManager } from \"../managers/TransactionManager\";\nimport { ContractManager } from \"../managers/ContractManager\";\nimport { AccountManager } from \"../managers/AccountManager\";\nimport { PersistenceManager } from \"../managers/PersistenceManager\";\nimport {\n ClientEvents,\n GetListenerCallback,\n MentaClientConfig,\n} from \"../types/MentaClient\";\nimport { withCache } from \"../utils/withCache\";\nimport { Account } from \"./Account\";\n\n/**\n * The main client for interacting with the Menta API.\n * It provides managers for blocks, transactions, contracts, and accounts.\n *\n * @description This class serves as the primary entry point for interacting with the Menta blockchain.\n * It encapsulates the core RPC client and provides specialized managers for various blockchain entities,\n * simplifying common operations.\n */\nexport class MentaClient {\n protected _rpc?: MentaAccountClient;\n protected _account?: Account;\n /**\n * The underlying RPC client used for blockchain interactions.\n * @description This client is responsible for low-level communication with the RPC node.\n */\n public get rpc(): MentaAccountClient {\n if (!this._rpc) {\n throw new Error(\"RPC client not initialized\");\n }\n return this._rpc;\n }\n\n /**\n * The account associated with the client.\n * @description This account is used for signing transactions and interacting with the blockchain.\n */\n public get account(): Account {\n if (!this._account) {\n throw new Error(\"Account not initialized\");\n }\n return this._account;\n }\n\n /**\n * Manager for block-related operations.\n * @description Provides methods to query and interact with blockchain blocks.\n */\n public blocks!: BlockManager;\n /**\n * Manager for transaction-related operations.\n * @description Provides methods to send, query, and manage blockchain transactions.\n */\n public transactions!: TransactionManager;\n /**\n * Manager for contract-related operations.\n * @description Provides methods to deploy, interact with, and query smart contracts.\n */\n public contracts!: ContractManager;\n /**\n * Manager for account-related operations.\n * @description Provides methods to manage and interact with blockchain accounts.\n */\n public accounts!: AccountManager;\n\n /**\n * Subscribes to a specific client event.\n * @template TEvent The type of the event to listen for.\n * @param {TEvent} event - The event to listen for (e.g., 'block', 'transaction').\n * @param {GetListenerCallback<TEvent>} callback - The callback function to execute when the event is triggered.\n * @returns {() => void} An unsubscribe function to stop listening to the event.\n * @description This method allows the client to listen for real-time events from the blockchain, such as new blocks or transactions.\n * @example\n * import { MentaClient } from '@mentaproject/client';\n *\n * const client = new MentaClient({ url: 'http://rpcurlhere.com' });\n *\n * // Subscribe to new blocks\n * const unsubscribe = client.on('block', (block) => {\n * console.log('New block received:', block);\n * });\n *\n * // To stop listening\n * // unsubscribe();\n */\n on<TEvent extends keyof typeof ClientEvents>(\n event: TEvent,\n callback: GetListenerCallback<TEvent>,\n ) {\n const eventFunction = ClientEvents[event];\n const capitalizedEvent = event.charAt(0).toUpperCase() + event.slice(1);\n const params = {\n [`on${capitalizedEvent}`]: callback,\n pollingInterval: 1000,\n };\n\n return (eventFunction as any)(this.rpc, params);\n }\n\n /**\n * Creates an instance of MentaClient.\n * @param {MentaClientConfig} params - The configuration parameters for the client.\n * @description The constructor initializes the RPC client and the various managers based on the provided configuration.\n * It also applies caching and persistence if specified in the configuration.\n * @example\n * import { MentaClient } from '@mentaproject/client';\n *\n * // Basic initialization\n * const client = new MentaClient({\n * url: 'http://rpcurlhere.com',\n * });\n *\n * // Initialization with a persistent cache\n * const clientWithCache = new MentaClient({\n * url: 'http://rpcurlhere.com',\n * cache: {\n * ttl: 60000, // 1 minute\n * },\n * });\n */\n constructor(protected params: MentaClientConfig) {\n this.blocks = new BlockManager(this);\n this.transactions = new TransactionManager(this);\n this.contracts = new ContractManager(this);\n\n if (params.persistenceAdapter) {\n this.persistenceManager = new PersistenceManager(\n this,\n params.persistenceAdapter,\n );\n this.accounts = new AccountManager(this, this.persistenceManager);\n } else {\n this.accounts = new AccountManager(this);\n }\n }\n\n async init() {\n let coreClient = createClient(this.params);\n\n if (this.params.cache) {\n coreClient = withCache(coreClient, this.params.cache);\n }\n\n this._rpc = await createMentaAccount(coreClient as any, {\n bundlerTransport: this.params.bundlerTransport,\n publicTransport: this.params.transport,\n signer: this.params.signer,\n validatorAddress: this.params.validatorAddress,\n });\n\n this._account = this.accounts.get(this.rpc.account.address);\n }\n\n /**\n * Optional manager for persistence-related operations.\n * @description This manager is initialized if a persistence adapter is provided in the client configuration,\n * allowing for data storage and retrieval.\n */\n public persistenceManager?: PersistenceManager;\n}\n","/**\n * @module BlockManager\n */\nimport { BlockTag, GetBlockParameters } from \"@mentaproject/core/types\";\nimport { Block } from \"../structures/Block\";\nimport { getBlock } from \"@mentaproject/core/actions\";\nimport { MentaClient } from \"../structures\";\n\n/**\n * Manages blockchain block-related operations, providing methods to interact with and retrieve block data.\n */\nexport class BlockManager {\n /**\n * Creates an instance of BlockManager.\n * @param client - The instance of MentaClient used to interact with the blockchain.\n */\n constructor(public client: MentaClient) {};\n\n /**\n * Retrieves a block from the blockchain based on the provided parameters.\n * This method uses the underlying RPC client to fetch block data and then\n * encapsulates it within a {@link Block} instance.\n * @param params The parameters for retrieving the block, including block hash, block number, or block tag.\n * @returns A promise that resolves to a {@link Block} instance representing the retrieved block.\n * @example\n * import { http } from '@mentaproject/core';\n * import { mainnet } from '@mentaproject/core/chains';\n * import { MentaClient } from '@mentaproject/client';\n *\n * // Initialize the MentaClient\n * const mentaClient = new MentaClient({ chain: mainnet, transport: http(\"http://rpcurlhere.com\") });\n *\n * async function fetchBlock() {\n * // Retrieve the latest block\n * const latestBlock = await mentaClient.blocks.get({ blockTag: 'latest' });\n * console.log('Latest block number:', latestBlock.number);\n *\n * // Retrieve a specific block by its number\n * if (latestBlock.number) {\n * const specificBlock = await mentaClient.blocks.get({ blockNumber: latestBlock.number - 10n });\n * console.log('Specific block hash:', specificBlock.hash);\n * }\n * }\n *\n * fetchBlock();\n */\n async get(params: GetBlockParameters<boolean, BlockTag>): Promise<Block> {\n const data = await getBlock(this.client.rpc, params);\n return new Block(this.client, data);\n };\n}","/**\n * @module TransactionManager\n */\nimport { GetTransactionParameters, Transaction as RawTransaction, SendTransactionParameters } from \"@mentaproject/core/types\";\nimport { Transaction as RichTransaction } from \"../structures/Transaction\";\nimport { MulticallTransaction } from \"@mentaproject/transactions\";\nimport { getTransaction, sendTransaction } from \"@mentaproject/core/actions\";\nimport { MentaClient } from \"../structures\";\nimport { JSONTransaction } from \"../types\";\nimport { parseBingints } from \"../utils/bigint\";\n\n/**\n * Manages blockchain transaction-related operations.\n *\n * @example\n * ```ts\n * // Create a multicall transaction\n * const pending = await client.transactions.create()\n * .addCall(account.sendEth(parseEther(\"1\")))\n * .addCall(erc20.transfer(to, amount))\n * .execute();\n *\n * const receipt = await pending.confirm();\n *\n * // Get a transaction by hash\n * const tx = await client.transactions.fromHash(hash);\n * console.log(tx.receipt, tx.block);\n * ```\n */\nexport class TransactionManager {\n constructor(public client: MentaClient) {}\n\n /**\n * Creates a new MulticallTransaction for batching multiple calls.\n *\n * @returns A MulticallTransaction builder\n *\n * @example\n * ```ts\n * const pending = await client.transactions.create()\n * .addCall(account.sendEth(parseEther(\"1\")))\n * .addCall(erc20.transfer(to, amount))\n * .execute();\n * ```\n */\n create(): MulticallTransaction {\n return new MulticallTransaction(this.client.rpc);\n }\n\n /**\n * Retrieves a rich transaction by its hash.\n *\n * @param hash - The transaction hash\n * @returns A rich Transaction with receipt, block, etc.\n *\n * @example\n * ```ts\n * const tx = await client.transactions.fromHash(hash);\n * console.log(tx.from, tx.to, tx.value);\n * ```\n */\n async fromHash(hash: `0x${string}`): Promise<RichTransaction> {\n return this.get({ hash });\n }\n\n /**\n * Retrieves a transaction by its hash or block number and index.\n */\n async get(params: GetTransactionParameters): Promise<RichTransaction> {\n const data = await getTransaction(this.client.rpc, params);\n return new RichTransaction(this.client, data);\n }\n\n /**\n * Parse a transaction object from a JSON converted transaction data object.\n */\n parse<J extends JSONTransaction<0>>(data: J): RichTransaction {\n const parsed = parseBingints(data);\n\n const rawData = {\n ...parsed,\n from: parsed.from.address,\n to: parsed.to ? parsed.to.address : null,\n };\n\n return new RichTransaction(this.client, rawData as RawTransaction);\n }\n\n /**\n * Sends a transaction to the blockchain network.\n * @deprecated Use client.transactions.create() for new transactions\n */\n async send(params: SendTransactionParameters): Promise<RichTransaction> {\n const hash = await sendTransaction(this.client.rpc, params);\n return await this.get({ hash });\n }\n}\n","import { WithoutBigintStringified } from \"../types/Utils\";\n\nexport const bigIntMax = (...args: bigint[]) => args.reduce((m, e) => e > m ? e : m);\nexport const bigIntMin = (...args: bigint[]) => args.reduce((m, e) => e < m ? e : m);\n\nexport function bigIntReviver(key: string, value: any) {\n if (typeof value === 'string') {\n if (value.endsWith('n')) {\n try {\n return BigInt(value.slice(0, -1));\n } catch (e) {\n return value;\n }\n };\n };\n\n return value;\n};\n\nexport function stringifyBingints(obj: any) {\n if (typeof obj === 'bigint') {\n return obj.toString() + \"n\";\n }\n\n if (typeof obj === 'object') {\n for (const key in obj) {\n obj[key] = stringifyBingints(obj[key]);\n }\n }\n\n if (Array.isArray(obj)) {\n for (let i = 0; i < obj.length; i++) {\n obj[i] = stringifyBingints(obj[i]);\n }\n }\n\n return obj;\n};\n\nexport function parseBingints<T extends { [key: string]: any }>(obj: T): WithoutBigintStringified<T> {\n if (typeof obj !== 'object' || obj === null) {\n return obj;\n }\n\n if (Array.isArray(obj)) {\n return obj.map((item, index) => bigIntReviver(index.toString(), parseBingints(item))) as WithoutBigintStringified<T>;\n }\n\n const newObj: { [key: string]: any } = {};\n for (const key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n const value = obj[key];\n const processedValue = parseBingints(value);\n newObj[key] = bigIntReviver(key, processedValue);\n }\n };\n\n return newObj as WithoutBigintStringified<T>;\n};","/**\n * @module ContractManager\n */\nimport type { AbiItem } from \"@mentaproject/core/types\";\nimport { getContract, GetContractParameters } from \"@mentaproject/contracts\";\nimport { MentaClient } from \"../structures\";\n\n/**\n * Manages smart contract-related operations within the Menta client.\n * This class provides methods to interact with smart contracts deployed on the blockchain,\n * facilitating the retrieval of contract instances for various operations.\n */\nexport class ContractManager {\n /**\n * Creates an instance of ContractManager.\n * @description Initializes the ContractManager with a CoreClient instance, which is used for RPC communication.\n * @param client - The instance of MentaClient used to interact with the blockchain.\n */\n constructor(protected client: MentaClient) {};\n\n /**\n * Retrieves a contract instance to interact with it.\n * @description This method fetches a contract instance based on the provided parameters, allowing for interaction with its methods and events.\n * @template P The type of the contract retrieval parameters, extending `GetContractParameters` with `AbiItem` array.\n * @param {P} params The parameters for retrieving the contract, including its Application Binary Interface (ABI) and address.\n * @returns {ReturnType<typeof getContract<ReadonlyArray<AbiItem>, P>>} A contract instance that can be used to call contract methods or listen to events.\n * @example\n * import { MentaClient } from '@mentaproject/client';\n * import { http } from '@mentaproject/core';\n *\n * // Initialize the MentaClient with a transport\n * const client = new MentaClient({\n * transport: http('http://rpcurlhere.com'),\n * });\n *\n * // Define the ABI and address for the smart contract\n * const abi = [\n * {\n * \"type\": \"function\",\n * \"name\": \"greet\",\n * \"stateMutability\": \"view\",\n * \"inputs\": [],\n * \"outputs\": [{ \"name\": \"\", \"type\": \"string\" }]\n * }\n * ] as const;\n * const contractAddress = '0x...'; // Replace with your contract address\n *\n * // Retrieve the contract instance\n * const contract = client.contracts.get({\n * abi,\n * address: contractAddress,\n * });\n *\n * // Example of interacting with the contract\n * const greeting = await contract.greet();\n */\n get<P extends GetContractParameters<ReadonlyArray<AbiItem>>>(params: P) {\n return getContract(this.client.rpc, params);\n };\n};","/**\n * @module AccountManager\n */\nimport { Address } from \"@mentaproject/core/types\";\nimport { Account } from \"../structures/Account\";\nimport { PersistenceManager } from \"./PersistenceManager\";\nimport { MentaClient } from \"../structures\";\n\n/**\n * Manages blockchain account operations.\n * This class provides methods to interact with accounts,\n * including retrieving and managing them via an RPC client and a persistence manager.\n *\n * @class AccountManager\n */\nexport class AccountManager {\n /**\n * Creates an instance of AccountManager.\n *\n * @param {MentaClient} client - The instance of MentaClient used to interact with the blockchain.\n * @param {persistenceManager} persistenceManager - The optional persistence manager to store and retrieve account data.\n */\n constructor(public client: MentaClient, private persistenceManager?: PersistenceManager) { };\n\n /**\n * Retrieves an account instance by its blockchain address.\n * @param address - The blockchain address of the account to retrieve.\n * @returns An instance of the `Account` class.\n * @example\n * ```typescript\n * import { MentaClient } from '@mentaproject/client';\n * import { http } from '@mentaproject/core';\n *\n * // Initialize the MentaClient\n * const client = new MentaClient({\n * transport: http('http://rpcurlhere.com'),\n * });\n *\n * // The address of the account to retrieve\n * const accountAddress = '0x1234567890123456789012345678901234567890';\n *\n * // Retrieve the account instance using the account manager from the client\n * const account = client.accounts.get(accountAddress);\n *\n * console.log(account.address); // 0x1234567890123456789012345678901234567890\n * ```\n */\n get(address: Address): Account {\n return new Account(this.client, { address: address }, this.persistenceManager);\n };\n}","import { getBlockNumber } from '@mentaproject/core/actions';\nimport { Address } from '@mentaproject/core/types';\n\nimport { Account } from '../structures/Account';\nimport { MentaClient, Transaction } from '../structures';\nimport { bigIntMax } from '../utils/bigint';\nimport { GetTransactionsParams, IPersistenceAdapter, JSONTransaction } from 'src/types';\n\n/**\n * Manages the persistence of data, including transactions, using a specified persistence adapter.\n * It handles fetching data from both local storage and remote sources, and synchronizing them.\n */\nexport class PersistenceManager {\n /**\n * Creates an instance of PersistenceManager.\n * @param client - The instance of MentaClient used to interact with the blockchain.\n * @param persistenceAdapter - The adapter responsible for actual data persistence operations.\n */\n constructor(\n private client: MentaClient,\n private persistenceAdapter: IPersistenceAdapter\n ) {}\n\n /**\n * Retrieves transactions for a given account, applying a \"stale-while-revalidate\" strategy.\n * @param params - Parameters for retrieving transactions.\n * @returns A promise that resolves to an array of transactions with associated account information.\n */\n public async getTransactions(address: Address, params: GetTransactionsParams): Promise<JSONTransaction<0>[]> {\n return await this.persistenceAdapter.getTransactions(address, params);\n }\n\n /**\n * Synchronizes an account's transactions from the remote source to the local persistence.\n * It fetches new transactions starting from the last synced block and updates the local storage.\n * @param account - The account whose transactions are to be synchronized.\n * @param limit - The maximum number of transactions to fetch.\n * @returns A promise that resolves when the synchronization is complete.\n */\n public async syncTransactions(account: Account, limit: number = 100_000): Promise<void> {\n const lastSyncedBlock = await this.persistenceAdapter.getLastSyncedBlock(account.address);\n const lastBlock = lastSyncedBlock ?? 0n;\n\n const fromBlock = lastSyncedBlock ? lastSyncedBlock + 1n : (await getBlockNumber(this.client.rpc));\n\n const newTransactions = await account.transactions({\n fromBlock: fromBlock,\n toBlock: lastBlock,\n limit: limit\n }, true)\n\n if (newTransactions.length > 0) {\n await this.persistenceAdapter.upsertTransactions(newTransactions);\n \n const latestBlock = bigIntMax(...newTransactions.map(t => t.blockNumber || 0n));\n await this.persistenceAdapter.setLastSyncedBlock(account.address, latestBlock);\n }\n }\n}","/**\n * @module MentaClientTypes\n */\nimport { Address, CoreClientConfig, Transport } from \"@mentaproject/core/types\";\nimport { ICache } from \"./Cache\";\nimport { watchBlockNumber, watchBlocks } from \"@mentaproject/core/actions\";\nimport { IPersistenceAdapter } from \"./PersistenceAdapter\";\nimport { WebAuthnAccount } from \"@mentaproject/core/account-abstraction\";\n\n/**\n * Configuration for the client's cache.\n * @interface CacheConfig\n */\nexport interface CacheConfig {\n /**\n * Time-to-live policies for different RPC methods.\n * Keys are RPC method names (e.g., \"eth_getBlockByNumber\"), and values are\n * the TTL in milliseconds for caching responses from those methods.\n */\n ttl_policies: Record<string, number>;\n}\n\n/**\n * Configuration options for the MentaClient.\n * Extends {@link CoreClientConfig} from `@mentaproject/core`.\n * @interface MentaClientConfig\n */\nexport interface MentaClientConfig extends CoreClientConfig {\n /**\n * Optional cache implementation for the client.\n * If provided, the client will use this cache for RPC responses.\n */\n cache?: ICache;\n /**\n * Optional persistence adapter for local data storage.\n * If provided, the client will use this adapter to persist and retrieve data.\n */\n persistenceAdapter?: IPersistenceAdapter;\n /**\n * Bundler transport used for userOperations\n */\n bundlerTransport: Transport;\n /**\n * Passkey compatible signer used for signing user operations\n */\n signer: WebAuthnAccount;\n /**\n * Validator address used for userOperations\n */\n validatorAddress: Address;\n}\n\n/**\n * Defines the available client events and their corresponding watch functions.\n * These functions are used to subscribe to real-time updates from the client.\n */\nexport const ClientEvents = {\n /**\n * Event for new blocks.\n * Uses the {@link watchBlocks} function from `@mentaproject/core`.\n */\n block: watchBlocks,\n /**\n * Event for new block numbers.\n * Uses the {@link watchBlockNumber} function from `@mentaproject/core`.\n */\n blockNumber: watchBlockNumber,\n};\n\n/**\n * Utility type to extract the callback function type for a given event.\n * This type dynamically determines the expected callback signature for a specific client event.\n * @template TEvent The name of the event (e.g., 'block' or 'blockNumber') for which to get the listener callback type.\n */\nexport type GetListenerCallback<TEvent extends keyof typeof ClientEvents> =\n Parameters<(typeof ClientEvents)[TEvent]>[1] extends infer P\n ? P extends { [K in `on${Capitalize<TEvent>}`]: infer TCallback }\n ? TCallback\n : never\n : never;\n","/**\n * @module withCache\n */\nimport { watchBlockNumber } from \"@mentaproject/core/actions\";\nimport type { CoreClient } from \"@mentaproject/core/types\";\nimport { ICache } from \"../types/Cache\";\nimport { Methods } from \"../types/JsonRPC\";\n\n// EntryPoint.getNonce selector - must never be cached to avoid nonce reuse\nconst GET_NONCE_SELECTOR = \"0x35567e1a\";\n\n/**\n * Checks if an eth_call is a getNonce call to the EntryPoint.\n * These calls must not be cached to ensure fresh nonce values for each UserOperation.\n */\nfunction isNonceCall(method: Methods, params: any): boolean {\n if (method !== \"eth_call\") return false;\n const callData = params?.[0]?.data;\n return typeof callData === \"string\" && callData.startsWith(GET_NONCE_SELECTOR);\n}\n\n/**\n * A higher-order function that enhances a class method with caching capabilities.\n * It intercepts RPC requests made through the client and caches their responses\n * based on the provided cache implementation.\n *\n * @param client The CoreClient instance to enhance with caching.\n * @param cache The cache implementation (ICache) to use for storing and retrieving responses.\n * @returns The enhanced CoreClient instance with caching enabled.\n */\nexport function withCache<T extends CoreClient>(client: T, cache: ICache): T {\n watchBlockNumber(client, {\n onBlockNumber: (blockNumber) => {\n cache.setBlockNumber(blockNumber);\n },\n pollingInterval: 1000,\n });\n // 2. We keep a reference to the original request method\n const originalRequest = client.request;\n\n // 3. We replace the client's `request` method\n client.request = (async (args: { method: Methods, params: any }) => {\n const { method, params } = args;\n\n // Never cache nonce calls - they must always return fresh values\n const shouldSkipCache = method === \"eth_blockNumber\" || isNonceCall(method, params);\n\n const cacheKey = `${client.chain!.id}:${method}:${JSON.stringify(params || [], (_, v) => typeof v === 'bigint' ? v.toString() : v)}`;\n\n let result;\n if (!shouldSkipCache) {\n result = cache.get(cacheKey);\n }\n\n if (!result) {\n result = await originalRequest(args as any);\n };\n\n if (result !== null && result !== undefined && !shouldSkipCache) {\n const ttl = cache.config.ttlPolicies[method] || cache.config.defaultTtl;\n await cache.set(cacheKey, result, ttl);\n }\n\n return result;\n }) as any;\n\n return client;\n}\n","/**\n * @module MemoryCache\n */\nimport { ICache, ICacheEntry, ICacheConfig } from '../types/Cache';\n\n/**\n/**\n * @class MemoryCache\n * @description A simple in-memory cache implementation that adheres to the ICache interface.\n * It stores key-value pairs with an associated time-to-live (TTL) based on block numbers.\n * The cache automatically evicts the oldest entries when its maximum size is reached.\n */\nexport class MemoryCache implements ICache {\n /**\n * @property {Map<string, ICacheEntry<any>>} cache - The internal Map used to store cache entries.\n * @private\n */\n private cache = new Map<string, ICacheEntry<any>>();\n /**\n * @property {ICacheConfig} config - The configuration object for the cache, including maxSize, defaultTtl, and ttlPolicies.\n */\n public config: ICacheConfig;\n /**\n * @property {bigint} blockNumber - The current block number used for TTL calculations.\n * @private\n */\n private blockNumber: bigint;\n\n /**\n * @constructor\n * @description Creates an instance of MemoryCache.\n * @param {bigint} blockNumber - The current block number to use for TTL calculations.\n * @param {Partial<ICacheConfig>} [options] - Optional configuration for the cache.\n * @param {number} [options.maxSize=500] - The maximum number of entries the cache can hold.\n * @param {number} [options.defaultTtl=1] - The default time-to-live in blocks for cache entries if not specified.\n * @param {Object.<string, number>} [options.ttlPolicies={}] - A map of specific TTL policies for different keys.\n */\n constructor(blockNumber: bigint, options?: Partial<ICacheConfig>) {\n this.blockNumber = blockNumber;\n this.config = {\n maxSize: 500,\n defaultTtl: 1,\n ttlPolicies: options?.ttlPolicies || {},\n ...options,\n };\n };\n\n /**\n * @method isExpired\n * @description Checks if a cache entry has expired based on the current block number and the entry's expiry block.\n * @param {bigint} expiry - The expiry block number of the cache entry.\n * @returns {boolean} `true` if the entry has expired, `false` otherwise.\n * @protected\n */\n protected isExpired(expiry: bigint): boolean {\n return this.blockNumber > expiry;\n };\n\n /**\n * @method setBlockNumber\n * @description Sets the current block number for TTL calculations. This is crucial for managing cache entry expiry.\n * @param {bigint} blockNumber - The new current block number.\n * @returns {void}\n */\n setBlockNumber(blockNumber: bigint): void {\n this.blockNumber = blockNumber;\n }\n\n /**\n * @method set\n * @description Sets a value in the cache. If the key already exists, its entry will be updated.\n * If the cache reaches its maximum size, the oldest entry will be evicted before adding the new one.\n * @template T - The type of the value being stored.\n * @param {string} key - The unique key for the cache entry.\n * @param {T} value - The value to store in the cache.\n * @param {number} [ttl=this.config.defaultTtl] - The time-to-live (in blocks) for this specific entry. Defaults to the cache's `defaultTtl`.\n * @returns {void}\n */\n set<T>(key: string, value: T, ttl: number = this.config.defaultTtl): void {\n if (this.cache.has(key)) {\n this.cache.delete(key);\n }\n\n if (this.cache.size >= this.config.maxSize) this.evict();\n \n const expiry = this.blockNumber + BigInt(ttl);\n this.cache.set(key, { value, expiry });\n }\n\n /**\n * @method get\n * @description Retrieves a value from the cache. If the entry is found and has not expired,\n * it is moved to the end of the cache (making it the most recently used) to prevent premature eviction.\n * @template T - The expected type of the value.\n * @param {string} key - The key of the cache entry to retrieve.\n * @returns {T | undefined} The cached value if found and not expired, otherwise `undefined`.\n */\n get<T>(key: string): T | undefined {\n const entry = this.cache.get(key);\n if (!entry) return undefined;\n\n if (this.isExpired(entry.expiry)) {\n this.cache.delete(key);\n return undefined;\n }\n\n this.cache.delete(key);\n this.cache.set(key, entry);\n\n return entry.value as T;\n }\n\n /**\n * @method evict\n * @description Evicts the oldest entry from the cache. This method is called internally when the cache\n * reaches its `maxSize` to make room for new entries.\n * @returns {void}\n * @private\n */\n private evict(): void {\n const oldestKey = this.cache.keys().next().value;\n if (!oldestKey) return;\n\n this.cache.delete(oldestKey);\n }\n}"],"mappings":";;;;;;;AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAOP,SAAS,mBAAmB;AAC5B,SAAS,aAAa;AAOtB,SAAS,uBAAuB;;;ACFhC,SAAS,gBAAgB,KAAmB;AACxC,MAAI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Aa,SAAS,eAAe,CAAC;AAAA,MACtC,GAAG;AAAA,IACL;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASU,UAAU,QAAyB;AAC3C,WAAO,KAAK,cAAc;AAAA,EAC5B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,eAAe,aAA2B;AACxC,SAAK,cAAc;AAAA,EACrB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYA,IAAO,KAAa,OAAU,MAAc,KAAK,OAAO,YAAkB;AACxE,QAAI,KAAK,MAAM,IAAI,GAAG,GAAG;AACvB,WAAK,MAAM,OAAO,GAAG;AAAA,IACvB;AAEC,QAAI,KAAK,MAAM,QAAQ,KAAK,OAAO,QAAS,MAAK,MAAM;AAEvD,UAAM,SAAS,KAAK,cAAc,OAAO,GAAG;AAC5C,SAAK,MAAM,IAAI,KAAK,EAAE,OAAO,OAAO,CAAC;AAAA,EACvC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUD,IAAO,KAA4B;AACjC,UAAM,QAAQ,KAAK,MAAM,IAAI,GAAG;AAChC,QAAI,CAAC,MAAO,QAAO;AAElB,QAAI,KAAK,UAAU,MAAM,MAAM,GAAG;AAChC,WAAK,MAAM,OAAO,GAAG;AACrB,aAAO;AAAA,IACT;AAEA,SAAK,MAAM,OAAO,GAAG;AACrB,SAAK,MAAM,IAAI,KAAK,KAAK;AAEzB,WAAO,MAAM;AAAA,EACf;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASO,QAAc;AACpB,UAAM,YAAY,KAAK,MAAM,KAAK,EAAE,KAAK,EAAE;AAC3C,QAAI,CAAC,UAAW;AAEf,SAAK,MAAM,OAAO,SAAS;AAAA,EAC7B;AACF;","names":["promise","fromBlock","toBlock","Transaction","data","Transaction","getBlock","Transaction","getBlockNumber","getBlockNumber","watchBlockNumber"]}