@pafi-dev/core 0.3.0-beta.2 → 0.3.0-beta.3
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/index.cjs +15 -82
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +75 -234
- package/dist/index.d.ts +75 -234
- package/dist/index.js +19 -86
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -276,90 +276,44 @@ interface CheckEthAndBranchParams {
|
|
|
276
276
|
declare function checkEthAndBranch(params: CheckEthAndBranchParams): Promise<SubmissionPath>;
|
|
277
277
|
|
|
278
278
|
/**
|
|
279
|
-
* ⚠️ MOCK —
|
|
279
|
+
* ⚠️ MOCK — `PointToken` v1.4 surface (mint + burn).
|
|
280
280
|
*
|
|
281
|
-
*
|
|
281
|
+
* ## Mint (NEW direct flow — no Relayer)
|
|
282
282
|
*
|
|
283
|
-
*
|
|
284
|
-
*
|
|
285
|
-
*
|
|
286
|
-
*
|
|
287
|
-
*
|
|
288
|
-
* address feeRecipient // typically operator or fee collector
|
|
289
|
-
* )
|
|
283
|
+
* In v1.4 the user calls `PointToken.mint()` directly via an EIP-7702
|
|
284
|
+
* delegated UserOp — `msg.sender == user`. The contract checks the
|
|
285
|
+
* caller is on its authorized minter allowlist. **No Relayer contract,
|
|
286
|
+
* no MintRequest EIP-712 signature.** Backend (gg56) only validates
|
|
287
|
+
* off-chain (balance, policy, KYC) before returning the unsigned UserOp.
|
|
290
288
|
*
|
|
291
|
-
*
|
|
292
|
-
*
|
|
293
|
-
*
|
|
294
|
-
* - Atomic transfer `feeAmount` from `request.to` → `feeRecipient`
|
|
295
|
-
* (net mint = `amount - feeAmount`)
|
|
296
|
-
* - Increment the on-chain nonce to prevent replay
|
|
289
|
+
* The mock signature `mint(uint256 amount)` mints to `msg.sender`.
|
|
290
|
+
* SC team confirmation pending — they may pick `mint(address to,
|
|
291
|
+
* uint256 amount)` instead. Either is a 1-line ABI change here.
|
|
297
292
|
*
|
|
298
|
-
*
|
|
299
|
-
* `src/contracts/real/relayerV2.abi.ts` and flip the export in
|
|
300
|
-
* `src/contracts/index.ts` — call sites unchanged.
|
|
293
|
+
* ## Burn — two variants mocked
|
|
301
294
|
*
|
|
302
|
-
*
|
|
295
|
+
* Variant A (simpler, most likely):
|
|
296
|
+
* burn(uint256 amount)
|
|
297
|
+
* - burns from `msg.sender` (user via EIP-7702)
|
|
298
|
+
*
|
|
299
|
+
* Variant B (signature-based, if SC prefers explicit on-chain consent):
|
|
300
|
+
* burnWithSig(BurnConsent consent, Signature sig)
|
|
301
|
+
* - verifies EIP-712 signature before burning
|
|
302
|
+
*
|
|
303
|
+
* Either way the ERC-20 emits `Transfer(from, address(0), amount)` so
|
|
304
|
+
* `BurnIndexer` semantics don't change.
|
|
303
305
|
*/
|
|
304
|
-
declare const
|
|
306
|
+
declare const MOCK_POINT_TOKEN_V2_ABI: readonly [{
|
|
305
307
|
readonly name: "mint";
|
|
306
308
|
readonly type: "function";
|
|
307
309
|
readonly stateMutability: "nonpayable";
|
|
308
310
|
readonly inputs: readonly [{
|
|
309
|
-
readonly type: "
|
|
310
|
-
readonly
|
|
311
|
-
readonly type: "address";
|
|
312
|
-
readonly name: "to";
|
|
313
|
-
}, {
|
|
314
|
-
readonly type: "uint256";
|
|
315
|
-
readonly name: "amount";
|
|
316
|
-
}, {
|
|
317
|
-
readonly type: "uint256";
|
|
318
|
-
readonly name: "feeAmount";
|
|
319
|
-
}, {
|
|
320
|
-
readonly type: "address";
|
|
321
|
-
readonly name: "feeRecipient";
|
|
322
|
-
}, {
|
|
323
|
-
readonly type: "uint256";
|
|
324
|
-
readonly name: "nonce";
|
|
325
|
-
}, {
|
|
326
|
-
readonly type: "uint256";
|
|
327
|
-
readonly name: "deadline";
|
|
328
|
-
}, {
|
|
329
|
-
readonly type: "bytes";
|
|
330
|
-
readonly name: "extData";
|
|
331
|
-
}];
|
|
332
|
-
readonly name: "request";
|
|
333
|
-
}, {
|
|
334
|
-
readonly type: "tuple";
|
|
335
|
-
readonly components: readonly [{
|
|
336
|
-
readonly type: "uint8";
|
|
337
|
-
readonly name: "v";
|
|
338
|
-
}, {
|
|
339
|
-
readonly type: "bytes32";
|
|
340
|
-
readonly name: "r";
|
|
341
|
-
}, {
|
|
342
|
-
readonly type: "bytes32";
|
|
343
|
-
readonly name: "s";
|
|
344
|
-
}];
|
|
345
|
-
readonly name: "userSig";
|
|
346
|
-
}, {
|
|
347
|
-
readonly type: "tuple";
|
|
348
|
-
readonly components: readonly [{
|
|
349
|
-
readonly type: "uint8";
|
|
350
|
-
readonly name: "v";
|
|
351
|
-
}, {
|
|
352
|
-
readonly type: "bytes32";
|
|
353
|
-
readonly name: "r";
|
|
354
|
-
}, {
|
|
355
|
-
readonly type: "bytes32";
|
|
356
|
-
readonly name: "s";
|
|
357
|
-
}];
|
|
358
|
-
readonly name: "issuerSig";
|
|
311
|
+
readonly type: "uint256";
|
|
312
|
+
readonly name: "amount";
|
|
359
313
|
}];
|
|
360
314
|
readonly outputs: readonly [];
|
|
361
315
|
}, {
|
|
362
|
-
readonly name: "
|
|
316
|
+
readonly name: "minters";
|
|
363
317
|
readonly type: "function";
|
|
364
318
|
readonly stateMutability: "view";
|
|
365
319
|
readonly inputs: readonly [{
|
|
@@ -367,79 +321,9 @@ declare const MOCK_RELAYER_V2_ABI: readonly [{
|
|
|
367
321
|
readonly name: "user";
|
|
368
322
|
}];
|
|
369
323
|
readonly outputs: readonly [{
|
|
370
|
-
readonly type: "
|
|
324
|
+
readonly type: "bool";
|
|
371
325
|
}];
|
|
372
326
|
}, {
|
|
373
|
-
readonly name: "Minted";
|
|
374
|
-
readonly type: "event";
|
|
375
|
-
readonly inputs: readonly [{
|
|
376
|
-
readonly type: "address";
|
|
377
|
-
readonly name: "user";
|
|
378
|
-
readonly indexed: true;
|
|
379
|
-
}, {
|
|
380
|
-
readonly type: "uint256";
|
|
381
|
-
readonly name: "amount";
|
|
382
|
-
}, {
|
|
383
|
-
readonly type: "uint256";
|
|
384
|
-
readonly name: "feeAmount";
|
|
385
|
-
}, {
|
|
386
|
-
readonly type: "address";
|
|
387
|
-
readonly name: "feeRecipient";
|
|
388
|
-
readonly indexed: true;
|
|
389
|
-
}, {
|
|
390
|
-
readonly type: "bytes32";
|
|
391
|
-
readonly name: "requestHash";
|
|
392
|
-
}];
|
|
393
|
-
}];
|
|
394
|
-
/**
|
|
395
|
-
* Calldata function selector for `mint((...),(...),(...))` as encoded
|
|
396
|
-
* by viem against {@link MOCK_RELAYER_V2_ABI}. Callers compare against
|
|
397
|
-
* this to sanity-check decoded UserOp inner calls.
|
|
398
|
-
*
|
|
399
|
-
* Recompute when the real ABI lands — almost certainly differs.
|
|
400
|
-
*/
|
|
401
|
-
declare const MOCK_RELAYER_V2_MINT_SELECTOR: "0xMOCKED__";
|
|
402
|
-
/**
|
|
403
|
-
* Struct shape that matches {@link MOCK_RELAYER_V2_ABI}. Exported so
|
|
404
|
-
* builders can accept a typed input without `as const` gymnastics.
|
|
405
|
-
*/
|
|
406
|
-
interface MockMintRequestV2 {
|
|
407
|
-
to: Address;
|
|
408
|
-
amount: bigint;
|
|
409
|
-
feeAmount: bigint;
|
|
410
|
-
feeRecipient: Address;
|
|
411
|
-
nonce: bigint;
|
|
412
|
-
deadline: bigint;
|
|
413
|
-
extData: `0x${string}`;
|
|
414
|
-
}
|
|
415
|
-
interface MockSignatureStruct {
|
|
416
|
-
v: number;
|
|
417
|
-
r: `0x${string}`;
|
|
418
|
-
s: `0x${string}`;
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
/**
|
|
422
|
-
* ⚠️ MOCK — `PointToken` v1.4 burn surface.
|
|
423
|
-
*
|
|
424
|
-
* Two variants mocked — SC team will pick ONE before stable; the other
|
|
425
|
-
* gets deleted during Phase B swap.
|
|
426
|
-
*
|
|
427
|
-
* Variant A (simpler, most likely):
|
|
428
|
-
* burn(uint256 amount)
|
|
429
|
-
* - burns from `msg.sender`
|
|
430
|
-
* - caller handles authorization (the user is `msg.sender` via
|
|
431
|
-
* EIP-7702 delegation, so `msg.sender == user`)
|
|
432
|
-
*
|
|
433
|
-
* Variant B (signature-based, if SC prefers explicit consent on-chain):
|
|
434
|
-
* burnWithSig(BurnConsent consent, Signature sig)
|
|
435
|
-
* - verifies EIP-712 signature before burning
|
|
436
|
-
* - used when the caller isn't the user (e.g. a relayer burns on
|
|
437
|
-
* behalf of the user)
|
|
438
|
-
*
|
|
439
|
-
* Either way the ERC-20 emits `Transfer(from, address(0), amount)` so
|
|
440
|
-
* `BurnIndexer` semantics don't change.
|
|
441
|
-
*/
|
|
442
|
-
declare const MOCK_POINT_TOKEN_V2_ABI: readonly [{
|
|
443
327
|
readonly name: "burn";
|
|
444
328
|
readonly type: "function";
|
|
445
329
|
readonly stateMutability: "nonpayable";
|
|
@@ -565,8 +449,14 @@ declare const MOCK_BATCH_EXECUTOR_ADDRESS_BASE_MAINNET: Address;
|
|
|
565
449
|
* 3. Update `src/contracts/index.ts` re-export
|
|
566
450
|
* 4. Delete MOCK_* named exports
|
|
567
451
|
*/
|
|
452
|
+
/**
|
|
453
|
+
* Per-chain contract addresses.
|
|
454
|
+
*
|
|
455
|
+
* v1.4 update: `relayerV2` field dropped — flow now calls
|
|
456
|
+
* `PointToken.mint()` directly via EIP-7702 delegation. No Relayer
|
|
457
|
+
* contract sits between user and PointToken.
|
|
458
|
+
*/
|
|
568
459
|
interface ContractAddresses {
|
|
569
|
-
relayerV2: Address;
|
|
570
460
|
pointToken: Address;
|
|
571
461
|
batchExecutor: Address;
|
|
572
462
|
usdt: Address;
|
|
@@ -580,96 +470,6 @@ declare const MOCK_ADDRESSES: Record<number, ContractAddresses>;
|
|
|
580
470
|
*/
|
|
581
471
|
declare function getMockAddresses(chainId: number): ContractAddresses;
|
|
582
472
|
|
|
583
|
-
/**
|
|
584
|
-
* ⚠️ MOCK — `MintRequest` v2 EIP-712 types.
|
|
585
|
-
*
|
|
586
|
-
* Extends v0.2.x `MintRequest` (4 fields) with three new fields needed
|
|
587
|
-
* for the v1.4 sponsored flow:
|
|
588
|
-
*
|
|
589
|
-
* + feeAmount PT units taken from the mint for the operator
|
|
590
|
-
* + feeRecipient where the fee goes (operator or treasury)
|
|
591
|
-
* + extData arbitrary bytes for future extensions (swap path, etc.)
|
|
592
|
-
*
|
|
593
|
-
* When SC team confirms the real struct, drop this file's content into
|
|
594
|
-
* the real builder and remove the MOCK_ prefix. The function signatures
|
|
595
|
-
* below stay stable — only `MOCK_MINT_REQUEST_V2_TYPES` changes.
|
|
596
|
-
*/
|
|
597
|
-
declare const MOCK_MINT_REQUEST_V2_TYPES: {
|
|
598
|
-
readonly MintRequest: readonly [{
|
|
599
|
-
readonly name: "to";
|
|
600
|
-
readonly type: "address";
|
|
601
|
-
}, {
|
|
602
|
-
readonly name: "amount";
|
|
603
|
-
readonly type: "uint256";
|
|
604
|
-
}, {
|
|
605
|
-
readonly name: "feeAmount";
|
|
606
|
-
readonly type: "uint256";
|
|
607
|
-
}, {
|
|
608
|
-
readonly name: "feeRecipient";
|
|
609
|
-
readonly type: "address";
|
|
610
|
-
}, {
|
|
611
|
-
readonly name: "nonce";
|
|
612
|
-
readonly type: "uint256";
|
|
613
|
-
}, {
|
|
614
|
-
readonly name: "deadline";
|
|
615
|
-
readonly type: "uint256";
|
|
616
|
-
}, {
|
|
617
|
-
readonly name: "extData";
|
|
618
|
-
readonly type: "bytes";
|
|
619
|
-
}];
|
|
620
|
-
};
|
|
621
|
-
/**
|
|
622
|
-
* Build the typed-data envelope that any EIP-712 signer (viem, ethers,
|
|
623
|
-
* Privy) can consume. Callers typically pass the result to
|
|
624
|
-
* `walletClient.signTypedData()` or `privy.signTypedData()`.
|
|
625
|
-
*/
|
|
626
|
-
declare function buildMockMintRequestV2TypedData(domain: PointTokenDomainConfig, message: MockMintRequestV2): {
|
|
627
|
-
domain: {
|
|
628
|
-
name: string;
|
|
629
|
-
version: "1";
|
|
630
|
-
chainId: number;
|
|
631
|
-
verifyingContract: `0x${string}`;
|
|
632
|
-
};
|
|
633
|
-
types: {
|
|
634
|
-
readonly MintRequest: readonly [{
|
|
635
|
-
readonly name: "to";
|
|
636
|
-
readonly type: "address";
|
|
637
|
-
}, {
|
|
638
|
-
readonly name: "amount";
|
|
639
|
-
readonly type: "uint256";
|
|
640
|
-
}, {
|
|
641
|
-
readonly name: "feeAmount";
|
|
642
|
-
readonly type: "uint256";
|
|
643
|
-
}, {
|
|
644
|
-
readonly name: "feeRecipient";
|
|
645
|
-
readonly type: "address";
|
|
646
|
-
}, {
|
|
647
|
-
readonly name: "nonce";
|
|
648
|
-
readonly type: "uint256";
|
|
649
|
-
}, {
|
|
650
|
-
readonly name: "deadline";
|
|
651
|
-
readonly type: "uint256";
|
|
652
|
-
}, {
|
|
653
|
-
readonly name: "extData";
|
|
654
|
-
readonly type: "bytes";
|
|
655
|
-
}];
|
|
656
|
-
};
|
|
657
|
-
primaryType: "MintRequest";
|
|
658
|
-
message: MockMintRequestV2;
|
|
659
|
-
};
|
|
660
|
-
/**
|
|
661
|
-
* Sign a `MintRequest` v2 with a viem WalletClient — server-side flow
|
|
662
|
-
* where the issuer holds the private key directly (KMS-backed signer
|
|
663
|
-
* is the production path; see `@pafi-dev/issuer` KMSSignerAdapter).
|
|
664
|
-
*/
|
|
665
|
-
declare function signMockMintRequestV2(walletClient: WalletClient, domain: PointTokenDomainConfig, message: MockMintRequestV2): Promise<EIP712Signature>;
|
|
666
|
-
/**
|
|
667
|
-
* Verify a `MintRequest` v2 signature and check it came from the
|
|
668
|
-
* expected signer (either user or issuer depending on which side is
|
|
669
|
-
* being verified).
|
|
670
|
-
*/
|
|
671
|
-
declare function verifyMockMintRequestV2(domain: PointTokenDomainConfig, message: MockMintRequestV2, signature: Hex, expectedSigner: Address): Promise<SignatureVerification>;
|
|
672
|
-
|
|
673
473
|
/**
|
|
674
474
|
* ⚠️ MOCK — `BurnConsent` EIP-712 type for the v1.4 reverse flow.
|
|
675
475
|
*
|
|
@@ -744,6 +544,47 @@ declare function buildMockBurnConsentTypedData(domain: PointTokenDomainConfig, m
|
|
|
744
544
|
declare function signMockBurnConsent(walletClient: WalletClient, domain: PointTokenDomainConfig, message: MockBurnConsent): Promise<EIP712Signature>;
|
|
745
545
|
declare function verifyMockBurnConsent(domain: PointTokenDomainConfig, message: MockBurnConsent, signature: Hex, expectedUser: Address): Promise<SignatureVerification>;
|
|
746
546
|
|
|
547
|
+
/**
|
|
548
|
+
* Public contract surface for `@pafi-dev/core/contracts`.
|
|
549
|
+
*
|
|
550
|
+
* Consumers import contract ABIs + addresses + EIP-712 builders from
|
|
551
|
+
* this module. The re-exports below dispatch to either `./mocks/*`
|
|
552
|
+
* (current) or `./real/*` (once SC team delivers real ABIs).
|
|
553
|
+
*
|
|
554
|
+
* ## v1.4 update — Relayer removed
|
|
555
|
+
*
|
|
556
|
+
* The flow no longer routes mint through a Relayer contract. Users
|
|
557
|
+
* call `PointToken.mint()` directly via an EIP-7702 delegated UserOp
|
|
558
|
+
* (`msg.sender == user`). PointToken checks `minters[user]` for
|
|
559
|
+
* authorization. No on-chain MintRequest signature, no dual-sig
|
|
560
|
+
* verification.
|
|
561
|
+
*
|
|
562
|
+
* Exports kept:
|
|
563
|
+
* - `POINT_TOKEN_V2_ABI` — mint + burn surface
|
|
564
|
+
* - `BATCH_EXECUTOR_*` — EIP-7702 delegation target
|
|
565
|
+
* - `CONTRACT_ADDRESSES` — per-chain map (pointToken, batchExecutor, etc.)
|
|
566
|
+
* - `BURN_CONSENT_*` — EIP-712 for Scenario 2 if `burnWithSig` variant
|
|
567
|
+
*
|
|
568
|
+
* Exports removed (vs beta.2):
|
|
569
|
+
* - `RELAYER_V2_ABI`, `RELAYER_V2_MINT_SELECTOR`, `MintRequestV2`,
|
|
570
|
+
* `SignatureStruct` — Relayer contract dropped from flow
|
|
571
|
+
* - `MINT_REQUEST_V2_TYPES`, `buildMintRequestV2TypedData`,
|
|
572
|
+
* `signMintRequestV2`, `verifyMintRequestV2` — no MintRequest sig
|
|
573
|
+
*
|
|
574
|
+
* Status: MOCKS active. See `./mocks/README.md` for deletion checklist.
|
|
575
|
+
*/
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
* Signature struct shared by `burnWithSig` (and any future EIP-712
|
|
579
|
+
* verifier on-chain). Exported here so consumers don't need to
|
|
580
|
+
* redefine it locally.
|
|
581
|
+
*/
|
|
582
|
+
interface SignatureStruct {
|
|
583
|
+
v: number;
|
|
584
|
+
r: `0x${string}`;
|
|
585
|
+
s: `0x${string}`;
|
|
586
|
+
}
|
|
587
|
+
|
|
747
588
|
/**
|
|
748
589
|
* Options for opening a PAFI Web modal — passed through by all adapters.
|
|
749
590
|
* Web-only fields (width/height/windowName) are ignored by mobile
|
|
@@ -1088,4 +929,4 @@ declare class PafiSDK {
|
|
|
1088
929
|
signLoginMessage(message: string): Promise<Hex>;
|
|
1089
930
|
}
|
|
1090
931
|
|
|
1091
|
-
export { ApiError, BATCH_EXECUTOR_ABI, MOCK_BATCH_EXECUTOR_ADDRESS_BASE_MAINNET as BATCH_EXECUTOR_ADDRESS_BASE_MAINNET, MOCK_BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA as BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA, MOCK_BURN_CONSENT_TYPES as BURN_CONSENT_TYPES, BestQuote, type BuildPartialUserOpParams, type MockBurnConsent as BurnConsent, COMMON_POOLS, COMMON_TOKENS, MOCK_ADDRESSES as CONTRACT_ADDRESSES, ChainConfig, type CheckEthAndBranchParams, ConfigurationError, type ContractAddresses, EIP712Signature, LoginMessageParams,
|
|
932
|
+
export { ApiError, BATCH_EXECUTOR_ABI, MOCK_BATCH_EXECUTOR_ADDRESS_BASE_MAINNET as BATCH_EXECUTOR_ADDRESS_BASE_MAINNET, MOCK_BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA as BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA, MOCK_BURN_CONSENT_TYPES as BURN_CONSENT_TYPES, BestQuote, type BuildPartialUserOpParams, type MockBurnConsent as BurnConsent, COMMON_POOLS, COMMON_TOKENS, MOCK_ADDRESSES as CONTRACT_ADDRESSES, ChainConfig, type CheckEthAndBranchParams, ConfigurationError, type ContractAddresses, EIP712Signature, LoginMessageParams, MintParams, MintRequest, type ModalOpenOptions, Operation, POINT_TOKEN_POOLS, MOCK_POINT_TOKEN_V2_ABI as POINT_TOKEN_V2_ABI, PafiSDK, PafiSDKConfig, PafiSDKError, type PafiWebModalAdapter, type PafiWebModalHandle, PartialUserOperation, PathKey, type PaymasterConfig, PointTokenDomainConfig, PoolKey, QuoteResult, ReceiverConsent, SUPPORTED_CHAINS, type SignatureStruct, SignatureVerification, SigningError, SimulationError, SimulationResult, type SponsorshipScenario, type SubmissionPath, SwapParams, SwapSimulationResult, UNIVERSAL_ROUTER_ADDRESSES, UserOperation, V4_QUOTER_ADDRESSES, _resetPaymasterConfigForTests, assembleUserOperation, buildMockBurnConsentTypedData as buildBurnConsentTypedData, buildPartialUserOperation, checkEthAndBranch, encodeBatchExecute, erc20ApproveOp, erc20BurnOp, erc20TransferOp, getMockAddresses as getContractAddresses, getPafiWebModalAdapter, getPaymasterConfig, isPaymasterConfigured, mintRequestTypes, openPafiWebModal, openWebPopup, rawCallOp, receiverConsentTypes, setPafiWebModalAdapter, setPaymasterConfig, signMockBurnConsent as signBurnConsent, verifyMockBurnConsent as verifyBurnConsent, webPopupAdapter };
|
package/dist/index.js
CHANGED
|
@@ -150,27 +150,23 @@ async function checkEthAndBranch(params) {
|
|
|
150
150
|
return balance >= required ? "normal" : "paymaster";
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
// src/contracts/mocks/relayerV2.mock.ts
|
|
154
|
-
import { parseAbi } from "viem";
|
|
155
|
-
var MOCK_RELAYER_V2_ABI = parseAbi([
|
|
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
153
|
// src/contracts/mocks/pointTokenV2.mock.ts
|
|
164
|
-
import { parseAbi
|
|
165
|
-
var MOCK_POINT_TOKEN_V2_ABI =
|
|
166
|
-
//
|
|
154
|
+
import { parseAbi } from "viem";
|
|
155
|
+
var MOCK_POINT_TOKEN_V2_ABI = parseAbi([
|
|
156
|
+
// --- Mint (v1.4 direct flow, no Relayer) ---
|
|
157
|
+
"function mint(uint256 amount) external",
|
|
158
|
+
// SC may instead pick: "function mint(address to, uint256 amount) external"
|
|
159
|
+
// Authorization check (off-chain reader for gg56 to verify BEFORE returning UserOp)
|
|
160
|
+
"function minters(address user) external view returns (bool)",
|
|
161
|
+
// --- Burn (v1.4 reverse flow, Scenario 2) ---
|
|
167
162
|
"function burn(uint256 amount) external",
|
|
168
|
-
// Variant B
|
|
169
163
|
"function burnWithSig((address user, address pointToken, uint256 amount, uint256 nonce, uint256 deadline) consent, (uint8 v, bytes32 r, bytes32 s) sig) external",
|
|
170
|
-
// Standard reads
|
|
164
|
+
// --- Standard reads ---
|
|
171
165
|
"function balanceOf(address user) external view returns (uint256)",
|
|
172
166
|
"function burnNonce(address user) external view returns (uint256)",
|
|
173
|
-
//
|
|
167
|
+
// --- Events ---
|
|
168
|
+
// PointIndexer filters Transfer(from=0x0) for mints
|
|
169
|
+
// BurnIndexer filters Transfer(to=0x0) for burns
|
|
174
170
|
"event Transfer(address indexed from, address indexed to, uint256 value)"
|
|
175
171
|
]);
|
|
176
172
|
|
|
@@ -181,20 +177,18 @@ var MOCK_BATCH_EXECUTOR_ADDRESS_BASE_MAINNET = "0x000000000000000000000000000000
|
|
|
181
177
|
// src/contracts/mocks/addresses.mock.ts
|
|
182
178
|
var MOCK_PLACEHOLDER = (suffix) => `0x000000000000000000000000000000000000${suffix.toLowerCase().padStart(4, "0")}`;
|
|
183
179
|
var MOCK_ADDRESSES = {
|
|
184
|
-
// Base Sepolia — safe targets for integration tests (
|
|
185
|
-
//
|
|
180
|
+
// Base Sepolia — safe targets for integration tests (Hardhat fixtures
|
|
181
|
+
// override at test time)
|
|
186
182
|
84532: {
|
|
187
|
-
relayerV2: MOCK_PLACEHOLDER("de10"),
|
|
188
183
|
pointToken: MOCK_PLACEHOLDER("de11"),
|
|
189
184
|
batchExecutor: MOCK_PLACEHOLDER("de01"),
|
|
190
185
|
usdt: MOCK_PLACEHOLDER("de12"),
|
|
191
186
|
issuerRegistry: MOCK_PLACEHOLDER("de13"),
|
|
192
187
|
mintingOracle: MOCK_PLACEHOLDER("de14")
|
|
193
188
|
},
|
|
194
|
-
// Base mainnet — intentionally
|
|
195
|
-
//
|
|
189
|
+
// Base mainnet — intentionally placeholder. Do NOT ship to prod
|
|
190
|
+
// without swapping with real addresses.
|
|
196
191
|
8453: {
|
|
197
|
-
relayerV2: MOCK_PLACEHOLDER("dead"),
|
|
198
192
|
pointToken: MOCK_PLACEHOLDER("dead"),
|
|
199
193
|
batchExecutor: MOCK_PLACEHOLDER("dead"),
|
|
200
194
|
usdt: MOCK_PLACEHOLDER("dead"),
|
|
@@ -212,66 +206,11 @@ function getMockAddresses(chainId) {
|
|
|
212
206
|
return addrs;
|
|
213
207
|
}
|
|
214
208
|
|
|
215
|
-
// src/contracts/mocks/eip712/
|
|
209
|
+
// src/contracts/mocks/eip712/burnConsent.mock.ts
|
|
216
210
|
import {
|
|
217
211
|
parseSignature,
|
|
218
212
|
recoverTypedDataAddress
|
|
219
213
|
} from "viem";
|
|
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: buildDomain(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: buildDomain(domain),
|
|
243
|
-
types: MOCK_MINT_REQUEST_V2_TYPES,
|
|
244
|
-
primaryType: "MintRequest",
|
|
245
|
-
message
|
|
246
|
-
});
|
|
247
|
-
const { v, r, s } = parseSignature(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 recoverTypedDataAddress({
|
|
257
|
-
domain: buildDomain(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
|
-
import {
|
|
272
|
-
parseSignature as parseSignature2,
|
|
273
|
-
recoverTypedDataAddress as recoverTypedDataAddress2
|
|
274
|
-
} from "viem";
|
|
275
214
|
var MOCK_BURN_CONSENT_TYPES = {
|
|
276
215
|
BurnConsent: [
|
|
277
216
|
{ name: "user", type: "address" },
|
|
@@ -297,7 +236,7 @@ async function signMockBurnConsent(walletClient, domain, message) {
|
|
|
297
236
|
primaryType: "BurnConsent",
|
|
298
237
|
message
|
|
299
238
|
});
|
|
300
|
-
const { v, r, s } =
|
|
239
|
+
const { v, r, s } = parseSignature(serialized);
|
|
301
240
|
return {
|
|
302
241
|
v: Number(v),
|
|
303
242
|
r,
|
|
@@ -306,7 +245,7 @@ async function signMockBurnConsent(walletClient, domain, message) {
|
|
|
306
245
|
};
|
|
307
246
|
}
|
|
308
247
|
async function verifyMockBurnConsent(domain, message, signature, expectedUser) {
|
|
309
|
-
const recoveredAddress = await
|
|
248
|
+
const recoveredAddress = await recoverTypedDataAddress({
|
|
310
249
|
domain: buildDomain(domain),
|
|
311
250
|
types: MOCK_BURN_CONSENT_TYPES,
|
|
312
251
|
primaryType: "BurnConsent",
|
|
@@ -702,13 +641,10 @@ export {
|
|
|
702
641
|
MOCK_ADDRESSES as CONTRACT_ADDRESSES,
|
|
703
642
|
ConfigurationError,
|
|
704
643
|
ENTRY_POINT_V07,
|
|
705
|
-
MOCK_MINT_REQUEST_V2_TYPES as MINT_REQUEST_V2_TYPES,
|
|
706
644
|
POINT_TOKEN_POOLS,
|
|
707
645
|
MOCK_POINT_TOKEN_V2_ABI as POINT_TOKEN_V2_ABI,
|
|
708
646
|
PafiSDK,
|
|
709
647
|
PafiSDKError,
|
|
710
|
-
MOCK_RELAYER_V2_ABI as RELAYER_V2_ABI,
|
|
711
|
-
MOCK_RELAYER_V2_MINT_SELECTOR as RELAYER_V2_MINT_SELECTOR,
|
|
712
648
|
SETTLE_ALL,
|
|
713
649
|
SUPPORTED_CHAINS,
|
|
714
650
|
SWAP_EXACT_IN,
|
|
@@ -726,7 +662,6 @@ export {
|
|
|
726
662
|
buildDomain,
|
|
727
663
|
buildErc20ApprovalCalldata,
|
|
728
664
|
buildMintRequestTypedData,
|
|
729
|
-
buildMockMintRequestV2TypedData as buildMintRequestV2TypedData,
|
|
730
665
|
buildPartialUserOperation,
|
|
731
666
|
buildPermit2ApprovalCalldata,
|
|
732
667
|
buildReceiverConsentTypedData,
|
|
@@ -782,7 +717,6 @@ export {
|
|
|
782
717
|
setPaymasterConfig,
|
|
783
718
|
signMockBurnConsent as signBurnConsent,
|
|
784
719
|
signMintRequest,
|
|
785
|
-
signMockMintRequestV2 as signMintRequestV2,
|
|
786
720
|
signReceiverConsent,
|
|
787
721
|
simulateMintAndSwap,
|
|
788
722
|
simulateSwap,
|
|
@@ -792,7 +726,6 @@ export {
|
|
|
792
726
|
verifyLoginMessage,
|
|
793
727
|
verifyMintCap,
|
|
794
728
|
verifyMintRequest,
|
|
795
|
-
verifyMockMintRequestV2 as verifyMintRequestV2,
|
|
796
729
|
verifyReceiverConsent,
|
|
797
730
|
webPopupAdapter
|
|
798
731
|
};
|