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

Commit 733e49b

Browse files
committed
use module style exports to maintain the way JS imports the compiled code
1 parent 384860e commit 733e49b

File tree

8 files changed

+22
-15
lines changed

8 files changed

+22
-15
lines changed

.gitignore

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@ package-lock.json
3535
# Optional REPL history
3636
.node_repl_history
3737

38-
# Build folder
39-
# Update 2018-08-07: currently build is done to / (before: dist/) due to
40-
# backwards compatibility reasons, JS files from root and root test/ folder
41-
# are excluded
42-
/*.js
4338

4439
# IDE and text editor config files
4540
.idea

prettier.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('@ethereumjs/config-prettier')

src/hdkey.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { Wallet } from './index'
1+
import Wallet = require('./index')
22

33
const HDKey = require('hdkey')
44

5-
export class EthereumHDKey {
5+
class EthereumHDKey {
66
public static fromMasterSeed(seedBuffer: Buffer): EthereumHDKey {
77
return new EthereumHDKey(HDKey.fromMasterSeed(seedBuffer))
88
}
@@ -39,3 +39,5 @@ export class EthereumHDKey {
3939
return Wallet.fromPublicKey(this._hdkey._publicKey, true)
4040
}
4141
}
42+
43+
export = EthereumHDKey

src/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ function stripUnusedKDFParamsForScrypt(params: KDFParams): Partial<KDFParams> {
101101
return params
102102
}
103103

104-
export class Wallet {
104+
class Wallet {
105105
// static methods
106106

107107
public static generate(icapDirect: boolean = false): Wallet {
@@ -309,6 +309,9 @@ export class Wallet {
309309
throw new Error('Cannot supply both a private and a public key to the constructor')
310310
}
311311

312+
if (!privateKey && !publicKey) {
313+
}
314+
312315
if (privateKey && !ethUtil.isValidPrivate(privateKey)) {
313316
throw new Error('Private key does not satisfy the curve requirements (ie. it is invalid)')
314317
}
@@ -442,3 +445,5 @@ function runCipherBuffer(cipher: crypto.Cipher | crypto.Decipher, data: Buffer):
442445
function keyExists(k: Buffer | undefined): k is Buffer {
443446
return k !== undefined
444447
}
448+
449+
export = Wallet

src/provider-engine.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { Wallet } from './index'
1+
import Wallet = require('./index')
22

33
const HookedWalletEthTxSubprovider = require('web3-provider-engine/subproviders/hooked-wallet-ethtx')
44

5-
export class WalletSubprovider extends HookedWalletEthTxSubprovider {
5+
class WalletSubprovider extends HookedWalletEthTxSubprovider {
66
constructor(wallet: Wallet, opts?: any) {
77
if (!opts) {
88
opts = {}
@@ -20,3 +20,5 @@ export class WalletSubprovider extends HookedWalletEthTxSubprovider {
2020
super(opts)
2121
}
2222
}
23+
24+
export = WalletSubprovider

src/thirdparty.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as crypto from 'crypto'
22
import * as ethUtil from 'ethereumjs-util'
33

4-
import { Wallet } from './index'
4+
import Wallet = require('./index')
55

66
const scryptsy = require('scrypt.js')
77
const utf8 = require('utf8')
@@ -239,9 +239,11 @@ function fromQuorumWallet(passphrase: string, userid: string): Wallet {
239239
return new Wallet(seed)
240240
}
241241

242-
export const Thirdparty = {
242+
const Thirdparty = {
243243
fromEtherWallet,
244244
fromEtherCamp,
245245
fromKryptoKit,
246246
fromQuorumWallet,
247247
}
248+
249+
export = Thirdparty

test/hdkey.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as assert from 'assert'
2-
import { EthereumHDKey } from '../src/hdkey'
2+
import EthereumHDKey = require('../src/hdkey')
33

44
// from BIP39 mnemonic: awake book subject inch gentle blur grant damage process float month clown
55
const fixtureseed = Buffer.from(

test/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
import * as assert from 'assert'
33
import * as ethUtil from 'ethereumjs-util'
44

5-
import { Wallet } from '../src'
6-
import { Thirdparty } from '../src/thirdparty'
5+
import Wallet = require('../src')
6+
import Thirdparty = require('../src/thirdparty')
77

88
const fixturePrivateKey = 'efca4cdd31923b50f4214af5d2ae10e7ac45a5019e9431cc195482d707485378'
99
const fixturePrivateKeyStr = '0x' + fixturePrivateKey

0 commit comments

Comments
 (0)