@zkp2p/sdk 0.5.6 → 0.5.8
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/dist/index.cjs +16 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +16 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -42314,9 +42314,11 @@ async function apiSignIntentV3(request, opts) {
|
|
|
42314
42314
|
async () => {
|
|
42315
42315
|
let res;
|
|
42316
42316
|
try {
|
|
42317
|
+
const headers2 = { "Content-Type": "application/json" };
|
|
42318
|
+
if (opts.apiKey) headers2["x-api-key"] = opts.apiKey;
|
|
42317
42319
|
res = await fetch(url, {
|
|
42318
42320
|
method: "POST",
|
|
42319
|
-
headers:
|
|
42321
|
+
headers: headers2,
|
|
42320
42322
|
body: JSON.stringify(request)
|
|
42321
42323
|
});
|
|
42322
42324
|
} catch (error) {
|
|
@@ -43061,6 +43063,7 @@ var IntentOperations = class {
|
|
|
43061
43063
|
if ((!gatingServiceSignature || !signatureExpiration) && baseApiUrl) {
|
|
43062
43064
|
const apiOpts = {
|
|
43063
43065
|
baseApiUrl,
|
|
43066
|
+
apiKey: this.config.getApiKey(),
|
|
43064
43067
|
timeoutMs: this.config.getApiTimeoutMs()
|
|
43065
43068
|
};
|
|
43066
43069
|
const response = await apiSignIntentV3(
|
|
@@ -47219,7 +47222,7 @@ async function apiPostDepositDetails(req, baseApiUrl, timeoutMs) {
|
|
|
47219
47222
|
timeoutMs
|
|
47220
47223
|
});
|
|
47221
47224
|
}
|
|
47222
|
-
async function apiGetQuote(req, baseApiUrl, timeoutMs) {
|
|
47225
|
+
async function apiGetQuote(req, baseApiUrl, timeoutMs, apiKey) {
|
|
47223
47226
|
if (req.quotesToReturn !== void 0) {
|
|
47224
47227
|
if (!Number.isInteger(req.quotesToReturn) || req.quotesToReturn < 1) {
|
|
47225
47228
|
throw new exports.ValidationError("quotesToReturn must be a positive integer", "quotesToReturn");
|
|
@@ -47254,10 +47257,11 @@ async function apiGetQuote(req, baseApiUrl, timeoutMs) {
|
|
|
47254
47257
|
url,
|
|
47255
47258
|
method: "POST",
|
|
47256
47259
|
body: requestBody,
|
|
47260
|
+
apiKey,
|
|
47257
47261
|
timeoutMs
|
|
47258
47262
|
});
|
|
47259
47263
|
}
|
|
47260
|
-
async function apiGetQuotesBestByPlatform(req, baseApiUrl, timeoutMs) {
|
|
47264
|
+
async function apiGetQuotesBestByPlatform(req, baseApiUrl, timeoutMs, apiKey) {
|
|
47261
47265
|
const isExactFiat = req.isExactFiat !== false;
|
|
47262
47266
|
const endpoint = isExactFiat ? "best-by-platform" : "best-by-platform-exact-token";
|
|
47263
47267
|
const url = `${withApiBase(baseApiUrl)}/v2/quote/${endpoint}`;
|
|
@@ -47275,6 +47279,7 @@ async function apiGetQuotesBestByPlatform(req, baseApiUrl, timeoutMs) {
|
|
|
47275
47279
|
url,
|
|
47276
47280
|
method: "POST",
|
|
47277
47281
|
body: requestBody,
|
|
47282
|
+
apiKey,
|
|
47278
47283
|
timeoutMs
|
|
47279
47284
|
});
|
|
47280
47285
|
}
|
|
@@ -48697,6 +48702,7 @@ var Zkp2pClient = class {
|
|
|
48697
48702
|
getChainId: () => this.chainId,
|
|
48698
48703
|
getRuntimeEnv: () => this.runtimeEnv,
|
|
48699
48704
|
getBaseApiUrl: () => this.baseApiUrl,
|
|
48705
|
+
getApiKey: () => this.apiKey,
|
|
48700
48706
|
getApiTimeoutMs: () => this.apiTimeoutMs,
|
|
48701
48707
|
getProtocolViewerAddress: () => this.protocolViewerAddress,
|
|
48702
48708
|
getProtocolViewerAbi: () => this.protocolViewerAbi,
|
|
@@ -49952,7 +49958,7 @@ var Zkp2pClient = class {
|
|
|
49952
49958
|
reqWithEscrow.escrowAddresses = configuredEscrows;
|
|
49953
49959
|
}
|
|
49954
49960
|
}
|
|
49955
|
-
const quote = await apiGetQuote(reqWithEscrow, baseApiUrl, timeoutMs);
|
|
49961
|
+
const quote = await apiGetQuote(reqWithEscrow, baseApiUrl, timeoutMs, this.apiKey);
|
|
49956
49962
|
const quotes = quote?.responseObject?.quotes ?? [];
|
|
49957
49963
|
for (const q of quotes) {
|
|
49958
49964
|
const maker = q?.maker;
|
|
@@ -49990,7 +49996,12 @@ var Zkp2pClient = class {
|
|
|
49990
49996
|
reqWithEscrow.escrowAddresses = configuredEscrows;
|
|
49991
49997
|
}
|
|
49992
49998
|
}
|
|
49993
|
-
const quote = await apiGetQuotesBestByPlatform(
|
|
49999
|
+
const quote = await apiGetQuotesBestByPlatform(
|
|
50000
|
+
reqWithEscrow,
|
|
50001
|
+
baseApiUrl,
|
|
50002
|
+
timeoutMs,
|
|
50003
|
+
this.apiKey
|
|
50004
|
+
);
|
|
49994
50005
|
const enrichedQuote = quote ? {
|
|
49995
50006
|
...quote,
|
|
49996
50007
|
responseObject: {
|