@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,654 @@
|
|
|
1
|
+
import { Address, Hex, WalletClient, Account, Chain, PublicClient, Hash } from 'viem';
|
|
2
|
+
|
|
3
|
+
/** A transaction a wallet (or smart account batch) can send. */
|
|
4
|
+
interface PaymasterCall {
|
|
5
|
+
to: Address;
|
|
6
|
+
data: Hex;
|
|
7
|
+
value: bigint;
|
|
8
|
+
/** Solidity signature, for logs and UIs. */
|
|
9
|
+
function: string;
|
|
10
|
+
}
|
|
11
|
+
/** The EIP-712 `ProjectClaim` attestation returned by `POST /v2/projects/verify`. */
|
|
12
|
+
interface ProjectClaimAttestation {
|
|
13
|
+
appId: string;
|
|
14
|
+
newOwner: Address;
|
|
15
|
+
nonce: string | bigint;
|
|
16
|
+
deadline: string | bigint;
|
|
17
|
+
signature: Hex;
|
|
18
|
+
}
|
|
19
|
+
interface PaymasterAddressOption {
|
|
20
|
+
/** v2 paymaster address. Defaults to the registry's `paymasterV2` entry once it is deployed. */
|
|
21
|
+
paymaster?: Address | undefined;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Resolve the v2 paymaster address: explicit option first, then the registry. Throws
|
|
25
|
+
* `CONFIG_MISSING_ENV` (never guesses an address) when neither is available.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* const paymaster = resolvePaymasterV2Address("0x1111111111111111111111111111111111111111");
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
declare function resolvePaymasterV2Address(explicit?: Address): Address;
|
|
33
|
+
/**
|
|
34
|
+
* `projectId = keccak256(bytes(appId))`. The app id is used exactly as given, so it is case-sensitive:
|
|
35
|
+
* Privy app ids are lower-case cuids, and a different case is a different project.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* const projectId = computeProjectId("clx0example0app0id");
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
declare function computeProjectId(appId: string): Hex;
|
|
43
|
+
/** Plan name for {@link computeProjectId}. */
|
|
44
|
+
declare const getProjectId: typeof computeProjectId;
|
|
45
|
+
/** State of a project, read from the paymaster contract. */
|
|
46
|
+
interface ProjectState {
|
|
47
|
+
projectId: Hex;
|
|
48
|
+
paymaster: Address;
|
|
49
|
+
/** `null` when unclaimed. */
|
|
50
|
+
owner: Address | null;
|
|
51
|
+
claimed: boolean;
|
|
52
|
+
paused: boolean;
|
|
53
|
+
/** Deposited, unspent wei. Deposit-only: this can only be spent as gas, never withdrawn. */
|
|
54
|
+
balance: bigint;
|
|
55
|
+
dailyLimit: bigint;
|
|
56
|
+
senderDailyLimit: bigint;
|
|
57
|
+
/** Spent in the current UTC day (0 when the stored day is stale). */
|
|
58
|
+
spentToday: bigint;
|
|
59
|
+
/** Day index (unix seconds / 86400) the stored `spentToday` belongs to. */
|
|
60
|
+
spentDay: number;
|
|
61
|
+
/** True when claimed and both limits are set. Targets are checked via `targetsAllowed`. */
|
|
62
|
+
limitsConfigured: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Pending timelocked claim, or `null`: a re-claim of an owned project, or (when `claimed` is false) the first
|
|
65
|
+
* claim of a project that already holds funds. Finish it with {@link encodeExecuteReclaim} after `executableAt`.
|
|
66
|
+
*/
|
|
67
|
+
pendingReclaim: {
|
|
68
|
+
newOwner: Address;
|
|
69
|
+
executableAt: number;
|
|
70
|
+
signer: Address;
|
|
71
|
+
} | null;
|
|
72
|
+
/** Address proposed in a two-step ownership transfer, or `null`. */
|
|
73
|
+
pendingOwner: Address | null;
|
|
74
|
+
/** Present when `checkTargets` was passed: allowed flag per address (checksummed keys). */
|
|
75
|
+
targetsAllowed?: Record<Address, boolean>;
|
|
76
|
+
}
|
|
77
|
+
interface ReadProjectOptions extends PaymasterAddressOption {
|
|
78
|
+
/** Also check these destinations against the on-chain allowlist (one `isTargetAllowed` read each). */
|
|
79
|
+
checkTargets?: readonly Address[];
|
|
80
|
+
/** Clock override for the day rollover (tests). Milliseconds. */
|
|
81
|
+
now?: () => number;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Read a project's on-chain state: owner, pause flag, balance, limits, pending re-claim and pending owner.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```ts
|
|
88
|
+
* const p = await readProject(publicClient, computeProjectId(appId), { paymaster });
|
|
89
|
+
* if (!p.claimed) console.log("claim it first");
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
declare function readProject(client: Pick<PublicClient, "readContract">, projectId: Hex, options?: ReadProjectOptions): Promise<ProjectState>;
|
|
93
|
+
/**
|
|
94
|
+
* Encode `depositFor(projectId)` with native PEPU as `value`. ONE-WAY: nothing can ever withdraw the deposit,
|
|
95
|
+
* and the id is `keccak256` of a case-sensitive app id, so a typo deposits into a project nobody can claim.
|
|
96
|
+
* Prefer {@link depositFor}, which checks the project is claimed first.
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```ts
|
|
100
|
+
* const tx = encodeDeposit(computeProjectId(appId), 10n ** 18n, { paymaster });
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
declare function encodeDeposit(projectId: Hex, amountWei: bigint, options?: PaymasterAddressOption): PaymasterCall;
|
|
104
|
+
/**
|
|
105
|
+
* Encode `claimProject(Claim)`. The attestation fixes the owner; anyone may submit the transaction. The claim
|
|
106
|
+
* sets ONLY the owner: follow with {@link configureProject}'s three calls, because nothing is sponsorable
|
|
107
|
+
* until `setTargets`, `setDailyLimit` and `setSenderDailyLimit` have run. If the project already holds deposited
|
|
108
|
+
* funds the claim is PENDING for the on-chain admin change delay (>= 48h): the contract owner or manager can cancel
|
|
109
|
+
* it, and anyone finishes it with {@link encodeExecuteReclaim}.
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```ts
|
|
113
|
+
* const tx = encodeClaimProject(attestation, { paymaster });
|
|
114
|
+
* await walletClient.sendTransaction({ to: tx.to, data: tx.data });
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
declare function encodeClaimProject(attestation: ProjectClaimAttestation, options?: PaymasterAddressOption): PaymasterCall;
|
|
118
|
+
/**
|
|
119
|
+
* Encode `reclaimProject(Claim)`: a timelocked (>= 48h) re-claim of an already-owned project. The current owner
|
|
120
|
+
* can cancel it ({@link encodeCancelReclaim}); anyone can finish it after the delay ({@link encodeExecuteReclaim}).
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```ts
|
|
124
|
+
* const tx = encodeReclaimProject(attestation, { paymaster });
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
declare function encodeReclaimProject(attestation: ProjectClaimAttestation, options?: PaymasterAddressOption): PaymasterCall;
|
|
128
|
+
/**
|
|
129
|
+
* Pick `claimProject` or `reclaimProject` from a `/v2/projects/verify` result (its `action` field) and encode it.
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* ```ts
|
|
133
|
+
* const tx = encodeClaimFromVerification(verified, { paymaster });
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
declare function encodeClaimFromVerification(verified: {
|
|
137
|
+
action: "claimProject" | "reclaimProject";
|
|
138
|
+
attestation: ProjectClaimAttestation;
|
|
139
|
+
}, options?: PaymasterAddressOption): PaymasterCall;
|
|
140
|
+
/**
|
|
141
|
+
* Encode `executeReclaim(projectId)`: completes a pending claim or re-claim once its delay has passed (and before it
|
|
142
|
+
* expires, 30 days later).
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* ```ts
|
|
146
|
+
* const tx = encodeExecuteReclaim(projectId, { paymaster });
|
|
147
|
+
* ```
|
|
148
|
+
*/
|
|
149
|
+
declare function encodeExecuteReclaim(projectId: Hex, options?: PaymasterAddressOption): PaymasterCall;
|
|
150
|
+
/**
|
|
151
|
+
* Encode `cancelReclaim(projectId)`: the current owner cancels a pending re-claim, ONCE per new owner (a second
|
|
152
|
+
* attested re-claim by the same new owner cannot be cancelled). For a pending FIRST claim of an unowned project the
|
|
153
|
+
* contract owner or manager cancels instead.
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* ```ts
|
|
157
|
+
* const tx = encodeCancelReclaim(projectId, { paymaster });
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
160
|
+
declare function encodeCancelReclaim(projectId: Hex, options?: PaymasterAddressOption): PaymasterCall;
|
|
161
|
+
/**
|
|
162
|
+
* Encode `setTargets(projectId, targets, allowed)`: add or remove destination contracts the project sponsors
|
|
163
|
+
* (at most 50 per call). Owner only.
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* ```ts
|
|
167
|
+
* const tx = encodeSetTargets(projectId, [counter], true, { paymaster });
|
|
168
|
+
* ```
|
|
169
|
+
*/
|
|
170
|
+
declare function encodeSetTargets(projectId: Hex, targets: readonly Address[], allowed: boolean, options?: PaymasterAddressOption): PaymasterCall;
|
|
171
|
+
/**
|
|
172
|
+
* Encode `setDailyLimit(projectId, limitWei)`: the project's total daily gas budget. Owner only. Must be above
|
|
173
|
+
* zero; a contract-side zero limit means nothing can be spent, and tightening is instant.
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* ```ts
|
|
177
|
+
* const tx = encodeSetDailyLimit(projectId, 5n * 10n ** 18n, { paymaster });
|
|
178
|
+
* ```
|
|
179
|
+
*/
|
|
180
|
+
declare function encodeSetDailyLimit(projectId: Hex, limitWei: bigint, options?: PaymasterAddressOption): PaymasterCall;
|
|
181
|
+
/**
|
|
182
|
+
* Encode `setSenderDailyLimit(projectId, limitWei)`: the per-wallet daily gas limit. Owner only.
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* ```ts
|
|
186
|
+
* const tx = encodeSetSenderDailyLimit(projectId, 10n ** 17n, { paymaster });
|
|
187
|
+
* ```
|
|
188
|
+
*/
|
|
189
|
+
declare function encodeSetSenderDailyLimit(projectId: Hex, limitWei: bigint, options?: PaymasterAddressOption): PaymasterCall;
|
|
190
|
+
/**
|
|
191
|
+
* Encode `setPaused(projectId, paused)`. Pausing takes effect immediately; it is the project's emergency stop.
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* ```ts
|
|
195
|
+
* const stop = encodeSetPaused(projectId, true, { paymaster });
|
|
196
|
+
* ```
|
|
197
|
+
*/
|
|
198
|
+
declare function encodeSetPaused(projectId: Hex, paused: boolean, options?: PaymasterAddressOption): PaymasterCall;
|
|
199
|
+
/**
|
|
200
|
+
* Encode `proposeProjectOwner(projectId, newOwner)`: step one of the two-step ownership transfer. The new
|
|
201
|
+
* owner must then call {@link encodeAcceptProjectOwnership}.
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
* ```ts
|
|
205
|
+
* const tx = encodeProposeProjectOwner(projectId, newOwner, { paymaster });
|
|
206
|
+
* ```
|
|
207
|
+
*/
|
|
208
|
+
declare function encodeProposeProjectOwner(projectId: Hex, newOwner: Address, options?: PaymasterAddressOption): PaymasterCall;
|
|
209
|
+
/**
|
|
210
|
+
* Encode `acceptProjectOwnership(projectId)`: step two of the ownership transfer, sent by the proposed owner.
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* ```ts
|
|
214
|
+
* const tx = encodeAcceptProjectOwnership(projectId, { paymaster });
|
|
215
|
+
* ```
|
|
216
|
+
*/
|
|
217
|
+
declare function encodeAcceptProjectOwnership(projectId: Hex, options?: PaymasterAddressOption): PaymasterCall;
|
|
218
|
+
interface ConfigureProjectParams extends PaymasterAddressOption {
|
|
219
|
+
/** Give `appId` or `projectId`. */
|
|
220
|
+
appId?: string;
|
|
221
|
+
projectId?: Hex;
|
|
222
|
+
/** Destination contracts to sponsor (the on-chain allowlist). 1 to 50. */
|
|
223
|
+
targets: readonly Address[];
|
|
224
|
+
/** Total daily budget, wei. */
|
|
225
|
+
dailyLimitWei: bigint;
|
|
226
|
+
/** Per-wallet daily budget, wei. */
|
|
227
|
+
senderDailyLimitWei: bigint;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* The three post-claim configuration calls, in order: `setTargets(allowed = true)`, `setDailyLimit`,
|
|
231
|
+
* `setSenderDailyLimit`. A project spends nothing until all three have run. All three are owner-only calls to
|
|
232
|
+
* the same contract, so a smart account or batched wallet can send them in one transaction; an EOA sends them
|
|
233
|
+
* one after another with {@link sendPaymasterCalls}.
|
|
234
|
+
*
|
|
235
|
+
* @example
|
|
236
|
+
* ```ts
|
|
237
|
+
* const { calls } = configureProject({
|
|
238
|
+
* appId, paymaster,
|
|
239
|
+
* targets: [counter],
|
|
240
|
+
* dailyLimitWei: 5n * 10n ** 18n,
|
|
241
|
+
* senderDailyLimitWei: 10n ** 17n,
|
|
242
|
+
* });
|
|
243
|
+
* await smartAccountClient.sendUserOperation({ calls: calls.map(({ to, data, value }) => ({ to, data, value })) });
|
|
244
|
+
* ```
|
|
245
|
+
*/
|
|
246
|
+
declare function configureProject(params: ConfigureProjectParams): {
|
|
247
|
+
projectId: Hex;
|
|
248
|
+
calls: PaymasterCall[];
|
|
249
|
+
};
|
|
250
|
+
type SendingWallet = Pick<WalletClient, "sendTransaction"> & {
|
|
251
|
+
account?: Account | undefined;
|
|
252
|
+
chain?: Chain | undefined;
|
|
253
|
+
};
|
|
254
|
+
/**
|
|
255
|
+
* Send prepared calls one after another from a wallet client, returning the hashes. When `publicClient` is
|
|
256
|
+
* given it waits for each receipt first (so a later call is not sent after an earlier one failed). The
|
|
257
|
+
* transaction `value` is exactly the call's value; nothing else is added.
|
|
258
|
+
*
|
|
259
|
+
* @example
|
|
260
|
+
* ```ts
|
|
261
|
+
* const hashes = await sendPaymasterCalls(walletClient, calls, { publicClient });
|
|
262
|
+
* ```
|
|
263
|
+
*/
|
|
264
|
+
declare function sendPaymasterCalls(walletClient: SendingWallet, calls: readonly PaymasterCall[], options?: {
|
|
265
|
+
publicClient?: Pick<PublicClient, "waitForTransactionReceipt">;
|
|
266
|
+
}): Promise<Hash[]>;
|
|
267
|
+
interface DepositForParams extends PaymasterAddressOption {
|
|
268
|
+
walletClient: SendingWallet;
|
|
269
|
+
/** Give `appId` or `projectId`. */
|
|
270
|
+
appId?: string;
|
|
271
|
+
projectId?: Hex;
|
|
272
|
+
amountWei: bigint;
|
|
273
|
+
/**
|
|
274
|
+
* Default true: read the project first and refuse when it has no owner, which catches a mistyped (case-sensitive)
|
|
275
|
+
* app id before funds go to a project nobody controls. Needs `publicClient`. Pass false to fund a project its
|
|
276
|
+
* owner has not claimed yet (deposits are credited and become spendable after the claim and configuration).
|
|
277
|
+
*/
|
|
278
|
+
requireClaimed?: boolean;
|
|
279
|
+
publicClient?: Pick<PublicClient, "readContract">;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Deposit native PEPU into a project with the caller's wallet. ONE-WAY: nobody can withdraw it afterwards, and
|
|
283
|
+
* anyone may deposit into any project. By default it first confirms the project is claimed.
|
|
284
|
+
*
|
|
285
|
+
* @example
|
|
286
|
+
* ```ts
|
|
287
|
+
* const hash = await depositFor({ walletClient, publicClient, appId, amountWei: 10n ** 18n, paymaster });
|
|
288
|
+
* ```
|
|
289
|
+
*/
|
|
290
|
+
declare function depositFor(params: DepositForParams): Promise<Hash>;
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* REST client for the PEPU paymaster policy service: v1 (`/sponsor`, ERC-7677 at `/paymaster/<token>`) and
|
|
294
|
+
* v2 (`/v2/*`, tiered, on-chain projects). Isomorphic (plain `fetch`), so it is safe in a browser EXCEPT for
|
|
295
|
+
* the claim attestation call that carries a Privy app secret, which lives in `@pepu-chain/sdk/paymaster/server`.
|
|
296
|
+
*
|
|
297
|
+
* Contract: services/paymaster/policy-service/openapi.yaml and SPONSORSHIP-SPEC.md. Credentials: a server key
|
|
298
|
+
* (`ppk_...`, secret, any wallet) and a client token (`ppt_...`, publishable, bound to allowed origins).
|
|
299
|
+
*/
|
|
300
|
+
/** A quantity as the service accepts it: `0x` hex or bigint (converted for you). */
|
|
301
|
+
type Quantity = Hex | bigint;
|
|
302
|
+
/** The UserOperation fields `POST /sponsor` and `POST /v2/sponsor` read (EntryPoint v0.7, unpacked). */
|
|
303
|
+
interface SponsorUserOp {
|
|
304
|
+
sender: Address;
|
|
305
|
+
nonce: Quantity;
|
|
306
|
+
factory?: Address;
|
|
307
|
+
factoryData?: Hex;
|
|
308
|
+
callData: Hex;
|
|
309
|
+
callGasLimit: Quantity;
|
|
310
|
+
verificationGasLimit: Quantity;
|
|
311
|
+
preVerificationGas: Quantity;
|
|
312
|
+
maxFeePerGas: Quantity;
|
|
313
|
+
maxPriorityFeePerGas: Quantity;
|
|
314
|
+
}
|
|
315
|
+
interface SponsorApproval {
|
|
316
|
+
status: "approved";
|
|
317
|
+
chainId: number;
|
|
318
|
+
paymaster: Address;
|
|
319
|
+
paymasterVerificationGasLimit: Hex;
|
|
320
|
+
paymasterPostOpGasLimit: Hex;
|
|
321
|
+
paymasterData: Hex;
|
|
322
|
+
validUntil: number;
|
|
323
|
+
validAfter: number;
|
|
324
|
+
/** EntryPoint's canonical userOpHash. */
|
|
325
|
+
userOpHash: Hex;
|
|
326
|
+
/** v2 only. */
|
|
327
|
+
sponsor?: {
|
|
328
|
+
kind: "project" | "free";
|
|
329
|
+
sponsorId: Hex;
|
|
330
|
+
projectKey: string;
|
|
331
|
+
};
|
|
332
|
+
/** v2 only: worst-case cost, decimal wei. */
|
|
333
|
+
maxCostWei?: string;
|
|
334
|
+
}
|
|
335
|
+
interface SponsorDenial {
|
|
336
|
+
status: "denied";
|
|
337
|
+
/** Machine-readable reason, see {@link PAYMASTER_DENIAL_REASONS}. */
|
|
338
|
+
reason: string;
|
|
339
|
+
message: string;
|
|
340
|
+
/** v2: per-tier reasons when both tiers were tried. */
|
|
341
|
+
detail?: {
|
|
342
|
+
project?: string;
|
|
343
|
+
free?: string;
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
type SponsorResult = SponsorApproval | SponsorDenial;
|
|
347
|
+
/** Credentials for a sponsor call. */
|
|
348
|
+
interface SponsorAuth {
|
|
349
|
+
/** The project's server key (`ppk_`) or client token (`ppt_`). Sent as `X-Api-Key`. */
|
|
350
|
+
apiKey: string;
|
|
351
|
+
/** The user's Privy access token. REQUIRED by v1 and by the v2 free tier. Sent as `Authorization: Bearer`. */
|
|
352
|
+
privyAccessToken?: string;
|
|
353
|
+
/** Origin header, for server-side calls with a client token (browsers set it themselves). */
|
|
354
|
+
origin?: string;
|
|
355
|
+
}
|
|
356
|
+
interface V2LoginResult {
|
|
357
|
+
token: string;
|
|
358
|
+
address: Address;
|
|
359
|
+
/** ISO timestamp. */
|
|
360
|
+
expiresAt: string;
|
|
361
|
+
}
|
|
362
|
+
type V2ConfigResponse = Record<string, unknown>;
|
|
363
|
+
type V2FreeTierInfo = Record<string, unknown>;
|
|
364
|
+
interface V2ContractInfo {
|
|
365
|
+
address: Address;
|
|
366
|
+
chainId: number;
|
|
367
|
+
entryPoint: Address;
|
|
368
|
+
abi: readonly unknown[];
|
|
369
|
+
}
|
|
370
|
+
/** `POST /v2/projects/prepare` response: a transaction for the owner's wallet to send. */
|
|
371
|
+
interface PreparedTx {
|
|
372
|
+
chainId: number;
|
|
373
|
+
to: Address;
|
|
374
|
+
data: Hex;
|
|
375
|
+
/** Decimal wei string. */
|
|
376
|
+
value: string;
|
|
377
|
+
function: string;
|
|
378
|
+
description: string;
|
|
379
|
+
}
|
|
380
|
+
type Wei = string;
|
|
381
|
+
type Bytes32 = Hex;
|
|
382
|
+
/** Body of `POST /v2/projects/prepare`. */
|
|
383
|
+
type PrepareRequest = {
|
|
384
|
+
action: "claimProject" | "reclaimProject";
|
|
385
|
+
attestation: SerializedAttestation;
|
|
386
|
+
} | {
|
|
387
|
+
action: "depositFor";
|
|
388
|
+
projectId: Bytes32;
|
|
389
|
+
amountWei: Wei;
|
|
390
|
+
} | {
|
|
391
|
+
action: "executeReclaim" | "cancelReclaim" | "acceptProjectOwnership";
|
|
392
|
+
projectId: Bytes32;
|
|
393
|
+
} | {
|
|
394
|
+
action: "setTargets";
|
|
395
|
+
projectId: Bytes32;
|
|
396
|
+
targets: Address[];
|
|
397
|
+
allowed: boolean;
|
|
398
|
+
} | {
|
|
399
|
+
action: "setDailyLimit" | "setSenderDailyLimit";
|
|
400
|
+
projectId: Bytes32;
|
|
401
|
+
limitWei: Wei;
|
|
402
|
+
} | {
|
|
403
|
+
action: "setPaused";
|
|
404
|
+
projectId: Bytes32;
|
|
405
|
+
paused: boolean;
|
|
406
|
+
} | {
|
|
407
|
+
action: "proposeProjectOwner";
|
|
408
|
+
projectId: Bytes32;
|
|
409
|
+
newOwner: Address;
|
|
410
|
+
};
|
|
411
|
+
/** Attestation in the service's wire format (decimal strings). */
|
|
412
|
+
interface SerializedAttestation {
|
|
413
|
+
appId: string;
|
|
414
|
+
newOwner: Address;
|
|
415
|
+
nonce: string;
|
|
416
|
+
deadline: string;
|
|
417
|
+
signature: Hex;
|
|
418
|
+
}
|
|
419
|
+
interface RegisterProjectRequest {
|
|
420
|
+
/** Give `projectId` or `appId` (the id is keccak256(appId)). */
|
|
421
|
+
projectId?: Bytes32;
|
|
422
|
+
appId?: string;
|
|
423
|
+
perUserDailyCapWei?: Wei;
|
|
424
|
+
/** Opt in: refuse wallets without a verified Privy token. Default false (any wallet). */
|
|
425
|
+
requireIdentity?: boolean;
|
|
426
|
+
/** Plain origins (scheme://host[:port], http only for localhost). Max 20. None means server-key only. */
|
|
427
|
+
allowedOrigins?: string[];
|
|
428
|
+
}
|
|
429
|
+
interface RegisterProjectResponse {
|
|
430
|
+
/** Publishable client token (`ppt_...`), shown once. */
|
|
431
|
+
token: string;
|
|
432
|
+
/** ERC-7677 URL embedding the client token. */
|
|
433
|
+
paymasterUrl: string;
|
|
434
|
+
/** SECRET server key (`ppk_...`), shown once. Backend only. */
|
|
435
|
+
serverKey?: string;
|
|
436
|
+
}
|
|
437
|
+
interface ProjectSettings {
|
|
438
|
+
perUserDailyCapWei?: Wei;
|
|
439
|
+
requireIdentity?: boolean;
|
|
440
|
+
allowedOrigins?: string[];
|
|
441
|
+
}
|
|
442
|
+
interface ProjectDetail {
|
|
443
|
+
projectId: Bytes32;
|
|
444
|
+
appId: string | null;
|
|
445
|
+
indexed: boolean;
|
|
446
|
+
owner: Address;
|
|
447
|
+
onchain: {
|
|
448
|
+
balance: Wei;
|
|
449
|
+
spendable: Wei;
|
|
450
|
+
outstandingApprovals: Wei;
|
|
451
|
+
paused: boolean;
|
|
452
|
+
dailyLimit: Wei;
|
|
453
|
+
senderDailyLimit: Wei;
|
|
454
|
+
spentToday: Wei;
|
|
455
|
+
dailyRemaining: Wei;
|
|
456
|
+
};
|
|
457
|
+
adminChangeDelaySeconds: number | null;
|
|
458
|
+
allowlist: Address[] | null;
|
|
459
|
+
offchain: Record<string, unknown> | null;
|
|
460
|
+
usage24h: {
|
|
461
|
+
ops: number;
|
|
462
|
+
projectFundedWei: Wei;
|
|
463
|
+
freeTierFundedWei: Wei;
|
|
464
|
+
} | null;
|
|
465
|
+
contract: {
|
|
466
|
+
address: Address;
|
|
467
|
+
chainId: number;
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
/** Options for the low-level request escape hatch. */
|
|
471
|
+
interface V2RequestOptions {
|
|
472
|
+
body?: unknown;
|
|
473
|
+
query?: Record<string, string | number | undefined>;
|
|
474
|
+
/** Send the stored SIWE session as a bearer token. Default false. */
|
|
475
|
+
session?: boolean;
|
|
476
|
+
/**
|
|
477
|
+
* Never put the service's message into thrown errors (only the HTTP status and error code). Set for calls whose
|
|
478
|
+
* request body holds a secret.
|
|
479
|
+
*/
|
|
480
|
+
quietErrors?: boolean;
|
|
481
|
+
}
|
|
482
|
+
interface CreatePaymasterApiOptions {
|
|
483
|
+
/**
|
|
484
|
+
* Policy-service base URL (no trailing path). Defaults to `PEPU_PAYMASTER_URL` /
|
|
485
|
+
* `NEXT_PUBLIC_PEPU_PAYMASTER_URL`, then the hosted default once it exists.
|
|
486
|
+
*/
|
|
487
|
+
baseUrl?: string;
|
|
488
|
+
/** Fetch implementation (tests, custom agents). Defaults to global `fetch`. */
|
|
489
|
+
fetch?: typeof fetch;
|
|
490
|
+
/** Environment for URL resolution. Defaults to `process.env`. */
|
|
491
|
+
env?: Record<string, string | undefined>;
|
|
492
|
+
/** Request timeout in milliseconds. Default 15000. */
|
|
493
|
+
timeoutMs?: number;
|
|
494
|
+
/** Start with an existing SIWE session token. */
|
|
495
|
+
sessionToken?: string;
|
|
496
|
+
}
|
|
497
|
+
interface PaymasterApiV1 {
|
|
498
|
+
/** `POST /sponsor`. Needs the user's Privy access token and the app API key. */
|
|
499
|
+
sponsor(userOp: SponsorUserOp, auth: SponsorAuth): Promise<SponsorResult>;
|
|
500
|
+
/** `GET /health`. */
|
|
501
|
+
health(): Promise<{
|
|
502
|
+
status: string;
|
|
503
|
+
}>;
|
|
504
|
+
/** ERC-7677 URL for this service (`<base>/paymaster/<token>`). */
|
|
505
|
+
erc7677Url(appToken: string): string;
|
|
506
|
+
}
|
|
507
|
+
interface PaymasterApiV2 {
|
|
508
|
+
/** `POST /v2/sponsor`. Denials are returned (not thrown); use {@link assertApproved}. */
|
|
509
|
+
sponsor(userOp: SponsorUserOp, auth: SponsorAuth): Promise<SponsorResult>;
|
|
510
|
+
/** ERC-7677 URL for this service (`<base>/v2/paymaster/<token>`). */
|
|
511
|
+
erc7677Url(appToken: string): string;
|
|
512
|
+
config(): Promise<V2ConfigResponse>;
|
|
513
|
+
contract(): Promise<V2ContractInfo>;
|
|
514
|
+
freeTier(): Promise<V2FreeTierInfo>;
|
|
515
|
+
auth: {
|
|
516
|
+
nonce(): Promise<{
|
|
517
|
+
nonce: string;
|
|
518
|
+
expiresAt: string;
|
|
519
|
+
}>;
|
|
520
|
+
/** Stores the returned session token on this client. */
|
|
521
|
+
login(message: string, signature: Hex): Promise<V2LoginResult>;
|
|
522
|
+
logout(): Promise<void>;
|
|
523
|
+
};
|
|
524
|
+
/** `GET /v2/me`: the session address. */
|
|
525
|
+
me(): Promise<{
|
|
526
|
+
address: Address;
|
|
527
|
+
}>;
|
|
528
|
+
/**
|
|
529
|
+
* Full SIWE sign-in: nonce, EIP-4361 message, your signature, login. The session lasts 1 hour and is stored
|
|
530
|
+
* on this client.
|
|
531
|
+
*/
|
|
532
|
+
loginWithWallet(sign: (message: string) => Promise<Hex>, o: LoginWithWalletOptions): Promise<V2LoginResult>;
|
|
533
|
+
/** Current session token, if signed in. */
|
|
534
|
+
getSessionToken(): string | null;
|
|
535
|
+
setSessionToken(token: string | null): void;
|
|
536
|
+
projects: {
|
|
537
|
+
/** `POST /v2/projects/prepare`: calldata for the owner's wallet. Sends nothing. */
|
|
538
|
+
prepare(request: PrepareRequest): Promise<PreparedTx>;
|
|
539
|
+
/** `POST /v2/projects`: index a claimed project and get its credentials. */
|
|
540
|
+
register(request: RegisterProjectRequest): Promise<RegisterProjectResponse>;
|
|
541
|
+
list(): Promise<{
|
|
542
|
+
projects: unknown[];
|
|
543
|
+
onchainUnindexed?: unknown[];
|
|
544
|
+
}>;
|
|
545
|
+
get(projectId: Hex): Promise<ProjectDetail>;
|
|
546
|
+
rotateClientToken(projectId: Hex): Promise<{
|
|
547
|
+
token: string;
|
|
548
|
+
paymasterUrl: string;
|
|
549
|
+
note?: string;
|
|
550
|
+
}>;
|
|
551
|
+
rotateServerKey(projectId: Hex): Promise<{
|
|
552
|
+
serverKey: string;
|
|
553
|
+
note?: string;
|
|
554
|
+
}>;
|
|
555
|
+
updateSettings(projectId: Hex, settings: ProjectSettings): Promise<Record<string, unknown>>;
|
|
556
|
+
usage(projectId: Hex, q?: {
|
|
557
|
+
limit?: number;
|
|
558
|
+
before?: number;
|
|
559
|
+
}): Promise<Record<string, unknown>>;
|
|
560
|
+
events(projectId: Hex, q?: {
|
|
561
|
+
fromBlock?: number;
|
|
562
|
+
limit?: number;
|
|
563
|
+
}): Promise<{
|
|
564
|
+
projectId: Hex;
|
|
565
|
+
events: unknown[];
|
|
566
|
+
}>;
|
|
567
|
+
allowlist(projectId: Hex): Promise<{
|
|
568
|
+
projectId: Hex;
|
|
569
|
+
source: string;
|
|
570
|
+
targets: Address[];
|
|
571
|
+
}>;
|
|
572
|
+
};
|
|
573
|
+
/**
|
|
574
|
+
* Low-level call to any `/v2` path, with the same error mapping. Used by `@pepu-chain/sdk/paymaster/server`
|
|
575
|
+
* for `POST /v2/projects/verify`. Prefer the typed methods.
|
|
576
|
+
*/
|
|
577
|
+
request<T>(method: "GET" | "POST" | "PATCH", path: string, options?: V2RequestOptions): Promise<T>;
|
|
578
|
+
}
|
|
579
|
+
interface PaymasterApi {
|
|
580
|
+
/** Resolved base URL, no trailing slash. */
|
|
581
|
+
readonly baseUrl: string;
|
|
582
|
+
v1: PaymasterApiV1;
|
|
583
|
+
v2: PaymasterApiV2;
|
|
584
|
+
}
|
|
585
|
+
interface LoginWithWalletOptions {
|
|
586
|
+
/** The signing wallet's address. */
|
|
587
|
+
address: Address;
|
|
588
|
+
/** SIWE domain; must be one of the service's `SIWE_DOMAINS` (for example `app.example.com`). */
|
|
589
|
+
domain: string;
|
|
590
|
+
/** SIWE `uri`. Default `https://<domain>`. */
|
|
591
|
+
uri?: string;
|
|
592
|
+
/** Chain id in the message. Default 97741. */
|
|
593
|
+
chainId?: number;
|
|
594
|
+
statement?: string;
|
|
595
|
+
/** Message lifetime in seconds (service maximum is 600 by default). Default 300. */
|
|
596
|
+
lifetimeSeconds?: number;
|
|
597
|
+
now?: () => number;
|
|
598
|
+
}
|
|
599
|
+
/** `"client"` for `ppt_` tokens, `"server"` for `ppk_` keys, otherwise `null`. Never inspects beyond the prefix. */
|
|
600
|
+
declare function credentialKind(credential: string): "client" | "server" | null;
|
|
601
|
+
interface BuildErc7677UrlOptions {
|
|
602
|
+
/** Policy-service base URL. */
|
|
603
|
+
baseUrl: string;
|
|
604
|
+
/** Client token (`ppt_`, browser-safe) or server key (`ppk_`, secret). */
|
|
605
|
+
token: string;
|
|
606
|
+
/** Default 2. v1 serves `/paymaster/<token>`, v2 serves `/v2/paymaster/<token>`. */
|
|
607
|
+
version?: 1 | 2;
|
|
608
|
+
}
|
|
609
|
+
/**
|
|
610
|
+
* Build the ERC-7677 paymaster URL for a project credential (paste it into a Privy "Paymaster URL" or pass it
|
|
611
|
+
* to a viem paymaster client). Refuses a server key (`ppk_`) in a browser, because the URL embeds it.
|
|
612
|
+
*
|
|
613
|
+
* @example
|
|
614
|
+
* ```ts
|
|
615
|
+
* const url = buildErc7677Url({ baseUrl: "https://paymaster.example.com", token: "ppt_abc" });
|
|
616
|
+
* // https://paymaster.example.com/v2/paymaster/ppt_abc
|
|
617
|
+
* ```
|
|
618
|
+
*/
|
|
619
|
+
declare function buildErc7677Url(options: BuildErc7677UrlOptions): string;
|
|
620
|
+
/**
|
|
621
|
+
* The hosted ERC-7677 URL for a project credential: `<hosted base>/v2/paymaster/<token>`.
|
|
622
|
+
* Pass the project's client token (`ppt_`, browser-safe); a server key is refused in a browser.
|
|
623
|
+
*
|
|
624
|
+
* @example
|
|
625
|
+
* const url = hostedErc7677Url("ppt_abc");
|
|
626
|
+
* // https://paymaster.pepeunchained.com/v2/paymaster/ppt_abc
|
|
627
|
+
*/
|
|
628
|
+
declare function hostedErc7677Url(token: string): string;
|
|
629
|
+
/**
|
|
630
|
+
* Turn a sponsor result into the approval, or throw the mapped {@link PepuPaymasterError}
|
|
631
|
+
* (`project_not_claimed_onchain` becomes `PAYMASTER_PROJECT_NOT_CLAIMED`, and so on).
|
|
632
|
+
*
|
|
633
|
+
* @example
|
|
634
|
+
* ```ts
|
|
635
|
+
* const approval = assertApproved(await api.v2.sponsor(userOp, { apiKey }));
|
|
636
|
+
* ```
|
|
637
|
+
*/
|
|
638
|
+
declare function assertApproved(result: SponsorResult): SponsorApproval;
|
|
639
|
+
/**
|
|
640
|
+
* Create the paymaster REST client.
|
|
641
|
+
*
|
|
642
|
+
* @example
|
|
643
|
+
* ```ts
|
|
644
|
+
* const api = createPaymasterApi({ baseUrl: "https://paymaster.example.com" });
|
|
645
|
+
* const free = await api.v2.freeTier();
|
|
646
|
+
* const result = await api.v2.sponsor(userOp, { apiKey: process.env.PEPU_SERVER_KEY!, privyAccessToken });
|
|
647
|
+
* if (result.status === "denied") console.log(result.reason);
|
|
648
|
+
* ```
|
|
649
|
+
*/
|
|
650
|
+
declare function createPaymasterApi(options?: CreatePaymasterApiOptions): PaymasterApi;
|
|
651
|
+
/** Serialize a typed attestation into the wire format for `projects.prepare`. */
|
|
652
|
+
declare function serializeAttestation(a: ProjectClaimAttestation): SerializedAttestation;
|
|
653
|
+
|
|
654
|
+
export { resolvePaymasterV2Address as $, createPaymasterApi as A, type BuildErc7677UrlOptions as B, type ConfigureProjectParams as C, type DepositForParams as D, credentialKind as E, depositFor as F, encodeAcceptProjectOwnership as G, encodeCancelReclaim as H, encodeClaimFromVerification as I, encodeClaimProject as J, encodeDeposit as K, type LoginWithWalletOptions as L, encodeExecuteReclaim as M, encodeProposeProjectOwner as N, encodeReclaimProject as O, type ProjectClaimAttestation as P, type Quantity as Q, type ReadProjectOptions as R, type SerializedAttestation as S, encodeSetDailyLimit as T, encodeSetPaused as U, type V2ConfigResponse as V, encodeSetSenderDailyLimit as W, encodeSetTargets as X, getProjectId as Y, hostedErc7677Url as Z, readProject as _, type PaymasterApi as a, sendPaymasterCalls as a0, serializeAttestation as a1, type CreatePaymasterApiOptions as b, type PaymasterAddressOption as c, type PaymasterApiV1 as d, type PaymasterApiV2 as e, type PaymasterCall as f, type PrepareRequest as g, type PreparedTx as h, type ProjectDetail as i, type ProjectSettings as j, type ProjectState as k, type RegisterProjectRequest as l, type RegisterProjectResponse as m, type SponsorApproval as n, type SponsorAuth as o, type SponsorDenial as p, type SponsorResult as q, type SponsorUserOp as r, type V2ContractInfo as s, type V2FreeTierInfo as t, type V2LoginResult as u, type V2RequestOptions as v, assertApproved as w, buildErc7677Url as x, computeProjectId as y, configureProject as z };
|