@fileverse-dev/formulajs 4.4.11-mod-68-patch-7 → 4.4.11-mod-68-patch-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/lib/browser/formula.js +121 -68
- package/lib/browser/formula.min.js +2 -2
- package/lib/browser/formula.min.js.map +1 -1
- package/lib/cjs/index.cjs +42 -29
- package/lib/esm/crypto-constants.mjs +2 -2
- package/lib/esm/index.mjs +42 -29
- package/package.json +1 -1
package/lib/cjs/index.cjs
CHANGED
|
@@ -13405,13 +13405,14 @@ async function handleScanRequest({
|
|
|
13405
13405
|
'all-txns': 'txlist',
|
|
13406
13406
|
'token-txns': 'tokentx',
|
|
13407
13407
|
'nft-txns': 'tokennfttx',
|
|
13408
|
-
gas: '
|
|
13408
|
+
'gas': 'gasoracle'
|
|
13409
13409
|
};
|
|
13410
13410
|
|
|
13411
13411
|
const action = ACTION_MAP[type];
|
|
13412
13412
|
if (!action) throw new ValidationError(`Invalid type: ${type}`)
|
|
13413
13413
|
|
|
13414
|
-
|
|
13414
|
+
const module = action === 'gasoracle' ? 'gastracker' : 'account';
|
|
13415
|
+
let url = `${baseUrl}?chainid=${chainId}&module=${module}&action=${action}&apikey=${apiKey}`;
|
|
13415
13416
|
|
|
13416
13417
|
if (['all-txns', 'token-txns', 'nft-txns'].includes(type)) {
|
|
13417
13418
|
url += `&address=${address}&startblock=0&endblock=99999999&sort=asc`;
|
|
@@ -13444,7 +13445,7 @@ async function handleScanRequest({
|
|
|
13444
13445
|
throw new RateLimitError(apiInfo.apiKeyName)
|
|
13445
13446
|
}
|
|
13446
13447
|
|
|
13447
|
-
return json.result
|
|
13448
|
+
return type === 'gas' && !Array.isArray(json.result) ? [json.result] : json.result
|
|
13448
13449
|
}
|
|
13449
13450
|
|
|
13450
13451
|
const fromUsernameToFid = async (username, apiKey) => {
|
|
@@ -17473,7 +17474,7 @@ const farcasterSchema = objectType({
|
|
|
17473
17474
|
contentType: enumType(['posts', 'replies', 'channels']),
|
|
17474
17475
|
identifier: stringType().nonempty(),
|
|
17475
17476
|
start: numberType().int().nonnegative().default(0),
|
|
17476
|
-
end: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
|
|
17477
|
+
end: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"end" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
|
|
17477
17478
|
});
|
|
17478
17479
|
|
|
17479
17480
|
const lensSchema = objectType({
|
|
@@ -17481,7 +17482,7 @@ const lensSchema = objectType({
|
|
|
17481
17482
|
contentType: enumType(['posts', 'replies']),
|
|
17482
17483
|
identifier: stringType().nonempty(),
|
|
17483
17484
|
start: numberType().int().nonnegative().default(0),
|
|
17484
|
-
end: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
|
|
17485
|
+
end: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"end" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
|
|
17485
17486
|
});
|
|
17486
17487
|
|
|
17487
17488
|
const fireflyParamsSchema = discriminatedUnionType('platform', [
|
|
@@ -17504,31 +17505,33 @@ const lensParamsSchema = objectType({
|
|
|
17504
17505
|
contentType: enumType(['posts', 'replies']),
|
|
17505
17506
|
identifier: stringType().nonempty(),
|
|
17506
17507
|
start: numberType().int().nonnegative().default(0),
|
|
17507
|
-
end: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
|
|
17508
|
+
end: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"end" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
|
|
17508
17509
|
});
|
|
17509
17510
|
|
|
17510
17511
|
const farcasterParamsSchema = objectType({
|
|
17511
17512
|
contentType: enumType(['posts', 'replies', 'channels']),
|
|
17512
17513
|
identifier: stringType().nonempty(),
|
|
17513
17514
|
start: numberType().int().nonnegative().default(0),
|
|
17514
|
-
end: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
|
|
17515
|
+
end: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"end" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
|
|
17515
17516
|
});
|
|
17516
17517
|
|
|
17517
17518
|
const dateStringToTimestamp = (val) => {
|
|
17518
|
-
const [
|
|
17519
|
-
|
|
17519
|
+
const [dd, mm, yyyy] = val.split('/');
|
|
17520
|
+
const date = new Date(`${yyyy}-${mm.padStart(2, '0')}-${dd.padStart(2, '0')}`);
|
|
17521
|
+
const timestamp = date.getTime();
|
|
17522
|
+
return isNaN(timestamp) ? NaN : Math.floor(timestamp / 1000);
|
|
17520
17523
|
};
|
|
17521
17524
|
|
|
17522
17525
|
/**
|
|
17523
|
-
* Accepts either a UNIX
|
|
17526
|
+
* Accepts either a UNIX timestamp number or a DD/MM/YYYY string,
|
|
17524
17527
|
* and always returns a nonnegative integer timestamp.
|
|
17525
17528
|
*/
|
|
17526
17529
|
const dateOrTimestamp = preprocessType(
|
|
17527
17530
|
(val) =>
|
|
17528
|
-
typeof val === 'string' && /^\d{2}\/\d{2}\/\d{4}$/.test(val)
|
|
17531
|
+
typeof val === 'string' && /^\d{1,2}\/\d{1,2}\/\d{4}$/.test(val)
|
|
17529
17532
|
? dateStringToTimestamp(val)
|
|
17530
17533
|
: val,
|
|
17531
|
-
numberType().int().nonnegative()
|
|
17534
|
+
numberType({ invalid_type_error: 'Date must be a valid DD/MM/YYYY or timestamp' }).int('Date must be an integer timestamp').nonnegative('Date must be a nonnegative timestamp').refine((n) => !isNaN(n), { message: 'Invalid date format or value: expected DD/MM/YYYY' })
|
|
17532
17535
|
);
|
|
17533
17536
|
|
|
17534
17537
|
const blockscoutParamsSchema = objectType({
|
|
@@ -17538,7 +17541,7 @@ const blockscoutParamsSchema = objectType({
|
|
|
17538
17541
|
startTimestamp: dateOrTimestamp.optional(),
|
|
17539
17542
|
endTimestamp: dateOrTimestamp.optional(),
|
|
17540
17543
|
page: numberType().int().nonnegative().default(1),
|
|
17541
|
-
offset: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
|
|
17544
|
+
offset: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"offset" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
|
|
17542
17545
|
});
|
|
17543
17546
|
|
|
17544
17547
|
const gasSchema$1 = objectType({
|
|
@@ -17546,7 +17549,7 @@ const gasSchema$1 = objectType({
|
|
|
17546
17549
|
startDate: dateOrTimestamp.optional(),
|
|
17547
17550
|
endDate: dateOrTimestamp.optional(),
|
|
17548
17551
|
page: numberType().int().nonnegative().default(1),
|
|
17549
|
-
limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
|
|
17552
|
+
limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"limit" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
|
|
17550
17553
|
});
|
|
17551
17554
|
|
|
17552
17555
|
const txnSchema$1 = objectType({
|
|
@@ -17555,7 +17558,7 @@ const txnSchema$1 = objectType({
|
|
|
17555
17558
|
startDate: dateOrTimestamp.optional(),
|
|
17556
17559
|
endDate: dateOrTimestamp.optional(),
|
|
17557
17560
|
page: numberType().int().nonnegative().default(1),
|
|
17558
|
-
limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
|
|
17561
|
+
limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"limit" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
|
|
17559
17562
|
});
|
|
17560
17563
|
|
|
17561
17564
|
const baseParamsSchema = discriminatedUnionType('type', [gasSchema$1, txnSchema$1]);
|
|
@@ -17565,7 +17568,7 @@ const gasSchema = objectType({
|
|
|
17565
17568
|
startDate: dateOrTimestamp.optional(),
|
|
17566
17569
|
endDate: dateOrTimestamp.optional(),
|
|
17567
17570
|
page: numberType().int().nonnegative().default(1),
|
|
17568
|
-
limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
|
|
17571
|
+
limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"limit" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
|
|
17569
17572
|
});
|
|
17570
17573
|
|
|
17571
17574
|
const txnSchema = objectType({
|
|
@@ -17575,11 +17578,21 @@ const txnSchema = objectType({
|
|
|
17575
17578
|
endDate: dateOrTimestamp.optional(),
|
|
17576
17579
|
chain: enumType(['ethereum','base','gnosis']),
|
|
17577
17580
|
page: numberType().int().nonnegative().default(1),
|
|
17578
|
-
limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
|
|
17581
|
+
limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"limit" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
|
|
17579
17582
|
});
|
|
17580
17583
|
|
|
17581
17584
|
const etherscanParamsSchema = discriminatedUnionType('type', [gasSchema, txnSchema]);
|
|
17582
17585
|
|
|
17586
|
+
const allowedValues = ['1h', '24h', '7d'];
|
|
17587
|
+
const param2Schema = stringType()
|
|
17588
|
+
.refine((val) => {
|
|
17589
|
+
const tokens = val.split(',').map((t) => t.trim().toLowerCase());
|
|
17590
|
+
return tokens.some((token) =>
|
|
17591
|
+
allowedValues.some((allowed) => token.includes(allowed))
|
|
17592
|
+
);
|
|
17593
|
+
}, {
|
|
17594
|
+
message: "param2 must contain at least one of: '1h', '24h', '7d'",
|
|
17595
|
+
}).optional();
|
|
17583
17596
|
const priceSchema = objectType({
|
|
17584
17597
|
category: literalType('price'),
|
|
17585
17598
|
param1: stringType().nonempty(),
|
|
@@ -17589,13 +17602,13 @@ const marketEcosystems = ['all','base','meme','aiagents','bitcoin','ethereum','h
|
|
|
17589
17602
|
const marketSchema = objectType({
|
|
17590
17603
|
category: literalType('market'),
|
|
17591
17604
|
param1: enumType(marketEcosystems),
|
|
17592
|
-
param2:
|
|
17605
|
+
param2: param2Schema,
|
|
17593
17606
|
});
|
|
17594
17607
|
const stablecoinsTypes = ['all','yield-bearing-stablecoins','crypto-backed-stablecoin'];
|
|
17595
17608
|
const stablecoinsSchema = objectType({
|
|
17596
17609
|
category: literalType('stablecoins'),
|
|
17597
17610
|
param1: enumType(stablecoinsTypes),
|
|
17598
|
-
param2:
|
|
17611
|
+
param2: param2Schema,
|
|
17599
17612
|
});
|
|
17600
17613
|
const derivativesSchema = objectType({
|
|
17601
17614
|
category: literalType('derivatives'),
|
|
@@ -17623,7 +17636,7 @@ const baseSchema = objectType({
|
|
|
17623
17636
|
startTime: dateOrTimestamp.optional(),
|
|
17624
17637
|
endTime: dateOrTimestamp.optional(),
|
|
17625
17638
|
page: numberType().int().nonnegative().default(1),
|
|
17626
|
-
offset: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
|
|
17639
|
+
offset: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"offset" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
|
|
17627
17640
|
});
|
|
17628
17641
|
|
|
17629
17642
|
const eoaParamsSchema = preprocessType(
|
|
@@ -17652,7 +17665,7 @@ const safeParamsSchema = objectType({
|
|
|
17652
17665
|
address: stringType().nonempty(),
|
|
17653
17666
|
utility: literalType('txns'),
|
|
17654
17667
|
chain: enumType(['ethereum','gnosis']),
|
|
17655
|
-
limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
|
|
17668
|
+
limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"limit" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
|
|
17656
17669
|
offset: numberType().int().nonnegative().default(0),
|
|
17657
17670
|
});
|
|
17658
17671
|
|
|
@@ -17716,7 +17729,7 @@ async function FIREFLY() {
|
|
|
17716
17729
|
url.searchParams.set('start', String(start));
|
|
17717
17730
|
url.searchParams.set('end', String(end));
|
|
17718
17731
|
|
|
17719
|
-
const { URL: finalUrl, HEADERS } = getUrlAndHeaders({ url: url.toString(), serviceName: 'Firefly', headers });
|
|
17732
|
+
const { URL: finalUrl, HEADERS } = getUrlAndHeaders({ url: url.toString(), serviceName: 'Firefly', headers: { 'x-api-key': apiKey } });
|
|
17720
17733
|
const response = await fetch(finalUrl, {
|
|
17721
17734
|
method: 'GET',
|
|
17722
17735
|
headers: HEADERS,
|
|
@@ -17784,7 +17797,7 @@ async function LENS() {
|
|
|
17784
17797
|
url.searchParams.set('start', String(start));
|
|
17785
17798
|
url.searchParams.set('end', String(end));
|
|
17786
17799
|
|
|
17787
|
-
const { URL: finalUrl, HEADERS } = getUrlAndHeaders({ url: url.toString(), serviceName: 'Firefly', headers });
|
|
17800
|
+
const { URL: finalUrl, HEADERS } = getUrlAndHeaders({ url: url.toString(), serviceName: 'Firefly', headers: { 'x-api-key': apiKey } });
|
|
17788
17801
|
|
|
17789
17802
|
const response = await fetch(finalUrl, {
|
|
17790
17803
|
method: 'GET',
|
|
@@ -17849,7 +17862,7 @@ async function FARCASTER() {
|
|
|
17849
17862
|
url.searchParams.set('start', String(start));
|
|
17850
17863
|
url.searchParams.set('end', String(end));
|
|
17851
17864
|
|
|
17852
|
-
const { URL: finalUrl, HEADERS } = getUrlAndHeaders({ url: url.toString(), serviceName: 'Firefly', headers });
|
|
17865
|
+
const { URL: finalUrl, HEADERS } = getUrlAndHeaders({ url: url.toString(), serviceName: 'Firefly', headers: { 'x-api-key': apiKey } });
|
|
17853
17866
|
|
|
17854
17867
|
const response = await fetch(finalUrl, {
|
|
17855
17868
|
method: 'GET',
|
|
@@ -18040,12 +18053,12 @@ async function NEYNAR() {
|
|
|
18040
18053
|
const url = `https://api.neynar.com/v2/farcaster/followers?fid=${fid}`;
|
|
18041
18054
|
|
|
18042
18055
|
const { URL: finalUrl, HEADERS } = getUrlAndHeaders({
|
|
18043
|
-
url: url.toString(), serviceName: 'Firefly',
|
|
18056
|
+
url: url.toString(), serviceName: 'Firefly',
|
|
18044
18057
|
headers: {
|
|
18045
|
-
'x-api-key':
|
|
18058
|
+
'x-api-key': apiKey,
|
|
18046
18059
|
'x-neynar-experimental': 'false'
|
|
18047
18060
|
}
|
|
18048
|
-
|
|
18061
|
+
|
|
18049
18062
|
});
|
|
18050
18063
|
|
|
18051
18064
|
const response = await fetch(finalUrl, {
|
|
@@ -18359,8 +18372,8 @@ async function SAFE() {
|
|
|
18359
18372
|
|
|
18360
18373
|
const url = `https://api.safe.global/tx-service/${chainId}/api/v2/safes/${resolved}/multisig-transactions?limit=${limit}&offset=${offset}`;
|
|
18361
18374
|
|
|
18362
|
-
|
|
18363
|
-
const res = await fetch(
|
|
18375
|
+
const { URL: finalUrl, HEADERS } = getUrlAndHeaders({ url, serviceName: 'Etherscan', headers: { Authorization: `Bearer ${apiKey}` } });
|
|
18376
|
+
const res = await fetch(finalUrl, { headers: HEADERS });
|
|
18364
18377
|
if (!res.ok) throw new NetworkError(SERVICES_API_KEY.Safe, res.status)
|
|
18365
18378
|
const json = await res.json();
|
|
18366
18379
|
|
|
@@ -286,14 +286,14 @@ If "derivatives": exchange name (e.g., "binance_futures", "hyperliquid", "weex-f
|
|
|
286
286
|
{
|
|
287
287
|
name: "page",
|
|
288
288
|
detail: "Page number for paginated transaction results. Applies only to 'txns', 'token-txns', and 'nft-txns'.",
|
|
289
|
-
example: `
|
|
289
|
+
example: `1`,
|
|
290
290
|
require: "o",
|
|
291
291
|
type: "number"
|
|
292
292
|
},
|
|
293
293
|
{
|
|
294
294
|
name: "offset",
|
|
295
295
|
detail: "Number of results per page (limit). Applies only to 'txns', 'token-txns', and 'nft-txns'.",
|
|
296
|
-
example: `
|
|
296
|
+
example: `50`,
|
|
297
297
|
require: "o",
|
|
298
298
|
type: "number"
|
|
299
299
|
}
|
package/lib/esm/index.mjs
CHANGED
|
@@ -13403,13 +13403,14 @@ async function handleScanRequest({
|
|
|
13403
13403
|
'all-txns': 'txlist',
|
|
13404
13404
|
'token-txns': 'tokentx',
|
|
13405
13405
|
'nft-txns': 'tokennfttx',
|
|
13406
|
-
gas: '
|
|
13406
|
+
'gas': 'gasoracle'
|
|
13407
13407
|
};
|
|
13408
13408
|
|
|
13409
13409
|
const action = ACTION_MAP[type];
|
|
13410
13410
|
if (!action) throw new ValidationError(`Invalid type: ${type}`)
|
|
13411
13411
|
|
|
13412
|
-
|
|
13412
|
+
const module = action === 'gasoracle' ? 'gastracker' : 'account';
|
|
13413
|
+
let url = `${baseUrl}?chainid=${chainId}&module=${module}&action=${action}&apikey=${apiKey}`;
|
|
13413
13414
|
|
|
13414
13415
|
if (['all-txns', 'token-txns', 'nft-txns'].includes(type)) {
|
|
13415
13416
|
url += `&address=${address}&startblock=0&endblock=99999999&sort=asc`;
|
|
@@ -13442,7 +13443,7 @@ async function handleScanRequest({
|
|
|
13442
13443
|
throw new RateLimitError(apiInfo.apiKeyName)
|
|
13443
13444
|
}
|
|
13444
13445
|
|
|
13445
|
-
return json.result
|
|
13446
|
+
return type === 'gas' && !Array.isArray(json.result) ? [json.result] : json.result
|
|
13446
13447
|
}
|
|
13447
13448
|
|
|
13448
13449
|
const fromUsernameToFid = async (username, apiKey) => {
|
|
@@ -17471,7 +17472,7 @@ const farcasterSchema = objectType({
|
|
|
17471
17472
|
contentType: enumType(['posts', 'replies', 'channels']),
|
|
17472
17473
|
identifier: stringType().nonempty(),
|
|
17473
17474
|
start: numberType().int().nonnegative().default(0),
|
|
17474
|
-
end: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
|
|
17475
|
+
end: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"end" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
|
|
17475
17476
|
});
|
|
17476
17477
|
|
|
17477
17478
|
const lensSchema = objectType({
|
|
@@ -17479,7 +17480,7 @@ const lensSchema = objectType({
|
|
|
17479
17480
|
contentType: enumType(['posts', 'replies']),
|
|
17480
17481
|
identifier: stringType().nonempty(),
|
|
17481
17482
|
start: numberType().int().nonnegative().default(0),
|
|
17482
|
-
end: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
|
|
17483
|
+
end: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"end" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
|
|
17483
17484
|
});
|
|
17484
17485
|
|
|
17485
17486
|
const fireflyParamsSchema = discriminatedUnionType('platform', [
|
|
@@ -17502,31 +17503,33 @@ const lensParamsSchema = objectType({
|
|
|
17502
17503
|
contentType: enumType(['posts', 'replies']),
|
|
17503
17504
|
identifier: stringType().nonempty(),
|
|
17504
17505
|
start: numberType().int().nonnegative().default(0),
|
|
17505
|
-
end: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
|
|
17506
|
+
end: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"end" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
|
|
17506
17507
|
});
|
|
17507
17508
|
|
|
17508
17509
|
const farcasterParamsSchema = objectType({
|
|
17509
17510
|
contentType: enumType(['posts', 'replies', 'channels']),
|
|
17510
17511
|
identifier: stringType().nonempty(),
|
|
17511
17512
|
start: numberType().int().nonnegative().default(0),
|
|
17512
|
-
end: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
|
|
17513
|
+
end: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"end" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
|
|
17513
17514
|
});
|
|
17514
17515
|
|
|
17515
17516
|
const dateStringToTimestamp = (val) => {
|
|
17516
|
-
const [
|
|
17517
|
-
|
|
17517
|
+
const [dd, mm, yyyy] = val.split('/');
|
|
17518
|
+
const date = new Date(`${yyyy}-${mm.padStart(2, '0')}-${dd.padStart(2, '0')}`);
|
|
17519
|
+
const timestamp = date.getTime();
|
|
17520
|
+
return isNaN(timestamp) ? NaN : Math.floor(timestamp / 1000);
|
|
17518
17521
|
};
|
|
17519
17522
|
|
|
17520
17523
|
/**
|
|
17521
|
-
* Accepts either a UNIX
|
|
17524
|
+
* Accepts either a UNIX timestamp number or a DD/MM/YYYY string,
|
|
17522
17525
|
* and always returns a nonnegative integer timestamp.
|
|
17523
17526
|
*/
|
|
17524
17527
|
const dateOrTimestamp = preprocessType(
|
|
17525
17528
|
(val) =>
|
|
17526
|
-
typeof val === 'string' && /^\d{2}\/\d{2}\/\d{4}$/.test(val)
|
|
17529
|
+
typeof val === 'string' && /^\d{1,2}\/\d{1,2}\/\d{4}$/.test(val)
|
|
17527
17530
|
? dateStringToTimestamp(val)
|
|
17528
17531
|
: val,
|
|
17529
|
-
numberType().int().nonnegative()
|
|
17532
|
+
numberType({ invalid_type_error: 'Date must be a valid DD/MM/YYYY or timestamp' }).int('Date must be an integer timestamp').nonnegative('Date must be a nonnegative timestamp').refine((n) => !isNaN(n), { message: 'Invalid date format or value: expected DD/MM/YYYY' })
|
|
17530
17533
|
);
|
|
17531
17534
|
|
|
17532
17535
|
const blockscoutParamsSchema = objectType({
|
|
@@ -17536,7 +17539,7 @@ const blockscoutParamsSchema = objectType({
|
|
|
17536
17539
|
startTimestamp: dateOrTimestamp.optional(),
|
|
17537
17540
|
endTimestamp: dateOrTimestamp.optional(),
|
|
17538
17541
|
page: numberType().int().nonnegative().default(1),
|
|
17539
|
-
offset: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
|
|
17542
|
+
offset: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"offset" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
|
|
17540
17543
|
});
|
|
17541
17544
|
|
|
17542
17545
|
const gasSchema$1 = objectType({
|
|
@@ -17544,7 +17547,7 @@ const gasSchema$1 = objectType({
|
|
|
17544
17547
|
startDate: dateOrTimestamp.optional(),
|
|
17545
17548
|
endDate: dateOrTimestamp.optional(),
|
|
17546
17549
|
page: numberType().int().nonnegative().default(1),
|
|
17547
|
-
limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
|
|
17550
|
+
limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"limit" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
|
|
17548
17551
|
});
|
|
17549
17552
|
|
|
17550
17553
|
const txnSchema$1 = objectType({
|
|
@@ -17553,7 +17556,7 @@ const txnSchema$1 = objectType({
|
|
|
17553
17556
|
startDate: dateOrTimestamp.optional(),
|
|
17554
17557
|
endDate: dateOrTimestamp.optional(),
|
|
17555
17558
|
page: numberType().int().nonnegative().default(1),
|
|
17556
|
-
limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
|
|
17559
|
+
limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"limit" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
|
|
17557
17560
|
});
|
|
17558
17561
|
|
|
17559
17562
|
const baseParamsSchema = discriminatedUnionType('type', [gasSchema$1, txnSchema$1]);
|
|
@@ -17563,7 +17566,7 @@ const gasSchema = objectType({
|
|
|
17563
17566
|
startDate: dateOrTimestamp.optional(),
|
|
17564
17567
|
endDate: dateOrTimestamp.optional(),
|
|
17565
17568
|
page: numberType().int().nonnegative().default(1),
|
|
17566
|
-
limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
|
|
17569
|
+
limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"limit" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
|
|
17567
17570
|
});
|
|
17568
17571
|
|
|
17569
17572
|
const txnSchema = objectType({
|
|
@@ -17573,11 +17576,21 @@ const txnSchema = objectType({
|
|
|
17573
17576
|
endDate: dateOrTimestamp.optional(),
|
|
17574
17577
|
chain: enumType(['ethereum','base','gnosis']),
|
|
17575
17578
|
page: numberType().int().nonnegative().default(1),
|
|
17576
|
-
limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
|
|
17579
|
+
limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"limit" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
|
|
17577
17580
|
});
|
|
17578
17581
|
|
|
17579
17582
|
const etherscanParamsSchema = discriminatedUnionType('type', [gasSchema, txnSchema]);
|
|
17580
17583
|
|
|
17584
|
+
const allowedValues = ['1h', '24h', '7d'];
|
|
17585
|
+
const param2Schema = stringType()
|
|
17586
|
+
.refine((val) => {
|
|
17587
|
+
const tokens = val.split(',').map((t) => t.trim().toLowerCase());
|
|
17588
|
+
return tokens.some((token) =>
|
|
17589
|
+
allowedValues.some((allowed) => token.includes(allowed))
|
|
17590
|
+
);
|
|
17591
|
+
}, {
|
|
17592
|
+
message: "param2 must contain at least one of: '1h', '24h', '7d'",
|
|
17593
|
+
}).optional();
|
|
17581
17594
|
const priceSchema = objectType({
|
|
17582
17595
|
category: literalType('price'),
|
|
17583
17596
|
param1: stringType().nonempty(),
|
|
@@ -17587,13 +17600,13 @@ const marketEcosystems = ['all','base','meme','aiagents','bitcoin','ethereum','h
|
|
|
17587
17600
|
const marketSchema = objectType({
|
|
17588
17601
|
category: literalType('market'),
|
|
17589
17602
|
param1: enumType(marketEcosystems),
|
|
17590
|
-
param2:
|
|
17603
|
+
param2: param2Schema,
|
|
17591
17604
|
});
|
|
17592
17605
|
const stablecoinsTypes = ['all','yield-bearing-stablecoins','crypto-backed-stablecoin'];
|
|
17593
17606
|
const stablecoinsSchema = objectType({
|
|
17594
17607
|
category: literalType('stablecoins'),
|
|
17595
17608
|
param1: enumType(stablecoinsTypes),
|
|
17596
|
-
param2:
|
|
17609
|
+
param2: param2Schema,
|
|
17597
17610
|
});
|
|
17598
17611
|
const derivativesSchema = objectType({
|
|
17599
17612
|
category: literalType('derivatives'),
|
|
@@ -17621,7 +17634,7 @@ const baseSchema = objectType({
|
|
|
17621
17634
|
startTime: dateOrTimestamp.optional(),
|
|
17622
17635
|
endTime: dateOrTimestamp.optional(),
|
|
17623
17636
|
page: numberType().int().nonnegative().default(1),
|
|
17624
|
-
offset: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
|
|
17637
|
+
offset: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"offset" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
|
|
17625
17638
|
});
|
|
17626
17639
|
|
|
17627
17640
|
const eoaParamsSchema = preprocessType(
|
|
@@ -17650,7 +17663,7 @@ const safeParamsSchema = objectType({
|
|
|
17650
17663
|
address: stringType().nonempty(),
|
|
17651
17664
|
utility: literalType('txns'),
|
|
17652
17665
|
chain: enumType(['ethereum','gnosis']),
|
|
17653
|
-
limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
|
|
17666
|
+
limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"limit" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
|
|
17654
17667
|
offset: numberType().int().nonnegative().default(0),
|
|
17655
17668
|
});
|
|
17656
17669
|
|
|
@@ -17714,7 +17727,7 @@ async function FIREFLY() {
|
|
|
17714
17727
|
url.searchParams.set('start', String(start));
|
|
17715
17728
|
url.searchParams.set('end', String(end));
|
|
17716
17729
|
|
|
17717
|
-
const { URL: finalUrl, HEADERS } = getUrlAndHeaders({ url: url.toString(), serviceName: 'Firefly', headers });
|
|
17730
|
+
const { URL: finalUrl, HEADERS } = getUrlAndHeaders({ url: url.toString(), serviceName: 'Firefly', headers: { 'x-api-key': apiKey } });
|
|
17718
17731
|
const response = await fetch(finalUrl, {
|
|
17719
17732
|
method: 'GET',
|
|
17720
17733
|
headers: HEADERS,
|
|
@@ -17782,7 +17795,7 @@ async function LENS() {
|
|
|
17782
17795
|
url.searchParams.set('start', String(start));
|
|
17783
17796
|
url.searchParams.set('end', String(end));
|
|
17784
17797
|
|
|
17785
|
-
const { URL: finalUrl, HEADERS } = getUrlAndHeaders({ url: url.toString(), serviceName: 'Firefly', headers });
|
|
17798
|
+
const { URL: finalUrl, HEADERS } = getUrlAndHeaders({ url: url.toString(), serviceName: 'Firefly', headers: { 'x-api-key': apiKey } });
|
|
17786
17799
|
|
|
17787
17800
|
const response = await fetch(finalUrl, {
|
|
17788
17801
|
method: 'GET',
|
|
@@ -17847,7 +17860,7 @@ async function FARCASTER() {
|
|
|
17847
17860
|
url.searchParams.set('start', String(start));
|
|
17848
17861
|
url.searchParams.set('end', String(end));
|
|
17849
17862
|
|
|
17850
|
-
const { URL: finalUrl, HEADERS } = getUrlAndHeaders({ url: url.toString(), serviceName: 'Firefly', headers });
|
|
17863
|
+
const { URL: finalUrl, HEADERS } = getUrlAndHeaders({ url: url.toString(), serviceName: 'Firefly', headers: { 'x-api-key': apiKey } });
|
|
17851
17864
|
|
|
17852
17865
|
const response = await fetch(finalUrl, {
|
|
17853
17866
|
method: 'GET',
|
|
@@ -18038,12 +18051,12 @@ async function NEYNAR() {
|
|
|
18038
18051
|
const url = `https://api.neynar.com/v2/farcaster/followers?fid=${fid}`;
|
|
18039
18052
|
|
|
18040
18053
|
const { URL: finalUrl, HEADERS } = getUrlAndHeaders({
|
|
18041
|
-
url: url.toString(), serviceName: 'Firefly',
|
|
18054
|
+
url: url.toString(), serviceName: 'Firefly',
|
|
18042
18055
|
headers: {
|
|
18043
|
-
'x-api-key':
|
|
18056
|
+
'x-api-key': apiKey,
|
|
18044
18057
|
'x-neynar-experimental': 'false'
|
|
18045
18058
|
}
|
|
18046
|
-
|
|
18059
|
+
|
|
18047
18060
|
});
|
|
18048
18061
|
|
|
18049
18062
|
const response = await fetch(finalUrl, {
|
|
@@ -18357,8 +18370,8 @@ async function SAFE() {
|
|
|
18357
18370
|
|
|
18358
18371
|
const url = `https://api.safe.global/tx-service/${chainId}/api/v2/safes/${resolved}/multisig-transactions?limit=${limit}&offset=${offset}`;
|
|
18359
18372
|
|
|
18360
|
-
|
|
18361
|
-
const res = await fetch(
|
|
18373
|
+
const { URL: finalUrl, HEADERS } = getUrlAndHeaders({ url, serviceName: 'Etherscan', headers: { Authorization: `Bearer ${apiKey}` } });
|
|
18374
|
+
const res = await fetch(finalUrl, { headers: HEADERS });
|
|
18362
18375
|
if (!res.ok) throw new NetworkError(SERVICES_API_KEY.Safe, res.status)
|
|
18363
18376
|
const json = await res.json();
|
|
18364
18377
|
|
package/package.json
CHANGED