@capxul/mcp 1.0.0-alpha.4 → 1.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/README.md +31 -62
- package/dist/{_esm-DUwdnl5L.mjs → _esm-CC5QpzeQ.mjs} +2 -236
- package/dist/alchemy-rpc-BuobS4-x.mjs +2 -0
- package/dist/{alchemy-rpc-mjuofdCf.mjs → alchemy-rpc-vGO5qErZ.mjs} +23 -3
- package/dist/{chunk-Dg0SBOkb.mjs → chunk-B5meny8j.mjs} +3 -1
- package/dist/esm-D2-zCfAo.mjs +4088 -0
- package/dist/eventemitter3-D-pLUuAN.mjs +238 -0
- package/dist/lib-B8hqwgiz.mjs +654 -0
- package/dist/lib-BGlYlc2Y.mjs +3 -0
- package/dist/lib-BRkcywUv.mjs +539 -0
- package/dist/lib-BSq2-y-R.mjs +3 -0
- package/dist/lib-CifIgXqP.mjs +12219 -0
- package/dist/lib-CnLS6gjn.mjs +6980 -0
- package/dist/lib-Dn7-RQTV.mjs +3635 -0
- package/dist/lib-YbuuWTqT.mjs +3 -0
- package/dist/lib-cc_08w0f.mjs +2148 -0
- package/dist/lib-hCYuvdcy.mjs +1764 -0
- package/dist/lib-yehPdjuB.mjs +3 -0
- package/dist/main.mjs +31352 -4076
- package/dist/{src-BDIKpZXn.mjs → src-2B8HO-zu.mjs} +944 -789
- package/dist/src-HgvNZjX7.mjs +2 -0
- package/dist/{src-Cg8p_ZgR.mjs → src-Iv70gRG_.mjs} +1 -1
- package/package.json +14 -20
- package/dist/alchemy-rpc-DxVP2GsG.mjs +0 -2
- package/dist/src-BmSYoMhj.mjs +0 -2
package/README.md
CHANGED
|
@@ -1,78 +1,47 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Capxul MCP (`@capxul/mcp`)
|
|
2
2
|
|
|
3
|
-
The
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
The published Capxul Model Context Protocol server. It exposes agent-facing
|
|
4
|
+
auth, account, financial operations, payments, Organizations, payment requests,
|
|
5
|
+
SDK restart, and faucet tool families through one registry.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
`capxul-mcp` executable.
|
|
7
|
+
The artifact is a CLI, not an importable library.
|
|
9
8
|
|
|
10
|
-
##
|
|
9
|
+
## Run
|
|
11
10
|
|
|
12
11
|
```bash
|
|
13
|
-
# one-off, via npx
|
|
14
12
|
npx @capxul/mcp serve --mode live
|
|
15
13
|
|
|
16
|
-
#
|
|
17
|
-
|
|
18
|
-
capxul-mcp serve --mode live
|
|
14
|
+
# Trusted local MCP-client spawn:
|
|
15
|
+
capxul-mcp serve --mode live --stdio
|
|
19
16
|
```
|
|
20
17
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
capxul-mcp serve [--mode live|dev] [--port <port>] [--approval-url <url>]
|
|
18
|
+
HTTP mode uses Streamable HTTP at `POST /mcp` and defaults to port `8788`.
|
|
19
|
+
Stdio mode reserves stdout for JSON-RPC and sends diagnostics to stderr.
|
|
24
20
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
--approval-url <url> Approval app base URL. Defaults to CAPXUL_MCP_APPROVAL_URL or http://localhost:5998.
|
|
29
|
-
--help Show this help.
|
|
21
|
+
```text
|
|
22
|
+
capxul-mcp serve [--mode live|dev] [--port <port>]
|
|
23
|
+
[--approval-url <url>] [--stdio]
|
|
30
24
|
```
|
|
31
25
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
Agent-facing financial-ops tools, composed in `src/registry.ts`:
|
|
38
|
-
|
|
39
|
-
- **`system.ping`** — liveness probe (no auth, no secrets).
|
|
40
|
-
- **`auth.*`** — request/verify an email OTP, exchanging it for an opaque
|
|
41
|
-
session token bound to the MCP session.
|
|
42
|
-
- **`account.*`** — account readiness and on-chain Money balances.
|
|
43
|
-
- **`faucet.fundTestnet`** — testnet faucet (env-gated).
|
|
44
|
-
- **`payments.send`** — send a sponsored stablecoin payment.
|
|
45
|
-
|
|
46
|
-
## Auth & transport
|
|
26
|
+
`--mode live` uses the production signer path. `--mode dev` requires a
|
|
27
|
+
deterministic development signer seed and is not production custody evidence.
|
|
28
|
+
Runtime environment is read lazily so `system.ping` can run without platform
|
|
29
|
+
secrets; missing authenticated configuration returns a structured error.
|
|
47
30
|
|
|
48
|
-
|
|
49
|
-
- **OAuth bearer auth** — an in-memory PKCE OAuth provider gates tool access
|
|
50
|
-
when `CAPXUL_MCP_OAUTH_REQUIRED=1`; a proof-issuer secret can mint bearer
|
|
51
|
-
tokens for automated probes.
|
|
52
|
-
- **Dev-mode custody gate** — `--mode dev` runs against a deterministic dev
|
|
53
|
-
signer seed (`CAPXUL_MCP_DEV_SIGNER_SEED`) so journeys can be exercised
|
|
54
|
-
without live custody; `--mode live` uses the production signer path.
|
|
31
|
+
## Verify in the repository
|
|
55
32
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
| Variable | Purpose |
|
|
63
|
-
| --- | --- |
|
|
64
|
-
| `CAPXUL_MCP_PORT` | Bind port (default `8788`; `0` = ephemeral). |
|
|
65
|
-
| `CAPXUL_MCP_DEV_SIGNER_SEED` | Deterministic dev signer seed (`--mode dev`). |
|
|
66
|
-
| `CAPXUL_MCP_OAUTH_REQUIRED` | `1` to require an OAuth bearer token. |
|
|
67
|
-
| `CAPXUL_MCP_OAUTH_PROOF_ISSUER_SECRET` | Secret to mint proof bearer tokens. |
|
|
68
|
-
| `CAPXUL_MCP_APPROVAL_URL` | Base URL of the Approval app for deploy approvals. |
|
|
33
|
+
```bash
|
|
34
|
+
vp run --filter @capxul/mcp check-types
|
|
35
|
+
vp test run apps/mcp
|
|
36
|
+
vp run --filter @capxul/mcp build
|
|
37
|
+
vp run --filter @capxul/mcp proofs:live -- --phase <phase>
|
|
38
|
+
```
|
|
69
39
|
|
|
70
|
-
|
|
40
|
+
Unit tests and dev-mode fixtures prove handler/transport contracts, not live
|
|
41
|
+
Convex, chain, OAuth issuance, or settlement. Only the explicitly selected
|
|
42
|
+
`proofs:live` phase supplies live evidence for that phase. The published CLI
|
|
43
|
+
still lacks an isolated packed-install/bin smoke; [#922](https://github.com/Xelmar-tech/infrastructure/issues/922)
|
|
44
|
+
owns that gap.
|
|
71
45
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
`@capxul/*` workspace package the server reaches (`@capxul/sdk`,
|
|
75
|
-
`@capxul/backend`, `@capxul/config`, `@capxul/types`) is bundled into
|
|
76
|
-
`dist/main.mjs` at pack time, while real npm dependencies (`effect`, `convex`,
|
|
77
|
-
`viem`, `zod`, `@modelcontextprotocol/sdk`, …) stay external and are resolved
|
|
78
|
-
from the consumer's lockfile.
|
|
46
|
+
Read [CONTEXT.md](./CONTEXT.md) before adding a tool or changing auth, approval,
|
|
47
|
+
wire, or proof behavior.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as __exportAll } from "./chunk-B5meny8j.mjs";
|
|
2
|
+
import { t as import_eventemitter3 } from "./eventemitter3-D-pLUuAN.mjs";
|
|
2
3
|
import * as nc from "node:crypto";
|
|
3
4
|
//#region ../../node_modules/.pnpm/abitype@1.2.3_typescript@5.9.2_zod@3.25.76/node_modules/abitype/dist/esm/version.js
|
|
4
5
|
const version$1 = "1.2.3";
|
|
@@ -41737,241 +41738,6 @@ function getSignPayload$9(data) {
|
|
|
41737
41738
|
return keccak256(encode$2(data));
|
|
41738
41739
|
}
|
|
41739
41740
|
//#endregion
|
|
41740
|
-
//#region ../../node_modules/.pnpm/eventemitter3@5.0.1/node_modules/eventemitter3/index.mjs
|
|
41741
|
-
var import_eventemitter3 = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
41742
|
-
var has = Object.prototype.hasOwnProperty, prefix = "~";
|
|
41743
|
-
/**
|
|
41744
|
-
* Constructor to create a storage for our `EE` objects.
|
|
41745
|
-
* An `Events` instance is a plain object whose properties are event names.
|
|
41746
|
-
*
|
|
41747
|
-
* @constructor
|
|
41748
|
-
* @private
|
|
41749
|
-
*/
|
|
41750
|
-
function Events() {}
|
|
41751
|
-
if (Object.create) {
|
|
41752
|
-
Events.prototype = Object.create(null);
|
|
41753
|
-
if (!new Events().__proto__) prefix = false;
|
|
41754
|
-
}
|
|
41755
|
-
/**
|
|
41756
|
-
* Representation of a single event listener.
|
|
41757
|
-
*
|
|
41758
|
-
* @param {Function} fn The listener function.
|
|
41759
|
-
* @param {*} context The context to invoke the listener with.
|
|
41760
|
-
* @param {Boolean} [once=false] Specify if the listener is a one-time listener.
|
|
41761
|
-
* @constructor
|
|
41762
|
-
* @private
|
|
41763
|
-
*/
|
|
41764
|
-
function EE(fn, context, once) {
|
|
41765
|
-
this.fn = fn;
|
|
41766
|
-
this.context = context;
|
|
41767
|
-
this.once = once || false;
|
|
41768
|
-
}
|
|
41769
|
-
/**
|
|
41770
|
-
* Add a listener for a given event.
|
|
41771
|
-
*
|
|
41772
|
-
* @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
|
|
41773
|
-
* @param {(String|Symbol)} event The event name.
|
|
41774
|
-
* @param {Function} fn The listener function.
|
|
41775
|
-
* @param {*} context The context to invoke the listener with.
|
|
41776
|
-
* @param {Boolean} once Specify if the listener is a one-time listener.
|
|
41777
|
-
* @returns {EventEmitter}
|
|
41778
|
-
* @private
|
|
41779
|
-
*/
|
|
41780
|
-
function addListener(emitter, event, fn, context, once) {
|
|
41781
|
-
if (typeof fn !== "function") throw new TypeError("The listener must be a function");
|
|
41782
|
-
var listener = new EE(fn, context || emitter, once), evt = prefix ? prefix + event : event;
|
|
41783
|
-
if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;
|
|
41784
|
-
else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);
|
|
41785
|
-
else emitter._events[evt] = [emitter._events[evt], listener];
|
|
41786
|
-
return emitter;
|
|
41787
|
-
}
|
|
41788
|
-
/**
|
|
41789
|
-
* Clear event by name.
|
|
41790
|
-
*
|
|
41791
|
-
* @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
|
|
41792
|
-
* @param {(String|Symbol)} evt The Event name.
|
|
41793
|
-
* @private
|
|
41794
|
-
*/
|
|
41795
|
-
function clearEvent(emitter, evt) {
|
|
41796
|
-
if (--emitter._eventsCount === 0) emitter._events = new Events();
|
|
41797
|
-
else delete emitter._events[evt];
|
|
41798
|
-
}
|
|
41799
|
-
/**
|
|
41800
|
-
* Minimal `EventEmitter` interface that is molded against the Node.js
|
|
41801
|
-
* `EventEmitter` interface.
|
|
41802
|
-
*
|
|
41803
|
-
* @constructor
|
|
41804
|
-
* @public
|
|
41805
|
-
*/
|
|
41806
|
-
function EventEmitter() {
|
|
41807
|
-
this._events = new Events();
|
|
41808
|
-
this._eventsCount = 0;
|
|
41809
|
-
}
|
|
41810
|
-
/**
|
|
41811
|
-
* Return an array listing the events for which the emitter has registered
|
|
41812
|
-
* listeners.
|
|
41813
|
-
*
|
|
41814
|
-
* @returns {Array}
|
|
41815
|
-
* @public
|
|
41816
|
-
*/
|
|
41817
|
-
EventEmitter.prototype.eventNames = function eventNames() {
|
|
41818
|
-
var names = [], events, name;
|
|
41819
|
-
if (this._eventsCount === 0) return names;
|
|
41820
|
-
for (name in events = this._events) if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
|
|
41821
|
-
if (Object.getOwnPropertySymbols) return names.concat(Object.getOwnPropertySymbols(events));
|
|
41822
|
-
return names;
|
|
41823
|
-
};
|
|
41824
|
-
/**
|
|
41825
|
-
* Return the listeners registered for a given event.
|
|
41826
|
-
*
|
|
41827
|
-
* @param {(String|Symbol)} event The event name.
|
|
41828
|
-
* @returns {Array} The registered listeners.
|
|
41829
|
-
* @public
|
|
41830
|
-
*/
|
|
41831
|
-
EventEmitter.prototype.listeners = function listeners(event) {
|
|
41832
|
-
var evt = prefix ? prefix + event : event, handlers = this._events[evt];
|
|
41833
|
-
if (!handlers) return [];
|
|
41834
|
-
if (handlers.fn) return [handlers.fn];
|
|
41835
|
-
for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) ee[i] = handlers[i].fn;
|
|
41836
|
-
return ee;
|
|
41837
|
-
};
|
|
41838
|
-
/**
|
|
41839
|
-
* Return the number of listeners listening to a given event.
|
|
41840
|
-
*
|
|
41841
|
-
* @param {(String|Symbol)} event The event name.
|
|
41842
|
-
* @returns {Number} The number of listeners.
|
|
41843
|
-
* @public
|
|
41844
|
-
*/
|
|
41845
|
-
EventEmitter.prototype.listenerCount = function listenerCount(event) {
|
|
41846
|
-
var evt = prefix ? prefix + event : event, listeners = this._events[evt];
|
|
41847
|
-
if (!listeners) return 0;
|
|
41848
|
-
if (listeners.fn) return 1;
|
|
41849
|
-
return listeners.length;
|
|
41850
|
-
};
|
|
41851
|
-
/**
|
|
41852
|
-
* Calls each of the listeners registered for a given event.
|
|
41853
|
-
*
|
|
41854
|
-
* @param {(String|Symbol)} event The event name.
|
|
41855
|
-
* @returns {Boolean} `true` if the event had listeners, else `false`.
|
|
41856
|
-
* @public
|
|
41857
|
-
*/
|
|
41858
|
-
EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
|
|
41859
|
-
var evt = prefix ? prefix + event : event;
|
|
41860
|
-
if (!this._events[evt]) return false;
|
|
41861
|
-
var listeners = this._events[evt], len = arguments.length, args, i;
|
|
41862
|
-
if (listeners.fn) {
|
|
41863
|
-
if (listeners.once) this.removeListener(event, listeners.fn, void 0, true);
|
|
41864
|
-
switch (len) {
|
|
41865
|
-
case 1: return listeners.fn.call(listeners.context), true;
|
|
41866
|
-
case 2: return listeners.fn.call(listeners.context, a1), true;
|
|
41867
|
-
case 3: return listeners.fn.call(listeners.context, a1, a2), true;
|
|
41868
|
-
case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;
|
|
41869
|
-
case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
|
|
41870
|
-
case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
|
|
41871
|
-
}
|
|
41872
|
-
for (i = 1, args = new Array(len - 1); i < len; i++) args[i - 1] = arguments[i];
|
|
41873
|
-
listeners.fn.apply(listeners.context, args);
|
|
41874
|
-
} else {
|
|
41875
|
-
var length = listeners.length, j;
|
|
41876
|
-
for (i = 0; i < length; i++) {
|
|
41877
|
-
if (listeners[i].once) this.removeListener(event, listeners[i].fn, void 0, true);
|
|
41878
|
-
switch (len) {
|
|
41879
|
-
case 1:
|
|
41880
|
-
listeners[i].fn.call(listeners[i].context);
|
|
41881
|
-
break;
|
|
41882
|
-
case 2:
|
|
41883
|
-
listeners[i].fn.call(listeners[i].context, a1);
|
|
41884
|
-
break;
|
|
41885
|
-
case 3:
|
|
41886
|
-
listeners[i].fn.call(listeners[i].context, a1, a2);
|
|
41887
|
-
break;
|
|
41888
|
-
case 4:
|
|
41889
|
-
listeners[i].fn.call(listeners[i].context, a1, a2, a3);
|
|
41890
|
-
break;
|
|
41891
|
-
default:
|
|
41892
|
-
if (!args) for (j = 1, args = new Array(len - 1); j < len; j++) args[j - 1] = arguments[j];
|
|
41893
|
-
listeners[i].fn.apply(listeners[i].context, args);
|
|
41894
|
-
}
|
|
41895
|
-
}
|
|
41896
|
-
}
|
|
41897
|
-
return true;
|
|
41898
|
-
};
|
|
41899
|
-
/**
|
|
41900
|
-
* Add a listener for a given event.
|
|
41901
|
-
*
|
|
41902
|
-
* @param {(String|Symbol)} event The event name.
|
|
41903
|
-
* @param {Function} fn The listener function.
|
|
41904
|
-
* @param {*} [context=this] The context to invoke the listener with.
|
|
41905
|
-
* @returns {EventEmitter} `this`.
|
|
41906
|
-
* @public
|
|
41907
|
-
*/
|
|
41908
|
-
EventEmitter.prototype.on = function on(event, fn, context) {
|
|
41909
|
-
return addListener(this, event, fn, context, false);
|
|
41910
|
-
};
|
|
41911
|
-
/**
|
|
41912
|
-
* Add a one-time listener for a given event.
|
|
41913
|
-
*
|
|
41914
|
-
* @param {(String|Symbol)} event The event name.
|
|
41915
|
-
* @param {Function} fn The listener function.
|
|
41916
|
-
* @param {*} [context=this] The context to invoke the listener with.
|
|
41917
|
-
* @returns {EventEmitter} `this`.
|
|
41918
|
-
* @public
|
|
41919
|
-
*/
|
|
41920
|
-
EventEmitter.prototype.once = function once(event, fn, context) {
|
|
41921
|
-
return addListener(this, event, fn, context, true);
|
|
41922
|
-
};
|
|
41923
|
-
/**
|
|
41924
|
-
* Remove the listeners of a given event.
|
|
41925
|
-
*
|
|
41926
|
-
* @param {(String|Symbol)} event The event name.
|
|
41927
|
-
* @param {Function} fn Only remove the listeners that match this function.
|
|
41928
|
-
* @param {*} context Only remove the listeners that have this context.
|
|
41929
|
-
* @param {Boolean} once Only remove one-time listeners.
|
|
41930
|
-
* @returns {EventEmitter} `this`.
|
|
41931
|
-
* @public
|
|
41932
|
-
*/
|
|
41933
|
-
EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {
|
|
41934
|
-
var evt = prefix ? prefix + event : event;
|
|
41935
|
-
if (!this._events[evt]) return this;
|
|
41936
|
-
if (!fn) {
|
|
41937
|
-
clearEvent(this, evt);
|
|
41938
|
-
return this;
|
|
41939
|
-
}
|
|
41940
|
-
var listeners = this._events[evt];
|
|
41941
|
-
if (listeners.fn) {
|
|
41942
|
-
if (listeners.fn === fn && (!once || listeners.once) && (!context || listeners.context === context)) clearEvent(this, evt);
|
|
41943
|
-
} else {
|
|
41944
|
-
for (var i = 0, events = [], length = listeners.length; i < length; i++) if (listeners[i].fn !== fn || once && !listeners[i].once || context && listeners[i].context !== context) events.push(listeners[i]);
|
|
41945
|
-
if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;
|
|
41946
|
-
else clearEvent(this, evt);
|
|
41947
|
-
}
|
|
41948
|
-
return this;
|
|
41949
|
-
};
|
|
41950
|
-
/**
|
|
41951
|
-
* Remove all listeners, or those of the specified event.
|
|
41952
|
-
*
|
|
41953
|
-
* @param {(String|Symbol)} [event] The event name.
|
|
41954
|
-
* @returns {EventEmitter} `this`.
|
|
41955
|
-
* @public
|
|
41956
|
-
*/
|
|
41957
|
-
EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
|
|
41958
|
-
var evt;
|
|
41959
|
-
if (event) {
|
|
41960
|
-
evt = prefix ? prefix + event : event;
|
|
41961
|
-
if (this._events[evt]) clearEvent(this, evt);
|
|
41962
|
-
} else {
|
|
41963
|
-
this._events = new Events();
|
|
41964
|
-
this._eventsCount = 0;
|
|
41965
|
-
}
|
|
41966
|
-
return this;
|
|
41967
|
-
};
|
|
41968
|
-
EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
|
|
41969
|
-
EventEmitter.prototype.addListener = EventEmitter.prototype.on;
|
|
41970
|
-
EventEmitter.prefixed = prefix;
|
|
41971
|
-
EventEmitter.EventEmitter = EventEmitter;
|
|
41972
|
-
if ("undefined" !== typeof module) module.exports = EventEmitter;
|
|
41973
|
-
})))(), 1);
|
|
41974
|
-
//#endregion
|
|
41975
41741
|
//#region ../../node_modules/.pnpm/ox@0.14.29_typescript@5.9.2_zod@3.25.76/node_modules/ox/_esm/core/RpcResponse.js
|
|
41976
41742
|
var RpcResponse_exports = /* @__PURE__ */ __exportAll({
|
|
41977
41743
|
BaseError: () => BaseError,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { E as ENTRY_POINT_07_ADDRESS, U as CAPXUL_PAYMENTS_ADDRESS, W as CAPXUL_PAYMENTS_COMMITMENT_ABI, ft as Errors } from "./src-2B8HO-zu.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
|
|
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.
|
|
118
|
+
logs: parseReceiptLogs(raw.logs)
|
|
99
119
|
}
|
|
100
120
|
};
|
|
101
121
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
1
2
|
//#region \0rolldown/runtime.js
|
|
2
3
|
var __create = Object.create;
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
@@ -30,5 +31,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
30
31
|
value: mod,
|
|
31
32
|
enumerable: true
|
|
32
33
|
}) : target, mod));
|
|
34
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
33
35
|
//#endregion
|
|
34
|
-
export { __toESM as i, __exportAll as n, __reExport as r, __commonJSMin as t };
|
|
36
|
+
export { __toESM as a, __require as i, __exportAll as n, __reExport as r, __commonJSMin as t };
|