Skip to content

Commit

Permalink
Merge 4379d37 into 0d81c40
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanio committed Mar 1, 2021
2 parents 0d81c40 + 4379d37 commit c0111e5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,21 @@ You can import the `Wallet` class like this
Node.js / ES5:

```js
// Introduced along v1.0.2 (UNRELEASED)
const { Wallet } = require('ethereumjs-wallet')

// @deprecated, up till version v1.0.1
const Wallet = require('ethereumjs-wallet').default
```

ESM / TypeScript:

```js
// Introduced along v1.0.2 (UNRELEASED)
import { Wallet } from 'ethereumjs-wallet'

// @deprecated, up till version v1.0.1
import Wallet from 'ethereumjs-wallet'
```

## Thirdparty API
Expand Down
18 changes: 16 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ interface EthSaleKeystore {

// wallet implementation

export default class Wallet {
class Wallet {
constructor(
private readonly privateKey?: Buffer | undefined,
private publicKey: Buffer | undefined = undefined,
Expand Down Expand Up @@ -599,7 +599,9 @@ export default class Wallet {
}

const ciphertext = runCipherBuffer(cipher, this.privKey)
const mac = keccak256(Buffer.concat([Buffer.from(derivedKey.slice(16, 32)), Buffer.from(ciphertext)]))
const mac = keccak256(
Buffer.concat([Buffer.from(derivedKey.slice(16, 32)), Buffer.from(ciphertext)]),
)

return {
version: 3,
Expand Down Expand Up @@ -646,6 +648,18 @@ export default class Wallet {
}
}

/**
* Please note that the default export for Wallet is DEPRECATED and
* may be removed in the next major version.
* Instead, please use the named export like so:
* `import { Wallet } from 'ethereumjs-wallet'`
* or
* `const { Wallet } = require('ethereumjs-wallet')`
*/
export default Wallet

export { Wallet }

// helpers

function runCipherBuffer(cipher: crypto.Cipher | crypto.Decipher, data: Buffer): Buffer {
Expand Down

0 comments on commit c0111e5

Please sign in to comment.