@metamask-previews/utils 11.12.1-preview-9962b7e
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 +584 -0
- package/LICENSE +15 -0
- package/README.md +106 -0
- package/dist/assert.d.ts +61 -0
- package/dist/assert.d.ts.map +1 -0
- package/dist/assert.js +115 -0
- package/dist/assert.js.map +1 -0
- package/dist/base64.d.ts +25 -0
- package/dist/base64.d.ts.map +1 -0
- package/dist/base64.js +30 -0
- package/dist/base64.js.map +1 -0
- package/dist/bytes.d.ts +198 -0
- package/dist/bytes.d.ts.map +1 -0
- package/dist/bytes.js +406 -0
- package/dist/bytes.js.map +1 -0
- package/dist/caip-types.d.ts +294 -0
- package/dist/caip-types.d.ts.map +1 -0
- package/dist/caip-types.js +369 -0
- package/dist/caip-types.js.map +1 -0
- package/dist/checksum.d.ts +2 -0
- package/dist/checksum.d.ts.map +1 -0
- package/dist/checksum.js +4 -0
- package/dist/checksum.js.map +1 -0
- package/dist/coercers.d.ts +97 -0
- package/dist/coercers.d.ts.map +1 -0
- package/dist/coercers.js +159 -0
- package/dist/coercers.js.map +1 -0
- package/dist/collections.d.ts +39 -0
- package/dist/collections.d.ts.map +1 -0
- package/dist/collections.js +105 -0
- package/dist/collections.js.map +1 -0
- package/dist/encryption-types.d.ts +7 -0
- package/dist/encryption-types.d.ts.map +1 -0
- package/dist/encryption-types.js +2 -0
- package/dist/encryption-types.js.map +1 -0
- package/dist/errors.d.ts +68 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +121 -0
- package/dist/errors.js.map +1 -0
- package/dist/fs.d.ts +133 -0
- package/dist/fs.d.ts.map +1 -0
- package/dist/fs.js +210 -0
- package/dist/fs.js.map +1 -0
- package/dist/hashing.d.ts +28 -0
- package/dist/hashing.d.ts.map +1 -0
- package/dist/hashing.js +59 -0
- package/dist/hashing.js.map +1 -0
- package/dist/hex.d.ts +117 -0
- package/dist/hex.d.ts.map +1 -0
- package/dist/hex.js +174 -0
- package/dist/hex.js.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/json.d.ts +398 -0
- package/dist/json.d.ts.map +1 -0
- package/dist/json.js +402 -0
- package/dist/json.js.map +1 -0
- package/dist/keyring.d.ts +243 -0
- package/dist/keyring.d.ts.map +1 -0
- package/dist/keyring.js +2 -0
- package/dist/keyring.js.map +1 -0
- package/dist/logging.d.ts +30 -0
- package/dist/logging.d.ts.map +1 -0
- package/dist/logging.js +35 -0
- package/dist/logging.js.map +1 -0
- package/dist/misc.d.ts +127 -0
- package/dist/misc.d.ts.map +1 -0
- package/dist/misc.js +142 -0
- package/dist/misc.js.map +1 -0
- package/dist/mnemonic.d.ts +14 -0
- package/dist/mnemonic.d.ts.map +1 -0
- package/dist/mnemonic.js +25 -0
- package/dist/mnemonic.js.map +1 -0
- package/dist/node.d.ts +3 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +3 -0
- package/dist/node.js.map +1 -0
- package/dist/number.d.ts +74 -0
- package/dist/number.d.ts.map +1 -0
- package/dist/number.js +95 -0
- package/dist/number.js.map +1 -0
- package/dist/opaque.d.ts +6 -0
- package/dist/opaque.d.ts.map +1 -0
- package/dist/opaque.js +2 -0
- package/dist/opaque.js.map +1 -0
- package/dist/promise.d.ts +45 -0
- package/dist/promise.d.ts.map +1 -0
- package/dist/promise.js +40 -0
- package/dist/promise.js.map +1 -0
- package/dist/superstruct.d.ts +20 -0
- package/dist/superstruct.d.ts.map +1 -0
- package/dist/superstruct.js +24 -0
- package/dist/superstruct.js.map +1 -0
- package/dist/time.d.ts +49 -0
- package/dist/time.d.ts.map +1 -0
- package/dist/time.js +62 -0
- package/dist/time.js.map +1 -0
- package/dist/transaction-types.d.ts +117 -0
- package/dist/transaction-types.d.ts.map +1 -0
- package/dist/transaction-types.js +2 -0
- package/dist/transaction-types.js.map +1 -0
- package/dist/unitsConversion.d.ts +80 -0
- package/dist/unitsConversion.d.ts.map +1 -0
- package/dist/unitsConversion.js +209 -0
- package/dist/unitsConversion.js.map +1 -0
- package/dist/versions.d.ts +101 -0
- package/dist/versions.d.ts.map +1 -0
- package/dist/versions.js +85 -0
- package/dist/versions.js.map +1 -0
- package/package.json +122 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,584 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- **BREAKING:** Drop support for Node 18 and 20 ([#324](https://github.com/MetaMask/utils/pull/324))
|
|
13
|
+
- The supported range is now `^22.14.0 || ^24`, matching core.
|
|
14
|
+
- **BREAKING:** The package is now ESM only ([#323](https://github.com/MetaMask/utils/pull/323))
|
|
15
|
+
- The CommonJS build is gone. `require('@metamask/utils')` now fails with `ERR_REQUIRE_ESM`; use `import` instead.
|
|
16
|
+
- `main` and `module` are removed. Both `.` and `./node` resolve through `exports` to a single `./dist/*.js` with `./dist/*.d.ts` types.
|
|
17
|
+
- Consumers already using `import` are unaffected.
|
|
18
|
+
- Bump `@ethereumjs/tx` from `^4.2.0` to `^5.4.0` ([#321](https://github.com/MetaMask/utils/pull/321))
|
|
19
|
+
- The deprecated `Keyring.signTransaction` now returns `LegacyTxData` rather than `TxData`. These describe the same shape: `@ethereumjs/tx@5` repurposed the name `TxData` for a map keyed by transaction type and renamed the old meaning to `LegacyTxData`. Implementations do not need changing.
|
|
20
|
+
- Bump `@metamask/scure-bip39` from `^2.0.3` to `^2.1.1` ([#311](https://github.com/MetaMask/utils/pull/311))
|
|
21
|
+
- Bump `@metamask/superstruct` from `^3.1.0` to `^3.4.1` ([#311](https://github.com/MetaMask/utils/pull/311))
|
|
22
|
+
- Bump `@noble/hashes` from `^1.3.1` to `^1.8.0` ([#311](https://github.com/MetaMask/utils/pull/311))
|
|
23
|
+
- Bump `@scure/base` from `^1.1.3` to `^1.2.6` ([#311](https://github.com/MetaMask/utils/pull/311))
|
|
24
|
+
- Bump `semver` from `^7.5.4` to `^7.6.3` ([#311](https://github.com/MetaMask/utils/pull/311))
|
|
25
|
+
|
|
26
|
+
## [11.12.1]
|
|
27
|
+
|
|
28
|
+
### Fixed
|
|
29
|
+
|
|
30
|
+
- Fix ESM compatibility for the BIP-39 mnemonic utilities ([#309](https://github.com/MetaMask/utils/pull/309))
|
|
31
|
+
|
|
32
|
+
## [11.12.0]
|
|
33
|
+
|
|
34
|
+
### Added
|
|
35
|
+
|
|
36
|
+
- Add `uint8ArrayToMnemonic` and `convertMnemonicToWordlistIndices` utilities ([#300](https://github.com/MetaMask/utils/pull/300))
|
|
37
|
+
- `uint8ArrayToMnemonic` converts little-endian `Uint16` English BIP-39 wordlist indices into a mnemonic string.
|
|
38
|
+
- `convertMnemonicToWordlistIndices` converts a mnemonic string into little-endian `Uint16` wordlist indices encoded as a `Uint8Array`.
|
|
39
|
+
- Add `@metamask/scure-bip39` as a dependency ([#300](https://github.com/MetaMask/utils/pull/300))
|
|
40
|
+
- Add optimized `sha512` and `sha384` utility functions ([#305](https://github.com/MetaMask/utils/pull/305))
|
|
41
|
+
|
|
42
|
+
## [11.11.0]
|
|
43
|
+
|
|
44
|
+
### Added
|
|
45
|
+
|
|
46
|
+
- Add Stellar CAIP namespace ([#278](https://github.com/MetaMask/utils/pull/278))
|
|
47
|
+
|
|
48
|
+
## [11.10.0]
|
|
49
|
+
|
|
50
|
+
### Added
|
|
51
|
+
|
|
52
|
+
- Add ensureError utility for converting unknown values to error ([#275](https://github.com/MetaMask/utils/pull/275))
|
|
53
|
+
|
|
54
|
+
## [11.9.0]
|
|
55
|
+
|
|
56
|
+
### Added
|
|
57
|
+
|
|
58
|
+
- Add `sha256` utility function ([#273](https://github.com/MetaMask/utils/pull/273))
|
|
59
|
+
|
|
60
|
+
## [11.8.1]
|
|
61
|
+
|
|
62
|
+
### Changed
|
|
63
|
+
|
|
64
|
+
- Replace `superstruct.is` with faster regex checks for `isCaip*` functions ([#270](https://github.com/MetaMask/utils/pull/270))
|
|
65
|
+
- Those calls were slow especially on our mobile client.
|
|
66
|
+
|
|
67
|
+
## [11.8.0]
|
|
68
|
+
|
|
69
|
+
### Added
|
|
70
|
+
|
|
71
|
+
- Add `areUint8ArraysEqual` function to compare two `Uint8Array` types ([#268](https://github.com/MetaMask/utils/pull/268))
|
|
72
|
+
|
|
73
|
+
## [11.7.0]
|
|
74
|
+
|
|
75
|
+
### Added
|
|
76
|
+
|
|
77
|
+
- Add Tron CAIP namespace ([#266](https://github.com/MetaMask/utils/pull/266))
|
|
78
|
+
|
|
79
|
+
### Fixed
|
|
80
|
+
|
|
81
|
+
- Fix API docs generation ([#264](https://github.com/MetaMask/utils/pull/264))
|
|
82
|
+
|
|
83
|
+
## [11.6.0]
|
|
84
|
+
|
|
85
|
+
### Added
|
|
86
|
+
|
|
87
|
+
- Migrate units conversion utils from `@metamask/ethjs-unit` ([#255](https://github.com/MetaMask/utils/pull/255))
|
|
88
|
+
|
|
89
|
+
### Changed
|
|
90
|
+
|
|
91
|
+
- Make `KnownCaipNamespacedChainId` type generic over `Namespace` type parameter ([#262](https://github.com/MetaMask/utils/pull/262))
|
|
92
|
+
|
|
93
|
+
## [11.5.0]
|
|
94
|
+
|
|
95
|
+
### Added
|
|
96
|
+
|
|
97
|
+
- Add `KnownCaipNamespacedChainId` type as narrower subtype of `CaipChainId` ([#258](https://github.com/MetaMask/utils/pull/258))
|
|
98
|
+
|
|
99
|
+
### Changed
|
|
100
|
+
|
|
101
|
+
- Add `lodash` and `@types/lodash` as dependencies ([#253](https://github.com/MetaMask/utils/pull/253), [#257](https://github.com/MetaMask/utils/pull/257))
|
|
102
|
+
|
|
103
|
+
### Removed
|
|
104
|
+
|
|
105
|
+
- Remove `lodash.memoize` (dependency) and `@types/lodash.memoize` (devDependency) ([#253](https://github.com/MetaMask/utils/pull/253)).
|
|
106
|
+
|
|
107
|
+
## [11.4.2]
|
|
108
|
+
|
|
109
|
+
### Fixed
|
|
110
|
+
|
|
111
|
+
- Improve performance of `isValidChecksumAddress` and `isValidHexAddress` functions ([#248](https://github.com/MetaMask/utils/pull/248))
|
|
112
|
+
|
|
113
|
+
## [11.4.1]
|
|
114
|
+
|
|
115
|
+
### Fixed
|
|
116
|
+
|
|
117
|
+
- Improve performance of `getChecksumAddress` function ([#246](https://github.com/MetaMask/utils/pull/246))
|
|
118
|
+
|
|
119
|
+
## [11.4.0]
|
|
120
|
+
|
|
121
|
+
### Changed
|
|
122
|
+
|
|
123
|
+
- Deprecate local `exactOptional` implementation ([#244](https://github.com/MetaMask/utils/pull/244))
|
|
124
|
+
- Use the one from `@metamask/superstruct@>=3.2.0` instead.
|
|
125
|
+
|
|
126
|
+
## [11.3.0]
|
|
127
|
+
|
|
128
|
+
### Added
|
|
129
|
+
|
|
130
|
+
- Add default JSON-RPC generics that extend `Json` to `Json` ([#241](https://github.com/MetaMask/utils/pull/241))
|
|
131
|
+
|
|
132
|
+
### Changed
|
|
133
|
+
|
|
134
|
+
- Deprecate `Keyring` types ([#236](https://github.com/MetaMask/utils/pull/236))
|
|
135
|
+
- These should now be imported from `@metamask/keyring-utils`.
|
|
136
|
+
|
|
137
|
+
## [11.2.0]
|
|
138
|
+
|
|
139
|
+
### Added
|
|
140
|
+
|
|
141
|
+
- Add optional `signEip7702Authorization` method to `Keyring` type ([#231](https://github.com/MetaMask/utils/pull/231))
|
|
142
|
+
|
|
143
|
+
## [11.1.0]
|
|
144
|
+
|
|
145
|
+
### Added
|
|
146
|
+
|
|
147
|
+
- Add additional CAIP-19 types (`CaipAsset{Namespace,Reference,TokenId}` support ([#227](https://github.com/MetaMask/utils/pull/227))
|
|
148
|
+
- Add CAIP-19 `CaipAssetTypeOrId` ([#229](https://github.com/MetaMask/utils/pull/229))
|
|
149
|
+
- This one combines both `CaipAssetType` and `CaipAssetId` to avoid relying on `superstruct.union`, resulting in better error messages.
|
|
150
|
+
- Add `definePattern` superstruct helper ([#228](https://github.com/MetaMask/utils/pull/228))
|
|
151
|
+
- Allow to define a `superstruct.pattern` while naming the struct and enforcing its type.
|
|
152
|
+
|
|
153
|
+
### Changed
|
|
154
|
+
|
|
155
|
+
- Use named structs for all CAIP types ([#228](https://github.com/MetaMask/utils/pull/228))
|
|
156
|
+
|
|
157
|
+
## [11.0.1]
|
|
158
|
+
|
|
159
|
+
### Fixed
|
|
160
|
+
|
|
161
|
+
- Improve error message for invalid JSON values ([#224](https://github.com/MetaMask/utils/pull/224))
|
|
162
|
+
|
|
163
|
+
## [11.0.0]
|
|
164
|
+
|
|
165
|
+
### Changed
|
|
166
|
+
|
|
167
|
+
- **BREAKING:** `generateRandomMnemonic` now returns `Promise<void>` instead of `void` ([#222](https://github.com/MetaMask/utils/pull/222))
|
|
168
|
+
|
|
169
|
+
## [10.0.1]
|
|
170
|
+
|
|
171
|
+
### Added
|
|
172
|
+
|
|
173
|
+
- Add Solana CAIP namespace ([#219](https://github.com/MetaMask/utils/pull/219))
|
|
174
|
+
|
|
175
|
+
## [10.0.0]
|
|
176
|
+
|
|
177
|
+
### Changed
|
|
178
|
+
|
|
179
|
+
- **BREAKING:** Drop support for Node.js versions 16, 21 ([#212](https://github.com/MetaMask/utils/pull/212))
|
|
180
|
+
- Improve JSON validation performance ([#218](https://github.com/MetaMask/utils/pull/218))
|
|
181
|
+
|
|
182
|
+
## [9.3.0]
|
|
183
|
+
|
|
184
|
+
### Added
|
|
185
|
+
|
|
186
|
+
- Add support for CAIP-19 ([#183](https://github.com/MetaMask/utils/pull/183))
|
|
187
|
+
- Add `Bip122` member to `KnownCaipNamespace` ([#213](https://github.com/MetaMask/utils/pull/213))
|
|
188
|
+
|
|
189
|
+
## [9.2.1]
|
|
190
|
+
|
|
191
|
+
### Fixed
|
|
192
|
+
|
|
193
|
+
- Fix wrong types for CAIP-2 and CAIP-10 structs ([#210](https://github.com/MetaMask/utils/pull/210))
|
|
194
|
+
|
|
195
|
+
## [9.2.0]
|
|
196
|
+
|
|
197
|
+
### Added
|
|
198
|
+
|
|
199
|
+
- Add `Wallet` member to `KnownCaipNamespace` enum ([#207](https://github.com/MetaMask/utils/pull/207))
|
|
200
|
+
|
|
201
|
+
## [9.1.0]
|
|
202
|
+
|
|
203
|
+
### Added
|
|
204
|
+
|
|
205
|
+
- Add `PublicInterface` type ([#197](https://github.com/MetaMask/utils/pull/197))
|
|
206
|
+
|
|
207
|
+
## [9.0.0]
|
|
208
|
+
|
|
209
|
+
### Changed
|
|
210
|
+
|
|
211
|
+
- **BREAKING:** The return types of functions `getChecksumAddress`, `numberToHex`, `bigIntToHex` are narrowed from `string` to `Hex` ([#193](https://github.com/MetaMask/utils/pull/193))
|
|
212
|
+
|
|
213
|
+
### Fixed
|
|
214
|
+
|
|
215
|
+
- Bump `@metamask/superstruct` from `^3.0.0` to `^3.1.0` ([#194](https://github.com/MetaMask/utils/pull/194))
|
|
216
|
+
- If `@metamask/utils` `<=8.5.0` is used with `@metamask/superstruct` `>=3.1.0` the following error may be encountered:
|
|
217
|
+
```ts
|
|
218
|
+
error TS2742: The inferred type of 'ExampleType' cannot be named without a reference to '@metamask/utils/node_modules/@metamask/superstruct'. This is likely not portable. A type annotation is necessary.
|
|
219
|
+
```
|
|
220
|
+
This can be resolved by updating `@metamask/utils` to `>=9.0.0`.
|
|
221
|
+
|
|
222
|
+
## [8.5.0]
|
|
223
|
+
|
|
224
|
+
### Changed
|
|
225
|
+
|
|
226
|
+
- Bump dependency `semver` from `^5.7.1` to `^7.6.0` ([#181](https://github.com/MetaMask/utils/pull/181)).
|
|
227
|
+
|
|
228
|
+
### Fixed
|
|
229
|
+
|
|
230
|
+
- Replace dependency `superstruct` `^1.0.3` with ESM-compatible `@metamask/superstruct` `^3.0.0` ([#185](https://github.com/MetaMask/utils/pull/185)).
|
|
231
|
+
- This fixes the issue of this package being unusable by any TypeScript project that uses `Node16` or `NodeNext` as its `moduleResolution` option.
|
|
232
|
+
- Produce and export ESM-compatible TypeScript type declaration files in addition to CommonJS-compatible declaration files ([#182](https://github.com/MetaMask/utils/pull/182))
|
|
233
|
+
- Previously, this package shipped with only one variant of type declaration files, and these files were only CommonJS-compatible, and the `exports` field in `package.json` linked to these files. This is an anti-pattern and was rightfully flagged by the ["Are the Types Wrong?"](https://arethetypeswrong.github.io/) tool as ["masquerading as CJS"](https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/FalseCJS.md). All of the ATTW checks now pass.
|
|
234
|
+
- Remove chunk files ([#182](https://github.com/MetaMask/utils/pull/182)).
|
|
235
|
+
- Previously, the build tool we used to generate JavaScript files extracted common code to "chunk" files. While this was intended to make this package more tree-shakeable, it also made debugging more difficult for our development teams. These chunk files are no longer present.
|
|
236
|
+
|
|
237
|
+
## [8.4.0]
|
|
238
|
+
|
|
239
|
+
### Added
|
|
240
|
+
|
|
241
|
+
- Add `toCaipChainId` utility function ([#175](https://github.com/MetaMask/utils/pull/175))
|
|
242
|
+
- Add `KnownCaipNamespace` enum ([#175](https://github.com/MetaMask/utils/pull/175))
|
|
243
|
+
|
|
244
|
+
### Changed
|
|
245
|
+
|
|
246
|
+
- Update docs for `createDeferredPromise` to caution against using `suppressUnhandledRejection` ([#174](https://github.com/MetaMask/utils/pull/174))
|
|
247
|
+
|
|
248
|
+
### Fixed
|
|
249
|
+
|
|
250
|
+
- Fix `createSandbox` to assign a unique name to the sandbox directory, so that it can be used in multiple concurrently running Jest tests ([#171](https://github.com/MetaMask/utils/pull/171))
|
|
251
|
+
|
|
252
|
+
## [8.3.0]
|
|
253
|
+
|
|
254
|
+
### Added
|
|
255
|
+
|
|
256
|
+
- Add `createDeferredPromise` ([#164](https://github.com/MetaMask/utils/pull/164))
|
|
257
|
+
|
|
258
|
+
## [8.2.1]
|
|
259
|
+
|
|
260
|
+
### Fixed
|
|
261
|
+
|
|
262
|
+
- Fix issue with source maps where line numbers were incorrect for src/error.ts ([#156](https://github.com/MetaMask/utils/pull/156))
|
|
263
|
+
|
|
264
|
+
## [8.2.0]
|
|
265
|
+
|
|
266
|
+
### Added
|
|
267
|
+
|
|
268
|
+
- Add struct utils for validating JSON objects with optional values ([#136](https://github.com/MetaMask/utils/pull/136))
|
|
269
|
+
- Add filesystem utils ([#148](https://github.com/MetaMask/utils/pull/148))
|
|
270
|
+
- Add error utils ([#146](https://github.com/MetaMask/utils/pull/146), [#151](https://github.com/MetaMask/utils/pull/151))
|
|
271
|
+
- Add base64 encoding and decoding functions ([#145](https://github.com/MetaMask/utils/pull/145))
|
|
272
|
+
|
|
273
|
+
### Changed
|
|
274
|
+
|
|
275
|
+
- Use `tsup` for bundling ([#144](https://github.com/MetaMask/utils/pull/144))
|
|
276
|
+
- This makes the package fully compliant with ES modules.
|
|
277
|
+
- Bump `@ethereumjs/tx` from `4.1.2` to `4.2.0` ([#133](https://github.com/MetaMask/utils/pull/133))
|
|
278
|
+
|
|
279
|
+
## [8.1.0]
|
|
280
|
+
|
|
281
|
+
### Changed
|
|
282
|
+
|
|
283
|
+
- Make types for JSON-RPC-related structs more accurate ([#134](https://github.com/MetaMask/utils/pull/134))
|
|
284
|
+
- Aligning `JsonRpcParams` to be optional, yet not `undefined`.
|
|
285
|
+
- Updated types:
|
|
286
|
+
- `InferWithParams`
|
|
287
|
+
- `JsonRpcNotificationStruct`
|
|
288
|
+
- `JsonRpcParamsStruct`
|
|
289
|
+
- `JsonRpcRequestStruct`
|
|
290
|
+
|
|
291
|
+
## [8.0.0]
|
|
292
|
+
|
|
293
|
+
### Changed
|
|
294
|
+
|
|
295
|
+
- **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))
|
|
296
|
+
|
|
297
|
+
## [7.1.0]
|
|
298
|
+
|
|
299
|
+
### Added
|
|
300
|
+
|
|
301
|
+
- Add CAIP-2 and CAIP-10 types ([#116](https://github.com/MetaMask/utils/pull/116))
|
|
302
|
+
|
|
303
|
+
## [7.0.0]
|
|
304
|
+
|
|
305
|
+
### Added
|
|
306
|
+
|
|
307
|
+
- Add `getKnownPropertyNames` function ([#111](https://github.com/MetaMask/utils/pull/111))
|
|
308
|
+
|
|
309
|
+
### Changed
|
|
310
|
+
|
|
311
|
+
- **BREAKING:** Build the package as both CJS and ESM ([#115](https://github.com/MetaMask/utils/pull/115), [#124](https://github.com/MetaMask/utils/pull/124))
|
|
312
|
+
- It's no longer possible to import from the `dist` folder. Everything must be imported from `@metamask/utils`.
|
|
313
|
+
- Bump `semver` to `^7.5.4` ([#123](https://github.com/MetaMask/utils/pull/123))
|
|
314
|
+
|
|
315
|
+
## [6.2.0]
|
|
316
|
+
|
|
317
|
+
### Added
|
|
318
|
+
|
|
319
|
+
- Add address related utils ([#112](https://github.com/MetaMask/utils/pull/112))
|
|
320
|
+
- `isValidHexAddress` has been added to check the validity of an hex address
|
|
321
|
+
- `getChecksumAddress` has been added to calculate the ERC-55 mixed-case checksum of an hex address
|
|
322
|
+
- `isValidChecksumAddress` has been added to check the validity of an ERC-55 mixed-case checksum address
|
|
323
|
+
|
|
324
|
+
## [6.1.0]
|
|
325
|
+
|
|
326
|
+
### Added
|
|
327
|
+
|
|
328
|
+
- Add optional `destroy` method to `Keyring` type ([#108](https://github.com/MetaMask/utils/pull/108))
|
|
329
|
+
|
|
330
|
+
## [6.0.1]
|
|
331
|
+
|
|
332
|
+
### Fixed
|
|
333
|
+
|
|
334
|
+
- Strip `__proto__` and `constructor` JSON properties in `getSafeJson` ([#105](https://github.com/MetaMask/utils/pull/105))
|
|
335
|
+
|
|
336
|
+
## [6.0.0]
|
|
337
|
+
|
|
338
|
+
### Changed
|
|
339
|
+
|
|
340
|
+
- **BREAKING:** Bump minimum Node version to 16 ([#102](https://github.com/MetaMask/utils/pull/102))
|
|
341
|
+
- **BREAKING:** Target `ES2020` ([#102](https://github.com/MetaMask/utils/pull/102))
|
|
342
|
+
|
|
343
|
+
### Fixed
|
|
344
|
+
|
|
345
|
+
- Fix JSON validation security issue ([#103](https://github.com/MetaMask/utils/pull/103))
|
|
346
|
+
- This adds a new function `getSafeJson` which validates and returns sanitized JSON.
|
|
347
|
+
|
|
348
|
+
## [5.0.2]
|
|
349
|
+
|
|
350
|
+
### Changed
|
|
351
|
+
|
|
352
|
+
- The `Keyring` exposes a new optional method `init` ([#99](https://github.com/MetaMask/utils/pull/99))
|
|
353
|
+
|
|
354
|
+
### Fixed
|
|
355
|
+
|
|
356
|
+
- Bump `@ethereumjs/tx` to `4.1.2` to address runtime compatibility issues ([#100](https://github.com/MetaMask/utils/pull/100))
|
|
357
|
+
|
|
358
|
+
## [5.0.1]
|
|
359
|
+
|
|
360
|
+
### Fixed
|
|
361
|
+
|
|
362
|
+
- Keep original type when using `hasProperty` if defined ([#94](https://github.com/MetaMask/utils/pull/94))
|
|
363
|
+
|
|
364
|
+
## [5.0.0]
|
|
365
|
+
|
|
366
|
+
### Changed
|
|
367
|
+
|
|
368
|
+
- **BREAKING:** Update `Keyring` type ([#89](https://github.com/MetaMask/utils/pull/89))
|
|
369
|
+
- The `Keyring` class now uses the data types `TypedTransaction` and `TxData` from `@ethereumjs/tx` (`v4.1.1`).
|
|
370
|
+
- The `Keyring` now exposes a new optional method called `generateRandomMnemonic`.
|
|
371
|
+
|
|
372
|
+
## [4.0.0]
|
|
373
|
+
|
|
374
|
+
### Changed
|
|
375
|
+
|
|
376
|
+
- Export new modules (`keyring`, `transaction-types`, and `encryption-types`) ([#86](https://github.com/MetaMask/utils/pull/86))
|
|
377
|
+
- **BREAKING:** Improve JSON validation ([#85](https://github.com/MetaMask/utils/pull/85))
|
|
378
|
+
- Fixes edge cases in our JSON validation logic.
|
|
379
|
+
- The previous function used for JSON validation (`validateJsonAndGetSize`) was removed.
|
|
380
|
+
- The `isValidJson` function now uses the new JSON validation logic.
|
|
381
|
+
- To get the size of a JSON value, you can use the `getJsonSize` function.
|
|
382
|
+
|
|
383
|
+
## [3.6.0]
|
|
384
|
+
|
|
385
|
+
### Added
|
|
386
|
+
|
|
387
|
+
- Add `Keyring` types ([#74](https://github.com/MetaMask/utils/pull/74))
|
|
388
|
+
- New data types added. These are `Keyring`, `Transaction` (`LegacyTransaction`, `EIP2930Transaction`, `EIP1559Transaction`), `SignedTransaction`, `Signature`, and `Eip1024EncryptedData`.
|
|
389
|
+
|
|
390
|
+
## [3.5.0]
|
|
391
|
+
|
|
392
|
+
### Changed
|
|
393
|
+
|
|
394
|
+
- Improve the `hasProperty` function ([#79](https://github.com/MetaMask/utils/pull/79), [#80](https://github.com/MetaMask/utils/pull/80))
|
|
395
|
+
- This function now acts as a type guard, informing TypeScript that the property exists.
|
|
396
|
+
- The function is now compatible with more types of objects, such as Errors and class instances.
|
|
397
|
+
|
|
398
|
+
## [3.4.1]
|
|
399
|
+
|
|
400
|
+
### Fixed
|
|
401
|
+
|
|
402
|
+
- Bump `superstruct` to `^1.0.3` ([#71](https://github.com/MetaMask/utils/pull/71))
|
|
403
|
+
|
|
404
|
+
## [3.4.0]
|
|
405
|
+
|
|
406
|
+
### Added
|
|
407
|
+
|
|
408
|
+
- Add types and utility functions for validating versions and checksums ([#67](https://github.com/MetaMask/utils/pull/67), [#69](https://github.com/MetaMask/utils/pull/69))
|
|
409
|
+
|
|
410
|
+
### Fixed
|
|
411
|
+
|
|
412
|
+
- JSON-RPC types now have a default generic `Params` value ([#54](https://github.com/MetaMask/utils/pull/54))
|
|
413
|
+
|
|
414
|
+
## [3.3.1]
|
|
415
|
+
|
|
416
|
+
### Fixed
|
|
417
|
+
|
|
418
|
+
- JSON-RPC parameters are now properly cast to Json upon validation ([#51](https://github.com/MetaMask/utils/pull/51))
|
|
419
|
+
|
|
420
|
+
## [3.3.0]
|
|
421
|
+
|
|
422
|
+
### Added
|
|
423
|
+
|
|
424
|
+
- Add more assertion utils ([#49](https://github.com/MetaMask/utils/pull/49))
|
|
425
|
+
- Add JSON-RPC error validation functions ([#46](https://github.com/MetaMask/utils/pull/46))
|
|
426
|
+
- Add convenience function for creating a `DataView` ([#45](https://github.com/MetaMask/utils/pull/45))
|
|
427
|
+
|
|
428
|
+
### Fixed
|
|
429
|
+
|
|
430
|
+
- Update JSON validation logic ([#47](https://github.com/MetaMask/utils/pull/47))
|
|
431
|
+
- Validation would previously allow for `undefined` values, which is not a standard JSON type
|
|
432
|
+
|
|
433
|
+
## [3.2.0]
|
|
434
|
+
|
|
435
|
+
### Added
|
|
436
|
+
|
|
437
|
+
- Add `PendingJsonRpcResponse` type ([#43](https://github.com/MetaMask/utils/pull/43))
|
|
438
|
+
- Add utils for converting between numbers and hex ([#41](https://github.com/MetaMask/utils/pull/41))
|
|
439
|
+
- Add coercion utils ([#38](https://github.com/MetaMask/utils/pull/38))
|
|
440
|
+
|
|
441
|
+
## [3.1.0]
|
|
442
|
+
|
|
443
|
+
### Added
|
|
444
|
+
|
|
445
|
+
- Add assertion utils ([#33](https://github.com/MetaMask/utils/pull/33))
|
|
446
|
+
- Add util functions for encoding and decoding bytes ([#34](https://github.com/MetaMask/utils/pull/34))
|
|
447
|
+
|
|
448
|
+
### Fixed
|
|
449
|
+
|
|
450
|
+
- Make JSON-RPC error `data` property optional ([#31](https://github.com/MetaMask/utils/pull/31))
|
|
451
|
+
- Don't include test files in dist folder ([#35](https://github.com/MetaMask/utils/pull/35))
|
|
452
|
+
- Fix typo in README ([#28](https://github.com/MetaMask/utils/pull/28))
|
|
453
|
+
|
|
454
|
+
## [3.0.3]
|
|
455
|
+
|
|
456
|
+
### Fixed
|
|
457
|
+
|
|
458
|
+
- Allow omitting JSON-RPC params when params can be undefined ([#29](https://github.com/MetaMask/utils/pull/29))
|
|
459
|
+
|
|
460
|
+
## [3.0.2]
|
|
461
|
+
|
|
462
|
+
### Fixed
|
|
463
|
+
|
|
464
|
+
- Bump `superstruct` to ^0.16.5 ([#26](https://github.com/MetaMask/utils/pull/26))
|
|
465
|
+
- `superstruct`s 0.16.1 through 0.16.4 were not compatible with Node 14; this restores that compatibility.
|
|
466
|
+
|
|
467
|
+
## [3.0.1]
|
|
468
|
+
|
|
469
|
+
### Fixed
|
|
470
|
+
|
|
471
|
+
- Promote `@types/debug` from development dependencies to production dependencies ([#23](https://github.com/MetaMask/utils/pull/23))
|
|
472
|
+
|
|
473
|
+
## [3.0.0]
|
|
474
|
+
|
|
475
|
+
### Added
|
|
476
|
+
|
|
477
|
+
- Add logging functions ([#20](https://github.com/MetaMask/utils/pull/20))
|
|
478
|
+
- Add frozen collections (implemented in [#5](https://github.com/MetaMask/utils/pull/5) but exported in [#19](https://github.com/MetaMask/utils/pull/19))
|
|
479
|
+
|
|
480
|
+
### Changed
|
|
481
|
+
|
|
482
|
+
- **BREAKING:** Improve types and type validation ([#19](https://github.com/MetaMask/utils/pull/19))
|
|
483
|
+
- Various type changes have been made that might be breaking:
|
|
484
|
+
- The `JsonRpcRequest` and `JsonRpcNotification` types now include a generic constraint requiring that the `Params` type extends the `JsonRpcParams` type.
|
|
485
|
+
- The `JsonRpcSuccess` and `JsonRpcResponse` types now include a generic contraint for the `Result` type, requiring that it extends the `Json` type.
|
|
486
|
+
- Various validation functions now accept `unknown` parameters rather than specific types. This should not be breaking except that it may affect type inference for the parameters passed in.
|
|
487
|
+
- New JSON-related functions have been added:
|
|
488
|
+
- `assertIsJsonRpcResponse`
|
|
489
|
+
- `isJsonRpcResponse`
|
|
490
|
+
- `InferWithParams`
|
|
491
|
+
- `JsonRpcParams`
|
|
492
|
+
- New JSON Struct types have been added:
|
|
493
|
+
- `JsonRpcErrorStruct`
|
|
494
|
+
- `JsonRpcFailureStruct`
|
|
495
|
+
- `JsonRpcIdStruct`
|
|
496
|
+
- `JsonRpcParamsStruct`
|
|
497
|
+
- `JsonRpcRequestStruct`
|
|
498
|
+
- `JsonRpcResponseStruct`
|
|
499
|
+
- `JsonRpcSuccessStruct`
|
|
500
|
+
- `JsonRpcVersionStruct`
|
|
501
|
+
- `JsonStruct`
|
|
502
|
+
|
|
503
|
+
## [2.1.0]
|
|
504
|
+
|
|
505
|
+
### Added
|
|
506
|
+
|
|
507
|
+
- Add JSON storage validation and limit utilities ([#14](https://github.com/MetaMask/utils/pull/14))
|
|
508
|
+
- Adds a new function `validateJsonAndGetSize`.
|
|
509
|
+
|
|
510
|
+
## [2.0.0]
|
|
511
|
+
|
|
512
|
+
### Added
|
|
513
|
+
|
|
514
|
+
- Add more JSON utils ([#8](https://github.com/MetaMask/utils/pull/8))
|
|
515
|
+
|
|
516
|
+
### Changed
|
|
517
|
+
|
|
518
|
+
- **BREAKING:** Refactor and expand time utils ([#9](https://github.com/MetaMask/utils/pull/9))
|
|
519
|
+
- Adds a new function, `inMilliseconds`, and moves the time constants into a TypeScript `enum`.
|
|
520
|
+
|
|
521
|
+
## [1.0.0]
|
|
522
|
+
|
|
523
|
+
### Added
|
|
524
|
+
|
|
525
|
+
- Initial release
|
|
526
|
+
|
|
527
|
+
[Unreleased]: https://github.com/MetaMask/utils/compare/v11.12.1...HEAD
|
|
528
|
+
[11.12.1]: https://github.com/MetaMask/utils/compare/v11.12.0...v11.12.1
|
|
529
|
+
[11.12.0]: https://github.com/MetaMask/utils/compare/v11.11.0...v11.12.0
|
|
530
|
+
[11.11.0]: https://github.com/MetaMask/utils/compare/v11.10.0...v11.11.0
|
|
531
|
+
[11.10.0]: https://github.com/MetaMask/utils/compare/v11.9.0...v11.10.0
|
|
532
|
+
[11.9.0]: https://github.com/MetaMask/utils/compare/v11.8.1...v11.9.0
|
|
533
|
+
[11.8.1]: https://github.com/MetaMask/utils/compare/v11.8.0...v11.8.1
|
|
534
|
+
[11.8.0]: https://github.com/MetaMask/utils/compare/v11.7.0...v11.8.0
|
|
535
|
+
[11.7.0]: https://github.com/MetaMask/utils/compare/v11.6.0...v11.7.0
|
|
536
|
+
[11.6.0]: https://github.com/MetaMask/utils/compare/v11.5.0...v11.6.0
|
|
537
|
+
[11.5.0]: https://github.com/MetaMask/utils/compare/v11.4.2...v11.5.0
|
|
538
|
+
[11.4.2]: https://github.com/MetaMask/utils/compare/v11.4.1...v11.4.2
|
|
539
|
+
[11.4.1]: https://github.com/MetaMask/utils/compare/v11.4.0...v11.4.1
|
|
540
|
+
[11.4.0]: https://github.com/MetaMask/utils/compare/v11.3.0...v11.4.0
|
|
541
|
+
[11.3.0]: https://github.com/MetaMask/utils/compare/v11.2.0...v11.3.0
|
|
542
|
+
[11.2.0]: https://github.com/MetaMask/utils/compare/v11.1.0...v11.2.0
|
|
543
|
+
[11.1.0]: https://github.com/MetaMask/utils/compare/v11.0.1...v11.1.0
|
|
544
|
+
[11.0.1]: https://github.com/MetaMask/utils/compare/v11.0.0...v11.0.1
|
|
545
|
+
[11.0.0]: https://github.com/MetaMask/utils/compare/v10.0.1...v11.0.0
|
|
546
|
+
[10.0.1]: https://github.com/MetaMask/utils/compare/v10.0.0...v10.0.1
|
|
547
|
+
[10.0.0]: https://github.com/MetaMask/utils/compare/v9.3.0...v10.0.0
|
|
548
|
+
[9.3.0]: https://github.com/MetaMask/utils/compare/v9.2.1...v9.3.0
|
|
549
|
+
[9.2.1]: https://github.com/MetaMask/utils/compare/v9.2.0...v9.2.1
|
|
550
|
+
[9.2.0]: https://github.com/MetaMask/utils/compare/v9.1.0...v9.2.0
|
|
551
|
+
[9.1.0]: https://github.com/MetaMask/utils/compare/v9.0.0...v9.1.0
|
|
552
|
+
[9.0.0]: https://github.com/MetaMask/utils/compare/v8.5.0...v9.0.0
|
|
553
|
+
[8.5.0]: https://github.com/MetaMask/utils/compare/v8.4.0...v8.5.0
|
|
554
|
+
[8.4.0]: https://github.com/MetaMask/utils/compare/v8.3.0...v8.4.0
|
|
555
|
+
[8.3.0]: https://github.com/MetaMask/utils/compare/v8.2.1...v8.3.0
|
|
556
|
+
[8.2.1]: https://github.com/MetaMask/utils/compare/v8.2.0...v8.2.1
|
|
557
|
+
[8.2.0]: https://github.com/MetaMask/utils/compare/v8.1.0...v8.2.0
|
|
558
|
+
[8.1.0]: https://github.com/MetaMask/utils/compare/v8.0.0...v8.1.0
|
|
559
|
+
[8.0.0]: https://github.com/MetaMask/utils/compare/v7.1.0...v8.0.0
|
|
560
|
+
[7.1.0]: https://github.com/MetaMask/utils/compare/v7.0.0...v7.1.0
|
|
561
|
+
[7.0.0]: https://github.com/MetaMask/utils/compare/v6.2.0...v7.0.0
|
|
562
|
+
[6.2.0]: https://github.com/MetaMask/utils/compare/v6.1.0...v6.2.0
|
|
563
|
+
[6.1.0]: https://github.com/MetaMask/utils/compare/v6.0.1...v6.1.0
|
|
564
|
+
[6.0.1]: https://github.com/MetaMask/utils/compare/v6.0.0...v6.0.1
|
|
565
|
+
[6.0.0]: https://github.com/MetaMask/utils/compare/v5.0.2...v6.0.0
|
|
566
|
+
[5.0.2]: https://github.com/MetaMask/utils/compare/v5.0.1...v5.0.2
|
|
567
|
+
[5.0.1]: https://github.com/MetaMask/utils/compare/v5.0.0...v5.0.1
|
|
568
|
+
[5.0.0]: https://github.com/MetaMask/utils/compare/v4.0.0...v5.0.0
|
|
569
|
+
[4.0.0]: https://github.com/MetaMask/utils/compare/v3.6.0...v4.0.0
|
|
570
|
+
[3.6.0]: https://github.com/MetaMask/utils/compare/v3.5.0...v3.6.0
|
|
571
|
+
[3.5.0]: https://github.com/MetaMask/utils/compare/v3.4.1...v3.5.0
|
|
572
|
+
[3.4.1]: https://github.com/MetaMask/utils/compare/v3.4.0...v3.4.1
|
|
573
|
+
[3.4.0]: https://github.com/MetaMask/utils/compare/v3.3.1...v3.4.0
|
|
574
|
+
[3.3.1]: https://github.com/MetaMask/utils/compare/v3.3.0...v3.3.1
|
|
575
|
+
[3.3.0]: https://github.com/MetaMask/utils/compare/v3.2.0...v3.3.0
|
|
576
|
+
[3.2.0]: https://github.com/MetaMask/utils/compare/v3.1.0...v3.2.0
|
|
577
|
+
[3.1.0]: https://github.com/MetaMask/utils/compare/v3.0.3...v3.1.0
|
|
578
|
+
[3.0.3]: https://github.com/MetaMask/utils/compare/v3.0.2...v3.0.3
|
|
579
|
+
[3.0.2]: https://github.com/MetaMask/utils/compare/v3.0.1...v3.0.2
|
|
580
|
+
[3.0.1]: https://github.com/MetaMask/utils/compare/v3.0.0...v3.0.1
|
|
581
|
+
[3.0.0]: https://github.com/MetaMask/utils/compare/v2.1.0...v3.0.0
|
|
582
|
+
[2.1.0]: https://github.com/MetaMask/utils/compare/v2.0.0...v2.1.0
|
|
583
|
+
[2.0.0]: https://github.com/MetaMask/utils/compare/v1.0.0...v2.0.0
|
|
584
|
+
[1.0.0]: https://github.com/MetaMask/utils/releases/tag/v1.0.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 MetaMask
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
15
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|