Skip to content

Commit 515a7ba

Browse files
authored
Merge pull request ethereumjs#2729 from ethereumjs/monorepo-add-wallet
Monorepo Wallet Library Integration
2 parents e9e3381 + d309c93 commit 515a7ba

28 files changed

+6002
-199
lines changed

package-lock.json

Lines changed: 2037 additions & 199 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/wallet/.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('../../config/eslint.js')
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Build
2+
on:
3+
push:
4+
branches:
5+
- master
6+
tags:
7+
- '*'
8+
pull_request:
9+
types: [opened, reopened, synchronize]
10+
jobs:
11+
test:
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
node-version: [14, 16, 18]
16+
steps:
17+
- uses: actions/checkout@v3
18+
- name: Use Node.js ${{ matrix.node-version }}
19+
uses: actions/setup-node@v2
20+
with:
21+
node-version: ${{ matrix.node-version }}
22+
cache: 'npm'
23+
- run: npm i
24+
- run: npm run lint
25+
- run: npm run coverage
26+
test-browser:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v3
30+
- name: Use Node.js 14
31+
uses: actions/setup-node@v2
32+
with:
33+
node-version: 14
34+
cache: 'npm'
35+
- run: npm i
36+
- run: npm run test:browser

packages/wallet/.gitignore

Whitespace-only changes.

packages/wallet/.prettierignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules
2+
.vscode
3+
package.json
4+
dist
5+
.nyc_output
6+
test/testdata
7+
docs

packages/wallet/CHANGELOG.md

Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
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](http://keepachangelog.com/en/1.0.0/)
6+
(modification: no type change headlines) and this project adheres to
7+
[Semantic Versioning](http://semver.org/spec/v2.0.0.html).
8+
9+
## [1.0.2] - 2021-10-08
10+
11+
- Updated dependencies to latest, added browser build, PR [#157](https://github.com/ethereumjs/ethereumjs-wallet/pull/157)
12+
13+
#### Included Source Files
14+
15+
Source files from the `src` folder are now included in the distribution build. This allows for a better debugging experience in debug tools like Chrome DevTools by having working source map references to the original sources available for inspection.
16+
17+
[1.0.2]: https://github.com/ethereumjs/ethereumjs-wallet/compare/v1.0.1...v1.0.2
18+
19+
## [1.0.1] - 2020-09-25
20+
21+
- Fixed a browser issue in `Wallet.fromV3()` and `Wallet.toV3()` triggered when using web bundlers using Buffer v4 shim (Webpack 4),
22+
see PR [#135](https://github.com/ethereumjs/ethereumjs-wallet/pull/135)
23+
24+
[1.0.1]: https://github.com/ethereumjs/ethereumjs-wallet/compare/v1.0.0...v1.0.1
25+
26+
## [1.0.0] - 2020-06-23
27+
28+
This is the first `TypeScript` release on the library (thanks @the-jackalope for the rewrite! ❤️), see PR [#93](https://github.com/ethereumjs/ethereumjs-wallet/pull/93) for the main PR here. The release comes with various breaking changes.
29+
30+
### Libray Import / API Documentation
31+
32+
The way submodules are exposed has been changed along the `TypeScript` rewrite and you will likely have to update your imports. Here is an example for the `hdkey` submodule:
33+
34+
Node.js / ES5:
35+
36+
```js
37+
const { hdkey } = require('ethereumjs-wallet')
38+
```
39+
40+
ESM / TypeScript:
41+
42+
```js
43+
import { hdkey } from 'ethereumjs-wallet'
44+
```
45+
46+
See [README](https://github.com/ethereumjs/ethereumjs-wallet#wallet-api) for examples on the other submodules.
47+
48+
Together with the switch to `TypeScript` the previously static documentation has been automated to now being generated with `TypeDoc` to reflect all latest changes, see PR [#98](https://github.com/ethereumjs/ethereumjs-wallet/pull/98). See the new [docs](https://github.com/ethereumjs/ethereumjs-wallet/blob/master/docs/README.md) for an overview on the `TypeScript` based API.
49+
50+
### API Changes
51+
52+
The API of the library hasn't been changed intentionally but has become more strict on type input by the explcit type definitions from the `TypeScript` code in function signatures together with the introduction of the `ethereumjs-util` [v7](https://github.com/ethereumjs/ethereumjs-util/releases) library within the `Wallet` library, which behaves more strict on type input on the various utility functions.
53+
54+
This leads to cases where some input - while not having been the intended way to use the library - might have been worked before through implicit type conversion and is now not possible any more.
55+
56+
One example for this is the `Wallet.fromPublicKey()` function, here is the old code of the function:
57+
58+
```js
59+
Wallet.fromPublicKey = function (pub, nonStrict) {
60+
if (nonStrict) {
61+
pub = ethUtil.importPublic(pub)
62+
}
63+
return new Wallet(null, pub)
64+
}
65+
```
66+
67+
and here the new `TypeScript` code:
68+
69+
```typescript
70+
public static fromPublicKey(publicKey: Buffer, nonStrict: boolean = false): Wallet {
71+
if (nonStrict) {
72+
publicKey = importPublic(publicKey)
73+
}
74+
return new Wallet(undefined, publicKey)
75+
}
76+
```
77+
78+
This function worked in the `v0.6.x` version also with passing in a string, since the `ethereumjs-util` `v6` `importPublic` method converted the input implicitly to a `Buffer`, the `v1.0.0` version now directly enforces the `fromPublicKey` input to be a `Buffer` first hand.
79+
80+
There will likely be more cases like this in the code since the type input of the library hasn't been documented in the older version. So we recommend here to go through all your function signature usages and see if you uses the correct input types. While a bit annoying this is a one-time task you will never have to do again since you can now profit from the clear `TypeScript` input types being both documented and enforced by the `TypeScript` compiler.
81+
82+
### Pure JS Crypto Dependencies
83+
84+
This library now uses pure JS crypto dependencies which doesn't bring in the need for native compilation on installation. For `scrypt` key derivation [scrypt-js](https://github.com/ricmoo/scrypt-js) from @ricmoo is used (see PR [#125](https://github.com/ethereumjs/ethereumjs-wallet/pull/125)).
85+
86+
For BIP-32 key derivation the new [ethereum-cryptography](https://github.com/ethereum/js-ethereum-cryptography) library is used which is a new Ethereum Foundation backed and formally audited libray to provide pure JS cryptographic primitives within the Ethereum ecosystem (see PR [#128](https://github.com/ethereumjs/ethereumjs-wallet/pull/128)).
87+
88+
### Removed ProviderEngine
89+
90+
Support for Provider Engine has been removed for security reasons, since the package is not very actively maintained and superseded by [`json-rpc-engine`](https://github.com/MetaMask/web3-provider-engine#web3-providerengine).
91+
92+
If you need the removed functionality, it should be relatively easily possible to do this integration by adopting the code from [provider-engine.ts](https://github.com/ethereumjs/ethereumjs-wallet/blob/v0.6.x/src/provider-engine.js).
93+
94+
See also: PR [#117](https://github.com/ethereumjs/ethereumjs-wallet/pull/117)
95+
96+
### Other Changes
97+
98+
#### Bug Fixes
99+
100+
- Fixes a bug where `salt`, `iv` and/or `uuid` options - being supplied as strings to `Wallet.toV3()` - could lead to errors during encryption and/or output that could not be decrypted,
101+
PR [#95](https://github.com/ethereumjs/ethereumjs-wallet/pull/95)
102+
103+
#### Refactoring & Maintenance
104+
105+
- `ES6` class rewrite,
106+
PR [#93](https://github.com/ethereumjs/ethereumjs-wallet/pull/93) (`TypeScript` PR)
107+
- Added support for Node 12, 13, and 14, upgraded CI provider to use GH Actions in place of Travis,
108+
PR [#120](https://github.com/ethereumjs/ethereumjs-wallet/pull/120)
109+
- Updated `ethereumjs-util` dependency from `v6` to
110+
[v7.0.2](https://github.com/ethereumjs/ethereumjs-util/releases/tag/v7.0.2 (stricter types),
111+
PR [#126](https://github.com/ethereumjs/ethereumjs-wallet/pull/126)
112+
- Refactored `Wallet.deciperBuffer()`,
113+
PR [#82](https://github.com/ethereumjs/ethereumjs-wallet/pull/82)
114+
115+
#### Development & CI
116+
117+
- Integrated the `ethereumjs-config` EthereumJS developer configuration standards,
118+
PR [#93](https://github.com/ethereumjs/ethereumjs-wallet/pull/93) (`TypeScript` PR)
119+
- Added org links and Git hooks,
120+
PR [#88](https://github.com/ethereumjs/ethereumjs-wallet/pull/88)
121+
122+
[0.6.4]: https://github.com/ethereumjs/ethereumjs-wallet/compare/v0.6.3...v1.0.0
123+
124+
## [0.6.4] - 2020-05-01
125+
126+
This is the last release from the `v0.6.x` release series. It adds Node 12 compatibility while maintaining compatibility
127+
down to Node 6. To be able to do so the `scrypt.js` key derivation library is exchanged with `scryptsy`. While this solution is backwards-compatible the changed library only provides a pure JS implementation and no native bindings. If you need native performance pin your dependency to `v0.6.3` or update to the `v1.0.0` library version to be released shortly after this release.
128+
129+
Change Summary:
130+
131+
- v0.6.x back patch: added node v12 support, switched to `scryptsy` key derivation library (pure JS implementation),
132+
PR [#114](https://github.com/ethereumjs/ethereumjs-wallet/pull/114)
133+
- Updated `hdkey` to `v1.1.1`,
134+
PR [#87](https://github.com/ethereumjs/ethereumjs-wallet/pull/87)
135+
- Refactored `decipherBuffer()`,
136+
PR [#82](https://github.com/ethereumjs/ethereumjs-wallet/pull/82)
137+
- Added more tests for `Wallet.fromEthSale()`,
138+
PR [#80](https://github.com/ethereumjs/ethereumjs-wallet/pull/80)
139+
140+
[0.6.4]: https://github.com/ethereumjs/ethereumjs-wallet/compare/v0.6.3...v0.6.4
141+
142+
## [0.6.3] - 2018-12-19
143+
144+
- Fixed installation errors for certain packaging tools, PR [#67](https://github.com/ethereumjs/ethereumjs-wallet/pull/67)
145+
- Remove dependency on `crypto.randomBytes` and use `randombytes` package instead, PR [#63](https://github.com/ethereumjs/ethereumjs-wallet/pull/63)
146+
- Add comprehensive test coverage for `fromV3`, PR [#62](https://github.com/ethereumjs/ethereumjs-wallet/pull/62)
147+
- Remove excess parameter from `decipherBuffer` usage, PR [#77](https://github.com/ethereumjs/ethereumjs-wallet/pull/77)
148+
- Update dependencies, including a fixed `scrypt.js`, which should resolve more installation issues, PR [#78](https://github.com/ethereumjs/ethereumjs-wallet/pull/78)
149+
150+
[0.6.3]: https://github.com/ethereumjs/ethereumjs-wallet/compare/v0.6.2...v0.6.3
151+
152+
## [0.6.2] - 2018-08-08
153+
154+
- [PLEASE UPDATE!] Fixes a critical import bug introduced in `v0.6.1` accidentally
155+
changing the import path for the different submodules, see PR [#65](https://github.com/ethereumjs/ethereumjs-wallet/pull/65)
156+
157+
[0.6.2]: https://github.com/ethereumjs/ethereumjs-wallet/compare/v0.6.1...v0.6.2
158+
159+
## [0.6.1] - 2018-07-28 [DEPRECATED]
160+
161+
- Added support for vanity address generation, PR [#5](https://github.com/ethereumjs/ethereumjs-wallet/pull/5)
162+
- Fixed typo in provider-engine, PR [#16](https://github.com/ethereumjs/ethereumjs-wallet/pull/16)
163+
- Accept the true range of addresses for ICAP direct, PR [#6](https://github.com/ethereumjs/ethereumjs-wallet/pull/6)
164+
- Switched to babel ES5 build, PR [#37](https://github.com/ethereumjs/ethereumjs-wallet/pull/37)
165+
- Improve test coverage (at 88% now), PR [#27](https://github.com/ethereumjs/ethereumjs-wallet/pull/27)
166+
- Various dependency updates, PR [#25](https://github.com/ethereumjs/ethereumjs-wallet/pull/25)
167+
168+
[0.6.1]: https://github.com/ethereumjs/ethereumjs-wallet/compare/v0.6.0...v0.6.1
169+
170+
## [0.6.0] - 2016-04-27
171+
172+
- Added provider-engine integration, PR [#7](https://github.com/ethereumjs/ethereumjs-wallet/pull/7)
173+
174+
[0.6.0]: https://github.com/ethereumjs/ethereumjs-wallet/compare/v0.5.2...v0.6.0
175+
176+
## [0.5.2] - 2016-04-25
177+
178+
- Dependency updates
179+
180+
[0.5.2]: https://github.com/ethereumjs/ethereumjs-wallet/compare/v0.5.1...v0.5.2
181+
182+
## [0.5.1] - 2016-03-26
183+
184+
- Bugfix for `EthereumHDKey.privateExtendedKey()`
185+
- Added travis and coveralls support
186+
- Documentation and test improvements
187+
188+
[0.5.1]: https://github.com/ethereumjs/ethereumjs-wallet/compare/v0.5.0...v0.5.1
189+
190+
## [0.5.0] - 2016-03-23
191+
192+
- Support HD keys using `cryptocoinjs/hdkey`
193+
- Ensure private keys are valid according to the curve
194+
- Support instantation with public keys
195+
- Support importing BIP32 xpub/xpriv
196+
- Only support Ethereum keys internally, non-strict mode for importing compressed ones
197+
- Thirdparty API doc improvements
198+
199+
[0.5.0]: https://github.com/ethereumjs/ethereumjs-wallet/compare/v0.4.0...v0.5.0
200+
201+
## Older releases:
202+
203+
- [0.4.0](https://github.com/ethereumjs/ethereumjs-wallet/compare/v0.3.0...v0.4.0) - 2016-03-16
204+
- [0.3.0](https://github.com/ethereumjs/ethereumjs-wallet/compare/v0.2.1...v0.3.0) - 2016-03-09
205+
- [0.2.1](https://github.com/ethereumjs/ethereumjs-wallet/compare/v0.2.0...v0.2.1) - 2016-03-07
206+
- [0.2.0](https://github.com/ethereumjs/ethereumjs-wallet/compare/v0.1.0...v0.2.0) - 2016-03-07
207+
- 0.1.0 - 2016-02-23

packages/wallet/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 Alex Beregszaszi
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)