@pafi-dev/core 0.3.0-alpha.0 → 0.3.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-CXFUP2YK.cjs +311 -0
- package/dist/chunk-CXFUP2YK.cjs.map +1 -0
- package/dist/chunk-IK4UK7KT.js +311 -0
- package/dist/chunk-IK4UK7KT.js.map +1 -0
- package/dist/contract/index.d.cts +1 -1
- package/dist/contract/index.d.ts +1 -1
- package/dist/eip712/index.d.cts +1 -1
- package/dist/eip712/index.d.ts +1 -1
- package/dist/index-BpUYHGu3.d.cts +244 -0
- package/dist/index-CNALKsH1.d.ts +244 -0
- package/dist/index.cjs +200 -94
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +474 -73
- package/dist/index.d.ts +474 -73
- package/dist/index.js +196 -90
- package/dist/index.js.map +1 -1
- package/dist/quoting/index.d.cts +1 -1
- package/dist/quoting/index.d.ts +1 -1
- package/dist/relay/index.d.cts +1 -1
- package/dist/relay/index.d.ts +1 -1
- package/dist/swap/index.cjs +4 -2
- package/dist/swap/index.cjs.map +1 -1
- package/dist/swap/index.d.cts +3 -84
- package/dist/swap/index.d.ts +3 -84
- package/dist/swap/index.js +3 -1
- package/dist/{types-CkRJzrZr.d.cts → types-BDOnH5Le.d.cts} +1 -1
- package/dist/{types-CkRJzrZr.d.ts → types-BDOnH5Le.d.ts} +1 -1
- package/package.json +1 -1
- package/dist/chunk-6I6K43RQ.cjs +0 -149
- package/dist/chunk-6I6K43RQ.cjs.map +0 -1
- package/dist/chunk-UU72CX7E.js +0 -149
- package/dist/chunk-UU72CX7E.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
2
|
|
|
3
3
|
var _chunkFGKLDKJKcjs = require('./chunk-FGKLDKJK.cjs');
|
|
4
4
|
|
|
@@ -77,7 +77,16 @@ var _chunk27V32VNMcjs = require('./chunk-27V32VNM.cjs');
|
|
|
77
77
|
|
|
78
78
|
|
|
79
79
|
|
|
80
|
-
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
var _chunkCXFUP2YKcjs = require('./chunk-CXFUP2YK.cjs');
|
|
81
90
|
|
|
82
91
|
|
|
83
92
|
|
|
@@ -98,95 +107,6 @@ var _viem = require('viem');
|
|
|
98
107
|
var ENTRY_POINT_V07 = "0x0000000071727De22E5E9d8BAf0edAc6f37da032";
|
|
99
108
|
var ZERO_VALUE = 0n;
|
|
100
109
|
|
|
101
|
-
// src/userop/operations.ts
|
|
102
|
-
|
|
103
|
-
var ERC20_BURNABLE_ABI = _viem.parseAbi.call(void 0, ["function burn(uint256 amount)"]);
|
|
104
|
-
function erc20TransferOp(token, to, amount) {
|
|
105
|
-
return {
|
|
106
|
-
target: token,
|
|
107
|
-
value: 0n,
|
|
108
|
-
data: _viem.encodeFunctionData.call(void 0, {
|
|
109
|
-
abi: _viem.erc20Abi,
|
|
110
|
-
functionName: "transfer",
|
|
111
|
-
args: [to, amount]
|
|
112
|
-
})
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
function erc20ApproveOp(token, spender, amount) {
|
|
116
|
-
return {
|
|
117
|
-
target: token,
|
|
118
|
-
value: 0n,
|
|
119
|
-
data: _viem.encodeFunctionData.call(void 0, {
|
|
120
|
-
abi: _viem.erc20Abi,
|
|
121
|
-
functionName: "approve",
|
|
122
|
-
args: [spender, amount]
|
|
123
|
-
})
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
function erc20BurnOp(token, amount) {
|
|
127
|
-
return {
|
|
128
|
-
target: token,
|
|
129
|
-
value: 0n,
|
|
130
|
-
data: _viem.encodeFunctionData.call(void 0, {
|
|
131
|
-
abi: ERC20_BURNABLE_ABI,
|
|
132
|
-
functionName: "burn",
|
|
133
|
-
args: [amount]
|
|
134
|
-
})
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
function rawCallOp(target, data, value = 0n) {
|
|
138
|
-
return { target, value, data };
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// src/userop/batchExecute.ts
|
|
142
|
-
|
|
143
|
-
var BATCH_EXECUTOR_ABI = _viem.parseAbi.call(void 0, [
|
|
144
|
-
"function execute((address target, uint256 value, bytes data)[] calls)"
|
|
145
|
-
]);
|
|
146
|
-
function encodeBatchExecute(operations) {
|
|
147
|
-
if (operations.length === 0) {
|
|
148
|
-
throw new Error("encodeBatchExecute: operations array must not be empty");
|
|
149
|
-
}
|
|
150
|
-
return _viem.encodeFunctionData.call(void 0, {
|
|
151
|
-
abi: BATCH_EXECUTOR_ABI,
|
|
152
|
-
functionName: "execute",
|
|
153
|
-
args: [
|
|
154
|
-
operations.map((op) => ({
|
|
155
|
-
target: op.target,
|
|
156
|
-
value: op.value,
|
|
157
|
-
data: op.data
|
|
158
|
-
}))
|
|
159
|
-
]
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
// src/userop/buildUserOperation.ts
|
|
164
|
-
var DEFAULT_CALL_GAS_LIMIT = 500000n;
|
|
165
|
-
var DEFAULT_VERIFICATION_GAS_LIMIT = 150000n;
|
|
166
|
-
var DEFAULT_PRE_VERIFICATION_GAS = 50000n;
|
|
167
|
-
function buildPartialUserOperation(params) {
|
|
168
|
-
return {
|
|
169
|
-
sender: params.sender,
|
|
170
|
-
nonce: params.nonce,
|
|
171
|
-
callData: encodeBatchExecute(params.operations),
|
|
172
|
-
callGasLimit: _nullishCoalesce(_optionalChain([params, 'access', _ => _.gasLimits, 'optionalAccess', _2 => _2.callGasLimit]), () => ( DEFAULT_CALL_GAS_LIMIT)),
|
|
173
|
-
verificationGasLimit: _nullishCoalesce(_optionalChain([params, 'access', _3 => _3.gasLimits, 'optionalAccess', _4 => _4.verificationGasLimit]), () => ( DEFAULT_VERIFICATION_GAS_LIMIT)),
|
|
174
|
-
preVerificationGas: _nullishCoalesce(_optionalChain([params, 'access', _5 => _5.gasLimits, 'optionalAccess', _6 => _6.preVerificationGas]), () => ( DEFAULT_PRE_VERIFICATION_GAS)),
|
|
175
|
-
maxFeePerGas: _nullishCoalesce(_optionalChain([params, 'access', _7 => _7.feeOverrides, 'optionalAccess', _8 => _8.maxFeePerGas]), () => ( 0n)),
|
|
176
|
-
maxPriorityFeePerGas: _nullishCoalesce(_optionalChain([params, 'access', _9 => _9.feeOverrides, 'optionalAccess', _10 => _10.maxPriorityFeePerGas]), () => ( 0n))
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
|
-
function assembleUserOperation(partial, paymaster, signature) {
|
|
180
|
-
return {
|
|
181
|
-
...partial,
|
|
182
|
-
paymaster: paymaster.paymaster,
|
|
183
|
-
paymasterData: paymaster.paymasterData,
|
|
184
|
-
paymasterVerificationGasLimit: paymaster.paymasterVerificationGasLimit,
|
|
185
|
-
paymasterPostOpGasLimit: paymaster.paymasterPostOpGasLimit,
|
|
186
|
-
signature
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
|
|
190
110
|
// src/paymaster/config.ts
|
|
191
111
|
var _config = null;
|
|
192
112
|
function setPaymasterConfig(config) {
|
|
@@ -230,6 +150,176 @@ async function checkEthAndBranch(params) {
|
|
|
230
150
|
return balance >= required ? "normal" : "paymaster";
|
|
231
151
|
}
|
|
232
152
|
|
|
153
|
+
// src/contracts/mocks/relayerV2.mock.ts
|
|
154
|
+
|
|
155
|
+
var MOCK_RELAYER_V2_ABI = _viem.parseAbi.call(void 0, [
|
|
156
|
+
"function mint((address to, uint256 amount, uint256 feeAmount, address feeRecipient, uint256 nonce, uint256 deadline, bytes extData) request, (uint8 v, bytes32 r, bytes32 s) userSig, (uint8 v, bytes32 r, bytes32 s) issuerSig) external",
|
|
157
|
+
// View functions we'll likely want (nonce getter is standard)
|
|
158
|
+
"function mintRequestNonce(address user) external view returns (uint256)",
|
|
159
|
+
"event Minted(address indexed user, uint256 amount, uint256 feeAmount, address indexed feeRecipient, bytes32 requestHash)"
|
|
160
|
+
]);
|
|
161
|
+
var MOCK_RELAYER_V2_MINT_SELECTOR = "0xMOCKED__";
|
|
162
|
+
|
|
163
|
+
// src/contracts/mocks/pointTokenV2.mock.ts
|
|
164
|
+
|
|
165
|
+
var MOCK_POINT_TOKEN_V2_ABI = _viem.parseAbi.call(void 0, [
|
|
166
|
+
// Variant A
|
|
167
|
+
"function burn(uint256 amount) external",
|
|
168
|
+
// Variant B
|
|
169
|
+
"function burnWithSig((address user, address pointToken, uint256 amount, uint256 nonce, uint256 deadline) consent, (uint8 v, bytes32 r, bytes32 s) sig) external",
|
|
170
|
+
// Standard reads we always need
|
|
171
|
+
"function balanceOf(address user) external view returns (uint256)",
|
|
172
|
+
"function burnNonce(address user) external view returns (uint256)",
|
|
173
|
+
// ERC-20 Transfer event (inherited) — BurnIndexer filters `to = 0x0`
|
|
174
|
+
"event Transfer(address indexed from, address indexed to, uint256 value)"
|
|
175
|
+
]);
|
|
176
|
+
|
|
177
|
+
// src/contracts/mocks/batchExecutor.mock.ts
|
|
178
|
+
var MOCK_BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA = "0x000000000000000000000000000000000000DE01";
|
|
179
|
+
var MOCK_BATCH_EXECUTOR_ADDRESS_BASE_MAINNET = "0x000000000000000000000000000000000000DE02";
|
|
180
|
+
|
|
181
|
+
// src/contracts/mocks/addresses.mock.ts
|
|
182
|
+
var MOCK_PLACEHOLDER = (suffix) => `0x000000000000000000000000000000000000${suffix.toLowerCase().padStart(4, "0")}`;
|
|
183
|
+
var MOCK_ADDRESSES = {
|
|
184
|
+
// Base Sepolia — safe targets for integration tests (MockRelayer
|
|
185
|
+
// fixtures deployed by Hardhat will override these at test time)
|
|
186
|
+
84532: {
|
|
187
|
+
relayerV2: MOCK_PLACEHOLDER("de10"),
|
|
188
|
+
pointToken: MOCK_PLACEHOLDER("de11"),
|
|
189
|
+
batchExecutor: MOCK_PLACEHOLDER("de01"),
|
|
190
|
+
usdt: MOCK_PLACEHOLDER("de12"),
|
|
191
|
+
issuerRegistry: MOCK_PLACEHOLDER("de13"),
|
|
192
|
+
mintingOracle: MOCK_PLACEHOLDER("de14")
|
|
193
|
+
},
|
|
194
|
+
// Base mainnet — intentionally left as placeholder. Do NOT ship to
|
|
195
|
+
// prod without swapping.
|
|
196
|
+
8453: {
|
|
197
|
+
relayerV2: MOCK_PLACEHOLDER("dead"),
|
|
198
|
+
pointToken: MOCK_PLACEHOLDER("dead"),
|
|
199
|
+
batchExecutor: MOCK_PLACEHOLDER("dead"),
|
|
200
|
+
usdt: MOCK_PLACEHOLDER("dead"),
|
|
201
|
+
issuerRegistry: MOCK_PLACEHOLDER("dead"),
|
|
202
|
+
mintingOracle: MOCK_PLACEHOLDER("dead")
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
function getMockAddresses(chainId) {
|
|
206
|
+
const addrs = MOCK_ADDRESSES[chainId];
|
|
207
|
+
if (!addrs) {
|
|
208
|
+
throw new Error(
|
|
209
|
+
`getMockAddresses: no mock addresses for chainId ${chainId}. Supported: ${Object.keys(MOCK_ADDRESSES).join(", ")}`
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
return addrs;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// src/contracts/mocks/eip712/mintRequestV2.mock.ts
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
var MOCK_MINT_REQUEST_V2_TYPES = {
|
|
221
|
+
MintRequest: [
|
|
222
|
+
{ name: "to", type: "address" },
|
|
223
|
+
{ name: "amount", type: "uint256" },
|
|
224
|
+
{ name: "feeAmount", type: "uint256" },
|
|
225
|
+
{ name: "feeRecipient", type: "address" },
|
|
226
|
+
{ name: "nonce", type: "uint256" },
|
|
227
|
+
{ name: "deadline", type: "uint256" },
|
|
228
|
+
{ name: "extData", type: "bytes" }
|
|
229
|
+
]
|
|
230
|
+
};
|
|
231
|
+
function buildMockMintRequestV2TypedData(domain, message) {
|
|
232
|
+
return {
|
|
233
|
+
domain: _chunkBNTVOKYTcjs.buildDomain.call(void 0, domain),
|
|
234
|
+
types: MOCK_MINT_REQUEST_V2_TYPES,
|
|
235
|
+
primaryType: "MintRequest",
|
|
236
|
+
message
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
async function signMockMintRequestV2(walletClient, domain, message) {
|
|
240
|
+
const serialized = await walletClient.signTypedData({
|
|
241
|
+
account: walletClient.account,
|
|
242
|
+
domain: _chunkBNTVOKYTcjs.buildDomain.call(void 0, domain),
|
|
243
|
+
types: MOCK_MINT_REQUEST_V2_TYPES,
|
|
244
|
+
primaryType: "MintRequest",
|
|
245
|
+
message
|
|
246
|
+
});
|
|
247
|
+
const { v, r, s } = _viem.parseSignature.call(void 0, serialized);
|
|
248
|
+
return {
|
|
249
|
+
v: Number(v),
|
|
250
|
+
r,
|
|
251
|
+
s,
|
|
252
|
+
serialized
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
async function verifyMockMintRequestV2(domain, message, signature, expectedSigner) {
|
|
256
|
+
const recoveredAddress = await _viem.recoverTypedDataAddress.call(void 0, {
|
|
257
|
+
domain: _chunkBNTVOKYTcjs.buildDomain.call(void 0, domain),
|
|
258
|
+
types: MOCK_MINT_REQUEST_V2_TYPES,
|
|
259
|
+
primaryType: "MintRequest",
|
|
260
|
+
message,
|
|
261
|
+
signature
|
|
262
|
+
});
|
|
263
|
+
const isValid = recoveredAddress.toLowerCase() === expectedSigner.toLowerCase();
|
|
264
|
+
return {
|
|
265
|
+
isValid,
|
|
266
|
+
recoveredAddress
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// src/contracts/mocks/eip712/burnConsent.mock.ts
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
var MOCK_BURN_CONSENT_TYPES = {
|
|
276
|
+
BurnConsent: [
|
|
277
|
+
{ name: "user", type: "address" },
|
|
278
|
+
{ name: "pointToken", type: "address" },
|
|
279
|
+
{ name: "amount", type: "uint256" },
|
|
280
|
+
{ name: "nonce", type: "uint256" },
|
|
281
|
+
{ name: "deadline", type: "uint256" }
|
|
282
|
+
]
|
|
283
|
+
};
|
|
284
|
+
function buildMockBurnConsentTypedData(domain, message) {
|
|
285
|
+
return {
|
|
286
|
+
domain: _chunkBNTVOKYTcjs.buildDomain.call(void 0, domain),
|
|
287
|
+
types: MOCK_BURN_CONSENT_TYPES,
|
|
288
|
+
primaryType: "BurnConsent",
|
|
289
|
+
message
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
async function signMockBurnConsent(walletClient, domain, message) {
|
|
293
|
+
const serialized = await walletClient.signTypedData({
|
|
294
|
+
account: walletClient.account,
|
|
295
|
+
domain: _chunkBNTVOKYTcjs.buildDomain.call(void 0, domain),
|
|
296
|
+
types: MOCK_BURN_CONSENT_TYPES,
|
|
297
|
+
primaryType: "BurnConsent",
|
|
298
|
+
message
|
|
299
|
+
});
|
|
300
|
+
const { v, r, s } = _viem.parseSignature.call(void 0, serialized);
|
|
301
|
+
return {
|
|
302
|
+
v: Number(v),
|
|
303
|
+
r,
|
|
304
|
+
s,
|
|
305
|
+
serialized
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
async function verifyMockBurnConsent(domain, message, signature, expectedUser) {
|
|
309
|
+
const recoveredAddress = await _viem.recoverTypedDataAddress.call(void 0, {
|
|
310
|
+
domain: _chunkBNTVOKYTcjs.buildDomain.call(void 0, domain),
|
|
311
|
+
types: MOCK_BURN_CONSENT_TYPES,
|
|
312
|
+
primaryType: "BurnConsent",
|
|
313
|
+
message,
|
|
314
|
+
signature
|
|
315
|
+
});
|
|
316
|
+
const isValid = recoveredAddress.toLowerCase() === expectedUser.toLowerCase();
|
|
317
|
+
return {
|
|
318
|
+
isValid,
|
|
319
|
+
recoveredAddress
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
|
|
233
323
|
// src/index.ts
|
|
234
324
|
var PafiSDK = class {
|
|
235
325
|
|
|
@@ -391,7 +481,7 @@ var PafiSDK = class {
|
|
|
391
481
|
* The caller provides `minAmountOut` after applying their own slippage.
|
|
392
482
|
*/
|
|
393
483
|
buildSwapFromQuote(params) {
|
|
394
|
-
return
|
|
484
|
+
return _chunkCXFUP2YKcjs.buildSwapFromQuote.call(void 0, params);
|
|
395
485
|
}
|
|
396
486
|
/**
|
|
397
487
|
* Build Relay SwapParams + extData from a quote result.
|
|
@@ -439,7 +529,7 @@ var PafiSDK = class {
|
|
|
439
529
|
* @param from - Address that will execute the swap
|
|
440
530
|
*/
|
|
441
531
|
async simulateSwap(routerAddress, commands, inputs, deadline, from) {
|
|
442
|
-
return
|
|
532
|
+
return _chunkCXFUP2YKcjs.simulateSwap.call(void 0,
|
|
443
533
|
this.requireProvider(),
|
|
444
534
|
routerAddress,
|
|
445
535
|
commands,
|
|
@@ -563,5 +653,21 @@ var PafiSDK = class {
|
|
|
563
653
|
|
|
564
654
|
|
|
565
655
|
|
|
566
|
-
|
|
656
|
+
|
|
657
|
+
|
|
658
|
+
|
|
659
|
+
|
|
660
|
+
|
|
661
|
+
|
|
662
|
+
|
|
663
|
+
|
|
664
|
+
|
|
665
|
+
|
|
666
|
+
|
|
667
|
+
|
|
668
|
+
|
|
669
|
+
|
|
670
|
+
|
|
671
|
+
|
|
672
|
+
exports.ApiError = _chunk5QJZT7VBcjs.ApiError; exports.BATCH_EXECUTOR_ABI = _chunkCXFUP2YKcjs.BATCH_EXECUTOR_ABI; exports.BATCH_EXECUTOR_ADDRESS_BASE_MAINNET = MOCK_BATCH_EXECUTOR_ADDRESS_BASE_MAINNET; exports.BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA = MOCK_BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA; exports.BURN_CONSENT_TYPES = MOCK_BURN_CONSENT_TYPES; exports.COMMON_POOLS = _chunkCWP4PFOPcjs.COMMON_POOLS; exports.COMMON_TOKENS = _chunkCWP4PFOPcjs.COMMON_TOKENS; exports.CONTRACT_ADDRESSES = MOCK_ADDRESSES; exports.ConfigurationError = _chunk5QJZT7VBcjs.ConfigurationError; exports.ENTRY_POINT_V07 = ENTRY_POINT_V07; exports.MINT_REQUEST_V2_TYPES = MOCK_MINT_REQUEST_V2_TYPES; exports.POINT_TOKEN_POOLS = _chunkCWP4PFOPcjs.POINT_TOKEN_POOLS; exports.POINT_TOKEN_V2_ABI = MOCK_POINT_TOKEN_V2_ABI; exports.PafiSDK = PafiSDK; exports.PafiSDKError = _chunk5QJZT7VBcjs.PafiSDKError; exports.RELAYER_V2_ABI = MOCK_RELAYER_V2_ABI; exports.RELAYER_V2_MINT_SELECTOR = MOCK_RELAYER_V2_MINT_SELECTOR; exports.SETTLE_ALL = _chunkCXFUP2YKcjs.SETTLE_ALL; exports.SUPPORTED_CHAINS = _chunkCWP4PFOPcjs.SUPPORTED_CHAINS; exports.SWAP_EXACT_IN = _chunkCXFUP2YKcjs.SWAP_EXACT_IN; exports.SigningError = _chunk5QJZT7VBcjs.SigningError; exports.SimulationError = _chunk5QJZT7VBcjs.SimulationError; exports.TAKE_ALL = _chunkCXFUP2YKcjs.TAKE_ALL; exports.UNIVERSAL_ROUTER_ADDRESSES = _chunkCWP4PFOPcjs.UNIVERSAL_ROUTER_ADDRESSES; exports.V4_QUOTER_ADDRESSES = _chunkCWP4PFOPcjs.V4_QUOTER_ADDRESSES; exports.V4_SWAP = _chunkCXFUP2YKcjs.V4_SWAP; exports.ZERO_VALUE = ZERO_VALUE; exports._resetPaymasterConfigForTests = _resetPaymasterConfigForTests; exports.assembleUserOperation = _chunkCXFUP2YKcjs.assembleUserOperation; exports.buildAllPaths = _chunkCAE2BVKIcjs.buildAllPaths; exports.buildBurnConsentTypedData = buildMockBurnConsentTypedData; exports.buildDomain = _chunkBNTVOKYTcjs.buildDomain; exports.buildErc20ApprovalCalldata = _chunkCXFUP2YKcjs.buildErc20ApprovalCalldata; exports.buildMintRequestTypedData = _chunkBNTVOKYTcjs.buildMintRequestTypedData; exports.buildMintRequestV2TypedData = buildMockMintRequestV2TypedData; exports.buildPartialUserOperation = _chunkCXFUP2YKcjs.buildPartialUserOperation; exports.buildPermit2ApprovalCalldata = _chunkCXFUP2YKcjs.buildPermit2ApprovalCalldata; exports.buildReceiverConsentTypedData = _chunkBNTVOKYTcjs.buildReceiverConsentTypedData; exports.buildRelaySwapParams = _chunkL74CZAVQcjs.buildRelaySwapParams; exports.buildSwapFromQuote = _chunkCXFUP2YKcjs.buildSwapFromQuote; exports.buildSwapWithGasDeduction = _chunkCXFUP2YKcjs.buildSwapWithGasDeduction; exports.buildUniversalRouterExecuteArgs = _chunkCXFUP2YKcjs.buildUniversalRouterExecuteArgs; exports.buildV4SwapInput = _chunkCXFUP2YKcjs.buildV4SwapInput; exports.checkAllowance = _chunkCXFUP2YKcjs.checkAllowance; exports.checkEthAndBranch = checkEthAndBranch; exports.combineRoutes = _chunkCAE2BVKIcjs.combineRoutes; exports.createLoginMessage = _chunkGWLEEXM4cjs.createLoginMessage; exports.decodeExtData = _chunkL74CZAVQcjs.decodeExtData; exports.decodeMintAndSwap = _chunkL74CZAVQcjs.decodeMintAndSwap; exports.encodeBatchExecute = _chunkCXFUP2YKcjs.encodeBatchExecute; exports.encodeExtData = _chunkL74CZAVQcjs.encodeExtData; exports.encodeMintAndSwap = _chunkL74CZAVQcjs.encodeMintAndSwap; exports.erc20Abi = _chunkIPXARZ6Fcjs.erc20Abi; exports.erc20ApproveOp = _chunkCXFUP2YKcjs.erc20ApproveOp; exports.erc20BurnOp = _chunkCXFUP2YKcjs.erc20BurnOp; exports.erc20TransferOp = _chunkCXFUP2YKcjs.erc20TransferOp; exports.findBestQuote = _chunkCAE2BVKIcjs.findBestQuote; exports.getContractAddresses = getMockAddresses; exports.getIssuer = _chunkX3I5XWARcjs.getIssuer2; exports.getMintRequestNonce = _chunkX3I5XWARcjs.getMintRequestNonce; exports.getPaymasterConfig = getPaymasterConfig; exports.getPointTokenBalance = _chunkX3I5XWARcjs.getPointTokenBalance; exports.getPointTokenIssuer = _chunkX3I5XWARcjs.getPointTokenIssuer; exports.getPointTokenIssuerAddress = _chunkX3I5XWARcjs.getIssuer; exports.getReceiverConsentNonce = _chunkX3I5XWARcjs.getReceiverConsentNonce; exports.getTokenName = _chunkX3I5XWARcjs.getTokenName; exports.getUsdt = _chunkX3I5XWARcjs.getUsdt; exports.isActiveIssuer = _chunkX3I5XWARcjs.isActiveIssuer; exports.isMinter = _chunkX3I5XWARcjs.isMinter; exports.isPaymasterConfigured = isPaymasterConfigured; exports.issuerRegistryAbi = _chunkS2XRFFP3cjs.issuerRegistryAbi; exports.mintRequestTypes = _chunkCWP4PFOPcjs.mintRequestTypes; exports.mintingOracleAbi = _chunkS2XRFFP3cjs.mintingOracleAbi; exports.parseLoginMessage = _chunkGWLEEXM4cjs.parseLoginMessage; exports.permit2Abi = _chunkIPXARZ6Fcjs.permit2Abi; exports.pointTokenAbi = _chunkS2XRFFP3cjs.pointTokenAbi; exports.pointTokenFactoryAbi = _chunkFGKLDKJKcjs.pointTokenFactoryAbi; exports.quoteBestRoute = _chunkCAE2BVKIcjs.quoteBestRoute; exports.quoteExactInput = _chunkCAE2BVKIcjs.quoteExactInput; exports.quoteExactInputSingle = _chunkCAE2BVKIcjs.quoteExactInputSingle; exports.rawCallOp = _chunkCXFUP2YKcjs.rawCallOp; exports.receiverConsentTypes = _chunkCWP4PFOPcjs.receiverConsentTypes; exports.relayAbi = _chunk27V32VNMcjs.relayAbi; exports.setPaymasterConfig = setPaymasterConfig; exports.signBurnConsent = signMockBurnConsent; exports.signMintRequest = _chunkBNTVOKYTcjs.signMintRequest; exports.signMintRequestV2 = signMockMintRequestV2; exports.signReceiverConsent = _chunkBNTVOKYTcjs.signReceiverConsent; exports.simulateMintAndSwap = _chunkL74CZAVQcjs.simulateMintAndSwap; exports.simulateSwap = _chunkCXFUP2YKcjs.simulateSwap; exports.universalRouterAbi = _chunkIPXARZ6Fcjs.universalRouterAbi; exports.v4QuoterAbi = _chunkCL3QSI4Ocjs.v4QuoterAbi; exports.verifyBurnConsent = verifyMockBurnConsent; exports.verifyLoginMessage = _chunkGWLEEXM4cjs.verifyLoginMessage; exports.verifyMintCap = _chunkX3I5XWARcjs.verifyMintCap; exports.verifyMintRequest = _chunkBNTVOKYTcjs.verifyMintRequest; exports.verifyMintRequestV2 = verifyMockMintRequestV2; exports.verifyReceiverConsent = _chunkBNTVOKYTcjs.verifyReceiverConsent;
|
|
567
673
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/phitran/Pacific-Finance/pafi-backend/pafi-sdk/packages/core/dist/index.cjs","../src/index.ts","../src/userop/types.ts","../src/userop/operations.ts","../src/userop/batchExecute.ts","../src/userop/buildUserOperation.ts","../src/paymaster/config.ts","../src/utils/checkEthAndBranch.ts"],"names":["erc20Abi","parseAbi","encodeFunctionData"],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACF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A;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,ixJAAC","file":"/Users/phitran/Pacific-Finance/pafi-backend/pafi-sdk/packages/core/dist/index.cjs","sourcesContent":[null,"import { createPublicClient, http } from \"viem\";\nimport type { Address, Hex, PublicClient, WalletClient } from \"viem\";\n\n// -------------------------------------------------------------------------\n// Re-export all sub-modules\n// -------------------------------------------------------------------------\nexport * from \"./types\";\nexport * from \"./constants\";\nexport * from \"./errors\";\nexport * from \"./abi/index\";\nexport * from \"./eip712/index\";\nexport * from \"./relay/index\";\nexport * from \"./contract/index\";\nexport * from \"./quoting/index\";\nexport * from \"./swap/index\";\nexport * from \"./auth/index\";\n\n// v1.4 — Account Abstraction primitives (EIP-7702 + ERC-4337 v0.7)\nexport * from \"./userop/index\";\nexport * from \"./paymaster/index\";\nexport * from \"./utils/index\";\n\n// -------------------------------------------------------------------------\n// Internal imports for PafiSDK class\n// -------------------------------------------------------------------------\nimport { buildMintRequestTypedData, signMintRequest, verifyMintRequest } from \"./eip712/mintRequest\";\nimport {\n buildReceiverConsentTypedData,\n signReceiverConsent,\n verifyReceiverConsent,\n} from \"./eip712/receiverConsent\";\nimport {\n getMintRequestNonce,\n getReceiverConsentNonce,\n getTokenName,\n} from \"./contract/pointToken\";\nimport {\n encodeMintAndSwap,\n decodeMintAndSwap,\n encodeExtData,\n buildRelaySwapParams,\n} from \"./relay/calldata\";\nimport { findBestQuote } from \"./quoting/quote\";\nimport {\n buildSwapFromQuote,\n buildUniversalRouterExecuteArgs,\n} from \"./swap/universalRouter\";\nimport { simulateMintAndSwap } from \"./relay/simulate\";\nimport { simulateSwap } from \"./swap/simulate\";\nimport type { SimulationResult } from \"./relay/simulate\";\nimport type { SwapSimulationResult } from \"./swap/simulate\";\nimport { createLoginMessage } from \"./auth/loginMessage\";\nimport type { LoginMessageParams } from \"./auth/types\";\nimport { ConfigurationError } from \"./errors\";\nimport type {\n BestQuote,\n EIP712Signature,\n MintParams,\n MintRequest,\n PafiSDKConfig,\n PathKey,\n PointTokenDomainConfig,\n PoolKey,\n QuoteResult,\n ReceiverConsent,\n SignatureVerification,\n SwapParams,\n} from \"./types\";\n\n// -------------------------------------------------------------------------\n// PafiSDK — convenience class wrapping all contract + crypto primitives.\n//\n// This class is HTTP-client-free on purpose. It covers signing, verifying,\n// contract reads, and calldata encoding — the things that need a signer\n// or a provider but no HTTP layer. The issuer backend defines its own HTTP\n// contract via `@pafi/issuer`; frontends build `fetch()` calls against\n// those types directly.\n// -------------------------------------------------------------------------\n\nexport class PafiSDK {\n private _pointTokenAddress?: Address;\n private _relayContractAddress?: Address;\n private _signer?: WalletClient;\n private _provider?: PublicClient;\n private _chainId?: number;\n\n constructor(config: PafiSDKConfig) {\n this._pointTokenAddress = config.pointTokenAddress;\n this._relayContractAddress = config.relayContractAddress;\n this._signer = config.signer;\n this._chainId = config.chainId;\n\n if (config.provider) {\n this._provider = config.provider;\n } else if (config.rpcUrl) {\n this._provider = createPublicClient({\n transport: http(config.rpcUrl),\n });\n }\n }\n\n // -------------------------------------------------------------------------\n // Setters\n // -------------------------------------------------------------------------\n\n setPointTokenAddress(address: Address): void {\n this._pointTokenAddress = address;\n }\n\n setRelayContractAddress(address: Address): void {\n this._relayContractAddress = address;\n }\n\n setSigner(signer: WalletClient): void {\n this._signer = signer;\n }\n\n setProvider(provider: PublicClient): void {\n this._provider = provider;\n }\n\n // -------------------------------------------------------------------------\n // Private guards\n // -------------------------------------------------------------------------\n\n private requirePointToken(): Address {\n if (!this._pointTokenAddress) {\n throw new ConfigurationError(\"pointTokenAddress not set\");\n }\n return this._pointTokenAddress;\n }\n\n private requireProvider(): PublicClient {\n if (!this._provider) {\n throw new ConfigurationError(\"provider not set\");\n }\n return this._provider;\n }\n\n private requireSigner(): WalletClient {\n if (!this._signer) {\n throw new ConfigurationError(\"signer not set\");\n }\n return this._signer;\n }\n\n private requireChainId(): number {\n if (this._chainId === undefined) {\n throw new ConfigurationError(\"chainId not set\");\n }\n return this._chainId;\n }\n\n // -------------------------------------------------------------------------\n // Domain\n // -------------------------------------------------------------------------\n\n async getDomain(): Promise<PointTokenDomainConfig> {\n const provider = this.requireProvider();\n const pointToken = this.requirePointToken();\n const chainId = this.requireChainId();\n const name = await getTokenName(provider, pointToken);\n return { name, verifyingContract: pointToken, chainId };\n }\n\n // -------------------------------------------------------------------------\n // EIP-712 — delegates to pure functions\n // -------------------------------------------------------------------------\n\n /**\n * Build the EIP-712 typed data for a MintRequest.\n * Pass the result to any external signer (Privy, WalletConnect, etc.).\n */\n async buildMintRequestTypedData(message: MintRequest) {\n const domain = await this.getDomain();\n return buildMintRequestTypedData(domain, message);\n }\n\n /**\n * Build the EIP-712 typed data for a ReceiverConsent.\n * Pass the result to any external signer (Privy, WalletConnect, etc.).\n */\n async buildReceiverConsentTypedData(message: ReceiverConsent) {\n const domain = await this.getDomain();\n return buildReceiverConsentTypedData(domain, message);\n }\n\n async signMintRequest(message: MintRequest): Promise<EIP712Signature> {\n const domain = await this.getDomain();\n return signMintRequest(this.requireSigner(), domain, message);\n }\n\n async verifyMintRequest(\n message: MintRequest,\n signature: Hex,\n expectedMinter: Address,\n ): Promise<SignatureVerification> {\n const domain = await this.getDomain();\n return verifyMintRequest(domain, message, signature, expectedMinter);\n }\n\n async signReceiverConsent(\n message: ReceiverConsent,\n ): Promise<EIP712Signature> {\n const domain = await this.getDomain();\n return signReceiverConsent(this.requireSigner(), domain, message);\n }\n\n async verifyReceiverConsent(\n message: ReceiverConsent,\n signature: Hex,\n expectedReceiver: Address,\n ): Promise<SignatureVerification> {\n const domain = await this.getDomain();\n return verifyReceiverConsent(domain, message, signature, expectedReceiver);\n }\n\n // -------------------------------------------------------------------------\n // Contract reads\n // -------------------------------------------------------------------------\n\n async getMintRequestNonce(receiver: Address): Promise<bigint> {\n return getMintRequestNonce(\n this.requireProvider(),\n this.requirePointToken(),\n receiver,\n );\n }\n\n async getReceiverConsentNonce(receiver: Address): Promise<bigint> {\n return getReceiverConsentNonce(\n this.requireProvider(),\n this.requirePointToken(),\n receiver,\n );\n }\n\n // -------------------------------------------------------------------------\n // Relay calldata — delegates to pure functions\n // -------------------------------------------------------------------------\n\n encodeMintAndSwap(mint: MintParams, swap: SwapParams): Hex {\n return encodeMintAndSwap(mint, swap);\n }\n\n decodeMintAndSwap(calldata: Hex): { mint: MintParams; swap: SwapParams } {\n return decodeMintAndSwap(calldata);\n }\n\n // -------------------------------------------------------------------------\n // Quoting — delegates to pure functions\n // -------------------------------------------------------------------------\n\n /**\n * Find the best swap route from `tokenIn` to `tokenOut`.\n * Merges `pools` with COMMON_POOLS for the configured chain, builds all\n * paths, and quotes via a single multicall RPC call.\n */\n async findBestQuote(\n tokenIn: Address,\n tokenOut: Address,\n exactAmount: bigint,\n pools: PoolKey[] = [],\n quoterAddress?: Address,\n maxHops?: number,\n ): Promise<BestQuote> {\n return findBestQuote(\n this.requireProvider(),\n this.requireChainId(),\n tokenIn,\n tokenOut,\n exactAmount,\n pools,\n quoterAddress,\n maxHops,\n );\n }\n\n // -------------------------------------------------------------------------\n // Swap building — delegates to pure functions\n // -------------------------------------------------------------------------\n\n /**\n * Build UniversalRouter execute args from a quote result.\n * The caller provides `minAmountOut` after applying their own slippage.\n */\n buildSwapFromQuote(params: {\n quote: QuoteResult;\n currencyIn: Address;\n currencyOut: Address;\n amountIn: bigint;\n minAmountOut: bigint;\n }): { commands: Hex; inputs: Hex[] } {\n return buildSwapFromQuote(params);\n }\n\n /**\n * Build Relay SwapParams + extData from a quote result.\n * Returns ready-to-use args for `Relay.mintAndSwap`.\n */\n buildRelaySwapParams(params: {\n quote: { path: PathKey[] };\n minAmountOut: bigint;\n feeInUsdt: bigint;\n deadline: bigint;\n }): { swapParams: SwapParams; extData: Hex } {\n return buildRelaySwapParams(params);\n }\n\n /**\n * Encode extData for ReceiverConsent and MintParams.\n * extData = abi.encode(minAmountOut, feeInUsdt)\n */\n encodeExtData(minAmountOut: bigint, feeInUsdt: bigint): Hex {\n return encodeExtData(minAmountOut, feeInUsdt);\n }\n\n // -------------------------------------------------------------------------\n // Simulation — dry-run via eth_call (no gas spent)\n // -------------------------------------------------------------------------\n\n /**\n * Simulate a Relay.mintAndSwap call. Catches reverts (bad signatures,\n * expired deadlines, insufficient mint cap, pool errors) before submitting.\n *\n * @param relayAddress - Relay contract address\n * @param mint - MintParams with real signatures\n * @param swap - SwapParams (path + deadline)\n * @param from - Relayer address that will submit the tx\n */\n async simulateMintAndSwap(\n relayAddress: Address,\n mint: MintParams,\n swap: SwapParams,\n from: Address,\n ): Promise<SimulationResult> {\n return simulateMintAndSwap(\n this.requireProvider(),\n relayAddress,\n mint,\n swap,\n from,\n );\n }\n\n /**\n * Simulate a UniversalRouter.execute swap call. Catches reverts (bad\n * approvals, insufficient balance, pool errors) before submitting.\n *\n * @param routerAddress - UniversalRouter contract address\n * @param commands - Packed command bytes (from buildSwapFromQuote)\n * @param inputs - Encoded inputs (from buildSwapFromQuote)\n * @param deadline - Unix timestamp\n * @param from - Address that will execute the swap\n */\n async simulateSwap(\n routerAddress: Address,\n commands: Hex,\n inputs: Hex[],\n deadline: bigint,\n from: Address,\n ): Promise<SwapSimulationResult> {\n return simulateSwap(\n this.requireProvider(),\n routerAddress,\n commands,\n inputs,\n deadline,\n from,\n );\n }\n\n // -------------------------------------------------------------------------\n // Auth — EIP-4361 login helpers (offline, stateless)\n //\n // These are convenience wrappers around the pure functions in\n // `./auth/loginMessage.ts`. They do NOT hit the network — the caller is\n // responsible for fetching the nonce, POSTing the signed message, and\n // storing the JWT returned by the issuer backend.\n // -------------------------------------------------------------------------\n\n /**\n * Build an EIP-4361 login message for the current signer + chain. The\n * caller supplies the issuer-specific fields (domain, nonce, uri); the SDK\n * fills in the wallet address and chain id from its own config.\n */\n async createLoginMessage(\n params: Omit<LoginMessageParams, \"address\" | \"chainId\">,\n ): Promise<string> {\n const signer = this.requireSigner();\n const chainId = this.requireChainId();\n const account = signer.account;\n if (!account) {\n throw new ConfigurationError(\"signer has no account attached\");\n }\n return createLoginMessage({ ...params, address: account.address, chainId });\n }\n\n /** Sign a login message string with the current signer (personal_sign) */\n async signLoginMessage(message: string): Promise<Hex> {\n const signer = this.requireSigner();\n const account = signer.account;\n if (!account) {\n throw new ConfigurationError(\"signer has no account attached\");\n }\n return signer.signMessage({ account, message });\n }\n}\n","import type { Address, Hex } from \"viem\";\n\n/**\n * ERC-4337 v0.7 EntryPoint standard address (deployed deterministically\n * at the same address across chains).\n * https://eips.ethereum.org/EIPS/eip-4337\n */\nexport const ENTRY_POINT_V07: Address =\n \"0x0000000071727De22E5E9d8BAf0edAc6f37da032\";\n\n/**\n * A single call inside a batch. `BatchExecutor.execute(Call[])` iterates\n * and invokes each one. When the batch runs via EIP-7702 delegation,\n * `msg.sender` for each call is the user's EOA.\n */\nexport interface Operation {\n target: Address;\n value: bigint;\n data: Hex;\n}\n\n/**\n * Paymaster fields attached to a UserOperation. Populated by the\n * Coinbase Paymaster (via PAFI Backend proxy) before the user signs.\n */\nexport interface PaymasterFields {\n paymaster: Address;\n paymasterData: Hex;\n paymasterVerificationGasLimit: bigint;\n paymasterPostOpGasLimit: bigint;\n}\n\n/**\n * Partial UserOp used during preparation — before paymaster fields are\n * attached or the user signs.\n */\nexport interface PartialUserOperation {\n sender: Address;\n nonce: bigint;\n callData: Hex;\n callGasLimit: bigint;\n verificationGasLimit: bigint;\n preVerificationGas: bigint;\n maxFeePerGas: bigint;\n maxPriorityFeePerGas: bigint;\n}\n\n/**\n * Full ERC-4337 v0.7 UserOperation, ready for bundler submission.\n */\nexport interface UserOperation extends PartialUserOperation {\n paymaster: Address;\n paymasterData: Hex;\n paymasterVerificationGasLimit: bigint;\n paymasterPostOpGasLimit: bigint;\n signature: Hex;\n}\n\n/**\n * Receipt returned by a bundler after a UserOp lands on-chain.\n */\nexport interface UserOpReceipt {\n userOpHash: Hex;\n success: boolean;\n txHash: Hex;\n blockNumber: bigint;\n gasUsed: bigint;\n /** Effective gas cost paid (wei). */\n actualGasCost: bigint;\n}\n\n/**\n * Sentinel operation value used in tests + docs when `Operation.value`\n * is irrelevant (ERC-20 transfers, for example).\n */\nexport const ZERO_VALUE = 0n;\n","import { encodeFunctionData, erc20Abi, parseAbi } from \"viem\";\nimport type { Address } from \"viem\";\nimport type { Operation } from \"./types\";\n\n/**\n * ERC20Burnable extension — `burn(uint256 amount)` burns from msg.sender.\n * The EOA (via EIP-7702 delegation) is the `msg.sender` when a batch\n * runs — so this burns the user's balance without any role check.\n */\nconst ERC20_BURNABLE_ABI = parseAbi([\"function burn(uint256 amount)\"]);\n\n/**\n * Build an ERC-20 `transfer(to, amount)` operation. Used inside a batch\n * to move fee tokens from the user to the fee recipient atomically with\n * the main action.\n */\nexport function erc20TransferOp(\n token: Address,\n to: Address,\n amount: bigint,\n): Operation {\n return {\n target: token,\n value: 0n,\n data: encodeFunctionData({\n abi: erc20Abi,\n functionName: \"transfer\",\n args: [to, amount],\n }),\n };\n}\n\n/**\n * Build an ERC-20 `approve(spender, amount)` operation. Used inside a\n * batch before a swap / deposit call so the AMM / protocol can pull\n * tokens from the user.\n */\nexport function erc20ApproveOp(\n token: Address,\n spender: Address,\n amount: bigint,\n): Operation {\n return {\n target: token,\n value: 0n,\n data: encodeFunctionData({\n abi: erc20Abi,\n functionName: \"approve\",\n args: [spender, amount],\n }),\n };\n}\n\n/**\n * Build an ERC-20 `burn(amount)` operation (OpenZeppelin ERC20Burnable\n * extension). Burns from `msg.sender`, which — via EIP-7702 — is the\n * user's EOA.\n *\n * Requires the PointToken contract to expose a public `burn(uint256)`\n * without a role check. See\n * [SDK_V1.4_TASKS.md §11 — PointToken.burn callable via batch].\n */\nexport function erc20BurnOp(token: Address, amount: bigint): Operation {\n return {\n target: token,\n value: 0n,\n data: encodeFunctionData({\n abi: ERC20_BURNABLE_ABI,\n functionName: \"burn\",\n args: [amount],\n }),\n };\n}\n\n/**\n * Build a raw call operation with caller-supplied calldata. Useful for\n * non-ERC-20 contracts (PoolManager.swap, PerpDEX.deposit, Relayer.mint)\n * where the encoding is specific to that protocol.\n */\nexport function rawCallOp(\n target: Address,\n data: `0x${string}`,\n value: bigint = 0n,\n): Operation {\n return { target, value, data };\n}\n","import { encodeFunctionData, parseAbi } from \"viem\";\nimport type { Hex } from \"viem\";\nimport type { Operation } from \"./types\";\n\n/**\n * Standard BatchExecutor ABI — a contract that takes an array of calls\n * and invokes each one in sequence, reverting all if any fail.\n *\n * Compatible with OpenZeppelin `Account.execute(Call[])`, Biconomy\n * `executeBatch`, Safe `MultiSend`, and most EIP-7702 delegation\n * targets. The exact deployed address is supplied by the infra team\n * (see [V1.4_V1.5_READINESS.md B2]).\n */\nexport const BATCH_EXECUTOR_ABI = parseAbi([\n \"function execute((address target, uint256 value, bytes data)[] calls)\",\n]);\n\n/**\n * Encode a batch of operations into calldata for `BatchExecutor.execute()`.\n * The resulting calldata goes into `UserOperation.callData`.\n *\n * When the EOA has an EIP-7702 delegation to a BatchExecutor, calling\n * this calldata against the EOA runs all operations with\n * `msg.sender = EOA` for each inner call.\n *\n * @param operations batch of calls, in execution order\n * @returns calldata bytes for `execute((address,uint256,bytes)[])`\n */\nexport function encodeBatchExecute(operations: Operation[]): Hex {\n if (operations.length === 0) {\n throw new Error(\"encodeBatchExecute: operations array must not be empty\");\n }\n return encodeFunctionData({\n abi: BATCH_EXECUTOR_ABI,\n functionName: \"execute\",\n args: [\n operations.map((op) => ({\n target: op.target,\n value: op.value,\n data: op.data,\n })),\n ],\n });\n}\n","import type { Address } from \"viem\";\nimport type { Operation, PartialUserOperation, UserOperation } from \"./types\";\nimport { encodeBatchExecute } from \"./batchExecute\";\n\n/**\n * Default gas limits — rough upper bounds for a 2-op batch on Base.\n * Bundler re-estimates before submission, so these are only used when\n * the caller doesn't supply their own.\n */\nconst DEFAULT_CALL_GAS_LIMIT = 500_000n;\nconst DEFAULT_VERIFICATION_GAS_LIMIT = 150_000n;\nconst DEFAULT_PRE_VERIFICATION_GAS = 50_000n;\n\nexport interface BuildPartialUserOpParams {\n /** User's EOA (with EIP-7702 delegation). */\n sender: Address;\n /** Batch of operations — encoded into callData via `encodeBatchExecute`. */\n operations: Operation[];\n /** EntryPoint nonce for this sender. Caller fetches from the EntryPoint contract. */\n nonce: bigint;\n /** Optional gas overrides; bundler re-estimates before submission. */\n gasLimits?: {\n callGasLimit?: bigint;\n verificationGasLimit?: bigint;\n preVerificationGas?: bigint;\n };\n /** Optional fee overrides; bundler usually fills these. */\n feeOverrides?: {\n maxFeePerGas?: bigint;\n maxPriorityFeePerGas?: bigint;\n };\n}\n\n/**\n * Build a partial ERC-4337 UserOperation from a batch of operations.\n * Paymaster fields and signature are populated later:\n * 1. Call `PafiBackendClient.requestSponsorship()` → get paymaster fields\n * 2. Compute userOpHash and have the user sign it (via Privy)\n * 3. Attach `signature` → submit to bundler\n *\n * This function is a pure struct builder — no network calls.\n */\nexport function buildPartialUserOperation(\n params: BuildPartialUserOpParams,\n): PartialUserOperation {\n return {\n sender: params.sender,\n nonce: params.nonce,\n callData: encodeBatchExecute(params.operations),\n callGasLimit: params.gasLimits?.callGasLimit ?? DEFAULT_CALL_GAS_LIMIT,\n verificationGasLimit:\n params.gasLimits?.verificationGasLimit ??\n DEFAULT_VERIFICATION_GAS_LIMIT,\n preVerificationGas:\n params.gasLimits?.preVerificationGas ?? DEFAULT_PRE_VERIFICATION_GAS,\n maxFeePerGas: params.feeOverrides?.maxFeePerGas ?? 0n,\n maxPriorityFeePerGas: params.feeOverrides?.maxPriorityFeePerGas ?? 0n,\n };\n}\n\n/**\n * Assemble a full UserOperation once paymaster fields + signature are\n * known. Used after `PafiBackendClient.requestSponsorship()` and user\n * signing complete.\n */\nexport function assembleUserOperation(\n partial: PartialUserOperation,\n paymaster: {\n paymaster: Address;\n paymasterData: `0x${string}`;\n paymasterVerificationGasLimit: bigint;\n paymasterPostOpGasLimit: bigint;\n },\n signature: `0x${string}`,\n): UserOperation {\n return {\n ...partial,\n paymaster: paymaster.paymaster,\n paymasterData: paymaster.paymasterData,\n paymasterVerificationGasLimit: paymaster.paymasterVerificationGasLimit,\n paymasterPostOpGasLimit: paymaster.paymasterPostOpGasLimit,\n signature,\n };\n}\n","import type { PaymasterConfig } from \"./types\";\n\n/**\n * Module-level paymaster config. Read by batch builders (via\n * `getPaymasterConfig()`) and by `@pafi/issuer` `RelayService` when\n * building UserOps.\n *\n * Consumers call `setPaymasterConfig()` once at application boot. All\n * subsequent helpers that need the feeRecipient / issuer identity /\n * backend URL pull from here.\n *\n * This is global state by design — making every batch builder take a\n * config param would clutter every call site. The alternative (a\n * context/service) has more ceremony than this flow justifies.\n */\nlet _config: PaymasterConfig | null = null;\n\n/**\n * Set the application-wide paymaster config. Safe to call multiple\n * times (later calls override earlier). Throws if required fields\n * are missing.\n */\nexport function setPaymasterConfig(config: PaymasterConfig): void {\n if (!config.pafiBackendUrl) {\n throw new Error(\"setPaymasterConfig: pafiBackendUrl is required\");\n }\n if (!config.issuerId) {\n throw new Error(\"setPaymasterConfig: issuerId is required\");\n }\n if (!config.apiKey) {\n throw new Error(\"setPaymasterConfig: apiKey is required\");\n }\n if (!config.feeRecipient) {\n throw new Error(\"setPaymasterConfig: feeRecipient is required\");\n }\n _config = { ...config };\n}\n\n/**\n * Get the current paymaster config. Throws if `setPaymasterConfig()`\n * has not been called yet — this surfaces boot-order bugs early\n * instead of failing with \"paymaster.feeRecipient is undefined\" at\n * the point of use.\n */\nexport function getPaymasterConfig(): PaymasterConfig {\n if (!_config) {\n throw new Error(\n \"PaymasterConfig not initialized — call setPaymasterConfig() at application boot before invoking any batch builder\",\n );\n }\n return _config;\n}\n\n/** Test helper — clear the singleton. */\nexport function _resetPaymasterConfigForTests(): void {\n _config = null;\n}\n\n/** Check whether paymaster config has been initialized. */\nexport function isPaymasterConfigured(): boolean {\n return _config !== null;\n}\n","import type { Address, PublicClient } from \"viem\";\n\n/**\n * Submission path chosen by `checkEthAndBranch`.\n * - `normal`: initiator has enough ETH; submit via `walletClient.writeContract`\n * or a plain `eth_sendRawTransaction`. No paymaster round-trip.\n * - `paymaster`: initiator doesn't have enough ETH; wrap the batch as a\n * UserOperation and route through PAFI Backend → Coinbase Paymaster\n * → Bundler.\n */\nexport type SubmissionPath = \"normal\" | \"paymaster\";\n\nexport interface CheckEthAndBranchParams {\n /** viem PublicClient bound to the target chain. */\n client: PublicClient;\n /** The address whose ETH balance we check. */\n initiator: Address;\n /** Estimated gas cost in wei for the upcoming tx. */\n estimatedGasWei: bigint;\n /**\n * Optional safety margin multiplier (basis points). Defaults to\n * 11_000 (110%) — the initiator needs 10% above the estimate to\n * qualify for the normal path. Prevents edge cases where gas price\n * spikes between estimation and submission cause a \"has enough\"\n * decision to fail at broadcast time.\n */\n marginBps?: number;\n}\n\nconst DEFAULT_MARGIN_BPS = 11_000;\n\n/**\n * Step 3 of the Generalized Flow ([SPONSORED_PATH_FLOW.md §2]):\n * choose between the normal path (initiator pays ETH directly) and the\n * paymaster path (bundler + Coinbase Paymaster).\n *\n * Intentionally synchronous in spirit — the only network call is\n * `getBalance`. Callers can parallelize it with other reads.\n */\nexport async function checkEthAndBranch(\n params: CheckEthAndBranchParams,\n): Promise<SubmissionPath> {\n const marginBps = params.marginBps ?? DEFAULT_MARGIN_BPS;\n const required =\n (params.estimatedGasWei * BigInt(marginBps)) / 10_000n;\n\n const balance = await params.client.getBalance({\n address: params.initiator,\n });\n\n return balance >= required ? \"normal\" : \"paymaster\";\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["/Users/phitran/Pacific-Finance/pafi-backend/pafi-sdk/packages/core/dist/index.cjs","../src/index.ts","../src/userop/types.ts","../src/paymaster/config.ts","../src/utils/checkEthAndBranch.ts","../src/contracts/mocks/relayerV2.mock.ts","../src/contracts/mocks/pointTokenV2.mock.ts","../src/contracts/mocks/batchExecutor.mock.ts","../src/contracts/mocks/addresses.mock.ts","../src/contracts/mocks/eip712/mintRequestV2.mock.ts","../src/contracts/mocks/eip712/burnConsent.mock.ts"],"names":["parseAbi","parseSignature","recoverTypedDataAddress"],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACtGA,4BAAyC;ADwGzC;AACA;AElGO,IAAM,gBAAA,EACX,4CAAA;AAmEK,IAAM,WAAA,EAAa,EAAA;AFiC1B;AACA;AG9FA,IAAI,QAAA,EAAkC,IAAA;AAO/B,SAAS,kBAAA,CAAmB,MAAA,EAA+B;AAChE,EAAA,GAAA,CAAI,CAAC,MAAA,CAAO,cAAA,EAAgB;AAC1B,IAAA,MAAM,IAAI,KAAA,CAAM,gDAAgD,CAAA;AAAA,EAClE;AACA,EAAA,GAAA,CAAI,CAAC,MAAA,CAAO,QAAA,EAAU;AACpB,IAAA,MAAM,IAAI,KAAA,CAAM,0CAA0C,CAAA;AAAA,EAC5D;AACA,EAAA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6B,EAAA;AACpB,IAAA;AACgB,MAAA;AACrB,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACF,IAAA;AACF,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAkBiC,EAAA;AACxB,IAAA;AACgB,MAAA;AACrB,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACF,IAAA;AACF,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAkBmB,EAAA;AACiB,IAAA;AACE,IAAA;AACb,IAAA;AACT,IAAA;AACiD,MAAA;AAC/D,IAAA;AAC0E,IAAA;AAC5E,EAAA;AAAA;AAGsD,EAAA;AAClB,IAAA;AACX,IAAA;AACT,IAAA;AACiD,MAAA;AAC/D,IAAA;AAC8C,IAAA;AAChD,EAAA;AACF;AD+JkH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/Users/phitran/Pacific-Finance/pafi-backend/pafi-sdk/packages/core/dist/index.cjs","sourcesContent":[null,"import { createPublicClient, http } from \"viem\";\nimport type { Address, Hex, PublicClient, WalletClient } from \"viem\";\n\n// -------------------------------------------------------------------------\n// Re-export all sub-modules\n// -------------------------------------------------------------------------\nexport * from \"./types\";\nexport * from \"./constants\";\nexport * from \"./errors\";\nexport * from \"./abi/index\";\nexport * from \"./eip712/index\";\nexport * from \"./relay/index\";\nexport * from \"./contract/index\";\nexport * from \"./quoting/index\";\nexport * from \"./swap/index\";\nexport * from \"./auth/index\";\n\n// v1.4 — Account Abstraction primitives (EIP-7702 + ERC-4337 v0.7)\nexport * from \"./userop/index\";\nexport * from \"./paymaster/index\";\nexport * from \"./utils/index\";\n\n// v1.4 — Contract ABIs + addresses + EIP-712 v2 types.\n// MOCKED until SC team ships real ABIs. See `src/contracts/mocks/README.md`.\n// Consumers: `import { RELAYER_V2_ABI, buildBurnConsentTypedData, ... } from '@pafi-dev/core'`\n// The re-export swaps mock → real in one file when SC delivers.\nexport * from \"./contracts/index\";\n\n// -------------------------------------------------------------------------\n// Internal imports for PafiSDK class\n// -------------------------------------------------------------------------\nimport { buildMintRequestTypedData, signMintRequest, verifyMintRequest } from \"./eip712/mintRequest\";\nimport {\n buildReceiverConsentTypedData,\n signReceiverConsent,\n verifyReceiverConsent,\n} from \"./eip712/receiverConsent\";\nimport {\n getMintRequestNonce,\n getReceiverConsentNonce,\n getTokenName,\n} from \"./contract/pointToken\";\nimport {\n encodeMintAndSwap,\n decodeMintAndSwap,\n encodeExtData,\n buildRelaySwapParams,\n} from \"./relay/calldata\";\nimport { findBestQuote } from \"./quoting/quote\";\nimport {\n buildSwapFromQuote,\n buildUniversalRouterExecuteArgs,\n} from \"./swap/universalRouter\";\nimport { simulateMintAndSwap } from \"./relay/simulate\";\nimport { simulateSwap } from \"./swap/simulate\";\nimport type { SimulationResult } from \"./relay/simulate\";\nimport type { SwapSimulationResult } from \"./swap/simulate\";\nimport { createLoginMessage } from \"./auth/loginMessage\";\nimport type { LoginMessageParams } from \"./auth/types\";\nimport { ConfigurationError } from \"./errors\";\nimport type {\n BestQuote,\n EIP712Signature,\n MintParams,\n MintRequest,\n PafiSDKConfig,\n PathKey,\n PointTokenDomainConfig,\n PoolKey,\n QuoteResult,\n ReceiverConsent,\n SignatureVerification,\n SwapParams,\n} from \"./types\";\n\n// -------------------------------------------------------------------------\n// PafiSDK — convenience class wrapping all contract + crypto primitives.\n//\n// This class is HTTP-client-free on purpose. It covers signing, verifying,\n// contract reads, and calldata encoding — the things that need a signer\n// or a provider but no HTTP layer. The issuer backend defines its own HTTP\n// contract via `@pafi/issuer`; frontends build `fetch()` calls against\n// those types directly.\n// -------------------------------------------------------------------------\n\nexport class PafiSDK {\n private _pointTokenAddress?: Address;\n private _relayContractAddress?: Address;\n private _signer?: WalletClient;\n private _provider?: PublicClient;\n private _chainId?: number;\n\n constructor(config: PafiSDKConfig) {\n this._pointTokenAddress = config.pointTokenAddress;\n this._relayContractAddress = config.relayContractAddress;\n this._signer = config.signer;\n this._chainId = config.chainId;\n\n if (config.provider) {\n this._provider = config.provider;\n } else if (config.rpcUrl) {\n this._provider = createPublicClient({\n transport: http(config.rpcUrl),\n });\n }\n }\n\n // -------------------------------------------------------------------------\n // Setters\n // -------------------------------------------------------------------------\n\n setPointTokenAddress(address: Address): void {\n this._pointTokenAddress = address;\n }\n\n setRelayContractAddress(address: Address): void {\n this._relayContractAddress = address;\n }\n\n setSigner(signer: WalletClient): void {\n this._signer = signer;\n }\n\n setProvider(provider: PublicClient): void {\n this._provider = provider;\n }\n\n // -------------------------------------------------------------------------\n // Private guards\n // -------------------------------------------------------------------------\n\n private requirePointToken(): Address {\n if (!this._pointTokenAddress) {\n throw new ConfigurationError(\"pointTokenAddress not set\");\n }\n return this._pointTokenAddress;\n }\n\n private requireProvider(): PublicClient {\n if (!this._provider) {\n throw new ConfigurationError(\"provider not set\");\n }\n return this._provider;\n }\n\n private requireSigner(): WalletClient {\n if (!this._signer) {\n throw new ConfigurationError(\"signer not set\");\n }\n return this._signer;\n }\n\n private requireChainId(): number {\n if (this._chainId === undefined) {\n throw new ConfigurationError(\"chainId not set\");\n }\n return this._chainId;\n }\n\n // -------------------------------------------------------------------------\n // Domain\n // -------------------------------------------------------------------------\n\n async getDomain(): Promise<PointTokenDomainConfig> {\n const provider = this.requireProvider();\n const pointToken = this.requirePointToken();\n const chainId = this.requireChainId();\n const name = await getTokenName(provider, pointToken);\n return { name, verifyingContract: pointToken, chainId };\n }\n\n // -------------------------------------------------------------------------\n // EIP-712 — delegates to pure functions\n // -------------------------------------------------------------------------\n\n /**\n * Build the EIP-712 typed data for a MintRequest.\n * Pass the result to any external signer (Privy, WalletConnect, etc.).\n */\n async buildMintRequestTypedData(message: MintRequest) {\n const domain = await this.getDomain();\n return buildMintRequestTypedData(domain, message);\n }\n\n /**\n * Build the EIP-712 typed data for a ReceiverConsent.\n * Pass the result to any external signer (Privy, WalletConnect, etc.).\n */\n async buildReceiverConsentTypedData(message: ReceiverConsent) {\n const domain = await this.getDomain();\n return buildReceiverConsentTypedData(domain, message);\n }\n\n async signMintRequest(message: MintRequest): Promise<EIP712Signature> {\n const domain = await this.getDomain();\n return signMintRequest(this.requireSigner(), domain, message);\n }\n\n async verifyMintRequest(\n message: MintRequest,\n signature: Hex,\n expectedMinter: Address,\n ): Promise<SignatureVerification> {\n const domain = await this.getDomain();\n return verifyMintRequest(domain, message, signature, expectedMinter);\n }\n\n async signReceiverConsent(\n message: ReceiverConsent,\n ): Promise<EIP712Signature> {\n const domain = await this.getDomain();\n return signReceiverConsent(this.requireSigner(), domain, message);\n }\n\n async verifyReceiverConsent(\n message: ReceiverConsent,\n signature: Hex,\n expectedReceiver: Address,\n ): Promise<SignatureVerification> {\n const domain = await this.getDomain();\n return verifyReceiverConsent(domain, message, signature, expectedReceiver);\n }\n\n // -------------------------------------------------------------------------\n // Contract reads\n // -------------------------------------------------------------------------\n\n async getMintRequestNonce(receiver: Address): Promise<bigint> {\n return getMintRequestNonce(\n this.requireProvider(),\n this.requirePointToken(),\n receiver,\n );\n }\n\n async getReceiverConsentNonce(receiver: Address): Promise<bigint> {\n return getReceiverConsentNonce(\n this.requireProvider(),\n this.requirePointToken(),\n receiver,\n );\n }\n\n // -------------------------------------------------------------------------\n // Relay calldata — delegates to pure functions\n // -------------------------------------------------------------------------\n\n encodeMintAndSwap(mint: MintParams, swap: SwapParams): Hex {\n return encodeMintAndSwap(mint, swap);\n }\n\n decodeMintAndSwap(calldata: Hex): { mint: MintParams; swap: SwapParams } {\n return decodeMintAndSwap(calldata);\n }\n\n // -------------------------------------------------------------------------\n // Quoting — delegates to pure functions\n // -------------------------------------------------------------------------\n\n /**\n * Find the best swap route from `tokenIn` to `tokenOut`.\n * Merges `pools` with COMMON_POOLS for the configured chain, builds all\n * paths, and quotes via a single multicall RPC call.\n */\n async findBestQuote(\n tokenIn: Address,\n tokenOut: Address,\n exactAmount: bigint,\n pools: PoolKey[] = [],\n quoterAddress?: Address,\n maxHops?: number,\n ): Promise<BestQuote> {\n return findBestQuote(\n this.requireProvider(),\n this.requireChainId(),\n tokenIn,\n tokenOut,\n exactAmount,\n pools,\n quoterAddress,\n maxHops,\n );\n }\n\n // -------------------------------------------------------------------------\n // Swap building — delegates to pure functions\n // -------------------------------------------------------------------------\n\n /**\n * Build UniversalRouter execute args from a quote result.\n * The caller provides `minAmountOut` after applying their own slippage.\n */\n buildSwapFromQuote(params: {\n quote: QuoteResult;\n currencyIn: Address;\n currencyOut: Address;\n amountIn: bigint;\n minAmountOut: bigint;\n }): { commands: Hex; inputs: Hex[] } {\n return buildSwapFromQuote(params);\n }\n\n /**\n * Build Relay SwapParams + extData from a quote result.\n * Returns ready-to-use args for `Relay.mintAndSwap`.\n */\n buildRelaySwapParams(params: {\n quote: { path: PathKey[] };\n minAmountOut: bigint;\n feeInUsdt: bigint;\n deadline: bigint;\n }): { swapParams: SwapParams; extData: Hex } {\n return buildRelaySwapParams(params);\n }\n\n /**\n * Encode extData for ReceiverConsent and MintParams.\n * extData = abi.encode(minAmountOut, feeInUsdt)\n */\n encodeExtData(minAmountOut: bigint, feeInUsdt: bigint): Hex {\n return encodeExtData(minAmountOut, feeInUsdt);\n }\n\n // -------------------------------------------------------------------------\n // Simulation — dry-run via eth_call (no gas spent)\n // -------------------------------------------------------------------------\n\n /**\n * Simulate a Relay.mintAndSwap call. Catches reverts (bad signatures,\n * expired deadlines, insufficient mint cap, pool errors) before submitting.\n *\n * @param relayAddress - Relay contract address\n * @param mint - MintParams with real signatures\n * @param swap - SwapParams (path + deadline)\n * @param from - Relayer address that will submit the tx\n */\n async simulateMintAndSwap(\n relayAddress: Address,\n mint: MintParams,\n swap: SwapParams,\n from: Address,\n ): Promise<SimulationResult> {\n return simulateMintAndSwap(\n this.requireProvider(),\n relayAddress,\n mint,\n swap,\n from,\n );\n }\n\n /**\n * Simulate a UniversalRouter.execute swap call. Catches reverts (bad\n * approvals, insufficient balance, pool errors) before submitting.\n *\n * @param routerAddress - UniversalRouter contract address\n * @param commands - Packed command bytes (from buildSwapFromQuote)\n * @param inputs - Encoded inputs (from buildSwapFromQuote)\n * @param deadline - Unix timestamp\n * @param from - Address that will execute the swap\n */\n async simulateSwap(\n routerAddress: Address,\n commands: Hex,\n inputs: Hex[],\n deadline: bigint,\n from: Address,\n ): Promise<SwapSimulationResult> {\n return simulateSwap(\n this.requireProvider(),\n routerAddress,\n commands,\n inputs,\n deadline,\n from,\n );\n }\n\n // -------------------------------------------------------------------------\n // Auth — EIP-4361 login helpers (offline, stateless)\n //\n // These are convenience wrappers around the pure functions in\n // `./auth/loginMessage.ts`. They do NOT hit the network — the caller is\n // responsible for fetching the nonce, POSTing the signed message, and\n // storing the JWT returned by the issuer backend.\n // -------------------------------------------------------------------------\n\n /**\n * Build an EIP-4361 login message for the current signer + chain. The\n * caller supplies the issuer-specific fields (domain, nonce, uri); the SDK\n * fills in the wallet address and chain id from its own config.\n */\n async createLoginMessage(\n params: Omit<LoginMessageParams, \"address\" | \"chainId\">,\n ): Promise<string> {\n const signer = this.requireSigner();\n const chainId = this.requireChainId();\n const account = signer.account;\n if (!account) {\n throw new ConfigurationError(\"signer has no account attached\");\n }\n return createLoginMessage({ ...params, address: account.address, chainId });\n }\n\n /** Sign a login message string with the current signer (personal_sign) */\n async signLoginMessage(message: string): Promise<Hex> {\n const signer = this.requireSigner();\n const account = signer.account;\n if (!account) {\n throw new ConfigurationError(\"signer has no account attached\");\n }\n return signer.signMessage({ account, message });\n }\n}\n","import type { Address, Hex } from \"viem\";\n\n/**\n * ERC-4337 v0.7 EntryPoint standard address (deployed deterministically\n * at the same address across chains).\n * https://eips.ethereum.org/EIPS/eip-4337\n */\nexport const ENTRY_POINT_V07: Address =\n \"0x0000000071727De22E5E9d8BAf0edAc6f37da032\";\n\n/**\n * A single call inside a batch. `BatchExecutor.execute(Call[])` iterates\n * and invokes each one. When the batch runs via EIP-7702 delegation,\n * `msg.sender` for each call is the user's EOA.\n */\nexport interface Operation {\n target: Address;\n value: bigint;\n data: Hex;\n}\n\n/**\n * Paymaster fields attached to a UserOperation. Populated by the\n * Coinbase Paymaster (via PAFI Backend proxy) before the user signs.\n */\nexport interface PaymasterFields {\n paymaster: Address;\n paymasterData: Hex;\n paymasterVerificationGasLimit: bigint;\n paymasterPostOpGasLimit: bigint;\n}\n\n/**\n * Partial UserOp used during preparation — before paymaster fields are\n * attached or the user signs.\n */\nexport interface PartialUserOperation {\n sender: Address;\n nonce: bigint;\n callData: Hex;\n callGasLimit: bigint;\n verificationGasLimit: bigint;\n preVerificationGas: bigint;\n maxFeePerGas: bigint;\n maxPriorityFeePerGas: bigint;\n}\n\n/**\n * Full ERC-4337 v0.7 UserOperation, ready for bundler submission.\n */\nexport interface UserOperation extends PartialUserOperation {\n paymaster: Address;\n paymasterData: Hex;\n paymasterVerificationGasLimit: bigint;\n paymasterPostOpGasLimit: bigint;\n signature: Hex;\n}\n\n/**\n * Receipt returned by a bundler after a UserOp lands on-chain.\n */\nexport interface UserOpReceipt {\n userOpHash: Hex;\n success: boolean;\n txHash: Hex;\n blockNumber: bigint;\n gasUsed: bigint;\n /** Effective gas cost paid (wei). */\n actualGasCost: bigint;\n}\n\n/**\n * Sentinel operation value used in tests + docs when `Operation.value`\n * is irrelevant (ERC-20 transfers, for example).\n */\nexport const ZERO_VALUE = 0n;\n","import type { PaymasterConfig } from \"./types\";\n\n/**\n * Module-level paymaster config. Read by batch builders (via\n * `getPaymasterConfig()`) and by `@pafi/issuer` `RelayService` when\n * building UserOps.\n *\n * Consumers call `setPaymasterConfig()` once at application boot. All\n * subsequent helpers that need the feeRecipient / issuer identity /\n * backend URL pull from here.\n *\n * This is global state by design — making every batch builder take a\n * config param would clutter every call site. The alternative (a\n * context/service) has more ceremony than this flow justifies.\n */\nlet _config: PaymasterConfig | null = null;\n\n/**\n * Set the application-wide paymaster config. Safe to call multiple\n * times (later calls override earlier). Throws if required fields\n * are missing.\n */\nexport function setPaymasterConfig(config: PaymasterConfig): void {\n if (!config.pafiBackendUrl) {\n throw new Error(\"setPaymasterConfig: pafiBackendUrl is required\");\n }\n if (!config.issuerId) {\n throw new Error(\"setPaymasterConfig: issuerId is required\");\n }\n if (!config.apiKey) {\n throw new Error(\"setPaymasterConfig: apiKey is required\");\n }\n if (!config.feeRecipient) {\n throw new Error(\"setPaymasterConfig: feeRecipient is required\");\n }\n _config = { ...config };\n}\n\n/**\n * Get the current paymaster config. Throws if `setPaymasterConfig()`\n * has not been called yet — this surfaces boot-order bugs early\n * instead of failing with \"paymaster.feeRecipient is undefined\" at\n * the point of use.\n */\nexport function getPaymasterConfig(): PaymasterConfig {\n if (!_config) {\n throw new Error(\n \"PaymasterConfig not initialized — call setPaymasterConfig() at application boot before invoking any batch builder\",\n );\n }\n return _config;\n}\n\n/** Test helper — clear the singleton. */\nexport function _resetPaymasterConfigForTests(): void {\n _config = null;\n}\n\n/** Check whether paymaster config has been initialized. */\nexport function isPaymasterConfigured(): boolean {\n return _config !== null;\n}\n","import type { Address, PublicClient } from \"viem\";\n\n/**\n * Submission path chosen by `checkEthAndBranch`.\n * - `normal`: initiator has enough ETH; submit via `walletClient.writeContract`\n * or a plain `eth_sendRawTransaction`. No paymaster round-trip.\n * - `paymaster`: initiator doesn't have enough ETH; wrap the batch as a\n * UserOperation and route through PAFI Backend → Coinbase Paymaster\n * → Bundler.\n */\nexport type SubmissionPath = \"normal\" | \"paymaster\";\n\nexport interface CheckEthAndBranchParams {\n /** viem PublicClient bound to the target chain. */\n client: PublicClient;\n /** The address whose ETH balance we check. */\n initiator: Address;\n /** Estimated gas cost in wei for the upcoming tx. */\n estimatedGasWei: bigint;\n /**\n * Optional safety margin multiplier (basis points). Defaults to\n * 11_000 (110%) — the initiator needs 10% above the estimate to\n * qualify for the normal path. Prevents edge cases where gas price\n * spikes between estimation and submission cause a \"has enough\"\n * decision to fail at broadcast time.\n */\n marginBps?: number;\n}\n\nconst DEFAULT_MARGIN_BPS = 11_000;\n\n/**\n * Step 3 of the Generalized Flow ([SPONSORED_PATH_FLOW.md §2]):\n * choose between the normal path (initiator pays ETH directly) and the\n * paymaster path (bundler + Coinbase Paymaster).\n *\n * Intentionally synchronous in spirit — the only network call is\n * `getBalance`. Callers can parallelize it with other reads.\n */\nexport async function checkEthAndBranch(\n params: CheckEthAndBranchParams,\n): Promise<SubmissionPath> {\n const marginBps = params.marginBps ?? DEFAULT_MARGIN_BPS;\n const required =\n (params.estimatedGasWei * BigInt(marginBps)) / 10_000n;\n\n const balance = await params.client.getBalance({\n address: params.initiator,\n });\n\n return balance >= required ? \"normal\" : \"paymaster\";\n}\n","import { parseAbi } from \"viem\";\nimport type { Address } from \"viem\";\n\n/**\n * ⚠️ MOCK — Relayer v2 `mint()` ABI for the v1.4 sponsored flow.\n *\n * Signature guess based on stakeholder memo (`REQUIREMENTS_V2.md §3`):\n *\n * mint(\n * MintRequest request, // EIP-712 signed by user + issuer\n * Signature userSig, // v, r, s\n * Signature issuerSig, // v, r, s\n * uint256 feeAmount, // PT units to split off to feeRecipient\n * address feeRecipient // typically operator or fee collector\n * )\n *\n * Behaviour expected:\n * - Verify user + issuer EIP-712 signatures against `request`\n * - Mint `request.amount` PT to `request.to`\n * - Atomic transfer `feeAmount` from `request.to` → `feeRecipient`\n * (net mint = `amount - feeAmount`)\n * - Increment the on-chain nonce to prevent replay\n *\n * When SC team publishes the real ABI, drop it in under\n * `src/contracts/real/relayerV2.abi.ts` and flip the export in\n * `src/contracts/index.ts` — call sites unchanged.\n *\n * See [SC_MOCK_PLAN.md §2.1] for the rationale + swap checklist.\n */\n\nexport const MOCK_RELAYER_V2_ABI = parseAbi([\n \"function mint((address to, uint256 amount, uint256 feeAmount, address feeRecipient, uint256 nonce, uint256 deadline, bytes extData) request, (uint8 v, bytes32 r, bytes32 s) userSig, (uint8 v, bytes32 r, bytes32 s) issuerSig) external\",\n // View functions we'll likely want (nonce getter is standard)\n \"function mintRequestNonce(address user) external view returns (uint256)\",\n \"event Minted(address indexed user, uint256 amount, uint256 feeAmount, address indexed feeRecipient, bytes32 requestHash)\",\n] as const);\n\n/**\n * Calldata function selector for `mint((...),(...),(...))` as encoded\n * by viem against {@link MOCK_RELAYER_V2_ABI}. Callers compare against\n * this to sanity-check decoded UserOp inner calls.\n *\n * Recompute when the real ABI lands — almost certainly differs.\n */\nexport const MOCK_RELAYER_V2_MINT_SELECTOR = \"0xMOCKED__\" as const;\n\n/**\n * Struct shape that matches {@link MOCK_RELAYER_V2_ABI}. Exported so\n * builders can accept a typed input without `as const` gymnastics.\n */\nexport interface MockMintRequestV2 {\n to: Address;\n amount: bigint;\n feeAmount: bigint;\n feeRecipient: Address;\n nonce: bigint;\n deadline: bigint;\n extData: `0x${string}`;\n}\n\nexport interface MockSignatureStruct {\n v: number;\n r: `0x${string}`;\n s: `0x${string}`;\n}\n","import { parseAbi } from \"viem\";\n\n/**\n * ⚠️ MOCK — `PointToken` v1.4 burn surface.\n *\n * Two variants mocked — SC team will pick ONE before stable; the other\n * gets deleted during Phase B swap.\n *\n * Variant A (simpler, most likely):\n * burn(uint256 amount)\n * - burns from `msg.sender`\n * - caller handles authorization (the user is `msg.sender` via\n * EIP-7702 delegation, so `msg.sender == user`)\n *\n * Variant B (signature-based, if SC prefers explicit consent on-chain):\n * burnWithSig(BurnConsent consent, Signature sig)\n * - verifies EIP-712 signature before burning\n * - used when the caller isn't the user (e.g. a relayer burns on\n * behalf of the user)\n *\n * Either way the ERC-20 emits `Transfer(from, address(0), amount)` so\n * `BurnIndexer` semantics don't change.\n */\nexport const MOCK_POINT_TOKEN_V2_ABI = parseAbi([\n // Variant A\n \"function burn(uint256 amount) external\",\n // Variant B\n \"function burnWithSig((address user, address pointToken, uint256 amount, uint256 nonce, uint256 deadline) consent, (uint8 v, bytes32 r, bytes32 s) sig) external\",\n // Standard reads we always need\n \"function balanceOf(address user) external view returns (uint256)\",\n \"function burnNonce(address user) external view returns (uint256)\",\n // ERC-20 Transfer event (inherited) — BurnIndexer filters `to = 0x0`\n \"event Transfer(address indexed from, address indexed to, uint256 value)\",\n] as const);\n","import { parseAbi } from \"viem\";\nimport type { Address } from \"viem\";\n\n/**\n * ⚠️ MOCK — placeholder BatchExecutor address.\n *\n * Real deployment:\n * - Coinbase may pre-deploy a canonical BatchExecutor that we target\n * via EIP-7702 delegation (see blocker B2 in V1.4_V1.5_READINESS.md)\n * - Otherwise PAFI deploys a minimal one and publishes the address\n *\n * The ABI itself (`execute(Call[])`) is stable and lives under\n * `../../userop/batchExecute.ts` — that's the real one, unchanged\n * by the mock swap. Only the **address** is mocked here.\n *\n * Pattern: checksum address with hex \"DEAD0001\" suffix per chain so\n * it's obvious in logs which chain is using a mock.\n */\n\n// Base Sepolia (testnet)\nexport const MOCK_BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA =\n \"0x000000000000000000000000000000000000DE01\" as Address;\n\n// Base mainnet\nexport const MOCK_BATCH_EXECUTOR_ADDRESS_BASE_MAINNET =\n \"0x000000000000000000000000000000000000DE02\" as Address;\n\n// Re-export the real ABI from userop module (not mocked — ABI is stable)\nexport { BATCH_EXECUTOR_ABI } from \"../../userop/batchExecute\";\n","import type { Address } from \"viem\";\n\n/**\n * ⚠️ MOCK — per-chain contract addresses for the v1.4 sponsored flow.\n *\n * Real addresses come from SC team once they deploy Relayer v2 and\n * pick a BatchExecutor. Until then we use placeholders so the SDK\n * code path compiles + tests execute end-to-end.\n *\n * **Intentionally not merge-safe to mainnet** — callers that resolve\n * a mainnet address here get a `0x...DEAD` placeholder which will\n * revert at contract-level. That's the point: prod refuses to run\n * on mocks.\n *\n * Chain id map:\n * - 8453 Base mainnet\n * - 84532 Base Sepolia\n *\n * Swap workflow when SC delivers:\n * 1. Rename this file → `addresses.ts` under `src/contracts/real/`\n * 2. Fill real addresses per chain\n * 3. Update `src/contracts/index.ts` re-export\n * 4. Delete MOCK_* named exports\n */\n\nexport interface ContractAddresses {\n relayerV2: Address;\n pointToken: Address;\n batchExecutor: Address;\n usdt: Address;\n issuerRegistry: Address;\n mintingOracle: Address;\n}\n\nconst MOCK_PLACEHOLDER = (suffix: string): Address =>\n `0x000000000000000000000000000000000000${suffix.toLowerCase().padStart(4, \"0\")}` as Address;\n\nexport const MOCK_ADDRESSES: Record<number, ContractAddresses> = {\n // Base Sepolia — safe targets for integration tests (MockRelayer\n // fixtures deployed by Hardhat will override these at test time)\n 84532: {\n relayerV2: MOCK_PLACEHOLDER(\"de10\"),\n pointToken: MOCK_PLACEHOLDER(\"de11\"),\n batchExecutor: MOCK_PLACEHOLDER(\"de01\"),\n usdt: MOCK_PLACEHOLDER(\"de12\"),\n issuerRegistry: MOCK_PLACEHOLDER(\"de13\"),\n mintingOracle: MOCK_PLACEHOLDER(\"de14\"),\n },\n // Base mainnet — intentionally left as placeholder. Do NOT ship to\n // prod without swapping.\n 8453: {\n relayerV2: MOCK_PLACEHOLDER(\"dead\"),\n pointToken: MOCK_PLACEHOLDER(\"dead\"),\n batchExecutor: MOCK_PLACEHOLDER(\"dead\"),\n usdt: MOCK_PLACEHOLDER(\"dead\"),\n issuerRegistry: MOCK_PLACEHOLDER(\"dead\"),\n mintingOracle: MOCK_PLACEHOLDER(\"dead\"),\n },\n};\n\n/**\n * Lookup helper — throws if the chain isn't in the map so callers fail\n * loudly on misconfiguration instead of silently using `undefined`.\n */\nexport function getMockAddresses(chainId: number): ContractAddresses {\n const addrs = MOCK_ADDRESSES[chainId];\n if (!addrs) {\n throw new Error(\n `getMockAddresses: no mock addresses for chainId ${chainId}. ` +\n `Supported: ${Object.keys(MOCK_ADDRESSES).join(\", \")}`,\n );\n }\n return addrs;\n}\n","import {\n parseSignature,\n recoverTypedDataAddress,\n type Address,\n type Hex,\n type WalletClient,\n} from \"viem\";\nimport { buildDomain } from \"../../../eip712/domain\";\nimport type {\n EIP712Signature,\n PointTokenDomainConfig,\n SignatureVerification,\n} from \"../../../types\";\nimport type { MockMintRequestV2 } from \"../relayerV2.mock\";\n\n/**\n * ⚠️ MOCK — `MintRequest` v2 EIP-712 types.\n *\n * Extends v0.2.x `MintRequest` (4 fields) with three new fields needed\n * for the v1.4 sponsored flow:\n *\n * + feeAmount PT units taken from the mint for the operator\n * + feeRecipient where the fee goes (operator or treasury)\n * + extData arbitrary bytes for future extensions (swap path, etc.)\n *\n * When SC team confirms the real struct, drop this file's content into\n * the real builder and remove the MOCK_ prefix. The function signatures\n * below stay stable — only `MOCK_MINT_REQUEST_V2_TYPES` changes.\n */\nexport const MOCK_MINT_REQUEST_V2_TYPES = {\n MintRequest: [\n { name: \"to\", type: \"address\" },\n { name: \"amount\", type: \"uint256\" },\n { name: \"feeAmount\", type: \"uint256\" },\n { name: \"feeRecipient\", type: \"address\" },\n { name: \"nonce\", type: \"uint256\" },\n { name: \"deadline\", type: \"uint256\" },\n { name: \"extData\", type: \"bytes\" },\n ],\n} as const;\n\n/**\n * Build the typed-data envelope that any EIP-712 signer (viem, ethers,\n * Privy) can consume. Callers typically pass the result to\n * `walletClient.signTypedData()` or `privy.signTypedData()`.\n */\nexport function buildMockMintRequestV2TypedData(\n domain: PointTokenDomainConfig,\n message: MockMintRequestV2,\n) {\n return {\n domain: buildDomain(domain),\n types: MOCK_MINT_REQUEST_V2_TYPES,\n primaryType: \"MintRequest\" as const,\n message,\n };\n}\n\n/**\n * Sign a `MintRequest` v2 with a viem WalletClient — server-side flow\n * where the issuer holds the private key directly (KMS-backed signer\n * is the production path; see `@pafi-dev/issuer` KMSSignerAdapter).\n */\nexport async function signMockMintRequestV2(\n walletClient: WalletClient,\n domain: PointTokenDomainConfig,\n message: MockMintRequestV2,\n): Promise<EIP712Signature> {\n const serialized = await walletClient.signTypedData({\n account: walletClient.account!,\n domain: buildDomain(domain),\n types: MOCK_MINT_REQUEST_V2_TYPES,\n primaryType: \"MintRequest\",\n message,\n });\n\n const { v, r, s } = parseSignature(serialized);\n return {\n v: Number(v),\n r,\n s,\n serialized,\n };\n}\n\n/**\n * Verify a `MintRequest` v2 signature and check it came from the\n * expected signer (either user or issuer depending on which side is\n * being verified).\n */\nexport async function verifyMockMintRequestV2(\n domain: PointTokenDomainConfig,\n message: MockMintRequestV2,\n signature: Hex,\n expectedSigner: Address,\n): Promise<SignatureVerification> {\n const recoveredAddress = await recoverTypedDataAddress({\n domain: buildDomain(domain),\n types: MOCK_MINT_REQUEST_V2_TYPES,\n primaryType: \"MintRequest\",\n message,\n signature,\n });\n\n const isValid =\n recoveredAddress.toLowerCase() === expectedSigner.toLowerCase();\n\n return {\n isValid,\n recoveredAddress,\n };\n}\n","import {\n parseSignature,\n recoverTypedDataAddress,\n type Address,\n type Hex,\n type WalletClient,\n} from \"viem\";\nimport { buildDomain } from \"../../../eip712/domain\";\nimport type {\n EIP712Signature,\n PointTokenDomainConfig,\n SignatureVerification,\n} from \"../../../types\";\n\n/**\n * ⚠️ MOCK — `BurnConsent` EIP-712 type for the v1.4 reverse flow.\n *\n * New type entirely — v0.2.x had no burn-for-credit flow.\n *\n * User signs `BurnConsent` to authorize burning `amount` PT from their\n * wallet in exchange for an off-chain credit of (amount - gasFee).\n * Signature is consumed either by:\n * - A relayer calling `PointToken.burnWithSig(...)` (Variant B)\n * - The paymaster-proxy-sponsored UserOp calling `PointToken.burn(...)`\n * with msg.sender = user via EIP-7702 (Variant A)\n *\n * Either way the tx emits `Transfer(user → 0x0)` which the issuer's\n * `BurnIndexer` watches for and uses to credit the off-chain ledger.\n *\n * Field list is a best-guess — SC team may add fields (e.g. `feeAmount`\n * explicit, `extData`). Update this mock when they freeze the spec.\n */\nexport interface MockBurnConsent {\n user: Address;\n pointToken: Address;\n amount: bigint;\n nonce: bigint;\n deadline: bigint;\n}\n\nexport const MOCK_BURN_CONSENT_TYPES = {\n BurnConsent: [\n { name: \"user\", type: \"address\" },\n { name: \"pointToken\", type: \"address\" },\n { name: \"amount\", type: \"uint256\" },\n { name: \"nonce\", type: \"uint256\" },\n { name: \"deadline\", type: \"uint256\" },\n ],\n} as const;\n\nexport function buildMockBurnConsentTypedData(\n domain: PointTokenDomainConfig,\n message: MockBurnConsent,\n) {\n return {\n domain: buildDomain(domain),\n types: MOCK_BURN_CONSENT_TYPES,\n primaryType: \"BurnConsent\" as const,\n message,\n };\n}\n\nexport async function signMockBurnConsent(\n walletClient: WalletClient,\n domain: PointTokenDomainConfig,\n message: MockBurnConsent,\n): Promise<EIP712Signature> {\n const serialized = await walletClient.signTypedData({\n account: walletClient.account!,\n domain: buildDomain(domain),\n types: MOCK_BURN_CONSENT_TYPES,\n primaryType: \"BurnConsent\",\n message,\n });\n\n const { v, r, s } = parseSignature(serialized);\n return {\n v: Number(v),\n r,\n s,\n serialized,\n };\n}\n\nexport async function verifyMockBurnConsent(\n domain: PointTokenDomainConfig,\n message: MockBurnConsent,\n signature: Hex,\n expectedUser: Address,\n): Promise<SignatureVerification> {\n const recoveredAddress = await recoverTypedDataAddress({\n domain: buildDomain(domain),\n types: MOCK_BURN_CONSENT_TYPES,\n primaryType: \"BurnConsent\",\n message,\n signature,\n });\n\n const isValid =\n recoveredAddress.toLowerCase() === expectedUser.toLowerCase();\n\n return {\n isValid,\n recoveredAddress,\n };\n}\n"]}
|