Skip to content

Commit

Permalink
Use standalone BN.js v4.11.8 instead of Util v5 re-exported BN.js v5 …
Browse files Browse the repository at this point in the history
…to solve missing r._strip issue on browser tests
  • Loading branch information
holgerd77 committed May 9, 2020
1 parent 81ac212 commit 56ec93a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"dependencies": {
"@web3-js/scrypt-shim": "^0.1.0",
"aes-js": "^3.1.1",
"bn.js": "^4.11.8",
"bs58check": "^2.1.2",
"ethereumjs-util": "^7.0.0",
"hdkey": "^1.1.1",
Expand Down
5 changes: 3 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as ethUtil from 'ethereumjs-util'
export { default as hdkey } from './hdkey'
export { default as thirdparty } from './thirdparty'

const BN = require('bn.js')
const bs58check = require('bs58check')
const randomBytes = require('randombytes')
const scryptsy = require('@web3-js/scrypt-shim')
Expand Down Expand Up @@ -253,10 +254,10 @@ export default class Wallet {
*/
public static generate(icapDirect: boolean = false): Wallet {
if (icapDirect) {
const max = new ethUtil.BN('088f924eeceeda7fe92e1f5b0fffffffffffffff', 16)
const max = new BN('088f924eeceeda7fe92e1f5b0fffffffffffffff', 16)
while (true) {
const privateKey = randomBytes(32) as Buffer
if (new ethUtil.BN(ethUtil.privateToAddress(privateKey)).lte(max)) {
if (new BN(ethUtil.privateToAddress(privateKey)).lte(max)) {
return new Wallet(privateKey)
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* tslint:disable no-invalid-this */
import * as assert from 'assert'
import { BN } from 'ethereumjs-util'
import { Wallet as ethersWallet } from 'ethers'

const BN = require('bn.js')
const zip = require('lodash.zip')

import Wallet from '../src'
Expand Down

0 comments on commit 56ec93a

Please sign in to comment.