@metamask/eth-hd-keyring 4.0.1 → 4.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -1
- package/index.js +6 -0
- package/package.json +1 -1
- package/test/index.js +11 -0
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [4.0.2]
|
|
10
|
+
### Added
|
|
11
|
+
- Add parameter validation for constructor / `deserialize` method ([#65](https://github.com/MetaMask/eth-hd-keyring/pull/65))
|
|
12
|
+
- As of v4.0.0, the `deserialize` method (which is also called by the constructor) can no longer generate accounts with the `numberOfAccounts` option without a `mnemonic`. Prior to v4.0.0, a mnemonic was generated automatically if it was missing, but we now want to ensure a mnemonic is never implicitly generated without the caller knowing.
|
|
13
|
+
|
|
9
14
|
## [4.0.1]
|
|
10
15
|
### Added
|
|
11
16
|
- Add tests to get coverage to 100% ([#62](https://github.com/MetaMask/eth-hd-keyring/pull/62))
|
|
@@ -22,8 +27,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
22
27
|
- We now have an allowlist for all post-install scripts. The standard setup script has been added, along with new contributor documentation in the README to explain this script.
|
|
23
28
|
- Obfuscate serialized mnemonic ([#59](https://github.com/MetaMask/eth-hd-keyring/pull/59))
|
|
24
29
|
- Class variable `mnemonic` on `HdKeyring` can now be either type `Buffer` or type `string`.
|
|
30
|
+
- Deserialize method (and `HdKeyring` constructor by extension) can no longer be passed an options object containing a value for `numberOfAccounts` if it is not also containing a value for `mnemonic`.
|
|
25
31
|
- Package name changed from `eth-hd-keyring` to `@metamask/eth-hd-keyring`.
|
|
26
32
|
|
|
27
|
-
[Unreleased]: https://github.com/MetaMask/eth-hd-keyring/compare/v4.0.
|
|
33
|
+
[Unreleased]: https://github.com/MetaMask/eth-hd-keyring/compare/v4.0.2...HEAD
|
|
34
|
+
[4.0.2]: https://github.com/MetaMask/eth-hd-keyring/compare/v4.0.1...v4.0.2
|
|
28
35
|
[4.0.1]: https://github.com/MetaMask/eth-hd-keyring/compare/v4.0.0...v4.0.1
|
|
29
36
|
[4.0.0]: https://github.com/MetaMask/eth-hd-keyring/releases/tag/v4.0.0
|
package/index.js
CHANGED
|
@@ -33,6 +33,12 @@ class HdKeyring extends SimpleKeyring {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
deserialize(opts = {}) {
|
|
36
|
+
if (opts.numberOfAccounts && !opts.mnemonic) {
|
|
37
|
+
throw new Error(
|
|
38
|
+
'Eth-Hd-Keyring: Deserialize method cannot be called with an opts value for numberOfAccounts and no menmonic',
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
36
42
|
if (this.root) {
|
|
37
43
|
throw new Error(
|
|
38
44
|
'Eth-Hd-Keyring: Secret recovery phrase already provided',
|
package/package.json
CHANGED
package/test/index.js
CHANGED
|
@@ -67,6 +67,17 @@ describe('hd-keyring', () => {
|
|
|
67
67
|
}),
|
|
68
68
|
).toThrow('Eth-Hd-Keyring: Invalid secret recovery phrase provided');
|
|
69
69
|
});
|
|
70
|
+
|
|
71
|
+
it('throws when numberOfAccounts is passed with no mnemonic', () => {
|
|
72
|
+
expect(
|
|
73
|
+
() =>
|
|
74
|
+
new HdKeyring({
|
|
75
|
+
numberOfAccounts: 2,
|
|
76
|
+
}),
|
|
77
|
+
).toThrow(
|
|
78
|
+
'Eth-Hd-Keyring: Deserialize method cannot be called with an opts value for numberOfAccounts and no menmonic',
|
|
79
|
+
);
|
|
80
|
+
});
|
|
70
81
|
});
|
|
71
82
|
|
|
72
83
|
describe('re-initialization protection', () => {
|