@metamask/utils 8.0.0 → 8.2.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 +25 -1
- package/dist/assert.js +16 -0
- package/dist/assert.js.map +1 -0
- package/dist/assert.mjs +16 -0
- package/dist/assert.mjs.map +1 -0
- package/dist/base64.js +11 -0
- package/dist/base64.js.map +1 -0
- package/dist/base64.mjs +11 -0
- package/dist/base64.mjs.map +1 -0
- package/dist/bytes.js +43 -0
- package/dist/bytes.js.map +1 -0
- package/dist/bytes.mjs +43 -0
- package/dist/bytes.mjs.map +1 -0
- package/dist/caip-types.js +40 -0
- package/dist/caip-types.js.map +1 -0
- package/dist/caip-types.mjs +40 -0
- package/dist/caip-types.mjs.map +1 -0
- package/dist/checksum.js +12 -0
- package/dist/checksum.js.map +1 -0
- package/dist/checksum.mjs +12 -0
- package/dist/checksum.mjs.map +1 -0
- package/dist/chunk-2CY4F77D.mjs +95 -0
- package/dist/chunk-2CY4F77D.mjs.map +1 -0
- package/dist/chunk-2LBGT4GH.js +15 -0
- package/dist/chunk-2LBGT4GH.js.map +1 -0
- package/dist/chunk-2TBCL6EF.js +1 -0
- package/dist/chunk-2TBCL6EF.js.map +1 -0
- package/dist/chunk-3W5G4CYI.js +25 -0
- package/dist/chunk-3W5G4CYI.js.map +1 -0
- package/dist/chunk-4JNG5UTO.js +44 -0
- package/dist/chunk-4JNG5UTO.js.map +1 -0
- package/dist/chunk-4RMX5YWE.js +34 -0
- package/dist/chunk-4RMX5YWE.js.map +1 -0
- package/dist/chunk-5WQRFJVQ.js +257 -0
- package/dist/chunk-5WQRFJVQ.js.map +1 -0
- package/dist/chunk-65KBH4FZ.mjs +257 -0
- package/dist/chunk-65KBH4FZ.mjs.map +1 -0
- package/dist/chunk-7S5AWFX7.mjs +61 -0
- package/dist/chunk-7S5AWFX7.mjs.map +1 -0
- package/dist/chunk-AY6FDCBT.mjs +1 -0
- package/dist/chunk-AY6FDCBT.mjs.map +1 -0
- package/dist/chunk-BKR45GQY.mjs +273 -0
- package/dist/chunk-BKR45GQY.mjs.map +1 -0
- package/dist/chunk-CSDMTDND.mjs +59 -0
- package/dist/chunk-CSDMTDND.mjs.map +1 -0
- package/dist/chunk-DMPG3H3G.js +61 -0
- package/dist/chunk-DMPG3H3G.js.map +1 -0
- package/dist/chunk-DYMCEQIV.mjs +1 -0
- package/dist/chunk-DYMCEQIV.mjs.map +1 -0
- package/dist/chunk-EQMZL4XU.js +1 -0
- package/dist/chunk-EQMZL4XU.js.map +1 -0
- package/dist/chunk-G66TREC6.mjs +69 -0
- package/dist/chunk-G66TREC6.mjs.map +1 -0
- package/dist/chunk-H4YFDLB7.mjs +70 -0
- package/dist/chunk-H4YFDLB7.mjs.map +1 -0
- package/dist/chunk-HLDWS2JR.mjs +35 -0
- package/dist/chunk-HLDWS2JR.mjs.map +1 -0
- package/dist/chunk-I575FZFH.mjs +1 -0
- package/dist/chunk-I575FZFH.mjs.map +1 -0
- package/dist/chunk-JCYFTGED.js +95 -0
- package/dist/chunk-JCYFTGED.js.map +1 -0
- package/dist/chunk-JPAL7Q5S.mjs +90 -0
- package/dist/chunk-JPAL7Q5S.mjs.map +1 -0
- package/dist/chunk-LC2CRSWD.js +1 -0
- package/dist/chunk-LC2CRSWD.js.map +1 -0
- package/dist/chunk-N53OILN6.mjs +16 -0
- package/dist/chunk-N53OILN6.mjs.map +1 -0
- package/dist/chunk-QVEKZRZ2.js +70 -0
- package/dist/chunk-QVEKZRZ2.js.map +1 -0
- package/dist/chunk-RIRDOQPX.mjs +15 -0
- package/dist/chunk-RIRDOQPX.mjs.map +1 -0
- package/dist/chunk-RKRGAFXY.js +1 -0
- package/dist/chunk-RKRGAFXY.js.map +1 -0
- package/dist/chunk-RRYOWRCV.mjs +1 -0
- package/dist/chunk-RRYOWRCV.mjs.map +1 -0
- package/dist/chunk-TGOMTREC.mjs +75 -0
- package/dist/chunk-TGOMTREC.mjs.map +1 -0
- package/dist/chunk-THNLGEXV.mjs +34 -0
- package/dist/chunk-THNLGEXV.mjs.map +1 -0
- package/dist/chunk-U7ZUGCE7.js +75 -0
- package/dist/chunk-U7ZUGCE7.js.map +1 -0
- package/dist/chunk-UOTVU7OQ.js +1 -0
- package/dist/chunk-UOTVU7OQ.js.map +1 -0
- package/dist/chunk-VBYRLAP6.js +59 -0
- package/dist/chunk-VBYRLAP6.js.map +1 -0
- package/dist/chunk-VL5DYXC5.mjs +122 -0
- package/dist/chunk-VL5DYXC5.mjs.map +1 -0
- package/dist/chunk-VSEW3V2L.mjs +44 -0
- package/dist/chunk-VSEW3V2L.mjs.map +1 -0
- package/dist/chunk-WA4DHIND.mjs +1 -0
- package/dist/chunk-WA4DHIND.mjs.map +1 -0
- package/dist/chunk-WQDTPIQK.js +122 -0
- package/dist/chunk-WQDTPIQK.js.map +1 -0
- package/dist/chunk-WRBN6DWM.js +35 -0
- package/dist/chunk-WRBN6DWM.js.map +1 -0
- package/dist/chunk-X66SUIEF.mjs +25 -0
- package/dist/chunk-X66SUIEF.mjs.map +1 -0
- package/dist/chunk-XYYGZF5Y.js +16 -0
- package/dist/chunk-XYYGZF5Y.js.map +1 -0
- package/dist/chunk-YQJBIHC7.js +273 -0
- package/dist/chunk-YQJBIHC7.js.map +1 -0
- package/dist/chunk-Z2RGWDD7.js +90 -0
- package/dist/chunk-Z2RGWDD7.js.map +1 -0
- package/dist/chunk-ZRNIY7OW.js +69 -0
- package/dist/chunk-ZRNIY7OW.js.map +1 -0
- package/dist/coercers.js +18 -0
- package/dist/coercers.js.map +1 -0
- package/dist/coercers.mjs +18 -0
- package/dist/coercers.mjs.map +1 -0
- package/dist/collections.js +10 -0
- package/dist/collections.js.map +1 -0
- package/dist/collections.mjs +10 -0
- package/dist/collections.mjs.map +1 -0
- package/dist/encryption-types.js +2 -0
- package/dist/encryption-types.js.map +1 -0
- package/dist/encryption-types.mjs +2 -0
- package/dist/encryption-types.mjs.map +1 -0
- package/dist/errors.js +17 -0
- package/dist/errors.js.map +1 -0
- package/dist/errors.mjs +17 -0
- package/dist/errors.mjs.map +1 -0
- package/dist/fs.js +26 -0
- package/dist/fs.js.map +1 -0
- package/dist/fs.mjs +26 -0
- package/dist/fs.mjs.map +1 -0
- package/dist/hex.js +35 -0
- package/dist/hex.js.map +1 -0
- package/dist/hex.mjs +35 -0
- package/dist/hex.mjs.map +1 -0
- package/dist/index.js +289 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +289 -0
- package/dist/index.mjs.map +1 -0
- package/dist/json.js +75 -0
- package/dist/json.js.map +1 -0
- package/dist/json.mjs +75 -0
- package/dist/json.mjs.map +1 -0
- package/dist/keyring.js +2 -0
- package/dist/keyring.js.map +1 -0
- package/dist/keyring.mjs +2 -0
- package/dist/keyring.mjs.map +1 -0
- package/dist/logging.js +10 -0
- package/dist/logging.js.map +1 -0
- package/dist/logging.mjs +10 -0
- package/dist/logging.mjs.map +1 -0
- package/dist/misc.js +28 -0
- package/dist/misc.js.map +1 -0
- package/dist/misc.mjs +28 -0
- package/dist/misc.mjs.map +1 -0
- package/dist/node.js +309 -0
- package/dist/node.js.map +1 -0
- package/dist/node.mjs +309 -0
- package/dist/node.mjs.map +1 -0
- package/dist/number.js +18 -0
- package/dist/number.js.map +1 -0
- package/dist/number.mjs +18 -0
- package/dist/number.mjs.map +1 -0
- package/dist/opaque.js +2 -0
- package/dist/opaque.js.map +1 -0
- package/dist/opaque.mjs +2 -0
- package/dist/opaque.mjs.map +1 -0
- package/dist/time.js +12 -0
- package/dist/time.js.map +1 -0
- package/dist/time.mjs +12 -0
- package/dist/time.mjs.map +1 -0
- package/dist/transaction-types.js +2 -0
- package/dist/transaction-types.js.map +1 -0
- package/dist/transaction-types.mjs +2 -0
- package/dist/transaction-types.mjs.map +1 -0
- package/dist/types/assert.d.ts.map +1 -1
- package/dist/types/bytes.d.ts +14 -0
- package/dist/types/bytes.d.ts.map +1 -1
- package/dist/types/errors.d.ts +58 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/fs.d.ts +133 -0
- package/dist/types/fs.d.ts.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/json.d.ts +83 -47
- package/dist/types/json.d.ts.map +1 -1
- package/dist/types/node.d.ts +3 -0
- package/dist/types/node.d.ts.map +1 -0
- package/dist/versions.js +27 -0
- package/dist/versions.js.map +1 -0
- package/dist/versions.mjs +27 -0
- package/dist/versions.mjs.map +1 -0
- package/package.json +21 -20
- package/dist/cjs/assert.js +0 -116
- package/dist/cjs/assert.js.map +0 -1
- package/dist/cjs/base64.js +0 -32
- package/dist/cjs/base64.js.map +0 -1
- package/dist/cjs/bytes.js +0 -255
- package/dist/cjs/bytes.js.map +0 -1
- package/dist/cjs/caip-types.js +0 -115
- package/dist/cjs/caip-types.js.map +0 -1
- package/dist/cjs/checksum.js +0 -17
- package/dist/cjs/checksum.js.map +0 -1
- package/dist/cjs/coercers.js +0 -96
- package/dist/cjs/coercers.js.map +0 -1
- package/dist/cjs/collections.js +0 -157
- package/dist/cjs/collections.js.map +0 -1
- package/dist/cjs/encryption-types.js +0 -6
- package/dist/cjs/encryption-types.js.map +0 -1
- package/dist/cjs/hex.js +0 -107
- package/dist/cjs/hex.js.map +0 -1
- package/dist/cjs/index.js +0 -37
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/json.js +0 -263
- package/dist/cjs/json.js.map +0 -1
- package/dist/cjs/keyring.js +0 -6
- package/dist/cjs/keyring.js.map +0 -1
- package/dist/cjs/logging.js +0 -33
- package/dist/cjs/logging.js.map +0 -1
- package/dist/cjs/misc.js +0 -111
- package/dist/cjs/misc.js.map +0 -1
- package/dist/cjs/number.js +0 -52
- package/dist/cjs/number.js.map +0 -1
- package/dist/cjs/opaque.js +0 -8
- package/dist/cjs/opaque.js.map +0 -1
- package/dist/cjs/time.js +0 -63
- package/dist/cjs/time.js.map +0 -1
- package/dist/cjs/transaction-types.js +0 -6
- package/dist/cjs/transaction-types.js.map +0 -1
- package/dist/cjs/versions.js +0 -79
- package/dist/cjs/versions.js.map +0 -1
- package/dist/esm/assert.js +0 -133
- package/dist/esm/assert.js.map +0 -1
- package/dist/esm/base64.js +0 -28
- package/dist/esm/base64.js.map +0 -1
- package/dist/esm/bytes.js +0 -334
- package/dist/esm/bytes.js.map +0 -1
- package/dist/esm/caip-types.js +0 -99
- package/dist/esm/caip-types.js.map +0 -1
- package/dist/esm/checksum.js +0 -7
- package/dist/esm/checksum.js.map +0 -1
- package/dist/esm/coercers.js +0 -153
- package/dist/esm/coercers.js.map +0 -1
- package/dist/esm/collections.js +0 -140
- package/dist/esm/collections.js.map +0 -1
- package/dist/esm/encryption-types.js +0 -3
- package/dist/esm/encryption-types.js.map +0 -1
- package/dist/esm/hex.js +0 -108
- package/dist/esm/hex.js.map +0 -1
- package/dist/esm/index.js +0 -20
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/json.js +0 -301
- package/dist/esm/json.js.map +0 -1
- package/dist/esm/keyring.js +0 -3
- package/dist/esm/keyring.js.map +0 -1
- package/dist/esm/logging.js +0 -34
- package/dist/esm/logging.js.map +0 -1
- package/dist/esm/misc.js +0 -129
- package/dist/esm/misc.js.map +0 -1
- package/dist/esm/number.js +0 -92
- package/dist/esm/number.js.map +0 -1
- package/dist/esm/opaque.js +0 -5
- package/dist/esm/opaque.js.map +0 -1
- package/dist/esm/package.json +0 -1
- package/dist/esm/time.js +0 -53
- package/dist/esm/time.js.map +0 -1
- package/dist/esm/transaction-types.js +0 -3
- package/dist/esm/transaction-types.js.map +0 -1
- package/dist/esm/versions.js +0 -78
- package/dist/esm/versions.js.map +0 -1
- package/dist/types/caip-types.test-d.d.ts +0 -2
- package/dist/types/caip-types.test-d.d.ts.map +0 -1
- package/dist/types/hex.test-d.d.ts +0 -2
- package/dist/types/hex.test-d.d.ts.map +0 -1
- package/dist/types/json.test-d.d.ts +0 -2
- package/dist/types/json.test-d.d.ts.map +0 -1
- package/dist/types/misc.test-d.d.ts +0 -2
- package/dist/types/misc.test-d.d.ts.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,28 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [8.2.0]
|
|
10
|
+
### Added
|
|
11
|
+
- Add struct utils for validating JSON objects with optional values ([#136](https://github.com/MetaMask/utils/pull/136))
|
|
12
|
+
- Add filesystem utils ([#148](https://github.com/MetaMask/utils/pull/148))
|
|
13
|
+
- Add error utils ([#146](https://github.com/MetaMask/utils/pull/146), [#151](https://github.com/MetaMask/utils/pull/151))
|
|
14
|
+
- Add base64 encoding and decoding functions ([#145](https://github.com/MetaMask/utils/pull/145))
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
- Use `tsup` for bundling ([#144](https://github.com/MetaMask/utils/pull/144))
|
|
18
|
+
- This makes the package fully compliant with ES modules.
|
|
19
|
+
- Bump `@ethereumjs/tx` from `4.1.2` to `4.2.0` ([#133](https://github.com/MetaMask/utils/pull/133))
|
|
20
|
+
|
|
21
|
+
## [8.1.0]
|
|
22
|
+
### Changed
|
|
23
|
+
- Make types for JSON-RPC-related structs more accurate ([#134](https://github.com/MetaMask/utils/pull/134))
|
|
24
|
+
- Aligning `JsonRpcParams` to be optional, yet not `undefined`.
|
|
25
|
+
- Updated types:
|
|
26
|
+
- `InferWithParams`
|
|
27
|
+
- `JsonRpcNotificationStruct`
|
|
28
|
+
- `JsonRpcParamsStruct`
|
|
29
|
+
- `JsonRpcRequestStruct`
|
|
30
|
+
|
|
9
31
|
## [8.0.0]
|
|
10
32
|
### Changed
|
|
11
33
|
- **BREAKING:** `JsonRpcParams` type no longer accepts `undefined` as value, as `undefined` is not a valid JSON type ([#130](https://github.com/MetaMask/utils/pull/130))
|
|
@@ -182,7 +204,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
182
204
|
### Added
|
|
183
205
|
- Initial release
|
|
184
206
|
|
|
185
|
-
[Unreleased]: https://github.com/MetaMask/utils/compare/v8.
|
|
207
|
+
[Unreleased]: https://github.com/MetaMask/utils/compare/v8.2.0...HEAD
|
|
208
|
+
[8.2.0]: https://github.com/MetaMask/utils/compare/v8.1.0...v8.2.0
|
|
209
|
+
[8.1.0]: https://github.com/MetaMask/utils/compare/v8.0.0...v8.1.0
|
|
186
210
|
[8.0.0]: https://github.com/MetaMask/utils/compare/v7.1.0...v8.0.0
|
|
187
211
|
[7.1.0]: https://github.com/MetaMask/utils/compare/v7.0.0...v7.1.0
|
|
188
212
|
[7.0.0]: https://github.com/MetaMask/utils/compare/v6.2.0...v7.0.0
|
package/dist/assert.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkVBYRLAP6js = require('./chunk-VBYRLAP6.js');
|
|
7
|
+
require('./chunk-DMPG3H3G.js');
|
|
8
|
+
require('./chunk-QVEKZRZ2.js');
|
|
9
|
+
require('./chunk-3W5G4CYI.js');
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
exports.AssertionError = _chunkVBYRLAP6js.AssertionError; exports.assert = _chunkVBYRLAP6js.assert; exports.assertExhaustive = _chunkVBYRLAP6js.assertExhaustive; exports.assertStruct = _chunkVBYRLAP6js.assertStruct;
|
|
16
|
+
//# sourceMappingURL=assert.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
package/dist/assert.mjs
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AssertionError,
|
|
3
|
+
assert,
|
|
4
|
+
assertExhaustive,
|
|
5
|
+
assertStruct
|
|
6
|
+
} from "./chunk-CSDMTDND.mjs";
|
|
7
|
+
import "./chunk-7S5AWFX7.mjs";
|
|
8
|
+
import "./chunk-H4YFDLB7.mjs";
|
|
9
|
+
import "./chunk-X66SUIEF.mjs";
|
|
10
|
+
export {
|
|
11
|
+
AssertionError,
|
|
12
|
+
assert,
|
|
13
|
+
assertExhaustive,
|
|
14
|
+
assertStruct
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=assert.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/base64.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkWRBN6DWMjs = require('./chunk-WRBN6DWM.js');
|
|
4
|
+
require('./chunk-VBYRLAP6.js');
|
|
5
|
+
require('./chunk-DMPG3H3G.js');
|
|
6
|
+
require('./chunk-QVEKZRZ2.js');
|
|
7
|
+
require('./chunk-3W5G4CYI.js');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
exports.base64 = _chunkWRBN6DWMjs.base64;
|
|
11
|
+
//# sourceMappingURL=base64.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
package/dist/base64.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/bytes.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
var _chunkYQJBIHC7js = require('./chunk-YQJBIHC7.js');
|
|
20
|
+
require('./chunk-VBYRLAP6.js');
|
|
21
|
+
require('./chunk-DMPG3H3G.js');
|
|
22
|
+
require('./chunk-QVEKZRZ2.js');
|
|
23
|
+
require('./chunk-3W5G4CYI.js');
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
exports.assertIsBytes = _chunkYQJBIHC7js.assertIsBytes; exports.base64ToBytes = _chunkYQJBIHC7js.base64ToBytes; exports.bigIntToBytes = _chunkYQJBIHC7js.bigIntToBytes; exports.bytesToBase64 = _chunkYQJBIHC7js.bytesToBase64; exports.bytesToBigInt = _chunkYQJBIHC7js.bytesToBigInt; exports.bytesToHex = _chunkYQJBIHC7js.bytesToHex; exports.bytesToNumber = _chunkYQJBIHC7js.bytesToNumber; exports.bytesToSignedBigInt = _chunkYQJBIHC7js.bytesToSignedBigInt; exports.bytesToString = _chunkYQJBIHC7js.bytesToString; exports.concatBytes = _chunkYQJBIHC7js.concatBytes; exports.createDataView = _chunkYQJBIHC7js.createDataView; exports.hexToBytes = _chunkYQJBIHC7js.hexToBytes; exports.isBytes = _chunkYQJBIHC7js.isBytes; exports.numberToBytes = _chunkYQJBIHC7js.numberToBytes; exports.signedBigIntToBytes = _chunkYQJBIHC7js.signedBigIntToBytes; exports.stringToBytes = _chunkYQJBIHC7js.stringToBytes; exports.valueToBytes = _chunkYQJBIHC7js.valueToBytes;
|
|
43
|
+
//# sourceMappingURL=bytes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
package/dist/bytes.mjs
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import {
|
|
2
|
+
assertIsBytes,
|
|
3
|
+
base64ToBytes,
|
|
4
|
+
bigIntToBytes,
|
|
5
|
+
bytesToBase64,
|
|
6
|
+
bytesToBigInt,
|
|
7
|
+
bytesToHex,
|
|
8
|
+
bytesToNumber,
|
|
9
|
+
bytesToSignedBigInt,
|
|
10
|
+
bytesToString,
|
|
11
|
+
concatBytes,
|
|
12
|
+
createDataView,
|
|
13
|
+
hexToBytes,
|
|
14
|
+
isBytes,
|
|
15
|
+
numberToBytes,
|
|
16
|
+
signedBigIntToBytes,
|
|
17
|
+
stringToBytes,
|
|
18
|
+
valueToBytes
|
|
19
|
+
} from "./chunk-BKR45GQY.mjs";
|
|
20
|
+
import "./chunk-CSDMTDND.mjs";
|
|
21
|
+
import "./chunk-7S5AWFX7.mjs";
|
|
22
|
+
import "./chunk-H4YFDLB7.mjs";
|
|
23
|
+
import "./chunk-X66SUIEF.mjs";
|
|
24
|
+
export {
|
|
25
|
+
assertIsBytes,
|
|
26
|
+
base64ToBytes,
|
|
27
|
+
bigIntToBytes,
|
|
28
|
+
bytesToBase64,
|
|
29
|
+
bytesToBigInt,
|
|
30
|
+
bytesToHex,
|
|
31
|
+
bytesToNumber,
|
|
32
|
+
bytesToSignedBigInt,
|
|
33
|
+
bytesToString,
|
|
34
|
+
concatBytes,
|
|
35
|
+
createDataView,
|
|
36
|
+
hexToBytes,
|
|
37
|
+
isBytes,
|
|
38
|
+
numberToBytes,
|
|
39
|
+
signedBigIntToBytes,
|
|
40
|
+
stringToBytes,
|
|
41
|
+
valueToBytes
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=bytes.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
var _chunkU7ZUGCE7js = require('./chunk-U7ZUGCE7.js');
|
|
20
|
+
require('./chunk-3W5G4CYI.js');
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
exports.CAIP_ACCOUNT_ADDRESS_REGEX = _chunkU7ZUGCE7js.CAIP_ACCOUNT_ADDRESS_REGEX; exports.CAIP_ACCOUNT_ID_REGEX = _chunkU7ZUGCE7js.CAIP_ACCOUNT_ID_REGEX; exports.CAIP_CHAIN_ID_REGEX = _chunkU7ZUGCE7js.CAIP_CHAIN_ID_REGEX; exports.CAIP_NAMESPACE_REGEX = _chunkU7ZUGCE7js.CAIP_NAMESPACE_REGEX; exports.CAIP_REFERENCE_REGEX = _chunkU7ZUGCE7js.CAIP_REFERENCE_REGEX; exports.CaipAccountAddressStruct = _chunkU7ZUGCE7js.CaipAccountAddressStruct; exports.CaipAccountIdStruct = _chunkU7ZUGCE7js.CaipAccountIdStruct; exports.CaipChainIdStruct = _chunkU7ZUGCE7js.CaipChainIdStruct; exports.CaipNamespaceStruct = _chunkU7ZUGCE7js.CaipNamespaceStruct; exports.CaipReferenceStruct = _chunkU7ZUGCE7js.CaipReferenceStruct; exports.isCaipAccountAddress = _chunkU7ZUGCE7js.isCaipAccountAddress; exports.isCaipAccountId = _chunkU7ZUGCE7js.isCaipAccountId; exports.isCaipChainId = _chunkU7ZUGCE7js.isCaipChainId; exports.isCaipNamespace = _chunkU7ZUGCE7js.isCaipNamespace; exports.isCaipReference = _chunkU7ZUGCE7js.isCaipReference; exports.parseCaipAccountId = _chunkU7ZUGCE7js.parseCaipAccountId; exports.parseCaipChainId = _chunkU7ZUGCE7js.parseCaipChainId;
|
|
40
|
+
//# sourceMappingURL=caip-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CAIP_ACCOUNT_ADDRESS_REGEX,
|
|
3
|
+
CAIP_ACCOUNT_ID_REGEX,
|
|
4
|
+
CAIP_CHAIN_ID_REGEX,
|
|
5
|
+
CAIP_NAMESPACE_REGEX,
|
|
6
|
+
CAIP_REFERENCE_REGEX,
|
|
7
|
+
CaipAccountAddressStruct,
|
|
8
|
+
CaipAccountIdStruct,
|
|
9
|
+
CaipChainIdStruct,
|
|
10
|
+
CaipNamespaceStruct,
|
|
11
|
+
CaipReferenceStruct,
|
|
12
|
+
isCaipAccountAddress,
|
|
13
|
+
isCaipAccountId,
|
|
14
|
+
isCaipChainId,
|
|
15
|
+
isCaipNamespace,
|
|
16
|
+
isCaipReference,
|
|
17
|
+
parseCaipAccountId,
|
|
18
|
+
parseCaipChainId
|
|
19
|
+
} from "./chunk-TGOMTREC.mjs";
|
|
20
|
+
import "./chunk-X66SUIEF.mjs";
|
|
21
|
+
export {
|
|
22
|
+
CAIP_ACCOUNT_ADDRESS_REGEX,
|
|
23
|
+
CAIP_ACCOUNT_ID_REGEX,
|
|
24
|
+
CAIP_CHAIN_ID_REGEX,
|
|
25
|
+
CAIP_NAMESPACE_REGEX,
|
|
26
|
+
CAIP_REFERENCE_REGEX,
|
|
27
|
+
CaipAccountAddressStruct,
|
|
28
|
+
CaipAccountIdStruct,
|
|
29
|
+
CaipChainIdStruct,
|
|
30
|
+
CaipNamespaceStruct,
|
|
31
|
+
CaipReferenceStruct,
|
|
32
|
+
isCaipAccountAddress,
|
|
33
|
+
isCaipAccountId,
|
|
34
|
+
isCaipChainId,
|
|
35
|
+
isCaipNamespace,
|
|
36
|
+
isCaipReference,
|
|
37
|
+
parseCaipAccountId,
|
|
38
|
+
parseCaipChainId
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=caip-types.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/checksum.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkXYYGZF5Yjs = require('./chunk-XYYGZF5Y.js');
|
|
4
|
+
require('./chunk-WRBN6DWM.js');
|
|
5
|
+
require('./chunk-VBYRLAP6.js');
|
|
6
|
+
require('./chunk-DMPG3H3G.js');
|
|
7
|
+
require('./chunk-QVEKZRZ2.js');
|
|
8
|
+
require('./chunk-3W5G4CYI.js');
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
exports.ChecksumStruct = _chunkXYYGZF5Yjs.ChecksumStruct;
|
|
12
|
+
//# sourceMappingURL=checksum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChecksumStruct
|
|
3
|
+
} from "./chunk-N53OILN6.mjs";
|
|
4
|
+
import "./chunk-HLDWS2JR.mjs";
|
|
5
|
+
import "./chunk-CSDMTDND.mjs";
|
|
6
|
+
import "./chunk-7S5AWFX7.mjs";
|
|
7
|
+
import "./chunk-H4YFDLB7.mjs";
|
|
8
|
+
import "./chunk-X66SUIEF.mjs";
|
|
9
|
+
export {
|
|
10
|
+
ChecksumStruct
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=checksum.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import {
|
|
2
|
+
StrictHexStruct,
|
|
3
|
+
bytesToHex,
|
|
4
|
+
hexToBytes
|
|
5
|
+
} from "./chunk-BKR45GQY.mjs";
|
|
6
|
+
import {
|
|
7
|
+
assert
|
|
8
|
+
} from "./chunk-CSDMTDND.mjs";
|
|
9
|
+
|
|
10
|
+
// src/coercers.ts
|
|
11
|
+
import {
|
|
12
|
+
bigint,
|
|
13
|
+
coerce,
|
|
14
|
+
create,
|
|
15
|
+
instance,
|
|
16
|
+
number,
|
|
17
|
+
string,
|
|
18
|
+
StructError,
|
|
19
|
+
union
|
|
20
|
+
} from "superstruct";
|
|
21
|
+
var NumberLikeStruct = union([number(), bigint(), string(), StrictHexStruct]);
|
|
22
|
+
var NumberCoercer = coerce(number(), NumberLikeStruct, Number);
|
|
23
|
+
var BigIntCoercer = coerce(bigint(), NumberLikeStruct, BigInt);
|
|
24
|
+
var BytesLikeStruct = union([StrictHexStruct, instance(Uint8Array)]);
|
|
25
|
+
var BytesCoercer = coerce(
|
|
26
|
+
instance(Uint8Array),
|
|
27
|
+
union([StrictHexStruct]),
|
|
28
|
+
hexToBytes
|
|
29
|
+
);
|
|
30
|
+
var HexCoercer = coerce(StrictHexStruct, instance(Uint8Array), bytesToHex);
|
|
31
|
+
function createNumber(value) {
|
|
32
|
+
try {
|
|
33
|
+
const result = create(value, NumberCoercer);
|
|
34
|
+
assert(
|
|
35
|
+
Number.isFinite(result),
|
|
36
|
+
`Expected a number-like value, got "${value}".`
|
|
37
|
+
);
|
|
38
|
+
return result;
|
|
39
|
+
} catch (error) {
|
|
40
|
+
if (error instanceof StructError) {
|
|
41
|
+
throw new Error(`Expected a number-like value, got "${value}".`);
|
|
42
|
+
}
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function createBigInt(value) {
|
|
47
|
+
try {
|
|
48
|
+
return create(value, BigIntCoercer);
|
|
49
|
+
} catch (error) {
|
|
50
|
+
if (error instanceof StructError) {
|
|
51
|
+
throw new Error(
|
|
52
|
+
`Expected a number-like value, got "${String(error.value)}".`
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
throw error;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function createBytes(value) {
|
|
59
|
+
if (typeof value === "string" && value.toLowerCase() === "0x") {
|
|
60
|
+
return new Uint8Array();
|
|
61
|
+
}
|
|
62
|
+
try {
|
|
63
|
+
return create(value, BytesCoercer);
|
|
64
|
+
} catch (error) {
|
|
65
|
+
if (error instanceof StructError) {
|
|
66
|
+
throw new Error(
|
|
67
|
+
`Expected a bytes-like value, got "${String(error.value)}".`
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function createHex(value) {
|
|
74
|
+
if (value instanceof Uint8Array && value.length === 0 || typeof value === "string" && value.toLowerCase() === "0x") {
|
|
75
|
+
return "0x";
|
|
76
|
+
}
|
|
77
|
+
try {
|
|
78
|
+
return create(value, HexCoercer);
|
|
79
|
+
} catch (error) {
|
|
80
|
+
if (error instanceof StructError) {
|
|
81
|
+
throw new Error(
|
|
82
|
+
`Expected a bytes-like value, got "${String(error.value)}".`
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
throw error;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export {
|
|
90
|
+
createNumber,
|
|
91
|
+
createBigInt,
|
|
92
|
+
createBytes,
|
|
93
|
+
createHex
|
|
94
|
+
};
|
|
95
|
+
//# sourceMappingURL=chunk-2CY4F77D.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/coercers.ts"],"sourcesContent":["import type { Infer } from 'superstruct';\nimport {\n bigint,\n coerce,\n create,\n instance,\n number,\n string,\n StructError,\n union,\n} from 'superstruct';\n\nimport { assert } from './assert';\nimport { bytesToHex, hexToBytes } from './bytes';\nimport type { Hex } from './hex';\nimport { StrictHexStruct } from './hex';\n\nconst NumberLikeStruct = union([number(), bigint(), string(), StrictHexStruct]);\nconst NumberCoercer = coerce(number(), NumberLikeStruct, Number);\nconst BigIntCoercer = coerce(bigint(), NumberLikeStruct, BigInt);\n\nconst BytesLikeStruct = union([StrictHexStruct, instance(Uint8Array)]);\nconst BytesCoercer = coerce(\n instance(Uint8Array),\n union([StrictHexStruct]),\n hexToBytes,\n);\n\nconst HexCoercer = coerce(StrictHexStruct, instance(Uint8Array), bytesToHex);\n\nexport type NumberLike = Infer<typeof NumberLikeStruct>;\nexport type BytesLike = Infer<typeof BytesLikeStruct>;\n\n/**\n * Create a number from a number-like value.\n *\n * - If the value is a number, it is returned as-is.\n * - If the value is a `bigint`, it is converted to a number.\n * - If the value is a string, it is interpreted as a decimal number.\n * - If the value is a hex string (i.e., it starts with \"0x\"), it is\n * interpreted as a hexadecimal number.\n *\n * This validates that the value is a number-like value, and that the resulting\n * number is not `NaN` or `Infinity`.\n *\n * @example\n * ```typescript\n * const value = createNumber('0x010203');\n * console.log(value); // 66051\n *\n * const otherValue = createNumber(123n);\n * console.log(otherValue); // 123\n * ```\n * @param value - The value to create the number from.\n * @returns The created number.\n * @throws If the value is not a number-like value, or if the resulting number\n * is `NaN` or `Infinity`.\n */\nexport function createNumber(value: NumberLike): number {\n try {\n const result = create(value, NumberCoercer);\n\n assert(\n Number.isFinite(result),\n `Expected a number-like value, got \"${value}\".`,\n );\n\n return result;\n } catch (error) {\n if (error instanceof StructError) {\n throw new Error(`Expected a number-like value, got \"${value}\".`);\n }\n\n /* istanbul ignore next */\n throw error;\n }\n}\n\n/**\n * Create a `bigint` from a number-like value.\n *\n * - If the value is a number, it is converted to a `bigint`.\n * - If the value is a `bigint`, it is returned as-is.\n * - If the value is a string, it is interpreted as a decimal number and\n * converted to a `bigint`.\n * - If the value is a hex string (i.e., it starts with \"0x\"), it is\n * interpreted as a hexadecimal number and converted to a `bigint`.\n *\n * @example\n * ```typescript\n * const value = createBigInt('0x010203');\n * console.log(value); // 16909060n\n *\n * const otherValue = createBigInt(123);\n * console.log(otherValue); // 123n\n * ```\n * @param value - The value to create the bigint from.\n * @returns The created bigint.\n * @throws If the value is not a number-like value.\n */\nexport function createBigInt(value: NumberLike): bigint {\n try {\n // The `BigInt` constructor throws if the value is not a number-like value.\n // There is no need to validate the value manually.\n return create(value, BigIntCoercer);\n } catch (error) {\n if (error instanceof StructError) {\n throw new Error(\n `Expected a number-like value, got \"${String(error.value)}\".`,\n );\n }\n\n /* istanbul ignore next */\n throw error;\n }\n}\n\n/**\n * Create a byte array from a bytes-like value.\n *\n * - If the value is a byte array, it is returned as-is.\n * - If the value is a hex string (i.e., it starts with \"0x\"), it is interpreted\n * as a hexadecimal number and converted to a byte array.\n *\n * @example\n * ```typescript\n * const value = createBytes('0x010203');\n * console.log(value); // Uint8Array [ 1, 2, 3 ]\n *\n * const otherValue = createBytes('0x010203');\n * console.log(otherValue); // Uint8Array [ 1, 2, 3 ]\n * ```\n * @param value - The value to create the byte array from.\n * @returns The created byte array.\n * @throws If the value is not a bytes-like value.\n */\nexport function createBytes(value: BytesLike): Uint8Array {\n if (typeof value === 'string' && value.toLowerCase() === '0x') {\n return new Uint8Array();\n }\n\n try {\n return create(value, BytesCoercer);\n } catch (error) {\n if (error instanceof StructError) {\n throw new Error(\n `Expected a bytes-like value, got \"${String(error.value)}\".`,\n );\n }\n\n /* istanbul ignore next */\n throw error;\n }\n}\n\n/**\n * Create a hexadecimal string from a bytes-like value.\n *\n * - If the value is a hex string (i.e., it starts with \"0x\"), it is returned\n * as-is.\n * - If the value is a `Uint8Array`, it is converted to a hex string.\n *\n * @example\n * ```typescript\n * const value = createHex(new Uint8Array([1, 2, 3]));\n * console.log(value); // '0x010203'\n *\n * const otherValue = createHex('0x010203');\n * console.log(otherValue); // '0x010203'\n * ```\n * @param value - The value to create the hex string from.\n * @returns The created hex string.\n * @throws If the value is not a bytes-like value.\n */\nexport function createHex(value: BytesLike): Hex {\n if (\n (value instanceof Uint8Array && value.length === 0) ||\n (typeof value === 'string' && value.toLowerCase() === '0x')\n ) {\n return '0x';\n }\n\n try {\n return create(value, HexCoercer);\n } catch (error) {\n if (error instanceof StructError) {\n throw new Error(\n `Expected a bytes-like value, got \"${String(error.value)}\".`,\n );\n }\n\n /* istanbul ignore next */\n throw error;\n }\n}\n"],"mappings":";;;;;;;;;;AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAOP,IAAM,mBAAmB,MAAM,CAAC,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,eAAe,CAAC;AAC9E,IAAM,gBAAgB,OAAO,OAAO,GAAG,kBAAkB,MAAM;AAC/D,IAAM,gBAAgB,OAAO,OAAO,GAAG,kBAAkB,MAAM;AAE/D,IAAM,kBAAkB,MAAM,CAAC,iBAAiB,SAAS,UAAU,CAAC,CAAC;AACrE,IAAM,eAAe;AAAA,EACnB,SAAS,UAAU;AAAA,EACnB,MAAM,CAAC,eAAe,CAAC;AAAA,EACvB;AACF;AAEA,IAAM,aAAa,OAAO,iBAAiB,SAAS,UAAU,GAAG,UAAU;AA8BpE,SAAS,aAAa,OAA2B;AACtD,MAAI;AACF,UAAM,SAAS,OAAO,OAAO,aAAa;AAE1C;AAAA,MACE,OAAO,SAAS,MAAM;AAAA,MACtB,sCAAsC,KAAK;AAAA,IAC7C;AAEA,WAAO;AAAA,EACT,SAAS,OAAO;AACd,QAAI,iBAAiB,aAAa;AAChC,YAAM,IAAI,MAAM,sCAAsC,KAAK,IAAI;AAAA,IACjE;AAGA,UAAM;AAAA,EACR;AACF;AAwBO,SAAS,aAAa,OAA2B;AACtD,MAAI;AAGF,WAAO,OAAO,OAAO,aAAa;AAAA,EACpC,SAAS,OAAO;AACd,QAAI,iBAAiB,aAAa;AAChC,YAAM,IAAI;AAAA,QACR,sCAAsC,OAAO,MAAM,KAAK,CAAC;AAAA,MAC3D;AAAA,IACF;AAGA,UAAM;AAAA,EACR;AACF;AAqBO,SAAS,YAAY,OAA8B;AACxD,MAAI,OAAO,UAAU,YAAY,MAAM,YAAY,MAAM,MAAM;AAC7D,WAAO,IAAI,WAAW;AAAA,EACxB;AAEA,MAAI;AACF,WAAO,OAAO,OAAO,YAAY;AAAA,EACnC,SAAS,OAAO;AACd,QAAI,iBAAiB,aAAa;AAChC,YAAM,IAAI;AAAA,QACR,qCAAqC,OAAO,MAAM,KAAK,CAAC;AAAA,MAC1D;AAAA,IACF;AAGA,UAAM;AAAA,EACR;AACF;AAqBO,SAAS,UAAU,OAAuB;AAC/C,MACG,iBAAiB,cAAc,MAAM,WAAW,KAChD,OAAO,UAAU,YAAY,MAAM,YAAY,MAAM,MACtD;AACA,WAAO;AAAA,EACT;AAEA,MAAI;AACF,WAAO,OAAO,OAAO,UAAU;AAAA,EACjC,SAAS,OAAO;AACd,QAAI,iBAAiB,aAAa;AAChC,YAAM,IAAI;AAAA,QACR,qCAAqC,OAAO,MAAM,KAAK,CAAC;AAAA,MAC1D;AAAA,IACF;AAGA,UAAM;AAAA,EACR;AACF;","names":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }// src/logging.ts
|
|
2
|
+
var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
|
|
3
|
+
var globalLogger = _debug2.default.call(void 0, "metamask");
|
|
4
|
+
function createProjectLogger(projectName) {
|
|
5
|
+
return globalLogger.extend(projectName);
|
|
6
|
+
}
|
|
7
|
+
function createModuleLogger(projectLogger, moduleName) {
|
|
8
|
+
return projectLogger.extend(moduleName);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
exports.createProjectLogger = createProjectLogger; exports.createModuleLogger = createModuleLogger;
|
|
15
|
+
//# sourceMappingURL=chunk-2LBGT4GH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/logging.ts"],"names":[],"mappings":";AACA,OAAO,WAAW;AAElB,IAAM,eAAe,MAAM,UAAU;AAc9B,SAAS,oBAAoB,aAA+B;AACjE,SAAO,aAAa,OAAO,WAAW;AACxC;AAgBO,SAAS,mBACd,eACA,YACU;AACV,SAAO,cAAc,OAAO,UAAU;AACxC","sourcesContent":["import type { Debugger } from 'debug';\nimport debug from 'debug';\n\nconst globalLogger = debug('metamask');\n\n/**\n * Creates a logger via the `debug` library whose log messages will be tagged\n * using the name of your project. By default, such messages will be\n * suppressed, but you can reveal them by setting the `DEBUG` environment\n * variable to `metamask:<projectName>`. You can also set this variable to\n * `metamask:*` if you want to see log messages from all MetaMask projects that\n * are also using this function to create their loggers.\n *\n * @param projectName - The name of your project. This should be the name of\n * your NPM package if you're developing one.\n * @returns An instance of `debug`.\n */\nexport function createProjectLogger(projectName: string): Debugger {\n return globalLogger.extend(projectName);\n}\n\n/**\n * Creates a logger via the `debug` library which is derived from the logger for\n * the whole project whose log messages will be tagged using the name of your\n * module. By default, such messages will be suppressed, but you can reveal them\n * by setting the `DEBUG` environment variable to\n * `metamask:<projectName>:<moduleName>`. You can also set this variable to\n * `metamask:<projectName>:*` if you want to see log messages from the project,\n * or `metamask:*` if you want to see log messages from all MetaMask projects.\n *\n * @param projectLogger - The logger created via {@link createProjectLogger}.\n * @param moduleName - The name of your module. You could use the name of the\n * file where you're using this logger or some other name.\n * @returns An instance of `debug`.\n */\nexport function createModuleLogger(\n projectLogger: Debugger,\n moduleName: string,\n): Debugger {\n return projectLogger.extend(moduleName);\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";//# sourceMappingURL=chunk-2TBCL6EF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var __accessCheck = (obj, member, msg) => {
|
|
2
|
+
if (!member.has(obj))
|
|
3
|
+
throw TypeError("Cannot " + msg);
|
|
4
|
+
};
|
|
5
|
+
var __privateGet = (obj, member, getter) => {
|
|
6
|
+
__accessCheck(obj, member, "read from private field");
|
|
7
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
8
|
+
};
|
|
9
|
+
var __privateAdd = (obj, member, value) => {
|
|
10
|
+
if (member.has(obj))
|
|
11
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
12
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
13
|
+
};
|
|
14
|
+
var __privateSet = (obj, member, value, setter) => {
|
|
15
|
+
__accessCheck(obj, member, "write to private field");
|
|
16
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
17
|
+
return value;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
exports.__privateGet = __privateGet; exports.__privateAdd = __privateAdd; exports.__privateSet = __privateSet;
|
|
25
|
+
//# sourceMappingURL=chunk-3W5G4CYI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var _chunkYQJBIHC7js = require('./chunk-YQJBIHC7.js');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
var _chunkVBYRLAP6js = require('./chunk-VBYRLAP6.js');
|
|
8
|
+
|
|
9
|
+
// src/number.ts
|
|
10
|
+
var numberToHex = (value) => {
|
|
11
|
+
_chunkVBYRLAP6js.assert.call(void 0, typeof value === "number", "Value must be a number.");
|
|
12
|
+
_chunkVBYRLAP6js.assert.call(void 0, value >= 0, "Value must be a non-negative number.");
|
|
13
|
+
_chunkVBYRLAP6js.assert.call(void 0,
|
|
14
|
+
Number.isSafeInteger(value),
|
|
15
|
+
"Value is not a safe integer. Use `bigIntToHex` instead."
|
|
16
|
+
);
|
|
17
|
+
return _chunkYQJBIHC7js.add0x.call(void 0, value.toString(16));
|
|
18
|
+
};
|
|
19
|
+
var bigIntToHex = (value) => {
|
|
20
|
+
_chunkVBYRLAP6js.assert.call(void 0, typeof value === "bigint", "Value must be a bigint.");
|
|
21
|
+
_chunkVBYRLAP6js.assert.call(void 0, value >= 0, "Value must be a non-negative bigint.");
|
|
22
|
+
return _chunkYQJBIHC7js.add0x.call(void 0, value.toString(16));
|
|
23
|
+
};
|
|
24
|
+
var hexToNumber = (value) => {
|
|
25
|
+
_chunkYQJBIHC7js.assertIsHexString.call(void 0, value);
|
|
26
|
+
const numberValue = parseInt(value, 16);
|
|
27
|
+
_chunkVBYRLAP6js.assert.call(void 0,
|
|
28
|
+
Number.isSafeInteger(numberValue),
|
|
29
|
+
"Value is not a safe integer. Use `hexToBigInt` instead."
|
|
30
|
+
);
|
|
31
|
+
return numberValue;
|
|
32
|
+
};
|
|
33
|
+
var hexToBigInt = (value) => {
|
|
34
|
+
_chunkYQJBIHC7js.assertIsHexString.call(void 0, value);
|
|
35
|
+
return BigInt(_chunkYQJBIHC7js.add0x.call(void 0, value));
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
exports.numberToHex = numberToHex; exports.bigIntToHex = bigIntToHex; exports.hexToNumber = hexToNumber; exports.hexToBigInt = hexToBigInt;
|
|
44
|
+
//# sourceMappingURL=chunk-4JNG5UTO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/number.ts"],"names":[],"mappings":";;;;;;;;;AAoBO,IAAM,cAAc,CAAC,UAA0B;AACpD,SAAO,OAAO,UAAU,UAAU,yBAAyB;AAC3D,SAAO,SAAS,GAAG,sCAAsC;AACzD;AAAA,IACE,OAAO,cAAc,KAAK;AAAA,IAC1B;AAAA,EACF;AAEA,SAAO,MAAM,MAAM,SAAS,EAAE,CAAC;AACjC;AAkBO,IAAM,cAAc,CAAC,UAA0B;AACpD,SAAO,OAAO,UAAU,UAAU,yBAAyB;AAC3D,SAAO,SAAS,GAAG,sCAAsC;AAEzD,SAAO,MAAM,MAAM,SAAS,EAAE,CAAC;AACjC;AAqBO,IAAM,cAAc,CAAC,UAA0B;AACpD,oBAAkB,KAAK;AAIvB,QAAM,cAAc,SAAS,OAAO,EAAE;AAEtC;AAAA,IACE,OAAO,cAAc,WAAW;AAAA,IAChC;AAAA,EACF;AAEA,SAAO;AACT;AAkBO,IAAM,cAAc,CAAC,UAA0B;AACpD,oBAAkB,KAAK;AAGvB,SAAO,OAAO,MAAM,KAAK,CAAC;AAC5B","sourcesContent":["import { assert } from './assert';\nimport { add0x, assertIsHexString } from './hex';\n\n/**\n * Convert a number to a hexadecimal string. This verifies that the number is a\n * non-negative safe integer.\n *\n * To convert a `bigint` to a hexadecimal string instead, use\n * {@link bigIntToHex}.\n *\n * @example\n * ```typescript\n * numberToHex(0); // '0x0'\n * numberToHex(1); // '0x1'\n * numberToHex(16); // '0x10'\n * ```\n * @param value - The number to convert to a hexadecimal string.\n * @returns The hexadecimal string, with the \"0x\"-prefix.\n * @throws If the number is not a non-negative safe integer.\n */\nexport const numberToHex = (value: number): string => {\n assert(typeof value === 'number', 'Value must be a number.');\n assert(value >= 0, 'Value must be a non-negative number.');\n assert(\n Number.isSafeInteger(value),\n 'Value is not a safe integer. Use `bigIntToHex` instead.',\n );\n\n return add0x(value.toString(16));\n};\n\n/**\n * Convert a `bigint` to a hexadecimal string. This verifies that the `bigint`\n * is a non-negative integer.\n *\n * To convert a number to a hexadecimal string instead, use {@link numberToHex}.\n *\n * @example\n * ```typescript\n * bigIntToHex(0n); // '0x0'\n * bigIntToHex(1n); // '0x1'\n * bigIntToHex(16n); // '0x10'\n * ```\n * @param value - The `bigint` to convert to a hexadecimal string.\n * @returns The hexadecimal string, with the \"0x\"-prefix.\n * @throws If the `bigint` is not a non-negative integer.\n */\nexport const bigIntToHex = (value: bigint): string => {\n assert(typeof value === 'bigint', 'Value must be a bigint.');\n assert(value >= 0, 'Value must be a non-negative bigint.');\n\n return add0x(value.toString(16));\n};\n\n/**\n * Convert a hexadecimal string to a number. This verifies that the string is a\n * valid hex string, and that the resulting number is a safe integer. Both\n * \"0x\"-prefixed and unprefixed strings are supported.\n *\n * To convert a hexadecimal string to a `bigint` instead, use\n * {@link hexToBigInt}.\n *\n * @example\n * ```typescript\n * hexToNumber('0x0'); // 0\n * hexToNumber('0x1'); // 1\n * hexToNumber('0x10'); // 16\n * ```\n * @param value - The hexadecimal string to convert to a number.\n * @returns The number.\n * @throws If the value is not a valid hexadecimal string, or if the resulting\n * number is not a safe integer.\n */\nexport const hexToNumber = (value: string): number => {\n assertIsHexString(value);\n\n // `parseInt` accepts values without the \"0x\"-prefix, whereas `Number` does\n // not. Using this is slightly faster than `Number(add0x(value))`.\n const numberValue = parseInt(value, 16);\n\n assert(\n Number.isSafeInteger(numberValue),\n 'Value is not a safe integer. Use `hexToBigInt` instead.',\n );\n\n return numberValue;\n};\n\n/**\n * Convert a hexadecimal string to a `bigint`. This verifies that the string is\n * a valid hex string. Both \"0x\"-prefixed and unprefixed strings are supported.\n *\n * To convert a hexadecimal string to a number instead, use {@link hexToNumber}.\n *\n * @example\n * ```typescript\n * hexToBigInt('0x0'); // 0n\n * hexToBigInt('0x1'); // 1n\n * hexToBigInt('0x10'); // 16n\n * ```\n * @param value - The hexadecimal string to convert to a `bigint`.\n * @returns The `bigint`.\n * @throws If the value is not a valid hexadecimal string.\n */\nexport const hexToBigInt = (value: string): bigint => {\n assertIsHexString(value);\n\n // The `BigInt` constructor requires the \"0x\"-prefix to parse a hex string.\n return BigInt(add0x(value));\n};\n"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/time.ts
|
|
2
|
+
var Duration = /* @__PURE__ */ ((Duration2) => {
|
|
3
|
+
Duration2[Duration2["Millisecond"] = 1] = "Millisecond";
|
|
4
|
+
Duration2[Duration2["Second"] = 1e3] = "Second";
|
|
5
|
+
Duration2[Duration2["Minute"] = 6e4] = "Minute";
|
|
6
|
+
Duration2[Duration2["Hour"] = 36e5] = "Hour";
|
|
7
|
+
Duration2[Duration2["Day"] = 864e5] = "Day";
|
|
8
|
+
Duration2[Duration2["Week"] = 6048e5] = "Week";
|
|
9
|
+
Duration2[Duration2["Year"] = 31536e6] = "Year";
|
|
10
|
+
return Duration2;
|
|
11
|
+
})(Duration || {});
|
|
12
|
+
var isNonNegativeInteger = (number) => Number.isInteger(number) && number >= 0;
|
|
13
|
+
var assertIsNonNegativeInteger = (number, name) => {
|
|
14
|
+
if (!isNonNegativeInteger(number)) {
|
|
15
|
+
throw new Error(
|
|
16
|
+
`"${name}" must be a non-negative integer. Received: "${number}".`
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
function inMilliseconds(count, duration) {
|
|
21
|
+
assertIsNonNegativeInteger(count, "count");
|
|
22
|
+
return count * duration;
|
|
23
|
+
}
|
|
24
|
+
function timeSince(timestamp) {
|
|
25
|
+
assertIsNonNegativeInteger(timestamp, "timestamp");
|
|
26
|
+
return Date.now() - timestamp;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
exports.Duration = Duration; exports.inMilliseconds = inMilliseconds; exports.timeSince = timeSince;
|
|
34
|
+
//# sourceMappingURL=chunk-4RMX5YWE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/time.ts"],"names":["Duration"],"mappings":";AAGO,IAAK,WAAL,kBAAKA,cAAL;AAIL,EAAAA,oBAAA,iBAAc,KAAd;AAKA,EAAAA,oBAAA,YAAS,OAAT;AAKA,EAAAA,oBAAA,YAAS,OAAT;AAKA,EAAAA,oBAAA,UAAO,QAAP;AAKA,EAAAA,oBAAA,SAAM,SAAN;AAKA,EAAAA,oBAAA,UAAO,UAAP;AAKA,EAAAA,oBAAA,UAAO,WAAP;AAlCU,SAAAA;AAAA,GAAA;AAqCZ,IAAM,uBAAuB,CAAC,WAC5B,OAAO,UAAU,MAAM,KAAK,UAAU;AAExC,IAAM,6BAA6B,CAAC,QAAgB,SAAiB;AACnE,MAAI,CAAC,qBAAqB,MAAM,GAAG;AACjC,UAAM,IAAI;AAAA,MACR,IAAI,IAAI,gDAAgD,MAAM;AAAA,IAChE;AAAA,EACF;AACF;AASO,SAAS,eAAe,OAAe,UAA4B;AACxE,6BAA2B,OAAO,OAAO;AACzC,SAAO,QAAQ;AACjB;AAQO,SAAS,UAAU,WAA2B;AACnD,6BAA2B,WAAW,WAAW;AACjD,SAAO,KAAK,IAAI,IAAI;AACtB","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"]}
|