Skip to content
This repository was archived by the owner on Oct 30, 2024. It is now read-only.

Commit 2121d5a

Browse files
authored
Merge pull request #112 from ethereumjs/setup-typedoc
Setup typedoc and fix web3-provider-engine dependency
2 parents 20171a9 + ac5ba8a commit 2121d5a

11 files changed

+1099
-51
lines changed

README.md

Lines changed: 42 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -28,81 +28,82 @@ Features not supported:
2828

2929
## Wallet API
3030

31-
Constructors:
31+
For information about the Wallet's API, please go to [./docs/classes/wallet.md](./docs/classes/wallet.md).
3232

33-
- `generate([icap])` - create an instance based on a new random key (setting `icap` to true will generate an address suitable for the `ICAP Direct mode`)
34-
- `generateVanityAddress(pattern)` - create an instance where the address is valid against the supplied pattern (**this will be very slow**)
35-
- `fromPrivateKey(input)` - create an instance based on a raw private key
36-
- `fromExtendedPrivateKey(input)` - create an instance based on a BIP32 extended private key (xprv)
37-
- `fromPublicKey(input, [nonStrict])` - create an instance based on a public key (certain methods will not be available)
38-
- `fromExtendedPublicKey(input)` - create an instance based on a BIP32 extended public key (xpub)
39-
- `fromV1(input, password)` - import a wallet (Version 1 of the Ethereum wallet format)
40-
- `fromV3(input, password, [nonStrict])` - import a wallet (Version 3 of the Ethereum wallet format). Set `nonStrict` true to accept files with mixed-caps.
41-
- `fromEthSale(input, password)` - import an Ethereum Pre Sale wallet
33+
You can import the `Wallet` class like this
4234

43-
For the V1, V3 and EthSale formats the input is a JSON serialized string. All these formats require a password.
35+
Node.js / ES5:
4436

45-
Note: `fromPublicKey()` only accepts uncompressed Ethereum-style public keys, unless the `nonStrict` flag is set to true.
46-
47-
Instance methods:
48-
49-
- `getPrivateKey()` - return the private key
50-
- `getPublicKey()` - return the public key
51-
- `getAddress()` - return the address
52-
- `getChecksumAddressString()` - return the [address with checksum](https://github.com/ethereum/EIPs/issues/55)
53-
- `getV3Filename([timestamp])` - return the suggested filename for V3 keystores
54-
- `toV3(password, [options])` - return the wallet as a JSON string (Version 3 of the Ethereum wallet format)
37+
```js
38+
const { Wallet } = require('ethereumjs-wallet')
39+
```
5540

56-
All of the above instance methods return a Buffer or JSON. Use the `String` suffixed versions for a string output, such as `getPrivateKeyString()`.
41+
ESM / TypeScript:
5742

58-
Note: `getPublicKey()` only returns uncompressed Ethereum-style public keys.
43+
```js
44+
import { Wallet } from 'ethereumjs-wallet'
45+
```
5946

6047
## Thirdparty API
6148

6249
Importing various third party wallets is possible through the `thirdparty` submodule:
6350

64-
`const { thirdparty } = require('ethereumjs-wallet')`
51+
Node.js / ES5:
6552

66-
Constructors:
53+
```js
54+
const { thirdparty } = require('ethereumjs-wallet')
55+
```
56+
57+
ESM / TypeScript:
58+
59+
```js
60+
import { thirdparty } from 'ethereumjs-wallet'
61+
```
6762

68-
- `fromEtherCamp(passphrase)` - import a brain wallet used by Ether.Camp
69-
- `fromEtherWallet(input, password)` - import a wallet generated by EtherWallet
70-
- `fromKryptoKit(seed)` - import a wallet from a KryptoKit seed
71-
- `fromQuorumWallet(passphrase, userid)` - import a brain wallet used by Quorum Wallet
63+
Please go to [./docs/README.md](./docs/README.md) for more info.
7264

7365
## HD Wallet API
7466

7567
To use BIP32 HD wallets, first include the `hdkey` submodule:
7668

77-
`const { hdkey } = require('ethereumjs-wallet')`
78-
79-
Constructors:
69+
Node.js / ES5:
8070

81-
- `fromMasterSeed(seed)` - create an instance based on a seed
82-
- `fromExtendedKey(key)` - create an instance based on a BIP32 extended private or public key
71+
```js
72+
const { hdkey } = require('ethereumjs-wallet')
73+
```
8374

84-
For the seed we suggest to use [bip39](https://npmjs.org/package/bip39) to create one from a BIP39 mnemonic.
75+
ESM / TypeScript:
8576

86-
Instance methods:
77+
```js
78+
import { hdkey } from 'ethereumjs-wallet'
79+
```
8780

88-
- `privateExtendedKey()` - return a BIP32 extended private key (xprv)
89-
- `publicExtendedKey()` - return a BIP32 extended public key (xpub)
90-
- `derivePath(path)` - derive a node based on a path (e.g. m/44'/0'/0/1)
91-
- `deriveChild(index)` - derive a node based on a child index
92-
- `getWallet()` - return a `Wallet` instance as seen above
81+
Please go to [./docs/classes/ethereumhdkey.md](./docs/classes/ethereumhdkey.md) for more info.
9382

9483
## Provider Engine
9584

9685
The Wallet can be easily plugged into [provider-engine](https://github.com/metamask/provider-engine) to provide signing:
9786

87+
Node.js / ES5:
88+
9889
```js
9990
const { WalletSubprovider } = require('ethereumjs-wallet')
10091

10192
<engine>.addProvider(new WalletSubprovider(<wallet instance>))
10293
```
10394

95+
ESM / TypeScript:
96+
97+
```js
98+
import { WalletSubprovider } from 'ethereumjs-wallet'
99+
100+
<engine>.addProvider(new WalletSubprovider(<wallet instance>))
101+
```
102+
104103
Note it only supports the basic wallet. With a HD Wallet, call `getWallet()` first.
105104

105+
Please go to [./docs/classes/walletsubprovider.md](./docs/README.md) for more info.
106+
106107
### Remarks about `toV3`
107108

108109
The `options` is an optional object hash, where all the serialization parameters can be fine tuned:

docs/README.md

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# ethereumjs-wallet
2+
3+
## Index
4+
5+
### Classes
6+
7+
- [EthereumHDKey](classes/ethereumhdkey.md)
8+
- [Wallet](classes/wallet.md)
9+
- [WalletSubprovider](classes/walletsubprovider.md)
10+
11+
### Interfaces
12+
13+
- [EtherWalletOptions](interfaces/etherwalletoptions.md)
14+
- [EvpKdfOpts](interfaces/evpkdfopts.md)
15+
16+
### Functions
17+
18+
- [fromEtherCamp](#fromethercamp)
19+
- [fromEtherWallet](#frometherwallet)
20+
- [fromKryptoKit](#fromkryptokit)
21+
- [fromQuorumWallet](#fromquorumwallet)
22+
23+
---
24+
25+
## Functions
26+
27+
<a id="fromethercamp"></a>
28+
29+
### fromEtherCamp
30+
31+
**fromEtherCamp**(passphrase: _`string`_): [Wallet](classes/wallet.md)
32+
33+
_Defined in [thirdparty.ts:169](https://github.com/ethereumjs/ethereumjs-wallet/blob/c748f97/src/thirdparty.ts#L169)_
34+
35+
Third Party API: Import a brain wallet used by Ether.Camp
36+
37+
**Parameters:**
38+
39+
| Name | Type |
40+
| ---------- | -------- |
41+
| passphrase | `string` |
42+
43+
**Returns:** [Wallet](classes/wallet.md)
44+
45+
---
46+
47+
<a id="frometherwallet"></a>
48+
49+
### fromEtherWallet
50+
51+
**fromEtherWallet**(input: _`string` \| [EtherWalletOptions](interfaces/etherwalletoptions.md)_, password: _`string`_): [Wallet](classes/wallet.md)
52+
53+
_Defined in [thirdparty.ts:121](https://github.com/ethereumjs/ethereumjs-wallet/blob/c748f97/src/thirdparty.ts#L121)_
54+
55+
**Parameters:**
56+
57+
| Name | Type |
58+
| -------- | ------------------------------------------------------------------ |
59+
| input | `string` \| [EtherWalletOptions](interfaces/etherwalletoptions.md) |
60+
| password | `string` |
61+
62+
**Returns:** [Wallet](classes/wallet.md)
63+
64+
---
65+
66+
<a id="fromkryptokit"></a>
67+
68+
### fromKryptoKit
69+
70+
**fromKryptoKit**(entropy: _`string`_, password: _`string`_): [Wallet](classes/wallet.md)
71+
72+
_Defined in [thirdparty.ts:176](https://github.com/ethereumjs/ethereumjs-wallet/blob/c748f97/src/thirdparty.ts#L176)_
73+
74+
Third Party API: Import a wallet from a KryptoKit seed
75+
76+
**Parameters:**
77+
78+
| Name | Type |
79+
| -------- | -------- |
80+
| entropy | `string` |
81+
| password | `string` |
82+
83+
**Returns:** [Wallet](classes/wallet.md)
84+
85+
---
86+
87+
<a id="fromquorumwallet"></a>
88+
89+
### fromQuorumWallet
90+
91+
**fromQuorumWallet**(passphrase: _`string`_, userid: _`string`_): [Wallet](classes/wallet.md)
92+
93+
_Defined in [thirdparty.ts:265](https://github.com/ethereumjs/ethereumjs-wallet/blob/c748f97/src/thirdparty.ts#L265)_
94+
95+
Third Party API: Import a brain wallet used by Quorum Wallet
96+
97+
**Parameters:**
98+
99+
| Name | Type |
100+
| ---------- | -------- |
101+
| passphrase | `string` |
102+
| userid | `string` |
103+
104+
**Returns:** [Wallet](classes/wallet.md)
105+
106+
---

0 commit comments

Comments
 (0)