@metamask/utils 8.4.0 → 8.5.0
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/CHANGELOG.md +14 -1
- package/dist/assert.cjs +127 -0
- package/dist/assert.cjs.map +1 -0
- package/dist/{types/assert.d.ts → assert.d.cts} +3 -3
- package/dist/assert.d.cts.map +1 -0
- package/dist/assert.d.mts +61 -0
- package/dist/assert.d.mts.map +1 -0
- package/dist/assert.mjs +119 -15
- package/dist/assert.mjs.map +1 -1
- package/dist/base64.cjs +34 -0
- package/dist/base64.cjs.map +1 -0
- package/dist/{types/base64.d.ts → base64.d.cts} +3 -3
- package/dist/base64.d.cts.map +1 -0
- package/dist/base64.d.mts +25 -0
- package/dist/base64.d.mts.map +1 -0
- package/dist/base64.mjs +28 -9
- package/dist/base64.mjs.map +1 -1
- package/dist/bytes.cjs +400 -0
- package/dist/{chunk-QEPVHEP7.js.map → bytes.cjs.map} +1 -1
- package/dist/{types/bytes.d.ts → bytes.d.cts} +3 -3
- package/dist/bytes.d.cts.map +1 -0
- package/dist/bytes.d.mts +183 -0
- package/dist/bytes.d.mts.map +1 -0
- package/dist/bytes.mjs +379 -42
- package/dist/bytes.mjs.map +1 -1
- package/dist/caip-types.cjs +151 -0
- package/dist/caip-types.cjs.map +1 -0
- package/dist/{types/caip-types.d.ts → caip-types.d.cts} +12 -12
- package/dist/caip-types.d.cts.map +1 -0
- package/dist/caip-types.d.mts +114 -0
- package/dist/caip-types.d.mts.map +1 -0
- package/dist/caip-types.mjs +139 -43
- package/dist/caip-types.mjs.map +1 -1
- package/dist/checksum.cjs +7 -0
- package/dist/checksum.cjs.map +1 -0
- package/dist/checksum.d.cts +2 -0
- package/dist/checksum.d.cts.map +1 -0
- package/dist/checksum.d.mts +2 -0
- package/dist/checksum.d.mts.map +1 -0
- package/dist/checksum.mjs +3 -11
- package/dist/checksum.mjs.map +1 -1
- package/dist/coercers.cjs +162 -0
- package/dist/coercers.cjs.map +1 -0
- package/dist/{types/coercers.d.ts → coercers.d.cts} +7 -7
- package/dist/coercers.d.cts.map +1 -0
- package/dist/coercers.d.mts +97 -0
- package/dist/coercers.d.mts.map +1 -0
- package/dist/coercers.mjs +154 -17
- package/dist/coercers.mjs.map +1 -1
- package/dist/collections.cjs +109 -0
- package/dist/collections.cjs.map +1 -0
- package/dist/{types/collections.d.ts → collections.d.cts} +1 -1
- package/dist/collections.d.cts.map +1 -0
- package/dist/collections.d.mts +39 -0
- package/dist/collections.d.mts.map +1 -0
- package/dist/collections.mjs +103 -8
- package/dist/collections.mjs.map +1 -1
- package/dist/encryption-types.cjs +3 -0
- package/dist/encryption-types.cjs.map +1 -0
- package/dist/{types/encryption-types.d.ts → encryption-types.d.cts} +2 -2
- package/dist/encryption-types.d.cts.map +1 -0
- package/dist/encryption-types.d.mts +7 -0
- package/dist/encryption-types.d.mts.map +1 -0
- package/dist/encryption-types.mjs +1 -1
- package/dist/encryption-types.mjs.map +1 -1
- package/dist/errors.cjs +111 -0
- package/dist/errors.cjs.map +1 -0
- package/dist/{types/errors.d.ts → errors.d.cts} +1 -1
- package/dist/errors.d.cts.map +1 -0
- package/dist/errors.d.mts +58 -0
- package/dist/errors.d.mts.map +1 -0
- package/dist/errors.mjs +102 -16
- package/dist/errors.mjs.map +1 -1
- package/dist/fs.cjs +248 -0
- package/dist/fs.cjs.map +1 -0
- package/dist/{types/fs.d.ts → fs.d.cts} +3 -3
- package/dist/fs.d.cts.map +1 -0
- package/dist/fs.d.mts +133 -0
- package/dist/fs.d.mts.map +1 -0
- package/dist/fs.mjs +209 -25
- package/dist/fs.mjs.map +1 -1
- package/dist/hex.cjs +134 -0
- package/dist/hex.cjs.map +1 -0
- package/dist/{types/hex.d.ts → hex.d.cts} +3 -3
- package/dist/hex.d.cts.map +1 -0
- package/dist/hex.d.mts +77 -0
- package/dist/hex.d.mts.map +1 -0
- package/dist/hex.mjs +121 -34
- package/dist/hex.mjs.map +1 -1
- package/dist/index.cjs +37 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +21 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +21 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +20 -296
- package/dist/index.mjs.map +1 -1
- package/dist/json.cjs +413 -0
- package/dist/json.cjs.map +1 -0
- package/dist/{types/json.d.ts → json.d.cts} +21 -22
- package/dist/json.d.cts.map +1 -0
- package/dist/json.d.mts +383 -0
- package/dist/json.d.mts.map +1 -0
- package/dist/json.mjs +389 -74
- package/dist/json.mjs.map +1 -1
- package/dist/keyring.cjs +3 -0
- package/dist/keyring.cjs.map +1 -0
- package/dist/{types/keyring.d.ts → keyring.d.cts} +7 -7
- package/dist/keyring.d.cts.map +1 -0
- package/dist/keyring.d.mts +224 -0
- package/dist/keyring.d.mts.map +1 -0
- package/dist/keyring.mjs +1 -1
- package/dist/keyring.mjs.map +1 -1
- package/dist/logging.cjs +43 -0
- package/dist/logging.cjs.map +1 -0
- package/dist/{types/logging.d.ts → logging.d.cts} +2 -2
- package/dist/logging.d.cts.map +1 -0
- package/dist/logging.d.mts +30 -0
- package/dist/logging.d.mts.map +1 -0
- package/dist/logging.mjs +34 -9
- package/dist/logging.mjs.map +1 -1
- package/dist/misc.cjs +149 -0
- package/dist/misc.cjs.map +1 -0
- package/dist/{types/misc.d.ts → misc.d.cts} +6 -6
- package/dist/misc.d.cts.map +1 -0
- package/dist/misc.d.mts +119 -0
- package/dist/misc.d.mts.map +1 -0
- package/dist/misc.mjs +136 -27
- package/dist/misc.mjs.map +1 -1
- package/dist/node.cjs +19 -0
- package/dist/node.cjs.map +1 -0
- package/dist/node.d.cts +3 -0
- package/dist/node.d.cts.map +1 -0
- package/dist/node.d.mts +3 -0
- package/dist/node.d.mts.map +1 -0
- package/dist/node.mjs +2 -316
- package/dist/node.mjs.map +1 -1
- package/dist/number.cjs +102 -0
- package/dist/number.cjs.map +1 -0
- package/dist/{types/number.d.ts → number.d.cts} +1 -1
- package/dist/number.d.cts.map +1 -0
- package/dist/number.d.mts +73 -0
- package/dist/number.d.mts.map +1 -0
- package/dist/number.mjs +93 -16
- package/dist/number.mjs.map +1 -1
- package/dist/opaque.cjs +3 -0
- package/dist/opaque.cjs.map +1 -0
- package/dist/opaque.d.cts +6 -0
- package/dist/opaque.d.cts.map +1 -0
- package/dist/opaque.d.mts +6 -0
- package/dist/opaque.d.mts.map +1 -0
- package/dist/opaque.mjs +1 -1
- package/dist/opaque.mjs.map +1 -1
- package/dist/promise.cjs +40 -0
- package/dist/promise.cjs.map +1 -0
- package/dist/{types/promise.d.ts → promise.d.cts} +2 -2
- package/dist/promise.d.cts.map +1 -0
- package/dist/promise.d.mts +45 -0
- package/dist/promise.d.mts.map +1 -0
- package/dist/promise.mjs +35 -7
- package/dist/promise.mjs.map +1 -1
- package/dist/time.cjs +67 -0
- package/dist/time.cjs.map +1 -0
- package/dist/{types/time.d.ts → time.d.cts} +1 -1
- package/dist/time.d.cts.map +1 -0
- package/dist/time.d.mts +49 -0
- package/dist/time.d.mts.map +1 -0
- package/dist/time.mjs +60 -10
- package/dist/time.mjs.map +1 -1
- package/dist/transaction-types.cjs +3 -0
- package/dist/transaction-types.cjs.map +1 -0
- package/dist/{types/transaction-types.d.ts → transaction-types.d.cts} +11 -11
- package/dist/transaction-types.d.cts.map +1 -0
- package/dist/transaction-types.d.mts +117 -0
- package/dist/transaction-types.d.mts.map +1 -0
- package/dist/transaction-types.mjs +1 -1
- package/dist/transaction-types.mjs.map +1 -1
- package/dist/versions.cjs +95 -0
- package/dist/versions.cjs.map +1 -0
- package/dist/{types/versions.d.ts → versions.d.cts} +5 -5
- package/dist/versions.d.cts.map +1 -0
- package/dist/versions.d.mts +101 -0
- package/dist/versions.d.mts.map +1 -0
- package/dist/versions.mjs +85 -26
- package/dist/versions.mjs.map +1 -1
- package/package.json +26 -17
- package/dist/assert.js +0 -16
- package/dist/assert.js.map +0 -1
- package/dist/base64.js +0 -11
- package/dist/base64.js.map +0 -1
- package/dist/bytes.js +0 -43
- package/dist/bytes.js.map +0 -1
- package/dist/caip-types.js +0 -44
- package/dist/caip-types.js.map +0 -1
- package/dist/checksum.js +0 -12
- package/dist/checksum.js.map +0 -1
- package/dist/chunk-2LBGT4GH.js +0 -15
- package/dist/chunk-2LBGT4GH.js.map +0 -1
- package/dist/chunk-3W5G4CYI.js +0 -25
- package/dist/chunk-3W5G4CYI.js.map +0 -1
- package/dist/chunk-4D6XQBHA.js +0 -69
- package/dist/chunk-4D6XQBHA.js.map +0 -1
- package/dist/chunk-4RMX5YWE.js +0 -34
- package/dist/chunk-4RMX5YWE.js.map +0 -1
- package/dist/chunk-5AVWINSB.js +0 -1
- package/dist/chunk-5AVWINSB.js.map +0 -1
- package/dist/chunk-622IOGVI.mjs +0 -1
- package/dist/chunk-622IOGVI.mjs.map +0 -1
- package/dist/chunk-6C35XQOF.mjs +0 -257
- package/dist/chunk-6C35XQOF.mjs.map +0 -1
- package/dist/chunk-6NZW4WK4.js +0 -35
- package/dist/chunk-6NZW4WK4.js.map +0 -1
- package/dist/chunk-6ZDHSOUV.js +0 -59
- package/dist/chunk-6ZDHSOUV.js.map +0 -1
- package/dist/chunk-74DGVJVE.mjs +0 -59
- package/dist/chunk-74DGVJVE.mjs.map +0 -1
- package/dist/chunk-AY6FDCBT.mjs +0 -1
- package/dist/chunk-AY6FDCBT.mjs.map +0 -1
- package/dist/chunk-C6HGFEYL.js +0 -23
- package/dist/chunk-C6HGFEYL.js.map +0 -1
- package/dist/chunk-DHVKFDHQ.js +0 -95
- package/dist/chunk-DHVKFDHQ.js.map +0 -1
- package/dist/chunk-DYRKZQMK.mjs +0 -122
- package/dist/chunk-DYRKZQMK.mjs.map +0 -1
- package/dist/chunk-E4C7EW4R.js +0 -16
- package/dist/chunk-E4C7EW4R.js.map +0 -1
- package/dist/chunk-EQMZL4XU.js +0 -1
- package/dist/chunk-EQMZL4XU.js.map +0 -1
- package/dist/chunk-GZS3IQBZ.mjs +0 -16
- package/dist/chunk-GZS3IQBZ.mjs.map +0 -1
- package/dist/chunk-H4YFDLB7.mjs +0 -70
- package/dist/chunk-H4YFDLB7.mjs.map +0 -1
- package/dist/chunk-I575FZFH.mjs +0 -1
- package/dist/chunk-I575FZFH.mjs.map +0 -1
- package/dist/chunk-IZC266HS.js +0 -55
- package/dist/chunk-IZC266HS.js.map +0 -1
- package/dist/chunk-JPAL7Q5S.mjs +0 -90
- package/dist/chunk-JPAL7Q5S.mjs.map +0 -1
- package/dist/chunk-LC2CRSWD.js +0 -1
- package/dist/chunk-LC2CRSWD.js.map +0 -1
- package/dist/chunk-NQMRFZHB.mjs +0 -35
- package/dist/chunk-NQMRFZHB.mjs.map +0 -1
- package/dist/chunk-O3EIM33O.mjs +0 -95
- package/dist/chunk-O3EIM33O.mjs.map +0 -1
- package/dist/chunk-OLLG4H35.js +0 -257
- package/dist/chunk-OLLG4H35.js.map +0 -1
- package/dist/chunk-OUZ3LSLX.mjs +0 -94
- package/dist/chunk-OUZ3LSLX.mjs.map +0 -1
- package/dist/chunk-QEPVHEP7.js +0 -273
- package/dist/chunk-QVEKZRZ2.js +0 -70
- package/dist/chunk-QVEKZRZ2.js.map +0 -1
- package/dist/chunk-RIRDOQPX.mjs +0 -15
- package/dist/chunk-RIRDOQPX.mjs.map +0 -1
- package/dist/chunk-RKRGAFXY.js +0 -1
- package/dist/chunk-RKRGAFXY.js.map +0 -1
- package/dist/chunk-RNEXSCNP.js +0 -122
- package/dist/chunk-RNEXSCNP.js.map +0 -1
- package/dist/chunk-ROQSKDP5.mjs +0 -69
- package/dist/chunk-ROQSKDP5.mjs.map +0 -1
- package/dist/chunk-RRYOWRCV.mjs +0 -1
- package/dist/chunk-RRYOWRCV.mjs.map +0 -1
- package/dist/chunk-S3UHBN2Z.mjs +0 -44
- package/dist/chunk-S3UHBN2Z.mjs.map +0 -1
- package/dist/chunk-THNLGEXV.mjs +0 -34
- package/dist/chunk-THNLGEXV.mjs.map +0 -1
- package/dist/chunk-UOTVU7OQ.js +0 -1
- package/dist/chunk-UOTVU7OQ.js.map +0 -1
- package/dist/chunk-VA2DRBDE.mjs +0 -273
- package/dist/chunk-VA2DRBDE.mjs.map +0 -1
- package/dist/chunk-VFXTVNXN.js +0 -44
- package/dist/chunk-VFXTVNXN.js.map +0 -1
- package/dist/chunk-W5XI7ERF.mjs +0 -23
- package/dist/chunk-W5XI7ERF.mjs.map +0 -1
- package/dist/chunk-WA4DHIND.mjs +0 -1
- package/dist/chunk-WA4DHIND.mjs.map +0 -1
- package/dist/chunk-X66SUIEF.mjs +0 -25
- package/dist/chunk-X66SUIEF.mjs.map +0 -1
- package/dist/chunk-XYGUOY6N.mjs +0 -55
- package/dist/chunk-XYGUOY6N.mjs.map +0 -1
- package/dist/chunk-YWAID473.js +0 -94
- package/dist/chunk-YWAID473.js.map +0 -1
- package/dist/chunk-Z2RGWDD7.js +0 -90
- package/dist/chunk-Z2RGWDD7.js.map +0 -1
- package/dist/coercers.js +0 -18
- package/dist/coercers.js.map +0 -1
- package/dist/collections.js +0 -10
- package/dist/collections.js.map +0 -1
- package/dist/encryption-types.js +0 -2
- package/dist/encryption-types.js.map +0 -1
- package/dist/errors.js +0 -17
- package/dist/errors.js.map +0 -1
- package/dist/fs.js +0 -26
- package/dist/fs.js.map +0 -1
- package/dist/hex.js +0 -35
- package/dist/hex.js.map +0 -1
- package/dist/index.js +0 -297
- package/dist/index.js.map +0 -1
- package/dist/json.js +0 -75
- package/dist/json.js.map +0 -1
- package/dist/keyring.js +0 -2
- package/dist/keyring.js.map +0 -1
- package/dist/logging.js +0 -10
- package/dist/logging.js.map +0 -1
- package/dist/misc.js +0 -28
- package/dist/misc.js.map +0 -1
- package/dist/node.js +0 -317
- package/dist/node.js.map +0 -1
- package/dist/number.js +0 -18
- package/dist/number.js.map +0 -1
- package/dist/opaque.js +0 -2
- package/dist/opaque.js.map +0 -1
- package/dist/promise.js +0 -8
- package/dist/promise.js.map +0 -1
- package/dist/time.js +0 -12
- package/dist/time.js.map +0 -1
- package/dist/transaction-types.js +0 -2
- package/dist/transaction-types.js.map +0 -1
- package/dist/types/assert.d.ts.map +0 -1
- package/dist/types/base64.d.ts.map +0 -1
- package/dist/types/bytes.d.ts.map +0 -1
- package/dist/types/caip-types.d.ts.map +0 -1
- package/dist/types/checksum.d.ts +0 -2
- package/dist/types/checksum.d.ts.map +0 -1
- package/dist/types/coercers.d.ts.map +0 -1
- package/dist/types/collections.d.ts.map +0 -1
- package/dist/types/encryption-types.d.ts.map +0 -1
- package/dist/types/errors.d.ts.map +0 -1
- package/dist/types/fs.d.ts.map +0 -1
- package/dist/types/hex.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -21
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/json.d.ts.map +0 -1
- package/dist/types/keyring.d.ts.map +0 -1
- package/dist/types/logging.d.ts.map +0 -1
- package/dist/types/misc.d.ts.map +0 -1
- package/dist/types/node.d.ts +0 -3
- package/dist/types/node.d.ts.map +0 -1
- package/dist/types/number.d.ts.map +0 -1
- package/dist/types/opaque.d.ts +0 -6
- package/dist/types/opaque.d.ts.map +0 -1
- package/dist/types/promise.d.ts.map +0 -1
- package/dist/types/time.d.ts.map +0 -1
- package/dist/types/transaction-types.d.ts.map +0 -1
- package/dist/types/versions.d.ts.map +0 -1
- package/dist/versions.js +0 -27
- package/dist/versions.js.map +0 -1
package/dist/time.d.mts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Common duration constants, in milliseconds.
|
|
3
|
+
*/
|
|
4
|
+
export declare enum Duration {
|
|
5
|
+
/**
|
|
6
|
+
* A millisecond.
|
|
7
|
+
*/
|
|
8
|
+
Millisecond = 1,
|
|
9
|
+
/**
|
|
10
|
+
* A second, in milliseconds.
|
|
11
|
+
*/
|
|
12
|
+
Second = 1000,
|
|
13
|
+
/**
|
|
14
|
+
* A minute, in milliseconds.
|
|
15
|
+
*/
|
|
16
|
+
Minute = 60000,
|
|
17
|
+
/**
|
|
18
|
+
* An hour, in milliseconds.
|
|
19
|
+
*/
|
|
20
|
+
Hour = 3600000,
|
|
21
|
+
/**
|
|
22
|
+
* A day, in milliseconds.
|
|
23
|
+
*/
|
|
24
|
+
Day = 86400000,
|
|
25
|
+
/**
|
|
26
|
+
* A week, in milliseconds.
|
|
27
|
+
*/
|
|
28
|
+
Week = 604800000,
|
|
29
|
+
/**
|
|
30
|
+
* A year, in milliseconds.
|
|
31
|
+
*/
|
|
32
|
+
Year = 31536000000
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Calculates the millisecond value of the specified number of units of time.
|
|
36
|
+
*
|
|
37
|
+
* @param count - The number of units of time.
|
|
38
|
+
* @param duration - The unit of time to count.
|
|
39
|
+
* @returns The count multiplied by the specified duration.
|
|
40
|
+
*/
|
|
41
|
+
export declare function inMilliseconds(count: number, duration: Duration): number;
|
|
42
|
+
/**
|
|
43
|
+
* Gets the milliseconds since a particular Unix epoch timestamp.
|
|
44
|
+
*
|
|
45
|
+
* @param timestamp - A Unix millisecond timestamp.
|
|
46
|
+
* @returns The number of milliseconds elapsed since the specified timestamp.
|
|
47
|
+
*/
|
|
48
|
+
export declare function timeSince(timestamp: number): number;
|
|
49
|
+
//# sourceMappingURL=time.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"time.d.mts","sourceRoot":"","sources":["../src/time.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,QAAQ;IAClB;;OAEG;IACH,WAAW,IAAI;IAEf;;OAEG;IACH,MAAM,OAAO;IAEb;;OAEG;IACH,MAAM,QAAS;IAEf;;OAEG;IACH,IAAI,UAAY;IAEhB;;OAEG;IACH,GAAG,WAAa;IAEhB;;OAEG;IACH,IAAI,YAAc;IAElB;;OAEG;IACH,IAAI,cAAiB;CACtB;AAaD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAGxE;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAGnD"}
|
package/dist/time.mjs
CHANGED
|
@@ -1,12 +1,62 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Common duration constants, in milliseconds.
|
|
3
|
+
*/
|
|
4
|
+
export var Duration;
|
|
5
|
+
(function (Duration) {
|
|
6
|
+
/**
|
|
7
|
+
* A millisecond.
|
|
8
|
+
*/
|
|
9
|
+
Duration[Duration["Millisecond"] = 1] = "Millisecond";
|
|
10
|
+
/**
|
|
11
|
+
* A second, in milliseconds.
|
|
12
|
+
*/
|
|
13
|
+
Duration[Duration["Second"] = 1000] = "Second";
|
|
14
|
+
/**
|
|
15
|
+
* A minute, in milliseconds.
|
|
16
|
+
*/
|
|
17
|
+
Duration[Duration["Minute"] = 60000] = "Minute";
|
|
18
|
+
/**
|
|
19
|
+
* An hour, in milliseconds.
|
|
20
|
+
*/
|
|
21
|
+
Duration[Duration["Hour"] = 3600000] = "Hour";
|
|
22
|
+
/**
|
|
23
|
+
* A day, in milliseconds.
|
|
24
|
+
*/
|
|
25
|
+
Duration[Duration["Day"] = 86400000] = "Day";
|
|
26
|
+
/**
|
|
27
|
+
* A week, in milliseconds.
|
|
28
|
+
*/
|
|
29
|
+
Duration[Duration["Week"] = 604800000] = "Week";
|
|
30
|
+
/**
|
|
31
|
+
* A year, in milliseconds.
|
|
32
|
+
*/
|
|
33
|
+
Duration[Duration["Year"] = 31536000000] = "Year";
|
|
34
|
+
})(Duration = Duration || (Duration = {}));
|
|
35
|
+
const isNonNegativeInteger = (number) => Number.isInteger(number) && number >= 0;
|
|
36
|
+
const assertIsNonNegativeInteger = (number, name) => {
|
|
37
|
+
if (!isNonNegativeInteger(number)) {
|
|
38
|
+
throw new Error(`"${name}" must be a non-negative integer. Received: "${number}".`);
|
|
39
|
+
}
|
|
11
40
|
};
|
|
41
|
+
/**
|
|
42
|
+
* Calculates the millisecond value of the specified number of units of time.
|
|
43
|
+
*
|
|
44
|
+
* @param count - The number of units of time.
|
|
45
|
+
* @param duration - The unit of time to count.
|
|
46
|
+
* @returns The count multiplied by the specified duration.
|
|
47
|
+
*/
|
|
48
|
+
export function inMilliseconds(count, duration) {
|
|
49
|
+
assertIsNonNegativeInteger(count, 'count');
|
|
50
|
+
return count * duration;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Gets the milliseconds since a particular Unix epoch timestamp.
|
|
54
|
+
*
|
|
55
|
+
* @param timestamp - A Unix millisecond timestamp.
|
|
56
|
+
* @returns The number of milliseconds elapsed since the specified timestamp.
|
|
57
|
+
*/
|
|
58
|
+
export function timeSince(timestamp) {
|
|
59
|
+
assertIsNonNegativeInteger(timestamp, 'timestamp');
|
|
60
|
+
return Date.now() - timestamp;
|
|
61
|
+
}
|
|
12
62
|
//# sourceMappingURL=time.mjs.map
|
package/dist/time.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"file":"time.mjs","sourceRoot":"","sources":["../src/time.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAN,IAAY,QAmCX;AAnCD,WAAY,QAAQ;IAClB;;OAEG;IACH,qDAAe,CAAA;IAEf;;OAEG;IACH,8CAAa,CAAA;IAEb;;OAEG;IACH,+CAAe,CAAA;IAEf;;OAEG;IACH,6CAAgB,CAAA;IAEhB;;OAEG;IACH,4CAAgB,CAAA;IAEhB;;OAEG;IACH,+CAAkB,CAAA;IAElB;;OAEG;IACH,iDAAqB,CAAA;AACvB,CAAC,EAnCW,QAAQ,GAAR,QAAQ,KAAR,QAAQ,QAmCnB;AAED,MAAM,oBAAoB,GAAG,CAAC,MAAc,EAAE,EAAE,CAC9C,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,MAAM,IAAI,CAAC,CAAC;AAE1C,MAAM,0BAA0B,GAAG,CAAC,MAAc,EAAE,IAAY,EAAE,EAAE;IAClE,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,EAAE;QACjC,MAAM,IAAI,KAAK,CACb,IAAI,IAAI,gDAAgD,MAAM,IAAI,CACnE,CAAC;KACH;AACH,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,KAAa,EAAE,QAAkB;IAC9D,0BAA0B,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC3C,OAAO,KAAK,GAAG,QAAQ,CAAC;AAC1B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,SAAiB;IACzC,0BAA0B,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;IACnD,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;AAChC,CAAC","sourcesContent":["/**\n * Common duration constants, in milliseconds.\n */\nexport enum Duration {\n /**\n * A millisecond.\n */\n Millisecond = 1,\n\n /**\n * A second, in milliseconds.\n */\n Second = 1000, // Millisecond * 1000\n\n /**\n * A minute, in milliseconds.\n */\n Minute = 60_000, // Second * 60\n\n /**\n * An hour, in milliseconds.\n */\n Hour = 3_600_000, // Minute * 60\n\n /**\n * A day, in milliseconds.\n */\n Day = 86_400_000, // Hour * 24\n\n /**\n * A week, in milliseconds.\n */\n Week = 604_800_000, // Day * 7\n\n /**\n * A year, in milliseconds.\n */\n Year = 31_536_000_000, // Day * 365\n}\n\nconst isNonNegativeInteger = (number: number) =>\n Number.isInteger(number) && number >= 0;\n\nconst assertIsNonNegativeInteger = (number: number, name: string) => {\n if (!isNonNegativeInteger(number)) {\n throw new Error(\n `\"${name}\" must be a non-negative integer. Received: \"${number}\".`,\n );\n }\n};\n\n/**\n * Calculates the millisecond value of the specified number of units of time.\n *\n * @param count - The number of units of time.\n * @param duration - The unit of time to count.\n * @returns The count multiplied by the specified duration.\n */\nexport function inMilliseconds(count: number, duration: Duration): number {\n assertIsNonNegativeInteger(count, 'count');\n return count * duration;\n}\n\n/**\n * Gets the milliseconds since a particular Unix epoch timestamp.\n *\n * @param timestamp - A Unix millisecond timestamp.\n * @returns The number of milliseconds elapsed since the specified timestamp.\n */\nexport function timeSince(timestamp: number): number {\n assertIsNonNegativeInteger(timestamp, 'timestamp');\n return Date.now() - timestamp;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction-types.cjs","sourceRoot":"","sources":["../src/transaction-types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Bytes } from './bytes';\nimport type { Hex } from './hex';\n\nexport type Transaction =\n | LegacyTransaction\n | EIP2930Transaction\n | EIP1559Transaction;\n\nexport type SignedTransaction = Transaction & Signature;\n\nexport type Signature = {\n /**\n * EC signature parameter\n * 32 bytes long sequence.\n */\n r: Bytes;\n\n /**\n * EC signature parameter\n * Signature proof.\n * 32 bytes long sequence\n */\n s: Bytes;\n\n /**\n * Recovery identifier. It can be either 0x1b or 0x1c\n * 1 byte long sequence\n */\n yParity: Bytes;\n};\n\n/**\n * Base Ethereum Transaction\n */\nexport type BaseTransaction = {\n /**\n * Sequentially incrementing counter which indicates the transaction\n * number from the account\n */\n nonce: Bytes;\n\n /**\n * The address of the sender, that will be signing the transaction\n */\n from: Hex | Uint8Array;\n\n /**\n * The receiving address.\n * If an externally-owned account, the transaction will transfer value.\n * If a contract account, the transaction will execute the contract code.\n */\n to: Hex | Uint8Array;\n\n /**\n * The amount of Ether sent.\n */\n value: Bytes;\n\n /**\n * Maximum amount of gas units that this transaction can consume.\n */\n gasLimit: Bytes;\n\n /**\n * Arbitrary data.\n */\n data?: Bytes;\n};\n\n/**\n * Typed Ethereum Transaction\n */\nexport type TypedTransaction = BaseTransaction & {\n /**\n * Transaction type.\n */\n type: number;\n};\n\n/**\n * Ethereum Legacy Transaction\n * Reference: https://ethereum.org/en/developers/docs/transactions/\n */\nexport type LegacyTransaction = BaseTransaction & {\n /**\n * Transaction's gas price.\n */\n gasPrice: Bytes | null;\n};\n\n/**\n * EIP-2930 Transaction: Optional Access Lists\n * Reference: https://eips.ethereum.org/EIPS/eip-2930\n */\nexport type EIP2930Transaction = TypedTransaction & {\n /**\n * Transaction type.\n */\n type: 1;\n\n /**\n * Transaction chain ID\n */\n chainId: Bytes;\n\n /**\n * List of addresses and storage keys that the transaction plans to access\n */\n accessList:\n | { address: Hex; storageKeys: Hex[] }[]\n | { address: Uint8Array; storageKeys: Uint8Array[] }[];\n};\n\n/**\n * EIP-1559 Transaction: Fee market change for ETH 1.0 chain (Type-2)\n *\n * Reference: https://eips.ethereum.org/EIPS/eip-1559\n */\nexport type EIP1559Transaction = TypedTransaction & {\n /**\n * Transaction type.\n */\n type: 2;\n\n /**\n * Maximum fee to give to the miner\n */\n maxPriorityFeePerGas: Bytes;\n\n /**\n * Maximum total fee\n */\n maxFeePerGas: Bytes;\n};\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { Bytes } from
|
|
2
|
-
import type { Hex } from
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
1
|
+
import type { Bytes } from "./bytes.cjs";
|
|
2
|
+
import type { Hex } from "./hex.cjs";
|
|
3
|
+
export type Transaction = LegacyTransaction | EIP2930Transaction | EIP1559Transaction;
|
|
4
|
+
export type SignedTransaction = Transaction & Signature;
|
|
5
|
+
export type Signature = {
|
|
6
6
|
/**
|
|
7
7
|
* EC signature parameter
|
|
8
8
|
* 32 bytes long sequence.
|
|
@@ -23,7 +23,7 @@ export declare type Signature = {
|
|
|
23
23
|
/**
|
|
24
24
|
* Base Ethereum Transaction
|
|
25
25
|
*/
|
|
26
|
-
export
|
|
26
|
+
export type BaseTransaction = {
|
|
27
27
|
/**
|
|
28
28
|
* Sequentially incrementing counter which indicates the transaction
|
|
29
29
|
* number from the account
|
|
@@ -55,7 +55,7 @@ export declare type BaseTransaction = {
|
|
|
55
55
|
/**
|
|
56
56
|
* Typed Ethereum Transaction
|
|
57
57
|
*/
|
|
58
|
-
export
|
|
58
|
+
export type TypedTransaction = BaseTransaction & {
|
|
59
59
|
/**
|
|
60
60
|
* Transaction type.
|
|
61
61
|
*/
|
|
@@ -65,7 +65,7 @@ export declare type TypedTransaction = BaseTransaction & {
|
|
|
65
65
|
* Ethereum Legacy Transaction
|
|
66
66
|
* Reference: https://ethereum.org/en/developers/docs/transactions/
|
|
67
67
|
*/
|
|
68
|
-
export
|
|
68
|
+
export type LegacyTransaction = BaseTransaction & {
|
|
69
69
|
/**
|
|
70
70
|
* Transaction's gas price.
|
|
71
71
|
*/
|
|
@@ -75,7 +75,7 @@ export declare type LegacyTransaction = BaseTransaction & {
|
|
|
75
75
|
* EIP-2930 Transaction: Optional Access Lists
|
|
76
76
|
* Reference: https://eips.ethereum.org/EIPS/eip-2930
|
|
77
77
|
*/
|
|
78
|
-
export
|
|
78
|
+
export type EIP2930Transaction = TypedTransaction & {
|
|
79
79
|
/**
|
|
80
80
|
* Transaction type.
|
|
81
81
|
*/
|
|
@@ -100,7 +100,7 @@ export declare type EIP2930Transaction = TypedTransaction & {
|
|
|
100
100
|
*
|
|
101
101
|
* Reference: https://eips.ethereum.org/EIPS/eip-1559
|
|
102
102
|
*/
|
|
103
|
-
export
|
|
103
|
+
export type EIP1559Transaction = TypedTransaction & {
|
|
104
104
|
/**
|
|
105
105
|
* Transaction type.
|
|
106
106
|
*/
|
|
@@ -114,4 +114,4 @@ export declare type EIP1559Transaction = TypedTransaction & {
|
|
|
114
114
|
*/
|
|
115
115
|
maxFeePerGas: Bytes;
|
|
116
116
|
};
|
|
117
|
-
//# sourceMappingURL=transaction-types.d.
|
|
117
|
+
//# sourceMappingURL=transaction-types.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction-types.d.cts","sourceRoot":"","sources":["../src/transaction-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,oBAAgB;AACrC,OAAO,KAAK,EAAE,GAAG,EAAE,kBAAc;AAEjC,MAAM,MAAM,WAAW,GACnB,iBAAiB,GACjB,kBAAkB,GAClB,kBAAkB,CAAC;AAEvB,MAAM,MAAM,iBAAiB,GAAG,WAAW,GAAG,SAAS,CAAC;AAExD,MAAM,MAAM,SAAS,GAAG;IACtB;;;OAGG;IACH,CAAC,EAAE,KAAK,CAAC;IAET;;;;OAIG;IACH,CAAC,EAAE,KAAK,CAAC;IAET;;;OAGG;IACH,OAAO,EAAE,KAAK,CAAC;CAChB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B;;;OAGG;IACH,KAAK,EAAE,KAAK,CAAC;IAEb;;OAEG;IACH,IAAI,EAAE,GAAG,GAAG,UAAU,CAAC;IAEvB;;;;OAIG;IACH,EAAE,EAAE,GAAG,GAAG,UAAU,CAAC;IAErB;;OAEG;IACH,KAAK,EAAE,KAAK,CAAC;IAEb;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC;IAEhB;;OAEG;IACH,IAAI,CAAC,EAAE,KAAK,CAAC;CACd,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,eAAe,GAAG;IAC/C;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,eAAe,GAAG;IAChD;;OAEG;IACH,QAAQ,EAAE,KAAK,GAAG,IAAI,CAAC;CACxB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG,gBAAgB,GAAG;IAClD;;OAEG;IACH,IAAI,EAAE,CAAC,CAAC;IAER;;OAEG;IACH,OAAO,EAAE,KAAK,CAAC;IAEf;;OAEG;IACH,UAAU,EACN;QAAE,OAAO,EAAE,GAAG,CAAC;QAAC,WAAW,EAAE,GAAG,EAAE,CAAA;KAAE,EAAE,GACtC;QAAE,OAAO,EAAE,UAAU,CAAC;QAAC,WAAW,EAAE,UAAU,EAAE,CAAA;KAAE,EAAE,CAAC;CAC1D,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,gBAAgB,GAAG;IAClD;;OAEG;IACH,IAAI,EAAE,CAAC,CAAC;IAER;;OAEG;IACH,oBAAoB,EAAE,KAAK,CAAC;IAE5B;;OAEG;IACH,YAAY,EAAE,KAAK,CAAC;CACrB,CAAC"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import type { Bytes } from "./bytes.mjs";
|
|
2
|
+
import type { Hex } from "./hex.mjs";
|
|
3
|
+
export type Transaction = LegacyTransaction | EIP2930Transaction | EIP1559Transaction;
|
|
4
|
+
export type SignedTransaction = Transaction & Signature;
|
|
5
|
+
export type Signature = {
|
|
6
|
+
/**
|
|
7
|
+
* EC signature parameter
|
|
8
|
+
* 32 bytes long sequence.
|
|
9
|
+
*/
|
|
10
|
+
r: Bytes;
|
|
11
|
+
/**
|
|
12
|
+
* EC signature parameter
|
|
13
|
+
* Signature proof.
|
|
14
|
+
* 32 bytes long sequence
|
|
15
|
+
*/
|
|
16
|
+
s: Bytes;
|
|
17
|
+
/**
|
|
18
|
+
* Recovery identifier. It can be either 0x1b or 0x1c
|
|
19
|
+
* 1 byte long sequence
|
|
20
|
+
*/
|
|
21
|
+
yParity: Bytes;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Base Ethereum Transaction
|
|
25
|
+
*/
|
|
26
|
+
export type BaseTransaction = {
|
|
27
|
+
/**
|
|
28
|
+
* Sequentially incrementing counter which indicates the transaction
|
|
29
|
+
* number from the account
|
|
30
|
+
*/
|
|
31
|
+
nonce: Bytes;
|
|
32
|
+
/**
|
|
33
|
+
* The address of the sender, that will be signing the transaction
|
|
34
|
+
*/
|
|
35
|
+
from: Hex | Uint8Array;
|
|
36
|
+
/**
|
|
37
|
+
* The receiving address.
|
|
38
|
+
* If an externally-owned account, the transaction will transfer value.
|
|
39
|
+
* If a contract account, the transaction will execute the contract code.
|
|
40
|
+
*/
|
|
41
|
+
to: Hex | Uint8Array;
|
|
42
|
+
/**
|
|
43
|
+
* The amount of Ether sent.
|
|
44
|
+
*/
|
|
45
|
+
value: Bytes;
|
|
46
|
+
/**
|
|
47
|
+
* Maximum amount of gas units that this transaction can consume.
|
|
48
|
+
*/
|
|
49
|
+
gasLimit: Bytes;
|
|
50
|
+
/**
|
|
51
|
+
* Arbitrary data.
|
|
52
|
+
*/
|
|
53
|
+
data?: Bytes;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Typed Ethereum Transaction
|
|
57
|
+
*/
|
|
58
|
+
export type TypedTransaction = BaseTransaction & {
|
|
59
|
+
/**
|
|
60
|
+
* Transaction type.
|
|
61
|
+
*/
|
|
62
|
+
type: number;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Ethereum Legacy Transaction
|
|
66
|
+
* Reference: https://ethereum.org/en/developers/docs/transactions/
|
|
67
|
+
*/
|
|
68
|
+
export type LegacyTransaction = BaseTransaction & {
|
|
69
|
+
/**
|
|
70
|
+
* Transaction's gas price.
|
|
71
|
+
*/
|
|
72
|
+
gasPrice: Bytes | null;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* EIP-2930 Transaction: Optional Access Lists
|
|
76
|
+
* Reference: https://eips.ethereum.org/EIPS/eip-2930
|
|
77
|
+
*/
|
|
78
|
+
export type EIP2930Transaction = TypedTransaction & {
|
|
79
|
+
/**
|
|
80
|
+
* Transaction type.
|
|
81
|
+
*/
|
|
82
|
+
type: 1;
|
|
83
|
+
/**
|
|
84
|
+
* Transaction chain ID
|
|
85
|
+
*/
|
|
86
|
+
chainId: Bytes;
|
|
87
|
+
/**
|
|
88
|
+
* List of addresses and storage keys that the transaction plans to access
|
|
89
|
+
*/
|
|
90
|
+
accessList: {
|
|
91
|
+
address: Hex;
|
|
92
|
+
storageKeys: Hex[];
|
|
93
|
+
}[] | {
|
|
94
|
+
address: Uint8Array;
|
|
95
|
+
storageKeys: Uint8Array[];
|
|
96
|
+
}[];
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* EIP-1559 Transaction: Fee market change for ETH 1.0 chain (Type-2)
|
|
100
|
+
*
|
|
101
|
+
* Reference: https://eips.ethereum.org/EIPS/eip-1559
|
|
102
|
+
*/
|
|
103
|
+
export type EIP1559Transaction = TypedTransaction & {
|
|
104
|
+
/**
|
|
105
|
+
* Transaction type.
|
|
106
|
+
*/
|
|
107
|
+
type: 2;
|
|
108
|
+
/**
|
|
109
|
+
* Maximum fee to give to the miner
|
|
110
|
+
*/
|
|
111
|
+
maxPriorityFeePerGas: Bytes;
|
|
112
|
+
/**
|
|
113
|
+
* Maximum total fee
|
|
114
|
+
*/
|
|
115
|
+
maxFeePerGas: Bytes;
|
|
116
|
+
};
|
|
117
|
+
//# sourceMappingURL=transaction-types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction-types.d.mts","sourceRoot":"","sources":["../src/transaction-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,oBAAgB;AACrC,OAAO,KAAK,EAAE,GAAG,EAAE,kBAAc;AAEjC,MAAM,MAAM,WAAW,GACnB,iBAAiB,GACjB,kBAAkB,GAClB,kBAAkB,CAAC;AAEvB,MAAM,MAAM,iBAAiB,GAAG,WAAW,GAAG,SAAS,CAAC;AAExD,MAAM,MAAM,SAAS,GAAG;IACtB;;;OAGG;IACH,CAAC,EAAE,KAAK,CAAC;IAET;;;;OAIG;IACH,CAAC,EAAE,KAAK,CAAC;IAET;;;OAGG;IACH,OAAO,EAAE,KAAK,CAAC;CAChB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B;;;OAGG;IACH,KAAK,EAAE,KAAK,CAAC;IAEb;;OAEG;IACH,IAAI,EAAE,GAAG,GAAG,UAAU,CAAC;IAEvB;;;;OAIG;IACH,EAAE,EAAE,GAAG,GAAG,UAAU,CAAC;IAErB;;OAEG;IACH,KAAK,EAAE,KAAK,CAAC;IAEb;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC;IAEhB;;OAEG;IACH,IAAI,CAAC,EAAE,KAAK,CAAC;CACd,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,eAAe,GAAG;IAC/C;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,eAAe,GAAG;IAChD;;OAEG;IACH,QAAQ,EAAE,KAAK,GAAG,IAAI,CAAC;CACxB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG,gBAAgB,GAAG;IAClD;;OAEG;IACH,IAAI,EAAE,CAAC,CAAC;IAER;;OAEG;IACH,OAAO,EAAE,KAAK,CAAC;IAEf;;OAEG;IACH,UAAU,EACN;QAAE,OAAO,EAAE,GAAG,CAAC;QAAC,WAAW,EAAE,GAAG,EAAE,CAAA;KAAE,EAAE,GACtC;QAAE,OAAO,EAAE,UAAU,CAAC;QAAC,WAAW,EAAE,UAAU,EAAE,CAAA;KAAE,EAAE,CAAC;CAC1D,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,gBAAgB,GAAG;IAClD;;OAEG;IACH,IAAI,EAAE,CAAC,CAAC;IAER;;OAEG;IACH,oBAAoB,EAAE,KAAK,CAAC;IAE5B;;OAEG;IACH,YAAY,EAAE,KAAK,CAAC;CACrB,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
|
2
2
|
//# sourceMappingURL=transaction-types.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"file":"transaction-types.mjs","sourceRoot":"","sources":["../src/transaction-types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Bytes } from './bytes';\nimport type { Hex } from './hex';\n\nexport type Transaction =\n | LegacyTransaction\n | EIP2930Transaction\n | EIP1559Transaction;\n\nexport type SignedTransaction = Transaction & Signature;\n\nexport type Signature = {\n /**\n * EC signature parameter\n * 32 bytes long sequence.\n */\n r: Bytes;\n\n /**\n * EC signature parameter\n * Signature proof.\n * 32 bytes long sequence\n */\n s: Bytes;\n\n /**\n * Recovery identifier. It can be either 0x1b or 0x1c\n * 1 byte long sequence\n */\n yParity: Bytes;\n};\n\n/**\n * Base Ethereum Transaction\n */\nexport type BaseTransaction = {\n /**\n * Sequentially incrementing counter which indicates the transaction\n * number from the account\n */\n nonce: Bytes;\n\n /**\n * The address of the sender, that will be signing the transaction\n */\n from: Hex | Uint8Array;\n\n /**\n * The receiving address.\n * If an externally-owned account, the transaction will transfer value.\n * If a contract account, the transaction will execute the contract code.\n */\n to: Hex | Uint8Array;\n\n /**\n * The amount of Ether sent.\n */\n value: Bytes;\n\n /**\n * Maximum amount of gas units that this transaction can consume.\n */\n gasLimit: Bytes;\n\n /**\n * Arbitrary data.\n */\n data?: Bytes;\n};\n\n/**\n * Typed Ethereum Transaction\n */\nexport type TypedTransaction = BaseTransaction & {\n /**\n * Transaction type.\n */\n type: number;\n};\n\n/**\n * Ethereum Legacy Transaction\n * Reference: https://ethereum.org/en/developers/docs/transactions/\n */\nexport type LegacyTransaction = BaseTransaction & {\n /**\n * Transaction's gas price.\n */\n gasPrice: Bytes | null;\n};\n\n/**\n * EIP-2930 Transaction: Optional Access Lists\n * Reference: https://eips.ethereum.org/EIPS/eip-2930\n */\nexport type EIP2930Transaction = TypedTransaction & {\n /**\n * Transaction type.\n */\n type: 1;\n\n /**\n * Transaction chain ID\n */\n chainId: Bytes;\n\n /**\n * List of addresses and storage keys that the transaction plans to access\n */\n accessList:\n | { address: Hex; storageKeys: Hex[] }[]\n | { address: Uint8Array; storageKeys: Uint8Array[] }[];\n};\n\n/**\n * EIP-1559 Transaction: Fee market change for ETH 1.0 chain (Type-2)\n *\n * Reference: https://eips.ethereum.org/EIPS/eip-1559\n */\nexport type EIP1559Transaction = TypedTransaction & {\n /**\n * Transaction type.\n */\n type: 2;\n\n /**\n * Maximum fee to give to the miner\n */\n maxPriorityFeePerGas: Bytes;\n\n /**\n * Maximum total fee\n */\n maxFeePerGas: Bytes;\n};\n"]}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.satisfiesVersionRange = exports.gtRange = exports.gtVersion = exports.assertIsSemVerRange = exports.assertIsSemVerVersion = exports.isValidSemVerRange = exports.isValidSemVerVersion = exports.VersionRangeStruct = exports.VersionStruct = void 0;
|
|
4
|
+
const superstruct_1 = require("@metamask/superstruct");
|
|
5
|
+
const semver_1 = require("semver");
|
|
6
|
+
const assert_1 = require("./assert.cjs");
|
|
7
|
+
/**
|
|
8
|
+
* A struct for validating a version string.
|
|
9
|
+
*/
|
|
10
|
+
exports.VersionStruct = (0, superstruct_1.refine)((0, superstruct_1.string)(), 'Version', (value) => {
|
|
11
|
+
if ((0, semver_1.valid)(value) === null) {
|
|
12
|
+
return `Expected SemVer version, got "${value}"`;
|
|
13
|
+
}
|
|
14
|
+
return true;
|
|
15
|
+
});
|
|
16
|
+
exports.VersionRangeStruct = (0, superstruct_1.refine)((0, superstruct_1.string)(), 'Version range', (value) => {
|
|
17
|
+
if ((0, semver_1.validRange)(value) === null) {
|
|
18
|
+
return `Expected SemVer range, got "${value}"`;
|
|
19
|
+
}
|
|
20
|
+
return true;
|
|
21
|
+
});
|
|
22
|
+
/**
|
|
23
|
+
* Checks whether a SemVer version is valid.
|
|
24
|
+
*
|
|
25
|
+
* @param version - A potential version.
|
|
26
|
+
* @returns `true` if the version is valid, and `false` otherwise.
|
|
27
|
+
*/
|
|
28
|
+
function isValidSemVerVersion(version) {
|
|
29
|
+
return (0, superstruct_1.is)(version, exports.VersionStruct);
|
|
30
|
+
}
|
|
31
|
+
exports.isValidSemVerVersion = isValidSemVerVersion;
|
|
32
|
+
/**
|
|
33
|
+
* Checks whether a SemVer version range is valid.
|
|
34
|
+
*
|
|
35
|
+
* @param versionRange - A potential version range.
|
|
36
|
+
* @returns `true` if the version range is valid, and `false` otherwise.
|
|
37
|
+
*/
|
|
38
|
+
function isValidSemVerRange(versionRange) {
|
|
39
|
+
return (0, superstruct_1.is)(versionRange, exports.VersionRangeStruct);
|
|
40
|
+
}
|
|
41
|
+
exports.isValidSemVerRange = isValidSemVerRange;
|
|
42
|
+
/**
|
|
43
|
+
* Asserts that a value is a valid concrete SemVer version.
|
|
44
|
+
*
|
|
45
|
+
* @param version - A potential SemVer concrete version.
|
|
46
|
+
*/
|
|
47
|
+
function assertIsSemVerVersion(version) {
|
|
48
|
+
(0, assert_1.assertStruct)(version, exports.VersionStruct);
|
|
49
|
+
}
|
|
50
|
+
exports.assertIsSemVerVersion = assertIsSemVerVersion;
|
|
51
|
+
/**
|
|
52
|
+
* Asserts that a value is a valid SemVer range.
|
|
53
|
+
*
|
|
54
|
+
* @param range - A potential SemVer range.
|
|
55
|
+
*/
|
|
56
|
+
function assertIsSemVerRange(range) {
|
|
57
|
+
(0, assert_1.assertStruct)(range, exports.VersionRangeStruct);
|
|
58
|
+
}
|
|
59
|
+
exports.assertIsSemVerRange = assertIsSemVerRange;
|
|
60
|
+
/**
|
|
61
|
+
* Checks whether a SemVer version is greater than another.
|
|
62
|
+
*
|
|
63
|
+
* @param version1 - The left-hand version.
|
|
64
|
+
* @param version2 - The right-hand version.
|
|
65
|
+
* @returns `version1 > version2`.
|
|
66
|
+
*/
|
|
67
|
+
function gtVersion(version1, version2) {
|
|
68
|
+
return (0, semver_1.gt)(version1, version2);
|
|
69
|
+
}
|
|
70
|
+
exports.gtVersion = gtVersion;
|
|
71
|
+
/**
|
|
72
|
+
* Checks whether a SemVer version is greater than all possibilities in a range.
|
|
73
|
+
*
|
|
74
|
+
* @param version - A SemvVer version.
|
|
75
|
+
* @param range - The range to check against.
|
|
76
|
+
* @returns `version > range`.
|
|
77
|
+
*/
|
|
78
|
+
function gtRange(version, range) {
|
|
79
|
+
return (0, semver_1.gtr)(version, range);
|
|
80
|
+
}
|
|
81
|
+
exports.gtRange = gtRange;
|
|
82
|
+
/**
|
|
83
|
+
* Returns whether a SemVer version satisfies a SemVer range.
|
|
84
|
+
*
|
|
85
|
+
* @param version - The SemVer version to check.
|
|
86
|
+
* @param versionRange - The SemVer version range to check against.
|
|
87
|
+
* @returns Whether the version satisfied the version range.
|
|
88
|
+
*/
|
|
89
|
+
function satisfiesVersionRange(version, versionRange) {
|
|
90
|
+
return (0, semver_1.satisfies)(version, versionRange, {
|
|
91
|
+
includePrerelease: true,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
exports.satisfiesVersionRange = satisfiesVersionRange;
|
|
95
|
+
//# sourceMappingURL=versions.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"versions.cjs","sourceRoot":"","sources":["../src/versions.ts"],"names":[],"mappings":";;;AACA,uDAA2D;AAC3D,mCAMgB;AAEhB,yCAAwC;AA+CxC;;GAEG;AACU,QAAA,aAAa,GAAG,IAAA,oBAAM,EACjC,IAAA,oBAAM,GAA4C,EAClD,SAAS,EACT,CAAC,KAAK,EAAE,EAAE;IACR,IAAI,IAAA,cAAkB,EAAC,KAAK,CAAC,KAAK,IAAI,EAAE;QACtC,OAAO,iCAAiC,KAAK,GAAG,CAAC;KAClD;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CACF,CAAC;AAEW,QAAA,kBAAkB,GAAG,IAAA,oBAAM,EACtC,IAAA,oBAAM,GAA0C,EAChD,eAAe,EACf,CAAC,KAAK,EAAE,EAAE;IACR,IAAI,IAAA,mBAAgB,EAAC,KAAK,CAAC,KAAK,IAAI,EAAE;QACpC,OAAO,+BAA+B,KAAK,GAAG,CAAC;KAChD;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CACF,CAAC;AAEF;;;;;GAKG;AACH,SAAgB,oBAAoB,CAClC,OAAgB;IAEhB,OAAO,IAAA,gBAAE,EAAC,OAAO,EAAE,qBAAa,CAAC,CAAC;AACpC,CAAC;AAJD,oDAIC;AAED;;;;;GAKG;AACH,SAAgB,kBAAkB,CAChC,YAAqB;IAErB,OAAO,IAAA,gBAAE,EAAC,YAAY,EAAE,0BAAkB,CAAC,CAAC;AAC9C,CAAC;AAJD,gDAIC;AAED;;;;GAIG;AACH,SAAgB,qBAAqB,CACnC,OAAgB;IAEhB,IAAA,qBAAY,EAAC,OAAO,EAAE,qBAAa,CAAC,CAAC;AACvC,CAAC;AAJD,sDAIC;AAED;;;;GAIG;AACH,SAAgB,mBAAmB,CACjC,KAAc;IAEd,IAAA,qBAAY,EAAC,KAAK,EAAE,0BAAkB,CAAC,CAAC;AAC1C,CAAC;AAJD,kDAIC;AAED;;;;;;GAMG;AACH,SAAgB,SAAS,CACvB,QAAuB,EACvB,QAAuB;IAEvB,OAAO,IAAA,WAAQ,EAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;AACtC,CAAC;AALD,8BAKC;AAED;;;;;;GAMG;AACH,SAAgB,OAAO,CAAC,OAAsB,EAAE,KAAkB;IAChE,OAAO,IAAA,YAAS,EAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AACnC,CAAC;AAFD,0BAEC;AAED;;;;;;GAMG;AACH,SAAgB,qBAAqB,CACnC,OAAsB,EACtB,YAAyB;IAEzB,OAAO,IAAA,kBAAe,EAAC,OAAO,EAAE,YAAY,EAAE;QAC5C,iBAAiB,EAAE,IAAI;KACxB,CAAC,CAAC;AACL,CAAC;AAPD,sDAOC","sourcesContent":["import type { Struct } from '@metamask/superstruct';\nimport { is, refine, string } from '@metamask/superstruct';\nimport {\n gt as gtSemver,\n gtr as gtrSemver,\n satisfies as satisfiesSemver,\n valid as validSemVerVersion,\n validRange as validSemVerRange,\n} from 'semver';\n\nimport { assertStruct } from './assert';\nimport type { Opaque } from './opaque';\n\n/**\n * {@link https://codemix.com/opaque-types-in-javascript/ Opaque} type for SemVer ranges.\n *\n * @example Use {@link assertIsSemVerRange} and {@link isValidSemVerRange} to cast to proper type.\n * ```typescript\n * const unsafeRange: string = dataFromUser();\n * assertIsSemVerRange(unsafeRange);\n * unsafeRange\n * // ^? SemVerRange\n * ```\n * @example If you know what you're doing and want to side-step type safety, casting from a string works correctly.\n * ```typescript\n * const unsafeRange: string = dataFromUser();\n * unsafeRange as SemVerRange;\n * // ^? SemVerRange\n * ```\n * @see {@link assertIsSemVerRange}\n * @see {@link isValidSemVerRange}\n */\nexport type SemVerRange = Opaque<string, typeof semVerRange>;\ndeclare const semVerRange: unique symbol;\n\n/**\n * {@link https://codemix.com/opaque-types-in-javascript/ Opaque} type for singular SemVer version.\n *\n * @example Use {@link assertIsSemVerVersion} and {@link isValidSemVerVersion} to cast to proper type.\n * ```typescript\n * const unsafeVersion: string = dataFromUser();\n * assertIsSemVerVersion(unsafeRange);\n * unsafeVersion\n * // ^? SemVerVersion\n * ```\n * @example If you know what you're doing and want to side-step type safety, casting from a string works correctly.\n * ```typescript\n * const unsafeVersion: string = dataFromUser();\n * unsafeRange as SemVerVersion;\n * // ^? SemVerVersion\n * ```\n * @see {@link assertIsSemVerVersion}\n * @see {@link isValidSemVerVersion}\n */\nexport type SemVerVersion = Opaque<string, typeof semVerVersion>;\ndeclare const semVerVersion: unique symbol;\n\n/**\n * A struct for validating a version string.\n */\nexport const VersionStruct = refine<SemVerVersion, null>(\n string() as unknown as Struct<SemVerVersion, null>,\n 'Version',\n (value) => {\n if (validSemVerVersion(value) === null) {\n return `Expected SemVer version, got \"${value}\"`;\n }\n return true;\n },\n);\n\nexport const VersionRangeStruct = refine<SemVerRange, null>(\n string() as unknown as Struct<SemVerRange, null>,\n 'Version range',\n (value) => {\n if (validSemVerRange(value) === null) {\n return `Expected SemVer range, got \"${value}\"`;\n }\n return true;\n },\n);\n\n/**\n * Checks whether a SemVer version is valid.\n *\n * @param version - A potential version.\n * @returns `true` if the version is valid, and `false` otherwise.\n */\nexport function isValidSemVerVersion(\n version: unknown,\n): version is SemVerVersion {\n return is(version, VersionStruct);\n}\n\n/**\n * Checks whether a SemVer version range is valid.\n *\n * @param versionRange - A potential version range.\n * @returns `true` if the version range is valid, and `false` otherwise.\n */\nexport function isValidSemVerRange(\n versionRange: unknown,\n): versionRange is SemVerRange {\n return is(versionRange, VersionRangeStruct);\n}\n\n/**\n * Asserts that a value is a valid concrete SemVer version.\n *\n * @param version - A potential SemVer concrete version.\n */\nexport function assertIsSemVerVersion(\n version: unknown,\n): asserts version is SemVerVersion {\n assertStruct(version, VersionStruct);\n}\n\n/**\n * Asserts that a value is a valid SemVer range.\n *\n * @param range - A potential SemVer range.\n */\nexport function assertIsSemVerRange(\n range: unknown,\n): asserts range is SemVerRange {\n assertStruct(range, VersionRangeStruct);\n}\n\n/**\n * Checks whether a SemVer version is greater than another.\n *\n * @param version1 - The left-hand version.\n * @param version2 - The right-hand version.\n * @returns `version1 > version2`.\n */\nexport function gtVersion(\n version1: SemVerVersion,\n version2: SemVerVersion,\n): boolean {\n return gtSemver(version1, version2);\n}\n\n/**\n * Checks whether a SemVer version is greater than all possibilities in a range.\n *\n * @param version - A SemvVer version.\n * @param range - The range to check against.\n * @returns `version > range`.\n */\nexport function gtRange(version: SemVerVersion, range: SemVerRange): boolean {\n return gtrSemver(version, range);\n}\n\n/**\n * Returns whether a SemVer version satisfies a SemVer range.\n *\n * @param version - The SemVer version to check.\n * @param versionRange - The SemVer version range to check against.\n * @returns Whether the version satisfied the version range.\n */\nexport function satisfiesVersionRange(\n version: SemVerVersion,\n versionRange: SemVerRange,\n): boolean {\n return satisfiesSemver(version, versionRange, {\n includePrerelease: true,\n });\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Struct } from
|
|
2
|
-
import type { Opaque } from
|
|
1
|
+
import type { Struct } from "@metamask/superstruct";
|
|
2
|
+
import type { Opaque } from "./opaque.cjs";
|
|
3
3
|
/**
|
|
4
4
|
* {@link https://codemix.com/opaque-types-in-javascript/ Opaque} type for SemVer ranges.
|
|
5
5
|
*
|
|
@@ -19,7 +19,7 @@ import type { Opaque } from './opaque';
|
|
|
19
19
|
* @see {@link assertIsSemVerRange}
|
|
20
20
|
* @see {@link isValidSemVerRange}
|
|
21
21
|
*/
|
|
22
|
-
export
|
|
22
|
+
export type SemVerRange = Opaque<string, typeof semVerRange>;
|
|
23
23
|
declare const semVerRange: unique symbol;
|
|
24
24
|
/**
|
|
25
25
|
* {@link https://codemix.com/opaque-types-in-javascript/ Opaque} type for singular SemVer version.
|
|
@@ -40,7 +40,7 @@ declare const semVerRange: unique symbol;
|
|
|
40
40
|
* @see {@link assertIsSemVerVersion}
|
|
41
41
|
* @see {@link isValidSemVerVersion}
|
|
42
42
|
*/
|
|
43
|
-
export
|
|
43
|
+
export type SemVerVersion = Opaque<string, typeof semVerVersion>;
|
|
44
44
|
declare const semVerVersion: unique symbol;
|
|
45
45
|
/**
|
|
46
46
|
* A struct for validating a version string.
|
|
@@ -98,4 +98,4 @@ export declare function gtRange(version: SemVerVersion, range: SemVerRange): boo
|
|
|
98
98
|
*/
|
|
99
99
|
export declare function satisfiesVersionRange(version: SemVerVersion, versionRange: SemVerRange): boolean;
|
|
100
100
|
export {};
|
|
101
|
-
//# sourceMappingURL=versions.d.
|
|
101
|
+
//# sourceMappingURL=versions.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"versions.d.cts","sourceRoot":"","sources":["../src/versions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,8BAA8B;AAWpD,OAAO,KAAK,EAAE,MAAM,EAAE,qBAAiB;AAEvC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,WAAW,CAAC,CAAC;AAC7D,OAAO,CAAC,MAAM,WAAW,EAAE,OAAO,MAAM,CAAC;AAEzC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,aAAa,CAAC,CAAC;AACjE,OAAO,CAAC,MAAM,aAAa,EAAE,OAAO,MAAM,CAAC;AAE3C;;GAEG;AACH,eAAO,MAAM,aAAa,6BASzB,CAAC;AAEF,eAAO,MAAM,kBAAkB,2BAS9B,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,OAAO,GACf,OAAO,IAAI,aAAa,CAE1B;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,YAAY,EAAE,OAAO,GACpB,YAAY,IAAI,WAAW,CAE7B;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,OAAO,IAAI,aAAa,CAElC;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,KAAK,IAAI,WAAW,CAE9B;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CACvB,QAAQ,EAAE,aAAa,EACvB,QAAQ,EAAE,aAAa,GACtB,OAAO,CAET;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,WAAW,GAAG,OAAO,CAE3E;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,aAAa,EACtB,YAAY,EAAE,WAAW,GACxB,OAAO,CAIT"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { Struct } from "@metamask/superstruct";
|
|
2
|
+
import type { Opaque } from "./opaque.mjs";
|
|
3
|
+
/**
|
|
4
|
+
* {@link https://codemix.com/opaque-types-in-javascript/ Opaque} type for SemVer ranges.
|
|
5
|
+
*
|
|
6
|
+
* @example Use {@link assertIsSemVerRange} and {@link isValidSemVerRange} to cast to proper type.
|
|
7
|
+
* ```typescript
|
|
8
|
+
* const unsafeRange: string = dataFromUser();
|
|
9
|
+
* assertIsSemVerRange(unsafeRange);
|
|
10
|
+
* unsafeRange
|
|
11
|
+
* // ^? SemVerRange
|
|
12
|
+
* ```
|
|
13
|
+
* @example If you know what you're doing and want to side-step type safety, casting from a string works correctly.
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const unsafeRange: string = dataFromUser();
|
|
16
|
+
* unsafeRange as SemVerRange;
|
|
17
|
+
* // ^? SemVerRange
|
|
18
|
+
* ```
|
|
19
|
+
* @see {@link assertIsSemVerRange}
|
|
20
|
+
* @see {@link isValidSemVerRange}
|
|
21
|
+
*/
|
|
22
|
+
export type SemVerRange = Opaque<string, typeof semVerRange>;
|
|
23
|
+
declare const semVerRange: unique symbol;
|
|
24
|
+
/**
|
|
25
|
+
* {@link https://codemix.com/opaque-types-in-javascript/ Opaque} type for singular SemVer version.
|
|
26
|
+
*
|
|
27
|
+
* @example Use {@link assertIsSemVerVersion} and {@link isValidSemVerVersion} to cast to proper type.
|
|
28
|
+
* ```typescript
|
|
29
|
+
* const unsafeVersion: string = dataFromUser();
|
|
30
|
+
* assertIsSemVerVersion(unsafeRange);
|
|
31
|
+
* unsafeVersion
|
|
32
|
+
* // ^? SemVerVersion
|
|
33
|
+
* ```
|
|
34
|
+
* @example If you know what you're doing and want to side-step type safety, casting from a string works correctly.
|
|
35
|
+
* ```typescript
|
|
36
|
+
* const unsafeVersion: string = dataFromUser();
|
|
37
|
+
* unsafeRange as SemVerVersion;
|
|
38
|
+
* // ^? SemVerVersion
|
|
39
|
+
* ```
|
|
40
|
+
* @see {@link assertIsSemVerVersion}
|
|
41
|
+
* @see {@link isValidSemVerVersion}
|
|
42
|
+
*/
|
|
43
|
+
export type SemVerVersion = Opaque<string, typeof semVerVersion>;
|
|
44
|
+
declare const semVerVersion: unique symbol;
|
|
45
|
+
/**
|
|
46
|
+
* A struct for validating a version string.
|
|
47
|
+
*/
|
|
48
|
+
export declare const VersionStruct: Struct<SemVerVersion, null>;
|
|
49
|
+
export declare const VersionRangeStruct: Struct<SemVerRange, null>;
|
|
50
|
+
/**
|
|
51
|
+
* Checks whether a SemVer version is valid.
|
|
52
|
+
*
|
|
53
|
+
* @param version - A potential version.
|
|
54
|
+
* @returns `true` if the version is valid, and `false` otherwise.
|
|
55
|
+
*/
|
|
56
|
+
export declare function isValidSemVerVersion(version: unknown): version is SemVerVersion;
|
|
57
|
+
/**
|
|
58
|
+
* Checks whether a SemVer version range is valid.
|
|
59
|
+
*
|
|
60
|
+
* @param versionRange - A potential version range.
|
|
61
|
+
* @returns `true` if the version range is valid, and `false` otherwise.
|
|
62
|
+
*/
|
|
63
|
+
export declare function isValidSemVerRange(versionRange: unknown): versionRange is SemVerRange;
|
|
64
|
+
/**
|
|
65
|
+
* Asserts that a value is a valid concrete SemVer version.
|
|
66
|
+
*
|
|
67
|
+
* @param version - A potential SemVer concrete version.
|
|
68
|
+
*/
|
|
69
|
+
export declare function assertIsSemVerVersion(version: unknown): asserts version is SemVerVersion;
|
|
70
|
+
/**
|
|
71
|
+
* Asserts that a value is a valid SemVer range.
|
|
72
|
+
*
|
|
73
|
+
* @param range - A potential SemVer range.
|
|
74
|
+
*/
|
|
75
|
+
export declare function assertIsSemVerRange(range: unknown): asserts range is SemVerRange;
|
|
76
|
+
/**
|
|
77
|
+
* Checks whether a SemVer version is greater than another.
|
|
78
|
+
*
|
|
79
|
+
* @param version1 - The left-hand version.
|
|
80
|
+
* @param version2 - The right-hand version.
|
|
81
|
+
* @returns `version1 > version2`.
|
|
82
|
+
*/
|
|
83
|
+
export declare function gtVersion(version1: SemVerVersion, version2: SemVerVersion): boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Checks whether a SemVer version is greater than all possibilities in a range.
|
|
86
|
+
*
|
|
87
|
+
* @param version - A SemvVer version.
|
|
88
|
+
* @param range - The range to check against.
|
|
89
|
+
* @returns `version > range`.
|
|
90
|
+
*/
|
|
91
|
+
export declare function gtRange(version: SemVerVersion, range: SemVerRange): boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Returns whether a SemVer version satisfies a SemVer range.
|
|
94
|
+
*
|
|
95
|
+
* @param version - The SemVer version to check.
|
|
96
|
+
* @param versionRange - The SemVer version range to check against.
|
|
97
|
+
* @returns Whether the version satisfied the version range.
|
|
98
|
+
*/
|
|
99
|
+
export declare function satisfiesVersionRange(version: SemVerVersion, versionRange: SemVerRange): boolean;
|
|
100
|
+
export {};
|
|
101
|
+
//# sourceMappingURL=versions.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"versions.d.mts","sourceRoot":"","sources":["../src/versions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,8BAA8B;AAWpD,OAAO,KAAK,EAAE,MAAM,EAAE,qBAAiB;AAEvC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,WAAW,CAAC,CAAC;AAC7D,OAAO,CAAC,MAAM,WAAW,EAAE,OAAO,MAAM,CAAC;AAEzC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,aAAa,CAAC,CAAC;AACjE,OAAO,CAAC,MAAM,aAAa,EAAE,OAAO,MAAM,CAAC;AAE3C;;GAEG;AACH,eAAO,MAAM,aAAa,6BASzB,CAAC;AAEF,eAAO,MAAM,kBAAkB,2BAS9B,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,OAAO,GACf,OAAO,IAAI,aAAa,CAE1B;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,YAAY,EAAE,OAAO,GACpB,YAAY,IAAI,WAAW,CAE7B;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,OAAO,IAAI,aAAa,CAElC;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,KAAK,IAAI,WAAW,CAE9B;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CACvB,QAAQ,EAAE,aAAa,EACvB,QAAQ,EAAE,aAAa,GACtB,OAAO,CAET;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,WAAW,GAAG,OAAO,CAE3E;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,aAAa,EACtB,YAAY,EAAE,WAAW,GACxB,OAAO,CAIT"}
|