@pepu-chain/sdk 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +565 -2
- package/dist/aa/kernel.cjs +40 -0
- package/dist/aa/kernel.cjs.map +1 -0
- package/dist/aa/kernel.d.cts +88 -0
- package/dist/aa/kernel.d.ts +88 -0
- package/dist/aa/kernel.js +11 -0
- package/dist/aa/kernel.js.map +1 -0
- package/dist/aa/react-direct.cjs +110 -0
- package/dist/aa/react-direct.cjs.map +1 -0
- package/dist/aa/react-direct.d.cts +42 -0
- package/dist/aa/react-direct.d.ts +42 -0
- package/dist/aa/react-direct.js +107 -0
- package/dist/aa/react-direct.js.map +1 -0
- package/dist/aa/react.cjs +151 -0
- package/dist/aa/react.cjs.map +1 -0
- package/dist/aa/react.d.cts +62 -0
- package/dist/aa/react.d.ts +62 -0
- package/dist/aa/react.js +147 -0
- package/dist/aa/react.js.map +1 -0
- package/dist/aa.cjs +84 -0
- package/dist/aa.cjs.map +1 -0
- package/dist/aa.d.cts +85 -0
- package/dist/aa.d.ts +85 -0
- package/dist/aa.js +11 -0
- package/dist/aa.js.map +1 -0
- package/dist/api-Dz4sCHH_.d.cts +654 -0
- package/dist/api-Dz4sCHH_.d.ts +654 -0
- package/dist/calls-BRPjKgjl.d.cts +70 -0
- package/dist/calls-z_EQOtFb.d.ts +70 -0
- package/dist/chains-DK13zGIp.d.cts +235 -0
- package/dist/chains-DK13zGIp.d.ts +235 -0
- package/dist/chunk-3XUGQODR.js +194 -0
- package/dist/chunk-3XUGQODR.js.map +1 -0
- package/dist/chunk-45KSZH26.cjs +145 -0
- package/dist/chunk-45KSZH26.cjs.map +1 -0
- package/dist/chunk-4GINFJO6.cjs +44 -0
- package/dist/chunk-4GINFJO6.cjs.map +1 -0
- package/dist/chunk-62M2LKQW.js +136 -0
- package/dist/chunk-62M2LKQW.js.map +1 -0
- package/dist/chunk-6DSZ4Z2N.js +498 -0
- package/dist/chunk-6DSZ4Z2N.js.map +1 -0
- package/dist/chunk-7MNJF2OB.cjs +72 -0
- package/dist/chunk-7MNJF2OB.cjs.map +1 -0
- package/dist/chunk-A5LP2UCS.cjs +2729 -0
- package/dist/chunk-A5LP2UCS.cjs.map +1 -0
- package/dist/chunk-AJS4UFQX.cjs +121 -0
- package/dist/chunk-AJS4UFQX.cjs.map +1 -0
- package/dist/chunk-C2XW44FI.cjs +200 -0
- package/dist/chunk-C2XW44FI.cjs.map +1 -0
- package/dist/chunk-C7IC36XS.cjs +13 -0
- package/dist/chunk-C7IC36XS.cjs.map +1 -0
- package/dist/chunk-D52PADVY.js +84 -0
- package/dist/chunk-D52PADVY.js.map +1 -0
- package/dist/chunk-DH6BFNVJ.cjs +272 -0
- package/dist/chunk-DH6BFNVJ.cjs.map +1 -0
- package/dist/chunk-DPCZJLB3.cjs +87 -0
- package/dist/chunk-DPCZJLB3.cjs.map +1 -0
- package/dist/chunk-EHBPIYY4.js +262 -0
- package/dist/chunk-EHBPIYY4.js.map +1 -0
- package/dist/chunk-ESMNAXUI.js +86 -0
- package/dist/chunk-ESMNAXUI.js.map +1 -0
- package/dist/chunk-ET3P6TX6.cjs +49 -0
- package/dist/chunk-ET3P6TX6.cjs.map +1 -0
- package/dist/chunk-FCXSP2YF.js +219 -0
- package/dist/chunk-FCXSP2YF.js.map +1 -0
- package/dist/chunk-IB2FSPMJ.js +66 -0
- package/dist/chunk-IB2FSPMJ.js.map +1 -0
- package/dist/chunk-IG7RSL2Y.cjs +178 -0
- package/dist/chunk-IG7RSL2Y.cjs.map +1 -0
- package/dist/chunk-IY3ALPUJ.js +2716 -0
- package/dist/chunk-IY3ALPUJ.js.map +1 -0
- package/dist/chunk-J3O2ZGG3.cjs +93 -0
- package/dist/chunk-J3O2ZGG3.cjs.map +1 -0
- package/dist/chunk-J6UXXHBE.js +37 -0
- package/dist/chunk-J6UXXHBE.js.map +1 -0
- package/dist/chunk-JLZ4LZ4Z.js +22 -0
- package/dist/chunk-JLZ4LZ4Z.js.map +1 -0
- package/dist/chunk-KIIFL4VM.js +274 -0
- package/dist/chunk-KIIFL4VM.js.map +1 -0
- package/dist/chunk-KVG3AYYR.js +99 -0
- package/dist/chunk-KVG3AYYR.js.map +1 -0
- package/dist/chunk-MBA4CLA5.js +45 -0
- package/dist/chunk-MBA4CLA5.js.map +1 -0
- package/dist/chunk-NE3QKDOB.cjs +24 -0
- package/dist/chunk-NE3QKDOB.cjs.map +1 -0
- package/dist/chunk-NVOPDXTA.cjs +95 -0
- package/dist/chunk-NVOPDXTA.cjs.map +1 -0
- package/dist/chunk-OH3QMAIB.js +11 -0
- package/dist/chunk-OH3QMAIB.js.map +1 -0
- package/dist/chunk-PHM3ZORG.cjs +110 -0
- package/dist/chunk-PHM3ZORG.cjs.map +1 -0
- package/dist/chunk-R5PXQNO3.cjs +209 -0
- package/dist/chunk-R5PXQNO3.cjs.map +1 -0
- package/dist/chunk-SLW7FRTL.cjs +285 -0
- package/dist/chunk-SLW7FRTL.cjs.map +1 -0
- package/dist/chunk-SVWRRALU.cjs +17 -0
- package/dist/chunk-SVWRRALU.cjs.map +1 -0
- package/dist/chunk-T43PQXJD.js +202 -0
- package/dist/chunk-T43PQXJD.js.map +1 -0
- package/dist/chunk-TIEAZYHF.cjs +225 -0
- package/dist/chunk-TIEAZYHF.cjs.map +1 -0
- package/dist/chunk-VBH3JLQ5.js +116 -0
- package/dist/chunk-VBH3JLQ5.js.map +1 -0
- package/dist/chunk-VF3D6KLQ.cjs +94 -0
- package/dist/chunk-VF3D6KLQ.cjs.map +1 -0
- package/dist/chunk-VTQIHMF3.js +82 -0
- package/dist/chunk-VTQIHMF3.js.map +1 -0
- package/dist/chunk-W3JN3YIW.js +15 -0
- package/dist/chunk-W3JN3YIW.js.map +1 -0
- package/dist/chunk-WANILJZQ.cjs +87 -0
- package/dist/chunk-WANILJZQ.cjs.map +1 -0
- package/dist/chunk-XC4IBCI2.js +86 -0
- package/dist/chunk-XC4IBCI2.js.map +1 -0
- package/dist/chunk-YKEWWQEJ.js +165 -0
- package/dist/chunk-YKEWWQEJ.js.map +1 -0
- package/dist/chunk-YQL7NISX.cjs +515 -0
- package/dist/chunk-YQL7NISX.cjs.map +1 -0
- package/dist/chunk-ZB6SVBK4.js +89 -0
- package/dist/chunk-ZB6SVBK4.js.map +1 -0
- package/dist/combo/react.cjs +235 -0
- package/dist/combo/react.cjs.map +1 -0
- package/dist/combo/react.d.cts +148 -0
- package/dist/combo/react.d.ts +148 -0
- package/dist/combo/react.js +230 -0
- package/dist/combo/react.js.map +1 -0
- package/dist/combo.cjs +262 -0
- package/dist/combo.cjs.map +1 -0
- package/dist/combo.d.cts +139 -0
- package/dist/combo.d.ts +139 -0
- package/dist/combo.js +249 -0
- package/dist/combo.js.map +1 -0
- package/dist/config-CHjz7ZjZ.d.cts +57 -0
- package/dist/config-COjhIZTh.d.ts +57 -0
- package/dist/doctor.cjs +354 -0
- package/dist/doctor.cjs.map +1 -0
- package/dist/doctor.d.cts +177 -0
- package/dist/doctor.d.ts +177 -0
- package/dist/doctor.js +345 -0
- package/dist/doctor.js.map +1 -0
- package/dist/erc7677-DOW58QBE.d.cts +111 -0
- package/dist/erc7677-DOW58QBE.d.ts +111 -0
- package/dist/errors-CgX1vNj7.d.cts +100 -0
- package/dist/errors-CgX1vNj7.d.ts +100 -0
- package/dist/index.cjs +802 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +2398 -0
- package/dist/index.d.ts +2398 -0
- package/dist/index.js +559 -0
- package/dist/index.js.map +1 -0
- package/dist/paymaster/server.cjs +38 -0
- package/dist/paymaster/server.cjs.map +1 -0
- package/dist/paymaster/server.d.cts +57 -0
- package/dist/paymaster/server.d.ts +57 -0
- package/dist/paymaster/server.js +36 -0
- package/dist/paymaster/server.js.map +1 -0
- package/dist/paymaster.cjs +356 -0
- package/dist/paymaster.cjs.map +1 -0
- package/dist/paymaster.d.cts +1851 -0
- package/dist/paymaster.d.ts +1851 -0
- package/dist/paymaster.js +289 -0
- package/dist/paymaster.js.map +1 -0
- package/dist/privy/react.cjs +48 -0
- package/dist/privy/react.cjs.map +1 -0
- package/dist/privy/react.d.cts +194 -0
- package/dist/privy/react.d.ts +194 -0
- package/dist/privy/react.js +7 -0
- package/dist/privy/react.js.map +1 -0
- package/dist/privy/server.cjs +43 -0
- package/dist/privy/server.cjs.map +1 -0
- package/dist/privy/server.d.cts +192 -0
- package/dist/privy/server.d.ts +192 -0
- package/dist/privy/server.js +6 -0
- package/dist/privy/server.js.map +1 -0
- package/dist/privy/wagmi.d.ts +90 -0
- package/dist/privy/wagmi.js +55 -0
- package/dist/privy/wagmi.js.map +1 -0
- package/dist/privy.cjs +34 -0
- package/dist/privy.cjs.map +1 -0
- package/dist/privy.d.cts +4 -0
- package/dist/privy.d.ts +4 -0
- package/dist/privy.js +5 -0
- package/dist/privy.js.map +1 -0
- package/dist/react.cjs +72 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +66 -0
- package/dist/react.d.ts +66 -0
- package/dist/react.js +68 -0
- package/dist/react.js.map +1 -0
- package/dist/requirements-C-QiJkL9.d.cts +134 -0
- package/dist/requirements-C-QiJkL9.d.ts +134 -0
- package/dist/scope-DBRkN7bR.d.cts +94 -0
- package/dist/scope-DBRkN7bR.d.ts +94 -0
- package/dist/server.cjs +59 -0
- package/dist/server.cjs.map +1 -0
- package/dist/server.d.cts +208 -0
- package/dist/server.d.ts +208 -0
- package/dist/server.js +8 -0
- package/dist/server.js.map +1 -0
- package/dist/session/kernel.cjs +82 -0
- package/dist/session/kernel.cjs.map +1 -0
- package/dist/session/kernel.d.cts +131 -0
- package/dist/session/kernel.d.ts +131 -0
- package/dist/session/kernel.js +13 -0
- package/dist/session/kernel.js.map +1 -0
- package/dist/session/react.cjs +37 -0
- package/dist/session/react.cjs.map +1 -0
- package/dist/session/react.d.cts +119 -0
- package/dist/session/react.d.ts +119 -0
- package/dist/session/react.js +8 -0
- package/dist/session/react.js.map +1 -0
- package/dist/session/server.cjs +267 -0
- package/dist/session/server.cjs.map +1 -0
- package/dist/session/server.d.cts +151 -0
- package/dist/session/server.d.ts +151 -0
- package/dist/session/server.js +252 -0
- package/dist/session/server.js.map +1 -0
- package/dist/session.cjs +74 -0
- package/dist/session.cjs.map +1 -0
- package/dist/session.d.cts +3 -0
- package/dist/session.d.ts +3 -0
- package/dist/session.js +5 -0
- package/dist/session.js.map +1 -0
- package/dist/status-CmOsyPmO.d.cts +295 -0
- package/dist/status-DwkkOrGQ.d.ts +295 -0
- package/dist/store-CjmLgp9g.d.cts +64 -0
- package/dist/store-CjmLgp9g.d.ts +64 -0
- package/dist/types-BEEM7WdG.d.cts +25 -0
- package/dist/types-BEEM7WdG.d.ts +25 -0
- package/dist/types-BilBTDqK.d.cts +27 -0
- package/dist/types-BilBTDqK.d.ts +27 -0
- package/package.json +209 -3
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import { Address, PublicClient, Transport, Hex } from 'viem';
|
|
2
|
+
import { P as PepuChain } from './chains-DK13zGIp.cjs';
|
|
3
|
+
import { a as PepuBundlerError } from './errors-CgX1vNj7.cjs';
|
|
4
|
+
|
|
5
|
+
/** Minimal fetch signature, so tests and non-browser hosts can inject one. */
|
|
6
|
+
type FetchLike = (input: string, init?: RequestInit) => Promise<Response>;
|
|
7
|
+
interface ProbeOptions {
|
|
8
|
+
fetch?: FetchLike;
|
|
9
|
+
/** Per-request timeout. Default 8000. */
|
|
10
|
+
timeoutMs?: number;
|
|
11
|
+
}
|
|
12
|
+
interface BundlerProbeResult {
|
|
13
|
+
ok: boolean;
|
|
14
|
+
chainId?: number;
|
|
15
|
+
entryPoints?: Address[];
|
|
16
|
+
/** `true` when the method exists (any answer but "method not found"). */
|
|
17
|
+
supportedMethods?: Record<string, boolean>;
|
|
18
|
+
latencyMs: number;
|
|
19
|
+
error?: PepuBundlerError;
|
|
20
|
+
}
|
|
21
|
+
interface PaymasterProbeResult {
|
|
22
|
+
ok: boolean;
|
|
23
|
+
/** `GET <origin>/health` answered `{ status: "ok" }`. */
|
|
24
|
+
health?: boolean;
|
|
25
|
+
/** Body of `GET <origin>/v2/free-tier` when the service exposes it. */
|
|
26
|
+
freeTier?: unknown;
|
|
27
|
+
/**
|
|
28
|
+
* The URL answered a `pm_getPaymasterStubData` call with a stub result. A
|
|
29
|
+
* JSON-RPC denial (no credential, unknown sender) is NOT a stub result:
|
|
30
|
+
* the endpoint is alive and speaks ERC-7677, but the probe has no
|
|
31
|
+
* credential, so this stays `false`.
|
|
32
|
+
*/
|
|
33
|
+
erc7677StubOk?: boolean;
|
|
34
|
+
latencyMs: number;
|
|
35
|
+
error?: PepuBundlerError;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Probe a bundler URL: `eth_chainId`, `eth_supportedEntryPoints` and a
|
|
39
|
+
* capability check of the methods PEPU apps use (a method answered with
|
|
40
|
+
* anything but "method not found" counts as supported; nothing is sent
|
|
41
|
+
* on-chain). Never throws for network trouble; returns `ok: false` with a
|
|
42
|
+
* `BUNDLER_UNREACHABLE` error. Throws `CONFIG_BAD_URL` for a malformed URL.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* const r = await probeBundler("https://bundler.example.com");
|
|
46
|
+
* if (!r.ok) console.log(r.error?.hint);
|
|
47
|
+
*/
|
|
48
|
+
declare function probeBundler(url: string, o?: ProbeOptions): Promise<BundlerProbeResult>;
|
|
49
|
+
/**
|
|
50
|
+
* Probe a paymaster URL: the service base (`https://paymaster.pepeunchained.com`) or the ERC-7677 endpoint
|
|
51
|
+
* (`https://host/v2/paymaster/<token>`).
|
|
52
|
+
* Checks `GET <origin>/health`, `GET <origin>/v2/free-tier`, and whether the URL
|
|
53
|
+
* answers JSON-RPC `pm_getPaymasterStubData`. `ok` means the service is alive:
|
|
54
|
+
* health is ok, or the URL spoke valid JSON-RPC. The URL (which can embed a
|
|
55
|
+
* token) never appears in the returned error.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* const r = await probePaymaster(process.env.PEPU_PAYMASTER_URL!);
|
|
59
|
+
* console.log(r.ok, r.freeTier);
|
|
60
|
+
*/
|
|
61
|
+
declare function probePaymaster(url: string, o?: ProbeOptions): Promise<PaymasterProbeResult>;
|
|
62
|
+
/**
|
|
63
|
+
* The paymaster's EntryPoint v0.7 deposit in wei. A drop across a UserOperation
|
|
64
|
+
* is the proof that it was sponsored. Defaults to PEPU's deployed paymaster.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* const before = await getPaymasterDeposit(publicClient);
|
|
68
|
+
*/
|
|
69
|
+
declare function getPaymasterDeposit(client: PublicClient, paymaster?: Address): Promise<bigint>;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Canonical keys for contracts tracked by this registry. Adding a new key
|
|
73
|
+
* here (and a corresponding entry per chain below) is not a breaking
|
|
74
|
+
* change for consumers that read the registry through {@link getContract}
|
|
75
|
+
* or {@link listContracts}.
|
|
76
|
+
*/
|
|
77
|
+
type PepuContractName = "create2Factory" | "multicall3" | "permit2" | "entryPoint06" | "entryPoint07" | "kernelFactory" | "kernelMetaFactory" | "ecdsaValidator" | "paymaster" | "kernelImplementation" | "kernelEcdsaSignerModule" | "kernelCallPolicyV004" | "kernelTimestampPolicy" | "tapScore" | "paymasterV1" | "paymasterV2";
|
|
78
|
+
/** A contract that is confirmed live on-chain at `address`. */
|
|
79
|
+
interface DeployedContract {
|
|
80
|
+
readonly status: "deployed";
|
|
81
|
+
/** Human-readable name, for logging/UI. */
|
|
82
|
+
readonly name: string;
|
|
83
|
+
/** Verified contract address. */
|
|
84
|
+
readonly address: Address;
|
|
85
|
+
/** Optional short note, e.g. how the address was verified. */
|
|
86
|
+
readonly notes?: string;
|
|
87
|
+
/**
|
|
88
|
+
* ISO date (YYYY-MM-DD) on which the address was last confirmed to have
|
|
89
|
+
* bytecode via `eth_getCode` against the PEPU mainnet RPC. Re-run
|
|
90
|
+
* `node packages/sdk/scripts/live-check.mjs` to refresh.
|
|
91
|
+
*/
|
|
92
|
+
readonly verifiedAt?: string;
|
|
93
|
+
/**
|
|
94
|
+
* True when the contract still has bytecode but must not be used (for example
|
|
95
|
+
* the v1 paymaster, whose EntryPoint deposit was withdrawn). Never route new
|
|
96
|
+
* work to a retired contract.
|
|
97
|
+
*/
|
|
98
|
+
readonly retired?: true;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* A contract that is not yet deployed on this chain. Deliberately has no
|
|
102
|
+
* `address` field — callers must not be able to accidentally read a
|
|
103
|
+
* placeholder value and treat it as real. Use {@link getContract} /
|
|
104
|
+
* {@link isDeployed} to narrow before reading an address.
|
|
105
|
+
*/
|
|
106
|
+
interface PendingContract {
|
|
107
|
+
readonly status: "pending";
|
|
108
|
+
/** Human-readable name, for logging/UI. */
|
|
109
|
+
readonly name: string;
|
|
110
|
+
/** Why this contract has no verified address yet. */
|
|
111
|
+
readonly reason: string;
|
|
112
|
+
}
|
|
113
|
+
type ContractEntry = DeployedContract | PendingContract;
|
|
114
|
+
/** Per-chain contract catalog, keyed by {@link PepuContractName}. */
|
|
115
|
+
type PepuContractRegistry = Readonly<Record<PepuContractName, ContractEntry>>;
|
|
116
|
+
/**
|
|
117
|
+
* Contract registry, keyed by chain id. Tracked as independent per-chain
|
|
118
|
+
* entries because deployments happen per-chain and have already diverged:
|
|
119
|
+
* mainnet has the CREATE2 deployer, a PEPU-specific Multicall3, the
|
|
120
|
+
* canonical Permit2, the full ZeroDev Kernel v3 AA stack (EntryPoint
|
|
121
|
+
* v0.6/v0.7, Kernel factory/meta-factory, ECDSA validator), and a
|
|
122
|
+
* project-deployed, funded verifying paymaster. Testnet has only the
|
|
123
|
+
* CREATE2 deployer — everything else is `status: "pending"` because
|
|
124
|
+
* testnet is out of scope for this package (no faucet exists to fund
|
|
125
|
+
* verification there).
|
|
126
|
+
*
|
|
127
|
+
* Note on the paymaster specifically: `status: "deployed"` here means the
|
|
128
|
+
* contract has live bytecode and a real EntryPoint deposit — it does NOT
|
|
129
|
+
* mean gas sponsorship is usable by an application. See
|
|
130
|
+
* `getSponsorshipStatus` in `./aa/status.js`, which is the single source of
|
|
131
|
+
* truth for that separate question.
|
|
132
|
+
*/
|
|
133
|
+
declare const pepuContracts: Readonly<Record<number, PepuContractRegistry>>;
|
|
134
|
+
/** Look up one contract entry for a chain id. Returns `undefined` if the chain isn't in the registry. */
|
|
135
|
+
declare function getContract(chainId: number, name: PepuContractName): ContractEntry | undefined;
|
|
136
|
+
/** List all tracked contract entries for a chain id, in registry order. */
|
|
137
|
+
declare function listContracts(chainId: number): readonly ContractEntry[];
|
|
138
|
+
/** Narrow a {@link ContractEntry} to {@link DeployedContract}. */
|
|
139
|
+
declare function isDeployed(entry: ContractEntry | undefined): entry is DeployedContract;
|
|
140
|
+
/** One row of the address table returned by {@link getPepuAddresses}. */
|
|
141
|
+
interface PepuAddressRow {
|
|
142
|
+
readonly key: PepuContractName;
|
|
143
|
+
readonly name: string;
|
|
144
|
+
readonly status: "deployed" | "pending";
|
|
145
|
+
/** Present only when `status` is `"deployed"`. */
|
|
146
|
+
readonly address?: Address;
|
|
147
|
+
/** ISO date of the last `eth_getCode` check, when known. */
|
|
148
|
+
readonly verifiedAt?: string;
|
|
149
|
+
/** True for a deployed contract that is retired and must not be used (the v1 paymaster). */
|
|
150
|
+
readonly retired?: true;
|
|
151
|
+
/** Notes (deployed) or reason (pending). */
|
|
152
|
+
readonly note: string;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* The full supporting-contract table for a chain, flattened for docs and
|
|
156
|
+
* MCP rendering. Pending entries carry no `address`.
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* ```ts
|
|
160
|
+
* const rows = getPepuAddresses(); // mainnet by default
|
|
161
|
+
* const live = rows.filter((r) => r.status === "deployed");
|
|
162
|
+
* ```
|
|
163
|
+
*/
|
|
164
|
+
declare function getPepuAddresses(chainId?: number): readonly PepuAddressRow[];
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* The account-abstraction contracts a Kernel v3 smart account needs,
|
|
168
|
+
* narrowed to their {@link DeployedContract} form for a given chain.
|
|
169
|
+
* Returns `undefined` if any one of them isn't deployed on that chain
|
|
170
|
+
* (today: everything except mainnet, `97741`) — this package never fabricates
|
|
171
|
+
* a partial/best-effort bundle.
|
|
172
|
+
*/
|
|
173
|
+
interface PepuKernelStack {
|
|
174
|
+
readonly entryPoint06: DeployedContract;
|
|
175
|
+
readonly entryPoint07: DeployedContract;
|
|
176
|
+
readonly kernelFactory: DeployedContract;
|
|
177
|
+
readonly kernelMetaFactory: DeployedContract;
|
|
178
|
+
readonly ecdsaValidator: DeployedContract;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Look up every AA contract this package knows about for `chainId`, already
|
|
182
|
+
* narrowed to {@link DeployedContract}. Returns `undefined` unless *all* five
|
|
183
|
+
* are deployed on that chain (today, only PEPU mainnet qualifies) — a caller
|
|
184
|
+
* building a Kernel account needs every one of them, so a partial result
|
|
185
|
+
* would just move the "is this actually usable" check into every caller.
|
|
186
|
+
*
|
|
187
|
+
* This is a convenience grouping over `getContract` from `./contracts.js`;
|
|
188
|
+
* it doesn't add any address or fact that registry doesn't already have.
|
|
189
|
+
*/
|
|
190
|
+
declare function getPepuKernelStack(chainId: number): PepuKernelStack | undefined;
|
|
191
|
+
/**
|
|
192
|
+
* Legacy static gas-sponsorship status for PEPU. **Always reports
|
|
193
|
+
* unavailable** (it never probes). Sponsorship is PROVEN end to end on PEPU
|
|
194
|
+
* mainnet through the hosted bundler and paymaster service (a zero-balance
|
|
195
|
+
* Kernel smart account transacted, paid for by the paymaster); use
|
|
196
|
+
* `checkSponsorship()` for the live answer. This function
|
|
197
|
+
* exists so nothing downstream (this package, `@pepu-chain/mcp`, an app)
|
|
198
|
+
* has to independently invent an "is sponsorship on?" check, and so that
|
|
199
|
+
* check can't silently start lying once this file changes.
|
|
200
|
+
*
|
|
201
|
+
* Do not treat the presence of `kernelFactory`/`ecdsaValidator`/`paymaster`
|
|
202
|
+
* addresses in {@link getPepuKernelStack} / the contract registry as
|
|
203
|
+
* sponsorship support — those let you build and deploy a Kernel account and
|
|
204
|
+
* send its UserOperations through a normal `eth_sendTransaction`-style flow
|
|
205
|
+
* (self-paying its own gas via the EntryPoint deposit), which is a real,
|
|
206
|
+
* working feature; sponsoring that gas needs a funded project or free-tier token.
|
|
207
|
+
*/
|
|
208
|
+
interface SponsorshipStatus {
|
|
209
|
+
readonly available: false;
|
|
210
|
+
readonly reason: string;
|
|
211
|
+
/**
|
|
212
|
+
* Extension point for a future bundler/paymaster integration. Passing a
|
|
213
|
+
* URL here does **not** make sponsorship available — `available` stays
|
|
214
|
+
* `false` regardless — this field only exists so a caller can start
|
|
215
|
+
* wiring a URL through their own config today and have this function
|
|
216
|
+
* start using it later without an API change.
|
|
217
|
+
*/
|
|
218
|
+
readonly bundlerUrl?: string;
|
|
219
|
+
}
|
|
220
|
+
/** Options for {@link getSponsorshipStatus}. */
|
|
221
|
+
interface GetSponsorshipStatusOptions {
|
|
222
|
+
/** See {@link SponsorshipStatus.bundlerUrl}. Not yet used for anything. */
|
|
223
|
+
readonly bundlerUrl?: string;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* @deprecated Always reports `available: false`. Use `checkSponsorship()` (live
|
|
227
|
+
* bundler and paymaster probe) from `@pepu-chain/sdk`. Kept for 0.1 callers.
|
|
228
|
+
*/
|
|
229
|
+
declare function getSponsorshipStatus(options?: GetSponsorshipStatusOptions): SponsorshipStatus;
|
|
230
|
+
/**
|
|
231
|
+
* Compute (or confirm) the counterfactual address of a Kernel v3 smart
|
|
232
|
+
* account via the verified factory's `getAddress(data, salt)` — a thin,
|
|
233
|
+
* typed pass-through, not a re-implementation.
|
|
234
|
+
*
|
|
235
|
+
* Deliberately does **not** build `data` (Kernel v3.1's `initialize(...)`
|
|
236
|
+
* calldata: root validator, hook, validator data, hook data, init config)
|
|
237
|
+
* for you. A hand-rolled encoding here would be a second, unverified copy of
|
|
238
|
+
* the byte layout that ZeroDev's SDK already produces (and that has been
|
|
239
|
+
* exercised against PEPU's factory through the sponsored-transaction run),
|
|
240
|
+
* which is exactly the kind of invented encoding this package's rules
|
|
241
|
+
* forbid for addresses. Build `data` with ZeroDev's
|
|
242
|
+
* `@zerodev/sdk` (or by hand from the public Kernel v3 contracts source),
|
|
243
|
+
* then pass the result here.
|
|
244
|
+
*/
|
|
245
|
+
declare function getKernelAccountAddress(client: PublicClient<Transport, PepuChain>, factory: Pick<DeployedContract, "address">, args: {
|
|
246
|
+
readonly data: Hex;
|
|
247
|
+
readonly salt: Hex;
|
|
248
|
+
}): Promise<Address>;
|
|
249
|
+
/** Live sponsorship report from {@link checkSponsorship}. */
|
|
250
|
+
interface SponsorshipReport {
|
|
251
|
+
/** True only when a bundler and a paymaster are configured and both answer. */
|
|
252
|
+
available: boolean;
|
|
253
|
+
/** `direct` when you bring your own bundler and paymaster URLs; `none` when nothing is configured. */
|
|
254
|
+
transport: "direct" | "none";
|
|
255
|
+
bundler: {
|
|
256
|
+
configured: boolean;
|
|
257
|
+
probe?: BundlerProbeResult;
|
|
258
|
+
};
|
|
259
|
+
paymaster: {
|
|
260
|
+
configured: boolean;
|
|
261
|
+
probe?: PaymasterProbeResult;
|
|
262
|
+
depositWei?: bigint;
|
|
263
|
+
};
|
|
264
|
+
/** One sentence for a human or an agent. */
|
|
265
|
+
reason: string;
|
|
266
|
+
/** Concrete next steps, empty when `available`. */
|
|
267
|
+
fixes: string[];
|
|
268
|
+
}
|
|
269
|
+
/** Options for {@link checkSponsorship}. */
|
|
270
|
+
interface CheckSponsorshipOptions {
|
|
271
|
+
bundlerUrl?: string;
|
|
272
|
+
paymasterUrl?: string;
|
|
273
|
+
env?: Record<string, string | undefined>;
|
|
274
|
+
fetch?: FetchLike;
|
|
275
|
+
/** When given, also read the paymaster's EntryPoint deposit. */
|
|
276
|
+
publicClient?: PublicClient;
|
|
277
|
+
/** Paymaster contract to read the deposit of. Defaults to PEPU's deployed paymaster. */
|
|
278
|
+
paymasterAddress?: Address;
|
|
279
|
+
timeoutMs?: number;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Live gas-sponsorship status. Resolves the bundler and paymaster URLs from
|
|
283
|
+
* options, env, then the hosted defaults (bundler.pepeunchained.com and the paymaster
|
|
284
|
+
* service base; with no token URL the service is probed at its base), probes both,
|
|
285
|
+
* and optionally reads the paymaster deposit. Never throws for an
|
|
286
|
+
* unreachable service; it reports `available: false` with `fixes`.
|
|
287
|
+
* Replaces the hard-coded {@link getSponsorshipStatus}.
|
|
288
|
+
*
|
|
289
|
+
* @example
|
|
290
|
+
* const s = await checkSponsorship({ publicClient });
|
|
291
|
+
* if (!s.available) console.log(s.reason, s.fixes);
|
|
292
|
+
*/
|
|
293
|
+
declare function checkSponsorship(options?: CheckSponsorshipOptions): Promise<SponsorshipReport>;
|
|
294
|
+
|
|
295
|
+
export { type BundlerProbeResult as B, type CheckSponsorshipOptions as C, type DeployedContract as D, type FetchLike as F, type GetSponsorshipStatusOptions as G, type PaymasterProbeResult as P, type SponsorshipReport as S, type PepuKernelStack as a, type ProbeOptions as b, type SponsorshipStatus as c, checkSponsorship as d, getPaymasterDeposit as e, getPepuKernelStack as f, getKernelAccountAddress as g, getSponsorshipStatus as h, probePaymaster as i, type ContractEntry as j, type PendingContract as k, type PepuAddressRow as l, type PepuContractName as m, type PepuContractRegistry as n, getContract as o, probeBundler as p, getPepuAddresses as q, isDeployed as r, listContracts as s, pepuContracts as t };
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import { Address, PublicClient, Transport, Hex } from 'viem';
|
|
2
|
+
import { P as PepuChain } from './chains-DK13zGIp.js';
|
|
3
|
+
import { a as PepuBundlerError } from './errors-CgX1vNj7.js';
|
|
4
|
+
|
|
5
|
+
/** Minimal fetch signature, so tests and non-browser hosts can inject one. */
|
|
6
|
+
type FetchLike = (input: string, init?: RequestInit) => Promise<Response>;
|
|
7
|
+
interface ProbeOptions {
|
|
8
|
+
fetch?: FetchLike;
|
|
9
|
+
/** Per-request timeout. Default 8000. */
|
|
10
|
+
timeoutMs?: number;
|
|
11
|
+
}
|
|
12
|
+
interface BundlerProbeResult {
|
|
13
|
+
ok: boolean;
|
|
14
|
+
chainId?: number;
|
|
15
|
+
entryPoints?: Address[];
|
|
16
|
+
/** `true` when the method exists (any answer but "method not found"). */
|
|
17
|
+
supportedMethods?: Record<string, boolean>;
|
|
18
|
+
latencyMs: number;
|
|
19
|
+
error?: PepuBundlerError;
|
|
20
|
+
}
|
|
21
|
+
interface PaymasterProbeResult {
|
|
22
|
+
ok: boolean;
|
|
23
|
+
/** `GET <origin>/health` answered `{ status: "ok" }`. */
|
|
24
|
+
health?: boolean;
|
|
25
|
+
/** Body of `GET <origin>/v2/free-tier` when the service exposes it. */
|
|
26
|
+
freeTier?: unknown;
|
|
27
|
+
/**
|
|
28
|
+
* The URL answered a `pm_getPaymasterStubData` call with a stub result. A
|
|
29
|
+
* JSON-RPC denial (no credential, unknown sender) is NOT a stub result:
|
|
30
|
+
* the endpoint is alive and speaks ERC-7677, but the probe has no
|
|
31
|
+
* credential, so this stays `false`.
|
|
32
|
+
*/
|
|
33
|
+
erc7677StubOk?: boolean;
|
|
34
|
+
latencyMs: number;
|
|
35
|
+
error?: PepuBundlerError;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Probe a bundler URL: `eth_chainId`, `eth_supportedEntryPoints` and a
|
|
39
|
+
* capability check of the methods PEPU apps use (a method answered with
|
|
40
|
+
* anything but "method not found" counts as supported; nothing is sent
|
|
41
|
+
* on-chain). Never throws for network trouble; returns `ok: false` with a
|
|
42
|
+
* `BUNDLER_UNREACHABLE` error. Throws `CONFIG_BAD_URL` for a malformed URL.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* const r = await probeBundler("https://bundler.example.com");
|
|
46
|
+
* if (!r.ok) console.log(r.error?.hint);
|
|
47
|
+
*/
|
|
48
|
+
declare function probeBundler(url: string, o?: ProbeOptions): Promise<BundlerProbeResult>;
|
|
49
|
+
/**
|
|
50
|
+
* Probe a paymaster URL: the service base (`https://paymaster.pepeunchained.com`) or the ERC-7677 endpoint
|
|
51
|
+
* (`https://host/v2/paymaster/<token>`).
|
|
52
|
+
* Checks `GET <origin>/health`, `GET <origin>/v2/free-tier`, and whether the URL
|
|
53
|
+
* answers JSON-RPC `pm_getPaymasterStubData`. `ok` means the service is alive:
|
|
54
|
+
* health is ok, or the URL spoke valid JSON-RPC. The URL (which can embed a
|
|
55
|
+
* token) never appears in the returned error.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* const r = await probePaymaster(process.env.PEPU_PAYMASTER_URL!);
|
|
59
|
+
* console.log(r.ok, r.freeTier);
|
|
60
|
+
*/
|
|
61
|
+
declare function probePaymaster(url: string, o?: ProbeOptions): Promise<PaymasterProbeResult>;
|
|
62
|
+
/**
|
|
63
|
+
* The paymaster's EntryPoint v0.7 deposit in wei. A drop across a UserOperation
|
|
64
|
+
* is the proof that it was sponsored. Defaults to PEPU's deployed paymaster.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* const before = await getPaymasterDeposit(publicClient);
|
|
68
|
+
*/
|
|
69
|
+
declare function getPaymasterDeposit(client: PublicClient, paymaster?: Address): Promise<bigint>;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Canonical keys for contracts tracked by this registry. Adding a new key
|
|
73
|
+
* here (and a corresponding entry per chain below) is not a breaking
|
|
74
|
+
* change for consumers that read the registry through {@link getContract}
|
|
75
|
+
* or {@link listContracts}.
|
|
76
|
+
*/
|
|
77
|
+
type PepuContractName = "create2Factory" | "multicall3" | "permit2" | "entryPoint06" | "entryPoint07" | "kernelFactory" | "kernelMetaFactory" | "ecdsaValidator" | "paymaster" | "kernelImplementation" | "kernelEcdsaSignerModule" | "kernelCallPolicyV004" | "kernelTimestampPolicy" | "tapScore" | "paymasterV1" | "paymasterV2";
|
|
78
|
+
/** A contract that is confirmed live on-chain at `address`. */
|
|
79
|
+
interface DeployedContract {
|
|
80
|
+
readonly status: "deployed";
|
|
81
|
+
/** Human-readable name, for logging/UI. */
|
|
82
|
+
readonly name: string;
|
|
83
|
+
/** Verified contract address. */
|
|
84
|
+
readonly address: Address;
|
|
85
|
+
/** Optional short note, e.g. how the address was verified. */
|
|
86
|
+
readonly notes?: string;
|
|
87
|
+
/**
|
|
88
|
+
* ISO date (YYYY-MM-DD) on which the address was last confirmed to have
|
|
89
|
+
* bytecode via `eth_getCode` against the PEPU mainnet RPC. Re-run
|
|
90
|
+
* `node packages/sdk/scripts/live-check.mjs` to refresh.
|
|
91
|
+
*/
|
|
92
|
+
readonly verifiedAt?: string;
|
|
93
|
+
/**
|
|
94
|
+
* True when the contract still has bytecode but must not be used (for example
|
|
95
|
+
* the v1 paymaster, whose EntryPoint deposit was withdrawn). Never route new
|
|
96
|
+
* work to a retired contract.
|
|
97
|
+
*/
|
|
98
|
+
readonly retired?: true;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* A contract that is not yet deployed on this chain. Deliberately has no
|
|
102
|
+
* `address` field — callers must not be able to accidentally read a
|
|
103
|
+
* placeholder value and treat it as real. Use {@link getContract} /
|
|
104
|
+
* {@link isDeployed} to narrow before reading an address.
|
|
105
|
+
*/
|
|
106
|
+
interface PendingContract {
|
|
107
|
+
readonly status: "pending";
|
|
108
|
+
/** Human-readable name, for logging/UI. */
|
|
109
|
+
readonly name: string;
|
|
110
|
+
/** Why this contract has no verified address yet. */
|
|
111
|
+
readonly reason: string;
|
|
112
|
+
}
|
|
113
|
+
type ContractEntry = DeployedContract | PendingContract;
|
|
114
|
+
/** Per-chain contract catalog, keyed by {@link PepuContractName}. */
|
|
115
|
+
type PepuContractRegistry = Readonly<Record<PepuContractName, ContractEntry>>;
|
|
116
|
+
/**
|
|
117
|
+
* Contract registry, keyed by chain id. Tracked as independent per-chain
|
|
118
|
+
* entries because deployments happen per-chain and have already diverged:
|
|
119
|
+
* mainnet has the CREATE2 deployer, a PEPU-specific Multicall3, the
|
|
120
|
+
* canonical Permit2, the full ZeroDev Kernel v3 AA stack (EntryPoint
|
|
121
|
+
* v0.6/v0.7, Kernel factory/meta-factory, ECDSA validator), and a
|
|
122
|
+
* project-deployed, funded verifying paymaster. Testnet has only the
|
|
123
|
+
* CREATE2 deployer — everything else is `status: "pending"` because
|
|
124
|
+
* testnet is out of scope for this package (no faucet exists to fund
|
|
125
|
+
* verification there).
|
|
126
|
+
*
|
|
127
|
+
* Note on the paymaster specifically: `status: "deployed"` here means the
|
|
128
|
+
* contract has live bytecode and a real EntryPoint deposit — it does NOT
|
|
129
|
+
* mean gas sponsorship is usable by an application. See
|
|
130
|
+
* `getSponsorshipStatus` in `./aa/status.js`, which is the single source of
|
|
131
|
+
* truth for that separate question.
|
|
132
|
+
*/
|
|
133
|
+
declare const pepuContracts: Readonly<Record<number, PepuContractRegistry>>;
|
|
134
|
+
/** Look up one contract entry for a chain id. Returns `undefined` if the chain isn't in the registry. */
|
|
135
|
+
declare function getContract(chainId: number, name: PepuContractName): ContractEntry | undefined;
|
|
136
|
+
/** List all tracked contract entries for a chain id, in registry order. */
|
|
137
|
+
declare function listContracts(chainId: number): readonly ContractEntry[];
|
|
138
|
+
/** Narrow a {@link ContractEntry} to {@link DeployedContract}. */
|
|
139
|
+
declare function isDeployed(entry: ContractEntry | undefined): entry is DeployedContract;
|
|
140
|
+
/** One row of the address table returned by {@link getPepuAddresses}. */
|
|
141
|
+
interface PepuAddressRow {
|
|
142
|
+
readonly key: PepuContractName;
|
|
143
|
+
readonly name: string;
|
|
144
|
+
readonly status: "deployed" | "pending";
|
|
145
|
+
/** Present only when `status` is `"deployed"`. */
|
|
146
|
+
readonly address?: Address;
|
|
147
|
+
/** ISO date of the last `eth_getCode` check, when known. */
|
|
148
|
+
readonly verifiedAt?: string;
|
|
149
|
+
/** True for a deployed contract that is retired and must not be used (the v1 paymaster). */
|
|
150
|
+
readonly retired?: true;
|
|
151
|
+
/** Notes (deployed) or reason (pending). */
|
|
152
|
+
readonly note: string;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* The full supporting-contract table for a chain, flattened for docs and
|
|
156
|
+
* MCP rendering. Pending entries carry no `address`.
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* ```ts
|
|
160
|
+
* const rows = getPepuAddresses(); // mainnet by default
|
|
161
|
+
* const live = rows.filter((r) => r.status === "deployed");
|
|
162
|
+
* ```
|
|
163
|
+
*/
|
|
164
|
+
declare function getPepuAddresses(chainId?: number): readonly PepuAddressRow[];
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* The account-abstraction contracts a Kernel v3 smart account needs,
|
|
168
|
+
* narrowed to their {@link DeployedContract} form for a given chain.
|
|
169
|
+
* Returns `undefined` if any one of them isn't deployed on that chain
|
|
170
|
+
* (today: everything except mainnet, `97741`) — this package never fabricates
|
|
171
|
+
* a partial/best-effort bundle.
|
|
172
|
+
*/
|
|
173
|
+
interface PepuKernelStack {
|
|
174
|
+
readonly entryPoint06: DeployedContract;
|
|
175
|
+
readonly entryPoint07: DeployedContract;
|
|
176
|
+
readonly kernelFactory: DeployedContract;
|
|
177
|
+
readonly kernelMetaFactory: DeployedContract;
|
|
178
|
+
readonly ecdsaValidator: DeployedContract;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Look up every AA contract this package knows about for `chainId`, already
|
|
182
|
+
* narrowed to {@link DeployedContract}. Returns `undefined` unless *all* five
|
|
183
|
+
* are deployed on that chain (today, only PEPU mainnet qualifies) — a caller
|
|
184
|
+
* building a Kernel account needs every one of them, so a partial result
|
|
185
|
+
* would just move the "is this actually usable" check into every caller.
|
|
186
|
+
*
|
|
187
|
+
* This is a convenience grouping over `getContract` from `./contracts.js`;
|
|
188
|
+
* it doesn't add any address or fact that registry doesn't already have.
|
|
189
|
+
*/
|
|
190
|
+
declare function getPepuKernelStack(chainId: number): PepuKernelStack | undefined;
|
|
191
|
+
/**
|
|
192
|
+
* Legacy static gas-sponsorship status for PEPU. **Always reports
|
|
193
|
+
* unavailable** (it never probes). Sponsorship is PROVEN end to end on PEPU
|
|
194
|
+
* mainnet through the hosted bundler and paymaster service (a zero-balance
|
|
195
|
+
* Kernel smart account transacted, paid for by the paymaster); use
|
|
196
|
+
* `checkSponsorship()` for the live answer. This function
|
|
197
|
+
* exists so nothing downstream (this package, `@pepu-chain/mcp`, an app)
|
|
198
|
+
* has to independently invent an "is sponsorship on?" check, and so that
|
|
199
|
+
* check can't silently start lying once this file changes.
|
|
200
|
+
*
|
|
201
|
+
* Do not treat the presence of `kernelFactory`/`ecdsaValidator`/`paymaster`
|
|
202
|
+
* addresses in {@link getPepuKernelStack} / the contract registry as
|
|
203
|
+
* sponsorship support — those let you build and deploy a Kernel account and
|
|
204
|
+
* send its UserOperations through a normal `eth_sendTransaction`-style flow
|
|
205
|
+
* (self-paying its own gas via the EntryPoint deposit), which is a real,
|
|
206
|
+
* working feature; sponsoring that gas needs a funded project or free-tier token.
|
|
207
|
+
*/
|
|
208
|
+
interface SponsorshipStatus {
|
|
209
|
+
readonly available: false;
|
|
210
|
+
readonly reason: string;
|
|
211
|
+
/**
|
|
212
|
+
* Extension point for a future bundler/paymaster integration. Passing a
|
|
213
|
+
* URL here does **not** make sponsorship available — `available` stays
|
|
214
|
+
* `false` regardless — this field only exists so a caller can start
|
|
215
|
+
* wiring a URL through their own config today and have this function
|
|
216
|
+
* start using it later without an API change.
|
|
217
|
+
*/
|
|
218
|
+
readonly bundlerUrl?: string;
|
|
219
|
+
}
|
|
220
|
+
/** Options for {@link getSponsorshipStatus}. */
|
|
221
|
+
interface GetSponsorshipStatusOptions {
|
|
222
|
+
/** See {@link SponsorshipStatus.bundlerUrl}. Not yet used for anything. */
|
|
223
|
+
readonly bundlerUrl?: string;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* @deprecated Always reports `available: false`. Use `checkSponsorship()` (live
|
|
227
|
+
* bundler and paymaster probe) from `@pepu-chain/sdk`. Kept for 0.1 callers.
|
|
228
|
+
*/
|
|
229
|
+
declare function getSponsorshipStatus(options?: GetSponsorshipStatusOptions): SponsorshipStatus;
|
|
230
|
+
/**
|
|
231
|
+
* Compute (or confirm) the counterfactual address of a Kernel v3 smart
|
|
232
|
+
* account via the verified factory's `getAddress(data, salt)` — a thin,
|
|
233
|
+
* typed pass-through, not a re-implementation.
|
|
234
|
+
*
|
|
235
|
+
* Deliberately does **not** build `data` (Kernel v3.1's `initialize(...)`
|
|
236
|
+
* calldata: root validator, hook, validator data, hook data, init config)
|
|
237
|
+
* for you. A hand-rolled encoding here would be a second, unverified copy of
|
|
238
|
+
* the byte layout that ZeroDev's SDK already produces (and that has been
|
|
239
|
+
* exercised against PEPU's factory through the sponsored-transaction run),
|
|
240
|
+
* which is exactly the kind of invented encoding this package's rules
|
|
241
|
+
* forbid for addresses. Build `data` with ZeroDev's
|
|
242
|
+
* `@zerodev/sdk` (or by hand from the public Kernel v3 contracts source),
|
|
243
|
+
* then pass the result here.
|
|
244
|
+
*/
|
|
245
|
+
declare function getKernelAccountAddress(client: PublicClient<Transport, PepuChain>, factory: Pick<DeployedContract, "address">, args: {
|
|
246
|
+
readonly data: Hex;
|
|
247
|
+
readonly salt: Hex;
|
|
248
|
+
}): Promise<Address>;
|
|
249
|
+
/** Live sponsorship report from {@link checkSponsorship}. */
|
|
250
|
+
interface SponsorshipReport {
|
|
251
|
+
/** True only when a bundler and a paymaster are configured and both answer. */
|
|
252
|
+
available: boolean;
|
|
253
|
+
/** `direct` when you bring your own bundler and paymaster URLs; `none` when nothing is configured. */
|
|
254
|
+
transport: "direct" | "none";
|
|
255
|
+
bundler: {
|
|
256
|
+
configured: boolean;
|
|
257
|
+
probe?: BundlerProbeResult;
|
|
258
|
+
};
|
|
259
|
+
paymaster: {
|
|
260
|
+
configured: boolean;
|
|
261
|
+
probe?: PaymasterProbeResult;
|
|
262
|
+
depositWei?: bigint;
|
|
263
|
+
};
|
|
264
|
+
/** One sentence for a human or an agent. */
|
|
265
|
+
reason: string;
|
|
266
|
+
/** Concrete next steps, empty when `available`. */
|
|
267
|
+
fixes: string[];
|
|
268
|
+
}
|
|
269
|
+
/** Options for {@link checkSponsorship}. */
|
|
270
|
+
interface CheckSponsorshipOptions {
|
|
271
|
+
bundlerUrl?: string;
|
|
272
|
+
paymasterUrl?: string;
|
|
273
|
+
env?: Record<string, string | undefined>;
|
|
274
|
+
fetch?: FetchLike;
|
|
275
|
+
/** When given, also read the paymaster's EntryPoint deposit. */
|
|
276
|
+
publicClient?: PublicClient;
|
|
277
|
+
/** Paymaster contract to read the deposit of. Defaults to PEPU's deployed paymaster. */
|
|
278
|
+
paymasterAddress?: Address;
|
|
279
|
+
timeoutMs?: number;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Live gas-sponsorship status. Resolves the bundler and paymaster URLs from
|
|
283
|
+
* options, env, then the hosted defaults (bundler.pepeunchained.com and the paymaster
|
|
284
|
+
* service base; with no token URL the service is probed at its base), probes both,
|
|
285
|
+
* and optionally reads the paymaster deposit. Never throws for an
|
|
286
|
+
* unreachable service; it reports `available: false` with `fixes`.
|
|
287
|
+
* Replaces the hard-coded {@link getSponsorshipStatus}.
|
|
288
|
+
*
|
|
289
|
+
* @example
|
|
290
|
+
* const s = await checkSponsorship({ publicClient });
|
|
291
|
+
* if (!s.available) console.log(s.reason, s.fixes);
|
|
292
|
+
*/
|
|
293
|
+
declare function checkSponsorship(options?: CheckSponsorshipOptions): Promise<SponsorshipReport>;
|
|
294
|
+
|
|
295
|
+
export { type BundlerProbeResult as B, type CheckSponsorshipOptions as C, type DeployedContract as D, type FetchLike as F, type GetSponsorshipStatusOptions as G, type PaymasterProbeResult as P, type SponsorshipReport as S, type PepuKernelStack as a, type ProbeOptions as b, type SponsorshipStatus as c, checkSponsorship as d, getPaymasterDeposit as e, getPepuKernelStack as f, getKernelAccountAddress as g, getSponsorshipStatus as h, probePaymaster as i, type ContractEntry as j, type PendingContract as k, type PepuAddressRow as l, type PepuContractName as m, type PepuContractRegistry as n, getContract as o, probeBundler as p, getPepuAddresses as q, isDeployed as r, listContracts as s, pepuContracts as t };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Address, Hex } from 'viem';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Server-side session records for the Kernel (on-chain) session flow, keyed by
|
|
5
|
+
* Privy user id. Ported from templates/sponsored-session-app/lib/session-store.ts.
|
|
6
|
+
*
|
|
7
|
+
* WHAT IS STORED: the session private key (a hot key whose power is limited
|
|
8
|
+
* ON-CHAIN by the call and timestamp policies until `validUntil`) and the
|
|
9
|
+
* public approval. The owner's key never reaches the server.
|
|
10
|
+
*
|
|
11
|
+
* PRODUCTION: {@link createMemoryStore} is DEV-GRADE. It is lost on every
|
|
12
|
+
* restart (the user simply starts a new session) and is not shared between
|
|
13
|
+
* serverless instances. A production deployment must implement
|
|
14
|
+
* {@link SessionStore} on a persistent database or KV AND keep
|
|
15
|
+
* `sessionPrivateKey` encrypted at rest (KMS or an envelope key). Nothing else
|
|
16
|
+
* in the SDK changes.
|
|
17
|
+
*/
|
|
18
|
+
interface SessionRecord {
|
|
19
|
+
userId: string;
|
|
20
|
+
ownerAddress: Address;
|
|
21
|
+
kernelAddress: Address;
|
|
22
|
+
/** The session key's private half. Encrypt it at rest in any persistent store. */
|
|
23
|
+
sessionPrivateKey: Hex;
|
|
24
|
+
sessionKeyAddress: Address;
|
|
25
|
+
permissionId: string;
|
|
26
|
+
/** Unix seconds. The on-chain permission is invalid at and after this time. */
|
|
27
|
+
validUntil: number;
|
|
28
|
+
/** Present once the owner has signed the grant. */
|
|
29
|
+
approval: string | null;
|
|
30
|
+
/** Number of successful sponsored actions in this session. */
|
|
31
|
+
actions: number;
|
|
32
|
+
}
|
|
33
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
34
|
+
/**
|
|
35
|
+
* Pluggable storage for {@link SessionRecord}s. Every method may be sync or
|
|
36
|
+
* async. `tryLock` must be atomic per user: it returns `false` when an action
|
|
37
|
+
* is already running for that user (a multi-instance deployment needs a
|
|
38
|
+
* distributed lock, for example a Redis `SET NX PX`).
|
|
39
|
+
*/
|
|
40
|
+
interface SessionStore {
|
|
41
|
+
get(userId: string): MaybePromise<SessionRecord | undefined>;
|
|
42
|
+
set(record: SessionRecord): MaybePromise<void>;
|
|
43
|
+
delete(userId: string): MaybePromise<void>;
|
|
44
|
+
tryLock(userId: string): MaybePromise<boolean>;
|
|
45
|
+
unlock(userId: string): MaybePromise<void>;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* An in-memory {@link SessionStore} for development and tests. DEV-GRADE: not
|
|
49
|
+
* persistent, not shared across instances, and the session key is held in
|
|
50
|
+
* plaintext in process memory. Production needs an encrypted persistent store.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* const store = createMemoryStore();
|
|
54
|
+
*/
|
|
55
|
+
declare function createMemoryStore(): SessionStore;
|
|
56
|
+
/**
|
|
57
|
+
* True while the on-chain permission is still valid: approved and before expiry.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* isLive(record, Math.floor(Date.now() / 1000));
|
|
61
|
+
*/
|
|
62
|
+
declare function isLive(record: SessionRecord, nowSeconds: number): boolean;
|
|
63
|
+
|
|
64
|
+
export { type SessionStore as S, type SessionRecord as a, createMemoryStore as c, isLive as i };
|