Skip to content

Commit

Permalink
add walletFromMnemonicAsync with better performance
Browse files Browse the repository at this point in the history
  • Loading branch information
shrpne committed Mar 24, 2021
1 parent 9d14972 commit a86f4f0
Show file tree
Hide file tree
Showing 11 changed files with 2,430 additions and 4,150 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 6.1.0 - 2021-03-24
- add `walletFromMnemonicAsync`, use it to get better performance in browser

## 6.0.0 - 2020-08-11
- **BREAKING** getPrivateKeyString now returns 0x-prefixed string

Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ or from browser
<script>
const wallet = minterWallet.generateWallet();
const wallet2 = minterWallet.walletFromMnemonic('...');
// use async for better performance
const wallet3 = await minterWallet.walletFromMnemonicAsync('...');
</script>
```

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

#### `walletFromMnemonicAsync(mnemonic)`
Same as `walletFromMnemonic` but async and has better performance in browser, beacause it uses `window.crypto.subtle` under hood
```js
import {walletFromMnemonicAsync} from 'minterjs-wallet';
const wallet = await walletFromMnemonicAsync('surround tape away million into program organ tonight write prefer inform cool');
```

#### `walletFromPrivateKey(privateKey)`
Create a wallet instance based on a raw private key
```js
Expand Down
6 changes: 6 additions & 0 deletions babel-jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
"presets": ["@babel/preset-env"],
"plugins": [
"@babel/plugin-transform-runtime",
],
}
10 changes: 10 additions & 0 deletions build/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import resolve from '@rollup/plugin-node-resolve';
//@TODO replace with rollup-plugin-polyfill-node when it ready
import builtins from 'rollup-plugin-node-builtins';
import globals from 'rollup-plugin-node-globals';
import babel from 'rollup-plugin-babel';

export default {
input: 'src/index.js',
plugins: [
// old acorn in rollup-plugin-node-globals doesn't support new syntax
babel({
babelrc: false,
configFile: false,
"plugins": [
"@babel/plugin-proposal-optional-chaining",
"@babel/plugin-proposal-numeric-separator",
],
}),
commonjs({
// namedExports: {
// 'node_modules/ethereumjs-util/dist/index.js': [ 'stripHexPrefix', 'padToEven' ],
Expand Down
10 changes: 7 additions & 3 deletions jest-bundle-cjs.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
const path = require('path');

module.exports = {
moduleNameMapper: {
'~\/src$': '<rootDir>/dist/cjs/index.js',
},
// transform: {
// '^.+\\.jsx?$': 'babel-jest',
// },
transform: {
'^.+\\.jsx?$': ['babel-jest', {
configFile: path.resolve(__dirname, './babel-jest.config.js')
}],
},
testEnvironment: 'node',
};
6 changes: 5 additions & 1 deletion jest-bundle.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
const path = require('path');

module.exports = {
moduleNameMapper: {
'~\/src$': '<rootDir>/dist/index.js',
},
transform: {
'^.+\\.jsx?$': 'babel-jest',
'^.+\\.jsx?$': ['babel-jest', {
configFile: path.resolve(__dirname, './babel-jest.config.js')
}],
},
transformIgnorePatterns: [
'node_modules/(?!(buffer-es6)/)',
Expand Down
6 changes: 5 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
const path = require('path');

module.exports = {
moduleNameMapper: {
'~(.*)$': '<rootDir>/$1',
},
transform: {
'^.+\\.jsx?$': 'babel-jest',
'^.+\\.jsx?$': ['babel-jest', {
configFile: path.resolve(__dirname, './babel-jest.config.js')
}],
},
transformIgnorePatterns: [
'node_modules/(?!(minterjs-util|other-module)/)',
Expand Down
Loading

0 comments on commit a86f4f0

Please sign in to comment.