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

Test downgraded BN.js version #122

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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