@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.js CHANGED
@@ -6,6 +6,7 @@ import {
6
6
  v4QuoterAbi
7
7
  } from "./chunk-6CXTFOIH.js";
8
8
  import {
9
+ SPONSOR_AUTH_DOMAIN_ANCHOR_BASE_MAINNET,
9
10
  SPONSOR_AUTH_DOMAIN_NAME,
10
11
  SPONSOR_AUTH_TYPES,
11
12
  buildAndSignSponsorAuth,
@@ -14,11 +15,12 @@ import {
14
15
  computeCallDataHash,
15
16
  createLoginMessage,
16
17
  generateSponsorAuthNonce,
18
+ getSponsorAuthDomainAnchor,
17
19
  parseLoginMessage,
18
20
  signSponsorAuth,
19
21
  verifyLoginMessage,
20
22
  verifySponsorAuth
21
- } from "./chunk-6UX2IFA2.js";
23
+ } from "./chunk-4EGXLYMM.js";
22
24
  import {
23
25
  getBurnRequestNonce,
24
26
  getIssuer,
@@ -32,22 +34,23 @@ import {
32
34
  isMinter,
33
35
  issuerRegistryGetIssuerFlatAbi,
34
36
  verifyMintCap
35
- } from "./chunk-YDLMVWDH.js";
37
+ } from "./chunk-AEYEFV5G.js";
36
38
  import {
37
39
  issuerRegistryAbi,
38
- mintingOracleAbi,
39
- pointTokenAbi
40
- } from "./chunk-5JZOJIBT.js";
40
+ mintingOracleAbi
41
+ } from "./chunk-B2NDSIAI.js";
41
42
  import {
42
43
  COMMON_POOLS,
43
44
  COMMON_TOKENS,
44
45
  ENTRY_POINT_V07,
45
46
  ENTRY_POINT_V08,
47
+ Eip712DomainMismatchError,
46
48
  PERMIT2_ADDRESS,
47
49
  POINT_TOKEN_POOLS,
48
50
  SUPPORTED_CHAINS,
49
51
  UNIVERSAL_ROUTER_ADDRESSES,
50
52
  V4_QUOTER_ADDRESSES,
53
+ assertDomainMatchesContract,
51
54
  buildBurnRequestTypedData,
52
55
  buildDomain,
53
56
  buildMintRequestTypedData,
@@ -61,7 +64,10 @@ import {
61
64
  verifyBurnRequest,
62
65
  verifyMintRequest,
63
66
  verifyReceiverConsent
64
- } from "./chunk-WJSIB5GF.js";
67
+ } from "./chunk-QL5COJQI.js";
68
+ import {
69
+ pointTokenAbi
70
+ } from "./chunk-SZMSKZHY.js";
65
71
  import "./chunk-DGUM43GV.js";
66
72
 
67
73
  // src/index.ts
@@ -582,7 +588,16 @@ function getDummySignatureFor7702(impl) {
582
588
 
583
589
  // src/paymaster/config.ts
584
590
  var _config = null;
591
+ var _deprecationWarned = false;
592
+ function warnDeprecated(fn) {
593
+ if (_deprecationWarned) return;
594
+ _deprecationWarned = true;
595
+ console.warn(
596
+ `[PAFI] DEPRECATION (v0.7.1+): \`${fn}\` from @pafi-dev/core/paymaster is deprecated and will be removed in v0.8. Use \`PafiBackendClient\` from @pafi-dev/issuer/pafi-backend instead.`
597
+ );
598
+ }
585
599
  function setPaymasterConfig(config) {
600
+ warnDeprecated("setPaymasterConfig");
586
601
  if (!config.pafiBackendUrl) {
587
602
  throw new Error("setPaymasterConfig: pafiBackendUrl is required");
588
603
  }
@@ -598,6 +613,7 @@ function setPaymasterConfig(config) {
598
613
  _config = { ...config };
599
614
  }
600
615
  function getPaymasterConfig() {
616
+ warnDeprecated("getPaymasterConfig");
601
617
  if (!_config) {
602
618
  throw new Error(
603
619
  "PaymasterConfig not initialized \u2014 call setPaymasterConfig() at application boot before invoking any batch builder"
@@ -838,7 +854,8 @@ async function delegateDirect(params) {
838
854
  nonce
839
855
  });
840
856
  const yParityRaw = raw.yParity;
841
- const yParity = typeof yParityRaw === "number" ? yParityRaw : String(yParityRaw) === "1" || String(yParityRaw) === "0x1" ? 1 : 0;
857
+ const yParityNum = typeof yParityRaw === "number" ? yParityRaw : String(yParityRaw) === "1" || String(yParityRaw) === "0x1" ? 1 : 0;
858
+ const yParity = yParityNum === 1 ? 1 : 0;
842
859
  const authorization = {
843
860
  contractAddress: target,
844
861
  chainId: params.chainId,
@@ -1057,7 +1074,8 @@ async function quoteOperatorFeeUsdt(config) {
1057
1074
  const ethPrice8dec = await getEthPrice8dec(
1058
1075
  provider,
1059
1076
  chainlinkFeedAddress,
1060
- allowStaleFallback ? fallbackEthPriceUsd : null
1077
+ allowStaleFallback ? fallbackEthPriceUsd : null,
1078
+ config.onFallback
1061
1079
  );
1062
1080
  const denomExp = 18 + 8 - usdtDecimals;
1063
1081
  return withPremium * ethPrice8dec / 10n ** BigInt(denomExp);
@@ -1085,18 +1103,20 @@ async function quoteOperatorFeePt(config) {
1085
1103
  getEthPrice8dec(
1086
1104
  provider,
1087
1105
  chainlinkFeedAddress,
1088
- allowStaleFallback ? fallbackEthPriceUsd : null
1106
+ allowStaleFallback ? fallbackEthPriceUsd : null,
1107
+ config.onFallback
1089
1108
  ),
1090
1109
  getPtPerUsdt18dec(
1091
1110
  fetchImpl,
1092
1111
  subgraphUrl,
1093
1112
  pointTokenAddress,
1094
- allowStaleFallback ? fallbackPtPriceUsdt : null
1113
+ allowStaleFallback ? fallbackPtPriceUsdt : null,
1114
+ config.onFallback
1095
1115
  )
1096
1116
  ]);
1097
1117
  return withPremium * ethPrice8dec * ptPerUsdt18dec / 10n ** 26n;
1098
1118
  }
1099
- async function getEthPrice8dec(provider, feed, fallback) {
1119
+ async function getEthPrice8dec(provider, feed, fallback, onFallback) {
1100
1120
  try {
1101
1121
  const result = await provider.readContract({
1102
1122
  address: feed,
@@ -1116,14 +1136,18 @@ async function getEthPrice8dec(provider, feed, fallback) {
1116
1136
  if (fallback === null) {
1117
1137
  throw new OracleStaleError("chainlink", reason);
1118
1138
  }
1119
- console.warn(
1120
- "[quoteOperatorFee] Chainlink unavailable, using opt-in fallback:",
1121
- reason
1122
- );
1139
+ if (onFallback) {
1140
+ onFallback({ source: "chainlink", reason, fallbackValue: fallback });
1141
+ } else {
1142
+ console.warn(
1143
+ "[quoteOperatorFee] Chainlink unavailable, using opt-in fallback:",
1144
+ reason
1145
+ );
1146
+ }
1123
1147
  return BigInt(Math.round(fallback * 1e8));
1124
1148
  }
1125
1149
  }
1126
- async function getPtPerUsdt18dec(fetchImpl, subgraphUrl, pointTokenAddress, fallbackPtPriceUsdt) {
1150
+ async function getPtPerUsdt18dec(fetchImpl, subgraphUrl, pointTokenAddress, fallbackPtPriceUsdt, onFallback) {
1127
1151
  try {
1128
1152
  const response = await fetchImpl(subgraphUrl, {
1129
1153
  method: "POST",
@@ -1155,10 +1179,18 @@ async function getPtPerUsdt18dec(fetchImpl, subgraphUrl, pointTokenAddress, fall
1155
1179
  if (fallbackPtPriceUsdt === null) {
1156
1180
  throw new OracleStaleError("subgraph", reason);
1157
1181
  }
1158
- console.warn(
1159
- "[quoteOperatorFeePt] subgraph unavailable, using opt-in fallback:",
1160
- reason
1161
- );
1182
+ if (onFallback) {
1183
+ onFallback({
1184
+ source: "subgraph",
1185
+ reason,
1186
+ fallbackValue: fallbackPtPriceUsdt
1187
+ });
1188
+ } else {
1189
+ console.warn(
1190
+ "[quoteOperatorFeePt] subgraph unavailable, using opt-in fallback:",
1191
+ reason
1192
+ );
1193
+ }
1162
1194
  const ptPerUsdtHuman = 1 / fallbackPtPriceUsdt;
1163
1195
  return parseBigDecimalTo18(ptPerUsdtHuman.toFixed(18));
1164
1196
  }
@@ -1174,6 +1206,29 @@ function parseBigDecimalTo18(s) {
1174
1206
  var BATCH_EXECUTOR_ADDRESS_BASE_MAINNET = getContractAddresses(8453).batchExecutor;
1175
1207
  var BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA = getContractAddresses(84532).batchExecutor;
1176
1208
 
1209
+ // src/contracts/real/pafi-services.ts
1210
+ var PAFI_SERVICE_URLS = {
1211
+ // Base mainnet
1212
+ 8453: {
1213
+ sponsorRelayer: "https://api-dev.pacificfinance.org/api/sponsor",
1214
+ issuerApi: "https://api-dev.pacificfinance.org/api/issuer"
1215
+ },
1216
+ // Base sepolia
1217
+ 84532: {
1218
+ sponsorRelayer: "https://api-dev.pacificfinance.org/api/sponsor",
1219
+ issuerApi: "https://api-dev.pacificfinance.org/api/issuer"
1220
+ }
1221
+ };
1222
+ function getPafiServiceUrls(chainId) {
1223
+ const urls = PAFI_SERVICE_URLS[chainId];
1224
+ if (!urls) {
1225
+ throw new Error(
1226
+ `getPafiServiceUrls: no PAFI service URLs for chainId ${chainId}. Supported: ${Object.keys(PAFI_SERVICE_URLS).join(", ")}`
1227
+ );
1228
+ }
1229
+ return urls;
1230
+ }
1231
+
1177
1232
  // src/web-handoff/webPopup.ts
1178
1233
  var DEFAULT_WIDTH = 900;
1179
1234
  var DEFAULT_HEIGHT = 700;
@@ -1230,10 +1285,15 @@ function openWebPopup(url, options = {}) {
1230
1285
  }, 500);
1231
1286
  if (options.onMessage) {
1232
1287
  const allowed = options.allowedOrigins ?? [];
1288
+ if (allowed.length === 0) {
1289
+ throw new Error(
1290
+ "openPafiWebModal: `allowedOrigins` is empty/missing while `onMessage` is supplied. The popup-message listener would silently reject every message \u2014 caller must explicitly whitelist PAFI Web's host (e.g. `['https://app.pacificfinance.org']`) before any payload reaches the callback. To accept any origin (insecure), pass an explicit list containing '*' or omit `onMessage` entirely."
1291
+ );
1292
+ }
1233
1293
  const onMessage = options.onMessage;
1234
1294
  messageListener = (event) => {
1235
1295
  if (event.source !== popup) return;
1236
- if (!allowed.includes(event.origin)) return;
1296
+ if (!allowed.includes("*") && !allowed.includes(event.origin)) return;
1237
1297
  onMessage(event.data, event.origin);
1238
1298
  };
1239
1299
  window.addEventListener("message", messageListener);
@@ -1466,11 +1526,13 @@ export {
1466
1526
  DUMMY_SIGNATURE_V07,
1467
1527
  ENTRY_POINT_V07,
1468
1528
  ENTRY_POINT_V08,
1529
+ Eip712DomainMismatchError,
1469
1530
  ORDERLY_RELAY_ABI,
1470
1531
  ORDERLY_VAULT_ABI,
1471
1532
  ORDERLY_VAULT_ADDRESSES,
1472
1533
  ORDERLY_VAULT_BASE_MAINNET,
1473
1534
  OracleStaleError,
1535
+ PAFI_SERVICE_URLS,
1474
1536
  PAFI_SUBGRAPH_URL,
1475
1537
  PERMIT2_ADDRESS,
1476
1538
  POINT_TOKEN_FACTORY_ADDRESSES,
@@ -1481,6 +1543,7 @@ export {
1481
1543
  PafiSDKError,
1482
1544
  PafiSdkError,
1483
1545
  SIMPLE_7702_IMPL_BASE_MAINNET,
1546
+ SPONSOR_AUTH_DOMAIN_ANCHOR_BASE_MAINNET,
1484
1547
  SPONSOR_AUTH_DOMAIN_NAME,
1485
1548
  SPONSOR_AUTH_TYPES,
1486
1549
  SUPPORTED_CHAINS,
@@ -1493,6 +1556,7 @@ export {
1493
1556
  ZERO_VALUE,
1494
1557
  _resetPaymasterConfigForTests,
1495
1558
  assembleUserOperation,
1559
+ assertDomainMatchesContract,
1496
1560
  buildAndSignSponsorAuth,
1497
1561
  buildBurnRequestTypedData,
1498
1562
  buildDelegationUserOp,
@@ -1531,12 +1595,14 @@ export {
1531
1595
  getDummySignatureFor7702,
1532
1596
  getIssuer2 as getIssuer,
1533
1597
  getMintRequestNonce,
1598
+ getPafiServiceUrls,
1534
1599
  getPafiWebModalAdapter,
1535
1600
  getPaymasterConfig,
1536
1601
  getPointTokenBalance,
1537
1602
  getPointTokenIssuer,
1538
1603
  getIssuer as getPointTokenIssuerAddress,
1539
1604
  getReceiverConsentNonce,
1605
+ getSponsorAuthDomainAnchor,
1540
1606
  getTokenName,
1541
1607
  isActiveIssuer,
1542
1608
  isDelegatedTo,