Skip to content

Commit

Permalink
chore: update some deps
Browse files Browse the repository at this point in the history
  • Loading branch information
vvvvvv1vvvvvv committed Oct 11, 2023
1 parent 4ab3b39 commit c5242c0
Show file tree
Hide file tree
Showing 8 changed files with 277 additions and 95 deletions.
4 changes: 4 additions & 0 deletions build/webpack.common.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,10 @@ const config = {
fallback: {
stream: require.resolve('stream-browserify'),
crypto: require.resolve('crypto-browserify'),
url: require.resolve('url'),
zlib: require.resolve('browserify-zlib'),
https: require.resolve('https-browserify'),
http: require.resolve('stream-http')
},
extensions: ['.js', 'jsx', '.ts', '.tsx'],
},
Expand Down
16 changes: 10 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,16 @@
"@ledgerhq/devices": "^7.0.5",
"@ledgerhq/hw-app-eth": "^6.25.0",
"@ledgerhq/hw-transport-webhid": "^6.24.1",
"@metamask/eth-sig-util": "^4.0.0",
"@metamask/browser-passworder": "^4.1.0",
"@metamask/eth-sig-util": "^7.0.0",
"@metamask/obs-store": "^6.0.2",
"@ngraveio/bc-ur": "^1.1.6",
"@onekeyfe/hd-core": "^0.3.27",
"@onekeyfe/hd-web-sdk": "^0.3.27",
"@rabby-wallet/eth-gnosis-keyring": "^0.0.1",
"@rabby-wallet/eth-hd-keyring": "^3.6.12",
"@rabby-wallet/eth-hd-keyring": "^4.0.0",
"@rabby-wallet/eth-lattice-keyring": "^1.0.5",
"@rabby-wallet/eth-simple-keyring": "^4.2.1",
"@rabby-wallet/eth-simple-keyring": "^5.0.0",
"@rabby-wallet/eth-trezor-keyring": "^2.2.0",
"@rabby-wallet/eth-walletconnect-keyring": "^1.7.21",
"@rabby-wallet/eth-watch-keyring": "^1.0.0",
Expand All @@ -48,6 +49,7 @@
"@rabby-wallet/widgets": "^1.0.9",
"@rematch/core": "^2.2.0",
"@rematch/select": "^3.1.2",
"@scure/bip39": "^1.2.1",
"@sentry/browser": "^6.7.2",
"@sentry/react": "^6.7.2",
"@sentry/tracing": "^6.19.7",
Expand All @@ -63,9 +65,8 @@
"ahooks": "^3.1.5",
"antd": "^4.15.3",
"bignumber.js": "^9.0.1",
"bip39": "^3.0.3",
"bitbox02-api": "^0.15.1",
"browser-passworder": "^2.0.3",
"browserify-zlib": "^0.2.0",
"buffer": "^6.0.3",
"clipboard": "^2.0.8",
"clsx": "^1.1.1",
Expand All @@ -77,10 +78,11 @@
"eth-rpc-errors": "^4.0.3",
"eth-sig-util": "^3.0.1",
"ethereumjs-util": "^7.1.2",
"ethereumjs-wallet": "^1.0.1",
"ethereumjs-wallet": "^1.0.2",
"ethers": "^5.4.2",
"events": "^3.3.0",
"hdkey": "0.8.0",
"https-browserify": "^1.0.0",
"human-standard-token-abi": "^2.0.0",
"immer": "^9.0.14",
"interval-promise": "^1.4.0",
Expand Down Expand Up @@ -114,8 +116,10 @@
"semver": "^7.5.2",
"semver-compare": "^1.0.0",
"stream-browserify": "^3.0.0",
"stream-http": "^3.2.0",
"styled-components": "^5.3.5",
"ts-toolbelt": "^9.6.0",
"url": "^0.11.3",
"uuid": "^9.0.0",
"web3-eth-abi": "^1.7.0",
"web3-utils": "^1.7.0",
Expand Down
2 changes: 0 additions & 2 deletions src/background/controller/provider/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@ import {
pageStateCacheService,
signTextHistoryService,
RPCService,
i18n,
swapService,
notificationService,
} from 'background/service';
import { notification } from 'background/webapi';
import { Session } from 'background/service/session';
import { Tx } from 'background/service/openapi';
import RpcCache from 'background/utils/rpcCache';
Expand Down
5 changes: 3 additions & 2 deletions src/background/controller/wallet.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import * as ethUtil from 'ethereumjs-util';
import Wallet, { thirdparty } from 'ethereumjs-wallet';
import { ethErrors } from 'eth-rpc-errors';
import * as bip39 from 'bip39';
import * as bip39 from '@scure/bip39';
import { wordlist } from '@scure/bip39/wordlists/english';
import { ethers, Contract } from 'ethers';
import { groupBy, uniq } from 'lodash';
import abiCoder, { AbiCoder } from 'web3-eth-abi';
Expand Down Expand Up @@ -2164,7 +2165,7 @@ export class WalletController extends BaseController {
};

generateKeyringWithMnemonic = async (mnemonic: string) => {
if (!bip39.validateMnemonic(mnemonic)) {
if (!bip39.validateMnemonic(mnemonic, wordlist)) {
throw new Error(t('background.error.invalidMnemonic'));
}
// If import twice use same kerying
Expand Down
13 changes: 8 additions & 5 deletions src/background/service/keyring/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

import { EventEmitter } from 'events';
import log from 'loglevel';
import encryptor from 'browser-passworder';
import * as encryptor from '@metamask/browser-passworder';
import * as ethUtil from 'ethereumjs-util';
import * as bip39 from 'bip39';
import * as bip39 from '@scure/bip39';
import { wordlist } from '@scure/bip39/wordlists/english';
import { ObservableStore } from '@metamask/obs-store';
import {
normalizeAddress,
Expand Down Expand Up @@ -188,7 +189,7 @@ export class KeyringService extends EventEmitter {
}

generateMnemonic(): string {
return bip39.generateMnemonic();
return bip39.generateMnemonic(wordlist);
}

async generatePreMnemonic(): Promise<string> {
Expand Down Expand Up @@ -238,7 +239,7 @@ export class KeyringService extends EventEmitter {
* @returns {Promise<Object>} A Promise that resolves to the state.
*/
createKeyringWithMnemonics(seed: string): Promise<any> {
if (!bip39.validateMnemonic(seed)) {
if (!bip39.validateMnemonic(seed, wordlist)) {
return Promise.reject(
new Error(i18n.t('background.error.invalidMnemonic'))
);
Expand Down Expand Up @@ -826,7 +827,9 @@ export class KeyringService extends EventEmitter {
await this.clearKeyrings();
const vault = await this.encryptor.decrypt(password, encryptedVault);
// TODO: FIXME
await Promise.all(Array.from(vault).map(this._restoreKeyring.bind(this)));
await Promise.all(
Array.from(vault as any).map(this._restoreKeyring.bind(this))
);
await this._updateMemStoreKeyrings();
return this.keyrings;
}
Expand Down
5 changes: 0 additions & 5 deletions src/modules.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
declare module 'browser-passworder' {
export function encrypt(password: string, privateKey: any): Promise<string>;
export function decrypt(password: string, encrypted: string): Promise<Buffer>;
}

declare module '*.svg' {
const ReactComponent: React.FC<React.SVGProps<SVGSVGElement>>;
const content: string;
Expand Down
4 changes: 2 additions & 2 deletions src/ui/utils/smart-completion.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { wordlists } from 'bip39';
import { wordlist } from '@scure/bip39/wordlists/english';

const EN = wordlists.EN;
const EN = wordlist;

const SEARCH_KEYS = new Set<string>();
const SEARCH_CACHE = [] as { prefix: string; words: string[] | false }[];
Expand Down
Loading

0 comments on commit c5242c0

Please sign in to comment.