@pepu-chain/sdk 0.2.0 → 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 (61) hide show
  1. package/README.md +25 -0
  2. package/dist/aa/kernel.cjs +1 -0
  3. package/dist/aa/kernel.guard.js +15 -0
  4. package/dist/aa/react-direct.cjs +4 -3
  5. package/dist/aa/react-direct.guard.js +15 -0
  6. package/dist/aa/react-direct.js +2 -2
  7. package/dist/aa/react.cjs +4 -3
  8. package/dist/aa/react.d.cts +1 -1
  9. package/dist/aa/react.d.ts +1 -1
  10. package/dist/aa/react.guard.js +15 -0
  11. package/dist/aa/react.js +2 -2
  12. package/dist/aa.cjs +9 -9
  13. package/dist/aa.d.cts +1 -1
  14. package/dist/aa.d.ts +1 -1
  15. package/dist/aa.js +2 -2
  16. package/dist/{chunk-MBA4CLA5.js → chunk-7PVR7QSE.js} +3 -3
  17. package/dist/{chunk-MBA4CLA5.js.map → chunk-7PVR7QSE.js.map} +1 -1
  18. package/dist/{chunk-SLW7FRTL.cjs → chunk-BGALSKAF.cjs} +50 -20
  19. package/dist/chunk-BGALSKAF.cjs.map +1 -0
  20. package/dist/{chunk-KIIFL4VM.js → chunk-F2R473FR.js} +41 -11
  21. package/dist/chunk-F2R473FR.js.map +1 -0
  22. package/dist/{chunk-TIEAZYHF.cjs → chunk-K7JSQPZO.cjs} +8 -2
  23. package/dist/chunk-K7JSQPZO.cjs.map +1 -0
  24. package/dist/{chunk-FCXSP2YF.js → chunk-KJYNF5KH.js} +8 -3
  25. package/dist/chunk-KJYNF5KH.js.map +1 -0
  26. package/dist/{chunk-ET3P6TX6.cjs → chunk-RCMKPJZO.cjs} +4 -4
  27. package/dist/{chunk-ET3P6TX6.cjs.map → chunk-RCMKPJZO.cjs.map} +1 -1
  28. package/dist/combo/react.cjs +1 -0
  29. package/dist/combo/react.guard.js +15 -0
  30. package/dist/combo.cjs +4 -3
  31. package/dist/combo.guard.js +15 -0
  32. package/dist/combo.js +2 -2
  33. package/dist/index.cjs +26 -22
  34. package/dist/index.d.cts +2 -2
  35. package/dist/index.d.ts +2 -2
  36. package/dist/index.js +4 -4
  37. package/dist/paymaster.cjs +2 -2
  38. package/dist/paymaster.js +1 -1
  39. package/dist/privy/react.cjs +1 -0
  40. package/dist/privy/react.guard.js +15 -0
  41. package/dist/privy/server.cjs +1 -0
  42. package/dist/privy/server.guard.js +15 -0
  43. package/dist/privy/wagmi.guard.js +15 -0
  44. package/dist/react.cjs +4 -3
  45. package/dist/react.d.cts +1 -1
  46. package/dist/react.d.ts +1 -1
  47. package/dist/react.guard.js +15 -0
  48. package/dist/react.js +2 -2
  49. package/dist/session/kernel.cjs +1 -0
  50. package/dist/session/kernel.guard.js +15 -0
  51. package/dist/session/react.cjs +1 -0
  52. package/dist/session/react.guard.js +15 -0
  53. package/dist/session/server.cjs +1 -0
  54. package/dist/session/server.guard.js +15 -0
  55. package/dist/{status-DwkkOrGQ.d.ts → status-Dx9zAFo9.d.ts} +42 -10
  56. package/dist/{status-CmOsyPmO.d.cts → status-wgTM26V7.d.cts} +42 -10
  57. package/package.json +38 -2
  58. package/dist/chunk-FCXSP2YF.js.map +0 -1
  59. package/dist/chunk-KIIFL4VM.js.map +0 -1
  60. package/dist/chunk-SLW7FRTL.cjs.map +0 -1
  61. package/dist/chunk-TIEAZYHF.cjs.map +0 -1
package/README.md CHANGED
@@ -31,6 +31,31 @@ dependency, needed only if you import from `@pepu-chain/sdk/react` (see below);
31
31
  the main `@pepu-chain/sdk` entry point never touches React and works in a plain
32
32
  Node script.
33
33
 
34
+ ### Install: peers per subpath
35
+
36
+ Every subpath also needs `viem`. The entries below need extra peers, and **the recommended path is the CLI: `create-pepu-app` scaffolds an app with every peer already in its `package.json`**, so you never run these by hand. If you install by hand and a peer is missing, importing the subpath throws `PEPU_MISSING_PEER` naming the subpath and the exact command (under Node; bundlers report their own "module not found"). Subpaths not listed here (`.`, `/privy`, `/session`, `/aa`, `/paymaster`, `/paymaster/server`, `/server`, `/doctor`) need only `viem`.
37
+
38
+ | Subpath | Required peers | Install |
39
+ |---|---|---|
40
+ | `@pepu-chain/sdk/react` | `react` | `npm i react` |
41
+ | `@pepu-chain/sdk/privy/react` | `react`, `@privy-io/react-auth` | `npm i react @privy-io/react-auth` |
42
+ | `@pepu-chain/sdk/privy/wagmi` | `react`, `@privy-io/react-auth`, `@privy-io/wagmi`, `wagmi`, `@tanstack/react-query` | `npm i react @privy-io/react-auth @privy-io/wagmi wagmi @tanstack/react-query` |
43
+ | `@pepu-chain/sdk/privy/server` | `@privy-io/node` | `npm i @privy-io/node` |
44
+ | `@pepu-chain/sdk/session/server` | `@privy-io/node` | `npm i @privy-io/node` |
45
+ | `@pepu-chain/sdk/session/react` | `react`, `@privy-io/react-auth` | `npm i react @privy-io/react-auth` |
46
+ | `@pepu-chain/sdk/session/kernel` | `@zerodev/sdk`, `@zerodev/permissions`, `@zerodev/ecdsa-validator` | `npm i @zerodev/sdk @zerodev/permissions @zerodev/ecdsa-validator` |
47
+ | `@pepu-chain/sdk/aa/kernel` | `@zerodev/sdk`, `@zerodev/ecdsa-validator` | `npm i @zerodev/sdk @zerodev/ecdsa-validator` |
48
+ | `@pepu-chain/sdk/aa/react` | `react`, `@privy-io/react-auth`, `permissionless` | `npm i react @privy-io/react-auth permissionless` |
49
+ | `@pepu-chain/sdk/aa/react-direct` | `react`, `@privy-io/react-auth`, `@zerodev/sdk`, `@zerodev/ecdsa-validator` | `npm i react @privy-io/react-auth @zerodev/sdk @zerodev/ecdsa-validator` |
50
+ | `@pepu-chain/sdk/combo` | `@privy-io/node`, `@zerodev/sdk`, `@zerodev/permissions`, `@zerodev/ecdsa-validator` | `npm i @privy-io/node @zerodev/sdk @zerodev/permissions @zerodev/ecdsa-validator` |
51
+ | `@pepu-chain/sdk/combo/react` | `react`, `@privy-io/react-auth`, `@zerodev/sdk`, `@zerodev/permissions`, `@zerodev/ecdsa-validator` | `npm i react @privy-io/react-auth @zerodev/sdk @zerodev/permissions @zerodev/ecdsa-validator` |
52
+
53
+ **Bundle** for the common pillars (Google login + session keys + sponsored gas), client and server together:
54
+
55
+ ```sh
56
+ npm i viem react @privy-io/react-auth @privy-io/node @zerodev/sdk @zerodev/permissions @zerodev/ecdsa-validator permissionless
57
+ ```
58
+
34
59
  ## Quickstart
35
60
 
36
61
  ```ts
@@ -1,4 +1,5 @@
1
1
  'use strict';
2
+ /* @pepu-chain/peer-guard */(function(){var p=["@zerodev/sdk","@zerodev/ecdsa-validator"];for(var i=0;i<p.length;i++){try{require.resolve(p[i])}catch(e){if(e&&e.code==="MODULE_NOT_FOUND"){var m="@pepu-chain/sdk/aa/kernel needs peer packages that are not installed: @zerodev/sdk @zerodev/ecdsa-validator. Install with: npm i @zerodev/sdk @zerodev/ecdsa-validator (or let create-pepu-app scaffold everything).";var x=new Error(m);x.code="PEPU_MISSING_PEER";throw x}}}})();
2
3
 
3
4
  var chunkNVOPDXTA_cjs = require('../chunk-NVOPDXTA.cjs');
4
5
  require('../chunk-7MNJF2OB.cjs');
@@ -0,0 +1,15 @@
1
+ // Generated by scripts/guard-peers.mjs. Used only under the "node" export condition.
2
+ const peers = ["@zerodev/sdk","@zerodev/ecdsa-validator"];
3
+ for (const peer of peers) {
4
+ try {
5
+ import.meta.resolve?.(peer);
6
+ } catch (e) {
7
+ if (e && e.code === "ERR_MODULE_NOT_FOUND") {
8
+ const err = new Error("@pepu-chain/sdk/aa/kernel needs peer packages that are not installed: @zerodev/sdk @zerodev/ecdsa-validator. Install with: npm i @zerodev/sdk @zerodev/ecdsa-validator (or let create-pepu-app scaffold everything).");
9
+ err.code = "PEPU_MISSING_PEER";
10
+ throw err;
11
+ }
12
+ }
13
+ }
14
+ const mod = await import("./kernel.js");
15
+ export const { KERNEL_VERSION, createPepuSponsoredClient, getKernelAddress, sendSponsored, toPepuKernelAccount, encodeKernelExecute } = mod;
@@ -1,12 +1,13 @@
1
1
  'use strict';
2
+ /* @pepu-chain/peer-guard */(function(){var p=["react","@privy-io/react-auth","@zerodev/sdk","@zerodev/ecdsa-validator"];for(var i=0;i<p.length;i++){try{require.resolve(p[i])}catch(e){if(e&&e.code==="MODULE_NOT_FOUND"){var m="@pepu-chain/sdk/aa/react-direct needs peer packages that are not installed: react @privy-io/react-auth @zerodev/sdk @zerodev/ecdsa-validator. Install with: npm i react @privy-io/react-auth @zerodev/sdk @zerodev/ecdsa-validator (or let create-pepu-app scaffold everything).";var x=new Error(m);x.code="PEPU_MISSING_PEER";throw x}}}})();
2
3
 
3
4
  var chunkNVOPDXTA_cjs = require('../chunk-NVOPDXTA.cjs');
4
5
  require('../chunk-7MNJF2OB.cjs');
5
6
  require('../chunk-AJS4UFQX.cjs');
6
7
  require('../chunk-A5LP2UCS.cjs');
7
- var chunkET3P6TX6_cjs = require('../chunk-ET3P6TX6.cjs');
8
+ var chunkRCMKPJZO_cjs = require('../chunk-RCMKPJZO.cjs');
8
9
  var chunkWANILJZQ_cjs = require('../chunk-WANILJZQ.cjs');
9
- require('../chunk-TIEAZYHF.cjs');
10
+ require('../chunk-K7JSQPZO.cjs');
10
11
  var chunkC7IC36XS_cjs = require('../chunk-C7IC36XS.cjs');
11
12
  require('../chunk-4GINFJO6.cjs');
12
13
  require('../chunk-VF3D6KLQ.cjs');
@@ -83,7 +84,7 @@ function useDirectSponsoredSend(o = {}) {
83
84
  publicClient: pc,
84
85
  ...o.bundlerUrl !== void 0 ? { bundlerUrl: o.bundlerUrl } : {},
85
86
  ...o.paymasterUrl !== void 0 ? { paymasterUrl: o.paymasterUrl } : {},
86
- ...token ? { paymasterContext: chunkET3P6TX6_cjs.buildPaymasterContext({ privyAccessToken: token }) } : {}
87
+ ...token ? { paymasterContext: chunkRCMKPJZO_cjs.buildPaymasterContext({ privyAccessToken: token }) } : {}
87
88
  });
88
89
  setStatus("submitting");
89
90
  const out = await chunkNVOPDXTA_cjs.sendSponsored({ client: kernel, calls });
@@ -0,0 +1,15 @@
1
+ // Generated by scripts/guard-peers.mjs. Used only under the "node" export condition.
2
+ const peers = ["react","@privy-io/react-auth","@zerodev/sdk","@zerodev/ecdsa-validator"];
3
+ for (const peer of peers) {
4
+ try {
5
+ import.meta.resolve?.(peer);
6
+ } catch (e) {
7
+ if (e && e.code === "ERR_MODULE_NOT_FOUND") {
8
+ const err = new Error("@pepu-chain/sdk/aa/react-direct needs peer packages that are not installed: react @privy-io/react-auth @zerodev/sdk @zerodev/ecdsa-validator. Install with: npm i react @privy-io/react-auth @zerodev/sdk @zerodev/ecdsa-validator (or let create-pepu-app scaffold everything).");
9
+ err.code = "PEPU_MISSING_PEER";
10
+ throw err;
11
+ }
12
+ }
13
+ }
14
+ const mod = await import("./react-direct.js");
15
+ export const { useDirectSmartAccount, useDirectSponsoredSend } = mod;
@@ -2,9 +2,9 @@ import { getKernelAddress, toPepuKernelAccount, createPepuSponsoredClient, sendS
2
2
  import '../chunk-IB2FSPMJ.js';
3
3
  import '../chunk-VBH3JLQ5.js';
4
4
  import '../chunk-IY3ALPUJ.js';
5
- import { buildPaymasterContext } from '../chunk-MBA4CLA5.js';
5
+ import { buildPaymasterContext } from '../chunk-7PVR7QSE.js';
6
6
  import { describeUserOpFailure } from '../chunk-D52PADVY.js';
7
- import '../chunk-FCXSP2YF.js';
7
+ import '../chunk-KJYNF5KH.js';
8
8
  import { getPublicClient } from '../chunk-OH3QMAIB.js';
9
9
  import '../chunk-J6UXXHBE.js';
10
10
  import '../chunk-XC4IBCI2.js';
package/dist/aa/react.cjs CHANGED
@@ -1,9 +1,10 @@
1
1
  'use strict';
2
+ /* @pepu-chain/peer-guard */(function(){var p=["react","@privy-io/react-auth","permissionless"];for(var i=0;i<p.length;i++){try{require.resolve(p[i])}catch(e){if(e&&e.code==="MODULE_NOT_FOUND"){var m="@pepu-chain/sdk/aa/react needs peer packages that are not installed: react @privy-io/react-auth permissionless. Install with: npm i react @privy-io/react-auth permissionless (or let create-pepu-app scaffold everything).";var x=new Error(m);x.code="PEPU_MISSING_PEER";throw x}}}})();
2
3
 
3
4
  var chunkAJS4UFQX_cjs = require('../chunk-AJS4UFQX.cjs');
4
- var chunkSLW7FRTL_cjs = require('../chunk-SLW7FRTL.cjs');
5
+ var chunkBGALSKAF_cjs = require('../chunk-BGALSKAF.cjs');
5
6
  var chunkWANILJZQ_cjs = require('../chunk-WANILJZQ.cjs');
6
- require('../chunk-TIEAZYHF.cjs');
7
+ require('../chunk-K7JSQPZO.cjs');
7
8
  var chunkC7IC36XS_cjs = require('../chunk-C7IC36XS.cjs');
8
9
  var chunk4GINFJO6_cjs = require('../chunk-4GINFJO6.cjs');
9
10
  require('../chunk-VF3D6KLQ.cjs');
@@ -120,7 +121,7 @@ function usePepuSponsorship(o = {}) {
120
121
  let cancelled = false;
121
122
  const run = async () => {
122
123
  try {
123
- const r = await chunkSLW7FRTL_cjs.checkSponsorship({
124
+ const r = await chunkBGALSKAF_cjs.checkSponsorship({
124
125
  publicClient: publicClient(),
125
126
  ...bundlerUrl !== void 0 ? { bundlerUrl } : {},
126
127
  ...paymasterUrl !== void 0 ? { paymasterUrl } : {}
@@ -1,6 +1,6 @@
1
1
  import { Address } from 'viem';
2
2
  import { P as PepuError } from '../errors-CgX1vNj7.cjs';
3
- import { S as SponsorshipReport } from '../status-CmOsyPmO.cjs';
3
+ import { S as SponsorshipReport } from '../status-wgTM26V7.cjs';
4
4
  import { C as Call, S as SponsoredResult } from '../types-BilBTDqK.cjs';
5
5
  import '../chains-DK13zGIp.cjs';
6
6
 
@@ -1,6 +1,6 @@
1
1
  import { Address } from 'viem';
2
2
  import { P as PepuError } from '../errors-CgX1vNj7.js';
3
- import { S as SponsorshipReport } from '../status-DwkkOrGQ.js';
3
+ import { S as SponsorshipReport } from '../status-Dx9zAFo9.js';
4
4
  import { C as Call, S as SponsoredResult } from '../types-BilBTDqK.js';
5
5
  import '../chains-DK13zGIp.js';
6
6
 
@@ -0,0 +1,15 @@
1
+ // Generated by scripts/guard-peers.mjs. Used only under the "node" export condition.
2
+ const peers = ["react","@privy-io/react-auth","permissionless"];
3
+ for (const peer of peers) {
4
+ try {
5
+ import.meta.resolve?.(peer);
6
+ } catch (e) {
7
+ if (e && e.code === "ERR_MODULE_NOT_FOUND") {
8
+ const err = new Error("@pepu-chain/sdk/aa/react needs peer packages that are not installed: react @privy-io/react-auth permissionless. Install with: npm i react @privy-io/react-auth permissionless (or let create-pepu-app scaffold everything).");
9
+ err.code = "PEPU_MISSING_PEER";
10
+ throw err;
11
+ }
12
+ }
13
+ }
14
+ const mod = await import("./react.js");
15
+ export const { usePepuSmartAccount, usePepuSponsorship, useSponsoredSend } = mod;
package/dist/aa/react.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { normalizeCalls, userOpEventFromReceipt } from '../chunk-VBH3JLQ5.js';
2
- import { checkSponsorship } from '../chunk-KIIFL4VM.js';
2
+ import { checkSponsorship } from '../chunk-F2R473FR.js';
3
3
  import { describeUserOpFailure } from '../chunk-D52PADVY.js';
4
- import '../chunk-FCXSP2YF.js';
4
+ import '../chunk-KJYNF5KH.js';
5
5
  import { getPublicClient } from '../chunk-OH3QMAIB.js';
6
6
  import { txUrl } from '../chunk-J6UXXHBE.js';
7
7
  import '../chunk-XC4IBCI2.js';
package/dist/aa.cjs CHANGED
@@ -3,9 +3,9 @@
3
3
  var chunk7MNJF2OB_cjs = require('./chunk-7MNJF2OB.cjs');
4
4
  var chunkAJS4UFQX_cjs = require('./chunk-AJS4UFQX.cjs');
5
5
  require('./chunk-A5LP2UCS.cjs');
6
- var chunkSLW7FRTL_cjs = require('./chunk-SLW7FRTL.cjs');
6
+ var chunkBGALSKAF_cjs = require('./chunk-BGALSKAF.cjs');
7
7
  var chunkWANILJZQ_cjs = require('./chunk-WANILJZQ.cjs');
8
- require('./chunk-TIEAZYHF.cjs');
8
+ require('./chunk-K7JSQPZO.cjs');
9
9
  require('./chunk-VF3D6KLQ.cjs');
10
10
  require('./chunk-DPCZJLB3.cjs');
11
11
  require('./chunk-YQL7NISX.cjs');
@@ -46,31 +46,31 @@ Object.defineProperty(exports, "userOpEventsFromReceipt", {
46
46
  });
47
47
  Object.defineProperty(exports, "checkSponsorship", {
48
48
  enumerable: true,
49
- get: function () { return chunkSLW7FRTL_cjs.checkSponsorship; }
49
+ get: function () { return chunkBGALSKAF_cjs.checkSponsorship; }
50
50
  });
51
51
  Object.defineProperty(exports, "getKernelAccountAddress", {
52
52
  enumerable: true,
53
- get: function () { return chunkSLW7FRTL_cjs.getKernelAccountAddress; }
53
+ get: function () { return chunkBGALSKAF_cjs.getKernelAccountAddress; }
54
54
  });
55
55
  Object.defineProperty(exports, "getPaymasterDeposit", {
56
56
  enumerable: true,
57
- get: function () { return chunkSLW7FRTL_cjs.getPaymasterDeposit; }
57
+ get: function () { return chunkBGALSKAF_cjs.getPaymasterDeposit; }
58
58
  });
59
59
  Object.defineProperty(exports, "getPepuKernelStack", {
60
60
  enumerable: true,
61
- get: function () { return chunkSLW7FRTL_cjs.getPepuKernelStack; }
61
+ get: function () { return chunkBGALSKAF_cjs.getPepuKernelStack; }
62
62
  });
63
63
  Object.defineProperty(exports, "getSponsorshipStatus", {
64
64
  enumerable: true,
65
- get: function () { return chunkSLW7FRTL_cjs.getSponsorshipStatus; }
65
+ get: function () { return chunkBGALSKAF_cjs.getSponsorshipStatus; }
66
66
  });
67
67
  Object.defineProperty(exports, "probeBundler", {
68
68
  enumerable: true,
69
- get: function () { return chunkSLW7FRTL_cjs.probeBundler; }
69
+ get: function () { return chunkBGALSKAF_cjs.probeBundler; }
70
70
  });
71
71
  Object.defineProperty(exports, "probePaymaster", {
72
72
  enumerable: true,
73
- get: function () { return chunkSLW7FRTL_cjs.probePaymaster; }
73
+ get: function () { return chunkBGALSKAF_cjs.probePaymaster; }
74
74
  });
75
75
  Object.defineProperty(exports, "describeUserOpFailure", {
76
76
  enumerable: true,
package/dist/aa.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { PublicClient } from 'viem';
2
2
  import { SmartAccount, PaymasterClient, BundlerClient } from 'viem/account-abstraction';
3
3
  import { P as PaymasterContext } from './erc7677-DOW58QBE.cjs';
4
- export { B as BundlerProbeResult, C as CheckSponsorshipOptions, F as FetchLike, G as GetSponsorshipStatusOptions, P as PaymasterProbeResult, a as PepuKernelStack, b as ProbeOptions, S as SponsorshipReport, c as SponsorshipStatus, d as checkSponsorship, g as getKernelAccountAddress, e as getPaymasterDeposit, f as getPepuKernelStack, h as getSponsorshipStatus, p as probeBundler, i as probePaymaster } from './status-CmOsyPmO.cjs';
4
+ export { B as BundlerProbeResult, C as CheckSponsorshipOptions, F as FetchLike, G as GetSponsorshipStatusOptions, P as PaymasterProbeResult, a as PepuKernelStack, b as ProbeOptions, S as SponsorshipReport, c as SponsorshipStatus, d as checkSponsorship, g as getKernelAccountAddress, e as getPaymasterDeposit, f as getPepuKernelStack, h as getSponsorshipStatus, p as probeBundler, i as probePaymaster } from './status-wgTM26V7.cjs';
5
5
  import { a as PepuBundlerError, b as PepuPaymasterError } from './errors-CgX1vNj7.cjs';
6
6
  export { E as EncodedCall, U as UserOpEvent, e as encodeKernelExecute, n as normalizeCalls, u as userOpEventFromReceipt, a as userOpEventsFromReceipt } from './calls-BRPjKgjl.cjs';
7
7
  export { C as Call, S as SponsoredResult } from './types-BilBTDqK.cjs';
package/dist/aa.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { PublicClient } from 'viem';
2
2
  import { SmartAccount, PaymasterClient, BundlerClient } from 'viem/account-abstraction';
3
3
  import { P as PaymasterContext } from './erc7677-DOW58QBE.js';
4
- export { B as BundlerProbeResult, C as CheckSponsorshipOptions, F as FetchLike, G as GetSponsorshipStatusOptions, P as PaymasterProbeResult, a as PepuKernelStack, b as ProbeOptions, S as SponsorshipReport, c as SponsorshipStatus, d as checkSponsorship, g as getKernelAccountAddress, e as getPaymasterDeposit, f as getPepuKernelStack, h as getSponsorshipStatus, p as probeBundler, i as probePaymaster } from './status-DwkkOrGQ.js';
4
+ export { B as BundlerProbeResult, C as CheckSponsorshipOptions, F as FetchLike, G as GetSponsorshipStatusOptions, P as PaymasterProbeResult, a as PepuKernelStack, b as ProbeOptions, S as SponsorshipReport, c as SponsorshipStatus, d as checkSponsorship, g as getKernelAccountAddress, e as getPaymasterDeposit, f as getPepuKernelStack, h as getSponsorshipStatus, p as probeBundler, i as probePaymaster } from './status-Dx9zAFo9.js';
5
5
  import { a as PepuBundlerError, b as PepuPaymasterError } from './errors-CgX1vNj7.js';
6
6
  export { E as EncodedCall, U as UserOpEvent, e as encodeKernelExecute, n as normalizeCalls, u as userOpEventFromReceipt, a as userOpEventsFromReceipt } from './calls-z_EQOtFb.js';
7
7
  export { C as Call, S as SponsoredResult } from './types-BilBTDqK.js';
package/dist/aa.js CHANGED
@@ -1,9 +1,9 @@
1
1
  export { ENTRY_POINT_V07, createPepuBundlerClient, createPepuPaymasterClient, estimatePepuUserOpFees } from './chunk-IB2FSPMJ.js';
2
2
  export { encodeKernelExecute, normalizeCalls, userOpEventFromReceipt, userOpEventsFromReceipt } from './chunk-VBH3JLQ5.js';
3
3
  import './chunk-IY3ALPUJ.js';
4
- export { checkSponsorship, getKernelAccountAddress, getPaymasterDeposit, getPepuKernelStack, getSponsorshipStatus, probeBundler, probePaymaster } from './chunk-KIIFL4VM.js';
4
+ export { checkSponsorship, getKernelAccountAddress, getPaymasterDeposit, getPepuKernelStack, getSponsorshipStatus, probeBundler, probePaymaster } from './chunk-F2R473FR.js';
5
5
  export { describeUserOpFailure, redactSecrets } from './chunk-D52PADVY.js';
6
- import './chunk-FCXSP2YF.js';
6
+ import './chunk-KJYNF5KH.js';
7
7
  import './chunk-XC4IBCI2.js';
8
8
  import './chunk-VTQIHMF3.js';
9
9
  import './chunk-6DSZ4Z2N.js';
@@ -1,4 +1,4 @@
1
- import { getContract } from './chunk-FCXSP2YF.js';
1
+ import { getContract } from './chunk-KJYNF5KH.js';
2
2
  import { pepuMainnet } from './chunk-VTQIHMF3.js';
3
3
  import { toHex } from 'viem';
4
4
 
@@ -41,5 +41,5 @@ function buildPaymasterDataRequest(options) {
41
41
  }
42
42
 
43
43
  export { buildPaymasterContext, buildPaymasterDataRequest, buildPaymasterStubDataRequest };
44
- //# sourceMappingURL=chunk-MBA4CLA5.js.map
45
- //# sourceMappingURL=chunk-MBA4CLA5.js.map
44
+ //# sourceMappingURL=chunk-7PVR7QSE.js.map
45
+ //# sourceMappingURL=chunk-7PVR7QSE.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/erc7677.ts"],"names":[],"mappings":";;;;AAkGO,SAAS,qBAAA,CACd,OAAA,GAA6C,EAAC,EAC5B;AAClB,EAAA,MAAM,UAA4B,EAAC;AACnC,EAAA,KAAA,MAAW,CAAC,GAAA,EAAK,KAAK,KAAK,MAAA,CAAO,OAAA,CAAQ,OAAO,CAAA,EAAG;AAClD,IAAA,IAAI,UAAU,MAAA,EAAW;AACzB,IAAA,MAAM,OAAO,OAAO,KAAA;AACpB,IAAA,IAAI,IAAA,KAAS,QAAA,IAAY,IAAA,KAAS,UAAA,IAAc,SAAS,QAAA,EAAU;AACjE,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,CAAA,wBAAA,EAA2B,GAAG,CAAA,OAAA,EAAU,IAAI,CAAA,yEAAA;AAAA,OAC9C;AAAA,IACF;AACA,IAAA,OAAA,CAAQ,GAAG,CAAA,GAAI,KAAA;AAAA,EACjB;AACA,EAAA,OAAO,OAAA;AACT;AAYA,SAAS,YAAY,OAAA,EAA2D;AAC9E,EAAA,MAAM,eAAA,GAAkB,WAAA,CAAY,WAAA,CAAY,EAAA,EAAI,cAAc,CAAA;AAClE,EAAA,MAAM,aACJ,OAAA,CAAQ,UAAA,KACP,iBAAiB,MAAA,KAAW,UAAA,GAAa,gBAAgB,OAAA,GAAU,MAAA,CAAA;AACtE,EAAA,IAAI,CAAC,UAAA,EAAY,MAAM,IAAI,MAAM,8DAA8D,CAAA;AAC/F,EAAA,MAAM,OAAA,GAAU,KAAA,CAAM,OAAA,CAAQ,OAAA,IAAW,YAAY,EAAE,CAAA;AACvD,EAAA,OAAO,OAAA,CAAQ,OAAA,GACX,CAAC,OAAA,CAAQ,eAAe,UAAA,EAAY,OAAA,EAAS,OAAA,CAAQ,OAAO,CAAA,GAC5D,CAAC,OAAA,CAAQ,aAAA,EAAe,YAAY,OAAO,CAAA;AACjD;AAGO,SAAS,8BACd,OAAA,EAC0B;AAC1B,EAAA,OAAO;AAAA,IACL,OAAA,EAAS,KAAA;AAAA,IACT,EAAA,EAAI,QAAQ,EAAA,IAAM,CAAA;AAAA,IAClB,MAAA,EAAQ,yBAAA;AAAA,IACR,MAAA,EAAQ,YAAY,OAAO;AAAA,GAC7B;AACF;AAGO,SAAS,0BACd,OAAA,EACsB;AACtB,EAAA,OAAO;AAAA,IACL,OAAA,EAAS,KAAA;AAAA,IACT,EAAA,EAAI,QAAQ,EAAA,IAAM,CAAA;AAAA,IAClB,MAAA,EAAQ,qBAAA;AAAA,IACR,MAAA,EAAQ,YAAY,OAAO;AAAA,GAC7B;AACF","file":"chunk-MBA4CLA5.js","sourcesContent":["import { toHex } from \"viem\";\nimport type { Address, Hex } from \"viem\";\n\nimport { pepuMainnet } from \"./chains.js\";\nimport { getContract } from \"./contracts.js\";\n\n/**\n * ERC-7677 paymaster web-service types, for the two JSON-RPC methods PEPU's\n * paymaster policy service implements: `pm_getPaymasterStubData` and\n * `pm_getPaymasterData`. See https://eips.ethereum.org/EIPS/eip-7677.\n *\n * Pure types plus a few tiny builders: no network, no secrets, safe in a\n * browser bundle. Quantities are `0x`-prefixed hex strings, as on the wire.\n *\n * Note this package never implies sponsorship is available to an app: see\n * `getSponsorshipStatus()`. These types describe the protocol only.\n */\n\n/** An ERC-4337 v0.7 UserOperation in its unpacked JSON-RPC shape. */\nexport interface Erc7677UserOperation {\n sender: Address;\n nonce: Hex;\n factory?: Address;\n factoryData?: Hex;\n callData: Hex;\n callGasLimit: Hex;\n verificationGasLimit: Hex;\n preVerificationGas: Hex;\n maxFeePerGas: Hex;\n maxPriorityFeePerGas: Hex;\n paymaster?: Address;\n paymasterVerificationGasLimit?: Hex;\n paymasterPostOpGasLimit?: Hex;\n paymasterData?: Hex;\n signature: Hex;\n}\n\n/** Paymaster-defined, JSON-serializable context (params[3]). */\nexport type PaymasterContext = Record<string, unknown>;\n\nexport type PaymasterRpcParams = readonly [\n userOperation: Partial<Erc7677UserOperation> & Pick<Erc7677UserOperation, \"sender\" | \"callData\">,\n entryPoint: Address,\n chainId: Hex,\n context?: PaymasterContext,\n];\n\nexport interface PaymasterStubDataRequest {\n jsonrpc: \"2.0\";\n id: number | string;\n method: \"pm_getPaymasterStubData\";\n params: PaymasterRpcParams;\n}\n\nexport interface PaymasterDataRequest {\n jsonrpc: \"2.0\";\n id: number | string;\n method: \"pm_getPaymasterData\";\n params: PaymasterRpcParams;\n}\n\n/** Result of `pm_getPaymasterStubData`. Stub values are for gas estimation only. */\nexport interface PaymasterStubDataResult {\n paymaster: Address;\n paymasterData: Hex;\n paymasterVerificationGasLimit?: Hex;\n paymasterPostOpGasLimit?: Hex;\n /** `true` when the stub values are also the final values. */\n isFinal?: boolean;\n sponsor?: { name: string; icon?: string };\n}\n\n/** Result of `pm_getPaymasterData`: the signed values to submit. */\nexport interface PaymasterDataResult {\n paymaster: Address;\n paymasterData: Hex;\n paymasterVerificationGasLimit?: Hex;\n paymasterPostOpGasLimit?: Hex;\n}\n\nexport interface PaymasterRpcError {\n code: number;\n message: string;\n /** PEPU's policy service puts the machine-readable denial reason in `data.reason`. */\n data?: { reason?: string } & Record<string, unknown>;\n}\n\nexport type PaymasterRpcResponse<TResult> =\n | { jsonrpc: \"2.0\"; id: number | string | null; result: TResult }\n | { jsonrpc: \"2.0\"; id: number | string | null; error: PaymasterRpcError };\n\n/**\n * Build a paymaster `context` object: drops `undefined` entries and throws on\n * anything that would not survive `JSON.stringify` (bigint, function, symbol),\n * so a bad value fails here instead of as an opaque RPC error. Returns `{}`\n * for no input. The context is paymaster-defined; PEPU's policy service\n * currently accepts and ignores it.\n */\nexport function buildPaymasterContext(\n entries: Readonly<Record<string, unknown>> = {},\n): PaymasterContext {\n const context: PaymasterContext = {};\n for (const [key, value] of Object.entries(entries)) {\n if (value === undefined) continue;\n const kind = typeof value;\n if (kind === \"bigint\" || kind === \"function\" || kind === \"symbol\") {\n throw new Error(\n `buildPaymasterContext: \"${key}\" is a ${kind}, which is not JSON-serializable. Convert it to a string or number first.`,\n );\n }\n context[key] = value;\n }\n return context;\n}\n\nexport interface BuildPaymasterRequestOptions {\n userOperation: PaymasterRpcParams[0];\n /** Defaults to PEPU mainnet's EntryPoint v0.7. */\n entryPoint?: Address;\n /** Defaults to 97741 (PEPU mainnet). */\n chainId?: number;\n context?: PaymasterContext;\n id?: number | string;\n}\n\nfunction buildParams(options: BuildPaymasterRequestOptions): PaymasterRpcParams {\n const entryPointEntry = getContract(pepuMainnet.id, \"entryPoint07\");\n const entryPoint =\n options.entryPoint ??\n (entryPointEntry?.status === \"deployed\" ? entryPointEntry.address : undefined);\n if (!entryPoint) throw new Error(\"buildPaymasterRequest: no EntryPoint v0.7 address available.\");\n const chainId = toHex(options.chainId ?? pepuMainnet.id);\n return options.context\n ? [options.userOperation, entryPoint, chainId, options.context]\n : [options.userOperation, entryPoint, chainId];\n}\n\n/** Build a `pm_getPaymasterStubData` JSON-RPC request body. */\nexport function buildPaymasterStubDataRequest(\n options: BuildPaymasterRequestOptions,\n): PaymasterStubDataRequest {\n return {\n jsonrpc: \"2.0\",\n id: options.id ?? 1,\n method: \"pm_getPaymasterStubData\",\n params: buildParams(options),\n };\n}\n\n/** Build a `pm_getPaymasterData` JSON-RPC request body. */\nexport function buildPaymasterDataRequest(\n options: BuildPaymasterRequestOptions,\n): PaymasterDataRequest {\n return {\n jsonrpc: \"2.0\",\n id: options.id ?? 1,\n method: \"pm_getPaymasterData\",\n params: buildParams(options),\n };\n}\n"]}
1
+ {"version":3,"sources":["../src/erc7677.ts"],"names":[],"mappings":";;;;AAkGO,SAAS,qBAAA,CACd,OAAA,GAA6C,EAAC,EAC5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R,MAAA,EAAQ,YAAY,OAAO;AAAA,GAC7B;AACF;AAGO,SAAS,0BACd,OAAA,EACsB;AACtB,EAAA,OAAO;AAAA,IACL,OAAA,EAAS,KAAA;AAAA,IACT,EAAA,EAAI,QAAQ,EAAA,IAAM,CAAA;AAAA,IAClB,MAAA,EAAQ,qBAAA;AAAA,IACR,MAAA,EAAQ,YAAY,OAAO;AAAA,GAC7B;AACF","file":"chunk-7PVR7QSE.js","sourcesContent":["import { toHex } from \"viem\";\nimport type { Address, Hex } from \"viem\";\n\nimport { pepuMainnet } from \"./chains.js\";\nimport { getContract } from \"./contracts.js\";\n\n/**\n * ERC-7677 paymaster web-service types, for the two JSON-RPC methods PEPU's\n * paymaster policy service implements: `pm_getPaymasterStubData` and\n * `pm_getPaymasterData`. See https://eips.ethereum.org/EIPS/eip-7677.\n *\n * Pure types plus a few tiny builders: no network, no secrets, safe in a\n * browser bundle. Quantities are `0x`-prefixed hex strings, as on the wire.\n *\n * Note this package never implies sponsorship is available to an app: see\n * `getSponsorshipStatus()`. These types describe the protocol only.\n */\n\n/** An ERC-4337 v0.7 UserOperation in its unpacked JSON-RPC shape. */\nexport interface Erc7677UserOperation {\n sender: Address;\n nonce: Hex;\n factory?: Address;\n factoryData?: Hex;\n callData: Hex;\n callGasLimit: Hex;\n verificationGasLimit: Hex;\n preVerificationGas: Hex;\n maxFeePerGas: Hex;\n maxPriorityFeePerGas: Hex;\n paymaster?: Address;\n paymasterVerificationGasLimit?: Hex;\n paymasterPostOpGasLimit?: Hex;\n paymasterData?: Hex;\n signature: Hex;\n}\n\n/** Paymaster-defined, JSON-serializable context (params[3]). */\nexport type PaymasterContext = Record<string, unknown>;\n\nexport type PaymasterRpcParams = readonly [\n userOperation: Partial<Erc7677UserOperation> & Pick<Erc7677UserOperation, \"sender\" | \"callData\">,\n entryPoint: Address,\n chainId: Hex,\n context?: PaymasterContext,\n];\n\nexport interface PaymasterStubDataRequest {\n jsonrpc: \"2.0\";\n id: number | string;\n method: \"pm_getPaymasterStubData\";\n params: PaymasterRpcParams;\n}\n\nexport interface PaymasterDataRequest {\n jsonrpc: \"2.0\";\n id: number | string;\n method: \"pm_getPaymasterData\";\n params: PaymasterRpcParams;\n}\n\n/** Result of `pm_getPaymasterStubData`. Stub values are for gas estimation only. */\nexport interface PaymasterStubDataResult {\n paymaster: Address;\n paymasterData: Hex;\n paymasterVerificationGasLimit?: Hex;\n paymasterPostOpGasLimit?: Hex;\n /** `true` when the stub values are also the final values. */\n isFinal?: boolean;\n sponsor?: { name: string; icon?: string };\n}\n\n/** Result of `pm_getPaymasterData`: the signed values to submit. */\nexport interface PaymasterDataResult {\n paymaster: Address;\n paymasterData: Hex;\n paymasterVerificationGasLimit?: Hex;\n paymasterPostOpGasLimit?: Hex;\n}\n\nexport interface PaymasterRpcError {\n code: number;\n message: string;\n /** PEPU's policy service puts the machine-readable denial reason in `data.reason`. */\n data?: { reason?: string } & Record<string, unknown>;\n}\n\nexport type PaymasterRpcResponse<TResult> =\n | { jsonrpc: \"2.0\"; id: number | string | null; result: TResult }\n | { jsonrpc: \"2.0\"; id: number | string | null; error: PaymasterRpcError };\n\n/**\n * Build a paymaster `context` object: drops `undefined` entries and throws on\n * anything that would not survive `JSON.stringify` (bigint, function, symbol),\n * so a bad value fails here instead of as an opaque RPC error. Returns `{}`\n * for no input. The context is paymaster-defined; PEPU's policy service\n * currently accepts and ignores it.\n */\nexport function buildPaymasterContext(\n entries: Readonly<Record<string, unknown>> = {},\n): PaymasterContext {\n const context: PaymasterContext = {};\n for (const [key, value] of Object.entries(entries)) {\n if (value === undefined) continue;\n const kind = typeof value;\n if (kind === \"bigint\" || kind === \"function\" || kind === \"symbol\") {\n throw new Error(\n `buildPaymasterContext: \"${key}\" is a ${kind}, which is not JSON-serializable. Convert it to a string or number first.`,\n );\n }\n context[key] = value;\n }\n return context;\n}\n\nexport interface BuildPaymasterRequestOptions {\n userOperation: PaymasterRpcParams[0];\n /** Defaults to PEPU mainnet's EntryPoint v0.7. */\n entryPoint?: Address;\n /** Defaults to 97741 (PEPU mainnet). */\n chainId?: number;\n context?: PaymasterContext;\n id?: number | string;\n}\n\nfunction buildParams(options: BuildPaymasterRequestOptions): PaymasterRpcParams {\n const entryPointEntry = getContract(pepuMainnet.id, \"entryPoint07\");\n const entryPoint =\n options.entryPoint ??\n (entryPointEntry?.status === \"deployed\" ? entryPointEntry.address : undefined);\n if (!entryPoint) throw new Error(\"buildPaymasterRequest: no EntryPoint v0.7 address available.\");\n const chainId = toHex(options.chainId ?? pepuMainnet.id);\n return options.context\n ? [options.userOperation, entryPoint, chainId, options.context]\n : [options.userOperation, entryPoint, chainId];\n}\n\n/** Build a `pm_getPaymasterStubData` JSON-RPC request body. */\nexport function buildPaymasterStubDataRequest(\n options: BuildPaymasterRequestOptions,\n): PaymasterStubDataRequest {\n return {\n jsonrpc: \"2.0\",\n id: options.id ?? 1,\n method: \"pm_getPaymasterStubData\",\n params: buildParams(options),\n };\n}\n\n/** Build a `pm_getPaymasterData` JSON-RPC request body. */\nexport function buildPaymasterDataRequest(\n options: BuildPaymasterRequestOptions,\n): PaymasterDataRequest {\n return {\n jsonrpc: \"2.0\",\n id: options.id ?? 1,\n method: \"pm_getPaymasterData\",\n params: buildParams(options),\n };\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var chunkWANILJZQ_cjs = require('./chunk-WANILJZQ.cjs');
4
- var chunkTIEAZYHF_cjs = require('./chunk-TIEAZYHF.cjs');
4
+ var chunkK7JSQPZO_cjs = require('./chunk-K7JSQPZO.cjs');
5
5
  var chunkVF3D6KLQ_cjs = require('./chunk-VF3D6KLQ.cjs');
6
6
  var chunkDPCZJLB3_cjs = require('./chunk-DPCZJLB3.cjs');
7
7
  var chunkYQL7NISX_cjs = require('./chunk-YQL7NISX.cjs');
@@ -32,7 +32,18 @@ var BUNDLER_METHODS = [
32
32
  "pimlico_getUserOperationGasPrice",
33
33
  "zd_getUserOperationGasPrice"
34
34
  ];
35
+ var REQUIRED_BUNDLER_METHODS = [
36
+ "eth_sendUserOperation",
37
+ "eth_estimateUserOperationGas",
38
+ "eth_getUserOperationReceipt"
39
+ ];
35
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
+ }
36
47
  function hostOf(url) {
37
48
  try {
38
49
  return new URL(url).host;
@@ -98,22 +109,31 @@ async function probeBundler(url, o = {}) {
98
109
  for (const m of BUNDLER_METHODS) {
99
110
  try {
100
111
  const r = await rpc(f, url, m, [], timeoutMs);
101
- supportedMethods[m] = r.error?.code !== METHOD_NOT_FOUND;
112
+ supportedMethods[m] = !isMethodNotFound(r.error);
102
113
  } catch {
103
114
  supportedMethods[m] = false;
104
115
  }
105
116
  }
106
- const ep07 = chunkTIEAZYHF_cjs.getContract(chunkDPCZJLB3_cjs.pepuMainnet.id, "entryPoint07");
117
+ const ep07 = chunkK7JSQPZO_cjs.getContract(chunkDPCZJLB3_cjs.pepuMainnet.id, "entryPoint07");
107
118
  const want = ep07?.status === "deployed" ? ep07.address.toLowerCase() : void 0;
108
- const ok = chainId === chunkDPCZJLB3_cjs.pepuMainnet.id && (want === void 0 || (entryPoints?.some((a) => a.toLowerCase() === want) ?? false));
109
- const out = { ok, latencyMs: Date.now() - started, supportedMethods };
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
+ };
110
128
  if (chainId !== void 0) out.chainId = chainId;
111
129
  if (entryPoints) out.entryPoints = entryPoints;
112
130
  if (!ok) {
113
131
  out.error = new chunkYQL7NISX_cjs.PepuBundlerError(
114
132
  "BUNDLER_UNREACHABLE",
115
- chainId !== void 0 && chainId !== chunkDPCZJLB3_cjs.pepuMainnet.id ? `The bundler serves chain ${chainId}, not ${chunkDPCZJLB3_cjs.pepuMainnet.id}.` : "The bundler does not list EntryPoint v0.7.",
116
- { hint: "Point PEPU_BUNDLER_URL at a bundler for chain 97741 that supports EntryPoint v0.7." }
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
+ }
117
137
  );
118
138
  }
119
139
  return out;
@@ -159,7 +179,7 @@ async function probePaymaster(url, o = {}) {
159
179
  }
160
180
  let speaksRpc = false;
161
181
  try {
162
- const ep07 = chunkTIEAZYHF_cjs.getContract(chunkDPCZJLB3_cjs.pepuMainnet.id, "entryPoint07");
182
+ const ep07 = chunkK7JSQPZO_cjs.getContract(chunkDPCZJLB3_cjs.pepuMainnet.id, "entryPoint07");
163
183
  const ep = ep07?.status === "deployed" ? ep07.address : "0x0000000071727De22E5E9d8BAf0edAc6f37da032";
164
184
  const reply = await rpc(
165
185
  f,
@@ -169,14 +189,24 @@ async function probePaymaster(url, o = {}) {
169
189
  timeoutMs
170
190
  );
171
191
  reached = true;
172
- speaksRpc = reply.result !== void 0 || reply.error !== void 0;
173
- out.erc7677StubOk = reply.result !== void 0;
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
+ }
174
203
  } catch (e) {
175
204
  lastError = e;
176
205
  out.erc7677StubOk = false;
206
+ out.erc7677 = "not-responding";
177
207
  }
178
208
  out.latencyMs = Date.now() - started;
179
- out.ok = out.health === true || speaksRpc;
209
+ out.ok = speaksRpc && out.health !== false;
180
210
  if (!reached) out.error = unreachable(url, lastError);
181
211
  else if (!out.ok) {
182
212
  out.error = new chunkYQL7NISX_cjs.PepuBundlerError("BUNDLER_UNREACHABLE", `${hostOf(url)} answered but is not a PEPU paymaster service.`, {
@@ -186,8 +216,8 @@ async function probePaymaster(url, o = {}) {
186
216
  return out;
187
217
  }
188
218
  async function getPaymasterDeposit(client, paymaster) {
189
- const pm = chunkTIEAZYHF_cjs.getContract(chunkDPCZJLB3_cjs.pepuMainnet.id, "paymaster");
190
- const ep = chunkTIEAZYHF_cjs.getContract(chunkDPCZJLB3_cjs.pepuMainnet.id, "entryPoint07");
219
+ const pm = chunkK7JSQPZO_cjs.getContract(chunkDPCZJLB3_cjs.pepuMainnet.id, "paymaster");
220
+ const ep = chunkK7JSQPZO_cjs.getContract(chunkDPCZJLB3_cjs.pepuMainnet.id, "entryPoint07");
191
221
  const account = paymaster ?? (pm?.status === "deployed" ? pm.address : void 0);
192
222
  if (!account || ep?.status !== "deployed") {
193
223
  throw new chunkYQL7NISX_cjs.PepuConfigError("CONFIG_MISSING_ENV", "No paymaster address is known; pass one explicitly.", {
@@ -204,11 +234,11 @@ async function getPaymasterDeposit(client, paymaster) {
204
234
 
205
235
  // src/aa/status.ts
206
236
  function getPepuKernelStack(chainId) {
207
- const entryPoint06 = chunkTIEAZYHF_cjs.getContract(chainId, "entryPoint06");
208
- const entryPoint07 = chunkTIEAZYHF_cjs.getContract(chainId, "entryPoint07");
209
- const kernelFactory = chunkTIEAZYHF_cjs.getContract(chainId, "kernelFactory");
210
- const kernelMetaFactory = chunkTIEAZYHF_cjs.getContract(chainId, "kernelMetaFactory");
211
- const ecdsaValidator = chunkTIEAZYHF_cjs.getContract(chainId, "ecdsaValidator");
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");
212
242
  if (entryPoint06?.status !== "deployed" || entryPoint07?.status !== "deployed" || kernelFactory?.status !== "deployed" || kernelMetaFactory?.status !== "deployed" || ecdsaValidator?.status !== "deployed") {
213
243
  return void 0;
214
244
  }
@@ -281,5 +311,5 @@ exports.getSponsorshipStatus = getSponsorshipStatus;
281
311
  exports.kernelFactoryAbi = kernelFactoryAbi;
282
312
  exports.probeBundler = probeBundler;
283
313
  exports.probePaymaster = probePaymaster;
284
- //# sourceMappingURL=chunk-SLW7FRTL.cjs.map
285
- //# sourceMappingURL=chunk-SLW7FRTL.cjs.map
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;AAA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ev 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"]}