@pear-protocol/utils 0.4.1 → 0.4.2
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.js +5 -1
- package/dist/sync/compute.d.ts +2 -2
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import BigNumber9 from 'bignumber.js';
|
|
2
2
|
import { sha256 } from '@noble/hashes/sha256';
|
|
3
3
|
import { bytesToHex } from '@noble/hashes/utils';
|
|
4
|
+
import { WATERMARK_FUTURE_SKEW_MS } from '@pear-protocol/types';
|
|
4
5
|
|
|
5
6
|
// src/asset/compute.ts
|
|
6
7
|
function parse(value) {
|
|
@@ -1663,7 +1664,10 @@ function _isValidExternalQuantity(quantity) {
|
|
|
1663
1664
|
return isGreaterThan(quantity, ZERO);
|
|
1664
1665
|
}
|
|
1665
1666
|
function _isValidExternalTimestamp(timestamp) {
|
|
1666
|
-
|
|
1667
|
+
if (!Number.isFinite(timestamp) || timestamp < 0) {
|
|
1668
|
+
return false;
|
|
1669
|
+
}
|
|
1670
|
+
return timestamp <= Date.now() + WATERMARK_FUTURE_SKEW_MS;
|
|
1667
1671
|
}
|
|
1668
1672
|
function groupConfirmablesByPosition(confirmableFills) {
|
|
1669
1673
|
return confirmableFills.reduce((acc, fill) => {
|
package/dist/sync/compute.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type HttpTypes } from '@pear-protocol/types';
|
|
2
2
|
import type { ComputeSyncPayloadArgs, ComputeSyncPayloadResult } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* Derive the full sync payload from raw exchange data and local state.
|
|
@@ -29,5 +29,5 @@ export declare function _normalizeCloid(cloid?: string | null): string | undefin
|
|
|
29
29
|
export declare function _normalizeExchangeFillId(exchangeFillId?: string | null): string | undefined;
|
|
30
30
|
/** Rejects scientific-notation quantities (e.g. 1e-8) that cannot be safely parsed as fills. */
|
|
31
31
|
export declare function _isValidExternalQuantity(quantity: string): boolean;
|
|
32
|
-
/** Returns true only when the timestamp is a non-negative finite number. */
|
|
32
|
+
/** Returns true only when the timestamp is a non-negative finite number no further than clock skew ahead of now. */
|
|
33
33
|
export declare function _isValidExternalTimestamp(timestamp: number): boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pear-protocol/utils",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "Pear Protocol Utility functions",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@noble/hashes": "^1.3.2",
|
|
30
|
-
"@pear-protocol/types": "^1.
|
|
30
|
+
"@pear-protocol/types": "^1.16.0",
|
|
31
31
|
"bignumber.js": "9.3.1"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|