@pafi-dev/core 0.3.0-beta.1 → 0.3.0-beta.11

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.
Files changed (86) hide show
  1. package/README.md +99 -1118
  2. package/dist/abi/index.cjs +2 -6
  3. package/dist/abi/index.cjs.map +1 -1
  4. package/dist/abi/index.d.cts +1 -286
  5. package/dist/abi/index.d.ts +1 -286
  6. package/dist/abi/index.js +1 -5
  7. package/dist/{chunk-R4L66ZR5.js → chunk-73CQTNLB.js} +10 -1
  8. package/dist/chunk-73CQTNLB.js.map +1 -0
  9. package/dist/{chunk-5YH4D7QF.js → chunk-7UBO7DY5.js} +1 -1
  10. package/dist/{chunk-FGKLDKJK.cjs → chunk-ALCWYDVG.cjs} +1 -1
  11. package/dist/{chunk-FGKLDKJK.cjs.map → chunk-ALCWYDVG.cjs.map} +1 -1
  12. package/dist/{chunk-X3I5XWAR.cjs → chunk-CQCSQPWG.cjs} +2 -15
  13. package/dist/chunk-CQCSQPWG.cjs.map +1 -0
  14. package/dist/{chunk-CWP4PFOP.cjs → chunk-DMW67WBU.cjs} +11 -2
  15. package/dist/chunk-DMW67WBU.cjs.map +1 -0
  16. package/dist/{chunk-C4ZDYG4D.js → chunk-DUY7Z2AI.js} +48 -6
  17. package/dist/chunk-DUY7Z2AI.js.map +1 -0
  18. package/dist/{chunk-CXFUP2YK.cjs → chunk-EDR5SFJN.cjs} +46 -6
  19. package/dist/chunk-EDR5SFJN.cjs.map +1 -0
  20. package/dist/{chunk-FIKTQR7H.js → chunk-I2P3TIP7.js} +2 -2
  21. package/dist/{chunk-BNTVOKYT.cjs → chunk-KJKDLD7N.cjs} +51 -9
  22. package/dist/chunk-KJKDLD7N.cjs.map +1 -0
  23. package/dist/{chunk-VQSRCMMK.js → chunk-QGO6X6LG.js} +2 -15
  24. package/dist/chunk-QGO6X6LG.js.map +1 -0
  25. package/dist/{chunk-IK4UK7KT.js → chunk-W23EJNYG.js} +44 -4
  26. package/dist/chunk-W23EJNYG.js.map +1 -0
  27. package/dist/{chunk-CAE2BVKI.cjs → chunk-Z2V525IS.cjs} +6 -6
  28. package/dist/{chunk-CAE2BVKI.cjs.map → chunk-Z2V525IS.cjs.map} +1 -1
  29. package/dist/contract/index.cjs +2 -5
  30. package/dist/contract/index.cjs.map +1 -1
  31. package/dist/contract/index.d.cts +2 -4
  32. package/dist/contract/index.d.ts +2 -4
  33. package/dist/contract/index.js +1 -4
  34. package/dist/eip712/index.cjs +9 -3
  35. package/dist/eip712/index.cjs.map +1 -1
  36. package/dist/eip712/index.d.cts +44 -2
  37. package/dist/eip712/index.d.ts +44 -2
  38. package/dist/eip712/index.js +8 -2
  39. package/dist/{index-CNALKsH1.d.ts → index-B06IJlHe.d.ts} +1 -1
  40. package/dist/{index-BpUYHGu3.d.cts → index-B7pGBych.d.cts} +1 -1
  41. package/dist/index.cjs +434 -247
  42. package/dist/index.cjs.map +1 -1
  43. package/dist/index.d.cts +905 -411
  44. package/dist/index.d.ts +905 -411
  45. package/dist/index.js +447 -260
  46. package/dist/index.js.map +1 -1
  47. package/dist/quoting/index.cjs +3 -3
  48. package/dist/quoting/index.d.cts +1 -1
  49. package/dist/quoting/index.d.ts +1 -1
  50. package/dist/quoting/index.js +2 -2
  51. package/dist/swap/index.cjs +2 -3
  52. package/dist/swap/index.cjs.map +1 -1
  53. package/dist/swap/index.d.cts +2 -2
  54. package/dist/swap/index.d.ts +2 -2
  55. package/dist/swap/index.js +1 -2
  56. package/dist/{types-BDOnH5Le.d.cts → types-b5_Tokjl.d.cts} +8 -17
  57. package/dist/{types-BDOnH5Le.d.ts → types-b5_Tokjl.d.ts} +8 -17
  58. package/package.json +1 -1
  59. package/dist/chunk-27V32VNM.cjs +0 -370
  60. package/dist/chunk-27V32VNM.cjs.map +0 -1
  61. package/dist/chunk-4RYBJLF3.js +0 -370
  62. package/dist/chunk-4RYBJLF3.js.map +0 -1
  63. package/dist/chunk-5QJZT7VB.cjs +0 -46
  64. package/dist/chunk-5QJZT7VB.cjs.map +0 -1
  65. package/dist/chunk-BNTVOKYT.cjs.map +0 -1
  66. package/dist/chunk-C4ZDYG4D.js.map +0 -1
  67. package/dist/chunk-CWP4PFOP.cjs.map +0 -1
  68. package/dist/chunk-CXFUP2YK.cjs.map +0 -1
  69. package/dist/chunk-IK4UK7KT.js.map +0 -1
  70. package/dist/chunk-L74CZAVQ.cjs +0 -99
  71. package/dist/chunk-L74CZAVQ.cjs.map +0 -1
  72. package/dist/chunk-P56TUGTS.js +0 -46
  73. package/dist/chunk-P56TUGTS.js.map +0 -1
  74. package/dist/chunk-R4L66ZR5.js.map +0 -1
  75. package/dist/chunk-VQSRCMMK.js.map +0 -1
  76. package/dist/chunk-X3I5XWAR.cjs.map +0 -1
  77. package/dist/chunk-X4IXUTTD.js +0 -99
  78. package/dist/chunk-X4IXUTTD.js.map +0 -1
  79. package/dist/relay/index.cjs +0 -19
  80. package/dist/relay/index.cjs.map +0 -1
  81. package/dist/relay/index.d.cts +0 -75
  82. package/dist/relay/index.d.ts +0 -75
  83. package/dist/relay/index.js +0 -19
  84. package/dist/relay/index.js.map +0 -1
  85. /package/dist/{chunk-5YH4D7QF.js.map → chunk-7UBO7DY5.js.map} +0 -0
  86. /package/dist/{chunk-FIKTQR7H.js.map → chunk-I2P3TIP7.js.map} +0 -0
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../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"],"sourcesContent":["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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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ataAddress"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/perp/buildPerpDepositWithGasDeduction.ts","../src/contracts/real/orderlyVault.ts","../src/userop/types.ts","../src/paymaster/config.ts","../src/utils/checkEthAndBranch.ts","../src/delegation/checkDelegation.ts","../src/delegation/buildDelegationUserOp.ts","../src/contracts/real/pointToken.ts","../src/contracts/real/batchExecutor.ts","../src/contracts/real/addresses.ts","../src/web-handoff/webPopup.ts","../src/web-handoff/index.ts"],"sourcesContent":["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 \"./contract/index\";\nexport * from \"./quoting/index\";\nexport * from \"./swap/index\";\nexport * from \"./perp/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\";\nexport * from \"./delegation/index\";\n\n// v1.4 — Contract ABIs + addresses. ABI matches deployed PointToken on\n// Base mainnet; only `batchExecutor` address + Base Sepolia row remain\n// placeholder. EIP-712 helpers live under `./eip712/` and are already\n// exported above — not re-exported here.\n// Consumers: `import { POINT_TOKEN_V2_ABI, CONTRACT_ADDRESSES, ... } from '@pafi-dev/core'`\nexport * from \"./contracts/index\";\n\n// v1.5 — PAFI Web handoff (mobile + desktop modal helper).\n// `openPafiWebModal()` + adapter registry for platform-specific UX.\nexport * from \"./web-handoff/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 { findBestQuote } from \"./quoting/quote\";\nimport {\n buildSwapFromQuote,\n buildUniversalRouterExecuteArgs,\n} from \"./swap/universalRouter\";\nimport { simulateSwap } from \"./swap/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 MintRequest,\n PafiSDKConfig,\n PointTokenDomainConfig,\n PoolKey,\n QuoteResult,\n ReceiverConsent,\n SignatureVerification,\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 _signer?: WalletClient;\n private _provider?: PublicClient;\n private _chainId?: number;\n\n constructor(config: PafiSDKConfig) {\n this._pointTokenAddress = config.pointTokenAddress;\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 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 async buildMintRequestTypedData(message: MintRequest) {\n const domain = await this.getDomain();\n return buildMintRequestTypedData(domain, message);\n }\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 // 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 // Simulation — dry-run via eth_call (no gas spent)\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\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\n// Expose the `buildUniversalRouterExecuteArgs` helper for consumers that\n// build swap calldata directly (e.g. v1.5 sponsored swap flow).\nexport { buildUniversalRouterExecuteArgs };\n","import { encodeFunctionData } from \"viem\";\nimport type { Address, Hex } from \"viem\";\nimport {\n ORDERLY_VAULT_ABI,\n ORDERLY_VAULT_ADDRESSES,\n type VaultDepositFE,\n} from \"../contracts/real/orderlyVault\";\nimport { erc20ApproveOp, rawCallOp } from \"../userop/operations\";\nimport { buildPartialUserOperation } from \"../userop/buildUserOperation\";\nimport type { Operation, PartialUserOperation } from \"../userop/types\";\n\n/**\n * v1.5 — Scenario 3: deposit USDC from the user's wallet into the\n * Orderly perp Vault on Base mainnet.\n *\n * Builds a `PartialUserOperation` packaging the 2 inner calls:\n *\n * 1. `USDC.approve(orderlyVault, amount)` — let the Vault pull USDC\n * 2. `OrderlyVault.deposit{value: layerZeroFee}(VaultDepositFE)` —\n * transfer USDC into the Vault + emit a LayerZero message that\n * credits the user's perp account on the Orderly chain\n *\n * ## ⚠️ Native ETH constraint\n *\n * Coinbase Paymaster sponsors GAS, **not `msg.value`**. The LayerZero\n * cross-chain fee MUST come from the user's own native ETH balance on\n * Base — even when the rest of the UserOp is sponsored.\n *\n * Quote the fee BEFORE calling this builder via:\n *\n * const fee = await client.readContract({\n * address: orderlyVault,\n * abi: ORDERLY_VAULT_ABI,\n * functionName: 'getDepositFee',\n * args: [user, depositData],\n * });\n *\n * If `user.eth < fee`, surface this error to the FE so the user can\n * top up before retrying — the Vault `deposit{value: 0}` call will\n * revert otherwise.\n *\n * ## Why no PT/USDC fee deduction?\n *\n * Unlike Scenario 1/2/4 which deduct an operator fee in PT/USDC inside\n * the batch, perp deposit doesn't append a fee transfer because:\n *\n * - User is paying Orderly's LayerZero fee directly via `msg.value`\n * - There's no PAFI-specific operator cost on top — Orderly handles\n * the off-chain accounting once the LayerZero message lands\n *\n * If we want to charge a PAFI service fee on top later, append a\n * `USDC.transfer(feeRecipient, fee)` op — same pattern as the swap\n * builder.\n */\nexport interface BuildPerpDepositWithGasDeductionParams {\n /** User EOA (will be `msg.sender` via EIP-7702 delegation). */\n userAddress: Address;\n /** ERC-4337 account nonce — fetched from EntryPoint by the caller. */\n aaNonce: bigint;\n\n /** Chain ID for Orderly Vault address resolution. */\n chainId: number;\n /**\n * Override Orderly Vault address (e.g. for fork tests). Defaults to\n * `ORDERLY_VAULT_ADDRESSES[chainId]`.\n */\n vaultAddress?: Address;\n\n /**\n * USDC ERC-20 address — the actual token Orderly accepts. Caller\n * resolves this via `vault.getAllowedToken(TOKEN_HASHES.USDC)` so we\n * don't hardcode the wrong USDC variant (native vs bridged).\n */\n usdcAddress: Address;\n\n /** USDC amount to deposit (uint128, 6 decimals). */\n amount: bigint;\n\n /**\n * Pre-built `VaultDepositFE` struct — caller computes accountId via\n * `computeAccountId(user, brokerHash)` and supplies tokenHash.\n */\n depositData: VaultDepositFE;\n\n /**\n * LayerZero fee in wei — from `vault.getDepositFee(user, data)`.\n * Becomes the `msg.value` on the `deposit()` call. User MUST hold\n * ≥ this much native ETH or the call reverts.\n */\n layerZeroFee: bigint;\n\n gasLimits?: {\n callGasLimit?: bigint;\n verificationGasLimit?: bigint;\n preVerificationGas?: bigint;\n };\n}\n\n/**\n * Build an unsigned UserOp for Scenario 3. Returns a\n * `PartialUserOperation` — caller attaches paymaster sponsorship for\n * gas + the user's UserOp-hash signature, then submits to the Bundler.\n */\nexport function buildPerpDepositWithGasDeduction(\n params: BuildPerpDepositWithGasDeductionParams,\n): PartialUserOperation {\n if (params.amount <= 0n) {\n throw new Error(\"buildPerpDepositWithGasDeduction: amount must be positive\");\n }\n if (params.layerZeroFee < 0n) {\n throw new Error(\n \"buildPerpDepositWithGasDeduction: layerZeroFee cannot be negative\",\n );\n }\n if (params.depositData.tokenAmount !== params.amount) {\n throw new Error(\n `buildPerpDepositWithGasDeduction: depositData.tokenAmount (${params.depositData.tokenAmount}) ` +\n `must equal amount (${params.amount})`,\n );\n }\n\n const vault =\n params.vaultAddress ?? ORDERLY_VAULT_ADDRESSES[params.chainId];\n if (!vault) {\n throw new Error(\n `buildPerpDepositWithGasDeduction: no Orderly Vault address for chainId ${params.chainId}`,\n );\n }\n\n const depositCallData: Hex = encodeFunctionData({\n abi: ORDERLY_VAULT_ABI,\n functionName: \"deposit\",\n args: [params.depositData],\n });\n\n const operations: Operation[] = [\n erc20ApproveOp(params.usdcAddress, vault, params.amount),\n {\n ...rawCallOp(vault, depositCallData),\n // BatchExecutor passes `value` from the inner call along; this\n // becomes the LayerZero fee. The aggregated `msg.value` for the\n // top-level UserOp must equal the sum of inner `value`s.\n value: params.layerZeroFee,\n },\n ];\n\n return buildPartialUserOperation({\n sender: params.userAddress,\n nonce: params.aaNonce,\n operations,\n gasLimits: {\n callGasLimit: params.gasLimits?.callGasLimit ?? 800_000n,\n verificationGasLimit:\n params.gasLimits?.verificationGasLimit ?? 150_000n,\n preVerificationGas: params.gasLimits?.preVerificationGas ?? 50_000n,\n },\n });\n}\n","import { keccak256, encodePacked, encodeAbiParameters } from \"viem\";\nimport type { Address, Hex } from \"viem\";\n\n/**\n * Orderly Network Vault — entrypoint for **perp deposit** flow on\n * Base mainnet (Scenario 3).\n *\n * Source of truth for addresses + integration:\n * https://orderly.network/docs/build-on-omnichain/addresses#base\n *\n * ## Architecture\n *\n * User wallet (Base)\n * │ 1. USDC.approve(vault, amount)\n * │ 2. vault.deposit{value: layerZeroFee}({\n * │ accountId, brokerHash, tokenHash, tokenAmount\n * │ })\n * ▼\n * OrderlyVault (Base)\n * │ — locks USDC, emits LayerZero message\n * ▼\n * Orderly chain (off-chain matching engine)\n * │ — credits the user's perp account\n * ▼\n * User can now place perp orders via Orderly REST/WS API\n *\n * **Important:** `value` is required and is the LayerZero cross-chain\n * fee (paid in native ETH on Base). Quote it via\n * `vault.getDepositFee(user, data)` BEFORE calling deposit. Fees vary\n * with destination chain congestion.\n *\n * ## Sponsored vs direct\n *\n * Coinbase Paymaster sponsors GAS, not `msg.value`. So even on the\n * sponsored path the user MUST hold enough native ETH on Base to cover\n * `getDepositFee()` (typically ~0.0002 ETH at quiet times).\n */\n\n/** Orderly Vault on Base mainnet (EIP-55 checksum). */\nexport const ORDERLY_VAULT_BASE_MAINNET: Address =\n \"0xDe5cE5DD048596e46Ff671b13317aCC3C5B59b01\";\n\n/**\n * Per-chain registry of the Orderly Vault. Add chains here as Orderly\n * deploys them.\n */\nexport const ORDERLY_VAULT_ADDRESSES: Record<number, Address> = {\n 8453: ORDERLY_VAULT_BASE_MAINNET,\n};\n\n/**\n * Pre-computed broker hashes — `keccak256(abi.encodePacked(brokerId))`.\n * Add new brokers as they launch.\n *\n * Reference: https://orderly.network/docs/build-on-omnichain/user-flows/accountId\n */\nexport const BROKER_HASHES = {\n /** Default partner broker on Base — most commonly whitelisted. */\n woofi_pro: keccak256(encodePacked([\"string\"], [\"woofi_pro\"])),\n /** Orderly's own white-label broker. */\n orderly: keccak256(encodePacked([\"string\"], [\"orderly\"])),\n /** LogX. */\n logx: keccak256(encodePacked([\"string\"], [\"logx\"])),\n} as const satisfies Record<string, Hex>;\n\n/**\n * Pre-computed token hashes — `keccak256(abi.encodePacked(tokenSymbol))`.\n * The hash maps to the actual ERC-20 address on each chain via\n * `vault.getAllowedToken(tokenHash)`.\n *\n * Note: Orderly canonicalises by symbol (USDC, not \"USD Coin\").\n */\nexport const TOKEN_HASHES = {\n USDC: keccak256(encodePacked([\"string\"], [\"USDC\"])),\n} as const satisfies Record<string, Hex>;\n\n/**\n * Compute Orderly's `accountId` — uniquely identifies a user+broker\n * tuple. Matches the off-chain formula used by the Orderly SDK so\n * deposits + future REST API calls reference the same account.\n *\n * accountId = keccak256(abi.encode(user, brokerHash))\n *\n * Note `abi.encode` (not `encodePacked`) — uses 32-byte left-padding.\n */\nexport function computeAccountId(\n user: Address,\n brokerHash: Hex,\n): Hex {\n return keccak256(\n encodeAbiParameters(\n [\n { type: \"address\" },\n { type: \"bytes32\" },\n ],\n [user, brokerHash],\n ),\n );\n}\n\n/**\n * Minimal Orderly Vault ABI — just the functions PAFI needs for\n * Scenario 3 (perp deposit). Full ABI is on Orderly's docs site.\n */\nexport const ORDERLY_VAULT_ABI = [\n // Deposit USDC into Orderly perp account. Emits LayerZero message\n // to the Orderly chain. `msg.value` MUST equal `getDepositFee(...)`.\n {\n type: \"function\",\n name: \"deposit\",\n stateMutability: \"payable\",\n inputs: [\n {\n name: \"data\",\n type: \"tuple\",\n components: [\n { name: \"accountId\", type: \"bytes32\" },\n { name: \"brokerHash\", type: \"bytes32\" },\n { name: \"tokenHash\", type: \"bytes32\" },\n { name: \"tokenAmount\", type: \"uint128\" },\n ],\n },\n ],\n outputs: [],\n },\n // Quote the LayerZero fee for a deposit message. Pass the same\n // VaultDepositFE struct you intend to send.\n {\n type: \"function\",\n name: \"getDepositFee\",\n stateMutability: \"view\",\n inputs: [\n { name: \"user\", type: \"address\" },\n {\n name: \"data\",\n type: \"tuple\",\n components: [\n { name: \"accountId\", type: \"bytes32\" },\n { name: \"brokerHash\", type: \"bytes32\" },\n { name: \"tokenHash\", type: \"bytes32\" },\n { name: \"tokenAmount\", type: \"uint128\" },\n ],\n },\n ],\n outputs: [{ name: \"\", type: \"uint256\" }],\n },\n // Pre-flight check — is this brokerId whitelisted on this Vault?\n {\n type: \"function\",\n name: \"getAllowedBroker\",\n stateMutability: \"view\",\n inputs: [{ name: \"brokerHash\", type: \"bytes32\" }],\n outputs: [{ name: \"\", type: \"bool\" }],\n },\n // Pre-flight check — what ERC-20 address does this token symbol\n // resolve to on this Vault?\n {\n type: \"function\",\n name: \"getAllowedToken\",\n stateMutability: \"view\",\n inputs: [{ name: \"tokenHash\", type: \"bytes32\" }],\n outputs: [{ name: \"\", type: \"address\" }],\n },\n] as const;\n\n/** Struct mirror of `IOrderlyVault.VaultDepositFE` for type-safe builders. */\nexport interface VaultDepositFE {\n accountId: Hex;\n brokerHash: Hex;\n tokenHash: Hex;\n /** uint128 — USDC has 6 decimals. */\n tokenAmount: bigint;\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 type { Address, Hex, PublicClient } from \"viem\";\n\n/**\n * EIP-7702 delegation designator prefix: 0xef0100 + 20-byte implementation address.\n *\n * When an EOA has been delegated via EIP-7702, `eth_getCode` returns bytecode\n * that starts with this magic prefix followed by the 20-byte address of the\n * implementation contract (BatchExecutor).\n *\n * References: EIP-7702 §4.2 — \"delegation designator\"\n */\nconst EIP7702_MAGIC = \"0xef0100\" as const;\n\n/**\n * Parse the implementation address out of an EIP-7702 delegation designator.\n *\n * Returns `null` when:\n * - `code` is undefined / empty / `\"0x\"` (plain EOA, no code)\n * - `code` does not contain the EIP-7702 magic prefix (regular contract)\n *\n * @param code - bytecode returned by `eth_getCode` / `client.getCode()`\n * @returns the 20-byte implementation address (checksummed), or `null`\n *\n * @example\n * const code = await client.getCode({ address });\n * const impl = parseEip7702DelegatedAddress(code);\n * // null → not delegated\n * // '0x7702cb554e6bFb442cb743A7dF23154544a7176C' → delegated to BatchExecutor\n */\nexport function parseEip7702DelegatedAddress(\n code: Hex | string | null | undefined,\n): Address | null {\n if (!code || code === \"0x\" || code === \"0x0\") return null;\n const normalized = code.toLowerCase();\n const magic = EIP7702_MAGIC.toLowerCase();\n const idx = normalized.indexOf(magic);\n if (idx === -1) return null;\n const raw = normalized.slice(idx + magic.length, idx + magic.length + 40);\n if (raw.length !== 40) return null;\n return `0x${raw}` as Address;\n}\n\n/**\n * Read the EIP-7702 delegation status of an EOA from the chain.\n *\n * @param client - viem PublicClient (any provider — only `eth_getCode` is called)\n * @param address - EOA address to inspect\n * @returns the implementation address the EOA is delegated to, or `null`\n *\n * @example\n * const impl = await checkDelegation(publicClient, userAddress);\n * if (impl === null) {\n * // show \"Setup Wallet\" button\n * } else {\n * // EOA already delegated; safe to send UserOps\n * }\n */\nexport async function checkDelegation(\n client: PublicClient,\n address: Address,\n): Promise<Address | null> {\n const code = await client.getCode({ address });\n return parseEip7702DelegatedAddress(code);\n}\n\n/**\n * Return `true` when the EOA at `address` is currently delegated to `target`.\n *\n * Useful for asserting that the delegation points specifically at the expected\n * BatchExecutor rather than some other implementation (e.g. old deployment).\n *\n * @example\n * import { BATCH_EXECUTOR_ADDRESS_BASE_MAINNET } from '@pafi-dev/core';\n * const ok = await isDelegatedTo(client, userAddress, BATCH_EXECUTOR_ADDRESS_BASE_MAINNET);\n */\nexport async function isDelegatedTo(\n client: PublicClient,\n address: Address,\n target: Address,\n): Promise<boolean> {\n const impl = await checkDelegation(client, address);\n if (!impl) return false;\n return impl.toLowerCase() === target.toLowerCase();\n}\n","import type { Address, PublicClient } from \"viem\";\nimport type { PartialUserOperation } from \"../userop/types\";\nimport { buildPartialUserOperation } from \"../userop/buildUserOperation\";\n\n/**\n * Parameters for building a delegation-only UserOperation.\n *\n * This UserOp carries no calldata — its sole purpose is to anchor the\n * EIP-7702 authorization (signed externally via `signAuthorization`) into\n * a sponsored transaction so the user doesn't need native ETH to delegate.\n */\nexport interface BuildDelegationUserOpParams {\n /** User EOA to delegate. */\n userAddress: Address;\n /** ERC-4337 account nonce — fetched from EntryPoint. Pass 0n on first ever op. */\n aaNonce: bigint;\n gasLimits?: {\n callGasLimit?: bigint;\n verificationGasLimit?: bigint;\n preVerificationGas?: bigint;\n };\n}\n\n/**\n * Build the minimal `PartialUserOperation` used to sponsor the one-time\n * EIP-7702 delegation.\n *\n * The caller must:\n * 1. Sign the EIP-7702 authorization via `signAuthorization()` (Privy hook).\n * 2. Pass the authorization as `authorization` alongside `calls` (or alone)\n * to `smartClient.sendTransaction()`.\n *\n * The permissionless SDK + Pimlico bundler handle the rest: they detect the\n * `authorization` field and submit an EIP-7702 type-4 transaction that sets\n * the EOA's bytecode to `0xef0100<batchExecutorAddress>`.\n *\n * This builder is a convenience wrapper — in practice you can also pass\n * `{ to: userAddress, value: 0n, data: '0x', authorization }` directly to\n * `smartClient.sendTransaction()` without calling this function at all.\n * Use it when you need a `PartialUserOperation` struct for inspection or\n * custom paymaster flows.\n *\n * @example\n * // Typical flow — no need to call this builder directly:\n * const nonce = await publicClient.getTransactionCount({ address, blockTag: 'pending' });\n * const authorization = await signAuthorization({ contractAddress: BATCH_EXECUTOR, chainId: 8453, nonce });\n * const txHash = await smartClient.sendTransaction({\n * to: address,\n * value: 0n,\n * data: '0x',\n * authorization,\n * paymasterContext: { sponsorshipPolicyId },\n * });\n */\nexport function buildDelegationUserOp(\n params: BuildDelegationUserOpParams,\n): PartialUserOperation {\n return buildPartialUserOperation({\n sender: params.userAddress,\n nonce: params.aaNonce,\n operations: [\n {\n // Self-call with no data — triggers EIP-7702 delegation without\n // executing any inner logic. The BatchExecutor.execute([]) call with\n // an empty array would revert, so we target the EOA itself (which\n // forwards to BatchExecutor that then no-ops on empty input).\n target: params.userAddress,\n value: 0n,\n data: \"0x\",\n },\n ],\n gasLimits: {\n callGasLimit: params.gasLimits?.callGasLimit ?? 50_000n,\n verificationGasLimit: params.gasLimits?.verificationGasLimit ?? 150_000n,\n preVerificationGas: params.gasLimits?.preVerificationGas ?? 50_000n,\n },\n });\n}\n\n/**\n * Fetch the AA nonce for a user EOA from the EntryPoint v0.7.\n *\n * Convenience helper so callers don't need to import the EntryPoint ABI\n * themselves when building the delegation UserOp.\n *\n * @param client - viem PublicClient\n * @param userAddress - EOA to query\n * @returns bigint nonce (0n on first-ever UserOp)\n */\nexport async function getAaNonce(\n client: PublicClient,\n userAddress: Address,\n): Promise<bigint> {\n // EntryPoint v0.7 address (canonical, same across EVM chains)\n const ENTRY_POINT = \"0x0000000071727De22E5E9d8BAf0edAc6f37da032\" as Address;\n const NONCE_ABI = [\n {\n inputs: [\n { name: \"sender\", type: \"address\" },\n { name: \"key\", type: \"uint192\" },\n ],\n name: \"getNonce\",\n outputs: [{ name: \"nonce\", type: \"uint256\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n ] as const;\n\n return client.readContract({\n address: ENTRY_POINT,\n abi: NONCE_ABI,\n functionName: \"getNonce\",\n args: [userAddress, 0n],\n });\n}\n","import { parseAbi } from \"viem\";\n\n/**\n * Real `PointToken` ABI — matches the contract deployed on Base mainnet\n * (POINT at `0x7d25E7156E51F865D522fd3ef257a6B5DD41b97e`). Sourced from\n * the Solidity contract shipped by the SC team 2026-04-21.\n *\n * ## Mint — two paths\n *\n * Path 1 — Direct (whitelisted minter):\n * mint(address to, uint256 amount)\n * - msg.sender must be in minters[]\n * - Used by off-chain services that hold a minter key\n *\n * Path 2 — Sig-gated (gasless, v1.4 sponsored flow):\n * mint(address to, uint256 amount, uint256 deadline, bytes minterSig)\n * - msg.sender MUST equal `to` (the receiver)\n * - minterSig is an EIP-712 MintRequest signature from a whitelisted minter\n * - Consumes `mintRequestNonces[to]`\n * - This is the path v1.4 uses: issuer backend signs, user submits\n * via EIP-7702 + Coinbase Paymaster\n *\n * ## Burn — mirror structure\n *\n * Path 1: burn(address from, uint256 amount) — whitelisted burner\n * Path 2: burn(address from, uint256 amount, uint256 deadline, bytes burnerSig)\n * — msg.sender must equal `from`, burnerSig from whitelisted burner,\n * consumes `burnRequestNonces[from]`\n *\n * Either burn path emits `Transfer(from → 0x0)` so BurnIndexer semantics\n * don't depend on which path was taken.\n *\n * ## EIP-712 type hashes (from contract source)\n *\n * MintRequest(address to,uint256 amount,uint256 nonce,uint256 deadline)\n * BurnRequest(address from,uint256 amount,uint256 nonce,uint256 deadline)\n *\n * Domain: EIP-712 standard — name = ERC-20 token name, version = \"1\",\n * chainId, verifyingContract = this PointToken address.\n */\nexport const POINT_TOKEN_ABI = parseAbi([\n // --- Mint paths ---\n \"function mint(address to, uint256 amount) external\",\n \"function mint(address to, uint256 amount, uint256 deadline, bytes minterSig) external\",\n\n // --- Burn paths ---\n \"function burn(address from, uint256 amount) external\",\n \"function burn(address from, uint256 amount, uint256 deadline, bytes burnerSig) external\",\n\n // --- Authorization reads ---\n \"function minters(address account) external view returns (bool)\",\n \"function burners(address account) external view returns (bool)\",\n\n // --- Authorization writes (owner-only; used by provisioning scripts) ---\n \"function addMinter(address minter) external\",\n \"function removeMinter(address minter) external\",\n \"function addBurner(address burner) external\",\n \"function removeBurner(address burner) external\",\n\n // --- Nonces (sig-gated paths) ---\n \"function mintRequestNonces(address receiver) external view returns (uint256)\",\n \"function burnRequestNonces(address from) external view returns (uint256)\",\n\n // --- Oracle ---\n \"function mintingOracle() external view returns (address)\",\n \"function setMintingOracle(address _mintingOracle) external\",\n\n // --- Issuer ---\n \"function issuer() external view returns (address)\",\n\n // --- Standard ERC-20 reads ---\n \"function balanceOf(address account) external view returns (uint256)\",\n \"function totalSupply() external view returns (uint256)\",\n \"function name() external view returns (string)\",\n \"function symbol() external view returns (string)\",\n \"function decimals() external view returns (uint8)\",\n\n // --- EIP-712 domain (for off-chain sig verification) ---\n \"function DOMAIN_SEPARATOR() external view returns (bytes32)\",\n \"function eip712Domain() external view returns (bytes1 fields, string name, string version, uint256 chainId, address verifyingContract, bytes32 salt, uint256[] extensions)\",\n\n // --- Events ---\n // PointIndexer filters Transfer(from=0x0) for mints\n // BurnIndexer filters Transfer(to=0x0) for burns\n \"event Transfer(address indexed from, address indexed to, uint256 value)\",\n \"event MinterAdded(address indexed minter)\",\n \"event MinterRemoved(address indexed minter)\",\n \"event BurnerAdded(address indexed burner)\",\n \"event BurnerRemoved(address indexed burner)\",\n \"event MintingOracleUpdated(address indexed mintingOracle)\",\n] as const);\n","import type { Address } from \"viem\";\n\n/**\n * BatchExecutor delegation target addresses.\n *\n * ## Status\n *\n * Base mainnet: points at **Coinbase Smart Wallet v2**\n * (`0x7702cb554e6bFb442cb743A7dF23154544a7176C`). Coinbase publishes\n * this as the canonical EIP-7702 delegation target on Base — every\n * user that wants gas sponsorship via Coinbase Paymaster delegates to\n * this single contract. One contract, all issuers.\n *\n * Base Sepolia: placeholder; Sepolia is not in active use for PAFI.\n *\n * The ABI (`execute(Call[])`) is exported from\n * `../../userop/batchExecute.ts` and works against the Coinbase\n * contract without change — Coinbase Smart Wallet v2 implements the\n * same call-array signature we already use.\n */\n\n// Base Sepolia (testnet) — placeholder\nexport const BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA =\n \"0x000000000000000000000000000000000000DE01\" as Address;\n\n// Base mainnet — Coinbase Smart Wallet v2\nexport const BATCH_EXECUTOR_ADDRESS_BASE_MAINNET =\n \"0x7702cb554e6bFb442cb743A7dF23154544a7176C\" as Address;\n\n// The ABI itself is fully real — re-exported from userop/ for\n// convenience so consumers don't need two imports.\nexport { BATCH_EXECUTOR_ABI } from \"../../userop/batchExecute\";\n","import type { Address } from \"viem\";\n\n/**\n * Per-chain deployed contract addresses — v1.4 flow.\n *\n * ## Status (2026-04-22)\n *\n * Base mainnet (8453): **all real**. BatchExecutor now points at the\n * canonical Coinbase Smart Wallet v2 contract which PAFI reuses as the\n * EIP-7702 delegation target (no per-app deploy required — one\n * contract, every issuer).\n *\n * Base Sepolia (84532): entire row is placeholder — not in active use.\n *\n * ## What lives where\n *\n * pointToken — live POINT instance (clone of PointToken impl)\n * batchExecutor — EIP-7702 delegation target (Coinbase Smart Wallet v2)\n * usdt — MockERC20 used by Uniswap pools\n * issuerRegistry — registry of all issuers on this chain\n * mintingOracle — per-issuer mint cap enforcer\n * pafiHook — Uniswap V4 hook enforcing the 10% PT→USDT fee\n *\n * PointTokenFactory + PointToken implementation addresses live in\n * separate exports below — they're only needed at provisioning /\n * observability time, not in the hot mint/burn path, so excluded from\n * the per-chain bundle.\n */\nexport interface ContractAddresses {\n pointToken: Address;\n batchExecutor: Address;\n usdt: Address;\n issuerRegistry: Address;\n mintingOracle: Address;\n /**\n * Uniswap V4 hook that enforces the 10% fee on PT→USDT swaps\n * (USDT→PT is free). FE reads this to build `PoolKey.hooks` when\n * constructing a swap; quoters + routers need it to resolve the\n * correct pool.\n */\n pafiHook: Address;\n}\n\nconst PLACEHOLDER_DEAD = (suffix: string): Address =>\n `0x000000000000000000000000000000000000${suffix.toLowerCase().padStart(4, \"0\")}` as Address;\n\nexport const CONTRACT_ADDRESSES: Record<number, ContractAddresses> = {\n // Base mainnet — SC-delivered (2026-04-21, 2026-04-22)\n // registry: IssuerRegistry 0xda2D3338CF70F462Ac175F5f2edfa45660CA4f31\n // factory: PointTokenFactory 0x36c0BAb2faBE45EfA6d13001143e43A266Af673B\n // oracle: MintingOracle 0xD85165939C700E51c8a45099316C6482634C2Ab9\n // tokenImpl: PointToken (impl) 0x2e6FB1B0C1A51abb83eC974890126a64eC02E995\n // mockUsdt: MockERC20 0x5d313485Ba59C3bb91e1A9C0C11782F0b83d5dcd\n // POINT: PointToken instance 0x7d25E7156E51F865D522fd3ef257a6B5DD41b97e\n // batchExecutor: Coinbase SW v2 0x7702cb554e6bFb442cb743A7dF23154544a7176C\n // pafiHook: PAFIHook (V4, 10%) 0x870cAF9882d3160602AaC1769C2B264A2d8EC044\n 8453: {\n pointToken: \"0x7d25E7156E51F865D522fd3ef257a6B5DD41b97e\",\n batchExecutor: \"0x7702cb554e6bFb442cb743A7dF23154544a7176C\",\n usdt: \"0x5d313485Ba59C3bb91e1A9C0C11782F0b83d5dcd\",\n issuerRegistry: \"0xda2D3338CF70F462Ac175F5f2edfa45660CA4f31\",\n mintingOracle: \"0xD85165939C700E51c8a45099316C6482634C2Ab9\",\n pafiHook: \"0x870cAF9882d3160602AaC1769C2B264A2d8EC044\",\n },\n // Base Sepolia — not in active use; placeholders kept so the map\n // compiles for tooling that enumerates chains.\n 84532: {\n pointToken: PLACEHOLDER_DEAD(\"dead\"),\n batchExecutor: PLACEHOLDER_DEAD(\"de01\"),\n usdt: PLACEHOLDER_DEAD(\"dead\"),\n issuerRegistry: PLACEHOLDER_DEAD(\"dead\"),\n mintingOracle: PLACEHOLDER_DEAD(\"dead\"),\n pafiHook: PLACEHOLDER_DEAD(\"dead\"),\n },\n};\n\n/**\n * PointTokenFactory address — separate from `ContractAddresses` because\n * it's only used at provisioning time (issuer onboard + token creation),\n * not in the hot mint/burn path.\n */\nexport const POINT_TOKEN_FACTORY_ADDRESSES: Record<number, Address> = {\n 8453: \"0x36c0BAb2faBE45EfA6d13001143e43A266Af673B\",\n 84532: PLACEHOLDER_DEAD(\"dead\"),\n};\n\n/**\n * PointToken implementation address — the EIP-1167 clone target used\n * by PointTokenFactory. Exposed for observability / proxy verification;\n * consumers should never call this directly.\n */\nexport const POINT_TOKEN_IMPL_ADDRESSES: Record<number, Address> = {\n 8453: \"0x2e6FB1B0C1A51abb83eC974890126a64eC02E995\",\n 84532: PLACEHOLDER_DEAD(\"dead\"),\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 getContractAddresses(chainId: number): ContractAddresses {\n const addrs = CONTRACT_ADDRESSES[chainId];\n if (!addrs) {\n throw new Error(\n `getContractAddresses: no addresses for chainId ${chainId}. ` +\n `Supported: ${Object.keys(CONTRACT_ADDRESSES).join(\", \")}`,\n );\n }\n return addrs;\n}\n","import type {\n ModalOpenOptions,\n PafiWebModalAdapter,\n PafiWebModalHandle,\n} from \"./types\";\n\nconst DEFAULT_WIDTH = 900;\nconst DEFAULT_HEIGHT = 700;\nconst DEFAULT_NAME = \"pafi-web\";\n\n/**\n * Web browser popup adapter. Opens the given URL in a centered\n * `window.open()` popup, polls for close, and optionally forwards\n * `postMessage` events back to the caller.\n *\n * Runtime requirement: `window.open` must exist. Throws if called\n * under Node / SSR / React Native — use `setPafiWebModalAdapter()` to\n * provide a platform-specific adapter in those environments.\n *\n * ## Popup blocking\n *\n * Browsers block `window.open()` unless it happens inside a user\n * gesture (click handler). Callers MUST wire this into a direct click\n * handler — wrapping it in a `setTimeout` or async await before the\n * open call will trigger the blocker.\n */\nexport function openWebPopup(\n url: string,\n options: ModalOpenOptions = {},\n): PafiWebModalHandle {\n if (typeof window === \"undefined\" || typeof window.open !== \"function\") {\n throw new Error(\n \"openWebPopup: `window.open` is not available in this runtime. \" +\n \"Register a platform adapter via setPafiWebModalAdapter() instead.\",\n );\n }\n\n const width = options.width ?? DEFAULT_WIDTH;\n const height = options.height ?? DEFAULT_HEIGHT;\n const name = options.windowName ?? DEFAULT_NAME;\n\n // Center on the screen — works in all major browsers. Falls back\n // gracefully if `screen.availWidth`/`screenX` are unavailable.\n const screenW = window.screen?.availWidth ?? window.innerWidth;\n const screenH = window.screen?.availHeight ?? window.innerHeight;\n const left = Math.max(0, Math.floor((screenW - width) / 2));\n const top = Math.max(0, Math.floor((screenH - height) / 2));\n\n const features = [\n `width=${width}`,\n `height=${height}`,\n `left=${left}`,\n `top=${top}`,\n \"resizable=yes\",\n \"scrollbars=yes\",\n \"noopener=no\", // we need opener.postMessage to work\n ].join(\",\");\n\n const popup = window.open(url, name, features);\n if (!popup) {\n throw new Error(\n \"openWebPopup: popup was blocked. Ensure this call runs inside a user gesture (click handler).\",\n );\n }\n\n // Set up state + listeners --------------------------------------------\n\n let closed = false;\n let pollId: ReturnType<typeof setInterval> | null = null;\n let messageListener: ((e: MessageEvent) => void) | null = null;\n\n const dispose = (): void => {\n if (closed) return;\n closed = true;\n if (pollId !== null) {\n clearInterval(pollId);\n pollId = null;\n }\n if (messageListener) {\n window.removeEventListener(\"message\", messageListener);\n messageListener = null;\n }\n options.onClose?.();\n };\n\n // Poll every 500ms for popup close — there's no `close` event.\n // Stops when `popup.closed` flips to true OR our handle is closed.\n pollId = setInterval(() => {\n if (popup.closed) {\n dispose();\n }\n }, 500);\n\n // Wire postMessage filtering by origin — secure-by-default. An\n // empty or missing `allowedOrigins` rejects ALL messages; the\n // caller must explicitly whitelist PAFI Web's host(s) before any\n // payload is delivered. This prevents a compromised popup (via\n // opener leak or redirect) from impersonating PAFI Web.\n if (options.onMessage) {\n const allowed = options.allowedOrigins ?? [];\n const onMessage = options.onMessage;\n messageListener = (event: MessageEvent): void => {\n if (event.source !== popup) return;\n if (!allowed.includes(event.origin)) return;\n onMessage(event.data, event.origin);\n };\n window.addEventListener(\"message\", messageListener);\n }\n\n // Handle object -------------------------------------------------------\n\n return {\n get isOpen(): boolean {\n return !closed && !popup.closed;\n },\n close(): void {\n if (closed) return;\n try {\n popup.close();\n } catch {\n // Some browsers block close() unless the popup was opened by\n // the same document. Dispose our listeners anyway.\n }\n dispose();\n },\n focus(): void {\n if (closed || popup.closed) return;\n try {\n popup.focus();\n } catch {\n // No-op on failure — focus is best-effort.\n }\n },\n postMessage(data: unknown): void {\n if (closed || popup.closed) return;\n try {\n // targetOrigin '*' is fine here because the caller owns the\n // data being sent. For security on the receiving side, the\n // PAFI Web page should check event.origin itself.\n popup.postMessage(data, \"*\");\n } catch {\n // No-op.\n }\n },\n };\n}\n\n/**\n * The web popup packaged as a {@link PafiWebModalAdapter} so callers\n * can register it explicitly (e.g. in a test harness).\n */\nexport const webPopupAdapter: PafiWebModalAdapter = {\n open(url, options) {\n return openWebPopup(url, options);\n },\n};\n","import { openWebPopup } from \"./webPopup\";\nimport type {\n ModalOpenOptions,\n PafiWebModalAdapter,\n PafiWebModalHandle,\n} from \"./types\";\n\nexport type {\n ModalOpenOptions,\n PafiWebModalAdapter,\n PafiWebModalHandle,\n} from \"./types\";\nexport { openWebPopup, webPopupAdapter } from \"./webPopup\";\n\n/**\n * Module-level adapter registry — allows platform consumers (React\n * Native, Electron, Tauri, etc.) to plug in their own handoff\n * implementation without forking the SDK.\n *\n * Callers set this once at app boot; `openPafiWebModal()` below uses\n * whatever is registered, or falls back to the web popup adapter\n * when `window.open` is available.\n */\nlet registeredAdapter: PafiWebModalAdapter | null = null;\n\n/**\n * Register the adapter used by `openPafiWebModal()`. Typically called\n * once during app initialization — mobile apps register a\n * SFSafariViewController / Chrome Custom Tabs adapter, desktop apps\n * can leave it unset (web popup is the default).\n *\n * Pass `null` to unregister and fall back to the default.\n */\nexport function setPafiWebModalAdapter(\n adapter: PafiWebModalAdapter | null,\n): void {\n registeredAdapter = adapter;\n}\n\n/**\n * Return the currently registered adapter, or `null` when none is set.\n * Useful for tests that want to snapshot-and-restore the adapter.\n */\nexport function getPafiWebModalAdapter(): PafiWebModalAdapter | null {\n return registeredAdapter;\n}\n\n/**\n * Open PAFI Web in the host platform's appropriate UX:\n *\n * - Browser (window.open): centered popup, 900×700 by default\n * - React Native (with adapter registered): SFSafariViewController\n * / Chrome Custom Tabs via `react-native-inappbrowser-reborn` or\n * `expo-web-browser`\n * - Desktop (with adapter registered): custom BrowserWindow / new tab\n *\n * Resolution order:\n * 1. If an adapter was registered via `setPafiWebModalAdapter()`, use it.\n * 2. Else if `window.open` is available, use the built-in web popup.\n * 3. Else throw with a clear error pointing at the adapter registry.\n *\n * @example\n * ```ts\n * // User clicks \"Trade on PAFI\" button\n * button.addEventListener('click', async () => {\n * const modal = await openPafiWebModal('https://app.pacificfinance.org', {\n * allowedOrigins: ['https://app.pacificfinance.org'],\n * onMessage: (data, origin) => {\n * if (typeof data === 'object' && data && 'txHash' in data) {\n * console.log('Swap confirmed:', data.txHash);\n * modal.close();\n * }\n * },\n * onClose: () => {\n * console.log('User closed modal');\n * },\n * });\n * });\n * ```\n */\nexport async function openPafiWebModal(\n url: string,\n options: ModalOpenOptions = {},\n): Promise<PafiWebModalHandle> {\n if (!url || typeof url !== \"string\") {\n throw new Error(\"openPafiWebModal: `url` is required\");\n }\n\n if (registeredAdapter) {\n return Promise.resolve(registeredAdapter.open(url, options));\n }\n\n if (typeof window !== \"undefined\" && typeof window.open === \"function\") {\n return openWebPopup(url, options);\n }\n\n throw new Error(\n \"openPafiWebModal: no adapter registered and `window.open` is unavailable. \" +\n \"Call `setPafiWebModalAdapter()` with a platform-specific adapter (e.g. SFSafariViewController on iOS) during app boot.\",\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,oBAAoB,YAAY;;;ACAzC,SAAS,0BAA0B;;;ACAnC,SAAS,WAAW,cAAc,2BAA2B;AAuCtD,IAAM,6BACX;AAMK,IAAM,0BAAmD;AAAA,EAC9D,MAAM;AACR;AAQO,IAAM,gBAAgB;AAAA;AAAA,EAE3B,WAAW,UAAU,aAAa,CAAC,QAAQ,GAAG,CAAC,WAAW,CAAC,CAAC;AAAA;AAAA,EAE5D,SAAS,UAAU,aAAa,CAAC,QAAQ,GAAG,CAAC,SAAS,CAAC,CAAC;AAAA;AAAA,EAExD,MAAM,UAAU,aAAa,CAAC,QAAQ,GAAG,CAA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AC5E;AAAA;AAAA,EAGA,MAAM,iBAAiB,SAA+B;AACpD,UAAM,SAAS,KAAK,cAAc;AAClC,UAAM,UAAU,OAAO;AACvB,QAAI,CAAC,SAAS;AACZ,YAAM,IAAI,mBAAmB,gCAAgC;AAAA,IAC/D;AACA,WAAO,OAAO,YAAY,EAAE,SAAS,QAAQ,CAAC;AAAA,EAChD;AACF;","names":[]}
@@ -5,9 +5,9 @@
5
5
 
6
6
 
7
7
 
8
- var _chunkCAE2BVKIcjs = require('../chunk-CAE2BVKI.cjs');
8
+ var _chunkZ2V525IScjs = require('../chunk-Z2V525IS.cjs');
9
9
  require('../chunk-CL3QSI4O.cjs');
10
- require('../chunk-CWP4PFOP.cjs');
10
+ require('../chunk-DMW67WBU.cjs');
11
11
 
12
12
 
13
13
 
@@ -15,5 +15,5 @@ require('../chunk-CWP4PFOP.cjs');
15
15
 
16
16
 
17
17
 
18
- exports.buildAllPaths = _chunkCAE2BVKIcjs.buildAllPaths; exports.combineRoutes = _chunkCAE2BVKIcjs.combineRoutes; exports.findBestQuote = _chunkCAE2BVKIcjs.findBestQuote; exports.quoteBestRoute = _chunkCAE2BVKIcjs.quoteBestRoute; exports.quoteExactInput = _chunkCAE2BVKIcjs.quoteExactInput; exports.quoteExactInputSingle = _chunkCAE2BVKIcjs.quoteExactInputSingle;
18
+ exports.buildAllPaths = _chunkZ2V525IScjs.buildAllPaths; exports.combineRoutes = _chunkZ2V525IScjs.combineRoutes; exports.findBestQuote = _chunkZ2V525IScjs.findBestQuote; exports.quoteBestRoute = _chunkZ2V525IScjs.quoteBestRoute; exports.quoteExactInput = _chunkZ2V525IScjs.quoteExactInput; exports.quoteExactInputSingle = _chunkZ2V525IScjs.quoteExactInputSingle;
19
19
  //# sourceMappingURL=index.cjs.map
@@ -1,5 +1,5 @@
1
1
  import { Address, PublicClient } from 'viem';
2
- import { P as PoolKey, e as PathKey, B as BestQuote, Q as QuoteResult } from '../types-BDOnH5Le.cjs';
2
+ import { P as PoolKey, d as PathKey, B as BestQuote, Q as QuoteResult } from '../types-b5_Tokjl.cjs';
3
3
 
4
4
  /**
5
5
  * Combine point-token-specific pools and common pools for a given chain.
@@ -1,5 +1,5 @@
1
1
  import { Address, PublicClient } from 'viem';
2
- import { P as PoolKey, e as PathKey, B as BestQuote, Q as QuoteResult } from '../types-BDOnH5Le.js';
2
+ import { P as PoolKey, d as PathKey, B as BestQuote, Q as QuoteResult } from '../types-b5_Tokjl.js';
3
3
 
4
4
  /**
5
5
  * Combine point-token-specific pools and common pools for a given chain.
@@ -5,9 +5,9 @@ import {
5
5
  quoteBestRoute,
6
6
  quoteExactInput,
7
7
  quoteExactInputSingle
8
- } from "../chunk-FIKTQR7H.js";
8
+ } from "../chunk-I2P3TIP7.js";
9
9
  import "../chunk-KFWZRL7I.js";
10
- import "../chunk-R4L66ZR5.js";
10
+ import "../chunk-73CQTNLB.js";
11
11
  export {
12
12
  buildAllPaths,
13
13
  combineRoutes,
@@ -11,9 +11,8 @@
11
11
 
12
12
 
13
13
 
14
- var _chunkCXFUP2YKcjs = require('../chunk-CXFUP2YK.cjs');
14
+ var _chunkEDR5SFJNcjs = require('../chunk-EDR5SFJN.cjs');
15
15
  require('../chunk-IPXARZ6F.cjs');
16
- require('../chunk-5QJZT7VB.cjs');
17
16
 
18
17
 
19
18
 
@@ -27,5 +26,5 @@ require('../chunk-5QJZT7VB.cjs');
27
26
 
28
27
 
29
28
 
30
- exports.SETTLE_ALL = _chunkCXFUP2YKcjs.SETTLE_ALL; exports.SWAP_EXACT_IN = _chunkCXFUP2YKcjs.SWAP_EXACT_IN; exports.TAKE_ALL = _chunkCXFUP2YKcjs.TAKE_ALL; exports.V4_SWAP = _chunkCXFUP2YKcjs.V4_SWAP; exports.buildErc20ApprovalCalldata = _chunkCXFUP2YKcjs.buildErc20ApprovalCalldata; exports.buildPermit2ApprovalCalldata = _chunkCXFUP2YKcjs.buildPermit2ApprovalCalldata; exports.buildSwapFromQuote = _chunkCXFUP2YKcjs.buildSwapFromQuote; exports.buildSwapWithGasDeduction = _chunkCXFUP2YKcjs.buildSwapWithGasDeduction; exports.buildUniversalRouterExecuteArgs = _chunkCXFUP2YKcjs.buildUniversalRouterExecuteArgs; exports.buildV4SwapInput = _chunkCXFUP2YKcjs.buildV4SwapInput; exports.checkAllowance = _chunkCXFUP2YKcjs.checkAllowance; exports.simulateSwap = _chunkCXFUP2YKcjs.simulateSwap;
29
+ exports.SETTLE_ALL = _chunkEDR5SFJNcjs.SETTLE_ALL; exports.SWAP_EXACT_IN = _chunkEDR5SFJNcjs.SWAP_EXACT_IN; exports.TAKE_ALL = _chunkEDR5SFJNcjs.TAKE_ALL; exports.V4_SWAP = _chunkEDR5SFJNcjs.V4_SWAP; exports.buildErc20ApprovalCalldata = _chunkEDR5SFJNcjs.buildErc20ApprovalCalldata; exports.buildPermit2ApprovalCalldata = _chunkEDR5SFJNcjs.buildPermit2ApprovalCalldata; exports.buildSwapFromQuote = _chunkEDR5SFJNcjs.buildSwapFromQuote; exports.buildSwapWithGasDeduction = _chunkEDR5SFJNcjs.buildSwapWithGasDeduction; exports.buildUniversalRouterExecuteArgs = _chunkEDR5SFJNcjs.buildUniversalRouterExecuteArgs; exports.buildV4SwapInput = _chunkEDR5SFJNcjs.buildV4SwapInput; exports.checkAllowance = _chunkEDR5SFJNcjs.checkAllowance; exports.simulateSwap = _chunkEDR5SFJNcjs.simulateSwap;
31
30
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/phitran/Pacific-Finance/pafi-backend/pafi-sdk/packages/core/dist/swap/index.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,yDAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,mxBAAC","file":"/Users/phitran/Pacific-Finance/pafi-backend/pafi-sdk/packages/core/dist/swap/index.cjs"}
1
+ {"version":3,"sources":["/Users/phitran/Pacific-Finance/pafi-backend/pafi-sdk/packages/core/dist/swap/index.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,yDAA8B;AAC9B,iCAA8B;AAC9B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,mxBAAC","file":"/Users/phitran/Pacific-Finance/pafi-backend/pafi-sdk/packages/core/dist/swap/index.cjs"}
@@ -1,3 +1,3 @@
1
- export { B as BuildSwapWithGasDeductionParams, b as SETTLE_ALL, c as SWAP_EXACT_IN, S as SwapSimulationResult, T as TAKE_ALL, V as V4_SWAP, e as buildErc20ApprovalCalldata, f as buildPermit2ApprovalCalldata, g as buildSwapFromQuote, h as buildSwapWithGasDeduction, i as buildUniversalRouterExecuteArgs, j as buildV4SwapInput, k as checkAllowance, s as simulateSwap } from '../index-BpUYHGu3.cjs';
1
+ export { B as BuildSwapWithGasDeductionParams, b as SETTLE_ALL, c as SWAP_EXACT_IN, S as SwapSimulationResult, T as TAKE_ALL, V as V4_SWAP, e as buildErc20ApprovalCalldata, f as buildPermit2ApprovalCalldata, g as buildSwapFromQuote, h as buildSwapWithGasDeduction, i as buildUniversalRouterExecuteArgs, j as buildV4SwapInput, k as checkAllowance, s as simulateSwap } from '../index-B7pGBych.cjs';
2
2
  import 'viem';
3
- import '../types-BDOnH5Le.cjs';
3
+ import '../types-b5_Tokjl.cjs';
@@ -1,3 +1,3 @@
1
- export { B as BuildSwapWithGasDeductionParams, b as SETTLE_ALL, c as SWAP_EXACT_IN, S as SwapSimulationResult, T as TAKE_ALL, V as V4_SWAP, e as buildErc20ApprovalCalldata, f as buildPermit2ApprovalCalldata, g as buildSwapFromQuote, h as buildSwapWithGasDeduction, i as buildUniversalRouterExecuteArgs, j as buildV4SwapInput, k as checkAllowance, s as simulateSwap } from '../index-CNALKsH1.js';
1
+ export { B as BuildSwapWithGasDeductionParams, b as SETTLE_ALL, c as SWAP_EXACT_IN, S as SwapSimulationResult, T as TAKE_ALL, V as V4_SWAP, e as buildErc20ApprovalCalldata, f as buildPermit2ApprovalCalldata, g as buildSwapFromQuote, h as buildSwapWithGasDeduction, i as buildUniversalRouterExecuteArgs, j as buildV4SwapInput, k as checkAllowance, s as simulateSwap } from '../index-B06IJlHe.js';
2
2
  import 'viem';
3
- import '../types-BDOnH5Le.js';
3
+ import '../types-b5_Tokjl.js';
@@ -11,9 +11,8 @@ import {
11
11
  buildV4SwapInput,
12
12
  checkAllowance,
13
13
  simulateSwap
14
- } from "../chunk-IK4UK7KT.js";
14
+ } from "../chunk-W23EJNYG.js";
15
15
  import "../chunk-2PIXFXA2.js";
16
- import "../chunk-P56TUGTS.js";
17
16
  export {
18
17
  SETTLE_ALL,
19
18
  SWAP_EXACT_IN,
@@ -7,6 +7,13 @@ interface MintRequest {
7
7
  nonce: bigint;
8
8
  deadline: bigint;
9
9
  }
10
+ /** BurnRequest(address from,uint256 amount,uint256 nonce,uint256 deadline) */
11
+ interface BurnRequest {
12
+ from: Address;
13
+ amount: bigint;
14
+ nonce: bigint;
15
+ deadline: bigint;
16
+ }
10
17
  /** ReceiverConsent(address onBehalfOf,address originalReceiver,uint256 amount,uint256 nonce,uint256 deadline,bytes extData) */
11
18
  interface ReceiverConsent {
12
19
  onBehalfOf: Address;
@@ -32,16 +39,6 @@ interface SignatureVerification {
32
39
  recoveredAddress: Address;
33
40
  }
34
41
  /** Auto-generated from Solidity struct — do not edit */
35
- interface MintParams {
36
- pointToken: Address;
37
- receiver: Address;
38
- amount: bigint;
39
- deadline: bigint;
40
- minterSig: Hex;
41
- receiverSig: Hex;
42
- extData: Hex;
43
- }
44
- /** Auto-generated from Solidity struct — do not edit */
45
42
  interface PathKey {
46
43
  intermediateCurrency: Address;
47
44
  fee: number;
@@ -50,11 +47,6 @@ interface PathKey {
50
47
  hookData: Hex;
51
48
  }
52
49
  /** Auto-generated from Solidity struct — do not edit */
53
- interface SwapParams {
54
- path: PathKey[];
55
- deadline: bigint;
56
- }
57
- /** Auto-generated from Solidity struct — do not edit */
58
50
  interface Issuer {
59
51
  issuerAddress: Address;
60
52
  signerAddress: Address;
@@ -88,11 +80,10 @@ interface BestQuote {
88
80
  }
89
81
  interface PafiSDKConfig {
90
82
  pointTokenAddress?: Address;
91
- relayContractAddress?: Address;
92
83
  signer?: WalletClient;
93
84
  provider?: PublicClient;
94
85
  rpcUrl?: string;
95
86
  chainId?: number;
96
87
  }
97
88
 
98
- export type { BestQuote as B, ChainConfig as C, EIP712Signature as E, Issuer as I, MintRequest as M, PoolKey as P, QuoteResult as Q, ReceiverConsent as R, SignatureVerification as S, PointTokenDomainConfig as a, PafiSDKConfig as b, MintParams as c, SwapParams as d, PathKey as e };
89
+ export type { BestQuote as B, ChainConfig as C, EIP712Signature as E, Issuer as I, MintRequest as M, PoolKey as P, QuoteResult as Q, ReceiverConsent as R, SignatureVerification as S, PafiSDKConfig as a, PointTokenDomainConfig as b, BurnRequest as c, PathKey as d };
@@ -7,6 +7,13 @@ interface MintRequest {
7
7
  nonce: bigint;
8
8
  deadline: bigint;
9
9
  }
10
+ /** BurnRequest(address from,uint256 amount,uint256 nonce,uint256 deadline) */
11
+ interface BurnRequest {
12
+ from: Address;
13
+ amount: bigint;
14
+ nonce: bigint;
15
+ deadline: bigint;
16
+ }
10
17
  /** ReceiverConsent(address onBehalfOf,address originalReceiver,uint256 amount,uint256 nonce,uint256 deadline,bytes extData) */
11
18
  interface ReceiverConsent {
12
19
  onBehalfOf: Address;
@@ -32,16 +39,6 @@ interface SignatureVerification {
32
39
  recoveredAddress: Address;
33
40
  }
34
41
  /** Auto-generated from Solidity struct — do not edit */
35
- interface MintParams {
36
- pointToken: Address;
37
- receiver: Address;
38
- amount: bigint;
39
- deadline: bigint;
40
- minterSig: Hex;
41
- receiverSig: Hex;
42
- extData: Hex;
43
- }
44
- /** Auto-generated from Solidity struct — do not edit */
45
42
  interface PathKey {
46
43
  intermediateCurrency: Address;
47
44
  fee: number;
@@ -50,11 +47,6 @@ interface PathKey {
50
47
  hookData: Hex;
51
48
  }
52
49
  /** Auto-generated from Solidity struct — do not edit */
53
- interface SwapParams {
54
- path: PathKey[];
55
- deadline: bigint;
56
- }
57
- /** Auto-generated from Solidity struct — do not edit */
58
50
  interface Issuer {
59
51
  issuerAddress: Address;
60
52
  signerAddress: Address;
@@ -88,11 +80,10 @@ interface BestQuote {
88
80
  }
89
81
  interface PafiSDKConfig {
90
82
  pointTokenAddress?: Address;
91
- relayContractAddress?: Address;
92
83
  signer?: WalletClient;
93
84
  provider?: PublicClient;
94
85
  rpcUrl?: string;
95
86
  chainId?: number;
96
87
  }
97
88
 
98
- export type { BestQuote as B, ChainConfig as C, EIP712Signature as E, Issuer as I, MintRequest as M, PoolKey as P, QuoteResult as Q, ReceiverConsent as R, SignatureVerification as S, PointTokenDomainConfig as a, PafiSDKConfig as b, MintParams as c, SwapParams as d, PathKey as e };
89
+ export type { BestQuote as B, ChainConfig as C, EIP712Signature as E, Issuer as I, MintRequest as M, PoolKey as P, QuoteResult as Q, ReceiverConsent as R, SignatureVerification as S, PafiSDKConfig as a, PointTokenDomainConfig as b, BurnRequest as c, PathKey as d };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pafi-dev/core",
3
- "version": "0.3.0-beta.1",
3
+ "version": "0.3.0-beta.11",
4
4
  "description": "EIP-712 signing, contract interaction, and Relay calldata for the PAFI point token system",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",