@pafi-dev/core 0.3.0-beta.9 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +165 -1084
- package/dist/auth/index.cjs +16 -2
- package/dist/auth/index.cjs.map +1 -1
- package/dist/auth/index.d.cts +93 -2
- package/dist/auth/index.d.ts +93 -2
- package/dist/auth/index.js +17 -3
- package/dist/{chunk-KJKDLD7N.cjs → chunk-2PY5RNVS.cjs} +11 -11
- package/dist/{chunk-KJKDLD7N.cjs.map → chunk-2PY5RNVS.cjs.map} +1 -1
- package/dist/{chunk-DMW67WBU.cjs → chunk-52SZJDFT.cjs} +6 -2
- package/dist/chunk-52SZJDFT.cjs.map +1 -0
- package/dist/{chunk-Z2V525IS.cjs → chunk-ARZSGP5Y.cjs} +6 -6
- package/dist/{chunk-Z2V525IS.cjs.map → chunk-ARZSGP5Y.cjs.map} +1 -1
- package/dist/{chunk-GWLEEXM4.cjs → chunk-FNJZUNK3.cjs} +90 -2
- package/dist/chunk-FNJZUNK3.cjs.map +1 -0
- package/dist/{chunk-I2P3TIP7.js → chunk-N5M3BLOV.js} +2 -2
- package/dist/{chunk-73CQTNLB.js → chunk-S5CCEO4O.js} +6 -2
- package/dist/{chunk-73CQTNLB.js.map → chunk-S5CCEO4O.js.map} +1 -1
- package/dist/{chunk-W23EJNYG.js → chunk-T6Y32SNK.js} +12 -2
- package/dist/chunk-T6Y32SNK.js.map +1 -0
- package/dist/{chunk-O4SMTUOY.js → chunk-W6VULMCO.js} +90 -2
- package/dist/chunk-W6VULMCO.js.map +1 -0
- package/dist/{chunk-DUY7Z2AI.js → chunk-WTWG6QXP.js} +2 -2
- package/dist/{chunk-EDR5SFJN.cjs → chunk-YU7MFR6Y.cjs} +12 -2
- package/dist/chunk-YU7MFR6Y.cjs.map +1 -0
- package/dist/eip712/index.cjs +3 -3
- package/dist/eip712/index.js +2 -2
- package/dist/{index-B7pGBych.d.cts → index-BEx-Q1bW.d.cts} +23 -40
- package/dist/{index-B06IJlHe.d.ts → index-r4xCdQO7.d.ts} +23 -40
- package/dist/index.cjs +178 -37
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +211 -26
- package/dist/index.d.ts +211 -26
- package/dist/index.js +176 -35
- package/dist/index.js.map +1 -1
- package/dist/quoting/index.cjs +3 -3
- package/dist/quoting/index.js +2 -2
- package/dist/swap/index.cjs +3 -2
- package/dist/swap/index.cjs.map +1 -1
- package/dist/swap/index.d.cts +1 -1
- package/dist/swap/index.d.ts +1 -1
- package/dist/swap/index.js +2 -1
- package/package.json +1 -1
- package/dist/chunk-DMW67WBU.cjs.map +0 -1
- package/dist/chunk-EDR5SFJN.cjs.map +0 -1
- package/dist/chunk-GWLEEXM4.cjs.map +0 -1
- package/dist/chunk-O4SMTUOY.js.map +0 -1
- package/dist/chunk-W23EJNYG.js.map +0 -1
- /package/dist/{chunk-I2P3TIP7.js.map → chunk-N5M3BLOV.js.map} +0 -0
- /package/dist/{chunk-DUY7Z2AI.js.map → chunk-WTWG6QXP.js.map} +0 -0
|
@@ -81,12 +81,6 @@ interface SwapSimulationResult {
|
|
|
81
81
|
*/
|
|
82
82
|
declare function simulateSwap(client: PublicClient, routerAddress: Address, commands: Hex, inputs: Hex[], deadline: bigint, from: Address): Promise<SwapSimulationResult>;
|
|
83
83
|
|
|
84
|
-
/**
|
|
85
|
-
* ERC-4337 v0.7 EntryPoint standard address (deployed deterministically
|
|
86
|
-
* at the same address across chains).
|
|
87
|
-
* https://eips.ethereum.org/EIPS/eip-4337
|
|
88
|
-
*/
|
|
89
|
-
declare const ENTRY_POINT_V07: Address;
|
|
90
84
|
/**
|
|
91
85
|
* A single call inside a batch. `BatchExecutor.execute(Call[])` iterates
|
|
92
86
|
* and invokes each one. When the batch runs via EIP-7702 delegation,
|
|
@@ -150,35 +144,32 @@ interface UserOpReceipt {
|
|
|
150
144
|
declare const ZERO_VALUE = 0n;
|
|
151
145
|
|
|
152
146
|
/**
|
|
153
|
-
* v1.5 — Scenario 4: Swap PT → USDT on PAFI Web with
|
|
154
|
-
* deducted in PT
|
|
147
|
+
* v1.5 — Scenario 4: Swap PT → USDT on PAFI Web with gas fee
|
|
148
|
+
* deducted in PT from the user's balance.
|
|
155
149
|
*
|
|
156
|
-
* Builds an unsigned `PartialUserOperation` that packages
|
|
157
|
-
* calls into a single `BatchExecutor.execute(calls[])`:
|
|
150
|
+
* Builds an unsigned `PartialUserOperation` that packages up to four
|
|
151
|
+
* inner calls into a single `BatchExecutor.execute(calls[])`:
|
|
158
152
|
*
|
|
159
|
-
* 1. `PT.approve(
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
153
|
+
* 1. `PT.approve(Permit2, amountIn)` — grant Permit2 ERC-20 allowance
|
|
154
|
+
* 2. `Permit2.approve(PT, router, amountIn, deadline)` — authorize
|
|
155
|
+
* the UniversalRouter to pull PT via Permit2
|
|
156
|
+
* 3. `UniversalRouter.execute(commands, inputs, deadline)` — V4 swap
|
|
157
|
+
* PT → USDT; user receives ≥ `minAmountOut` USDT
|
|
158
|
+
* 4. `PT.transfer(feeRecipient, gasFeePt)` — pay the operator back
|
|
159
|
+
* for sponsoring the gas, in PT (omitted when `gasFeePt` is 0)
|
|
166
160
|
*
|
|
167
|
-
* The user's wallet must hold `amountIn + gasFeePt` PT
|
|
168
|
-
* UserOp runs.
|
|
169
|
-
*
|
|
170
|
-
*
|
|
161
|
+
* The user's wallet must hold `amountIn + gasFeePt` PT before the
|
|
162
|
+
* UserOp runs. All inner calls execute atomically via EIP-7702
|
|
163
|
+
* delegation (`msg.sender = user`), so a reverting swap unwinds
|
|
164
|
+
* the approvals and fee transfer too.
|
|
171
165
|
*
|
|
172
166
|
* ## Fee model
|
|
173
167
|
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
177
|
-
* separate `transfer` call — it does NOT come out of the swap's USDT
|
|
178
|
-
* output, because that output goes straight to the user's wallet with
|
|
179
|
-
* no intermediate hook to skim from.
|
|
168
|
+
* The gas fee is a separate `transfer` after the swap — it does NOT
|
|
169
|
+
* come out of the USDT output, because that output goes straight to
|
|
170
|
+
* the user's wallet with no intermediate hook.
|
|
180
171
|
*
|
|
181
|
-
* If the FE wants "user receives exactly X USDT after gas"
|
|
172
|
+
* If the FE wants "user receives exactly X USDT after gas":
|
|
182
173
|
* 1. Quote PT→USDT for candidate `amountIn` values
|
|
183
174
|
* 2. Pick an `amountIn` where `minAmountOut ≈ X`
|
|
184
175
|
* 3. Separately compute `gasFeePt` from the operator's rate
|
|
@@ -186,11 +177,8 @@ declare const ZERO_VALUE = 0n;
|
|
|
186
177
|
*
|
|
187
178
|
* ## Order of operations
|
|
188
179
|
*
|
|
189
|
-
*
|
|
190
|
-
*
|
|
191
|
-
* batch revert). Doing fee transfer first would still unwind on
|
|
192
|
-
* revert, but ordering it last matches the intuitive "only charge
|
|
193
|
-
* gas on success" semantics.
|
|
180
|
+
* Fee transfer is last so a reverting swap also refunds the fee
|
|
181
|
+
* (atomic batch revert semantics).
|
|
194
182
|
*/
|
|
195
183
|
interface BuildSwapWithGasDeductionParams {
|
|
196
184
|
/** User's EOA (with EIP-7702 delegation to BatchExecutor). */
|
|
@@ -218,12 +206,7 @@ interface BuildSwapWithGasDeductionParams {
|
|
|
218
206
|
gasFeePt: bigint;
|
|
219
207
|
/** Where the gas fee lands — typically the operator or fee collector. */
|
|
220
208
|
feeRecipient: Address;
|
|
221
|
-
/**
|
|
222
|
-
* Optional — pre-signed Permit2 / EIP-2612 approval. If omitted, a
|
|
223
|
-
* standard `approve()` call is appended as the first batch op.
|
|
224
|
-
* Future work: support Permit2 so the approve is part of the swap
|
|
225
|
-
* input rather than a separate call.
|
|
226
|
-
*/
|
|
209
|
+
/** Override ERC-4337 gas estimates. Defaults are conservative; tune down for cheaper UserOps. */
|
|
227
210
|
gasLimits?: {
|
|
228
211
|
callGasLimit?: bigint;
|
|
229
212
|
verificationGasLimit?: bigint;
|
|
@@ -241,4 +224,4 @@ interface BuildSwapWithGasDeductionParams {
|
|
|
241
224
|
*/
|
|
242
225
|
declare function buildSwapWithGasDeduction(params: BuildSwapWithGasDeductionParams): PartialUserOperation;
|
|
243
226
|
|
|
244
|
-
export { type BuildSwapWithGasDeductionParams as B,
|
|
227
|
+
export { type BuildSwapWithGasDeductionParams as B, type Operation as O, type PartialUserOperation as P, type SwapSimulationResult as S, TAKE_ALL as T, type UserOperation as U, V4_SWAP as V, ZERO_VALUE as Z, type PaymasterFields as a, SETTLE_ALL as b, SWAP_EXACT_IN as c, type UserOpReceipt as d, buildErc20ApprovalCalldata as e, buildPermit2ApprovalCalldata as f, buildSwapFromQuote as g, buildSwapWithGasDeduction as h, buildUniversalRouterExecuteArgs as i, buildV4SwapInput as j, checkAllowance as k, simulateSwap as s };
|
package/dist/index.cjs
CHANGED
|
@@ -5,7 +5,6 @@ var _chunkALCWYDVGcjs = require('./chunk-ALCWYDVG.cjs');
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var _chunkGWLEEXM4cjs = require('./chunk-GWLEEXM4.cjs');
|
|
9
8
|
|
|
10
9
|
|
|
11
10
|
|
|
@@ -13,16 +12,23 @@ var _chunkGWLEEXM4cjs = require('./chunk-GWLEEXM4.cjs');
|
|
|
13
12
|
|
|
14
13
|
|
|
15
14
|
|
|
15
|
+
var _chunkFNJZUNK3cjs = require('./chunk-FNJZUNK3.cjs');
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
var _chunkCQCSQPWGcjs = require('./chunk-CQCSQPWG.cjs');
|
|
21
20
|
|
|
22
21
|
|
|
23
22
|
|
|
24
23
|
|
|
25
|
-
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
var _chunk2PY5RNVScjs = require('./chunk-2PY5RNVS.cjs');
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
26
32
|
|
|
27
33
|
|
|
28
34
|
|
|
@@ -30,11 +36,12 @@ var _chunkS2XRFFP3cjs = require('./chunk-S2XRFFP3.cjs');
|
|
|
30
36
|
|
|
31
37
|
|
|
32
38
|
|
|
39
|
+
var _chunkCQCSQPWGcjs = require('./chunk-CQCSQPWG.cjs');
|
|
33
40
|
|
|
34
41
|
|
|
35
42
|
|
|
36
43
|
|
|
37
|
-
var
|
|
44
|
+
var _chunkS2XRFFP3cjs = require('./chunk-S2XRFFP3.cjs');
|
|
38
45
|
|
|
39
46
|
|
|
40
47
|
|
|
@@ -42,7 +49,7 @@ var _chunkKJKDLD7Ncjs = require('./chunk-KJKDLD7N.cjs');
|
|
|
42
49
|
|
|
43
50
|
|
|
44
51
|
|
|
45
|
-
var
|
|
52
|
+
var _chunkARZSGP5Ycjs = require('./chunk-ARZSGP5Y.cjs');
|
|
46
53
|
|
|
47
54
|
|
|
48
55
|
var _chunkCL3QSI4Ocjs = require('./chunk-CL3QSI4O.cjs');
|
|
@@ -56,7 +63,6 @@ var _chunkCL3QSI4Ocjs = require('./chunk-CL3QSI4O.cjs');
|
|
|
56
63
|
|
|
57
64
|
|
|
58
65
|
|
|
59
|
-
var _chunkDMW67WBUcjs = require('./chunk-DMW67WBU.cjs');
|
|
60
66
|
|
|
61
67
|
|
|
62
68
|
|
|
@@ -73,22 +79,25 @@ var _chunkDMW67WBUcjs = require('./chunk-DMW67WBU.cjs');
|
|
|
73
79
|
|
|
74
80
|
|
|
75
81
|
|
|
82
|
+
var _chunkYU7MFR6Ycjs = require('./chunk-YU7MFR6Y.cjs');
|
|
76
83
|
|
|
77
84
|
|
|
78
85
|
|
|
79
86
|
|
|
87
|
+
var _chunkIPXARZ6Fcjs = require('./chunk-IPXARZ6F.cjs');
|
|
88
|
+
|
|
80
89
|
|
|
81
90
|
|
|
82
91
|
|
|
83
92
|
|
|
84
93
|
|
|
85
94
|
|
|
86
|
-
var _chunkEDR5SFJNcjs = require('./chunk-EDR5SFJN.cjs');
|
|
87
95
|
|
|
88
96
|
|
|
89
97
|
|
|
90
98
|
|
|
91
|
-
|
|
99
|
+
|
|
100
|
+
var _chunk52SZJDFTcjs = require('./chunk-52SZJDFT.cjs');
|
|
92
101
|
|
|
93
102
|
// src/index.ts
|
|
94
103
|
var _viem = require('viem');
|
|
@@ -98,7 +107,7 @@ var _viem = require('viem');
|
|
|
98
107
|
|
|
99
108
|
// src/contracts/real/orderlyVault.ts
|
|
100
109
|
|
|
101
|
-
var ORDERLY_VAULT_BASE_MAINNET = "
|
|
110
|
+
var ORDERLY_VAULT_BASE_MAINNET = "0x816f722424B49Cf1275cc86DA9840Fbd5a6167e9";
|
|
102
111
|
var ORDERLY_VAULT_ADDRESSES = {
|
|
103
112
|
8453: ORDERLY_VAULT_BASE_MAINNET
|
|
104
113
|
};
|
|
@@ -212,16 +221,16 @@ function buildPerpDepositWithGasDeduction(params) {
|
|
|
212
221
|
args: [params.depositData]
|
|
213
222
|
});
|
|
214
223
|
const operations = [
|
|
215
|
-
|
|
224
|
+
_chunkYU7MFR6Ycjs.erc20ApproveOp.call(void 0, params.usdcAddress, vault, params.amount),
|
|
216
225
|
{
|
|
217
|
-
...
|
|
226
|
+
..._chunkYU7MFR6Ycjs.rawCallOp.call(void 0, vault, depositCallData),
|
|
218
227
|
// BatchExecutor passes `value` from the inner call along; this
|
|
219
228
|
// becomes the LayerZero fee. The aggregated `msg.value` for the
|
|
220
229
|
// top-level UserOp must equal the sum of inner `value`s.
|
|
221
230
|
value: params.layerZeroFee
|
|
222
231
|
}
|
|
223
232
|
];
|
|
224
|
-
return
|
|
233
|
+
return _chunkYU7MFR6Ycjs.buildPartialUserOperation.call(void 0, {
|
|
225
234
|
sender: params.userAddress,
|
|
226
235
|
nonce: params.aaNonce,
|
|
227
236
|
operations,
|
|
@@ -234,7 +243,6 @@ function buildPerpDepositWithGasDeduction(params) {
|
|
|
234
243
|
}
|
|
235
244
|
|
|
236
245
|
// src/userop/types.ts
|
|
237
|
-
var ENTRY_POINT_V07 = "0x0000000071727De22E5E9d8BAf0edAc6f37da032";
|
|
238
246
|
var ZERO_VALUE = 0n;
|
|
239
247
|
|
|
240
248
|
// src/paymaster/config.ts
|
|
@@ -280,6 +288,92 @@ async function checkEthAndBranch(params) {
|
|
|
280
288
|
return balance >= required ? "normal" : "paymaster";
|
|
281
289
|
}
|
|
282
290
|
|
|
291
|
+
// src/delegation/checkDelegation.ts
|
|
292
|
+
var EIP7702_MAGIC = "0xef0100";
|
|
293
|
+
function parseEip7702DelegatedAddress(code) {
|
|
294
|
+
if (!code || code === "0x" || code === "0x0") return null;
|
|
295
|
+
const normalized = code.toLowerCase();
|
|
296
|
+
const magic = EIP7702_MAGIC.toLowerCase();
|
|
297
|
+
const idx = normalized.indexOf(magic);
|
|
298
|
+
if (idx === -1) return null;
|
|
299
|
+
const raw = normalized.slice(idx + magic.length, idx + magic.length + 40);
|
|
300
|
+
if (raw.length !== 40) return null;
|
|
301
|
+
return `0x${raw}`;
|
|
302
|
+
}
|
|
303
|
+
async function checkDelegation(client, address) {
|
|
304
|
+
const code = await client.getCode({ address });
|
|
305
|
+
return parseEip7702DelegatedAddress(code);
|
|
306
|
+
}
|
|
307
|
+
async function isDelegatedTo(client, address, target) {
|
|
308
|
+
const impl = await checkDelegation(client, address);
|
|
309
|
+
if (!impl) return false;
|
|
310
|
+
return impl.toLowerCase() === target.toLowerCase();
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// src/delegation/buildDelegationUserOp.ts
|
|
314
|
+
function buildDelegationUserOp(params) {
|
|
315
|
+
return _chunkYU7MFR6Ycjs.buildPartialUserOperation.call(void 0, {
|
|
316
|
+
sender: params.userAddress,
|
|
317
|
+
nonce: params.aaNonce,
|
|
318
|
+
operations: [
|
|
319
|
+
{
|
|
320
|
+
// Self-call with no data — triggers EIP-7702 delegation without
|
|
321
|
+
// executing any inner logic. The BatchExecutor.execute([]) call with
|
|
322
|
+
// an empty array would revert, so we target the EOA itself (which
|
|
323
|
+
// forwards to BatchExecutor that then no-ops on empty input).
|
|
324
|
+
target: params.userAddress,
|
|
325
|
+
value: 0n,
|
|
326
|
+
data: "0x"
|
|
327
|
+
}
|
|
328
|
+
],
|
|
329
|
+
gasLimits: {
|
|
330
|
+
callGasLimit: _nullishCoalesce(_optionalChain([params, 'access', _7 => _7.gasLimits, 'optionalAccess', _8 => _8.callGasLimit]), () => ( 50000n)),
|
|
331
|
+
verificationGasLimit: _nullishCoalesce(_optionalChain([params, 'access', _9 => _9.gasLimits, 'optionalAccess', _10 => _10.verificationGasLimit]), () => ( 150000n)),
|
|
332
|
+
preVerificationGas: _nullishCoalesce(_optionalChain([params, 'access', _11 => _11.gasLimits, 'optionalAccess', _12 => _12.preVerificationGas]), () => ( 50000n))
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
async function getAaNonce(client, userAddress) {
|
|
337
|
+
const NONCE_ABI = [
|
|
338
|
+
{
|
|
339
|
+
inputs: [
|
|
340
|
+
{ name: "sender", type: "address" },
|
|
341
|
+
{ name: "key", type: "uint192" }
|
|
342
|
+
],
|
|
343
|
+
name: "getNonce",
|
|
344
|
+
outputs: [{ name: "nonce", type: "uint256" }],
|
|
345
|
+
stateMutability: "view",
|
|
346
|
+
type: "function"
|
|
347
|
+
}
|
|
348
|
+
];
|
|
349
|
+
return client.readContract({
|
|
350
|
+
address: _chunk52SZJDFTcjs.ENTRY_POINT_V07,
|
|
351
|
+
abi: NONCE_ABI,
|
|
352
|
+
functionName: "getNonce",
|
|
353
|
+
args: [userAddress, 0n]
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
// src/transport/proxyTransport.ts
|
|
358
|
+
|
|
359
|
+
function createPafiProxyTransport(params) {
|
|
360
|
+
const { proxyUrl, getIdentityToken, issuerId } = params;
|
|
361
|
+
return _viem.http.call(void 0, proxyUrl, {
|
|
362
|
+
fetchOptions: {},
|
|
363
|
+
// fetchFn intercepts every fetch call the viem http transport makes,
|
|
364
|
+
// injecting the auth headers before the request leaves the browser.
|
|
365
|
+
fetchFn: (input, init) => {
|
|
366
|
+
const headers = new Headers(_optionalChain([init, 'optionalAccess', _13 => _13.headers]));
|
|
367
|
+
const token = getIdentityToken();
|
|
368
|
+
if (token) {
|
|
369
|
+
headers.set("authorization", `Bearer ${token}`);
|
|
370
|
+
}
|
|
371
|
+
headers.set("x-issuer-id", issuerId);
|
|
372
|
+
return fetch(input, { ...init, headers });
|
|
373
|
+
}
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
|
|
283
377
|
// src/contracts/real/pointToken.ts
|
|
284
378
|
|
|
285
379
|
var POINT_TOKEN_ABI = _viem.parseAbi.call(void 0, [
|
|
@@ -325,10 +419,6 @@ var POINT_TOKEN_ABI = _viem.parseAbi.call(void 0, [
|
|
|
325
419
|
"event MintingOracleUpdated(address indexed mintingOracle)"
|
|
326
420
|
]);
|
|
327
421
|
|
|
328
|
-
// src/contracts/real/batchExecutor.ts
|
|
329
|
-
var BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA = "0x000000000000000000000000000000000000DE01";
|
|
330
|
-
var BATCH_EXECUTOR_ADDRESS_BASE_MAINNET = "0x7702cb554e6bFb442cb743A7dF23154544a7176C";
|
|
331
|
-
|
|
332
422
|
// src/contracts/real/addresses.ts
|
|
333
423
|
var PLACEHOLDER_DEAD = (suffix) => `0x000000000000000000000000000000000000${suffix.toLowerCase().padStart(4, "0")}`;
|
|
334
424
|
var CONTRACT_ADDRESSES = {
|
|
@@ -378,6 +468,10 @@ function getContractAddresses(chainId) {
|
|
|
378
468
|
return addrs;
|
|
379
469
|
}
|
|
380
470
|
|
|
471
|
+
// src/contracts/real/batchExecutor.ts
|
|
472
|
+
var BATCH_EXECUTOR_ADDRESS_BASE_MAINNET = getContractAddresses(8453).batchExecutor;
|
|
473
|
+
var BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA = getContractAddresses(84532).batchExecutor;
|
|
474
|
+
|
|
381
475
|
// src/web-handoff/webPopup.ts
|
|
382
476
|
var DEFAULT_WIDTH = 900;
|
|
383
477
|
var DEFAULT_HEIGHT = 700;
|
|
@@ -391,8 +485,8 @@ function openWebPopup(url, options = {}) {
|
|
|
391
485
|
const width = _nullishCoalesce(options.width, () => ( DEFAULT_WIDTH));
|
|
392
486
|
const height = _nullishCoalesce(options.height, () => ( DEFAULT_HEIGHT));
|
|
393
487
|
const name = _nullishCoalesce(options.windowName, () => ( DEFAULT_NAME));
|
|
394
|
-
const screenW = _nullishCoalesce(_optionalChain([window, 'access',
|
|
395
|
-
const screenH = _nullishCoalesce(_optionalChain([window, 'access',
|
|
488
|
+
const screenW = _nullishCoalesce(_optionalChain([window, 'access', _14 => _14.screen, 'optionalAccess', _15 => _15.availWidth]), () => ( window.innerWidth));
|
|
489
|
+
const screenH = _nullishCoalesce(_optionalChain([window, 'access', _16 => _16.screen, 'optionalAccess', _17 => _17.availHeight]), () => ( window.innerHeight));
|
|
396
490
|
const left = Math.max(0, Math.floor((screenW - width) / 2));
|
|
397
491
|
const top = Math.max(0, Math.floor((screenH - height) / 2));
|
|
398
492
|
const features = [
|
|
@@ -425,7 +519,7 @@ function openWebPopup(url, options = {}) {
|
|
|
425
519
|
window.removeEventListener("message", messageListener);
|
|
426
520
|
messageListener = null;
|
|
427
521
|
}
|
|
428
|
-
_optionalChain([options, 'access',
|
|
522
|
+
_optionalChain([options, 'access', _18 => _18.onClose, 'optionalCall', _19 => _19()]);
|
|
429
523
|
};
|
|
430
524
|
pollId = setInterval(() => {
|
|
431
525
|
if (popup.closed) {
|
|
@@ -505,6 +599,16 @@ var PafiSDK = class {
|
|
|
505
599
|
|
|
506
600
|
|
|
507
601
|
|
|
602
|
+
// -------------------------------------------------------------------------
|
|
603
|
+
// Domain namespaces — grouped by concern for better IDE autocomplete.
|
|
604
|
+
// Each property is a plain object of bound methods; the underlying logic
|
|
605
|
+
// lives in the flat methods below so both access styles work.
|
|
606
|
+
// -------------------------------------------------------------------------
|
|
607
|
+
|
|
608
|
+
|
|
609
|
+
|
|
610
|
+
|
|
611
|
+
|
|
508
612
|
constructor(config) {
|
|
509
613
|
this._pointTokenAddress = config.pointTokenAddress;
|
|
510
614
|
this._signer = config.signer;
|
|
@@ -516,6 +620,29 @@ var PafiSDK = class {
|
|
|
516
620
|
transport: _viem.http.call(void 0, config.rpcUrl)
|
|
517
621
|
});
|
|
518
622
|
}
|
|
623
|
+
this.mint = {
|
|
624
|
+
buildTypedData: this.buildMintRequestTypedData.bind(this),
|
|
625
|
+
sign: this.signMintRequest.bind(this),
|
|
626
|
+
verify: this.verifyMintRequest.bind(this),
|
|
627
|
+
getNonce: this.getMintRequestNonce.bind(this)
|
|
628
|
+
};
|
|
629
|
+
this.consent = {
|
|
630
|
+
buildTypedData: this.buildReceiverConsentTypedData.bind(this),
|
|
631
|
+
sign: this.signReceiverConsent.bind(this),
|
|
632
|
+
verify: this.verifyReceiverConsent.bind(this),
|
|
633
|
+
getNonce: this.getReceiverConsentNonce.bind(this)
|
|
634
|
+
};
|
|
635
|
+
this.swap = {
|
|
636
|
+
buildFromQuote: this.buildSwapFromQuote.bind(this),
|
|
637
|
+
simulate: this.simulateSwap.bind(this)
|
|
638
|
+
};
|
|
639
|
+
this.quote = {
|
|
640
|
+
findBest: this.findBestQuote.bind(this)
|
|
641
|
+
};
|
|
642
|
+
this.auth = {
|
|
643
|
+
createLoginMessage: this.createLoginMessage.bind(this),
|
|
644
|
+
signMessage: this.signLoginMessage.bind(this)
|
|
645
|
+
};
|
|
519
646
|
}
|
|
520
647
|
// -------------------------------------------------------------------------
|
|
521
648
|
// Setters
|
|
@@ -534,25 +661,25 @@ var PafiSDK = class {
|
|
|
534
661
|
// -------------------------------------------------------------------------
|
|
535
662
|
requirePointToken() {
|
|
536
663
|
if (!this._pointTokenAddress) {
|
|
537
|
-
throw new (0,
|
|
664
|
+
throw new (0, _chunkYU7MFR6Ycjs.ConfigurationError)("pointTokenAddress not set");
|
|
538
665
|
}
|
|
539
666
|
return this._pointTokenAddress;
|
|
540
667
|
}
|
|
541
668
|
requireProvider() {
|
|
542
669
|
if (!this._provider) {
|
|
543
|
-
throw new (0,
|
|
670
|
+
throw new (0, _chunkYU7MFR6Ycjs.ConfigurationError)("provider not set");
|
|
544
671
|
}
|
|
545
672
|
return this._provider;
|
|
546
673
|
}
|
|
547
674
|
requireSigner() {
|
|
548
675
|
if (!this._signer) {
|
|
549
|
-
throw new (0,
|
|
676
|
+
throw new (0, _chunkYU7MFR6Ycjs.ConfigurationError)("signer not set");
|
|
550
677
|
}
|
|
551
678
|
return this._signer;
|
|
552
679
|
}
|
|
553
680
|
requireChainId() {
|
|
554
681
|
if (this._chainId === void 0) {
|
|
555
|
-
throw new (0,
|
|
682
|
+
throw new (0, _chunkYU7MFR6Ycjs.ConfigurationError)("chainId not set");
|
|
556
683
|
}
|
|
557
684
|
return this._chainId;
|
|
558
685
|
}
|
|
@@ -571,27 +698,27 @@ var PafiSDK = class {
|
|
|
571
698
|
// -------------------------------------------------------------------------
|
|
572
699
|
async buildMintRequestTypedData(message) {
|
|
573
700
|
const domain = await this.getDomain();
|
|
574
|
-
return
|
|
701
|
+
return _chunk2PY5RNVScjs.buildMintRequestTypedData.call(void 0, domain, message);
|
|
575
702
|
}
|
|
576
703
|
async buildReceiverConsentTypedData(message) {
|
|
577
704
|
const domain = await this.getDomain();
|
|
578
|
-
return
|
|
705
|
+
return _chunk2PY5RNVScjs.buildReceiverConsentTypedData.call(void 0, domain, message);
|
|
579
706
|
}
|
|
580
707
|
async signMintRequest(message) {
|
|
581
708
|
const domain = await this.getDomain();
|
|
582
|
-
return
|
|
709
|
+
return _chunk2PY5RNVScjs.signMintRequest.call(void 0, this.requireSigner(), domain, message);
|
|
583
710
|
}
|
|
584
711
|
async verifyMintRequest(message, signature, expectedMinter) {
|
|
585
712
|
const domain = await this.getDomain();
|
|
586
|
-
return
|
|
713
|
+
return _chunk2PY5RNVScjs.verifyMintRequest.call(void 0, domain, message, signature, expectedMinter);
|
|
587
714
|
}
|
|
588
715
|
async signReceiverConsent(message) {
|
|
589
716
|
const domain = await this.getDomain();
|
|
590
|
-
return
|
|
717
|
+
return _chunk2PY5RNVScjs.signReceiverConsent.call(void 0, this.requireSigner(), domain, message);
|
|
591
718
|
}
|
|
592
719
|
async verifyReceiverConsent(message, signature, expectedReceiver) {
|
|
593
720
|
const domain = await this.getDomain();
|
|
594
|
-
return
|
|
721
|
+
return _chunk2PY5RNVScjs.verifyReceiverConsent.call(void 0, domain, message, signature, expectedReceiver);
|
|
595
722
|
}
|
|
596
723
|
// -------------------------------------------------------------------------
|
|
597
724
|
// Contract reads
|
|
@@ -619,7 +746,7 @@ var PafiSDK = class {
|
|
|
619
746
|
* paths, and quotes via a single multicall RPC call.
|
|
620
747
|
*/
|
|
621
748
|
async findBestQuote(tokenIn, tokenOut, exactAmount, pools = [], quoterAddress, maxHops) {
|
|
622
|
-
return
|
|
749
|
+
return _chunkARZSGP5Ycjs.findBestQuote.call(void 0,
|
|
623
750
|
this.requireProvider(),
|
|
624
751
|
this.requireChainId(),
|
|
625
752
|
tokenIn,
|
|
@@ -638,7 +765,7 @@ var PafiSDK = class {
|
|
|
638
765
|
* The caller provides `minAmountOut` after applying their own slippage.
|
|
639
766
|
*/
|
|
640
767
|
buildSwapFromQuote(params) {
|
|
641
|
-
return
|
|
768
|
+
return _chunkYU7MFR6Ycjs.buildSwapFromQuote.call(void 0, params);
|
|
642
769
|
}
|
|
643
770
|
// -------------------------------------------------------------------------
|
|
644
771
|
// Simulation — dry-run via eth_call (no gas spent)
|
|
@@ -654,7 +781,7 @@ var PafiSDK = class {
|
|
|
654
781
|
* @param from - Address that will execute the swap
|
|
655
782
|
*/
|
|
656
783
|
async simulateSwap(routerAddress, commands, inputs, deadline, from) {
|
|
657
|
-
return
|
|
784
|
+
return _chunkYU7MFR6Ycjs.simulateSwap.call(void 0,
|
|
658
785
|
this.requireProvider(),
|
|
659
786
|
routerAddress,
|
|
660
787
|
commands,
|
|
@@ -671,16 +798,16 @@ var PafiSDK = class {
|
|
|
671
798
|
const chainId = this.requireChainId();
|
|
672
799
|
const account = signer.account;
|
|
673
800
|
if (!account) {
|
|
674
|
-
throw new (0,
|
|
801
|
+
throw new (0, _chunkYU7MFR6Ycjs.ConfigurationError)("signer has no account attached");
|
|
675
802
|
}
|
|
676
|
-
return
|
|
803
|
+
return _chunkFNJZUNK3cjs.createLoginMessage.call(void 0, { ...params, address: account.address, chainId });
|
|
677
804
|
}
|
|
678
805
|
/** Sign a login message string with the current signer (personal_sign) */
|
|
679
806
|
async signLoginMessage(message) {
|
|
680
807
|
const signer = this.requireSigner();
|
|
681
808
|
const account = signer.account;
|
|
682
809
|
if (!account) {
|
|
683
|
-
throw new (0,
|
|
810
|
+
throw new (0, _chunkYU7MFR6Ycjs.ConfigurationError)("signer has no account attached");
|
|
684
811
|
}
|
|
685
812
|
return signer.signMessage({ account, message });
|
|
686
813
|
}
|
|
@@ -784,5 +911,19 @@ var PafiSDK = class {
|
|
|
784
911
|
|
|
785
912
|
|
|
786
913
|
|
|
787
|
-
|
|
914
|
+
|
|
915
|
+
|
|
916
|
+
|
|
917
|
+
|
|
918
|
+
|
|
919
|
+
|
|
920
|
+
|
|
921
|
+
|
|
922
|
+
|
|
923
|
+
|
|
924
|
+
|
|
925
|
+
|
|
926
|
+
|
|
927
|
+
|
|
928
|
+
exports.ApiError = _chunkYU7MFR6Ycjs.ApiError; exports.BATCH_EXECUTOR_ABI = _chunkYU7MFR6Ycjs.BATCH_EXECUTOR_ABI; exports.BATCH_EXECUTOR_ADDRESS_BASE_MAINNET = BATCH_EXECUTOR_ADDRESS_BASE_MAINNET; exports.BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA = BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA; exports.BROKER_HASHES = BROKER_HASHES; exports.COMMON_POOLS = _chunk52SZJDFTcjs.COMMON_POOLS; exports.COMMON_TOKENS = _chunk52SZJDFTcjs.COMMON_TOKENS; exports.CONTRACT_ADDRESSES = CONTRACT_ADDRESSES; exports.ConfigurationError = _chunkYU7MFR6Ycjs.ConfigurationError; exports.ENTRY_POINT_V07 = _chunk52SZJDFTcjs.ENTRY_POINT_V07; exports.ORDERLY_VAULT_ABI = ORDERLY_VAULT_ABI; exports.ORDERLY_VAULT_ADDRESSES = ORDERLY_VAULT_ADDRESSES; exports.ORDERLY_VAULT_BASE_MAINNET = ORDERLY_VAULT_BASE_MAINNET; exports.PERMIT2_ADDRESS = _chunk52SZJDFTcjs.PERMIT2_ADDRESS; exports.POINT_TOKEN_FACTORY_ADDRESSES = POINT_TOKEN_FACTORY_ADDRESSES; exports.POINT_TOKEN_IMPL_ADDRESSES = POINT_TOKEN_IMPL_ADDRESSES; exports.POINT_TOKEN_POOLS = _chunk52SZJDFTcjs.POINT_TOKEN_POOLS; exports.POINT_TOKEN_V2_ABI = POINT_TOKEN_ABI; exports.PafiSDK = PafiSDK; exports.PafiSDKError = _chunkYU7MFR6Ycjs.PafiSDKError; exports.SETTLE_ALL = _chunkYU7MFR6Ycjs.SETTLE_ALL; exports.SPONSOR_AUTH_DOMAIN_NAME = _chunkFNJZUNK3cjs.SPONSOR_AUTH_DOMAIN_NAME; exports.SPONSOR_AUTH_TYPES = _chunkFNJZUNK3cjs.SPONSOR_AUTH_TYPES; exports.SUPPORTED_CHAINS = _chunk52SZJDFTcjs.SUPPORTED_CHAINS; exports.SWAP_EXACT_IN = _chunkYU7MFR6Ycjs.SWAP_EXACT_IN; exports.SigningError = _chunkYU7MFR6Ycjs.SigningError; exports.SimulationError = _chunkYU7MFR6Ycjs.SimulationError; exports.TAKE_ALL = _chunkYU7MFR6Ycjs.TAKE_ALL; exports.TOKEN_HASHES = TOKEN_HASHES; exports.UNIVERSAL_ROUTER_ADDRESSES = _chunk52SZJDFTcjs.UNIVERSAL_ROUTER_ADDRESSES; exports.V4_QUOTER_ADDRESSES = _chunk52SZJDFTcjs.V4_QUOTER_ADDRESSES; exports.V4_SWAP = _chunkYU7MFR6Ycjs.V4_SWAP; exports.ZERO_VALUE = ZERO_VALUE; exports._resetPaymasterConfigForTests = _resetPaymasterConfigForTests; exports.assembleUserOperation = _chunkYU7MFR6Ycjs.assembleUserOperation; exports.buildAllPaths = _chunkARZSGP5Ycjs.buildAllPaths; exports.buildBurnRequestTypedData = _chunk2PY5RNVScjs.buildBurnRequestTypedData; exports.buildDelegationUserOp = buildDelegationUserOp; exports.buildDomain = _chunk2PY5RNVScjs.buildDomain; exports.buildErc20ApprovalCalldata = _chunkYU7MFR6Ycjs.buildErc20ApprovalCalldata; exports.buildMintRequestTypedData = _chunk2PY5RNVScjs.buildMintRequestTypedData; exports.buildPartialUserOperation = _chunkYU7MFR6Ycjs.buildPartialUserOperation; exports.buildPermit2ApprovalCalldata = _chunkYU7MFR6Ycjs.buildPermit2ApprovalCalldata; exports.buildPerpDepositWithGasDeduction = buildPerpDepositWithGasDeduction; exports.buildReceiverConsentTypedData = _chunk2PY5RNVScjs.buildReceiverConsentTypedData; exports.buildSponsorAuthDomain = _chunkFNJZUNK3cjs.buildSponsorAuthDomain; exports.buildSponsorAuthTypedData = _chunkFNJZUNK3cjs.buildSponsorAuthTypedData; exports.buildSwapFromQuote = _chunkYU7MFR6Ycjs.buildSwapFromQuote; exports.buildSwapWithGasDeduction = _chunkYU7MFR6Ycjs.buildSwapWithGasDeduction; exports.buildUniversalRouterExecuteArgs = _chunkYU7MFR6Ycjs.buildUniversalRouterExecuteArgs; exports.buildV4SwapInput = _chunkYU7MFR6Ycjs.buildV4SwapInput; exports.burnRequestTypes = _chunk52SZJDFTcjs.burnRequestTypes; exports.checkAllowance = _chunkYU7MFR6Ycjs.checkAllowance; exports.checkDelegation = checkDelegation; exports.checkEthAndBranch = checkEthAndBranch; exports.combineRoutes = _chunkARZSGP5Ycjs.combineRoutes; exports.computeAccountId = computeAccountId; exports.computeCallDataHash = _chunkFNJZUNK3cjs.computeCallDataHash; exports.createLoginMessage = _chunkFNJZUNK3cjs.createLoginMessage; exports.createPafiProxyTransport = createPafiProxyTransport; exports.encodeBatchExecute = _chunkYU7MFR6Ycjs.encodeBatchExecute; exports.erc20Abi = _chunkIPXARZ6Fcjs.erc20Abi; exports.erc20ApproveOp = _chunkYU7MFR6Ycjs.erc20ApproveOp; exports.erc20BurnOp = _chunkYU7MFR6Ycjs.erc20BurnOp; exports.erc20TransferOp = _chunkYU7MFR6Ycjs.erc20TransferOp; exports.findBestQuote = _chunkARZSGP5Ycjs.findBestQuote; exports.getAaNonce = getAaNonce; exports.getContractAddresses = getContractAddresses; exports.getIssuer = _chunkCQCSQPWGcjs.getIssuer2; exports.getMintRequestNonce = _chunkCQCSQPWGcjs.getMintRequestNonce; exports.getPafiWebModalAdapter = getPafiWebModalAdapter; exports.getPaymasterConfig = getPaymasterConfig; exports.getPointTokenBalance = _chunkCQCSQPWGcjs.getPointTokenBalance; exports.getPointTokenIssuer = _chunkCQCSQPWGcjs.getPointTokenIssuer; exports.getPointTokenIssuerAddress = _chunkCQCSQPWGcjs.getIssuer; exports.getReceiverConsentNonce = _chunkCQCSQPWGcjs.getReceiverConsentNonce; exports.getTokenName = _chunkCQCSQPWGcjs.getTokenName; exports.isActiveIssuer = _chunkCQCSQPWGcjs.isActiveIssuer; exports.isDelegatedTo = isDelegatedTo; exports.isMinter = _chunkCQCSQPWGcjs.isMinter; exports.isPaymasterConfigured = isPaymasterConfigured; exports.issuerRegistryAbi = _chunkS2XRFFP3cjs.issuerRegistryAbi; exports.mintRequestTypes = _chunk52SZJDFTcjs.mintRequestTypes; exports.mintingOracleAbi = _chunkS2XRFFP3cjs.mintingOracleAbi; exports.openPafiWebModal = openPafiWebModal; exports.openWebPopup = openWebPopup; exports.parseEip7702DelegatedAddress = parseEip7702DelegatedAddress; exports.parseLoginMessage = _chunkFNJZUNK3cjs.parseLoginMessage; exports.permit2Abi = _chunkIPXARZ6Fcjs.permit2Abi; exports.pointTokenAbi = _chunkS2XRFFP3cjs.pointTokenAbi; exports.pointTokenFactoryAbi = _chunkALCWYDVGcjs.pointTokenFactoryAbi; exports.quoteBestRoute = _chunkARZSGP5Ycjs.quoteBestRoute; exports.quoteExactInput = _chunkARZSGP5Ycjs.quoteExactInput; exports.quoteExactInputSingle = _chunkARZSGP5Ycjs.quoteExactInputSingle; exports.rawCallOp = _chunkYU7MFR6Ycjs.rawCallOp; exports.receiverConsentTypes = _chunk52SZJDFTcjs.receiverConsentTypes; exports.setPafiWebModalAdapter = setPafiWebModalAdapter; exports.setPaymasterConfig = setPaymasterConfig; exports.signBurnRequest = _chunk2PY5RNVScjs.signBurnRequest; exports.signMintRequest = _chunk2PY5RNVScjs.signMintRequest; exports.signReceiverConsent = _chunk2PY5RNVScjs.signReceiverConsent; exports.signSponsorAuth = _chunkFNJZUNK3cjs.signSponsorAuth; exports.simulateSwap = _chunkYU7MFR6Ycjs.simulateSwap; exports.universalRouterAbi = _chunkIPXARZ6Fcjs.universalRouterAbi; exports.v4QuoterAbi = _chunkCL3QSI4Ocjs.v4QuoterAbi; exports.verifyBurnRequest = _chunk2PY5RNVScjs.verifyBurnRequest; exports.verifyLoginMessage = _chunkFNJZUNK3cjs.verifyLoginMessage; exports.verifyMintCap = _chunkCQCSQPWGcjs.verifyMintCap; exports.verifyMintRequest = _chunk2PY5RNVScjs.verifyMintRequest; exports.verifyReceiverConsent = _chunk2PY5RNVScjs.verifyReceiverConsent; exports.verifySponsorAuth = _chunkFNJZUNK3cjs.verifySponsorAuth; exports.webPopupAdapter = webPopupAdapter;
|
|
788
929
|
//# sourceMappingURL=index.cjs.map
|