@zkp2p/sdk 0.5.2 → 0.5.5
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-L526MKG3.mjs → chunk-NKTSEXJB.mjs} +37 -5
- package/dist/{chunk-L526MKG3.mjs.map → chunk-NKTSEXJB.mjs.map} +1 -1
- package/dist/{chunk-LPJE2MN7.mjs → chunk-TGMRXUP2.mjs} +28 -3
- package/dist/chunk-TGMRXUP2.mjs.map +1 -0
- package/dist/index.cjs +194 -85
- 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 +153 -90
- package/dist/index.mjs.map +1 -1
- package/dist/protocolViewerParsers-3JGPLQGP.mjs +5 -0
- package/dist/{protocolViewerParsers-GGSM2243.mjs.map → protocolViewerParsers-3JGPLQGP.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-NKTSEXJB.mjs';
|
|
5
|
+
export { asciiToBytes32, enrichPvDepositView, enrichPvIntentView, ensureBytes32, getContracts, getGatingServiceAddress, getPaymentMethodsCatalog, getRateManagerContracts, parseDepositView, parseIntentView, resolveFiatCurrencyBytes32, resolvePaymentMethodHash, resolvePaymentMethodHashFromCatalog, resolvePaymentMethodNameFromHash } from './chunk-NKTSEXJB.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) {
|
|
@@ -1006,13 +999,15 @@ var PLATFORM_ATTESTATION_CONFIG = {
|
|
|
1006
999
|
chime: { actionType: "transfer_chime", actionPlatform: "chime" },
|
|
1007
1000
|
luxon: { actionType: "transfer_luxon", actionPlatform: "luxon" },
|
|
1008
1001
|
n26: { actionType: "transfer_n26", actionPlatform: "n26" },
|
|
1009
|
-
alipay: { actionType: "transfer_alipay", actionPlatform: "alipay" }
|
|
1010
|
-
"zelle-chase": { actionType: "transfer_zelle", actionPlatform: "chase" },
|
|
1011
|
-
"zelle-bofa": { actionType: "transfer_zelle", actionPlatform: "bankofamerica" },
|
|
1012
|
-
"zelle-citi": { actionType: "transfer_zelle", actionPlatform: "citi" }
|
|
1002
|
+
alipay: { actionType: "transfer_alipay", actionPlatform: "alipay" }
|
|
1013
1003
|
};
|
|
1014
1004
|
function resolvePlatformAttestationConfig(platformName) {
|
|
1015
1005
|
const normalized = platformName.toLowerCase();
|
|
1006
|
+
if (normalized === "zelle") {
|
|
1007
|
+
throw new Error(
|
|
1008
|
+
"Generic Zelle buyer TEE fulfillment requires a bank-specific actionType override."
|
|
1009
|
+
);
|
|
1010
|
+
}
|
|
1016
1011
|
const config = PLATFORM_ATTESTATION_CONFIG[normalized];
|
|
1017
1012
|
if (!config) {
|
|
1018
1013
|
throw new Error(`Unknown payment platform: ${platformName}`);
|
|
@@ -1021,6 +1016,48 @@ function resolvePlatformAttestationConfig(platformName) {
|
|
|
1021
1016
|
}
|
|
1022
1017
|
|
|
1023
1018
|
// src/client/IntentOperations.ts
|
|
1019
|
+
var INTENT_MIN_AT_SIGNAL_ABI = [
|
|
1020
|
+
{
|
|
1021
|
+
type: "function",
|
|
1022
|
+
name: "getIntentMinAtSignal",
|
|
1023
|
+
stateMutability: "view",
|
|
1024
|
+
inputs: [{ name: "_intentHash", type: "bytes32" }],
|
|
1025
|
+
outputs: [{ name: "", type: "uint256" }]
|
|
1026
|
+
}
|
|
1027
|
+
];
|
|
1028
|
+
var GENERIC_ZELLE_ATTESTATION_ACTION_TYPES = /* @__PURE__ */ new Set([
|
|
1029
|
+
"transfer_zelle_bofa",
|
|
1030
|
+
"transfer_zelle_chase",
|
|
1031
|
+
"transfer_zelle_citi"
|
|
1032
|
+
]);
|
|
1033
|
+
function hasBuyerTeeRouteOverrides(buyerTeeProof) {
|
|
1034
|
+
return Boolean(buyerTeeProof.actionPlatform && buyerTeeProof.actionType);
|
|
1035
|
+
}
|
|
1036
|
+
function resolveBuyerTeeAttestationRoute(platformName, buyerTeeProof) {
|
|
1037
|
+
const normalizedPlatformName = platformName.toLowerCase();
|
|
1038
|
+
if (normalizedPlatformName === "zelle") {
|
|
1039
|
+
if (buyerTeeProof.actionPlatform !== "zelle" || !buyerTeeProof.actionType || !GENERIC_ZELLE_ATTESTATION_ACTION_TYPES.has(buyerTeeProof.actionType)) {
|
|
1040
|
+
throw new Error(
|
|
1041
|
+
'Generic Zelle buyer TEE fulfillment requires actionPlatform "zelle" and a bank-specific transfer_zelle_* actionType.'
|
|
1042
|
+
);
|
|
1043
|
+
}
|
|
1044
|
+
return {
|
|
1045
|
+
actionPlatform: buyerTeeProof.actionPlatform,
|
|
1046
|
+
actionType: buyerTeeProof.actionType
|
|
1047
|
+
};
|
|
1048
|
+
}
|
|
1049
|
+
if (hasBuyerTeeRouteOverrides(buyerTeeProof)) {
|
|
1050
|
+
return {
|
|
1051
|
+
actionPlatform: buyerTeeProof.actionPlatform,
|
|
1052
|
+
actionType: buyerTeeProof.actionType
|
|
1053
|
+
};
|
|
1054
|
+
}
|
|
1055
|
+
const platformConfig = resolvePlatformAttestationConfig(platformName);
|
|
1056
|
+
return {
|
|
1057
|
+
actionPlatform: platformConfig.actionPlatform,
|
|
1058
|
+
actionType: platformConfig.actionType
|
|
1059
|
+
};
|
|
1060
|
+
}
|
|
1024
1061
|
var IntentOperations = class {
|
|
1025
1062
|
constructor(config) {
|
|
1026
1063
|
this.config = config;
|
|
@@ -1065,13 +1102,9 @@ var IntentOperations = class {
|
|
|
1065
1102
|
let { gatingServiceSignature, signatureExpiration } = params;
|
|
1066
1103
|
let preIntentHookData = params.preIntentHookData;
|
|
1067
1104
|
const baseApiUrl = this.config.getBaseApiUrl();
|
|
1068
|
-
|
|
1069
|
-
const authorizationToken = this.config.getAuthorizationToken();
|
|
1070
|
-
if ((!gatingServiceSignature || !signatureExpiration) && baseApiUrl && (apiKey || authorizationToken)) {
|
|
1105
|
+
if ((!gatingServiceSignature || !signatureExpiration) && baseApiUrl) {
|
|
1071
1106
|
const apiOpts = {
|
|
1072
1107
|
baseApiUrl,
|
|
1073
|
-
apiKey,
|
|
1074
|
-
authorizationToken,
|
|
1075
1108
|
timeoutMs: this.config.getApiTimeoutMs()
|
|
1076
1109
|
};
|
|
1077
1110
|
const response = await apiSignIntentV3(
|
|
@@ -1321,7 +1354,7 @@ var IntentOperations = class {
|
|
|
1321
1354
|
if (!platformName) {
|
|
1322
1355
|
throw new Error("Unknown paymentMethodHash for this network/env; update SDK catalogs.");
|
|
1323
1356
|
}
|
|
1324
|
-
const
|
|
1357
|
+
const attestationRoute = resolveBuyerTeeAttestationRoute(platformName, buyerTeeProof);
|
|
1325
1358
|
const intent = {
|
|
1326
1359
|
intentHash,
|
|
1327
1360
|
amount: inputs.amount,
|
|
@@ -1340,9 +1373,10 @@ var IntentOperations = class {
|
|
|
1340
1373
|
intent
|
|
1341
1374
|
},
|
|
1342
1375
|
attestationServiceUrl,
|
|
1343
|
-
|
|
1344
|
-
|
|
1376
|
+
attestationRoute.actionPlatform,
|
|
1377
|
+
attestationRoute.actionType
|
|
1345
1378
|
);
|
|
1379
|
+
assertReleaseAmountMeetsMinimum(attestation, inputs.minimumReleaseAmount);
|
|
1346
1380
|
paymentProof = encodePaymentAttestation(attestation);
|
|
1347
1381
|
verificationData = encodeVerifyPaymentData({
|
|
1348
1382
|
intentHash,
|
|
@@ -1393,13 +1427,19 @@ var IntentOperations = class {
|
|
|
1393
1427
|
);
|
|
1394
1428
|
const payee2 = matched?.verificationData?.payeeDetails;
|
|
1395
1429
|
if (payee2) {
|
|
1430
|
+
const minimumReleaseAmount2 = await this.resolveIntentMinimumReleaseAmount(
|
|
1431
|
+
intentHash,
|
|
1432
|
+
options?.orchestratorAddress,
|
|
1433
|
+
view.deposit.deposit.intentAmountRange.min
|
|
1434
|
+
);
|
|
1396
1435
|
return {
|
|
1397
1436
|
amount: view.intent.amount.toString(),
|
|
1398
1437
|
fiatCurrency: view.intent.fiatCurrency,
|
|
1399
1438
|
conversionRate: view.intent.conversionRate.toString(),
|
|
1400
1439
|
payeeDetails: payee2,
|
|
1401
1440
|
intentTimestampMs: (BigInt(view.intent.timestamp) * 1000n).toString(),
|
|
1402
|
-
paymentMethodHash: view.intent.paymentMethod
|
|
1441
|
+
paymentMethodHash: view.intent.paymentMethod,
|
|
1442
|
+
...minimumReleaseAmount2 ? { minimumReleaseAmount: minimumReleaseAmount2 } : {}
|
|
1403
1443
|
};
|
|
1404
1444
|
}
|
|
1405
1445
|
}
|
|
@@ -1419,6 +1459,8 @@ var IntentOperations = class {
|
|
|
1419
1459
|
depositId
|
|
1420
1460
|
signalTimestamp
|
|
1421
1461
|
verifier
|
|
1462
|
+
status
|
|
1463
|
+
isExpired
|
|
1422
1464
|
}
|
|
1423
1465
|
}
|
|
1424
1466
|
`
|
|
@@ -1427,6 +1469,18 @@ var IntentOperations = class {
|
|
|
1427
1469
|
});
|
|
1428
1470
|
const record = response?.Intent?.[0];
|
|
1429
1471
|
if (!record) throw new Error("Intent not found on indexer");
|
|
1472
|
+
if (record.status && record.status !== "SIGNALED") {
|
|
1473
|
+
throw new ValidationError(
|
|
1474
|
+
`Intent not found or no longer fulfillable (status: ${record.status})`,
|
|
1475
|
+
"intentHash",
|
|
1476
|
+
{ intentHash, status: record.status }
|
|
1477
|
+
);
|
|
1478
|
+
}
|
|
1479
|
+
if (record.isExpired) {
|
|
1480
|
+
throw new ValidationError("Intent expired and can no longer be fulfilled", "intentHash", {
|
|
1481
|
+
intentHash
|
|
1482
|
+
});
|
|
1483
|
+
}
|
|
1430
1484
|
if (!record.signalTimestamp) throw new Error("Intent signal timestamp not found on indexer");
|
|
1431
1485
|
const deposit = await this.config.getIndexerService().fetchDepositWithRelations(record.depositId, {
|
|
1432
1486
|
includeIntents: false
|
|
@@ -1443,6 +1497,11 @@ var IntentOperations = class {
|
|
|
1443
1497
|
}
|
|
1444
1498
|
}
|
|
1445
1499
|
if (!payee) throw new Error("Payee details not found for intent");
|
|
1500
|
+
const minimumReleaseAmount = await this.resolveIntentMinimumReleaseAmount(
|
|
1501
|
+
intentHash,
|
|
1502
|
+
options?.orchestratorAddress,
|
|
1503
|
+
deposit.intentAmountMin
|
|
1504
|
+
);
|
|
1446
1505
|
return {
|
|
1447
1506
|
amount: record.amount,
|
|
1448
1507
|
fiatCurrency: record.fiatCurrency,
|
|
@@ -1450,10 +1509,51 @@ var IntentOperations = class {
|
|
|
1450
1509
|
payeeDetails: payee,
|
|
1451
1510
|
intentTimestampMs: (BigInt(record.signalTimestamp) * 1000n).toString(),
|
|
1452
1511
|
paymentMethodHash: record.paymentMethodHash || "0x0000000000000000000000000000000000000000000000000000000000000000",
|
|
1453
|
-
paymentVerifier: record.verifier || void 0
|
|
1512
|
+
paymentVerifier: record.verifier || void 0,
|
|
1513
|
+
...minimumReleaseAmount ? { minimumReleaseAmount } : {}
|
|
1454
1514
|
};
|
|
1455
1515
|
}
|
|
1516
|
+
async resolveIntentMinimumReleaseAmount(intentHash, orchestratorAddress, fallbackMinimum) {
|
|
1517
|
+
const snapshotMinimum = await this.readIntentMinAtSignal(intentHash, orchestratorAddress);
|
|
1518
|
+
if (snapshotMinimum && snapshotMinimum !== "0") {
|
|
1519
|
+
return snapshotMinimum;
|
|
1520
|
+
}
|
|
1521
|
+
if (fallbackMinimum === void 0 || fallbackMinimum === null) {
|
|
1522
|
+
return snapshotMinimum;
|
|
1523
|
+
}
|
|
1524
|
+
return BigInt(fallbackMinimum).toString();
|
|
1525
|
+
}
|
|
1526
|
+
async readIntentMinAtSignal(intentHash, orchestratorAddress) {
|
|
1527
|
+
const address = orchestratorAddress ?? this.config.getOrchestratorV2Address();
|
|
1528
|
+
if (!address) return void 0;
|
|
1529
|
+
try {
|
|
1530
|
+
const value = await this.config.getPublicClient().readContract({
|
|
1531
|
+
address,
|
|
1532
|
+
abi: INTENT_MIN_AT_SIGNAL_ABI,
|
|
1533
|
+
functionName: "getIntentMinAtSignal",
|
|
1534
|
+
args: [intentHash]
|
|
1535
|
+
});
|
|
1536
|
+
return value.toString();
|
|
1537
|
+
} catch {
|
|
1538
|
+
return void 0;
|
|
1539
|
+
}
|
|
1540
|
+
}
|
|
1456
1541
|
};
|
|
1542
|
+
function assertReleaseAmountMeetsMinimum(attestation, minimumReleaseAmount) {
|
|
1543
|
+
if (!minimumReleaseAmount) return;
|
|
1544
|
+
const minimum = BigInt(minimumReleaseAmount);
|
|
1545
|
+
if (minimum === 0n) return;
|
|
1546
|
+
const releaseAmount = BigInt(attestation.responseObject.typedDataValue.releaseAmount);
|
|
1547
|
+
if (releaseAmount >= minimum) return;
|
|
1548
|
+
throw new ValidationError(
|
|
1549
|
+
`Payment amount is below the minimum required for this intent. Release amount ${releaseAmount.toString()} is below minimum ${minimum.toString()}.`,
|
|
1550
|
+
"releaseAmount",
|
|
1551
|
+
{
|
|
1552
|
+
releaseAmount: releaseAmount.toString(),
|
|
1553
|
+
minimumReleaseAmount: minimum.toString()
|
|
1554
|
+
}
|
|
1555
|
+
);
|
|
1556
|
+
}
|
|
1457
1557
|
function isRecord(value) {
|
|
1458
1558
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1459
1559
|
}
|
|
@@ -1720,7 +1820,7 @@ var ProtocolViewerReader = class {
|
|
|
1720
1820
|
if (inputCount === null) {
|
|
1721
1821
|
throw new Error("Configured ProtocolViewer ABI does not expose getDeposit");
|
|
1722
1822
|
}
|
|
1723
|
-
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-
|
|
1823
|
+
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-3JGPLQGP.mjs');
|
|
1724
1824
|
if (inputCount >= 3) {
|
|
1725
1825
|
return tryContexts(
|
|
1726
1826
|
protocolViewerContexts,
|
|
@@ -1799,7 +1899,7 @@ var ProtocolViewerReader = class {
|
|
|
1799
1899
|
return Promise.all(ids.map((id) => this.config.host.getPvDepositById(id)));
|
|
1800
1900
|
}
|
|
1801
1901
|
const bn = ids.map((id) => typeof id === "bigint" ? id : parseRawDepositId(id));
|
|
1802
|
-
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-
|
|
1902
|
+
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-3JGPLQGP.mjs');
|
|
1803
1903
|
if (inputCount >= 2) {
|
|
1804
1904
|
const requests = ids.map((id, index) => ({
|
|
1805
1905
|
index,
|
|
@@ -1904,7 +2004,7 @@ var ProtocolViewerReader = class {
|
|
|
1904
2004
|
if (!protocolViewerAddress || !protocolViewerAbi || inputCount === null) {
|
|
1905
2005
|
return this.config.host.getPvAccountDepositsFromIndexer(owner);
|
|
1906
2006
|
}
|
|
1907
|
-
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-
|
|
2007
|
+
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-3JGPLQGP.mjs');
|
|
1908
2008
|
const { address, abi } = this.config.host.requireProtocolViewer();
|
|
1909
2009
|
if (inputCount >= 2) {
|
|
1910
2010
|
const readAndFilter = async (raw2) => {
|
|
@@ -1975,7 +2075,7 @@ var ProtocolViewerReader = class {
|
|
|
1975
2075
|
if (protocolViewerEntries.length === 0) {
|
|
1976
2076
|
throw new Error("ProtocolViewer not available for this network");
|
|
1977
2077
|
}
|
|
1978
|
-
const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-
|
|
2078
|
+
const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-3JGPLQGP.mjs');
|
|
1979
2079
|
const intentsByHash = /* @__PURE__ */ new Map();
|
|
1980
2080
|
let attemptedRead = false;
|
|
1981
2081
|
let hadSuccessfulRead = false;
|
|
@@ -2083,7 +2183,7 @@ var ProtocolViewerReader = class {
|
|
|
2083
2183
|
if (protocolViewerEntries.length === 0) {
|
|
2084
2184
|
throw new Error("ProtocolViewer not available for this network");
|
|
2085
2185
|
}
|
|
2086
|
-
const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-
|
|
2186
|
+
const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-3JGPLQGP.mjs');
|
|
2087
2187
|
let lastError;
|
|
2088
2188
|
for (const pvEntry of protocolViewerEntries) {
|
|
2089
2189
|
const inputCount = this.pvEntryFunctionInputCount(pvEntry, "getIntent");
|
|
@@ -4981,11 +5081,9 @@ var logger = {
|
|
|
4981
5081
|
};
|
|
4982
5082
|
|
|
4983
5083
|
// src/adapters/api.ts
|
|
4984
|
-
function
|
|
5084
|
+
function createHeaders(apiKey) {
|
|
4985
5085
|
const headers2 = { "Content-Type": "application/json" };
|
|
4986
5086
|
if (apiKey) headers2["x-api-key"] = apiKey;
|
|
4987
|
-
if (authToken)
|
|
4988
|
-
headers2["Authorization"] = authToken.startsWith("Bearer ") ? authToken : `Bearer ${authToken}`;
|
|
4989
5087
|
return headers2;
|
|
4990
5088
|
}
|
|
4991
5089
|
function withApiBase(baseApiUrl) {
|
|
@@ -5000,7 +5098,6 @@ async function apiFetch({
|
|
|
5000
5098
|
method = "GET",
|
|
5001
5099
|
body,
|
|
5002
5100
|
apiKey,
|
|
5003
|
-
authToken,
|
|
5004
5101
|
timeoutMs,
|
|
5005
5102
|
retryCount = 3,
|
|
5006
5103
|
retryDelayMs = 1e3
|
|
@@ -5012,7 +5109,7 @@ async function apiFetch({
|
|
|
5012
5109
|
try {
|
|
5013
5110
|
const options = {
|
|
5014
5111
|
method,
|
|
5015
|
-
headers:
|
|
5112
|
+
headers: createHeaders(apiKey)
|
|
5016
5113
|
};
|
|
5017
5114
|
if (body && method !== "GET") {
|
|
5018
5115
|
options.body = JSON.stringify(body);
|
|
@@ -5149,7 +5246,7 @@ function convertIndexerDepositToLegacyApiDeposit(deposit) {
|
|
|
5149
5246
|
verifiers
|
|
5150
5247
|
};
|
|
5151
5248
|
}
|
|
5152
|
-
async function apiPostDepositDetails(req, baseApiUrl, timeoutMs
|
|
5249
|
+
async function apiPostDepositDetails(req, baseApiUrl, timeoutMs) {
|
|
5153
5250
|
return apiFetch({
|
|
5154
5251
|
url: `${withApiBase(baseApiUrl)}/v2/makers/create`,
|
|
5155
5252
|
method: "POST",
|
|
@@ -5157,7 +5254,7 @@ async function apiPostDepositDetails(req, baseApiUrl, timeoutMs, _apiKey, _authT
|
|
|
5157
5254
|
timeoutMs
|
|
5158
5255
|
});
|
|
5159
5256
|
}
|
|
5160
|
-
async function apiGetQuote(req, baseApiUrl, timeoutMs
|
|
5257
|
+
async function apiGetQuote(req, baseApiUrl, timeoutMs) {
|
|
5161
5258
|
if (req.quotesToReturn !== void 0) {
|
|
5162
5259
|
if (!Number.isInteger(req.quotesToReturn) || req.quotesToReturn < 1) {
|
|
5163
5260
|
throw new ValidationError("quotesToReturn must be a positive integer", "quotesToReturn");
|
|
@@ -5192,12 +5289,10 @@ async function apiGetQuote(req, baseApiUrl, timeoutMs, apiKey, authToken) {
|
|
|
5192
5289
|
url,
|
|
5193
5290
|
method: "POST",
|
|
5194
5291
|
body: requestBody,
|
|
5195
|
-
apiKey,
|
|
5196
|
-
authToken,
|
|
5197
5292
|
timeoutMs
|
|
5198
5293
|
});
|
|
5199
5294
|
}
|
|
5200
|
-
async function apiGetQuotesBestByPlatform(req, baseApiUrl, timeoutMs
|
|
5295
|
+
async function apiGetQuotesBestByPlatform(req, baseApiUrl, timeoutMs) {
|
|
5201
5296
|
const isExactFiat = req.isExactFiat !== false;
|
|
5202
5297
|
const endpoint = isExactFiat ? "best-by-platform" : "best-by-platform-exact-token";
|
|
5203
5298
|
const url = `${withApiBase(baseApiUrl)}/v2/quote/${endpoint}`;
|
|
@@ -5215,17 +5310,13 @@ async function apiGetQuotesBestByPlatform(req, baseApiUrl, timeoutMs, apiKey, au
|
|
|
5215
5310
|
url,
|
|
5216
5311
|
method: "POST",
|
|
5217
5312
|
body: requestBody,
|
|
5218
|
-
apiKey,
|
|
5219
|
-
authToken,
|
|
5220
5313
|
timeoutMs
|
|
5221
5314
|
});
|
|
5222
5315
|
}
|
|
5223
|
-
async function apiGetPayeeDetails(req,
|
|
5316
|
+
async function apiGetPayeeDetails(req, baseApiUrl, timeoutMs) {
|
|
5224
5317
|
return apiFetch({
|
|
5225
5318
|
url: `${baseApiUrl.replace(/\/$/, "")}/v2/makers/${req.processorName}/${req.hashedOnchainId}`,
|
|
5226
5319
|
method: "GET",
|
|
5227
|
-
apiKey,
|
|
5228
|
-
authToken,
|
|
5229
5320
|
timeoutMs
|
|
5230
5321
|
});
|
|
5231
5322
|
}
|
|
@@ -5276,7 +5367,7 @@ async function apiGetOwnerDeposits(req, apiKey, baseApiUrl, authToken, timeoutMs
|
|
|
5276
5367
|
statusCode: 200
|
|
5277
5368
|
};
|
|
5278
5369
|
}
|
|
5279
|
-
async function apiGetTakerTier(req,
|
|
5370
|
+
async function apiGetTakerTier(req, baseApiUrl, timeoutMs) {
|
|
5280
5371
|
const normalizedOwner = req.owner.toLowerCase();
|
|
5281
5372
|
const query = new URLSearchParams({
|
|
5282
5373
|
owner: normalizedOwner,
|
|
@@ -5308,8 +5399,6 @@ async function apiUploadGoogleOAuthSellerCredential(processorName, payeeDetails,
|
|
|
5308
5399
|
url: `${withApiBase(baseApiUrl)}${endpoint}`,
|
|
5309
5400
|
method: "POST",
|
|
5310
5401
|
body,
|
|
5311
|
-
apiKey: opts?.apiKey,
|
|
5312
|
-
authToken: opts?.authToken,
|
|
5313
5402
|
timeoutMs: opts?.timeoutMs
|
|
5314
5403
|
});
|
|
5315
5404
|
}
|
|
@@ -5323,7 +5412,7 @@ async function apiGetSellerCredentialStatus(processorName, payeeDetails, baseApi
|
|
|
5323
5412
|
timeoutMs
|
|
5324
5413
|
});
|
|
5325
5414
|
}
|
|
5326
|
-
async function apiVerifySellerPayment(platform, req, baseApiUrl, timeoutMs, apiKey
|
|
5415
|
+
async function apiVerifySellerPayment(platform, req, baseApiUrl, timeoutMs, apiKey) {
|
|
5327
5416
|
const body = {
|
|
5328
5417
|
txId: req.txId,
|
|
5329
5418
|
chainId: req.chainId,
|
|
@@ -5335,15 +5424,13 @@ async function apiVerifySellerPayment(platform, req, baseApiUrl, timeoutMs, apiK
|
|
|
5335
5424
|
method: "POST",
|
|
5336
5425
|
body,
|
|
5337
5426
|
apiKey,
|
|
5338
|
-
authToken,
|
|
5339
5427
|
timeoutMs
|
|
5340
5428
|
});
|
|
5341
5429
|
}
|
|
5342
|
-
async function apiGetOrderbook(params, optsOrBaseApiUrl, timeoutMs
|
|
5430
|
+
async function apiGetOrderbook(params, optsOrBaseApiUrl, timeoutMs) {
|
|
5343
5431
|
const opts = typeof optsOrBaseApiUrl === "string" ? {
|
|
5344
5432
|
baseApiUrl: optsOrBaseApiUrl,
|
|
5345
|
-
timeoutMs
|
|
5346
|
-
apiKey
|
|
5433
|
+
timeoutMs
|
|
5347
5434
|
} : optsOrBaseApiUrl;
|
|
5348
5435
|
const query = new URLSearchParams();
|
|
5349
5436
|
Object.entries(params).forEach(([key, value]) => {
|
|
@@ -5353,17 +5440,14 @@ async function apiGetOrderbook(params, optsOrBaseApiUrl, timeoutMs, apiKey) {
|
|
|
5353
5440
|
const response = await apiFetch({
|
|
5354
5441
|
url: `${withApiBase(opts.baseApiUrl)}/v2/orderbook?${query.toString()}`,
|
|
5355
5442
|
method: "GET",
|
|
5356
|
-
apiKey: opts.apiKey,
|
|
5357
|
-
authToken: opts.authToken,
|
|
5358
5443
|
timeoutMs: opts.timeoutMs
|
|
5359
5444
|
});
|
|
5360
5445
|
return response.responseObject;
|
|
5361
5446
|
}
|
|
5362
|
-
async function apiGetDepositBundle(params, optsOrBaseApiUrl, timeoutMs
|
|
5447
|
+
async function apiGetDepositBundle(params, optsOrBaseApiUrl, timeoutMs) {
|
|
5363
5448
|
const opts = typeof optsOrBaseApiUrl === "string" ? {
|
|
5364
5449
|
baseApiUrl: optsOrBaseApiUrl,
|
|
5365
|
-
timeoutMs
|
|
5366
|
-
apiKey
|
|
5450
|
+
timeoutMs
|
|
5367
5451
|
} : optsOrBaseApiUrl;
|
|
5368
5452
|
const escrowAddress = requireEscrowAddress(
|
|
5369
5453
|
params.escrowAddress,
|
|
@@ -5376,8 +5460,6 @@ async function apiGetDepositBundle(params, optsOrBaseApiUrl, timeoutMs, apiKey)
|
|
|
5376
5460
|
const response = await apiFetch({
|
|
5377
5461
|
url: `${withApiBase(opts.baseApiUrl)}/v2/deposits/${params.depositId}/bundle?${query.toString()}`,
|
|
5378
5462
|
method: "GET",
|
|
5379
|
-
apiKey: opts.apiKey,
|
|
5380
|
-
authToken: opts.authToken,
|
|
5381
5463
|
timeoutMs: opts.timeoutMs
|
|
5382
5464
|
});
|
|
5383
5465
|
return response.responseObject;
|
|
@@ -6213,9 +6295,9 @@ var Zkp2pClient = class {
|
|
|
6213
6295
|
* sending fiat payment to the deposit's payee.
|
|
6214
6296
|
*
|
|
6215
6297
|
* If `gatingServiceSignature` is not provided, the SDK will automatically
|
|
6216
|
-
* fetch one from curator `/v3/intent/sign` when `
|
|
6217
|
-
*
|
|
6218
|
-
*
|
|
6298
|
+
* fetch one from curator `/v3/intent/sign` when `baseApiUrl` is configured.
|
|
6299
|
+
* Otherwise you must provide `gatingServiceSignature` and `signatureExpiration`
|
|
6300
|
+
* yourself.
|
|
6219
6301
|
*
|
|
6220
6302
|
* **Prepare Mode**: Use `.prepare()` to get the transaction calldata without sending:
|
|
6221
6303
|
* ```typescript
|
|
@@ -6645,8 +6727,6 @@ var Zkp2pClient = class {
|
|
|
6645
6727
|
getChainId: () => this.chainId,
|
|
6646
6728
|
getRuntimeEnv: () => this.runtimeEnv,
|
|
6647
6729
|
getBaseApiUrl: () => this.baseApiUrl,
|
|
6648
|
-
getApiKey: () => this.apiKey,
|
|
6649
|
-
getAuthorizationToken: () => this.authorizationToken,
|
|
6650
6730
|
getApiTimeoutMs: () => this.apiTimeoutMs,
|
|
6651
6731
|
getProtocolViewerAddress: () => this.protocolViewerAddress,
|
|
6652
6732
|
getProtocolViewerAbi: () => this.protocolViewerAbi,
|
|
@@ -7902,13 +7982,7 @@ var Zkp2pClient = class {
|
|
|
7902
7982
|
reqWithEscrow.escrowAddresses = configuredEscrows;
|
|
7903
7983
|
}
|
|
7904
7984
|
}
|
|
7905
|
-
const quote = await apiGetQuote(
|
|
7906
|
-
reqWithEscrow,
|
|
7907
|
-
baseApiUrl,
|
|
7908
|
-
timeoutMs,
|
|
7909
|
-
this.apiKey,
|
|
7910
|
-
this.authorizationToken
|
|
7911
|
-
);
|
|
7985
|
+
const quote = await apiGetQuote(reqWithEscrow, baseApiUrl, timeoutMs);
|
|
7912
7986
|
const quotes = quote?.responseObject?.quotes ?? [];
|
|
7913
7987
|
for (const q of quotes) {
|
|
7914
7988
|
const maker = q?.maker;
|
|
@@ -7922,8 +7996,8 @@ var Zkp2pClient = class {
|
|
|
7922
7996
|
/**
|
|
7923
7997
|
* **Supporting Method** - Fetches the best available quote per supported payment platform.
|
|
7924
7998
|
*
|
|
7925
|
-
* Returns one quote per platform when available.
|
|
7926
|
-
*
|
|
7999
|
+
* Returns one quote per platform when available. The API returns payee details
|
|
8000
|
+
* in each platform's best quote when available.
|
|
7927
8001
|
*
|
|
7928
8002
|
* @param req - Best-by-platform quote request parameters
|
|
7929
8003
|
* @param opts - Optional overrides for API URL and timeout
|
|
@@ -7946,13 +8020,7 @@ var Zkp2pClient = class {
|
|
|
7946
8020
|
reqWithEscrow.escrowAddresses = configuredEscrows;
|
|
7947
8021
|
}
|
|
7948
8022
|
}
|
|
7949
|
-
const quote = await apiGetQuotesBestByPlatform(
|
|
7950
|
-
reqWithEscrow,
|
|
7951
|
-
baseApiUrl,
|
|
7952
|
-
timeoutMs,
|
|
7953
|
-
this.apiKey,
|
|
7954
|
-
this.authorizationToken
|
|
7955
|
-
);
|
|
8023
|
+
const quote = await apiGetQuotesBestByPlatform(reqWithEscrow, baseApiUrl, timeoutMs);
|
|
7956
8024
|
const enrichedQuote = quote ? {
|
|
7957
8025
|
...quote,
|
|
7958
8026
|
responseObject: {
|
|
@@ -7989,7 +8057,7 @@ var Zkp2pClient = class {
|
|
|
7989
8057
|
""
|
|
7990
8058
|
);
|
|
7991
8059
|
const timeoutMs = opts?.timeoutMs ?? this.apiTimeoutMs;
|
|
7992
|
-
return apiGetTakerTier(req,
|
|
8060
|
+
return apiGetTakerTier(req, baseApiUrl, timeoutMs);
|
|
7993
8061
|
}
|
|
7994
8062
|
/**
|
|
7995
8063
|
* The signed `credentialValidatedAt` field is an upload-time freshness witness minted by
|
|
@@ -8089,8 +8157,6 @@ var Zkp2pClient = class {
|
|
|
8089
8157
|
},
|
|
8090
8158
|
baseApiUrl,
|
|
8091
8159
|
{
|
|
8092
|
-
apiKey: this.apiKey,
|
|
8093
|
-
authToken: this.authorizationToken,
|
|
8094
8160
|
timeoutMs
|
|
8095
8161
|
}
|
|
8096
8162
|
);
|
|
@@ -8105,8 +8171,6 @@ var Zkp2pClient = class {
|
|
|
8105
8171
|
},
|
|
8106
8172
|
baseApiUrl,
|
|
8107
8173
|
{
|
|
8108
|
-
apiKey: this.apiKey,
|
|
8109
|
-
authToken: this.authorizationToken,
|
|
8110
8174
|
timeoutMs
|
|
8111
8175
|
}
|
|
8112
8176
|
);
|
|
@@ -8133,8 +8197,8 @@ var Zkp2pClient = class {
|
|
|
8133
8197
|
);
|
|
8134
8198
|
}
|
|
8135
8199
|
/**
|
|
8136
|
-
* Internal-use endpoint. The curator route requires an internal `x-api-key`;
|
|
8137
|
-
* API keys will be rejected
|
|
8200
|
+
* Internal-use endpoint. The curator route requires an internal `x-api-key`; non-internal
|
|
8201
|
+
* API keys will be rejected. Returns 410 GONE when curator has marked the credential inactive
|
|
8138
8202
|
* or a stale credential fails its synchronous re-probe.
|
|
8139
8203
|
*
|
|
8140
8204
|
* Verify a seller payment via curator's seller-credential proxy.
|
|
@@ -8154,8 +8218,7 @@ var Zkp2pClient = class {
|
|
|
8154
8218
|
},
|
|
8155
8219
|
baseApiUrl,
|
|
8156
8220
|
timeoutMs,
|
|
8157
|
-
this.apiKey
|
|
8158
|
-
this.authorizationToken
|
|
8221
|
+
this.apiKey
|
|
8159
8222
|
);
|
|
8160
8223
|
}
|
|
8161
8224
|
// ╔═══════════════════════════════════════════════════════════════════════════╗
|