@ensnode/ensnode-sdk 1.10.0 → 1.10.1
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 +29 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +29 -1
- package/dist/index.d.ts +29 -1
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -188,10 +188,12 @@ __export(index_exports, {
|
|
|
188
188
|
makeENSApiPublicConfigSchema: () => makeENSApiPublicConfigSchema,
|
|
189
189
|
makeEnsApiPublicConfigSchema: () => makeEnsApiPublicConfigSchema,
|
|
190
190
|
makeSerializedEnsApiPublicConfigSchema: () => makeSerializedEnsApiPublicConfigSchema,
|
|
191
|
+
maxPrice: () => maxPrice,
|
|
191
192
|
maybeGetDatasourceContract: () => maybeGetDatasourceContract,
|
|
192
193
|
maybeGetENSv2RootRegistry: () => maybeGetENSv2RootRegistry,
|
|
193
194
|
maybeGetENSv2RootRegistryId: () => maybeGetENSv2RootRegistryId,
|
|
194
195
|
mergeBlockNumberRanges: () => mergeBlockNumberRanges,
|
|
196
|
+
minPrice: () => minPrice,
|
|
195
197
|
nameTokensPrerequisites: () => nameTokensPrerequisites,
|
|
196
198
|
parseAccountId: () => parseAccountId,
|
|
197
199
|
parseAssetId: () => parseAssetId,
|
|
@@ -239,6 +241,7 @@ __export(index_exports, {
|
|
|
239
241
|
serializeUrl: () => serializeUrl,
|
|
240
242
|
sortChainStatusesByStartBlockAsc: () => sortChainStatusesByStartBlockAsc,
|
|
241
243
|
stripNullBytes: () => stripNullBytes,
|
|
244
|
+
subtractPrice: () => subtractPrice,
|
|
242
245
|
translateDefaultableChainIdToChainId: () => translateDefaultableChainIdToChainId,
|
|
243
246
|
uniq: () => uniq,
|
|
244
247
|
validateChainIndexingStatusSnapshot: () => validateChainIndexingStatusSnapshot,
|
|
@@ -392,6 +395,32 @@ function addPrices(...prices) {
|
|
|
392
395
|
}
|
|
393
396
|
);
|
|
394
397
|
}
|
|
398
|
+
function subtractPrice(a, b) {
|
|
399
|
+
if (!isPriceCurrencyEqual(a, b)) {
|
|
400
|
+
throw new Error("All prices must have the same currency to be subtracted.");
|
|
401
|
+
}
|
|
402
|
+
const resultAmount = a.amount - b.amount;
|
|
403
|
+
if (resultAmount < 0n) {
|
|
404
|
+
throw new Error("subtractPrice result must be non-negative.");
|
|
405
|
+
}
|
|
406
|
+
return { amount: resultAmount, currency: a.currency };
|
|
407
|
+
}
|
|
408
|
+
function minPrice(...prices) {
|
|
409
|
+
const firstPrice = prices[0];
|
|
410
|
+
const allPricesInSameCurrency = prices.every((price) => isPriceCurrencyEqual(firstPrice, price));
|
|
411
|
+
if (allPricesInSameCurrency === false) {
|
|
412
|
+
throw new Error("All prices must have the same currency to be compared.");
|
|
413
|
+
}
|
|
414
|
+
return prices.reduce((acc, price) => price.amount < acc.amount ? price : acc);
|
|
415
|
+
}
|
|
416
|
+
function maxPrice(...prices) {
|
|
417
|
+
const firstPrice = prices[0];
|
|
418
|
+
const allPricesInSameCurrency = prices.every((price) => isPriceCurrencyEqual(firstPrice, price));
|
|
419
|
+
if (allPricesInSameCurrency === false) {
|
|
420
|
+
throw new Error("All prices must have the same currency to be compared.");
|
|
421
|
+
}
|
|
422
|
+
return prices.reduce((acc, price) => price.amount > acc.amount ? price : acc);
|
|
423
|
+
}
|
|
395
424
|
function scalePrice(price, scaleFactor) {
|
|
396
425
|
const scaledAmount = scaleBigintByNumber(price.amount, scaleFactor);
|
|
397
426
|
return {
|