Skip to content

Commit a86f4f0

Browse files
committed
add walletFromMnemonicAsync with better performance
1 parent 9d14972 commit a86f4f0

11 files changed

+2430
-4150
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 6.1.0 - 2021-03-24
2+
- add `walletFromMnemonicAsync`, use it to get better performance in browser
3+
14
## 6.0.0 - 2020-08-11
25
- **BREAKING** getPrivateKeyString now returns 0x-prefixed string
36

README.md

+9
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ or from browser
3535
<script>
3636
const wallet = minterWallet.generateWallet();
3737
const wallet2 = minterWallet.walletFromMnemonic('...');
38+
// use async for better performance
39+
const wallet3 = await minterWallet.walletFromMnemonicAsync('...');
3840
</script>
3941
```
4042

@@ -56,6 +58,13 @@ import {walletFromMnemonic} from 'minterjs-wallet';
5658
const wallet = walletFromMnemonic('surround tape away million into program organ tonight write prefer inform cool');
5759
```
5860

61+
#### `walletFromMnemonicAsync(mnemonic)`
62+
Same as `walletFromMnemonic` but async and has better performance in browser, beacause it uses `window.crypto.subtle` under hood
63+
```js
64+
import {walletFromMnemonicAsync} from 'minterjs-wallet';
65+
const wallet = await walletFromMnemonicAsync('surround tape away million into program organ tonight write prefer inform cool');
66+
```
67+
5968
#### `walletFromPrivateKey(privateKey)`
6069
Create a wallet instance based on a raw private key
6170
```js

babel-jest.config.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
"presets": ["@babel/preset-env"],
3+
"plugins": [
4+
"@babel/plugin-transform-runtime",
5+
],
6+
}

build/rollup.config.js

+10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
import commonjs from '@rollup/plugin-commonjs';
22
import json from '@rollup/plugin-json';
33
import resolve from '@rollup/plugin-node-resolve';
4+
//@TODO replace with rollup-plugin-polyfill-node when it ready
45
import builtins from 'rollup-plugin-node-builtins';
56
import globals from 'rollup-plugin-node-globals';
67
import babel from 'rollup-plugin-babel';
78

89
export default {
910
input: 'src/index.js',
1011
plugins: [
12+
// old acorn in rollup-plugin-node-globals doesn't support new syntax
13+
babel({
14+
babelrc: false,
15+
configFile: false,
16+
"plugins": [
17+
"@babel/plugin-proposal-optional-chaining",
18+
"@babel/plugin-proposal-numeric-separator",
19+
],
20+
}),
1121
commonjs({
1222
// namedExports: {
1323
// 'node_modules/ethereumjs-util/dist/index.js': [ 'stripHexPrefix', 'padToEven' ],

jest-bundle-cjs.config.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1+
const path = require('path');
2+
13
module.exports = {
24
moduleNameMapper: {
35
'~\/src$': '<rootDir>/dist/cjs/index.js',
46
},
5-
// transform: {
6-
// '^.+\\.jsx?$': 'babel-jest',
7-
// },
7+
transform: {
8+
'^.+\\.jsx?$': ['babel-jest', {
9+
configFile: path.resolve(__dirname, './babel-jest.config.js')
10+
}],
11+
},
812
testEnvironment: 'node',
913
};

jest-bundle.config.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1+
const path = require('path');
2+
13
module.exports = {
24
moduleNameMapper: {
35
'~\/src$': '<rootDir>/dist/index.js',
46
},
57
transform: {
6-
'^.+\\.jsx?$': 'babel-jest',
8+
'^.+\\.jsx?$': ['babel-jest', {
9+
configFile: path.resolve(__dirname, './babel-jest.config.js')
10+
}],
711
},
812
transformIgnorePatterns: [
913
'node_modules/(?!(buffer-es6)/)',

jest.config.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1+
const path = require('path');
2+
13
module.exports = {
24
moduleNameMapper: {
35
'~(.*)$': '<rootDir>/$1',
46
},
57
transform: {
6-
'^.+\\.jsx?$': 'babel-jest',
8+
'^.+\\.jsx?$': ['babel-jest', {
9+
configFile: path.resolve(__dirname, './babel-jest.config.js')
10+
}],
711
},
812
transformIgnorePatterns: [
913
'node_modules/(?!(minterjs-util|other-module)/)',

0 commit comments

Comments
 (0)