@zkp2p/sdk 0.5.2 → 0.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/{chunk-LPJE2MN7.mjs → chunk-TGMRXUP2.mjs} +28 -3
- package/dist/chunk-TGMRXUP2.mjs.map +1 -0
- package/dist/{chunk-L526MKG3.mjs → chunk-VJ33XYCV.mjs} +123 -128
- package/dist/{chunk-L526MKG3.mjs.map → chunk-VJ33XYCV.mjs.map} +1 -1
- package/dist/index.cjs +340 -273
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +42 -11
- package/dist/index.d.ts +42 -11
- package/dist/index.mjs +143 -87
- package/dist/index.mjs.map +1 -1
- package/dist/protocolViewerParsers-XN63B2S5.mjs +5 -0
- package/dist/{protocolViewerParsers-GGSM2243.mjs.map → protocolViewerParsers-XN63B2S5.mjs.map} +1 -1
- package/dist/react.cjs +31 -16
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.mts +2 -2
- package/dist/react.d.ts +2 -2
- package/dist/react.mjs +6 -18
- package/dist/react.mjs.map +1 -1
- package/dist/{vaultUtils-CtNcKlpg.d.mts → vaultUtils-DOOl9QUP.d.mts} +15 -17
- package/dist/{vaultUtils-CtNcKlpg.d.ts → vaultUtils-DOOl9QUP.d.ts} +15 -17
- package/package.json +3 -3
- package/dist/chunk-LPJE2MN7.mjs.map +0 -1
- package/dist/protocolViewerParsers-GGSM2243.mjs +0 -5
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { ZERO_RATE_MANAGER_ID, classifyDelegationState, getDelegationRoute, isZeroRateManagerId, normalizeRateManagerId, normalizeRegistry } from './chunk-
|
|
1
|
+
export { TAKER_TIER_CAPS, TAKER_TIER_ORDER, TAKER_TIER_SCHEDULE, ZERO_RATE_MANAGER_ID, classifyDelegationState, getDelegationRoute, getNextTakerTier, isZeroRateManagerId, normalizeRateManagerId, normalizeRegistry } from './chunk-TGMRXUP2.mjs';
|
|
2
2
|
import { APIError, NetworkError, ValidationError } from './chunk-GHQK65J2.mjs';
|
|
3
3
|
export { APIError, ContractError, ErrorCode, NetworkError, ValidationError, ZKP2PError } from './chunk-GHQK65J2.mjs';
|
|
4
|
-
import { getContracts, getRateManagerContracts, getPaymentMethodsCatalog, resolvePaymentMethodHashFromCatalog, getGatingServiceAddress, parseBigIntLike, resolveFiatCurrencyBytes32, resolvePaymentMethodNameFromHash } from './chunk-
|
|
5
|
-
export { asciiToBytes32, enrichPvDepositView, enrichPvIntentView, ensureBytes32, getContracts, getGatingServiceAddress, getPaymentMethodsCatalog, getRateManagerContracts, parseDepositView, parseIntentView, resolveFiatCurrencyBytes32, resolvePaymentMethodHash, resolvePaymentMethodHashFromCatalog, resolvePaymentMethodNameFromHash } from './chunk-
|
|
4
|
+
import { getContracts, getRateManagerContracts, getPaymentMethodsCatalog, resolvePaymentMethodHashFromCatalog, getGatingServiceAddress, parseBigIntLike, resolveFiatCurrencyBytes32, resolvePaymentMethodNameFromHash } from './chunk-VJ33XYCV.mjs';
|
|
5
|
+
export { asciiToBytes32, enrichPvDepositView, enrichPvIntentView, ensureBytes32, getContracts, getGatingServiceAddress, getPaymentMethodsCatalog, getRateManagerContracts, parseDepositView, parseIntentView, resolveFiatCurrencyBytes32, resolvePaymentMethodHash, resolvePaymentMethodHashFromCatalog, resolvePaymentMethodNameFromHash } from './chunk-VJ33XYCV.mjs';
|
|
6
6
|
import { Currency, currencyKeccak256 } from './chunk-ZFBH4HD7.mjs';
|
|
7
7
|
export { Currency, currencyInfo, getCurrencyCodeFromHash, getCurrencyInfoFromCountryCode, getCurrencyInfoFromHash, isSupportedCurrencyHash, mapConversionRatesToOnchainMinRate } from './chunk-ZFBH4HD7.mjs';
|
|
8
8
|
import './chunk-J5LGTIGS.mjs';
|
|
@@ -365,13 +365,6 @@ async function withRetry(fn, maxRetries = 3, delayMs = 1e3, timeoutMs) {
|
|
|
365
365
|
}
|
|
366
366
|
|
|
367
367
|
// src/adapters/verification.ts
|
|
368
|
-
function createHeaders(apiKey, authorizationToken) {
|
|
369
|
-
const headers2 = { "Content-Type": "application/json" };
|
|
370
|
-
if (apiKey) headers2["x-api-key"] = apiKey;
|
|
371
|
-
if (authorizationToken)
|
|
372
|
-
headers2["Authorization"] = authorizationToken.startsWith("Bearer ") ? authorizationToken : `Bearer ${authorizationToken}`;
|
|
373
|
-
return headers2;
|
|
374
|
-
}
|
|
375
368
|
async function apiSignIntentV3(request, opts) {
|
|
376
369
|
const url = `${opts.baseApiUrl.replace(/\/$/, "")}/v3/intent/sign`;
|
|
377
370
|
const json = await withRetry(
|
|
@@ -380,7 +373,7 @@ async function apiSignIntentV3(request, opts) {
|
|
|
380
373
|
try {
|
|
381
374
|
res = await fetch(url, {
|
|
382
375
|
method: "POST",
|
|
383
|
-
headers:
|
|
376
|
+
headers: { "Content-Type": "application/json" },
|
|
384
377
|
body: JSON.stringify(request)
|
|
385
378
|
});
|
|
386
379
|
} catch (error) {
|
|
@@ -723,7 +716,7 @@ var PAYMENT_PLATFORMS = [
|
|
|
723
716
|
// src/utils/constants.ts
|
|
724
717
|
var DEFAULT_BASE_API_URL = "https://api.zkp2p.xyz";
|
|
725
718
|
|
|
726
|
-
// ../../node_modules/.pnpm/@zkp2p+contracts-v2@0.2.
|
|
719
|
+
// ../../node_modules/.pnpm/@zkp2p+contracts-v2@0.2.4_ethers@6.16.0_bufferutil@4.1.0_utf-8-validate@5.0.10__typescript@5.9.3_zod@4.2.1/node_modules/@zkp2p/contracts-v2/oracleFeeds/chainlink.json
|
|
727
720
|
var chainlink_default = {
|
|
728
721
|
feeds: [
|
|
729
722
|
{
|
|
@@ -1013,6 +1006,11 @@ var PLATFORM_ATTESTATION_CONFIG = {
|
|
|
1013
1006
|
};
|
|
1014
1007
|
function resolvePlatformAttestationConfig(platformName) {
|
|
1015
1008
|
const normalized = platformName.toLowerCase();
|
|
1009
|
+
if (normalized === "zelle") {
|
|
1010
|
+
throw new Error(
|
|
1011
|
+
"Generic Zelle buyer TEE fulfillment requires a bank-specific actionType override."
|
|
1012
|
+
);
|
|
1013
|
+
}
|
|
1016
1014
|
const config = PLATFORM_ATTESTATION_CONFIG[normalized];
|
|
1017
1015
|
if (!config) {
|
|
1018
1016
|
throw new Error(`Unknown payment platform: ${platformName}`);
|
|
@@ -1021,6 +1019,38 @@ function resolvePlatformAttestationConfig(platformName) {
|
|
|
1021
1019
|
}
|
|
1022
1020
|
|
|
1023
1021
|
// src/client/IntentOperations.ts
|
|
1022
|
+
var INTENT_MIN_AT_SIGNAL_ABI = [
|
|
1023
|
+
{
|
|
1024
|
+
type: "function",
|
|
1025
|
+
name: "getIntentMinAtSignal",
|
|
1026
|
+
stateMutability: "view",
|
|
1027
|
+
inputs: [{ name: "_intentHash", type: "bytes32" }],
|
|
1028
|
+
outputs: [{ name: "", type: "uint256" }]
|
|
1029
|
+
}
|
|
1030
|
+
];
|
|
1031
|
+
var GENERIC_ZELLE_ATTESTATION_ACTION_TYPES = /* @__PURE__ */ new Set([
|
|
1032
|
+
"transfer_zelle_bofa",
|
|
1033
|
+
"transfer_zelle_chase",
|
|
1034
|
+
"transfer_zelle_citi"
|
|
1035
|
+
]);
|
|
1036
|
+
function resolveBuyerTeeAttestationRoute(platformName, buyerTeeProof) {
|
|
1037
|
+
if (platformName.toLowerCase() !== "zelle") {
|
|
1038
|
+
const platformConfig = resolvePlatformAttestationConfig(platformName);
|
|
1039
|
+
return {
|
|
1040
|
+
actionPlatform: buyerTeeProof.actionPlatform ?? platformConfig.actionPlatform,
|
|
1041
|
+
actionType: buyerTeeProof.actionType ?? platformConfig.actionType
|
|
1042
|
+
};
|
|
1043
|
+
}
|
|
1044
|
+
if (buyerTeeProof.actionPlatform !== "zelle" || !buyerTeeProof.actionType || !GENERIC_ZELLE_ATTESTATION_ACTION_TYPES.has(buyerTeeProof.actionType)) {
|
|
1045
|
+
throw new Error(
|
|
1046
|
+
'Generic Zelle buyer TEE fulfillment requires actionPlatform "zelle" and a bank-specific transfer_zelle_* actionType.'
|
|
1047
|
+
);
|
|
1048
|
+
}
|
|
1049
|
+
return {
|
|
1050
|
+
actionPlatform: buyerTeeProof.actionPlatform,
|
|
1051
|
+
actionType: buyerTeeProof.actionType
|
|
1052
|
+
};
|
|
1053
|
+
}
|
|
1024
1054
|
var IntentOperations = class {
|
|
1025
1055
|
constructor(config) {
|
|
1026
1056
|
this.config = config;
|
|
@@ -1065,13 +1095,9 @@ var IntentOperations = class {
|
|
|
1065
1095
|
let { gatingServiceSignature, signatureExpiration } = params;
|
|
1066
1096
|
let preIntentHookData = params.preIntentHookData;
|
|
1067
1097
|
const baseApiUrl = this.config.getBaseApiUrl();
|
|
1068
|
-
|
|
1069
|
-
const authorizationToken = this.config.getAuthorizationToken();
|
|
1070
|
-
if ((!gatingServiceSignature || !signatureExpiration) && baseApiUrl && (apiKey || authorizationToken)) {
|
|
1098
|
+
if ((!gatingServiceSignature || !signatureExpiration) && baseApiUrl) {
|
|
1071
1099
|
const apiOpts = {
|
|
1072
1100
|
baseApiUrl,
|
|
1073
|
-
apiKey,
|
|
1074
|
-
authorizationToken,
|
|
1075
1101
|
timeoutMs: this.config.getApiTimeoutMs()
|
|
1076
1102
|
};
|
|
1077
1103
|
const response = await apiSignIntentV3(
|
|
@@ -1321,7 +1347,7 @@ var IntentOperations = class {
|
|
|
1321
1347
|
if (!platformName) {
|
|
1322
1348
|
throw new Error("Unknown paymentMethodHash for this network/env; update SDK catalogs.");
|
|
1323
1349
|
}
|
|
1324
|
-
const
|
|
1350
|
+
const attestationRoute = resolveBuyerTeeAttestationRoute(platformName, buyerTeeProof);
|
|
1325
1351
|
const intent = {
|
|
1326
1352
|
intentHash,
|
|
1327
1353
|
amount: inputs.amount,
|
|
@@ -1340,9 +1366,10 @@ var IntentOperations = class {
|
|
|
1340
1366
|
intent
|
|
1341
1367
|
},
|
|
1342
1368
|
attestationServiceUrl,
|
|
1343
|
-
|
|
1344
|
-
|
|
1369
|
+
attestationRoute.actionPlatform,
|
|
1370
|
+
attestationRoute.actionType
|
|
1345
1371
|
);
|
|
1372
|
+
assertReleaseAmountMeetsMinimum(attestation, inputs.minimumReleaseAmount);
|
|
1346
1373
|
paymentProof = encodePaymentAttestation(attestation);
|
|
1347
1374
|
verificationData = encodeVerifyPaymentData({
|
|
1348
1375
|
intentHash,
|
|
@@ -1393,13 +1420,19 @@ var IntentOperations = class {
|
|
|
1393
1420
|
);
|
|
1394
1421
|
const payee2 = matched?.verificationData?.payeeDetails;
|
|
1395
1422
|
if (payee2) {
|
|
1423
|
+
const minimumReleaseAmount2 = await this.resolveIntentMinimumReleaseAmount(
|
|
1424
|
+
intentHash,
|
|
1425
|
+
options?.orchestratorAddress,
|
|
1426
|
+
view.deposit.deposit.intentAmountRange.min
|
|
1427
|
+
);
|
|
1396
1428
|
return {
|
|
1397
1429
|
amount: view.intent.amount.toString(),
|
|
1398
1430
|
fiatCurrency: view.intent.fiatCurrency,
|
|
1399
1431
|
conversionRate: view.intent.conversionRate.toString(),
|
|
1400
1432
|
payeeDetails: payee2,
|
|
1401
1433
|
intentTimestampMs: (BigInt(view.intent.timestamp) * 1000n).toString(),
|
|
1402
|
-
paymentMethodHash: view.intent.paymentMethod
|
|
1434
|
+
paymentMethodHash: view.intent.paymentMethod,
|
|
1435
|
+
...minimumReleaseAmount2 ? { minimumReleaseAmount: minimumReleaseAmount2 } : {}
|
|
1403
1436
|
};
|
|
1404
1437
|
}
|
|
1405
1438
|
}
|
|
@@ -1419,6 +1452,8 @@ var IntentOperations = class {
|
|
|
1419
1452
|
depositId
|
|
1420
1453
|
signalTimestamp
|
|
1421
1454
|
verifier
|
|
1455
|
+
status
|
|
1456
|
+
isExpired
|
|
1422
1457
|
}
|
|
1423
1458
|
}
|
|
1424
1459
|
`
|
|
@@ -1427,6 +1462,18 @@ var IntentOperations = class {
|
|
|
1427
1462
|
});
|
|
1428
1463
|
const record = response?.Intent?.[0];
|
|
1429
1464
|
if (!record) throw new Error("Intent not found on indexer");
|
|
1465
|
+
if (record.status && record.status !== "SIGNALED") {
|
|
1466
|
+
throw new ValidationError(
|
|
1467
|
+
`Intent not found or no longer fulfillable (status: ${record.status})`,
|
|
1468
|
+
"intentHash",
|
|
1469
|
+
{ intentHash, status: record.status }
|
|
1470
|
+
);
|
|
1471
|
+
}
|
|
1472
|
+
if (record.isExpired) {
|
|
1473
|
+
throw new ValidationError("Intent expired and can no longer be fulfilled", "intentHash", {
|
|
1474
|
+
intentHash
|
|
1475
|
+
});
|
|
1476
|
+
}
|
|
1430
1477
|
if (!record.signalTimestamp) throw new Error("Intent signal timestamp not found on indexer");
|
|
1431
1478
|
const deposit = await this.config.getIndexerService().fetchDepositWithRelations(record.depositId, {
|
|
1432
1479
|
includeIntents: false
|
|
@@ -1443,6 +1490,11 @@ var IntentOperations = class {
|
|
|
1443
1490
|
}
|
|
1444
1491
|
}
|
|
1445
1492
|
if (!payee) throw new Error("Payee details not found for intent");
|
|
1493
|
+
const minimumReleaseAmount = await this.resolveIntentMinimumReleaseAmount(
|
|
1494
|
+
intentHash,
|
|
1495
|
+
options?.orchestratorAddress,
|
|
1496
|
+
deposit.intentAmountMin
|
|
1497
|
+
);
|
|
1446
1498
|
return {
|
|
1447
1499
|
amount: record.amount,
|
|
1448
1500
|
fiatCurrency: record.fiatCurrency,
|
|
@@ -1450,10 +1502,51 @@ var IntentOperations = class {
|
|
|
1450
1502
|
payeeDetails: payee,
|
|
1451
1503
|
intentTimestampMs: (BigInt(record.signalTimestamp) * 1000n).toString(),
|
|
1452
1504
|
paymentMethodHash: record.paymentMethodHash || "0x0000000000000000000000000000000000000000000000000000000000000000",
|
|
1453
|
-
paymentVerifier: record.verifier || void 0
|
|
1505
|
+
paymentVerifier: record.verifier || void 0,
|
|
1506
|
+
...minimumReleaseAmount ? { minimumReleaseAmount } : {}
|
|
1454
1507
|
};
|
|
1455
1508
|
}
|
|
1509
|
+
async resolveIntentMinimumReleaseAmount(intentHash, orchestratorAddress, fallbackMinimum) {
|
|
1510
|
+
const snapshotMinimum = await this.readIntentMinAtSignal(intentHash, orchestratorAddress);
|
|
1511
|
+
if (snapshotMinimum && snapshotMinimum !== "0") {
|
|
1512
|
+
return snapshotMinimum;
|
|
1513
|
+
}
|
|
1514
|
+
if (fallbackMinimum === void 0 || fallbackMinimum === null) {
|
|
1515
|
+
return snapshotMinimum;
|
|
1516
|
+
}
|
|
1517
|
+
return BigInt(fallbackMinimum).toString();
|
|
1518
|
+
}
|
|
1519
|
+
async readIntentMinAtSignal(intentHash, orchestratorAddress) {
|
|
1520
|
+
const address = orchestratorAddress ?? this.config.getOrchestratorV2Address();
|
|
1521
|
+
if (!address) return void 0;
|
|
1522
|
+
try {
|
|
1523
|
+
const value = await this.config.getPublicClient().readContract({
|
|
1524
|
+
address,
|
|
1525
|
+
abi: INTENT_MIN_AT_SIGNAL_ABI,
|
|
1526
|
+
functionName: "getIntentMinAtSignal",
|
|
1527
|
+
args: [intentHash]
|
|
1528
|
+
});
|
|
1529
|
+
return value.toString();
|
|
1530
|
+
} catch {
|
|
1531
|
+
return void 0;
|
|
1532
|
+
}
|
|
1533
|
+
}
|
|
1456
1534
|
};
|
|
1535
|
+
function assertReleaseAmountMeetsMinimum(attestation, minimumReleaseAmount) {
|
|
1536
|
+
if (!minimumReleaseAmount) return;
|
|
1537
|
+
const minimum = BigInt(minimumReleaseAmount);
|
|
1538
|
+
if (minimum === 0n) return;
|
|
1539
|
+
const releaseAmount = BigInt(attestation.responseObject.typedDataValue.releaseAmount);
|
|
1540
|
+
if (releaseAmount >= minimum) return;
|
|
1541
|
+
throw new ValidationError(
|
|
1542
|
+
`Payment amount is below the minimum required for this intent. Release amount ${releaseAmount.toString()} is below minimum ${minimum.toString()}.`,
|
|
1543
|
+
"releaseAmount",
|
|
1544
|
+
{
|
|
1545
|
+
releaseAmount: releaseAmount.toString(),
|
|
1546
|
+
minimumReleaseAmount: minimum.toString()
|
|
1547
|
+
}
|
|
1548
|
+
);
|
|
1549
|
+
}
|
|
1457
1550
|
function isRecord(value) {
|
|
1458
1551
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1459
1552
|
}
|
|
@@ -1720,7 +1813,7 @@ var ProtocolViewerReader = class {
|
|
|
1720
1813
|
if (inputCount === null) {
|
|
1721
1814
|
throw new Error("Configured ProtocolViewer ABI does not expose getDeposit");
|
|
1722
1815
|
}
|
|
1723
|
-
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-
|
|
1816
|
+
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-XN63B2S5.mjs');
|
|
1724
1817
|
if (inputCount >= 3) {
|
|
1725
1818
|
return tryContexts(
|
|
1726
1819
|
protocolViewerContexts,
|
|
@@ -1799,7 +1892,7 @@ var ProtocolViewerReader = class {
|
|
|
1799
1892
|
return Promise.all(ids.map((id) => this.config.host.getPvDepositById(id)));
|
|
1800
1893
|
}
|
|
1801
1894
|
const bn = ids.map((id) => typeof id === "bigint" ? id : parseRawDepositId(id));
|
|
1802
|
-
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-
|
|
1895
|
+
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-XN63B2S5.mjs');
|
|
1803
1896
|
if (inputCount >= 2) {
|
|
1804
1897
|
const requests = ids.map((id, index) => ({
|
|
1805
1898
|
index,
|
|
@@ -1904,7 +1997,7 @@ var ProtocolViewerReader = class {
|
|
|
1904
1997
|
if (!protocolViewerAddress || !protocolViewerAbi || inputCount === null) {
|
|
1905
1998
|
return this.config.host.getPvAccountDepositsFromIndexer(owner);
|
|
1906
1999
|
}
|
|
1907
|
-
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-
|
|
2000
|
+
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-XN63B2S5.mjs');
|
|
1908
2001
|
const { address, abi } = this.config.host.requireProtocolViewer();
|
|
1909
2002
|
if (inputCount >= 2) {
|
|
1910
2003
|
const readAndFilter = async (raw2) => {
|
|
@@ -1975,7 +2068,7 @@ var ProtocolViewerReader = class {
|
|
|
1975
2068
|
if (protocolViewerEntries.length === 0) {
|
|
1976
2069
|
throw new Error("ProtocolViewer not available for this network");
|
|
1977
2070
|
}
|
|
1978
|
-
const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-
|
|
2071
|
+
const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-XN63B2S5.mjs');
|
|
1979
2072
|
const intentsByHash = /* @__PURE__ */ new Map();
|
|
1980
2073
|
let attemptedRead = false;
|
|
1981
2074
|
let hadSuccessfulRead = false;
|
|
@@ -2083,7 +2176,7 @@ var ProtocolViewerReader = class {
|
|
|
2083
2176
|
if (protocolViewerEntries.length === 0) {
|
|
2084
2177
|
throw new Error("ProtocolViewer not available for this network");
|
|
2085
2178
|
}
|
|
2086
|
-
const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-
|
|
2179
|
+
const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-XN63B2S5.mjs');
|
|
2087
2180
|
let lastError;
|
|
2088
2181
|
for (const pvEntry of protocolViewerEntries) {
|
|
2089
2182
|
const inputCount = this.pvEntryFunctionInputCount(pvEntry, "getIntent");
|
|
@@ -4981,11 +5074,9 @@ var logger = {
|
|
|
4981
5074
|
};
|
|
4982
5075
|
|
|
4983
5076
|
// src/adapters/api.ts
|
|
4984
|
-
function
|
|
5077
|
+
function createHeaders(apiKey) {
|
|
4985
5078
|
const headers2 = { "Content-Type": "application/json" };
|
|
4986
5079
|
if (apiKey) headers2["x-api-key"] = apiKey;
|
|
4987
|
-
if (authToken)
|
|
4988
|
-
headers2["Authorization"] = authToken.startsWith("Bearer ") ? authToken : `Bearer ${authToken}`;
|
|
4989
5080
|
return headers2;
|
|
4990
5081
|
}
|
|
4991
5082
|
function withApiBase(baseApiUrl) {
|
|
@@ -5000,7 +5091,6 @@ async function apiFetch({
|
|
|
5000
5091
|
method = "GET",
|
|
5001
5092
|
body,
|
|
5002
5093
|
apiKey,
|
|
5003
|
-
authToken,
|
|
5004
5094
|
timeoutMs,
|
|
5005
5095
|
retryCount = 3,
|
|
5006
5096
|
retryDelayMs = 1e3
|
|
@@ -5012,7 +5102,7 @@ async function apiFetch({
|
|
|
5012
5102
|
try {
|
|
5013
5103
|
const options = {
|
|
5014
5104
|
method,
|
|
5015
|
-
headers:
|
|
5105
|
+
headers: createHeaders(apiKey)
|
|
5016
5106
|
};
|
|
5017
5107
|
if (body && method !== "GET") {
|
|
5018
5108
|
options.body = JSON.stringify(body);
|
|
@@ -5149,7 +5239,7 @@ function convertIndexerDepositToLegacyApiDeposit(deposit) {
|
|
|
5149
5239
|
verifiers
|
|
5150
5240
|
};
|
|
5151
5241
|
}
|
|
5152
|
-
async function apiPostDepositDetails(req, baseApiUrl, timeoutMs
|
|
5242
|
+
async function apiPostDepositDetails(req, baseApiUrl, timeoutMs) {
|
|
5153
5243
|
return apiFetch({
|
|
5154
5244
|
url: `${withApiBase(baseApiUrl)}/v2/makers/create`,
|
|
5155
5245
|
method: "POST",
|
|
@@ -5157,7 +5247,7 @@ async function apiPostDepositDetails(req, baseApiUrl, timeoutMs, _apiKey, _authT
|
|
|
5157
5247
|
timeoutMs
|
|
5158
5248
|
});
|
|
5159
5249
|
}
|
|
5160
|
-
async function apiGetQuote(req, baseApiUrl, timeoutMs
|
|
5250
|
+
async function apiGetQuote(req, baseApiUrl, timeoutMs) {
|
|
5161
5251
|
if (req.quotesToReturn !== void 0) {
|
|
5162
5252
|
if (!Number.isInteger(req.quotesToReturn) || req.quotesToReturn < 1) {
|
|
5163
5253
|
throw new ValidationError("quotesToReturn must be a positive integer", "quotesToReturn");
|
|
@@ -5192,12 +5282,10 @@ async function apiGetQuote(req, baseApiUrl, timeoutMs, apiKey, authToken) {
|
|
|
5192
5282
|
url,
|
|
5193
5283
|
method: "POST",
|
|
5194
5284
|
body: requestBody,
|
|
5195
|
-
apiKey,
|
|
5196
|
-
authToken,
|
|
5197
5285
|
timeoutMs
|
|
5198
5286
|
});
|
|
5199
5287
|
}
|
|
5200
|
-
async function apiGetQuotesBestByPlatform(req, baseApiUrl, timeoutMs
|
|
5288
|
+
async function apiGetQuotesBestByPlatform(req, baseApiUrl, timeoutMs) {
|
|
5201
5289
|
const isExactFiat = req.isExactFiat !== false;
|
|
5202
5290
|
const endpoint = isExactFiat ? "best-by-platform" : "best-by-platform-exact-token";
|
|
5203
5291
|
const url = `${withApiBase(baseApiUrl)}/v2/quote/${endpoint}`;
|
|
@@ -5215,17 +5303,13 @@ async function apiGetQuotesBestByPlatform(req, baseApiUrl, timeoutMs, apiKey, au
|
|
|
5215
5303
|
url,
|
|
5216
5304
|
method: "POST",
|
|
5217
5305
|
body: requestBody,
|
|
5218
|
-
apiKey,
|
|
5219
|
-
authToken,
|
|
5220
5306
|
timeoutMs
|
|
5221
5307
|
});
|
|
5222
5308
|
}
|
|
5223
|
-
async function apiGetPayeeDetails(req,
|
|
5309
|
+
async function apiGetPayeeDetails(req, baseApiUrl, timeoutMs) {
|
|
5224
5310
|
return apiFetch({
|
|
5225
5311
|
url: `${baseApiUrl.replace(/\/$/, "")}/v2/makers/${req.processorName}/${req.hashedOnchainId}`,
|
|
5226
5312
|
method: "GET",
|
|
5227
|
-
apiKey,
|
|
5228
|
-
authToken,
|
|
5229
5313
|
timeoutMs
|
|
5230
5314
|
});
|
|
5231
5315
|
}
|
|
@@ -5276,7 +5360,7 @@ async function apiGetOwnerDeposits(req, apiKey, baseApiUrl, authToken, timeoutMs
|
|
|
5276
5360
|
statusCode: 200
|
|
5277
5361
|
};
|
|
5278
5362
|
}
|
|
5279
|
-
async function apiGetTakerTier(req,
|
|
5363
|
+
async function apiGetTakerTier(req, baseApiUrl, timeoutMs) {
|
|
5280
5364
|
const normalizedOwner = req.owner.toLowerCase();
|
|
5281
5365
|
const query = new URLSearchParams({
|
|
5282
5366
|
owner: normalizedOwner,
|
|
@@ -5308,8 +5392,6 @@ async function apiUploadGoogleOAuthSellerCredential(processorName, payeeDetails,
|
|
|
5308
5392
|
url: `${withApiBase(baseApiUrl)}${endpoint}`,
|
|
5309
5393
|
method: "POST",
|
|
5310
5394
|
body,
|
|
5311
|
-
apiKey: opts?.apiKey,
|
|
5312
|
-
authToken: opts?.authToken,
|
|
5313
5395
|
timeoutMs: opts?.timeoutMs
|
|
5314
5396
|
});
|
|
5315
5397
|
}
|
|
@@ -5323,7 +5405,7 @@ async function apiGetSellerCredentialStatus(processorName, payeeDetails, baseApi
|
|
|
5323
5405
|
timeoutMs
|
|
5324
5406
|
});
|
|
5325
5407
|
}
|
|
5326
|
-
async function apiVerifySellerPayment(platform, req, baseApiUrl, timeoutMs, apiKey
|
|
5408
|
+
async function apiVerifySellerPayment(platform, req, baseApiUrl, timeoutMs, apiKey) {
|
|
5327
5409
|
const body = {
|
|
5328
5410
|
txId: req.txId,
|
|
5329
5411
|
chainId: req.chainId,
|
|
@@ -5335,15 +5417,13 @@ async function apiVerifySellerPayment(platform, req, baseApiUrl, timeoutMs, apiK
|
|
|
5335
5417
|
method: "POST",
|
|
5336
5418
|
body,
|
|
5337
5419
|
apiKey,
|
|
5338
|
-
authToken,
|
|
5339
5420
|
timeoutMs
|
|
5340
5421
|
});
|
|
5341
5422
|
}
|
|
5342
|
-
async function apiGetOrderbook(params, optsOrBaseApiUrl, timeoutMs
|
|
5423
|
+
async function apiGetOrderbook(params, optsOrBaseApiUrl, timeoutMs) {
|
|
5343
5424
|
const opts = typeof optsOrBaseApiUrl === "string" ? {
|
|
5344
5425
|
baseApiUrl: optsOrBaseApiUrl,
|
|
5345
|
-
timeoutMs
|
|
5346
|
-
apiKey
|
|
5426
|
+
timeoutMs
|
|
5347
5427
|
} : optsOrBaseApiUrl;
|
|
5348
5428
|
const query = new URLSearchParams();
|
|
5349
5429
|
Object.entries(params).forEach(([key, value]) => {
|
|
@@ -5353,17 +5433,14 @@ async function apiGetOrderbook(params, optsOrBaseApiUrl, timeoutMs, apiKey) {
|
|
|
5353
5433
|
const response = await apiFetch({
|
|
5354
5434
|
url: `${withApiBase(opts.baseApiUrl)}/v2/orderbook?${query.toString()}`,
|
|
5355
5435
|
method: "GET",
|
|
5356
|
-
apiKey: opts.apiKey,
|
|
5357
|
-
authToken: opts.authToken,
|
|
5358
5436
|
timeoutMs: opts.timeoutMs
|
|
5359
5437
|
});
|
|
5360
5438
|
return response.responseObject;
|
|
5361
5439
|
}
|
|
5362
|
-
async function apiGetDepositBundle(params, optsOrBaseApiUrl, timeoutMs
|
|
5440
|
+
async function apiGetDepositBundle(params, optsOrBaseApiUrl, timeoutMs) {
|
|
5363
5441
|
const opts = typeof optsOrBaseApiUrl === "string" ? {
|
|
5364
5442
|
baseApiUrl: optsOrBaseApiUrl,
|
|
5365
|
-
timeoutMs
|
|
5366
|
-
apiKey
|
|
5443
|
+
timeoutMs
|
|
5367
5444
|
} : optsOrBaseApiUrl;
|
|
5368
5445
|
const escrowAddress = requireEscrowAddress(
|
|
5369
5446
|
params.escrowAddress,
|
|
@@ -5376,8 +5453,6 @@ async function apiGetDepositBundle(params, optsOrBaseApiUrl, timeoutMs, apiKey)
|
|
|
5376
5453
|
const response = await apiFetch({
|
|
5377
5454
|
url: `${withApiBase(opts.baseApiUrl)}/v2/deposits/${params.depositId}/bundle?${query.toString()}`,
|
|
5378
5455
|
method: "GET",
|
|
5379
|
-
apiKey: opts.apiKey,
|
|
5380
|
-
authToken: opts.authToken,
|
|
5381
5456
|
timeoutMs: opts.timeoutMs
|
|
5382
5457
|
});
|
|
5383
5458
|
return response.responseObject;
|
|
@@ -6213,9 +6288,9 @@ var Zkp2pClient = class {
|
|
|
6213
6288
|
* sending fiat payment to the deposit's payee.
|
|
6214
6289
|
*
|
|
6215
6290
|
* If `gatingServiceSignature` is not provided, the SDK will automatically
|
|
6216
|
-
* fetch one from curator `/v3/intent/sign` when `
|
|
6217
|
-
*
|
|
6218
|
-
*
|
|
6291
|
+
* fetch one from curator `/v3/intent/sign` when `baseApiUrl` is configured.
|
|
6292
|
+
* Otherwise you must provide `gatingServiceSignature` and `signatureExpiration`
|
|
6293
|
+
* yourself.
|
|
6219
6294
|
*
|
|
6220
6295
|
* **Prepare Mode**: Use `.prepare()` to get the transaction calldata without sending:
|
|
6221
6296
|
* ```typescript
|
|
@@ -6645,8 +6720,6 @@ var Zkp2pClient = class {
|
|
|
6645
6720
|
getChainId: () => this.chainId,
|
|
6646
6721
|
getRuntimeEnv: () => this.runtimeEnv,
|
|
6647
6722
|
getBaseApiUrl: () => this.baseApiUrl,
|
|
6648
|
-
getApiKey: () => this.apiKey,
|
|
6649
|
-
getAuthorizationToken: () => this.authorizationToken,
|
|
6650
6723
|
getApiTimeoutMs: () => this.apiTimeoutMs,
|
|
6651
6724
|
getProtocolViewerAddress: () => this.protocolViewerAddress,
|
|
6652
6725
|
getProtocolViewerAbi: () => this.protocolViewerAbi,
|
|
@@ -7902,13 +7975,7 @@ var Zkp2pClient = class {
|
|
|
7902
7975
|
reqWithEscrow.escrowAddresses = configuredEscrows;
|
|
7903
7976
|
}
|
|
7904
7977
|
}
|
|
7905
|
-
const quote = await apiGetQuote(
|
|
7906
|
-
reqWithEscrow,
|
|
7907
|
-
baseApiUrl,
|
|
7908
|
-
timeoutMs,
|
|
7909
|
-
this.apiKey,
|
|
7910
|
-
this.authorizationToken
|
|
7911
|
-
);
|
|
7978
|
+
const quote = await apiGetQuote(reqWithEscrow, baseApiUrl, timeoutMs);
|
|
7912
7979
|
const quotes = quote?.responseObject?.quotes ?? [];
|
|
7913
7980
|
for (const q of quotes) {
|
|
7914
7981
|
const maker = q?.maker;
|
|
@@ -7922,8 +7989,8 @@ var Zkp2pClient = class {
|
|
|
7922
7989
|
/**
|
|
7923
7990
|
* **Supporting Method** - Fetches the best available quote per supported payment platform.
|
|
7924
7991
|
*
|
|
7925
|
-
* Returns one quote per platform when available.
|
|
7926
|
-
*
|
|
7992
|
+
* Returns one quote per platform when available. The API returns payee details
|
|
7993
|
+
* in each platform's best quote when available.
|
|
7927
7994
|
*
|
|
7928
7995
|
* @param req - Best-by-platform quote request parameters
|
|
7929
7996
|
* @param opts - Optional overrides for API URL and timeout
|
|
@@ -7946,13 +8013,7 @@ var Zkp2pClient = class {
|
|
|
7946
8013
|
reqWithEscrow.escrowAddresses = configuredEscrows;
|
|
7947
8014
|
}
|
|
7948
8015
|
}
|
|
7949
|
-
const quote = await apiGetQuotesBestByPlatform(
|
|
7950
|
-
reqWithEscrow,
|
|
7951
|
-
baseApiUrl,
|
|
7952
|
-
timeoutMs,
|
|
7953
|
-
this.apiKey,
|
|
7954
|
-
this.authorizationToken
|
|
7955
|
-
);
|
|
8016
|
+
const quote = await apiGetQuotesBestByPlatform(reqWithEscrow, baseApiUrl, timeoutMs);
|
|
7956
8017
|
const enrichedQuote = quote ? {
|
|
7957
8018
|
...quote,
|
|
7958
8019
|
responseObject: {
|
|
@@ -7989,7 +8050,7 @@ var Zkp2pClient = class {
|
|
|
7989
8050
|
""
|
|
7990
8051
|
);
|
|
7991
8052
|
const timeoutMs = opts?.timeoutMs ?? this.apiTimeoutMs;
|
|
7992
|
-
return apiGetTakerTier(req,
|
|
8053
|
+
return apiGetTakerTier(req, baseApiUrl, timeoutMs);
|
|
7993
8054
|
}
|
|
7994
8055
|
/**
|
|
7995
8056
|
* The signed `credentialValidatedAt` field is an upload-time freshness witness minted by
|
|
@@ -8089,8 +8150,6 @@ var Zkp2pClient = class {
|
|
|
8089
8150
|
},
|
|
8090
8151
|
baseApiUrl,
|
|
8091
8152
|
{
|
|
8092
|
-
apiKey: this.apiKey,
|
|
8093
|
-
authToken: this.authorizationToken,
|
|
8094
8153
|
timeoutMs
|
|
8095
8154
|
}
|
|
8096
8155
|
);
|
|
@@ -8105,8 +8164,6 @@ var Zkp2pClient = class {
|
|
|
8105
8164
|
},
|
|
8106
8165
|
baseApiUrl,
|
|
8107
8166
|
{
|
|
8108
|
-
apiKey: this.apiKey,
|
|
8109
|
-
authToken: this.authorizationToken,
|
|
8110
8167
|
timeoutMs
|
|
8111
8168
|
}
|
|
8112
8169
|
);
|
|
@@ -8133,8 +8190,8 @@ var Zkp2pClient = class {
|
|
|
8133
8190
|
);
|
|
8134
8191
|
}
|
|
8135
8192
|
/**
|
|
8136
|
-
* Internal-use endpoint. The curator route requires an internal `x-api-key`;
|
|
8137
|
-
* API keys will be rejected
|
|
8193
|
+
* Internal-use endpoint. The curator route requires an internal `x-api-key`; non-internal
|
|
8194
|
+
* API keys will be rejected. Returns 410 GONE when curator has marked the credential inactive
|
|
8138
8195
|
* or a stale credential fails its synchronous re-probe.
|
|
8139
8196
|
*
|
|
8140
8197
|
* Verify a seller payment via curator's seller-credential proxy.
|
|
@@ -8154,8 +8211,7 @@ var Zkp2pClient = class {
|
|
|
8154
8211
|
},
|
|
8155
8212
|
baseApiUrl,
|
|
8156
8213
|
timeoutMs,
|
|
8157
|
-
this.apiKey
|
|
8158
|
-
this.authorizationToken
|
|
8214
|
+
this.apiKey
|
|
8159
8215
|
);
|
|
8160
8216
|
}
|
|
8161
8217
|
// ╔═══════════════════════════════════════════════════════════════════════════╗
|