@pafi-dev/core 0.7.6 → 0.7.10

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 (57) hide show
  1. package/dist/abi/index.cjs +4 -2
  2. package/dist/abi/index.cjs.map +1 -1
  3. package/dist/abi/index.js +4 -2
  4. package/dist/auth/index.cjs +6 -2
  5. package/dist/auth/index.cjs.map +1 -1
  6. package/dist/auth/index.d.cts +21 -9
  7. package/dist/auth/index.d.ts +21 -9
  8. package/dist/auth/index.js +5 -1
  9. package/dist/{chunk-6UX2IFA2.js → chunk-4EGXLYMM.js} +20 -2
  10. package/dist/chunk-4EGXLYMM.js.map +1 -0
  11. package/dist/{chunk-M5ULOZ3A.cjs → chunk-4QRHSZZQ.cjs} +55 -3
  12. package/dist/chunk-4QRHSZZQ.cjs.map +1 -0
  13. package/dist/chunk-6WWSKC3Z.cjs +1097 -0
  14. package/dist/chunk-6WWSKC3Z.cjs.map +1 -0
  15. package/dist/{chunk-5254AG3Z.cjs → chunk-75JWR5SA.cjs} +21 -3
  16. package/dist/chunk-75JWR5SA.cjs.map +1 -0
  17. package/dist/{chunk-YDLMVWDH.js → chunk-AEYEFV5G.js} +5 -3
  18. package/dist/{chunk-YDLMVWDH.js.map → chunk-AEYEFV5G.js.map} +1 -1
  19. package/dist/{chunk-5JZOJIBT.js → chunk-B2NDSIAI.js} +1 -1095
  20. package/dist/chunk-B2NDSIAI.js.map +1 -0
  21. package/dist/chunk-JEWSN7Q3.cjs +1059 -0
  22. package/dist/chunk-JEWSN7Q3.cjs.map +1 -0
  23. package/dist/{chunk-WJSIB5GF.js → chunk-QL5COJQI.js} +53 -1
  24. package/dist/chunk-QL5COJQI.js.map +1 -0
  25. package/dist/{chunk-CLPRSQT2.cjs → chunk-REUEMYWB.cjs} +14 -12
  26. package/dist/chunk-REUEMYWB.cjs.map +1 -0
  27. package/dist/chunk-SZMSKZHY.js +1097 -0
  28. package/dist/chunk-SZMSKZHY.js.map +1 -0
  29. package/dist/contract/index.cjs +4 -3
  30. package/dist/contract/index.cjs.map +1 -1
  31. package/dist/contract/index.d.cts +1 -1
  32. package/dist/contract/index.d.ts +1 -1
  33. package/dist/contract/index.js +3 -2
  34. package/dist/eip712/index.cjs +7 -2
  35. package/dist/eip712/index.cjs.map +1 -1
  36. package/dist/eip712/index.d.cts +39 -4
  37. package/dist/eip712/index.d.ts +39 -4
  38. package/dist/eip712/index.js +6 -1
  39. package/dist/index.cjs +98 -32
  40. package/dist/index.cjs.map +1 -1
  41. package/dist/index.d.cts +78 -31
  42. package/dist/index.d.ts +78 -31
  43. package/dist/index.js +87 -21
  44. package/dist/index.js.map +1 -1
  45. package/dist/types-CCvAk-ma.d.cts +159 -0
  46. package/dist/types-CCvAk-ma.d.ts +159 -0
  47. package/package.json +1 -1
  48. package/dist/chunk-5254AG3Z.cjs.map +0 -1
  49. package/dist/chunk-5JZOJIBT.js.map +0 -1
  50. package/dist/chunk-6UX2IFA2.js.map +0 -1
  51. package/dist/chunk-CLPRSQT2.cjs.map +0 -1
  52. package/dist/chunk-LRHY7GOR.cjs +0 -2153
  53. package/dist/chunk-LRHY7GOR.cjs.map +0 -1
  54. package/dist/chunk-M5ULOZ3A.cjs.map +0 -1
  55. package/dist/chunk-WJSIB5GF.js.map +0 -1
  56. package/dist/types-BAkmxgVo.d.cts +0 -99
  57. package/dist/types-BAkmxgVo.d.ts +0 -99
package/dist/index.d.cts CHANGED
@@ -1,11 +1,11 @@
1
1
  import { Address, Hex, TypedDataDomain, PublicClient, WalletClient, TransactionReceipt, HttpTransport } from 'viem';
2
- import { P as PoolKey, C as ChainConfig, a as PafiSDKConfig, b as PointTokenDomainConfig, M as MintRequest, R as ReceiverConsent, E as EIP712Signature, S as SignatureVerification } from './types-BAkmxgVo.cjs';
3
- export { B as BestQuote, c as BurnRequest, I as Issuer, d as PathKey, Q as QuoteResult } from './types-BAkmxgVo.cjs';
2
+ import { P as PoolKey, C as ChainConfig, a as PafiSDKConfig, b as PointTokenDomainConfig, M as MintRequest, R as ReceiverConsent, E as EIP712Signature, S as SignatureVerification } from './types-CCvAk-ma.cjs';
3
+ export { B as BestQuote, c as BlackoutWindow, d as BurnRequest, I as Issuer, e as PathKey, Q as QuoteResult, f as RedemptionDecision, g as RedemptionDenial, h as RedemptionDenialCode, i as RedemptionPolicy, j as RedemptionPolicySource, k as RedemptionPreview } from './types-CCvAk-ma.cjs';
4
4
  export { pointTokenAbi as POINT_TOKEN_V2_ABI, erc20Abi, issuerRegistryAbi, mintingOracleAbi, permit2Abi, pointTokenAbi, pointTokenFactoryAbi, universalRouterAbi, v4QuoterAbi } from './abi/index.cjs';
5
- export { buildBurnRequestTypedData, buildDomain, buildMintRequestTypedData, buildReceiverConsentTypedData, signBurnRequest, signMintRequest, signReceiverConsent, verifyBurnRequest, verifyMintRequest, verifyReceiverConsent } from './eip712/index.cjs';
5
+ export { Eip712DomainMismatchError, assertDomainMatchesContract, buildBurnRequestTypedData, buildDomain, buildMintRequestTypedData, buildReceiverConsentTypedData, signBurnRequest, signMintRequest, signReceiverConsent, verifyBurnRequest, verifyMintRequest, verifyReceiverConsent } from './eip712/index.cjs';
6
6
  export { getBurnRequestNonce, getIssuer, getMintRequestNonce, getPointTokenBalance, getPointTokenIssuer, getPointTokenIssuerAddress, getReceiverConsentNonce, getTokenName, isActiveIssuer, isMinter, issuerRegistryGetIssuerFlatAbi, verifyMintCap } from './contract/index.cjs';
7
7
  import { LoginMessageParams } from './auth/index.cjs';
8
- export { BuildSponsorAuthParams, BuiltSponsorAuth, SPONSOR_AUTH_DOMAIN_NAME, SPONSOR_AUTH_TYPES, SponsorAuthPayload, SponsorAuthVerifyResult, VerifyLoginResult, buildAndSignSponsorAuth, buildSponsorAuthDomain, buildSponsorAuthTypedData, computeCallDataHash, createLoginMessage, generateSponsorAuthNonce, parseLoginMessage, signSponsorAuth, verifyLoginMessage, verifySponsorAuth } from './auth/index.cjs';
8
+ export { BuildSponsorAuthParams, BuiltSponsorAuth, SPONSOR_AUTH_DOMAIN_ANCHOR_BASE_MAINNET, SPONSOR_AUTH_DOMAIN_NAME, SPONSOR_AUTH_TYPES, SponsorAuthPayload, SponsorAuthVerifyResult, VerifyLoginResult, buildAndSignSponsorAuth, buildSponsorAuthDomain, buildSponsorAuthTypedData, computeCallDataHash, createLoginMessage, generateSponsorAuthNonce, getSponsorAuthDomainAnchor, parseLoginMessage, signSponsorAuth, verifyLoginMessage, verifySponsorAuth } from './auth/index.cjs';
9
9
 
10
10
  declare const mintRequestTypes: {
11
11
  readonly MintRequest: readonly [{
@@ -83,15 +83,13 @@ declare const ENTRY_POINT_V08: Address;
83
83
  declare const PERMIT2_ADDRESS: Address;
84
84
 
85
85
  /**
86
- * v0.7.1 — unified error base for the entire SDK (core + issuer +
87
- * trading). Subclasses declare `code` (machine-readable) and
88
- * `httpStatus` (recommended HTTP status for issuer's controller).
86
+ * Unified error base for the entire SDK (core + issuer + trading).
87
+ * Subclasses declare `code` (machine-readable) and `httpStatus`
88
+ * (recommended HTTP status for issuer's controller).
89
89
  *
90
90
  * Issuer's `createSdkErrorMapper` routes any `PafiSdkError` instance
91
91
  * through framework-specific exception factories; non-PafiSdkError
92
92
  * still becomes 500.
93
- *
94
- * See SDK_CORE_TRADING_AUDIT.md H3.
95
93
  */
96
94
  type SdkErrorHttpStatus = "not_found" | "forbidden" | "unprocessable" | "service_unavailable";
97
95
  declare abstract class PafiSdkError extends Error {
@@ -106,11 +104,11 @@ declare abstract class PafiSdkError extends Error {
106
104
  constructor(message: string);
107
105
  }
108
106
  /**
109
- * @deprecated v0.7.1 — use `PafiSdkError` (capital S, lowercase dk).
107
+ * @deprecated Use `PafiSdkError` (capital S, lowercase dk).
110
108
  * The two classes existed in parallel ("PafiSDKError" in core,
111
109
  * "PafiSdkError" in issuer) due to historical drift; consolidating
112
110
  * here. Kept as alias for back-compat through v0.7.x; will be removed
113
- * in v0.8. See SDK_CORE_TRADING_AUDIT.md H3.
111
+ * in v0.8.
114
112
  */
115
113
  declare class PafiSDKError extends Error {
116
114
  constructor(message: string);
@@ -133,11 +131,8 @@ declare class ApiError extends PafiSDKError {
133
131
  /**
134
132
  * Thrown by `quoteOperatorFee*` when an upstream price source
135
133
  * (Chainlink ETH/USD, PAFI subgraph) is unavailable or stale and the
136
- * caller did not opt in to the hardcoded fallback prices.
137
- *
138
- * v0.7.1 — previously `quoteOperatorFeePt` silently fell back to
139
- * ETH=$3000 / PT=$0.10 with `console.warn`. Now opt-in via
140
- * `allowStaleFallback: true`. See SDK_CORE_TRADING_AUDIT.md C2.
134
+ * caller did not opt in to the hardcoded fallback prices via
135
+ * `allowStaleFallback: true`.
141
136
  *
142
137
  * Extends the unified `PafiSdkError` so issuer's `createSdkErrorMapper`
143
138
  * routes it to 503 instead of leaking as a 500.
@@ -156,8 +151,6 @@ declare class OracleStaleError extends PafiSdkError {
156
151
  *
157
152
  * Uses an instance `details` field so subclasses can override the
158
153
  * declaration; matches the issuer-side shape that pre-existed here.
159
- *
160
- * v0.7.4 — added per SDK_CORE_TRADING_AUDIT.md H2/H13.
161
154
  */
162
155
  declare class ValidationError extends PafiSdkError {
163
156
  readonly httpStatus: "unprocessable";
@@ -1173,8 +1166,8 @@ type SignAuthorizationFn = (args: {
1173
1166
  nonce: number;
1174
1167
  r: Hex | string;
1175
1168
  s: Hex | string;
1176
- v?: string | number;
1177
- yParity: 0 | 1 | string;
1169
+ v?: bigint | string | number;
1170
+ yParity: number | string;
1178
1171
  }>;
1179
1172
  /**
1180
1173
  * Authorization tuple in the shape `walletClient.sendTransaction`
@@ -1392,10 +1385,6 @@ interface SmartAccountSender {
1392
1385
  *
1393
1386
  * Use this to decide whether retrying without a paymaster makes sense.
1394
1387
  * Contract reverts (AA23, AA24, AA25) and bundler errors are NOT matched.
1395
- *
1396
- * v0.7.1 — replaced naive substring matching that false-positived on
1397
- * arbitrary text containing "503"/"403"/"429" (e.g. address/transit ID).
1398
- * See SDK_CORE_TRADING_AUDIT.md C3.
1399
1388
  */
1400
1389
  declare function isPaymasterError(err: unknown): boolean;
1401
1390
  interface SendWithPaymasterFallbackParams {
@@ -1459,8 +1448,7 @@ declare function sendWithPaymasterFallback(params: SendWithPaymasterFallbackPara
1459
1448
  * perp-deposit — `buildPerpDepositViaRelay` 800k (LayerZero msg)
1460
1449
  * delegate — minimal no-op self-call, 200k margin
1461
1450
  *
1462
- * Pass an explicit `gasUnits` to override. v0.7.4 — added per
1463
- * SDK_CORE_TRADING_AUDIT.md H12.
1451
+ * Pass an explicit `gasUnits` to override.
1464
1452
  */
1465
1453
  type FeeScenario = "mint" | "burn" | "swap" | "perp-deposit" | "delegate";
1466
1454
  interface QuoteOperatorFeePtConfig {
@@ -1497,17 +1485,38 @@ interface QuoteOperatorFeePtConfig {
1497
1485
  * `true` AND configure `fallbackEthPriceUsd` / `fallbackPtPriceUsdt`
1498
1486
  * to absorb oracle outages instead of surfacing them.
1499
1487
  *
1500
- * v0.7.1 previously fallback was always-on with hardcoded
1501
- * defaults (ETH=$3000, PT=$0.10), causing under-priced fees during
1502
- * incidents. See SDK_CORE_TRADING_AUDIT.md C2.
1488
+ * When fallback fires, callers SHOULD observe via `onFallback` so
1489
+ * production can flag the under-priced quote (e.g. show "fee priced
1490
+ * against stale oracle" banner in FE; alert on-call).
1503
1491
  */
1504
1492
  allowStaleFallback?: boolean;
1505
1493
  /** Fallback ETH price (USD) when Chainlink is unreachable. Only used when `allowStaleFallback: true`. Default 3000. */
1506
1494
  fallbackEthPriceUsd?: number;
1507
1495
  /** Fallback PT price (USDT per 1 PT) when subgraph is unreachable. Only used when `allowStaleFallback: true`. Default 0.1. */
1508
1496
  fallbackPtPriceUsdt?: number;
1497
+ /**
1498
+ * Observability hook fired when the quoter falls back to stale
1499
+ * prices. Callers SHOULD wire this to their alert pipeline (Sentry,
1500
+ * Datadog, PagerDuty) so under-priced quotes don't go unnoticed.
1501
+ * When omitted, falls back to `console.warn` (kept for back-compat
1502
+ * but invisible in most prod log shippers).
1503
+ */
1504
+ onFallback?: (info: FallbackInfo) => void;
1509
1505
  fetchImpl?: typeof fetch;
1510
1506
  }
1507
+ /**
1508
+ * Detail surfaced via `onFallback` when the quoter substitutes a
1509
+ * stale-fallback price. Callers can format this into a UI banner or
1510
+ * log line.
1511
+ */
1512
+ interface FallbackInfo {
1513
+ /** Which oracle failed. */
1514
+ source: "chainlink" | "subgraph";
1515
+ /** Underlying reason from the oracle call (e.g. RPC error message). */
1516
+ reason: string;
1517
+ /** The fallback value that was used (in source-native units). */
1518
+ fallbackValue: number;
1519
+ }
1511
1520
  /**
1512
1521
  * Subset of `QuoteOperatorFeePtConfig` that doesn't need the V4 pool
1513
1522
  * step — used by `quoteOperatorFeeUsdt` (FE cashout-preview / `/gas-fee`
@@ -1525,10 +1534,12 @@ interface QuoteOperatorFeeUsdtConfig {
1525
1534
  usdtDecimals?: number;
1526
1535
  /**
1527
1536
  * Opt-in fallback price when Chainlink is unavailable. Default
1528
- * `false` — throw `OracleStaleError`. v0.7.1 — see C2.
1537
+ * `false` — throw `OracleStaleError`.
1529
1538
  */
1530
1539
  allowStaleFallback?: boolean;
1531
1540
  fallbackEthPriceUsd?: number;
1541
+ /** See QuoteOperatorFeePtConfig.onFallback. */
1542
+ onFallback?: (info: FallbackInfo) => void;
1532
1543
  }
1533
1544
  /**
1534
1545
  * Operator fee quoted in USDT raw units (default 6 decimals). Returns
@@ -1634,6 +1645,42 @@ declare const POINT_TOKEN_IMPL_ADDRESSES: Record<number, Address>;
1634
1645
  */
1635
1646
  declare function getContractAddresses(chainId: number): ContractAddresses;
1636
1647
 
1648
+ /**
1649
+ * PAFI HTTP service URLs by chainId. Mirrors the `getContractAddresses`
1650
+ * pattern: SDK ships with the URL for each supported chain so issuers
1651
+ * don't pass URLs as env vars / constructor args.
1652
+ *
1653
+ * When PAFI changes URLs (rebrand, re-host, environment migration),
1654
+ * bump the SDK version and re-publish. Issuers pin a version, get the
1655
+ * URLs that match.
1656
+ *
1657
+ * No env override is provided on purpose — different environments use
1658
+ * different SDK versions (e.g. an `@pafi-dev/issuer-dev` channel for
1659
+ * staging). This keeps issuer integration to chainId + creds only.
1660
+ */
1661
+ interface PafiServiceUrls {
1662
+ /**
1663
+ * sponsor-relayer base URL (paymaster proxy). PafiBackendClient
1664
+ * appends `/paymaster/sponsor`, `/bundler/receipt`, etc.
1665
+ */
1666
+ sponsorRelayer: string;
1667
+ /**
1668
+ * issuer-api base URL. SettlementClient appends
1669
+ * `/issuers/:issuerId/redemption-policy`.
1670
+ */
1671
+ issuerApi: string;
1672
+ }
1673
+ /**
1674
+ * Per-chain URL map. URLs follow the pattern
1675
+ * `https://<host>/api/<service>` so Kong gateway can route by path.
1676
+ *
1677
+ * NOTE: placeholder URLs — Phi will swap in real prod/staging hosts
1678
+ * once the deploy targets are finalized. SDK version bump captures
1679
+ * the change.
1680
+ */
1681
+ declare const PAFI_SERVICE_URLS: Record<number, PafiServiceUrls>;
1682
+ declare function getPafiServiceUrls(chainId: number): PafiServiceUrls;
1683
+
1637
1684
  /**
1638
1685
  * Public contract surface for `@pafi-dev/core/contracts`.
1639
1686
  *
@@ -1971,4 +2018,4 @@ declare class PafiSDK {
1971
2018
  signLoginMessage(message: string): Promise<Hex>;
1972
2019
  }
1973
2020
 
1974
- export { ApiError, BATCH_EXECUTOR_7702_IMPL, BATCH_EXECUTOR_ABI, BATCH_EXECUTOR_ADDRESS_BASE_MAINNET, BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA, BROKER_HASHES, type BuildDelegationUserOpParams, type BuildPartialUserOpParams, type BuildPerpDepositViaRelayParams, type BuildPerpDepositWithGasDeductionParams, COMMON_POOLS, COMMON_TOKENS, CONTRACT_ADDRESSES, ChainConfig, type CheckEthAndBranchParams, ConfigurationError, type ContractAddresses, DUMMY_SIGNATURE_V07, type DelegateDirectParams, type DelegateDirectResult, type DelegateImpl, EIP712Signature, ENTRY_POINT_V07, ENTRY_POINT_V08, type Eip7702AuthorizationJsonRpc, LoginMessageParams, MintRequest, type ModalOpenOptions, ORDERLY_RELAY_ABI, ORDERLY_VAULT_ABI, ORDERLY_VAULT_ADDRESSES, ORDERLY_VAULT_BASE_MAINNET, type Operation, OracleStaleError, type OrderlyRelayDepositRequest, PAFI_SUBGRAPH_URL, PERMIT2_ADDRESS, POINT_TOKEN_FACTORY_ADDRESSES, POINT_TOKEN_IMPL_ADDRESSES, POINT_TOKEN_POOLS, type PackedUserOperationMessage, type PafiProxyTransportParams, PafiSDK, PafiSDKConfig, PafiSDKError, PafiSdkError, type PafiWebModalAdapter, type PafiWebModalHandle, type PartialUserOperation, type PaymasterConfig, type PaymasterFields, PointTokenDomainConfig, PoolKey, type QuoteOperatorFeePtConfig, type QuoteOperatorFeeUsdtConfig, ReceiverConsent, SIMPLE_7702_IMPL_BASE_MAINNET, SUPPORTED_CHAINS, type SdkErrorHttpStatus, type SendWithPaymasterFallbackParams, type SignAuthorizationFn, type SignatureStruct, SignatureVerification, type SignedAuthorization, SigningError, SimulationError, type SmartAccountSender, type SponsorshipScenario, type SubmissionPath, TOKEN_HASHES, UNIVERSAL_ROUTER_ADDRESSES, type UserOpReceipt, type UserOpTypedData, type UserOperation, V4_QUOTER_ADDRESSES, ValidationError, type VaultDepositFE, ZERO_VALUE, _resetPaymasterConfigForTests, assembleUserOperation, buildDelegationUserOp, buildEip7702Authorization, buildPartialUserOperation, buildPerpDepositViaRelay, buildPerpDepositWithGasDeduction, buildUserOpTypedData, burnRequestTypes, checkDelegation, checkEthAndBranch, computeAccountId, computeAuthorizationHash, computeUserOpHash, createPafiProxyTransport, decodeBatchExecuteCalls, delegateDirect, detectDelegateImpl, encodeBatchExecute, erc20ApproveOp, erc20BurnOp, erc20TransferOp, fetchPafiPools, getAaNonce, getContractAddresses, getDummySignatureFor7702, getPafiWebModalAdapter, getPaymasterConfig, isDelegatedTo, isDelegatedToTarget, isPaymasterConfigured, isPaymasterError, mintRequestTypes, openPafiWebModal, openWebPopup, parseEip7702DelegatedAddress, quoteOperatorFeePt, quoteOperatorFeeUsdt, rawCallOp, receiverConsentTypes, sendWithPaymasterFallback, serializeUserOpToJsonRpc, setPafiWebModalAdapter, setPaymasterConfig, splitAuthorizationSig, webPopupAdapter };
2021
+ export { ApiError, BATCH_EXECUTOR_7702_IMPL, BATCH_EXECUTOR_ABI, BATCH_EXECUTOR_ADDRESS_BASE_MAINNET, BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA, BROKER_HASHES, type BuildDelegationUserOpParams, type BuildPartialUserOpParams, type BuildPerpDepositViaRelayParams, type BuildPerpDepositWithGasDeductionParams, COMMON_POOLS, COMMON_TOKENS, CONTRACT_ADDRESSES, ChainConfig, type CheckEthAndBranchParams, ConfigurationError, type ContractAddresses, DUMMY_SIGNATURE_V07, type DelegateDirectParams, type DelegateDirectResult, type DelegateImpl, EIP712Signature, ENTRY_POINT_V07, ENTRY_POINT_V08, type Eip7702AuthorizationJsonRpc, LoginMessageParams, MintRequest, type ModalOpenOptions, ORDERLY_RELAY_ABI, ORDERLY_VAULT_ABI, ORDERLY_VAULT_ADDRESSES, ORDERLY_VAULT_BASE_MAINNET, type Operation, OracleStaleError, type OrderlyRelayDepositRequest, PAFI_SERVICE_URLS, PAFI_SUBGRAPH_URL, PERMIT2_ADDRESS, POINT_TOKEN_FACTORY_ADDRESSES, POINT_TOKEN_IMPL_ADDRESSES, POINT_TOKEN_POOLS, type PackedUserOperationMessage, type PafiProxyTransportParams, PafiSDK, PafiSDKConfig, PafiSDKError, PafiSdkError, type PafiServiceUrls, type PafiWebModalAdapter, type PafiWebModalHandle, type PartialUserOperation, type PaymasterConfig, type PaymasterFields, PointTokenDomainConfig, PoolKey, type QuoteOperatorFeePtConfig, type QuoteOperatorFeeUsdtConfig, ReceiverConsent, SIMPLE_7702_IMPL_BASE_MAINNET, SUPPORTED_CHAINS, type SdkErrorHttpStatus, type SendWithPaymasterFallbackParams, type SignAuthorizationFn, type SignatureStruct, SignatureVerification, type SignedAuthorization, SigningError, SimulationError, type SmartAccountSender, type SponsorshipScenario, type SubmissionPath, TOKEN_HASHES, UNIVERSAL_ROUTER_ADDRESSES, type UserOpReceipt, type UserOpTypedData, type UserOperation, V4_QUOTER_ADDRESSES, ValidationError, type VaultDepositFE, ZERO_VALUE, _resetPaymasterConfigForTests, assembleUserOperation, buildDelegationUserOp, buildEip7702Authorization, buildPartialUserOperation, buildPerpDepositViaRelay, buildPerpDepositWithGasDeduction, buildUserOpTypedData, burnRequestTypes, checkDelegation, checkEthAndBranch, computeAccountId, computeAuthorizationHash, computeUserOpHash, createPafiProxyTransport, decodeBatchExecuteCalls, delegateDirect, detectDelegateImpl, encodeBatchExecute, erc20ApproveOp, erc20BurnOp, erc20TransferOp, fetchPafiPools, getAaNonce, getContractAddresses, getDummySignatureFor7702, getPafiServiceUrls, getPafiWebModalAdapter, getPaymasterConfig, isDelegatedTo, isDelegatedToTarget, isPaymasterConfigured, isPaymasterError, mintRequestTypes, openPafiWebModal, openWebPopup, parseEip7702DelegatedAddress, quoteOperatorFeePt, quoteOperatorFeeUsdt, rawCallOp, receiverConsentTypes, sendWithPaymasterFallback, serializeUserOpToJsonRpc, setPafiWebModalAdapter, setPaymasterConfig, splitAuthorizationSig, webPopupAdapter };
package/dist/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  import { Address, Hex, TypedDataDomain, PublicClient, WalletClient, TransactionReceipt, HttpTransport } from 'viem';
2
- import { P as PoolKey, C as ChainConfig, a as PafiSDKConfig, b as PointTokenDomainConfig, M as MintRequest, R as ReceiverConsent, E as EIP712Signature, S as SignatureVerification } from './types-BAkmxgVo.js';
3
- export { B as BestQuote, c as BurnRequest, I as Issuer, d as PathKey, Q as QuoteResult } from './types-BAkmxgVo.js';
2
+ import { P as PoolKey, C as ChainConfig, a as PafiSDKConfig, b as PointTokenDomainConfig, M as MintRequest, R as ReceiverConsent, E as EIP712Signature, S as SignatureVerification } from './types-CCvAk-ma.js';
3
+ export { B as BestQuote, c as BlackoutWindow, d as BurnRequest, I as Issuer, e as PathKey, Q as QuoteResult, f as RedemptionDecision, g as RedemptionDenial, h as RedemptionDenialCode, i as RedemptionPolicy, j as RedemptionPolicySource, k as RedemptionPreview } from './types-CCvAk-ma.js';
4
4
  export { pointTokenAbi as POINT_TOKEN_V2_ABI, erc20Abi, issuerRegistryAbi, mintingOracleAbi, permit2Abi, pointTokenAbi, pointTokenFactoryAbi, universalRouterAbi, v4QuoterAbi } from './abi/index.js';
5
- export { buildBurnRequestTypedData, buildDomain, buildMintRequestTypedData, buildReceiverConsentTypedData, signBurnRequest, signMintRequest, signReceiverConsent, verifyBurnRequest, verifyMintRequest, verifyReceiverConsent } from './eip712/index.js';
5
+ export { Eip712DomainMismatchError, assertDomainMatchesContract, buildBurnRequestTypedData, buildDomain, buildMintRequestTypedData, buildReceiverConsentTypedData, signBurnRequest, signMintRequest, signReceiverConsent, verifyBurnRequest, verifyMintRequest, verifyReceiverConsent } from './eip712/index.js';
6
6
  export { getBurnRequestNonce, getIssuer, getMintRequestNonce, getPointTokenBalance, getPointTokenIssuer, getPointTokenIssuerAddress, getReceiverConsentNonce, getTokenName, isActiveIssuer, isMinter, issuerRegistryGetIssuerFlatAbi, verifyMintCap } from './contract/index.js';
7
7
  import { LoginMessageParams } from './auth/index.js';
8
- export { BuildSponsorAuthParams, BuiltSponsorAuth, SPONSOR_AUTH_DOMAIN_NAME, SPONSOR_AUTH_TYPES, SponsorAuthPayload, SponsorAuthVerifyResult, VerifyLoginResult, buildAndSignSponsorAuth, buildSponsorAuthDomain, buildSponsorAuthTypedData, computeCallDataHash, createLoginMessage, generateSponsorAuthNonce, parseLoginMessage, signSponsorAuth, verifyLoginMessage, verifySponsorAuth } from './auth/index.js';
8
+ export { BuildSponsorAuthParams, BuiltSponsorAuth, SPONSOR_AUTH_DOMAIN_ANCHOR_BASE_MAINNET, SPONSOR_AUTH_DOMAIN_NAME, SPONSOR_AUTH_TYPES, SponsorAuthPayload, SponsorAuthVerifyResult, VerifyLoginResult, buildAndSignSponsorAuth, buildSponsorAuthDomain, buildSponsorAuthTypedData, computeCallDataHash, createLoginMessage, generateSponsorAuthNonce, getSponsorAuthDomainAnchor, parseLoginMessage, signSponsorAuth, verifyLoginMessage, verifySponsorAuth } from './auth/index.js';
9
9
 
10
10
  declare const mintRequestTypes: {
11
11
  readonly MintRequest: readonly [{
@@ -83,15 +83,13 @@ declare const ENTRY_POINT_V08: Address;
83
83
  declare const PERMIT2_ADDRESS: Address;
84
84
 
85
85
  /**
86
- * v0.7.1 — unified error base for the entire SDK (core + issuer +
87
- * trading). Subclasses declare `code` (machine-readable) and
88
- * `httpStatus` (recommended HTTP status for issuer's controller).
86
+ * Unified error base for the entire SDK (core + issuer + trading).
87
+ * Subclasses declare `code` (machine-readable) and `httpStatus`
88
+ * (recommended HTTP status for issuer's controller).
89
89
  *
90
90
  * Issuer's `createSdkErrorMapper` routes any `PafiSdkError` instance
91
91
  * through framework-specific exception factories; non-PafiSdkError
92
92
  * still becomes 500.
93
- *
94
- * See SDK_CORE_TRADING_AUDIT.md H3.
95
93
  */
96
94
  type SdkErrorHttpStatus = "not_found" | "forbidden" | "unprocessable" | "service_unavailable";
97
95
  declare abstract class PafiSdkError extends Error {
@@ -106,11 +104,11 @@ declare abstract class PafiSdkError extends Error {
106
104
  constructor(message: string);
107
105
  }
108
106
  /**
109
- * @deprecated v0.7.1 — use `PafiSdkError` (capital S, lowercase dk).
107
+ * @deprecated Use `PafiSdkError` (capital S, lowercase dk).
110
108
  * The two classes existed in parallel ("PafiSDKError" in core,
111
109
  * "PafiSdkError" in issuer) due to historical drift; consolidating
112
110
  * here. Kept as alias for back-compat through v0.7.x; will be removed
113
- * in v0.8. See SDK_CORE_TRADING_AUDIT.md H3.
111
+ * in v0.8.
114
112
  */
115
113
  declare class PafiSDKError extends Error {
116
114
  constructor(message: string);
@@ -133,11 +131,8 @@ declare class ApiError extends PafiSDKError {
133
131
  /**
134
132
  * Thrown by `quoteOperatorFee*` when an upstream price source
135
133
  * (Chainlink ETH/USD, PAFI subgraph) is unavailable or stale and the
136
- * caller did not opt in to the hardcoded fallback prices.
137
- *
138
- * v0.7.1 — previously `quoteOperatorFeePt` silently fell back to
139
- * ETH=$3000 / PT=$0.10 with `console.warn`. Now opt-in via
140
- * `allowStaleFallback: true`. See SDK_CORE_TRADING_AUDIT.md C2.
134
+ * caller did not opt in to the hardcoded fallback prices via
135
+ * `allowStaleFallback: true`.
141
136
  *
142
137
  * Extends the unified `PafiSdkError` so issuer's `createSdkErrorMapper`
143
138
  * routes it to 503 instead of leaking as a 500.
@@ -156,8 +151,6 @@ declare class OracleStaleError extends PafiSdkError {
156
151
  *
157
152
  * Uses an instance `details` field so subclasses can override the
158
153
  * declaration; matches the issuer-side shape that pre-existed here.
159
- *
160
- * v0.7.4 — added per SDK_CORE_TRADING_AUDIT.md H2/H13.
161
154
  */
162
155
  declare class ValidationError extends PafiSdkError {
163
156
  readonly httpStatus: "unprocessable";
@@ -1173,8 +1166,8 @@ type SignAuthorizationFn = (args: {
1173
1166
  nonce: number;
1174
1167
  r: Hex | string;
1175
1168
  s: Hex | string;
1176
- v?: string | number;
1177
- yParity: 0 | 1 | string;
1169
+ v?: bigint | string | number;
1170
+ yParity: number | string;
1178
1171
  }>;
1179
1172
  /**
1180
1173
  * Authorization tuple in the shape `walletClient.sendTransaction`
@@ -1392,10 +1385,6 @@ interface SmartAccountSender {
1392
1385
  *
1393
1386
  * Use this to decide whether retrying without a paymaster makes sense.
1394
1387
  * Contract reverts (AA23, AA24, AA25) and bundler errors are NOT matched.
1395
- *
1396
- * v0.7.1 — replaced naive substring matching that false-positived on
1397
- * arbitrary text containing "503"/"403"/"429" (e.g. address/transit ID).
1398
- * See SDK_CORE_TRADING_AUDIT.md C3.
1399
1388
  */
1400
1389
  declare function isPaymasterError(err: unknown): boolean;
1401
1390
  interface SendWithPaymasterFallbackParams {
@@ -1459,8 +1448,7 @@ declare function sendWithPaymasterFallback(params: SendWithPaymasterFallbackPara
1459
1448
  * perp-deposit — `buildPerpDepositViaRelay` 800k (LayerZero msg)
1460
1449
  * delegate — minimal no-op self-call, 200k margin
1461
1450
  *
1462
- * Pass an explicit `gasUnits` to override. v0.7.4 — added per
1463
- * SDK_CORE_TRADING_AUDIT.md H12.
1451
+ * Pass an explicit `gasUnits` to override.
1464
1452
  */
1465
1453
  type FeeScenario = "mint" | "burn" | "swap" | "perp-deposit" | "delegate";
1466
1454
  interface QuoteOperatorFeePtConfig {
@@ -1497,17 +1485,38 @@ interface QuoteOperatorFeePtConfig {
1497
1485
  * `true` AND configure `fallbackEthPriceUsd` / `fallbackPtPriceUsdt`
1498
1486
  * to absorb oracle outages instead of surfacing them.
1499
1487
  *
1500
- * v0.7.1 previously fallback was always-on with hardcoded
1501
- * defaults (ETH=$3000, PT=$0.10), causing under-priced fees during
1502
- * incidents. See SDK_CORE_TRADING_AUDIT.md C2.
1488
+ * When fallback fires, callers SHOULD observe via `onFallback` so
1489
+ * production can flag the under-priced quote (e.g. show "fee priced
1490
+ * against stale oracle" banner in FE; alert on-call).
1503
1491
  */
1504
1492
  allowStaleFallback?: boolean;
1505
1493
  /** Fallback ETH price (USD) when Chainlink is unreachable. Only used when `allowStaleFallback: true`. Default 3000. */
1506
1494
  fallbackEthPriceUsd?: number;
1507
1495
  /** Fallback PT price (USDT per 1 PT) when subgraph is unreachable. Only used when `allowStaleFallback: true`. Default 0.1. */
1508
1496
  fallbackPtPriceUsdt?: number;
1497
+ /**
1498
+ * Observability hook fired when the quoter falls back to stale
1499
+ * prices. Callers SHOULD wire this to their alert pipeline (Sentry,
1500
+ * Datadog, PagerDuty) so under-priced quotes don't go unnoticed.
1501
+ * When omitted, falls back to `console.warn` (kept for back-compat
1502
+ * but invisible in most prod log shippers).
1503
+ */
1504
+ onFallback?: (info: FallbackInfo) => void;
1509
1505
  fetchImpl?: typeof fetch;
1510
1506
  }
1507
+ /**
1508
+ * Detail surfaced via `onFallback` when the quoter substitutes a
1509
+ * stale-fallback price. Callers can format this into a UI banner or
1510
+ * log line.
1511
+ */
1512
+ interface FallbackInfo {
1513
+ /** Which oracle failed. */
1514
+ source: "chainlink" | "subgraph";
1515
+ /** Underlying reason from the oracle call (e.g. RPC error message). */
1516
+ reason: string;
1517
+ /** The fallback value that was used (in source-native units). */
1518
+ fallbackValue: number;
1519
+ }
1511
1520
  /**
1512
1521
  * Subset of `QuoteOperatorFeePtConfig` that doesn't need the V4 pool
1513
1522
  * step — used by `quoteOperatorFeeUsdt` (FE cashout-preview / `/gas-fee`
@@ -1525,10 +1534,12 @@ interface QuoteOperatorFeeUsdtConfig {
1525
1534
  usdtDecimals?: number;
1526
1535
  /**
1527
1536
  * Opt-in fallback price when Chainlink is unavailable. Default
1528
- * `false` — throw `OracleStaleError`. v0.7.1 — see C2.
1537
+ * `false` — throw `OracleStaleError`.
1529
1538
  */
1530
1539
  allowStaleFallback?: boolean;
1531
1540
  fallbackEthPriceUsd?: number;
1541
+ /** See QuoteOperatorFeePtConfig.onFallback. */
1542
+ onFallback?: (info: FallbackInfo) => void;
1532
1543
  }
1533
1544
  /**
1534
1545
  * Operator fee quoted in USDT raw units (default 6 decimals). Returns
@@ -1634,6 +1645,42 @@ declare const POINT_TOKEN_IMPL_ADDRESSES: Record<number, Address>;
1634
1645
  */
1635
1646
  declare function getContractAddresses(chainId: number): ContractAddresses;
1636
1647
 
1648
+ /**
1649
+ * PAFI HTTP service URLs by chainId. Mirrors the `getContractAddresses`
1650
+ * pattern: SDK ships with the URL for each supported chain so issuers
1651
+ * don't pass URLs as env vars / constructor args.
1652
+ *
1653
+ * When PAFI changes URLs (rebrand, re-host, environment migration),
1654
+ * bump the SDK version and re-publish. Issuers pin a version, get the
1655
+ * URLs that match.
1656
+ *
1657
+ * No env override is provided on purpose — different environments use
1658
+ * different SDK versions (e.g. an `@pafi-dev/issuer-dev` channel for
1659
+ * staging). This keeps issuer integration to chainId + creds only.
1660
+ */
1661
+ interface PafiServiceUrls {
1662
+ /**
1663
+ * sponsor-relayer base URL (paymaster proxy). PafiBackendClient
1664
+ * appends `/paymaster/sponsor`, `/bundler/receipt`, etc.
1665
+ */
1666
+ sponsorRelayer: string;
1667
+ /**
1668
+ * issuer-api base URL. SettlementClient appends
1669
+ * `/issuers/:issuerId/redemption-policy`.
1670
+ */
1671
+ issuerApi: string;
1672
+ }
1673
+ /**
1674
+ * Per-chain URL map. URLs follow the pattern
1675
+ * `https://<host>/api/<service>` so Kong gateway can route by path.
1676
+ *
1677
+ * NOTE: placeholder URLs — Phi will swap in real prod/staging hosts
1678
+ * once the deploy targets are finalized. SDK version bump captures
1679
+ * the change.
1680
+ */
1681
+ declare const PAFI_SERVICE_URLS: Record<number, PafiServiceUrls>;
1682
+ declare function getPafiServiceUrls(chainId: number): PafiServiceUrls;
1683
+
1637
1684
  /**
1638
1685
  * Public contract surface for `@pafi-dev/core/contracts`.
1639
1686
  *
@@ -1971,4 +2018,4 @@ declare class PafiSDK {
1971
2018
  signLoginMessage(message: string): Promise<Hex>;
1972
2019
  }
1973
2020
 
1974
- export { ApiError, BATCH_EXECUTOR_7702_IMPL, BATCH_EXECUTOR_ABI, BATCH_EXECUTOR_ADDRESS_BASE_MAINNET, BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA, BROKER_HASHES, type BuildDelegationUserOpParams, type BuildPartialUserOpParams, type BuildPerpDepositViaRelayParams, type BuildPerpDepositWithGasDeductionParams, COMMON_POOLS, COMMON_TOKENS, CONTRACT_ADDRESSES, ChainConfig, type CheckEthAndBranchParams, ConfigurationError, type ContractAddresses, DUMMY_SIGNATURE_V07, type DelegateDirectParams, type DelegateDirectResult, type DelegateImpl, EIP712Signature, ENTRY_POINT_V07, ENTRY_POINT_V08, type Eip7702AuthorizationJsonRpc, LoginMessageParams, MintRequest, type ModalOpenOptions, ORDERLY_RELAY_ABI, ORDERLY_VAULT_ABI, ORDERLY_VAULT_ADDRESSES, ORDERLY_VAULT_BASE_MAINNET, type Operation, OracleStaleError, type OrderlyRelayDepositRequest, PAFI_SUBGRAPH_URL, PERMIT2_ADDRESS, POINT_TOKEN_FACTORY_ADDRESSES, POINT_TOKEN_IMPL_ADDRESSES, POINT_TOKEN_POOLS, type PackedUserOperationMessage, type PafiProxyTransportParams, PafiSDK, PafiSDKConfig, PafiSDKError, PafiSdkError, type PafiWebModalAdapter, type PafiWebModalHandle, type PartialUserOperation, type PaymasterConfig, type PaymasterFields, PointTokenDomainConfig, PoolKey, type QuoteOperatorFeePtConfig, type QuoteOperatorFeeUsdtConfig, ReceiverConsent, SIMPLE_7702_IMPL_BASE_MAINNET, SUPPORTED_CHAINS, type SdkErrorHttpStatus, type SendWithPaymasterFallbackParams, type SignAuthorizationFn, type SignatureStruct, SignatureVerification, type SignedAuthorization, SigningError, SimulationError, type SmartAccountSender, type SponsorshipScenario, type SubmissionPath, TOKEN_HASHES, UNIVERSAL_ROUTER_ADDRESSES, type UserOpReceipt, type UserOpTypedData, type UserOperation, V4_QUOTER_ADDRESSES, ValidationError, type VaultDepositFE, ZERO_VALUE, _resetPaymasterConfigForTests, assembleUserOperation, buildDelegationUserOp, buildEip7702Authorization, buildPartialUserOperation, buildPerpDepositViaRelay, buildPerpDepositWithGasDeduction, buildUserOpTypedData, burnRequestTypes, checkDelegation, checkEthAndBranch, computeAccountId, computeAuthorizationHash, computeUserOpHash, createPafiProxyTransport, decodeBatchExecuteCalls, delegateDirect, detectDelegateImpl, encodeBatchExecute, erc20ApproveOp, erc20BurnOp, erc20TransferOp, fetchPafiPools, getAaNonce, getContractAddresses, getDummySignatureFor7702, getPafiWebModalAdapter, getPaymasterConfig, isDelegatedTo, isDelegatedToTarget, isPaymasterConfigured, isPaymasterError, mintRequestTypes, openPafiWebModal, openWebPopup, parseEip7702DelegatedAddress, quoteOperatorFeePt, quoteOperatorFeeUsdt, rawCallOp, receiverConsentTypes, sendWithPaymasterFallback, serializeUserOpToJsonRpc, setPafiWebModalAdapter, setPaymasterConfig, splitAuthorizationSig, webPopupAdapter };
2021
+ export { ApiError, BATCH_EXECUTOR_7702_IMPL, BATCH_EXECUTOR_ABI, BATCH_EXECUTOR_ADDRESS_BASE_MAINNET, BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA, BROKER_HASHES, type BuildDelegationUserOpParams, type BuildPartialUserOpParams, type BuildPerpDepositViaRelayParams, type BuildPerpDepositWithGasDeductionParams, COMMON_POOLS, COMMON_TOKENS, CONTRACT_ADDRESSES, ChainConfig, type CheckEthAndBranchParams, ConfigurationError, type ContractAddresses, DUMMY_SIGNATURE_V07, type DelegateDirectParams, type DelegateDirectResult, type DelegateImpl, EIP712Signature, ENTRY_POINT_V07, ENTRY_POINT_V08, type Eip7702AuthorizationJsonRpc, LoginMessageParams, MintRequest, type ModalOpenOptions, ORDERLY_RELAY_ABI, ORDERLY_VAULT_ABI, ORDERLY_VAULT_ADDRESSES, ORDERLY_VAULT_BASE_MAINNET, type Operation, OracleStaleError, type OrderlyRelayDepositRequest, PAFI_SERVICE_URLS, PAFI_SUBGRAPH_URL, PERMIT2_ADDRESS, POINT_TOKEN_FACTORY_ADDRESSES, POINT_TOKEN_IMPL_ADDRESSES, POINT_TOKEN_POOLS, type PackedUserOperationMessage, type PafiProxyTransportParams, PafiSDK, PafiSDKConfig, PafiSDKError, PafiSdkError, type PafiServiceUrls, type PafiWebModalAdapter, type PafiWebModalHandle, type PartialUserOperation, type PaymasterConfig, type PaymasterFields, PointTokenDomainConfig, PoolKey, type QuoteOperatorFeePtConfig, type QuoteOperatorFeeUsdtConfig, ReceiverConsent, SIMPLE_7702_IMPL_BASE_MAINNET, SUPPORTED_CHAINS, type SdkErrorHttpStatus, type SendWithPaymasterFallbackParams, type SignAuthorizationFn, type SignatureStruct, SignatureVerification, type SignedAuthorization, SigningError, SimulationError, type SmartAccountSender, type SponsorshipScenario, type SubmissionPath, TOKEN_HASHES, UNIVERSAL_ROUTER_ADDRESSES, type UserOpReceipt, type UserOpTypedData, type UserOperation, V4_QUOTER_ADDRESSES, ValidationError, type VaultDepositFE, ZERO_VALUE, _resetPaymasterConfigForTests, assembleUserOperation, buildDelegationUserOp, buildEip7702Authorization, buildPartialUserOperation, buildPerpDepositViaRelay, buildPerpDepositWithGasDeduction, buildUserOpTypedData, burnRequestTypes, checkDelegation, checkEthAndBranch, computeAccountId, computeAuthorizationHash, computeUserOpHash, createPafiProxyTransport, decodeBatchExecuteCalls, delegateDirect, detectDelegateImpl, encodeBatchExecute, erc20ApproveOp, erc20BurnOp, erc20TransferOp, fetchPafiPools, getAaNonce, getContractAddresses, getDummySignatureFor7702, getPafiServiceUrls, getPafiWebModalAdapter, getPaymasterConfig, isDelegatedTo, isDelegatedToTarget, isPaymasterConfigured, isPaymasterError, mintRequestTypes, openPafiWebModal, openWebPopup, parseEip7702DelegatedAddress, quoteOperatorFeePt, quoteOperatorFeeUsdt, rawCallOp, receiverConsentTypes, sendWithPaymasterFallback, serializeUserOpToJsonRpc, setPafiWebModalAdapter, setPaymasterConfig, splitAuthorizationSig, webPopupAdapter };