@pepu-chain/sdk 0.0.0-stage → 0.2.1

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.
Files changed (244) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +590 -2
  3. package/dist/aa/kernel.cjs +41 -0
  4. package/dist/aa/kernel.cjs.map +1 -0
  5. package/dist/aa/kernel.d.cts +88 -0
  6. package/dist/aa/kernel.d.ts +88 -0
  7. package/dist/aa/kernel.guard.js +15 -0
  8. package/dist/aa/kernel.js +11 -0
  9. package/dist/aa/kernel.js.map +1 -0
  10. package/dist/aa/react-direct.cjs +111 -0
  11. package/dist/aa/react-direct.cjs.map +1 -0
  12. package/dist/aa/react-direct.d.cts +42 -0
  13. package/dist/aa/react-direct.d.ts +42 -0
  14. package/dist/aa/react-direct.guard.js +15 -0
  15. package/dist/aa/react-direct.js +107 -0
  16. package/dist/aa/react-direct.js.map +1 -0
  17. package/dist/aa/react.cjs +152 -0
  18. package/dist/aa/react.cjs.map +1 -0
  19. package/dist/aa/react.d.cts +62 -0
  20. package/dist/aa/react.d.ts +62 -0
  21. package/dist/aa/react.guard.js +15 -0
  22. package/dist/aa/react.js +147 -0
  23. package/dist/aa/react.js.map +1 -0
  24. package/dist/aa.cjs +84 -0
  25. package/dist/aa.cjs.map +1 -0
  26. package/dist/aa.d.cts +85 -0
  27. package/dist/aa.d.ts +85 -0
  28. package/dist/aa.js +11 -0
  29. package/dist/aa.js.map +1 -0
  30. package/dist/api-Dz4sCHH_.d.cts +654 -0
  31. package/dist/api-Dz4sCHH_.d.ts +654 -0
  32. package/dist/calls-BRPjKgjl.d.cts +70 -0
  33. package/dist/calls-z_EQOtFb.d.ts +70 -0
  34. package/dist/chains-DK13zGIp.d.cts +235 -0
  35. package/dist/chains-DK13zGIp.d.ts +235 -0
  36. package/dist/chunk-3XUGQODR.js +194 -0
  37. package/dist/chunk-3XUGQODR.js.map +1 -0
  38. package/dist/chunk-45KSZH26.cjs +145 -0
  39. package/dist/chunk-45KSZH26.cjs.map +1 -0
  40. package/dist/chunk-4GINFJO6.cjs +44 -0
  41. package/dist/chunk-4GINFJO6.cjs.map +1 -0
  42. package/dist/chunk-62M2LKQW.js +136 -0
  43. package/dist/chunk-62M2LKQW.js.map +1 -0
  44. package/dist/chunk-6DSZ4Z2N.js +498 -0
  45. package/dist/chunk-6DSZ4Z2N.js.map +1 -0
  46. package/dist/chunk-7MNJF2OB.cjs +72 -0
  47. package/dist/chunk-7MNJF2OB.cjs.map +1 -0
  48. package/dist/chunk-7PVR7QSE.js +45 -0
  49. package/dist/chunk-7PVR7QSE.js.map +1 -0
  50. package/dist/chunk-A5LP2UCS.cjs +2729 -0
  51. package/dist/chunk-A5LP2UCS.cjs.map +1 -0
  52. package/dist/chunk-AJS4UFQX.cjs +121 -0
  53. package/dist/chunk-AJS4UFQX.cjs.map +1 -0
  54. package/dist/chunk-BGALSKAF.cjs +315 -0
  55. package/dist/chunk-BGALSKAF.cjs.map +1 -0
  56. package/dist/chunk-C2XW44FI.cjs +200 -0
  57. package/dist/chunk-C2XW44FI.cjs.map +1 -0
  58. package/dist/chunk-C7IC36XS.cjs +13 -0
  59. package/dist/chunk-C7IC36XS.cjs.map +1 -0
  60. package/dist/chunk-D52PADVY.js +84 -0
  61. package/dist/chunk-D52PADVY.js.map +1 -0
  62. package/dist/chunk-DH6BFNVJ.cjs +272 -0
  63. package/dist/chunk-DH6BFNVJ.cjs.map +1 -0
  64. package/dist/chunk-DPCZJLB3.cjs +87 -0
  65. package/dist/chunk-DPCZJLB3.cjs.map +1 -0
  66. package/dist/chunk-EHBPIYY4.js +262 -0
  67. package/dist/chunk-EHBPIYY4.js.map +1 -0
  68. package/dist/chunk-ESMNAXUI.js +86 -0
  69. package/dist/chunk-ESMNAXUI.js.map +1 -0
  70. package/dist/chunk-F2R473FR.js +304 -0
  71. package/dist/chunk-F2R473FR.js.map +1 -0
  72. package/dist/chunk-IB2FSPMJ.js +66 -0
  73. package/dist/chunk-IB2FSPMJ.js.map +1 -0
  74. package/dist/chunk-IG7RSL2Y.cjs +178 -0
  75. package/dist/chunk-IG7RSL2Y.cjs.map +1 -0
  76. package/dist/chunk-IY3ALPUJ.js +2716 -0
  77. package/dist/chunk-IY3ALPUJ.js.map +1 -0
  78. package/dist/chunk-J3O2ZGG3.cjs +93 -0
  79. package/dist/chunk-J3O2ZGG3.cjs.map +1 -0
  80. package/dist/chunk-J6UXXHBE.js +37 -0
  81. package/dist/chunk-J6UXXHBE.js.map +1 -0
  82. package/dist/chunk-JLZ4LZ4Z.js +22 -0
  83. package/dist/chunk-JLZ4LZ4Z.js.map +1 -0
  84. package/dist/chunk-K7JSQPZO.cjs +231 -0
  85. package/dist/chunk-K7JSQPZO.cjs.map +1 -0
  86. package/dist/chunk-KJYNF5KH.js +224 -0
  87. package/dist/chunk-KJYNF5KH.js.map +1 -0
  88. package/dist/chunk-KVG3AYYR.js +99 -0
  89. package/dist/chunk-KVG3AYYR.js.map +1 -0
  90. package/dist/chunk-NE3QKDOB.cjs +24 -0
  91. package/dist/chunk-NE3QKDOB.cjs.map +1 -0
  92. package/dist/chunk-NVOPDXTA.cjs +95 -0
  93. package/dist/chunk-NVOPDXTA.cjs.map +1 -0
  94. package/dist/chunk-OH3QMAIB.js +11 -0
  95. package/dist/chunk-OH3QMAIB.js.map +1 -0
  96. package/dist/chunk-PHM3ZORG.cjs +110 -0
  97. package/dist/chunk-PHM3ZORG.cjs.map +1 -0
  98. package/dist/chunk-R5PXQNO3.cjs +209 -0
  99. package/dist/chunk-R5PXQNO3.cjs.map +1 -0
  100. package/dist/chunk-RCMKPJZO.cjs +49 -0
  101. package/dist/chunk-RCMKPJZO.cjs.map +1 -0
  102. package/dist/chunk-SVWRRALU.cjs +17 -0
  103. package/dist/chunk-SVWRRALU.cjs.map +1 -0
  104. package/dist/chunk-T43PQXJD.js +202 -0
  105. package/dist/chunk-T43PQXJD.js.map +1 -0
  106. package/dist/chunk-VBH3JLQ5.js +116 -0
  107. package/dist/chunk-VBH3JLQ5.js.map +1 -0
  108. package/dist/chunk-VF3D6KLQ.cjs +94 -0
  109. package/dist/chunk-VF3D6KLQ.cjs.map +1 -0
  110. package/dist/chunk-VTQIHMF3.js +82 -0
  111. package/dist/chunk-VTQIHMF3.js.map +1 -0
  112. package/dist/chunk-W3JN3YIW.js +15 -0
  113. package/dist/chunk-W3JN3YIW.js.map +1 -0
  114. package/dist/chunk-WANILJZQ.cjs +87 -0
  115. package/dist/chunk-WANILJZQ.cjs.map +1 -0
  116. package/dist/chunk-XC4IBCI2.js +86 -0
  117. package/dist/chunk-XC4IBCI2.js.map +1 -0
  118. package/dist/chunk-YKEWWQEJ.js +165 -0
  119. package/dist/chunk-YKEWWQEJ.js.map +1 -0
  120. package/dist/chunk-YQL7NISX.cjs +515 -0
  121. package/dist/chunk-YQL7NISX.cjs.map +1 -0
  122. package/dist/chunk-ZB6SVBK4.js +89 -0
  123. package/dist/chunk-ZB6SVBK4.js.map +1 -0
  124. package/dist/combo/react.cjs +236 -0
  125. package/dist/combo/react.cjs.map +1 -0
  126. package/dist/combo/react.d.cts +148 -0
  127. package/dist/combo/react.d.ts +148 -0
  128. package/dist/combo/react.guard.js +15 -0
  129. package/dist/combo/react.js +230 -0
  130. package/dist/combo/react.js.map +1 -0
  131. package/dist/combo.cjs +263 -0
  132. package/dist/combo.cjs.map +1 -0
  133. package/dist/combo.d.cts +139 -0
  134. package/dist/combo.d.ts +139 -0
  135. package/dist/combo.guard.js +15 -0
  136. package/dist/combo.js +249 -0
  137. package/dist/combo.js.map +1 -0
  138. package/dist/config-CHjz7ZjZ.d.cts +57 -0
  139. package/dist/config-COjhIZTh.d.ts +57 -0
  140. package/dist/doctor.cjs +354 -0
  141. package/dist/doctor.cjs.map +1 -0
  142. package/dist/doctor.d.cts +177 -0
  143. package/dist/doctor.d.ts +177 -0
  144. package/dist/doctor.js +345 -0
  145. package/dist/doctor.js.map +1 -0
  146. package/dist/erc7677-DOW58QBE.d.cts +111 -0
  147. package/dist/erc7677-DOW58QBE.d.ts +111 -0
  148. package/dist/errors-CgX1vNj7.d.cts +100 -0
  149. package/dist/errors-CgX1vNj7.d.ts +100 -0
  150. package/dist/index.cjs +806 -0
  151. package/dist/index.cjs.map +1 -0
  152. package/dist/index.d.cts +2398 -0
  153. package/dist/index.d.ts +2398 -0
  154. package/dist/index.js +559 -0
  155. package/dist/index.js.map +1 -0
  156. package/dist/paymaster/server.cjs +38 -0
  157. package/dist/paymaster/server.cjs.map +1 -0
  158. package/dist/paymaster/server.d.cts +57 -0
  159. package/dist/paymaster/server.d.ts +57 -0
  160. package/dist/paymaster/server.js +36 -0
  161. package/dist/paymaster/server.js.map +1 -0
  162. package/dist/paymaster.cjs +356 -0
  163. package/dist/paymaster.cjs.map +1 -0
  164. package/dist/paymaster.d.cts +1851 -0
  165. package/dist/paymaster.d.ts +1851 -0
  166. package/dist/paymaster.js +289 -0
  167. package/dist/paymaster.js.map +1 -0
  168. package/dist/privy/react.cjs +49 -0
  169. package/dist/privy/react.cjs.map +1 -0
  170. package/dist/privy/react.d.cts +194 -0
  171. package/dist/privy/react.d.ts +194 -0
  172. package/dist/privy/react.guard.js +15 -0
  173. package/dist/privy/react.js +7 -0
  174. package/dist/privy/react.js.map +1 -0
  175. package/dist/privy/server.cjs +44 -0
  176. package/dist/privy/server.cjs.map +1 -0
  177. package/dist/privy/server.d.cts +192 -0
  178. package/dist/privy/server.d.ts +192 -0
  179. package/dist/privy/server.guard.js +15 -0
  180. package/dist/privy/server.js +6 -0
  181. package/dist/privy/server.js.map +1 -0
  182. package/dist/privy/wagmi.d.ts +90 -0
  183. package/dist/privy/wagmi.guard.js +15 -0
  184. package/dist/privy/wagmi.js +55 -0
  185. package/dist/privy/wagmi.js.map +1 -0
  186. package/dist/privy.cjs +34 -0
  187. package/dist/privy.cjs.map +1 -0
  188. package/dist/privy.d.cts +4 -0
  189. package/dist/privy.d.ts +4 -0
  190. package/dist/privy.js +5 -0
  191. package/dist/privy.js.map +1 -0
  192. package/dist/react.cjs +73 -0
  193. package/dist/react.cjs.map +1 -0
  194. package/dist/react.d.cts +66 -0
  195. package/dist/react.d.ts +66 -0
  196. package/dist/react.guard.js +15 -0
  197. package/dist/react.js +68 -0
  198. package/dist/react.js.map +1 -0
  199. package/dist/requirements-C-QiJkL9.d.cts +134 -0
  200. package/dist/requirements-C-QiJkL9.d.ts +134 -0
  201. package/dist/scope-DBRkN7bR.d.cts +94 -0
  202. package/dist/scope-DBRkN7bR.d.ts +94 -0
  203. package/dist/server.cjs +59 -0
  204. package/dist/server.cjs.map +1 -0
  205. package/dist/server.d.cts +208 -0
  206. package/dist/server.d.ts +208 -0
  207. package/dist/server.js +8 -0
  208. package/dist/server.js.map +1 -0
  209. package/dist/session/kernel.cjs +83 -0
  210. package/dist/session/kernel.cjs.map +1 -0
  211. package/dist/session/kernel.d.cts +131 -0
  212. package/dist/session/kernel.d.ts +131 -0
  213. package/dist/session/kernel.guard.js +15 -0
  214. package/dist/session/kernel.js +13 -0
  215. package/dist/session/kernel.js.map +1 -0
  216. package/dist/session/react.cjs +38 -0
  217. package/dist/session/react.cjs.map +1 -0
  218. package/dist/session/react.d.cts +119 -0
  219. package/dist/session/react.d.ts +119 -0
  220. package/dist/session/react.guard.js +15 -0
  221. package/dist/session/react.js +8 -0
  222. package/dist/session/react.js.map +1 -0
  223. package/dist/session/server.cjs +268 -0
  224. package/dist/session/server.cjs.map +1 -0
  225. package/dist/session/server.d.cts +151 -0
  226. package/dist/session/server.d.ts +151 -0
  227. package/dist/session/server.guard.js +15 -0
  228. package/dist/session/server.js +252 -0
  229. package/dist/session/server.js.map +1 -0
  230. package/dist/session.cjs +74 -0
  231. package/dist/session.cjs.map +1 -0
  232. package/dist/session.d.cts +3 -0
  233. package/dist/session.d.ts +3 -0
  234. package/dist/session.js +5 -0
  235. package/dist/session.js.map +1 -0
  236. package/dist/status-Dx9zAFo9.d.ts +327 -0
  237. package/dist/status-wgTM26V7.d.cts +327 -0
  238. package/dist/store-CjmLgp9g.d.cts +64 -0
  239. package/dist/store-CjmLgp9g.d.ts +64 -0
  240. package/dist/types-BEEM7WdG.d.cts +25 -0
  241. package/dist/types-BEEM7WdG.d.ts +25 -0
  242. package/dist/types-BilBTDqK.d.cts +27 -0
  243. package/dist/types-BilBTDqK.d.ts +27 -0
  244. package/package.json +245 -3
@@ -0,0 +1,315 @@
1
+ 'use strict';
2
+
3
+ var chunkWANILJZQ_cjs = require('./chunk-WANILJZQ.cjs');
4
+ var chunkK7JSQPZO_cjs = require('./chunk-K7JSQPZO.cjs');
5
+ var chunkVF3D6KLQ_cjs = require('./chunk-VF3D6KLQ.cjs');
6
+ var chunkDPCZJLB3_cjs = require('./chunk-DPCZJLB3.cjs');
7
+ var chunkYQL7NISX_cjs = require('./chunk-YQL7NISX.cjs');
8
+ var viem = require('viem');
9
+
10
+ var kernelFactoryAbi = viem.parseAbi([
11
+ "function implementation() view returns (address)",
12
+ "function getAddress(bytes calldata data, bytes32 salt) view returns (address)",
13
+ "function createAccount(bytes calldata data, bytes32 salt) payable returns (address)"
14
+ ]);
15
+ var KERNEL_V3_1_IMPLEMENTATION_ADDRESS = "0xbAC849bB641841b44E965fb01A4Bf5F074F84B4d";
16
+ var entryPointV07Abi = viem.parseAbi([
17
+ "function getNonce(address sender, uint192 key) view returns (uint256 nonce)",
18
+ "function balanceOf(address account) view returns (uint256)",
19
+ "function depositTo(address account) payable",
20
+ "function withdrawTo(address payable withdrawAddress, uint256 withdrawAmount)",
21
+ "function getDepositInfo(address account) view returns ((uint256 deposit, bool staked, uint96 stake, uint32 unstakeDelaySec, uint48 withdrawTime) info)",
22
+ "event Deposited(address indexed account, uint256 totalDeposit)",
23
+ "event Withdrawn(address indexed account, address withdrawAddress, uint256 amount)"
24
+ ]);
25
+
26
+ // src/aa/probes.ts
27
+ var BUNDLER_METHODS = [
28
+ "eth_sendUserOperation",
29
+ "eth_estimateUserOperationGas",
30
+ "eth_getUserOperationReceipt",
31
+ "eth_getUserOperationByHash",
32
+ "pimlico_getUserOperationGasPrice",
33
+ "zd_getUserOperationGasPrice"
34
+ ];
35
+ var REQUIRED_BUNDLER_METHODS = [
36
+ "eth_sendUserOperation",
37
+ "eth_estimateUserOperationGas",
38
+ "eth_getUserOperationReceipt"
39
+ ];
40
+ var METHOD_NOT_FOUND = -32601;
41
+ function isMethodNotFound(error) {
42
+ if (!error || error.code !== METHOD_NOT_FOUND) return false;
43
+ const message = error.message ?? "";
44
+ if (/invalid discriminator value/i.test(message)) return true;
45
+ return !/validation error|invalid params|must contain|required at/i.test(message);
46
+ }
47
+ function hostOf(url) {
48
+ try {
49
+ return new URL(url).host;
50
+ } catch {
51
+ return "the configured host";
52
+ }
53
+ }
54
+ function checkUrl(url, label) {
55
+ let u;
56
+ try {
57
+ u = new URL(url);
58
+ } catch {
59
+ throw new chunkYQL7NISX_cjs.PepuConfigError("CONFIG_BAD_URL", `${label} is not a valid URL.`);
60
+ }
61
+ if (u.protocol !== "http:" && u.protocol !== "https:") {
62
+ throw new chunkYQL7NISX_cjs.PepuConfigError("CONFIG_BAD_URL", `${label} must be an http(s) URL.`);
63
+ }
64
+ }
65
+ async function timedFetch(f, url, init, timeoutMs) {
66
+ const ctl = new AbortController();
67
+ const t = setTimeout(() => ctl.abort(), timeoutMs);
68
+ try {
69
+ return await f(url, { ...init, signal: ctl.signal });
70
+ } finally {
71
+ clearTimeout(t);
72
+ }
73
+ }
74
+ async function rpc(f, url, method, params, timeoutMs) {
75
+ const res = await timedFetch(
76
+ f,
77
+ url,
78
+ {
79
+ method: "POST",
80
+ headers: { "content-type": "application/json" },
81
+ body: JSON.stringify({ jsonrpc: "2.0", id: 1, method, params })
82
+ },
83
+ timeoutMs
84
+ );
85
+ let body;
86
+ try {
87
+ body = await res.json();
88
+ } catch {
89
+ throw new Error(`HTTP ${res.status} with a non-JSON body`);
90
+ }
91
+ if (!body || typeof body !== "object") throw new Error(`HTTP ${res.status} with an unexpected body`);
92
+ return body;
93
+ }
94
+ function unreachable(url, e) {
95
+ const reason = e instanceof Error && e.name === "AbortError" ? "timed out" : chunkWANILJZQ_cjs.redactSecrets(e instanceof Error ? e.message : String(e)).replace(/https?:\/\/\S+/g, "[url]");
96
+ return new chunkYQL7NISX_cjs.PepuBundlerError("BUNDLER_UNREACHABLE", `Could not reach ${hostOf(url)}: ${reason}`, { cause: e });
97
+ }
98
+ async function probeBundler(url, o = {}) {
99
+ checkUrl(url, "Bundler URL");
100
+ const f = o.fetch ?? ((i, init) => fetch(i, init));
101
+ const timeoutMs = o.timeoutMs ?? 8e3;
102
+ const started = Date.now();
103
+ try {
104
+ const chain = await rpc(f, url, "eth_chainId", [], timeoutMs);
105
+ const eps = await rpc(f, url, "eth_supportedEntryPoints", [], timeoutMs);
106
+ const chainId = typeof chain.result === "string" ? Number(BigInt(chain.result)) : void 0;
107
+ const entryPoints = Array.isArray(eps.result) ? eps.result : void 0;
108
+ const supportedMethods = {};
109
+ for (const m of BUNDLER_METHODS) {
110
+ try {
111
+ const r = await rpc(f, url, m, [], timeoutMs);
112
+ supportedMethods[m] = !isMethodNotFound(r.error);
113
+ } catch {
114
+ supportedMethods[m] = false;
115
+ }
116
+ }
117
+ const ep07 = chunkK7JSQPZO_cjs.getContract(chunkDPCZJLB3_cjs.pepuMainnet.id, "entryPoint07");
118
+ const want = ep07?.status === "deployed" ? ep07.address.toLowerCase() : void 0;
119
+ const missing = REQUIRED_BUNDLER_METHODS.filter((m) => supportedMethods[m] !== true);
120
+ const chainAndEntryPointOk = chainId === chunkDPCZJLB3_cjs.pepuMainnet.id && (want === void 0 || (entryPoints?.some((a) => a.toLowerCase() === want) ?? false));
121
+ const ok = chainAndEntryPointOk && missing.length === 0;
122
+ const out = {
123
+ ok,
124
+ latencyMs: Date.now() - started,
125
+ supportedMethods,
126
+ missingRequiredMethods: [...missing]
127
+ };
128
+ if (chainId !== void 0) out.chainId = chainId;
129
+ if (entryPoints) out.entryPoints = entryPoints;
130
+ if (!ok) {
131
+ out.error = new chunkYQL7NISX_cjs.PepuBundlerError(
132
+ "BUNDLER_UNREACHABLE",
133
+ chainId !== void 0 && chainId !== chunkDPCZJLB3_cjs.pepuMainnet.id ? `The bundler serves chain ${chainId}, not ${chunkDPCZJLB3_cjs.pepuMainnet.id}.` : !chainAndEntryPointOk ? "The bundler does not list EntryPoint v0.7." : `The bundler does not support ${missing.join(", ")}.`,
134
+ {
135
+ hint: "Point PEPU_BUNDLER_URL at a bundler for chain 97741 that supports EntryPoint v0.7 and the ERC-4337 UserOperation methods."
136
+ }
137
+ );
138
+ }
139
+ return out;
140
+ } catch (e) {
141
+ return { ok: false, latencyMs: Date.now() - started, error: unreachable(url, e) };
142
+ }
143
+ }
144
+ var STUB_PROBE_OP = {
145
+ sender: "0x0000000000000000000000000000000000000001",
146
+ nonce: "0x0",
147
+ callData: "0x",
148
+ callGasLimit: "0x0",
149
+ verificationGasLimit: "0x0",
150
+ preVerificationGas: "0x0",
151
+ maxFeePerGas: "0x0",
152
+ maxPriorityFeePerGas: "0x0",
153
+ signature: "0x"
154
+ };
155
+ async function probePaymaster(url, o = {}) {
156
+ checkUrl(url, "Paymaster URL");
157
+ const f = o.fetch ?? ((i, init) => fetch(i, init));
158
+ const timeoutMs = o.timeoutMs ?? 8e3;
159
+ const started = Date.now();
160
+ const origin = new URL(url).origin;
161
+ const out = { ok: false, latencyMs: 0 };
162
+ let reached = false;
163
+ let lastError;
164
+ try {
165
+ const res = await timedFetch(f, `${origin}/health`, { method: "GET" }, timeoutMs);
166
+ reached = true;
167
+ const body = await res.json().catch(() => null);
168
+ out.health = res.ok && body?.status === "ok";
169
+ } catch (e) {
170
+ lastError = e;
171
+ out.health = false;
172
+ }
173
+ try {
174
+ const res = await timedFetch(f, `${origin}/v2/free-tier`, { method: "GET" }, timeoutMs);
175
+ reached = true;
176
+ if (res.ok) out.freeTier = await res.json().catch(() => void 0);
177
+ } catch (e) {
178
+ lastError = e;
179
+ }
180
+ let speaksRpc = false;
181
+ try {
182
+ const ep07 = chunkK7JSQPZO_cjs.getContract(chunkDPCZJLB3_cjs.pepuMainnet.id, "entryPoint07");
183
+ const ep = ep07?.status === "deployed" ? ep07.address : "0x0000000071727De22E5E9d8BAf0edAc6f37da032";
184
+ const reply = await rpc(
185
+ f,
186
+ url,
187
+ "pm_getPaymasterStubData",
188
+ [STUB_PROBE_OP, ep, `0x${chunkDPCZJLB3_cjs.pepuMainnet.id.toString(16)}`, {}],
189
+ timeoutMs
190
+ );
191
+ reached = true;
192
+ const rpcError = reply.error !== null && typeof reply.error === "object";
193
+ speaksRpc = reply.result !== void 0 || rpcError;
194
+ if (reply.result !== void 0) {
195
+ out.erc7677StubOk = true;
196
+ out.erc7677 = "stub-ok";
197
+ } else if (rpcError) {
198
+ out.erc7677 = "needs-credential";
199
+ } else {
200
+ out.erc7677StubOk = false;
201
+ out.erc7677 = "not-responding";
202
+ }
203
+ } catch (e) {
204
+ lastError = e;
205
+ out.erc7677StubOk = false;
206
+ out.erc7677 = "not-responding";
207
+ }
208
+ out.latencyMs = Date.now() - started;
209
+ out.ok = speaksRpc && out.health !== false;
210
+ if (!reached) out.error = unreachable(url, lastError);
211
+ else if (!out.ok) {
212
+ out.error = new chunkYQL7NISX_cjs.PepuBundlerError("BUNDLER_UNREACHABLE", `${hostOf(url)} answered but is not a PEPU paymaster service.`, {
213
+ hint: "Check PEPU_PAYMASTER_URL points at the policy service (https://paymaster.pepeunchained.com), or its /v2/paymaster/<client token> endpoint."
214
+ });
215
+ }
216
+ return out;
217
+ }
218
+ async function getPaymasterDeposit(client, paymaster) {
219
+ const pm = chunkK7JSQPZO_cjs.getContract(chunkDPCZJLB3_cjs.pepuMainnet.id, "paymaster");
220
+ const ep = chunkK7JSQPZO_cjs.getContract(chunkDPCZJLB3_cjs.pepuMainnet.id, "entryPoint07");
221
+ const account = paymaster ?? (pm?.status === "deployed" ? pm.address : void 0);
222
+ if (!account || ep?.status !== "deployed") {
223
+ throw new chunkYQL7NISX_cjs.PepuConfigError("CONFIG_MISSING_ENV", "No paymaster address is known; pass one explicitly.", {
224
+ hint: "Pass the paymaster address as the second argument."
225
+ });
226
+ }
227
+ return client.readContract({
228
+ address: ep.address,
229
+ abi: entryPointV07Abi,
230
+ functionName: "balanceOf",
231
+ args: [account]
232
+ });
233
+ }
234
+
235
+ // src/aa/status.ts
236
+ function getPepuKernelStack(chainId) {
237
+ const entryPoint06 = chunkK7JSQPZO_cjs.getContract(chainId, "entryPoint06");
238
+ const entryPoint07 = chunkK7JSQPZO_cjs.getContract(chainId, "entryPoint07");
239
+ const kernelFactory = chunkK7JSQPZO_cjs.getContract(chainId, "kernelFactory");
240
+ const kernelMetaFactory = chunkK7JSQPZO_cjs.getContract(chainId, "kernelMetaFactory");
241
+ const ecdsaValidator = chunkK7JSQPZO_cjs.getContract(chainId, "ecdsaValidator");
242
+ if (entryPoint06?.status !== "deployed" || entryPoint07?.status !== "deployed" || kernelFactory?.status !== "deployed" || kernelMetaFactory?.status !== "deployed" || ecdsaValidator?.status !== "deployed") {
243
+ return void 0;
244
+ }
245
+ return { entryPoint06, entryPoint07, kernelFactory, kernelMetaFactory, ecdsaValidator };
246
+ }
247
+ function getSponsorshipStatus(options) {
248
+ const reason = "This deprecated function never probes anything and always reports unavailable. The hosted bundler (bundler.pepeunchained.com) and paymaster service (paymaster.pepeunchained.com) are live, and sponsorship is proven end to end on mainnet through them. Call checkSponsorship() for the live status. A Kernel v3 smart account without a funded project or free-tier token must still fund its own EntryPoint deposit and pay its own gas, like a normal EOA-sent transaction.";
249
+ return options?.bundlerUrl === void 0 ? { available: false, reason } : { available: false, reason, bundlerUrl: options.bundlerUrl };
250
+ }
251
+ async function getKernelAccountAddress(client, factory, args) {
252
+ return client.readContract({
253
+ address: factory.address,
254
+ abi: kernelFactoryAbi,
255
+ functionName: "getAddress",
256
+ args: [args.data, args.salt]
257
+ });
258
+ }
259
+ async function checkSponsorship(options = {}) {
260
+ const { bundlerUrl, paymasterUrl: erc7677Url, paymasterBaseUrl } = chunkVF3D6KLQ_cjs.resolvePepuEndpoints({
261
+ ...options.bundlerUrl !== void 0 ? { bundlerUrl: options.bundlerUrl } : {},
262
+ ...options.paymasterUrl !== void 0 ? { paymasterUrl: options.paymasterUrl } : {},
263
+ ...options.env ? { env: options.env } : {}
264
+ });
265
+ const paymasterUrl = erc7677Url ?? paymasterBaseUrl;
266
+ const probeOpts = {
267
+ ...options.fetch ? { fetch: options.fetch } : {},
268
+ ...options.timeoutMs !== void 0 ? { timeoutMs: options.timeoutMs } : {}
269
+ };
270
+ const fixes = [];
271
+ if (bundlerUrl === null) fixes.push(`Set ${chunkVF3D6KLQ_cjs.PEPU_ENV.bundlerUrl} to a bundler for chain 97741 (EntryPoint v0.7).`);
272
+ if (paymasterUrl === null) fixes.push(`Set ${chunkVF3D6KLQ_cjs.PEPU_ENV.paymasterUrl} to your ERC-7677 paymaster endpoint (https://paymaster.pepeunchained.com/v2/paymaster/<client token>).`);
273
+ const [bProbe, pProbe] = await Promise.all([
274
+ bundlerUrl === null ? void 0 : probeBundler(bundlerUrl, probeOpts),
275
+ paymasterUrl === null ? void 0 : probePaymaster(paymasterUrl, probeOpts)
276
+ ]);
277
+ if (bProbe && !bProbe.ok) fixes.push(bProbe.error?.hint ?? "The bundler did not answer correctly.");
278
+ if (pProbe && !pProbe.ok) fixes.push(pProbe.error?.hint ?? "The paymaster did not answer correctly.");
279
+ let depositWei;
280
+ if (options.publicClient) {
281
+ try {
282
+ depositWei = await getPaymasterDeposit(options.publicClient, options.paymasterAddress);
283
+ if (depositWei === 0n) fixes.push("The paymaster's EntryPoint deposit is empty. Deposit PEPU to it.");
284
+ } catch {
285
+ }
286
+ }
287
+ const available = !!bProbe?.ok && !!pProbe?.ok && depositWei !== 0n;
288
+ const configured = bundlerUrl !== null || paymasterUrl !== null;
289
+ const reason = available ? "Bundler and paymaster are reachable; sponsored UserOperations can be sent." : !configured ? "No bundler or paymaster URL is configured. Set PEPU_BUNDLER_URL and PEPU_PAYMASTER_URL, or use the hosted defaults." : "A bundler or paymaster is configured but not fully working. See fixes.";
290
+ return {
291
+ available,
292
+ transport: configured ? "direct" : "none",
293
+ bundler: { configured: bundlerUrl !== null, ...bProbe ? { probe: bProbe } : {} },
294
+ paymaster: {
295
+ configured: paymasterUrl !== null,
296
+ ...pProbe ? { probe: pProbe } : {},
297
+ ...depositWei !== void 0 ? { depositWei } : {}
298
+ },
299
+ reason,
300
+ fixes
301
+ };
302
+ }
303
+
304
+ exports.KERNEL_V3_1_IMPLEMENTATION_ADDRESS = KERNEL_V3_1_IMPLEMENTATION_ADDRESS;
305
+ exports.checkSponsorship = checkSponsorship;
306
+ exports.entryPointV07Abi = entryPointV07Abi;
307
+ exports.getKernelAccountAddress = getKernelAccountAddress;
308
+ exports.getPaymasterDeposit = getPaymasterDeposit;
309
+ exports.getPepuKernelStack = getPepuKernelStack;
310
+ exports.getSponsorshipStatus = getSponsorshipStatus;
311
+ exports.kernelFactoryAbi = kernelFactoryAbi;
312
+ exports.probeBundler = probeBundler;
313
+ exports.probePaymaster = probePaymaster;
314
+ //# sourceMappingURL=chunk-BGALSKAF.cjs.map
315
+ //# sourceMappingURL=chunk-BGALSKAF.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/abi/kernelFactory.ts","../src/abi/entryPointV07.ts","../src/aa/probes.ts","../src/aa/status.ts"],"names":["parseAbi","PepuConfigError","redactSecrets","PepuBundlerError","getContract","pepuMainnet","resolvePepuEndpoints","PEPU_ENV"],"mappings":";;;;;;;;;AA6BO,IAAM,mBAAmBA,aAAA,CAAS;AAAA,EACvC,kDAAA;AAAA,EACA,+EAAA;AAAA,EACA;AACF,CAAC;AAOM,IAAM,kCAAA,GACX;ACdK,IAAM,mBAAmBA,aAAAA,CAAS;AAAA,EACvC,6EAAA;AAAA,EACA,4DAAA;AAAA,EACA,6CAAA;AAAA,EACA,8EAAA;AAAA,EACA,wJAAA;AAAA,EACA,gEAAA;AAAA,EACA;AACF,CAAC;;;ACuBD,IAAM,eAAA,GAAkB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AyC,CAAA;AAEpG,EAAA,IAAI,UAAA;AACJ,EAAA,IAAI,QAAQ,YAAA,EAAc;AACxB,IAAA,IAAI;AACF,MAAA,UAAA,GAAa,MAAM,mBAAA,CAAoB,OAAA,CAAQ,YAAA,EAAc,QAAQ,gBAAgB,CAAA;AACrF,MAAA,IAAI,UAAA,KAAe,EAAA,EAAI,KAAA,CAAM,IAAA,CAAK,kEAAkE,CAAA;AAAA,IACtG,CAAA,CAAA,MAAQ;AAAA,IAER;AAAA,EACF;AAEA,EAAA,MAAM,SAAA,GAAY,CAAC,CAAC,MAAA,EAAQ,MAAM,CAAC,CAAC,MAAA,EAAQ,EAAA,IAAM,UAAA,KAAe,EAAA;AACjE,EAAA,MAAM,UAAA,GAAa,UAAA,KAAe,IAAA,IAAQ,YAAA,KAAiB,IAAA;AAC3D,EAAA,MAAM,MAAA,GAAS,SAAA,GACX,4EAAA,GACA,CAAC,aACC,qHAAA,GACA,wEAAA;AACN,EAAA,OAAO;AAAA,IACL,SAAA;AAAA,IACA,SAAA,EAAW,aAAa,QAAA,GAAW,MAAA;AAAA,IACnC,OAAA,EAAS,EAAE,UAAA,EAAY,UAAA,KAAe,IAAA,EAAM,GAAI,MAAA,GAAS,EAAE,KAAA,EAAO,MAAA,EAAO,GAAI,EAAC,EAAG;AAAA,IACjF,SAAA,EAAW;AAAA,MACT,YAAY,YAAA,KAAiB,IAAA;AAAA,MAC7B,GAAI,MAAA,GAAS,EAAE,KAAA,EAAO,MAAA,KAAW,EAAC;AAAA,MAClC,GAAI,UAAA,KAAe,MAAA,GAAY,EAAE,UAAA,KAAe;AAAC,KACnD;AAAA,IACA,MAAA;AAAA,IACA;AAAA,GACF;AACF","file":"chunk-BGALSKAF.cjs","sourcesContent":["import { parseAbi } from \"viem\";\n\n/**\n * ZeroDev Kernel v3 account factory ABI, at\n * `0xaac5D4240AF87249B3f71BC8E4A2cae074A3E419` (deployed on PEPU mainnet\n * only; see `pepuContracts.kernelFactory` in `../contracts.js`).\n *\n * Verified live against mainnet 2026-09-24 via `eth_call`:\n * - `implementation()` returns `0xbAC849bB641841b44E965fb01A4Bf5F074F84B4d` —\n * ZeroDev's Kernel v3.1 singleton implementation address, deployed at the\n * same address on every chain that has it via CREATE2.\n * - `getAddress(bytes,bytes32)`, called with empty `data` and a zero salt,\n * returns a computed address without reverting.\n * - `createAccount(bytes,bytes32)`, simulated (not sent) with the same\n * empty `data` and zero salt via `eth_call`, returns the **same** address\n * `getAddress` computed for those inputs — exactly the counterfactual-\n * address behavior a CREATE2 account factory is supposed to have.\n *\n * What this package does NOT ship: a helper that encodes the `data`\n * argument (Kernel v3.1's `initialize(...)` calldata — root validator,\n * hook, validator data, hook data, init config). No account has ever been\n * created through this factory on PEPU yet (its transaction history is\n * empty as of the verification date above), so there was nothing on-chain\n * to check a hand-rolled encoding against, and guessing one here would be\n * exactly the kind of invented byte layout this package's rules forbid.\n * Use ZeroDev's own `@zerodev/sdk` (or the public Kernel contracts source)\n * to build that payload, then pass the resulting bytes into\n * `getAddress`/`createAccount` from this ABI.\n */\nexport const kernelFactoryAbi = parseAbi([\n \"function implementation() view returns (address)\",\n \"function getAddress(bytes calldata data, bytes32 salt) view returns (address)\",\n \"function createAccount(bytes calldata data, bytes32 salt) payable returns (address)\",\n]);\n\n/**\n * The verified Kernel v3.1 singleton implementation address that\n * `kernelFactoryAbi`'s `implementation()` resolves to on PEPU mainnet. Same\n * address ZeroDev uses across every chain that has this Kernel version.\n */\nexport const KERNEL_V3_1_IMPLEMENTATION_ADDRESS =\n \"0xbAC849bB641841b44E965fb01A4Bf5F074F84B4d\" as const;\n","import { parseAbi } from \"viem\";\n\n/**\n * ERC-4337 EntryPoint v0.7 ABI — the subset a dapp actually needs to manage\n * a smart account's gas deposit and read its nonce, at the canonical address\n * `0x0000000071727De22E5E9d8BAf0edAc6f37da032` (deployed on PEPU mainnet\n * only; see `pepuContracts.entryPoint07` in `../contracts.js`).\n *\n * This is NOT the full `IEntryPoint` interface (no `handleOps`,\n * `simulateValidation`, etc.) — those are normally called by a bundler, and\n * PEPU has no publicly hosted bundler yet (see `getSponsorshipStatus` in\n * `../aa/status.js`). This ABI only covers deposit/nonce management, which works\n * today with a plain viem wallet client and no bundler at all.\n *\n * Verified live against mainnet 2026-09-24 via `eth_call`:\n * - `getNonce(address,uint192)` for the zero address/key returns `0`.\n * - `balanceOf(address)` for the zero address returns `0`.\n * - `getDepositInfo(address)` for the zero address returns a 5-word\n * (all-zero) tuple, matching the v0.7 `DepositInfo` struct shape\n * `(uint256 deposit, bool staked, uint96 stake, uint32 unstakeDelaySec,\n * uint48 withdrawTime)` field-for-field.\n * `depositTo`/`withdrawTo` share the same `IStakeManager` interface as the\n * verified `getDepositInfo`/`balanceOf` pair and are standard across every\n * EntryPoint version; they were not separately simulated (both mutate\n * state, and simulating a withdrawal from an empty deposit would only prove\n * it reverts, not that it works).\n */\nexport const entryPointV07Abi = parseAbi([\n \"function getNonce(address sender, uint192 key) view returns (uint256 nonce)\",\n \"function balanceOf(address account) view returns (uint256)\",\n \"function depositTo(address account) payable\",\n \"function withdrawTo(address payable withdrawAddress, uint256 withdrawAmount)\",\n \"function getDepositInfo(address account) view returns ((uint256 deposit, bool staked, uint96 stake, uint32 unstakeDelaySec, uint48 withdrawTime) info)\",\n \"event Deposited(address indexed account, uint256 totalDeposit)\",\n \"event Withdrawn(address indexed account, address withdrawAddress, uint256 amount)\",\n]);\n","import type { Address, PublicClient } from \"viem\";\n\nimport { entryPointV07Abi } from \"../abi/entryPointV07.js\";\nimport { pepuMainnet } from \"../chains.js\";\nimport { getContract } from \"../contracts.js\";\nimport { PepuBundlerError, PepuConfigError } from \"../errors.js\";\nimport { redactSecrets } from \"./describe.js\";\n\n/** Minimal fetch signature, so tests and non-browser hosts can inject one. */\nexport type FetchLike = (input: string, init?: RequestInit) => Promise<Response>;\n\nexport interface ProbeOptions {\n fetch?: FetchLike;\n /** Per-request timeout. Default 8000. */\n timeoutMs?: number;\n}\n\nexport interface BundlerProbeResult {\n ok: boolean;\n chainId?: number;\n entryPoints?: Address[];\n /**\n * `true` when the method exists. Each method is called with deliberately empty\n * (invalid) params, so nothing is ever sent on-chain: an \"invalid params\" or\n * validation answer means the method exists, a \"method not found\" answer\n * (including Alto's \"Invalid discriminator value\") means it does not.\n */\n supportedMethods?: Record<string, boolean>;\n /** Required methods (see `REQUIRED_BUNDLER_METHODS`) the bundler lacks. Empty when all are present. */\n missingRequiredMethods?: string[];\n latencyMs: number;\n error?: PepuBundlerError;\n}\n\nexport interface PaymasterProbeResult {\n ok: boolean;\n /** `GET <origin>/health` answered `{ status: \"ok\" }`. */\n health?: boolean;\n /** Body of `GET <origin>/v2/free-tier` when the service exposes it. */\n freeTier?: unknown;\n /**\n * `true` when the URL answered `pm_getPaymasterStubData` with a stub result,\n * `false` when it did not answer JSON-RPC at all. A JSON-RPC denial (no\n * credential, unknown sender) leaves it `undefined`: the endpoint speaks\n * ERC-7677 but the probe has no credential, so a stub cannot be judged. Read\n * `erc7677` for the three-way answer.\n */\n erc7677StubOk?: boolean;\n /**\n * `\"stub-ok\"`: a stub came back. `\"needs-credential\"`: the endpoint speaks ERC-7677\n * JSON-RPC and answered with an error (no credential, unknown sender), so the stub\n * check is not applicable without a client token. `\"not-responding\"`: no JSON-RPC answer.\n */\n erc7677?: \"stub-ok\" | \"needs-credential\" | \"not-responding\";\n latencyMs: number;\n error?: PepuBundlerError;\n}\n\nconst BUNDLER_METHODS = [\n \"eth_sendUserOperation\",\n \"eth_estimateUserOperationGas\",\n \"eth_getUserOperationReceipt\",\n \"eth_getUserOperationByHash\",\n \"pimlico_getUserOperationGasPrice\",\n \"zd_getUserOperationGasPrice\",\n] as const;\n\n/** Methods a bundler must support to be usable for PEPU sponsored UserOperations. */\nexport const REQUIRED_BUNDLER_METHODS = [\n \"eth_sendUserOperation\",\n \"eth_estimateUserOperationGas\",\n \"eth_getUserOperationReceipt\",\n] as const;\n\nconst METHOD_NOT_FOUND = -32601;\n\n/**\n * A bundler answers a method that does not exist with \"method not found\". Alto\n * (Pimlico) also reports bad params of a KNOWN method with code -32601 and a\n * \"Validation error: ...\" message, and an unknown method as \"Validation error:\n * Invalid discriminator value\". So -32601 means unsupported unless the message is\n * a params validation error that is not the discriminator one.\n */\nfunction isMethodNotFound(error: { code?: number; message?: string } | undefined): boolean {\n if (!error || error.code !== METHOD_NOT_FOUND) return false;\n const message = error.message ?? \"\";\n if (/invalid discriminator value/i.test(message)) return true;\n return !/validation error|invalid params|must contain|required at/i.test(message);\n}\n\nfunction hostOf(url: string): string {\n try {\n return new URL(url).host;\n } catch {\n return \"the configured host\";\n }\n}\n\nfunction checkUrl(url: string, label: string): void {\n let u: URL;\n try {\n u = new URL(url);\n } catch {\n throw new PepuConfigError(\"CONFIG_BAD_URL\", `${label} is not a valid URL.`);\n }\n if (u.protocol !== \"http:\" && u.protocol !== \"https:\") {\n throw new PepuConfigError(\"CONFIG_BAD_URL\", `${label} must be an http(s) URL.`);\n }\n}\n\nasync function timedFetch(f: FetchLike, url: string, init: RequestInit, timeoutMs: number): Promise<Response> {\n const ctl = new AbortController();\n const t = setTimeout(() => ctl.abort(), timeoutMs);\n try {\n return await f(url, { ...init, signal: ctl.signal });\n } finally {\n clearTimeout(t);\n }\n}\n\ninterface RpcReply {\n result?: unknown;\n error?: { code?: number; message?: string; data?: unknown };\n}\n\nasync function rpc(f: FetchLike, url: string, method: string, params: unknown[], timeoutMs: number): Promise<RpcReply> {\n const res = await timedFetch(\n f,\n url,\n {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify({ jsonrpc: \"2.0\", id: 1, method, params }),\n },\n timeoutMs,\n );\n let body: unknown;\n try {\n body = await res.json();\n } catch {\n throw new Error(`HTTP ${res.status} with a non-JSON body`);\n }\n if (!body || typeof body !== \"object\") throw new Error(`HTTP ${res.status} with an unexpected body`);\n return body as RpcReply;\n}\n\nfunction unreachable(url: string, e: unknown): PepuBundlerError {\n const reason = e instanceof Error && e.name === \"AbortError\" ? \"timed out\" : redactSecrets(e instanceof Error ? e.message : String(e)).replace(/https?:\\/\\/\\S+/g, \"[url]\");\n return new PepuBundlerError(\"BUNDLER_UNREACHABLE\", `Could not reach ${hostOf(url)}: ${reason}`, { cause: e });\n}\n\n/**\n * Probe a bundler URL: `eth_chainId`, `eth_supportedEntryPoints` and a\n * capability check of the methods PEPU apps use (a method answered with\n * anything but \"method not found\" counts as supported; nothing is sent\n * on-chain). Never throws for network trouble; returns `ok: false` with a\n * `BUNDLER_UNREACHABLE` error. Throws `CONFIG_BAD_URL` for a malformed URL.\n *\n * @example\n * const r = await probeBundler(\"https://bundler.example.com\");\n * if (!r.ok) console.log(r.error?.hint);\n */\nexport async function probeBundler(url: string, o: ProbeOptions = {}): Promise<BundlerProbeResult> {\n checkUrl(url, \"Bundler URL\");\n const f: FetchLike = o.fetch ?? ((i, init) => fetch(i, init));\n const timeoutMs = o.timeoutMs ?? 8000;\n const started = Date.now();\n try {\n const chain = await rpc(f, url, \"eth_chainId\", [], timeoutMs);\n const eps = await rpc(f, url, \"eth_supportedEntryPoints\", [], timeoutMs);\n const chainId = typeof chain.result === \"string\" ? Number(BigInt(chain.result)) : undefined;\n const entryPoints = Array.isArray(eps.result) ? (eps.result as Address[]) : undefined;\n const supportedMethods: Record<string, boolean> = {};\n for (const m of BUNDLER_METHODS) {\n try {\n const r = await rpc(f, url, m, [], timeoutMs);\n supportedMethods[m] = !isMethodNotFound(r.error);\n } catch {\n supportedMethods[m] = false;\n }\n }\n const ep07 = getContract(pepuMainnet.id, \"entryPoint07\");\n const want = ep07?.status === \"deployed\" ? ep07.address.toLowerCase() : undefined;\n const missing = REQUIRED_BUNDLER_METHODS.filter((m) => supportedMethods[m] !== true);\n const chainAndEntryPointOk =\n chainId === pepuMainnet.id &&\n (want === undefined || (entryPoints?.some((a) => a.toLowerCase() === want) ?? false));\n const ok = chainAndEntryPointOk && missing.length === 0;\n const out: BundlerProbeResult = {\n ok,\n latencyMs: Date.now() - started,\n supportedMethods,\n missingRequiredMethods: [...missing],\n };\n if (chainId !== undefined) out.chainId = chainId;\n if (entryPoints) out.entryPoints = entryPoints;\n if (!ok) {\n out.error = new PepuBundlerError(\n \"BUNDLER_UNREACHABLE\",\n chainId !== undefined && chainId !== pepuMainnet.id\n ? `The bundler serves chain ${chainId}, not ${pepuMainnet.id}.`\n : !chainAndEntryPointOk\n ? \"The bundler does not list EntryPoint v0.7.\"\n : `The bundler does not support ${missing.join(\", \")}.`,\n {\n hint: \"Point PEPU_BUNDLER_URL at a bundler for chain 97741 that supports EntryPoint v0.7 and the ERC-4337 UserOperation methods.\",\n },\n );\n }\n return out;\n } catch (e) {\n return { ok: false, latencyMs: Date.now() - started, error: unreachable(url, e) };\n }\n}\n\nconst STUB_PROBE_OP = {\n sender: \"0x0000000000000000000000000000000000000001\",\n nonce: \"0x0\",\n callData: \"0x\",\n callGasLimit: \"0x0\",\n verificationGasLimit: \"0x0\",\n preVerificationGas: \"0x0\",\n maxFeePerGas: \"0x0\",\n maxPriorityFeePerGas: \"0x0\",\n signature: \"0x\",\n} as const;\n\n/**\n * Probe a paymaster URL: the service base (`https://paymaster.pepeunchained.com`) or the ERC-7677 endpoint\n * (`https://host/v2/paymaster/<token>`).\n * Checks `GET <origin>/health`, `GET <origin>/v2/free-tier`, and whether the URL\n * answers JSON-RPC `pm_getPaymasterStubData` (`erc7677`: without a client token a\n * JSON-RPC denial is reported as `\"needs-credential\"`, not as a failure). `ok` means\n * every capability that could be checked is fine: `/health` did not fail and the URL\n * spoke ERC-7677 JSON-RPC. The URL (which can embed a\n * token) never appears in the returned error.\n *\n * @example\n * const r = await probePaymaster(process.env.PEPU_PAYMASTER_URL!);\n * console.log(r.ok, r.freeTier);\n */\nexport async function probePaymaster(url: string, o: ProbeOptions = {}): Promise<PaymasterProbeResult> {\n checkUrl(url, \"Paymaster URL\");\n const f: FetchLike = o.fetch ?? ((i, init) => fetch(i, init));\n const timeoutMs = o.timeoutMs ?? 8000;\n const started = Date.now();\n const origin = new URL(url).origin;\n const out: PaymasterProbeResult = { ok: false, latencyMs: 0 };\n let reached = false;\n let lastError: unknown;\n\n try {\n const res = await timedFetch(f, `${origin}/health`, { method: \"GET\" }, timeoutMs);\n reached = true;\n const body = (await res.json().catch(() => null)) as { status?: unknown } | null;\n out.health = res.ok && body?.status === \"ok\";\n } catch (e) {\n lastError = e;\n out.health = false;\n }\n\n try {\n const res = await timedFetch(f, `${origin}/v2/free-tier`, { method: \"GET\" }, timeoutMs);\n reached = true;\n if (res.ok) out.freeTier = await res.json().catch(() => undefined);\n } catch (e) {\n lastError = e;\n }\n\n let speaksRpc = false;\n try {\n const ep07 = getContract(pepuMainnet.id, \"entryPoint07\");\n const ep = ep07?.status === \"deployed\" ? ep07.address : \"0x0000000071727De22E5E9d8BAf0edAc6f37da032\";\n const reply = await rpc(\n f,\n url,\n \"pm_getPaymasterStubData\",\n [STUB_PROBE_OP, ep, `0x${pepuMainnet.id.toString(16)}`, {}],\n timeoutMs,\n );\n reached = true;\n // A JSON-RPC answer has a result, or an error OBJECT (a REST 404 body like {\"error\":\"not_found\"} is not one).\n const rpcError = reply.error !== null && typeof reply.error === \"object\";\n speaksRpc = reply.result !== undefined || rpcError;\n if (reply.result !== undefined) {\n out.erc7677StubOk = true;\n out.erc7677 = \"stub-ok\";\n } else if (rpcError) {\n // Alive and speaking JSON-RPC, but the probe has no credential: not applicable, not a failure.\n out.erc7677 = \"needs-credential\";\n } else {\n out.erc7677StubOk = false;\n out.erc7677 = \"not-responding\";\n }\n } catch (e) {\n lastError = e;\n out.erc7677StubOk = false;\n out.erc7677 = \"not-responding\";\n }\n\n out.latencyMs = Date.now() - started;\n out.ok = speaksRpc && out.health !== false;\n if (!reached) out.error = unreachable(url, lastError);\n else if (!out.ok) {\n out.error = new PepuBundlerError(\"BUNDLER_UNREACHABLE\", `${hostOf(url)} answered but is not a PEPU paymaster service.`, {\n hint: \"Check PEPU_PAYMASTER_URL points at the policy service (https://paymaster.pepeunchained.com), or its /v2/paymaster/<client token> endpoint.\",\n });\n }\n return out;\n}\n\n/**\n * The paymaster's EntryPoint v0.7 deposit in wei. A drop across a UserOperation\n * is the proof that it was sponsored. Defaults to PEPU's deployed paymaster.\n *\n * @example\n * const before = await getPaymasterDeposit(publicClient);\n */\nexport async function getPaymasterDeposit(client: PublicClient, paymaster?: Address): Promise<bigint> {\n const pm = getContract(pepuMainnet.id, \"paymaster\");\n const ep = getContract(pepuMainnet.id, \"entryPoint07\");\n const account = paymaster ?? (pm?.status === \"deployed\" ? pm.address : undefined);\n if (!account || ep?.status !== \"deployed\") {\n throw new PepuConfigError(\"CONFIG_MISSING_ENV\", \"No paymaster address is known; pass one explicitly.\", {\n hint: \"Pass the paymaster address as the second argument.\",\n });\n }\n return client.readContract({\n address: ep.address,\n abi: entryPointV07Abi,\n functionName: \"balanceOf\",\n args: [account],\n });\n}\n","import type { Address, Hex, PublicClient, Transport } from \"viem\";\n\nimport { kernelFactoryAbi } from \"../abi/kernelFactory.js\";\nimport type { PepuChain } from \"../chains.js\";\nimport type { DeployedContract } from \"../contracts.js\";\nimport { getContract } from \"../contracts.js\";\nimport { PEPU_ENV, resolvePepuEndpoints } from \"../endpoints.js\";\nimport { getPaymasterDeposit, probeBundler, probePaymaster } from \"./probes.js\";\nimport type { BundlerProbeResult, FetchLike, PaymasterProbeResult } from \"./probes.js\";\n\n/**\n * The account-abstraction contracts a Kernel v3 smart account needs,\n * narrowed to their {@link DeployedContract} form for a given chain.\n * Returns `undefined` if any one of them isn't deployed on that chain\n * (today: everything except mainnet, `97741`) — this package never fabricates\n * a partial/best-effort bundle.\n */\nexport interface PepuKernelStack {\n readonly entryPoint06: DeployedContract;\n readonly entryPoint07: DeployedContract;\n readonly kernelFactory: DeployedContract;\n readonly kernelMetaFactory: DeployedContract;\n readonly ecdsaValidator: DeployedContract;\n}\n\n/**\n * Look up every AA contract this package knows about for `chainId`, already\n * narrowed to {@link DeployedContract}. Returns `undefined` unless *all* five\n * are deployed on that chain (today, only PEPU mainnet qualifies) — a caller\n * building a Kernel account needs every one of them, so a partial result\n * would just move the \"is this actually usable\" check into every caller.\n *\n * This is a convenience grouping over `getContract` from `./contracts.js`;\n * it doesn't add any address or fact that registry doesn't already have.\n */\nexport function getPepuKernelStack(chainId: number): PepuKernelStack | undefined {\n const entryPoint06 = getContract(chainId, \"entryPoint06\");\n const entryPoint07 = getContract(chainId, \"entryPoint07\");\n const kernelFactory = getContract(chainId, \"kernelFactory\");\n const kernelMetaFactory = getContract(chainId, \"kernelMetaFactory\");\n const ecdsaValidator = getContract(chainId, \"ecdsaValidator\");\n\n if (\n entryPoint06?.status !== \"deployed\" ||\n entryPoint07?.status !== \"deployed\" ||\n kernelFactory?.status !== \"deployed\" ||\n kernelMetaFactory?.status !== \"deployed\" ||\n ecdsaValidator?.status !== \"deployed\"\n ) {\n return undefined;\n }\n\n return { entryPoint06, entryPoint07, kernelFactory, kernelMetaFactory, ecdsaValidator };\n}\n\n/**\n * Legacy static gas-sponsorship status for PEPU. **Always reports\n * unavailable** (it never probes). Sponsorship is PROVEN end to end on PEPU\n * mainnet through the hosted bundler and paymaster service (a zero-balance\n * Kernel smart account transacted, paid for by the paymaster); use\n * `checkSponsorship()` for the live answer. This function\n * exists so nothing downstream (this package, `@pepu-chain/mcp`, an app)\n * has to independently invent an \"is sponsorship on?\" check, and so that\n * check can't silently start lying once this file changes.\n *\n * Do not treat the presence of `kernelFactory`/`ecdsaValidator`/`paymaster`\n * addresses in {@link getPepuKernelStack} / the contract registry as\n * sponsorship support — those let you build and deploy a Kernel account and\n * send its UserOperations through a normal `eth_sendTransaction`-style flow\n * (self-paying its own gas via the EntryPoint deposit), which is a real,\n * working feature; sponsoring that gas needs a funded project or free-tier token.\n */\nexport interface SponsorshipStatus {\n readonly available: false;\n readonly reason: string;\n /**\n * Extension point for a future bundler/paymaster integration. Passing a\n * URL here does **not** make sponsorship available — `available` stays\n * `false` regardless — this field only exists so a caller can start\n * wiring a URL through their own config today and have this function\n * start using it later without an API change.\n */\n readonly bundlerUrl?: string;\n}\n\n/** Options for {@link getSponsorshipStatus}. */\nexport interface GetSponsorshipStatusOptions {\n /** See {@link SponsorshipStatus.bundlerUrl}. Not yet used for anything. */\n readonly bundlerUrl?: string;\n}\n\n/**\n * @deprecated Always reports `available: false`. Use `checkSponsorship()` (live\n * bundler and paymaster probe) from `@pepu-chain/sdk`. Kept for 0.1 callers.\n */\nexport function getSponsorshipStatus(\n options?: GetSponsorshipStatusOptions,\n): SponsorshipStatus {\n const reason =\n \"This deprecated function never probes anything and always reports \" +\n \"unavailable. The hosted bundler (bundler.pepeunchained.com) and \" +\n \"paymaster service (paymaster.pepeunchained.com) are live, and \" +\n \"sponsorship is proven end to end on mainnet through them. Call \" +\n \"checkSponsorship() for the live status. A Kernel v3 smart account \" +\n \"without a funded project or free-tier token must still fund its own \" +\n \"EntryPoint deposit and pay its own gas, like a normal EOA-sent transaction.\";\n return options?.bundlerUrl === undefined\n ? { available: false, reason }\n : { available: false, reason, bundlerUrl: options.bundlerUrl };\n}\n\n/**\n * Compute (or confirm) the counterfactual address of a Kernel v3 smart\n * account via the verified factory's `getAddress(data, salt)` — a thin,\n * typed pass-through, not a re-implementation.\n *\n * Deliberately does **not** build `data` (Kernel v3.1's `initialize(...)`\n * calldata: root validator, hook, validator data, hook data, init config)\n * for you. A hand-rolled encoding here would be a second, unverified copy of\n * the byte layout that ZeroDev's SDK already produces (and that has been\n * exercised against PEPU's factory through the sponsored-transaction run),\n * which is exactly the kind of invented encoding this package's rules\n * forbid for addresses. Build `data` with ZeroDev's\n * `@zerodev/sdk` (or by hand from the public Kernel v3 contracts source),\n * then pass the result here.\n */\nexport async function getKernelAccountAddress(\n client: PublicClient<Transport, PepuChain>,\n factory: Pick<DeployedContract, \"address\">,\n args: { readonly data: Hex; readonly salt: Hex },\n): Promise<Address> {\n return client.readContract({\n address: factory.address,\n abi: kernelFactoryAbi,\n functionName: \"getAddress\",\n args: [args.data, args.salt],\n });\n}\n\n/** Live sponsorship report from {@link checkSponsorship}. */\nexport interface SponsorshipReport {\n /** True only when a bundler and a paymaster are configured and both answer. */\n available: boolean;\n /** `direct` when you bring your own bundler and paymaster URLs; `none` when nothing is configured. */\n transport: \"direct\" | \"none\";\n bundler: { configured: boolean; probe?: BundlerProbeResult };\n paymaster: { configured: boolean; probe?: PaymasterProbeResult; depositWei?: bigint };\n /** One sentence for a human or an agent. */\n reason: string;\n /** Concrete next steps, empty when `available`. */\n fixes: string[];\n}\n\n/** Options for {@link checkSponsorship}. */\nexport interface CheckSponsorshipOptions {\n bundlerUrl?: string;\n paymasterUrl?: string;\n env?: Record<string, string | undefined>;\n fetch?: FetchLike;\n /** When given, also read the paymaster's EntryPoint deposit. */\n publicClient?: PublicClient;\n /** Paymaster contract to read the deposit of. Defaults to PEPU's deployed paymaster. */\n paymasterAddress?: Address;\n timeoutMs?: number;\n}\n\n/**\n * Live gas-sponsorship status. Resolves the bundler and paymaster URLs from\n * options, env, then the hosted defaults (bundler.pepeunchained.com and the paymaster\n * service base; with no token URL the service is probed at its base), probes both,\n * and optionally reads the paymaster deposit. Never throws for an\n * unreachable service; it reports `available: false` with `fixes`.\n * Replaces the hard-coded {@link getSponsorshipStatus}.\n *\n * @example\n * const s = await checkSponsorship({ publicClient });\n * if (!s.available) console.log(s.reason, s.fixes);\n */\nexport async function checkSponsorship(options: CheckSponsorshipOptions = {}): Promise<SponsorshipReport> {\n const { bundlerUrl, paymasterUrl: erc7677Url, paymasterBaseUrl } = resolvePepuEndpoints({\n ...(options.bundlerUrl !== undefined ? { bundlerUrl: options.bundlerUrl } : {}),\n ...(options.paymasterUrl !== undefined ? { paymasterUrl: options.paymasterUrl } : {}),\n ...(options.env ? { env: options.env } : {}),\n });\n // No token means no complete ERC-7677 URL: probe the service base (health + free-tier state) instead.\n const paymasterUrl = erc7677Url ?? paymasterBaseUrl;\n const probeOpts = {\n ...(options.fetch ? { fetch: options.fetch } : {}),\n ...(options.timeoutMs !== undefined ? { timeoutMs: options.timeoutMs } : {}),\n };\n const fixes: string[] = [];\n if (bundlerUrl === null) fixes.push(`Set ${PEPU_ENV.bundlerUrl} to a bundler for chain 97741 (EntryPoint v0.7).`);\n if (paymasterUrl === null) fixes.push(`Set ${PEPU_ENV.paymasterUrl} to your ERC-7677 paymaster endpoint (https://paymaster.pepeunchained.com/v2/paymaster/<client token>).`);\n\n const [bProbe, pProbe] = await Promise.all([\n bundlerUrl === null ? undefined : probeBundler(bundlerUrl, probeOpts),\n paymasterUrl === null ? undefined : probePaymaster(paymasterUrl, probeOpts),\n ]);\n if (bProbe && !bProbe.ok) fixes.push(bProbe.error?.hint ?? \"The bundler did not answer correctly.\");\n if (pProbe && !pProbe.ok) fixes.push(pProbe.error?.hint ?? \"The paymaster did not answer correctly.\");\n\n let depositWei: bigint | undefined;\n if (options.publicClient) {\n try {\n depositWei = await getPaymasterDeposit(options.publicClient, options.paymasterAddress);\n if (depositWei === 0n) fixes.push(\"The paymaster's EntryPoint deposit is empty. Deposit PEPU to it.\");\n } catch {\n // A failed read must not flip availability; the probes are the source of truth.\n }\n }\n\n const available = !!bProbe?.ok && !!pProbe?.ok && depositWei !== 0n;\n const configured = bundlerUrl !== null || paymasterUrl !== null;\n const reason = available\n ? \"Bundler and paymaster are reachable; sponsored UserOperations can be sent.\"\n : !configured\n ? \"No bundler or paymaster URL is configured. Set PEPU_BUNDLER_URL and PEPU_PAYMASTER_URL, or use the hosted defaults.\"\n : \"A bundler or paymaster is configured but not fully working. See fixes.\";\n return {\n available,\n transport: configured ? \"direct\" : \"none\",\n bundler: { configured: bundlerUrl !== null, ...(bProbe ? { probe: bProbe } : {}) },\n paymaster: {\n configured: paymasterUrl !== null,\n ...(pProbe ? { probe: pProbe } : {}),\n ...(depositWei !== undefined ? { depositWei } : {}),\n },\n reason,\n fixes,\n };\n}\n"]}
@@ -0,0 +1,200 @@
1
+ 'use strict';
2
+
3
+ // src/privy/requirements.ts
4
+ var PRIVY_ENV = {
5
+ appId: "NEXT_PUBLIC_PRIVY_APP_ID",
6
+ appSecret: "PRIVY_APP_SECRET",
7
+ authorizationKey: "PRIVY_AUTHORIZATION_KEY",
8
+ keyQuorumId: "NEXT_PUBLIC_PRIVY_KEY_QUORUM_ID"
9
+ };
10
+ var PRIVY_ENV_ALIASES = {
11
+ appId: ["PRIVY_APP_ID"],
12
+ appSecret: [],
13
+ authorizationKey: [],
14
+ keyQuorumId: ["PRIVY_KEY_QUORUM_ID"]
15
+ };
16
+ var PRIVY_DOCS = "https://guide.pepeunchained.com/privy";
17
+ var normOrigin = (o) => o.trim().replace(/\/+$/, "").toLowerCase();
18
+ var PEPU_PRIVY_REQUIREMENTS = [
19
+ {
20
+ id: "app-id",
21
+ where: "env",
22
+ label: `${PRIVY_ENV.appId} is set`,
23
+ required: true,
24
+ pillars: ["login", "session", "sponsor"],
25
+ fix: `Copy the App ID from the Privy dashboard (Settings, Basics) into ${PRIVY_ENV.appId}.`,
26
+ docsUrl: `${PRIVY_DOCS}#app-id`
27
+ },
28
+ {
29
+ id: "app-secret",
30
+ where: "env",
31
+ label: `${PRIVY_ENV.appSecret} is set (server only)`,
32
+ required: true,
33
+ pillars: ["login", "session", "sponsor"],
34
+ fix: `Create an app secret in the Privy dashboard and put it in ${PRIVY_ENV.appSecret}. Never prefix it with NEXT_PUBLIC_.`,
35
+ docsUrl: `${PRIVY_DOCS}#app-secret`
36
+ },
37
+ {
38
+ id: "allowed-origins",
39
+ where: "dashboard",
40
+ label: "The page origin (including the port) is in Allowed origins",
41
+ required: true,
42
+ pillars: ["login", "session", "sponsor"],
43
+ check: (cfg, ctx) => {
44
+ if (!ctx.origin) return { ok: "unknown", detail: "No origin was given to check." };
45
+ if (!Array.isArray(cfg.allowed_domains)) {
46
+ return { ok: "unknown", detail: "Privy did not report allowed origins." };
47
+ }
48
+ const want = normOrigin(ctx.origin);
49
+ const hit = cfg.allowed_domains.some((d) => normOrigin(d) === want || normOrigin(d) === "*");
50
+ return hit ? { ok: true, detail: `${ctx.origin} is allowed.` } : { ok: false, detail: `${ctx.origin} is not in Allowed origins.` };
51
+ },
52
+ fix: "Add the exact origin, scheme, host and port, to Privy dashboard, Configuration, App settings, Allowed origins. A different dev port counts as a different origin.",
53
+ docsUrl: `${PRIVY_DOCS}#allowed-origins`
54
+ },
55
+ {
56
+ id: "login-methods",
57
+ where: "dashboard",
58
+ label: "At least one login method is enabled",
59
+ required: true,
60
+ pillars: ["login"],
61
+ check: (cfg) => {
62
+ if (!Array.isArray(cfg.login_methods)) {
63
+ return { ok: "unknown", detail: "Privy did not report login methods." };
64
+ }
65
+ return cfg.login_methods.length > 0 ? { ok: true, detail: `Enabled: ${cfg.login_methods.join(", ")}.` } : { ok: false, detail: "No login methods are enabled." };
66
+ },
67
+ fix: "Enable the methods you list in loginMethods under Privy dashboard, User management, Authentication. Methods not enabled there are hidden even if listed in code.",
68
+ docsUrl: `${PRIVY_DOCS}#login-methods`
69
+ },
70
+ {
71
+ id: "login-methods.google",
72
+ where: "dashboard",
73
+ label: "Google login is enabled",
74
+ required: false,
75
+ pillars: ["login"],
76
+ check: (cfg) => {
77
+ if (!Array.isArray(cfg.login_methods)) {
78
+ return { ok: "unknown", detail: "Privy did not report login methods." };
79
+ }
80
+ return cfg.login_methods.some((m) => m === "google" || m === "google_oauth") ? { ok: true, detail: "Google login is enabled." } : { ok: false, detail: "Google login is not enabled." };
81
+ },
82
+ fix: "Enable Google under Privy dashboard, User management, Authentication, Socials.",
83
+ docsUrl: `${PRIVY_DOCS}#google`
84
+ },
85
+ {
86
+ id: "embedded-wallets",
87
+ where: "dashboard",
88
+ label: "Embedded wallets are enabled for Ethereum",
89
+ required: true,
90
+ pillars: ["login", "session", "sponsor"],
91
+ check: (cfg) => {
92
+ const eth = cfg.embedded_wallet_config?.ethereum;
93
+ if (!eth) return { ok: "unknown", detail: "Privy did not report the Ethereum embedded wallet config." };
94
+ const mode = eth.create_on_login;
95
+ return {
96
+ ok: true,
97
+ detail: typeof mode === "string" ? `Dashboard create-on-login is "${mode}". The SDK provisions wallets server-side either way (WalletGate).` : "Ethereum embedded wallets are configured."
98
+ };
99
+ },
100
+ fix: "Turn on embedded wallets for Ethereum in Privy dashboard, Wallets. Wallet creation itself is handled server-side by createEnsureWalletRoute().",
101
+ docsUrl: `${PRIVY_DOCS}#embedded-wallets`
102
+ },
103
+ {
104
+ id: "coinbase-eoa-only",
105
+ where: "code",
106
+ label: "Coinbase Wallet is pinned to eoaOnly",
107
+ required: true,
108
+ pillars: ["login"],
109
+ fix: "Build the Privy config with createPepuPrivyConfig() (or use PepuPrivyProvider). Coinbase Smart Wallet does not support chain 97741.",
110
+ docsUrl: `${PRIVY_DOCS}#coinbase`
111
+ },
112
+ {
113
+ id: "authorization-key-quorum",
114
+ where: "env",
115
+ label: `${PRIVY_ENV.authorizationKey} is set and ${PRIVY_ENV.keyQuorumId} is its key quorum id`,
116
+ required: false,
117
+ pillars: ["session"],
118
+ fix: `Create an authorization key in the Privy dashboard, put the private half in ${PRIVY_ENV.authorizationKey} and its key quorum id in ${PRIVY_ENV.keyQuorumId}. A mismatch gives "No valid authorization keys or user signing keys available".`,
119
+ docsUrl: `${PRIVY_DOCS}#key-quorum`
120
+ },
121
+ {
122
+ id: "smart-wallets",
123
+ where: "dashboard",
124
+ label: "Smart wallets are enabled with the PEPU bundler and paymaster URLs (Privy transport only)",
125
+ required: false,
126
+ pillars: ["sponsor"],
127
+ check: (cfg) => cfg.smart_wallet_config === void 0 ? { ok: "unknown", detail: "Privy did not report smart wallet settings." } : { ok: true, detail: "Smart wallet settings are present." },
128
+ fix: "Only needed for the Privy Smart Wallets transport: add the PEPU chain with bundler and paymaster URLs under Privy dashboard, Wallets, Smart wallets. The direct transport does not need this.",
129
+ docsUrl: `${PRIVY_DOCS}#smart-wallets`
130
+ }
131
+ ];
132
+ var PRIVY_APP_CONFIG_URL = "https://auth.privy.io/api/v1/apps/";
133
+ async function checkPrivyDashboardConfig(o) {
134
+ const rows = PEPU_PRIVY_REQUIREMENTS.filter((r) => r.where === "dashboard");
135
+ const unknownAll = (detail) => ({
136
+ ok: true,
137
+ items: rows.map((r) => ({ id: r.id, ok: "unknown", detail, fix: r.fix }))
138
+ });
139
+ const appId = o.appId?.trim() ?? "";
140
+ if (!appId) return unknownAll(`${PRIVY_ENV.appId} is empty, so nothing could be checked.`);
141
+ let cfg;
142
+ try {
143
+ const doFetch = o.fetch ?? globalThis.fetch;
144
+ const res = await doFetch(`${PRIVY_APP_CONFIG_URL}${encodeURIComponent(appId)}`, {
145
+ headers: {
146
+ "privy-app-id": appId,
147
+ ...o.origin ? { origin: o.origin } : {}
148
+ }
149
+ });
150
+ if (!res.ok) return unknownAll(`Privy's public app config returned HTTP ${res.status}.`);
151
+ const json = await res.json();
152
+ if (typeof json !== "object" || json === null) return unknownAll("Privy's public app config was not an object.");
153
+ cfg = json;
154
+ } catch {
155
+ return unknownAll("Could not reach Privy's public app config (network error).");
156
+ }
157
+ const items = rows.map((r) => {
158
+ let result = { ok: "unknown", detail: "No automatic check." };
159
+ if (r.check) {
160
+ try {
161
+ result = r.check(cfg, o.origin !== void 0 ? { origin: o.origin } : {});
162
+ } catch {
163
+ result = { ok: "unknown", detail: "The check could not read Privy's response." };
164
+ }
165
+ }
166
+ return result.ok === true ? { id: r.id, ok: true, detail: result.detail } : { id: r.id, ok: result.ok, detail: result.detail, fix: r.fix };
167
+ });
168
+ const ok = !items.some((i) => i.ok === false && rows.find((r) => r.id === i.id)?.required);
169
+ return { ok, items };
170
+ }
171
+ async function privyDashboardChecker(input) {
172
+ const report = await checkPrivyDashboardConfig({
173
+ appId: input.appId,
174
+ fetch: input.fetch,
175
+ ...input.origin !== void 0 ? { origin: input.origin } : {}
176
+ });
177
+ return input.requirementKeys.map((key) => {
178
+ const id = `privy.${key}`;
179
+ const row = PEPU_PRIVY_REQUIREMENTS.find((r) => r.id === key);
180
+ if (!row) {
181
+ return { id, status: "fail", message: `Unknown Privy requirement key "${key}".`, fix: "Use a key from PEPU_PRIVY_REQUIREMENTS." };
182
+ }
183
+ if (row.where !== "dashboard") {
184
+ return { id, status: "skip", message: `${row.label}: checked by the env/code checks, not the dashboard.` };
185
+ }
186
+ const item = report.items.find((i) => i.id === key);
187
+ if (!item || item.ok === "unknown") {
188
+ return { id, status: "warn", message: `${row.label}: could not be verified. ${item?.detail ?? ""}`.trim(), fix: row.fix };
189
+ }
190
+ return item.ok ? { id, status: "pass", message: `${row.label}: ${item.detail}` } : { id, status: "fail", message: `${row.label}: ${item.detail}`, fix: row.fix };
191
+ });
192
+ }
193
+
194
+ exports.PEPU_PRIVY_REQUIREMENTS = PEPU_PRIVY_REQUIREMENTS;
195
+ exports.PRIVY_ENV = PRIVY_ENV;
196
+ exports.PRIVY_ENV_ALIASES = PRIVY_ENV_ALIASES;
197
+ exports.checkPrivyDashboardConfig = checkPrivyDashboardConfig;
198
+ exports.privyDashboardChecker = privyDashboardChecker;
199
+ //# sourceMappingURL=chunk-C2XW44FI.cjs.map
200
+ //# sourceMappingURL=chunk-C2XW44FI.cjs.map