@capxul/mcp 1.0.0-alpha.2 → 1.0.0-alpha.20

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,4 +1,4 @@
1
- import { H as ENTRY_POINT_07_ADDRESS, b as CAPXUL_PAYMENTS_ADDRESS, lt as Errors, x as CAPXUL_PAYMENTS_COMMITMENT_ABI } from "./src-CJVATdCb.mjs";
1
+ import { E as ENTRY_POINT_07_ADDRESS, U as CAPXUL_PAYMENTS_ADDRESS, W as CAPXUL_PAYMENTS_COMMITMENT_ABI, dt as Errors } from "./src-DM3bg5NZ.mjs";
2
2
  import { decodeFunctionResult, encodeFunctionData, isHex, toHex } from "viem";
3
3
  //#region ../../packages/backend/convex/_shared/env.ts
4
4
  function requireEnvOrThrow(name) {
@@ -41,6 +41,22 @@ function alchemyUrl(chainId) {
41
41
  default: throw Errors.invalidInput("chainId", `unsupported chainId ${String(chainId)}`);
42
42
  }
43
43
  }
44
+ function isRecord(value) {
45
+ return typeof value === "object" && value !== null && !Array.isArray(value);
46
+ }
47
+ function isValidJsonRpcEnvelope(value) {
48
+ if (!isRecord(value) || value.jsonrpc !== "2.0" || value.id !== 1) return false;
49
+ return Object.hasOwn(value, "result") !== Object.hasOwn(value, "error");
50
+ }
51
+ function isValidJsonRpcError(value) {
52
+ return isRecord(value) && typeof value.code === "number" && Number.isInteger(value.code) && typeof value.message === "string";
53
+ }
54
+ var DefinitiveAlchemyJsonRpcRejection = class extends Error {
55
+ constructor() {
56
+ super("Alchemy returned an explicit JSON-RPC rejection");
57
+ this.name = "DefinitiveAlchemyJsonRpcRejection";
58
+ }
59
+ };
44
60
  async function alchemyRpc(chainId, method, params) {
45
61
  const url = alchemyUrl(chainId);
46
62
  const res = await fetch(url, {
@@ -63,7 +79,11 @@ async function alchemyRpc(chainId, method, params) {
63
79
  } catch (cause) {
64
80
  throw Errors.providerError("alchemy", `${method} json`, cause);
65
81
  }
66
- if (json.error !== void 0) throw Errors.providerError("alchemy", method, json.error.message);
82
+ if (!isValidJsonRpcEnvelope(json)) throw Errors.providerError("alchemy", method, "malformed JSON-RPC envelope");
83
+ if (json.error !== void 0) {
84
+ if (!isValidJsonRpcError(json.error)) throw Errors.providerError("alchemy", method, "malformed JSON-RPC error");
85
+ throw Errors.providerError("alchemy", method, method === "eth_sendUserOperation" ? new DefinitiveAlchemyJsonRpcRejection() : json.error.message);
86
+ }
67
87
  if (json.result === void 0) throw Errors.providerError("alchemy", method, "missing result");
68
88
  return json.result;
69
89
  }
@@ -95,7 +115,7 @@ async function fetchUserOperationReceipt(args) {
95
115
  receipt: {
96
116
  blockNumber: hexToSafeInteger(raw.receipt.blockNumber, "eth_getUserOperationReceipt"),
97
117
  transactionHash: raw.receipt.transactionHash,
98
- logs: parseReceiptLogs(raw.receipt.logs)
118
+ logs: parseReceiptLogs(raw.logs)
99
119
  }
100
120
  };
101
121
  }
@@ -0,0 +1,2 @@
1
+ import { r as fetchCommitmentCreatedLog } from "./alchemy-rpc-BORldDgR.mjs";
2
+ export { fetchCommitmentCreatedLog };