@mentaproject/core 0.5.11 → 0.5.13

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.
@@ -1,7 +1,9 @@
1
1
  export * from "viem/actions";
2
- export { sendTransaction, signMessage, signTypedData, writeContract } from "permissionless/actions/smartAccount";
2
+ export { sendTransaction, signMessage, signTypedData, writeContract, } from "permissionless/actions/smartAccount";
3
3
  /** Trace Actions */
4
4
  export { traceFilter } from "./traceFilter";
5
5
  export { traceTransaction } from "./traceTransaction";
6
+ export { traceActions } from "./traceActions";
7
+ export type { TraceActions } from "./traceActions";
6
8
  /** Block Range Actions */
7
9
  export { fetchByBlockRange } from "./fetchByBlockRange";
@@ -14,7 +14,7 @@ var smartAccount = require('permissionless/actions/smartAccount');
14
14
  * NOTE: This method relies on the non-standard 'trace_filter' method of the RPC.
15
15
  * It may not be supported by all nodes.
16
16
  *
17
- * @param client The CoreClient instance used to perform the RPC call.
17
+ * @param client The client instance used to perform the RPC call.
18
18
  * @param params The filtering parameters for the trace request (block range, addresses, etc.).
19
19
  * @returns A promise that returns an array of trace entries (GenericTraceEntry[])
20
20
  * that match the filtering criteria.
@@ -25,7 +25,7 @@ async function traceFilter(client, params) {
25
25
  if (typeof params.toAddress === "string")
26
26
  params.toAddress = [params.toAddress];
27
27
  return await client.request({
28
- method: 'trace_filter',
28
+ method: "trace_filter",
29
29
  params: [params],
30
30
  });
31
31
  }
@@ -41,18 +41,25 @@ async function traceFilter(client, params) {
41
41
  * NOTE: This method relies on the non-standard 'trace_transaction' method of the RPC.
42
42
  * It may not be supported by all nodes.
43
43
  *
44
- * @param client The CoreClient instance used to perform the RPC call.
44
+ * @param client The client instance used to perform the RPC call.
45
45
  * @param params The transaction hash for which to retrieve traces.
46
46
  * @returns A promise that returns an array of trace entries (GenericTraceEntry[])
47
47
  * for the specified transaction hash.
48
48
  */
49
49
  async function traceTransaction(client, params) {
50
50
  return await client.request({
51
- method: 'trace_transaction',
51
+ method: "trace_transaction",
52
52
  params: [params],
53
53
  });
54
54
  }
55
55
 
56
+ function traceActions() {
57
+ return (client) => ({
58
+ traceFilter: (args) => traceFilter(client, args),
59
+ traceTransaction: (args) => traceTransaction(client, args),
60
+ });
61
+ }
62
+
56
63
  function calcBlockRange(fromBlock, rangeSize, direction = "forward") {
57
64
  if (direction === "backward")
58
65
  return { fromBlock: fromBlock - BigInt(rangeSize), toBlock: fromBlock };
@@ -161,6 +168,7 @@ Object.defineProperty(exports, "writeContract", {
161
168
  get: function () { return smartAccount.writeContract; }
162
169
  });
163
170
  exports.fetchByBlockRange = fetchByBlockRange;
171
+ exports.traceActions = traceActions;
164
172
  exports.traceFilter = traceFilter;
165
173
  exports.traceTransaction = traceTransaction;
166
174
  Object.keys(actions).forEach(function (k) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/actions/traceFilter.ts","../../src/actions/traceTransaction.ts","../../src/actions/fetchByBlockRange.ts"],"sourcesContent":["import type { TraceFilterParameters, TraceFilterReturnType, CoreClient, Hash } from \"../types\";\n\n/**\n * Calls the 'trace_filter' RPC method to retrieve execution traces\n * filtered according to the specified criteria.\n *\n * This function sends a JSON-RPC request to the Ethereum node (or EVM-compatible)\n * via the provided client object and returns the array of trace entries matching\n * the filters.\n * \n * NOTE: This method relies on the non-standard 'trace_filter' method of the RPC.\n * It may not be supported by all nodes.\n *\n * @param client The CoreClient instance used to perform the RPC call.\n * @param params The filtering parameters for the trace request (block range, addresses, etc.).\n * @returns A promise that returns an array of trace entries (GenericTraceEntry[])\n * that match the filtering criteria.\n */\nexport async function traceFilter(client: CoreClient, params: TraceFilterParameters): Promise<TraceFilterReturnType> {\n if (typeof params.fromAddress === \"string\") params.fromAddress = [params.fromAddress];\n if (typeof params.toAddress === \"string\") params.toAddress = [params.toAddress];\n \n return await client.request<{\n method: 'trace_filter',\n Parameters: TraceFilterParameters[],\n ReturnType: TraceFilterReturnType\n }>({\n method: 'trace_filter',\n params: [params],\n });\n}","import type { TraceTransactionParameters, TraceTransactionReturnType, CoreClient, Hash } from \"../types\";\n\n/**\n * Calls the 'trace_transaction' RPC method to retrieve execution traces\n * for a specific transaction hash.\n *\n * This function sends a JSON-RPC request to the Ethereum node (or EVM-compatible)\n * via the provided client object and returns the array of trace entries for\n * the specified transaction hash.\n * \n * NOTE: This method relies on the non-standard 'trace_transaction' method of the RPC.\n * It may not be supported by all nodes.\n * \n * @param client The CoreClient instance used to perform the RPC call.\n * @param params The transaction hash for which to retrieve traces.\n * @returns A promise that returns an array of trace entries (GenericTraceEntry[])\n * for the specified transaction hash.\n */\nexport async function traceTransaction(client: CoreClient, params: TraceTransactionParameters): Promise<TraceTransactionReturnType> {\n return await client.request<{\n method: 'trace_transaction',\n Parameters: TraceTransactionParameters[],\n ReturnType: TraceTransactionReturnType\n }>({\n method: 'trace_transaction',\n params: [params],\n });\n}","import { FetchBlockRangeParameters } from \"../types/BlockRangeFetcher\";\n\nfunction calcBlockRange(fromBlock: bigint, rangeSize: number, direction: \"backward\" | \"forward\" = \"forward\") {\n if (direction === \"backward\") return { fromBlock: fromBlock - BigInt(rangeSize), toBlock: fromBlock };\n return { fromBlock: fromBlock, toBlock: fromBlock + BigInt(rangeSize) };\n};\n\nfunction hasHitBlockLimit(blockNumber: bigint, direction: \"backward\" | \"forward\", blockLimit: bigint) {\n return direction === \"backward\" ? blockNumber < blockLimit : blockNumber > blockLimit;\n};\n\nfunction hasHitItemLimit(items: any[], itemLimit: number) {\n return items.length >= itemLimit;\n};\n\n/**\n * Fetch large amounts of data in batches by exploring with dynamic block ranges.\n * \n * Block ranges automatically adjust based on the provided configuration and how many items are found per batch. \n * If the actual block range returns too many items, the explorer will automatically reduce the range size for the next batch. \n * If the actual block range returns too few items, the explorer will automatically increase the range size for the next batch.\n * \n * This method is optimized to maximize efficiency by fetching items and minimizing the charge on the RPC node by \n * requesting too many items per batch or too many batches per second.\n * \n * Useful for methods like `eth_getLogs` or `trace_filter` that iterate over blocks to find items.\n * \n * @param params - The parameters for creating the explorer.\n */\nexport async function fetchByBlockRange(params: FetchBlockRangeParameters) {\n const options = {\n\n // By how much to increase/decrease the range size if the batch returns few/many items\n dividerOnHigh: 2,\n multiplierOnLow: 1.5,\n multiplierOnZero: 2,\n\n // How to determine if the batch returned few/many items\n highActivityThreshold: 50,\n lowActivityThreshold: 10,\n\n // Limits and init values for the range size\n initialRangeSize: 100,\n maxRangeSize: 100_000,\n minRangeSize: 1,\n\n // \n ...params.options,\n };\n\n let currentBlock = params.fromBlock;\n let rangeSize = options.initialRangeSize;\n let stopped = false;\n\n const stop = () => {\n stopped = true;\n };\n\n const totalItems: any[] = [];\n\n function shouldStop() {\n return hasHitBlockLimit(currentBlock, params.direction, params.toBlock) || hasHitItemLimit(totalItems, params.itemLimit);\n }\n\n while (!stopped && !shouldStop() ) {\n const blockRange = calcBlockRange(currentBlock, rangeSize, params.direction);\n\n // Cap the block range to the overall limits\n if (params.direction === \"forward\") {\n if (blockRange.toBlock > params.toBlock) {\n blockRange.toBlock = params.toBlock;\n }\n } else { // backward\n if (blockRange.fromBlock < params.toBlock) {\n blockRange.fromBlock = params.toBlock;\n }\n }\n\n const batchItems = await params.onBlockRange(blockRange, stop);\n\n totalItems.push(...batchItems);\n\n if (stopped) break;\n\n // Adjust range size based on activity\n if (batchItems.length > options.highActivityThreshold) {\n rangeSize /= options.dividerOnHigh;\n } else if (batchItems.length === 0) {\n rangeSize *= options.multiplierOnZero;\n } else if (batchItems.length <= options.lowActivityThreshold) {\n rangeSize *= options.multiplierOnLow;\n }\n\n // Cap and round the range size\n rangeSize = Math.round(\n Math.max(options.minRangeSize, Math.min(options.maxRangeSize, rangeSize))\n );\n\n // Determine the next block to start from, fixing the \"backward\" direction logic\n if (params.direction === \"backward\") {\n currentBlock = blockRange.fromBlock - 1n;\n } else {\n currentBlock = blockRange.toBlock + 1n;\n }\n }\n\n return totalItems.slice(0, params.itemLimit);\n}\n"],"names":[],"mappings":";;;;;AAEA;;;;;;;;;;;;;;;AA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AM,CAAC,OAAO;YACzC;QACJ;QAEA,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,UAAU,EAAE,IAAI,CAAC;AAE9D,QAAA,UAAU,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC;AAE9B,QAAA,IAAI,OAAO;YAAE;;QAGb,IAAI,UAAU,CAAC,MAAM,GAAG,OAAO,CAAC,qBAAqB,EAAE;AACnD,YAAA,SAAS,IAAI,OAAO,CAAC,aAAa;QACtC;AAAO,aAAA,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE;AAChC,YAAA,SAAS,IAAI,OAAO,CAAC,gBAAgB;QACzC;aAAO,IAAI,UAAU,CAAC,MAAM,IAAI,OAAO,CAAC,oBAAoB,EAAE;AAC1D,YAAA,SAAS,IAAI,OAAO,CAAC,eAAe;QACxC;;QAGA,SAAS,GAAG,IAAI,CAAC,KAAK,CAClB,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,YAAY,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC,CAC5E;;AAGD,QAAA,IAAI,MAAM,CAAC,SAAS,KAAK,UAAU,EAAE;AACjC,YAAA,YAAY,GAAG,UAAU,CAAC,SAAS,GAAG,EAAE;QAC5C;aAAO;AACH,YAAA,YAAY,GAAG,UAAU,CAAC,OAAO,GAAG,EAAE;QAC1C;IACJ;IAEA,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,SAAS,CAAC;AAChD;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/actions/traceFilter.ts","../../src/actions/traceTransaction.ts","../../src/actions/traceActions.ts","../../src/actions/fetchByBlockRange.ts"],"sourcesContent":["import type { Client, Transport, Chain } from \"viem\";\nimport type { TraceFilterParameters, TraceFilterReturnType } from \"../types\";\n\n/**\n * Calls the 'trace_filter' RPC method to retrieve execution traces\n * filtered according to the specified criteria.\n *\n * This function sends a JSON-RPC request to the Ethereum node (or EVM-compatible)\n * via the provided client object and returns the array of trace entries matching\n * the filters.\n *\n * NOTE: This method relies on the non-standard 'trace_filter' method of the RPC.\n * It may not be supported by all nodes.\n *\n * @param client The client instance used to perform the RPC call.\n * @param params The filtering parameters for the trace request (block range, addresses, etc.).\n * @returns A promise that returns an array of trace entries (GenericTraceEntry[])\n * that match the filtering criteria.\n */\nexport async function traceFilter<TChain extends Chain | undefined>(\n client: Client<Transport, TChain>,\n params: TraceFilterParameters,\n): Promise<TraceFilterReturnType> {\n if (typeof params.fromAddress === \"string\")\n params.fromAddress = [params.fromAddress];\n if (typeof params.toAddress === \"string\")\n params.toAddress = [params.toAddress];\n\n return await client.request<{\n method: \"trace_filter\";\n Parameters: TraceFilterParameters[];\n ReturnType: TraceFilterReturnType;\n }>({\n method: \"trace_filter\",\n params: [params],\n });\n}\n","import type { Client, Transport, Chain } from \"viem\";\nimport type {\n TraceTransactionParameters,\n TraceTransactionReturnType,\n} from \"../types\";\n\n/**\n * Calls the 'trace_transaction' RPC method to retrieve execution traces\n * for a specific transaction hash.\n *\n * This function sends a JSON-RPC request to the Ethereum node (or EVM-compatible)\n * via the provided client object and returns the array of trace entries for\n * the specified transaction hash.\n *\n * NOTE: This method relies on the non-standard 'trace_transaction' method of the RPC.\n * It may not be supported by all nodes.\n *\n * @param client The client instance used to perform the RPC call.\n * @param params The transaction hash for which to retrieve traces.\n * @returns A promise that returns an array of trace entries (GenericTraceEntry[])\n * for the specified transaction hash.\n */\nexport async function traceTransaction<TChain extends Chain | undefined>(\n client: Client<Transport, TChain>,\n params: TraceTransactionParameters,\n): Promise<TraceTransactionReturnType> {\n return await client.request<{\n method: \"trace_transaction\";\n Parameters: TraceTransactionParameters[];\n ReturnType: TraceTransactionReturnType;\n }>({\n method: \"trace_transaction\",\n params: [params],\n });\n}\n","import type { Chain, Client, Transport } from \"viem\";\nimport type {\n TraceFilterParameters,\n TraceFilterReturnType,\n TraceTransactionParameters,\n TraceTransactionReturnType,\n} from \"../types\";\nimport { traceFilter } from \"./traceFilter\";\nimport { traceTransaction } from \"./traceTransaction\";\n\nexport type TraceActions = {\n traceFilter: (args: TraceFilterParameters) => Promise<TraceFilterReturnType>;\n traceTransaction: (\n args: TraceTransactionParameters,\n ) => Promise<TraceTransactionReturnType>;\n};\n\nexport function traceActions(): <TChain extends Chain | undefined>(\n client: Client<Transport, TChain>,\n) => TraceActions {\n return (client) => ({\n traceFilter: (args) => traceFilter(client, args),\n traceTransaction: (args) => traceTransaction(client, args),\n });\n}\n","import { FetchBlockRangeParameters } from \"../types/BlockRangeFetcher\";\n\nfunction calcBlockRange(fromBlock: bigint, rangeSize: number, direction: \"backward\" | \"forward\" = \"forward\") {\n if (direction === \"backward\") return { fromBlock: fromBlock - BigInt(rangeSize), toBlock: fromBlock };\n return { fromBlock: fromBlock, toBlock: fromBlock + BigInt(rangeSize) };\n};\n\nfunction hasHitBlockLimit(blockNumber: bigint, direction: \"backward\" | \"forward\", blockLimit: bigint) {\n return direction === \"backward\" ? blockNumber < blockLimit : blockNumber > blockLimit;\n};\n\nfunction hasHitItemLimit(items: any[], itemLimit: number) {\n return items.length >= itemLimit;\n};\n\n/**\n * Fetch large amounts of data in batches by exploring with dynamic block ranges.\n * \n * Block ranges automatically adjust based on the provided configuration and how many items are found per batch. \n * If the actual block range returns too many items, the explorer will automatically reduce the range size for the next batch. \n * If the actual block range returns too few items, the explorer will automatically increase the range size for the next batch.\n * \n * This method is optimized to maximize efficiency by fetching items and minimizing the charge on the RPC node by \n * requesting too many items per batch or too many batches per second.\n * \n * Useful for methods like `eth_getLogs` or `trace_filter` that iterate over blocks to find items.\n * \n * @param params - The parameters for creating the explorer.\n */\nexport async function fetchByBlockRange(params: FetchBlockRangeParameters) {\n const options = {\n\n // By how much to increase/decrease the range size if the batch returns few/many items\n dividerOnHigh: 2,\n multiplierOnLow: 1.5,\n multiplierOnZero: 2,\n\n // How to determine if the batch returned few/many items\n highActivityThreshold: 50,\n lowActivityThreshold: 10,\n\n // Limits and init values for the range size\n initialRangeSize: 100,\n maxRangeSize: 100_000,\n minRangeSize: 1,\n\n // \n ...params.options,\n };\n\n let currentBlock = params.fromBlock;\n let rangeSize = options.initialRangeSize;\n let stopped = false;\n\n const stop = () => {\n stopped = true;\n };\n\n const totalItems: any[] = [];\n\n function shouldStop() {\n return hasHitBlockLimit(currentBlock, params.direction, params.toBlock) || hasHitItemLimit(totalItems, params.itemLimit);\n }\n\n while (!stopped && !shouldStop() ) {\n const blockRange = calcBlockRange(currentBlock, rangeSize, params.direction);\n\n // Cap the block range to the overall limits\n if (params.direction === \"forward\") {\n if (blockRange.toBlock > params.toBlock) {\n blockRange.toBlock = params.toBlock;\n }\n } else { // backward\n if (blockRange.fromBlock < params.toBlock) {\n blockRange.fromBlock = params.toBlock;\n }\n }\n\n const batchItems = await params.onBlockRange(blockRange, stop);\n\n totalItems.push(...batchItems);\n\n if (stopped) break;\n\n // Adjust range size based on activity\n if (batchItems.length > options.highActivityThreshold) {\n rangeSize /= options.dividerOnHigh;\n } else if (batchItems.length === 0) {\n rangeSize *= options.multiplierOnZero;\n } else if (batchItems.length <= options.lowActivityThreshold) {\n rangeSize *= options.multiplierOnLow;\n }\n\n // Cap and round the range size\n rangeSize = Math.round(\n Math.max(options.minRangeSize, Math.min(options.maxRangeSize, rangeSize))\n );\n\n // Determine the next block to start from, fixing the \"backward\" direction logic\n if (params.direction === \"backward\") {\n currentBlock = blockRange.fromBlock - 1n;\n } else {\n currentBlock = blockRange.toBlock + 1n;\n }\n }\n\n return totalItems.slice(0, params.itemLimit);\n}\n"],"names":[],"mappings":";;;;;AAGA;;;;;;;;;;;;;;;AAeG;AACI,eAAe,WAAW,CAC/B,MAAiC,EACjC,MAA6B,EAAA;AAE7B,IAAA,IAAI,OAAO,MAAM,CAAC,WAAW,KAAK,QAAQ;QACxC,MAAM,CAAC,WAAW,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC;AAC3C,IAAA,I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,OAAO,EAAE;AACvC,gBAAA,UAAU,CAAC,SAAS,GAAG,MAAM,CAAC,OAAO;YACzC;QACJ;QAEA,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,UAAU,EAAE,IAAI,CAAC;AAE9D,QAAA,UAAU,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC;AAE9B,QAAA,IAAI,OAAO;YAAE;;QAGb,IAAI,UAAU,CAAC,MAAM,GAAG,OAAO,CAAC,qBAAqB,EAAE;AACnD,YAAA,SAAS,IAAI,OAAO,CAAC,aAAa;QACtC;AAAO,aAAA,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE;AAChC,YAAA,SAAS,IAAI,OAAO,CAAC,gBAAgB;QACzC;aAAO,IAAI,UAAU,CAAC,MAAM,IAAI,OAAO,CAAC,oBAAoB,EAAE;AAC1D,YAAA,SAAS,IAAI,OAAO,CAAC,eAAe;QACxC;;QAGA,SAAS,GAAG,IAAI,CAAC,KAAK,CAClB,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,YAAY,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC,CAC5E;;AAGD,QAAA,IAAI,MAAM,CAAC,SAAS,KAAK,UAAU,EAAE;AACjC,YAAA,YAAY,GAAG,UAAU,CAAC,SAAS,GAAG,EAAE;QAC5C;aAAO;AACH,YAAA,YAAY,GAAG,UAAU,CAAC,OAAO,GAAG,EAAE;QAC1C;IACJ;IAEA,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,SAAS,CAAC;AAChD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -12,7 +12,7 @@ export { sendTransaction, signMessage, signTypedData, writeContract } from 'perm
12
12
  * NOTE: This method relies on the non-standard 'trace_filter' method of the RPC.
13
13
  * It may not be supported by all nodes.
14
14
  *
15
- * @param client The CoreClient instance used to perform the RPC call.
15
+ * @param client The client instance used to perform the RPC call.
16
16
  * @param params The filtering parameters for the trace request (block range, addresses, etc.).
17
17
  * @returns A promise that returns an array of trace entries (GenericTraceEntry[])
18
18
  * that match the filtering criteria.
@@ -23,7 +23,7 @@ async function traceFilter(client, params) {
23
23
  if (typeof params.toAddress === "string")
24
24
  params.toAddress = [params.toAddress];
25
25
  return await client.request({
26
- method: 'trace_filter',
26
+ method: "trace_filter",
27
27
  params: [params],
28
28
  });
29
29
  }
@@ -39,18 +39,25 @@ async function traceFilter(client, params) {
39
39
  * NOTE: This method relies on the non-standard 'trace_transaction' method of the RPC.
40
40
  * It may not be supported by all nodes.
41
41
  *
42
- * @param client The CoreClient instance used to perform the RPC call.
42
+ * @param client The client instance used to perform the RPC call.
43
43
  * @param params The transaction hash for which to retrieve traces.
44
44
  * @returns A promise that returns an array of trace entries (GenericTraceEntry[])
45
45
  * for the specified transaction hash.
46
46
  */
47
47
  async function traceTransaction(client, params) {
48
48
  return await client.request({
49
- method: 'trace_transaction',
49
+ method: "trace_transaction",
50
50
  params: [params],
51
51
  });
52
52
  }
53
53
 
54
+ function traceActions() {
55
+ return (client) => ({
56
+ traceFilter: (args) => traceFilter(client, args),
57
+ traceTransaction: (args) => traceTransaction(client, args),
58
+ });
59
+ }
60
+
54
61
  function calcBlockRange(fromBlock, rangeSize, direction = "forward") {
55
62
  if (direction === "backward")
56
63
  return { fromBlock: fromBlock - BigInt(rangeSize), toBlock: fromBlock };
@@ -142,5 +149,5 @@ async function fetchByBlockRange(params) {
142
149
  return totalItems.slice(0, params.itemLimit);
143
150
  }
144
151
 
145
- export { fetchByBlockRange, traceFilter, traceTransaction };
152
+ export { fetchByBlockRange, traceActions, traceFilter, traceTransaction };
146
153
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../src/actions/traceFilter.ts","../../src/actions/traceTransaction.ts","../../src/actions/fetchByBlockRange.ts"],"sourcesContent":["import type { TraceFilterParameters, TraceFilterReturnType, CoreClient, Hash } from \"../types\";\n\n/**\n * Calls the 'trace_filter' RPC method to retrieve execution traces\n * filtered according to the specified criteria.\n *\n * This function sends a JSON-RPC request to the Ethereum node (or EVM-compatible)\n * via the provided client object and returns the array of trace entries matching\n * the filters.\n * \n * NOTE: This method relies on the non-standard 'trace_filter' method of the RPC.\n * It may not be supported by all nodes.\n *\n * @param client The CoreClient instance used to perform the RPC call.\n * @param params The filtering parameters for the trace request (block range, addresses, etc.).\n * @returns A promise that returns an array of trace entries (GenericTraceEntry[])\n * that match the filtering criteria.\n */\nexport async function traceFilter(client: CoreClient, params: TraceFilterParameters): Promise<TraceFilterReturnType> {\n if (typeof params.fromAddress === \"string\") params.fromAddress = [params.fromAddress];\n if (typeof params.toAddress === \"string\") params.toAddress = [params.toAddress];\n \n return await client.request<{\n method: 'trace_filter',\n Parameters: TraceFilterParameters[],\n ReturnType: TraceFilterReturnType\n }>({\n method: 'trace_filter',\n params: [params],\n });\n}","import type { TraceTransactionParameters, TraceTransactionReturnType, CoreClient, Hash } from \"../types\";\n\n/**\n * Calls the 'trace_transaction' RPC method to retrieve execution traces\n * for a specific transaction hash.\n *\n * This function sends a JSON-RPC request to the Ethereum node (or EVM-compatible)\n * via the provided client object and returns the array of trace entries for\n * the specified transaction hash.\n * \n * NOTE: This method relies on the non-standard 'trace_transaction' method of the RPC.\n * It may not be supported by all nodes.\n * \n * @param client The CoreClient instance used to perform the RPC call.\n * @param params The transaction hash for which to retrieve traces.\n * @returns A promise that returns an array of trace entries (GenericTraceEntry[])\n * for the specified transaction hash.\n */\nexport async function traceTransaction(client: CoreClient, params: TraceTransactionParameters): Promise<TraceTransactionReturnType> {\n return await client.request<{\n method: 'trace_transaction',\n Parameters: TraceTransactionParameters[],\n ReturnType: TraceTransactionReturnType\n }>({\n method: 'trace_transaction',\n params: [params],\n });\n}","import { FetchBlockRangeParameters } from \"../types/BlockRangeFetcher\";\n\nfunction calcBlockRange(fromBlock: bigint, rangeSize: number, direction: \"backward\" | \"forward\" = \"forward\") {\n if (direction === \"backward\") return { fromBlock: fromBlock - BigInt(rangeSize), toBlock: fromBlock };\n return { fromBlock: fromBlock, toBlock: fromBlock + BigInt(rangeSize) };\n};\n\nfunction hasHitBlockLimit(blockNumber: bigint, direction: \"backward\" | \"forward\", blockLimit: bigint) {\n return direction === \"backward\" ? blockNumber < blockLimit : blockNumber > blockLimit;\n};\n\nfunction hasHitItemLimit(items: any[], itemLimit: number) {\n return items.length >= itemLimit;\n};\n\n/**\n * Fetch large amounts of data in batches by exploring with dynamic block ranges.\n * \n * Block ranges automatically adjust based on the provided configuration and how many items are found per batch. \n * If the actual block range returns too many items, the explorer will automatically reduce the range size for the next batch. \n * If the actual block range returns too few items, the explorer will automatically increase the range size for the next batch.\n * \n * This method is optimized to maximize efficiency by fetching items and minimizing the charge on the RPC node by \n * requesting too many items per batch or too many batches per second.\n * \n * Useful for methods like `eth_getLogs` or `trace_filter` that iterate over blocks to find items.\n * \n * @param params - The parameters for creating the explorer.\n */\nexport async function fetchByBlockRange(params: FetchBlockRangeParameters) {\n const options = {\n\n // By how much to increase/decrease the range size if the batch returns few/many items\n dividerOnHigh: 2,\n multiplierOnLow: 1.5,\n multiplierOnZero: 2,\n\n // How to determine if the batch returned few/many items\n highActivityThreshold: 50,\n lowActivityThreshold: 10,\n\n // Limits and init values for the range size\n initialRangeSize: 100,\n maxRangeSize: 100_000,\n minRangeSize: 1,\n\n // \n ...params.options,\n };\n\n let currentBlock = params.fromBlock;\n let rangeSize = options.initialRangeSize;\n let stopped = false;\n\n const stop = () => {\n stopped = true;\n };\n\n const totalItems: any[] = [];\n\n function shouldStop() {\n return hasHitBlockLimit(currentBlock, params.direction, params.toBlock) || hasHitItemLimit(totalItems, params.itemLimit);\n }\n\n while (!stopped && !shouldStop() ) {\n const blockRange = calcBlockRange(currentBlock, rangeSize, params.direction);\n\n // Cap the block range to the overall limits\n if (params.direction === \"forward\") {\n if (blockRange.toBlock > params.toBlock) {\n blockRange.toBlock = params.toBlock;\n }\n } else { // backward\n if (blockRange.fromBlock < params.toBlock) {\n blockRange.fromBlock = params.toBlock;\n }\n }\n\n const batchItems = await params.onBlockRange(blockRange, stop);\n\n totalItems.push(...batchItems);\n\n if (stopped) break;\n\n // Adjust range size based on activity\n if (batchItems.length > options.highActivityThreshold) {\n rangeSize /= options.dividerOnHigh;\n } else if (batchItems.length === 0) {\n rangeSize *= options.multiplierOnZero;\n } else if (batchItems.length <= options.lowActivityThreshold) {\n rangeSize *= options.multiplierOnLow;\n }\n\n // Cap and round the range size\n rangeSize = Math.round(\n Math.max(options.minRangeSize, Math.min(options.maxRangeSize, rangeSize))\n );\n\n // Determine the next block to start from, fixing the \"backward\" direction logic\n if (params.direction === \"backward\") {\n currentBlock = blockRange.fromBlock - 1n;\n } else {\n currentBlock = blockRange.toBlock + 1n;\n }\n }\n\n return totalItems.slice(0, params.itemLimit);\n}\n"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;;;AAeG;AACI,eAAe,WAAW,CAAC,MAAkB,EAAE,MAA6B,EAAA;AAC/E,IAAA,IAAI,OAAO,MAAM,CAAC,WAAW,KAAK,QAAQ;QAAE,MAAM,CAAC,WAAW,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC;AACrF,IAAA,IAAI,OAAO,MAAM,CAAC,SAAS,KAAK,QAAQ;QAAE,MAAM,CAAC,SAAS,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC;AAE/E,IAAA,OAAO,MAAM,MAAM,CAAC,OAAO,CAIxB;AACC,QAAA,MAAM,EAAE,cAAc;QACtB,MAAM,EAAE,CAAC,MAAM,CAAC;AACnB,KAAA,CAAC;AACN;;AC5BA;;;;;;;;;;;;;;;AAeG;AACI,eAAe,gBAAgB,CAAC,MAAkB,EAAE,MAAkC,EAAA;AACzF,IAAA,OAAO,MAAM,MAAM,CAAC,OAAO,CAIxB;AACC,QAAA,MAAM,EAAE,mBAAmB;QAC3B,MAAM,EAAE,CAAC,MAAM,CAAC;AACnB,KAAA,CAAC;AACN;;ACz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Y,EAAE,SAAS,CAAC,CAAC,CAC5E;;AAGD,QAAA,IAAI,MAAM,CAAC,SAAS,KAAK,UAAU,EAAE;AACjC,YAAA,YAAY,GAAG,UAAU,CAAC,SAAS,GAAG,EAAE;QAC5C;aAAO;AACH,YAAA,YAAY,GAAG,UAAU,CAAC,OAAO,GAAG,EAAE;QAC1C;IACJ;IAEA,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,SAAS,CAAC;AAChD;;;;"}
1
+ {"version":3,"file":"index.mjs","sources":["../../src/actions/traceFilter.ts","../../src/actions/traceTransaction.ts","../../src/actions/traceActions.ts","../../src/actions/fetchByBlockRange.ts"],"sourcesContent":["import type { Client, Transport, Chain } from \"viem\";\nimport type { TraceFilterParameters, TraceFilterReturnType } from \"../types\";\n\n/**\n * Calls the 'trace_filter' RPC method to retrieve execution traces\n * filtered according to the specified criteria.\n *\n * This function sends a JSON-RPC request to the Ethereum node (or EVM-compatible)\n * via the provided client object and returns the array of trace entries matching\n * the filters.\n *\n * NOTE: This method relies on the non-standard 'trace_filter' method of the RPC.\n * It may not be supported by all nodes.\n *\n * @param client The client instance used to perform the RPC call.\n * @param params The filtering parameters for the trace request (block range, addresses, etc.).\n * @returns A promise that returns an array of trace entries (GenericTraceEntry[])\n * that match the filtering criteria.\n */\nexport async function traceFilter<TChain extends Chain | undefined>(\n client: Client<Transport, TChain>,\n params: TraceFilterParameters,\n): Promise<TraceFilterReturnType> {\n if (typeof params.fromAddress === \"string\")\n params.fromAddress = [params.fromAddress];\n if (typeof params.toAddress === \"string\")\n params.toAddress = [params.toAddress];\n\n return await client.request<{\n method: \"trace_filter\";\n Parameters: TraceFilterParameters[];\n ReturnType: TraceFilterReturnType;\n }>({\n method: \"trace_filter\",\n params: [params],\n });\n}\n","import type { Client, Transport, Chain } from \"viem\";\nimport type {\n TraceTransactionParameters,\n TraceTransactionReturnType,\n} from \"../types\";\n\n/**\n * Calls the 'trace_transaction' RPC method to retrieve execution traces\n * for a specific transaction hash.\n *\n * This function sends a JSON-RPC request to the Ethereum node (or EVM-compatible)\n * via the provided client object and returns the array of trace entries for\n * the specified transaction hash.\n *\n * NOTE: This method relies on the non-standard 'trace_transaction' method of the RPC.\n * It may not be supported by all nodes.\n *\n * @param client The client instance used to perform the RPC call.\n * @param params The transaction hash for which to retrieve traces.\n * @returns A promise that returns an array of trace entries (GenericTraceEntry[])\n * for the specified transaction hash.\n */\nexport async function traceTransaction<TChain extends Chain | undefined>(\n client: Client<Transport, TChain>,\n params: TraceTransactionParameters,\n): Promise<TraceTransactionReturnType> {\n return await client.request<{\n method: \"trace_transaction\";\n Parameters: TraceTransactionParameters[];\n ReturnType: TraceTransactionReturnType;\n }>({\n method: \"trace_transaction\",\n params: [params],\n });\n}\n","import type { Chain, Client, Transport } from \"viem\";\nimport type {\n TraceFilterParameters,\n TraceFilterReturnType,\n TraceTransactionParameters,\n TraceTransactionReturnType,\n} from \"../types\";\nimport { traceFilter } from \"./traceFilter\";\nimport { traceTransaction } from \"./traceTransaction\";\n\nexport type TraceActions = {\n traceFilter: (args: TraceFilterParameters) => Promise<TraceFilterReturnType>;\n traceTransaction: (\n args: TraceTransactionParameters,\n ) => Promise<TraceTransactionReturnType>;\n};\n\nexport function traceActions(): <TChain extends Chain | undefined>(\n client: Client<Transport, TChain>,\n) => TraceActions {\n return (client) => ({\n traceFilter: (args) => traceFilter(client, args),\n traceTransaction: (args) => traceTransaction(client, args),\n });\n}\n","import { FetchBlockRangeParameters } from \"../types/BlockRangeFetcher\";\n\nfunction calcBlockRange(fromBlock: bigint, rangeSize: number, direction: \"backward\" | \"forward\" = \"forward\") {\n if (direction === \"backward\") return { fromBlock: fromBlock - BigInt(rangeSize), toBlock: fromBlock };\n return { fromBlock: fromBlock, toBlock: fromBlock + BigInt(rangeSize) };\n};\n\nfunction hasHitBlockLimit(blockNumber: bigint, direction: \"backward\" | \"forward\", blockLimit: bigint) {\n return direction === \"backward\" ? blockNumber < blockLimit : blockNumber > blockLimit;\n};\n\nfunction hasHitItemLimit(items: any[], itemLimit: number) {\n return items.length >= itemLimit;\n};\n\n/**\n * Fetch large amounts of data in batches by exploring with dynamic block ranges.\n * \n * Block ranges automatically adjust based on the provided configuration and how many items are found per batch. \n * If the actual block range returns too many items, the explorer will automatically reduce the range size for the next batch. \n * If the actual block range returns too few items, the explorer will automatically increase the range size for the next batch.\n * \n * This method is optimized to maximize efficiency by fetching items and minimizing the charge on the RPC node by \n * requesting too many items per batch or too many batches per second.\n * \n * Useful for methods like `eth_getLogs` or `trace_filter` that iterate over blocks to find items.\n * \n * @param params - The parameters for creating the explorer.\n */\nexport async function fetchByBlockRange(params: FetchBlockRangeParameters) {\n const options = {\n\n // By how much to increase/decrease the range size if the batch returns few/many items\n dividerOnHigh: 2,\n multiplierOnLow: 1.5,\n multiplierOnZero: 2,\n\n // How to determine if the batch returned few/many items\n highActivityThreshold: 50,\n lowActivityThreshold: 10,\n\n // Limits and init values for the range size\n initialRangeSize: 100,\n maxRangeSize: 100_000,\n minRangeSize: 1,\n\n // \n ...params.options,\n };\n\n let currentBlock = params.fromBlock;\n let rangeSize = options.initialRangeSize;\n let stopped = false;\n\n const stop = () => {\n stopped = true;\n };\n\n const totalItems: any[] = [];\n\n function shouldStop() {\n return hasHitBlockLimit(currentBlock, params.direction, params.toBlock) || hasHitItemLimit(totalItems, params.itemLimit);\n }\n\n while (!stopped && !shouldStop() ) {\n const blockRange = calcBlockRange(currentBlock, rangeSize, params.direction);\n\n // Cap the block range to the overall limits\n if (params.direction === \"forward\") {\n if (blockRange.toBlock > params.toBlock) {\n blockRange.toBlock = params.toBlock;\n }\n } else { // backward\n if (blockRange.fromBlock < params.toBlock) {\n blockRange.fromBlock = params.toBlock;\n }\n }\n\n const batchItems = await params.onBlockRange(blockRange, stop);\n\n totalItems.push(...batchItems);\n\n if (stopped) break;\n\n // Adjust range size based on activity\n if (batchItems.length > options.highActivityThreshold) {\n rangeSize /= options.dividerOnHigh;\n } else if (batchItems.length === 0) {\n rangeSize *= options.multiplierOnZero;\n } else if (batchItems.length <= options.lowActivityThreshold) {\n rangeSize *= options.multiplierOnLow;\n }\n\n // Cap and round the range size\n rangeSize = Math.round(\n Math.max(options.minRangeSize, Math.min(options.maxRangeSize, rangeSize))\n );\n\n // Determine the next block to start from, fixing the \"backward\" direction logic\n if (params.direction === \"backward\") {\n currentBlock = blockRange.fromBlock - 1n;\n } else {\n currentBlock = blockRange.toBlock + 1n;\n }\n }\n\n return totalItems.slice(0, params.itemLimit);\n}\n"],"names":[],"mappings":";;;AAGA;;;;;;;;;;;;;;;AAeG;AACI,eAAe,WAAW,CAC/B,MAAiC,EACjC,MAA6B,EAAA;AAE7B,IAAA,IAAI,OAAO,MAAM,CAAC,WAAW,KAAK,QAAQ;QACxC,MAAM,CAAC,WAAW,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC;AAC3C,IAAA,IAAI,OAAO,MAAM,CAAC,SAAS,KAAK,QAAQ;QACtC,MAAM,CAAC,SAAS,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC;AAEvC,IAAA,OAAO,MAAM,MAAM,CAAC,OAAO,CAIxB;AACD,QAAA,MAAM,EAAE,cAAc;QACtB,MAAM,EAAE,CAAC,MAAM,CAAC;AACjB,KAAA,CAAC;AACJ;;AC9BA;;;;;;;;;;;;;;;AAeG;AACI,eAAe,gBAAgB,CACpC,MAAiC,EACjC,MAAkC,EAAA;AAElC,IAAA,OAAO,MAAM,MAAM,CAAC,OAAO,CAIxB;AACD,QAAA,MAAM,EAAE,mBAAmB;QAC3B,MAAM,EAAE,CAAC,MAAM,CAAC;AACjB,KAAA,CAAC;AACJ;;SCjBgB,YAAY,GAAA;AAG1B,IAAA,OAAO,CAAC,MAAM,MAAM;QAClB,WAAW,EAAE,CAAC,IAAI,KAAK,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC;QAChD,gBAAgB,EAAE,CAAC,IAAI,KAAK,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC;AAC3D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G,CAAC,OAAO,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC,CAC5E;;AAGD,QAAA,IAAI,MAAM,CAAC,SAAS,KAAK,UAAU,EAAE;AACjC,YAAA,YAAY,GAAG,UAAU,CAAC,SAAS,GAAG,EAAE;QAC5C;aAAO;AACH,YAAA,YAAY,GAAG,UAAU,CAAC,OAAO,GAAG,EAAE;QAC1C;IACJ;IAEA,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,SAAS,CAAC;AAChD;;;;"}
@@ -0,0 +1,7 @@
1
+ import type { Chain, Client, Transport } from "viem";
2
+ import type { TraceFilterParameters, TraceFilterReturnType, TraceTransactionParameters, TraceTransactionReturnType } from "../types";
3
+ export type TraceActions = {
4
+ traceFilter: (args: TraceFilterParameters) => Promise<TraceFilterReturnType>;
5
+ traceTransaction: (args: TraceTransactionParameters) => Promise<TraceTransactionReturnType>;
6
+ };
7
+ export declare function traceActions(): <TChain extends Chain | undefined>(client: Client<Transport, TChain>) => TraceActions;
@@ -1,4 +1,5 @@
1
- import type { TraceFilterParameters, TraceFilterReturnType, CoreClient } from "../types";
1
+ import type { Client, Transport, Chain } from "viem";
2
+ import type { TraceFilterParameters, TraceFilterReturnType } from "../types";
2
3
  /**
3
4
  * Calls the 'trace_filter' RPC method to retrieve execution traces
4
5
  * filtered according to the specified criteria.
@@ -10,9 +11,9 @@ import type { TraceFilterParameters, TraceFilterReturnType, CoreClient } from ".
10
11
  * NOTE: This method relies on the non-standard 'trace_filter' method of the RPC.
11
12
  * It may not be supported by all nodes.
12
13
  *
13
- * @param client The CoreClient instance used to perform the RPC call.
14
+ * @param client The client instance used to perform the RPC call.
14
15
  * @param params The filtering parameters for the trace request (block range, addresses, etc.).
15
16
  * @returns A promise that returns an array of trace entries (GenericTraceEntry[])
16
17
  * that match the filtering criteria.
17
18
  */
18
- export declare function traceFilter(client: CoreClient, params: TraceFilterParameters): Promise<TraceFilterReturnType>;
19
+ export declare function traceFilter<TChain extends Chain | undefined>(client: Client<Transport, TChain>, params: TraceFilterParameters): Promise<TraceFilterReturnType>;
@@ -1,4 +1,5 @@
1
- import type { TraceTransactionParameters, TraceTransactionReturnType, CoreClient } from "../types";
1
+ import type { Client, Transport, Chain } from "viem";
2
+ import type { TraceTransactionParameters, TraceTransactionReturnType } from "../types";
2
3
  /**
3
4
  * Calls the 'trace_transaction' RPC method to retrieve execution traces
4
5
  * for a specific transaction hash.
@@ -10,9 +11,9 @@ import type { TraceTransactionParameters, TraceTransactionReturnType, CoreClient
10
11
  * NOTE: This method relies on the non-standard 'trace_transaction' method of the RPC.
11
12
  * It may not be supported by all nodes.
12
13
  *
13
- * @param client The CoreClient instance used to perform the RPC call.
14
+ * @param client The client instance used to perform the RPC call.
14
15
  * @param params The transaction hash for which to retrieve traces.
15
16
  * @returns A promise that returns an array of trace entries (GenericTraceEntry[])
16
17
  * for the specified transaction hash.
17
18
  */
18
- export declare function traceTransaction(client: CoreClient, params: TraceTransactionParameters): Promise<TraceTransactionReturnType>;
19
+ export declare function traceTransaction<TChain extends Chain | undefined>(client: Client<Transport, TChain>, params: TraceTransactionParameters): Promise<TraceTransactionReturnType>;
@@ -1,5 +1,5 @@
1
1
  import { CoreClient, MentaAccountParams } from "../types";
2
- export declare function createMentaAccount(coreClient: CoreClient, params: MentaAccountParams): Promise<import("viem").Client<import("viem").Transport, import("viem").Chain, object & {
2
+ export declare function createMentaAccount(coreClient: CoreClient, params: MentaAccountParams): Promise<import("viem").Client<import("viem").Transport, undefined, object & {
3
3
  client: import("viem").Client<import("viem").Transport, import("viem").Chain | undefined, {
4
4
  address: import("abitype").Address;
5
5
  nonceManager?: import("viem").NonceManager | undefined;
@@ -19511,7 +19511,7 @@ export declare function createMentaAccount(coreClient: CoreClient, params: Menta
19511
19511
  getNonce: NonNullable<import("viem/account-abstraction").SmartAccountImplementation["getNonce"]>;
19512
19512
  isDeployed: () => Promise<boolean>;
19513
19513
  type: "smart";
19514
- }> & import("permissionless").SmartAccountActions<import("viem").Chain, object & {
19514
+ }> & import("permissionless").SmartAccountActions<undefined, object & {
19515
19515
  client: import("viem").Client<import("viem").Transport, import("viem").Chain | undefined, {
19516
19516
  address: import("abitype").Address;
19517
19517
  nonceManager?: import("viem").NonceManager | undefined;
@@ -5955,7 +5955,6 @@ async function createMentaAccount(coreClient, params) {
5955
5955
  });
5956
5956
  return permissionless.createSmartAccountClient({
5957
5957
  account: kernel,
5958
- chain: params.chain,
5959
5958
  bundlerTransport: params.bundlerTransport,
5960
5959
  }).extend(erc7579.erc7579Actions());
5961
5960
  }