Skip to content

Commit

Permalink
refactor(): upgrade deps, fix tests, clean lint
Browse files Browse the repository at this point in the history
  • Loading branch information
jwerle committed Apr 2, 2021
1 parent 6d934d0 commit 2b6f642
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 28 deletions.
5 changes: 4 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"extends": "ara"
"extends": "ara",
"rules": {
"no-warnings-comments": "off"
}
}
4 changes: 2 additions & 2 deletions create.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ async function create(opts) {
if (isBuffer(opts.seed)) {
seed = opts.seed
} else {
seed = crypto.blake2b(bip39.mnemonicToSeed(mnemonic))
seed = crypto.blake2b(await bip39.mnemonicToSeed(mnemonic))
}

const kp = crypto.keyPair(seed)
Expand All @@ -305,7 +305,7 @@ async function create(opts) {
encryptionKey = createEncryptionKey()

wallet = await ethereum.wallet.load({
seed: bip39.mnemonicToSeed(mnemonic)
seed: await bip39.mnemonicToSeed(mnemonic)
})

account = await ethereum.account.create({
Expand Down
5 changes: 2 additions & 3 deletions ethereum/wallet.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* eslint-disable import/no-unresolved */
/* eslint-disable global-require */
const { fromMasterSeed } = require('ethereumjs-wallet/hdkey')
const isZeroBuffer = require('is-zero-buffer')
const { hdkey } = require('ethereumjs-wallet')
const isBuffer = require('is-buffer')

const DERIVATION_PATH = 'm/44\'/60\'/0\'/0/'
Expand All @@ -22,7 +21,7 @@ async function load(opts) {
}

const { seed } = opts
const hdWallet = fromMasterSeed(seed)
const hdWallet = hdkey.fromMasterSeed(seed)

return hdWallet.derivePath(`${DERIVATION_PATH}${index}`).getWallet()
}
Expand Down
2 changes: 1 addition & 1 deletion fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ async function readFile(identifier, filename, opts) {
*/
async function writeFile(identifier, filename, buffer, opts) {
const path = resolvePath(identifier, filename)
await pify(mkdirp)(dirname(path))
await mkdirp(dirname(path))
return pify(fs.writeFile)(path, buffer, opts)
}

Expand Down
28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,23 @@
"author": "Joseph Werle <[email protected]>",
"license": "LGPL-3.0",
"dependencies": {
"ara-console": "^0.2.1",
"ara-console": "^0.3.0",
"ara-context": "^1.0.2",
"ara-crypto": "^0.8.5",
"ara-crypto": "^0.9.1",
"ara-identity-dns": "^0.3.0",
"ara-network": "^1.3.7",
"ara-runtime-configuration": "^2.0.1",
"ara-secret-storage": "^0.1.3",
"ara-secret-storage": "^0.2.0",
"async-exit-hook": "^2.0.1",
"bip39": "^2.5.0",
"bip39": "^3.0.3",
"brfs": "^2.0.2",
"cfsnet": "^0.19.2",
"debug": "^3.1.0",
"debug": "^4.3.1",
"did-document": "^0.6.2",
"did-uri": "^0.2.8",
"ethereumjs-wallet": "^0.6.3",
"did-uri": "^0.4.1",
"ethereumjs-wallet": "^1.0.1",
"extend": "^3.0.1",
"inquirer": "^5.2.0",
"inquirer": "^8.0.0",
"ip": "^1.1.5",
"is-browser": "^2.1.0",
"is-buffer": "^2.0.2",
Expand All @@ -55,18 +55,18 @@
"keythereum": "^1.0.4",
"ld-cryptosuite-registry": "^0.3.2",
"mirror-folder": "^3.0.0",
"mkdirp": "^0.5.1",
"mkdirp": "^1.0.4",
"node-fetch": "^2.3.0",
"pify": "^3.0.0",
"pify": "^5.0.0",
"protocol-buffers": "^4.0.4",
"protocol-buffers-encodings": "^1.1.0",
"pump": "^3.0.0",
"random-access-file": "^2.1.1",
"random-access-memory": "^3.0.0",
"randombytes": "^2.1.0",
"rimraf": "^2.6.2",
"table": "^4.0.3",
"yargs": "^12.0.1"
"rimraf": "^3.0.2",
"table": "^6.0.9",
"yargs": "^16.2.0"
},
"devDependencies": {
"ava": "^3.15.0",
Expand All @@ -75,7 +75,7 @@
"eslint-config-ara": "github:arablocks/eslint-config-ara#semver:^3.0.x",
"eslint-plugin-import": "^2.22.1",
"pkg": "^4.5.1",
"truffle": "^5.2.6",
"truffle": "^5.3.0",
"web3": "^1.3.4"
},
"directories": {
Expand Down
7 changes: 6 additions & 1 deletion resolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,12 @@ async function findResolution(did, opts, state) {
return
}

if (0 === pending && !didResolve && 0 === resolvers.length && !state.aborted) {
if (
0 === pending
&& !didResolve
&& 0 === resolvers.length
&& !state.aborted
) {
// Revert to expired cache copy if present
if (false === isBrowser) {
try {
Expand Down
2 changes: 1 addition & 1 deletion revoke.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async function revoke(opts) {
throw new TypeError('Expecting password to be a string.')
}

const seed = crypto.blake2b(bip39.mnemonicToSeed(opts.mnemonic))
const seed = crypto.blake2b(await bip39.mnemonicToSeed(opts.mnemonic))
const { publicKey } = crypto.keyPair(seed)

let ddo
Expand Down
2 changes: 1 addition & 1 deletion test/ethereum/keystore.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ test('create(opts)', async (t) => {
})

test('dump(opts)', async (t) => {
let seed = bip39.mnemonicToSeed(bip39.generateMnemonic())
let seed = await bip39.mnemonicToSeed(bip39.generateMnemonic())
seed = crypto.blake2b(seed)
const wal = await wallet.load({ seed })
const ks = await keystore.create()
Expand Down
2 changes: 1 addition & 1 deletion test/ethereum/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ test('ethereum.wallet.load(opts)', async (t) => {
await t.throwsAsync(load(NaN), { instanceOf: TypeError })
await t.throwsAsync(load({}), { instanceOf: TypeError })

let seed = bip39.mnemonicToSeed(bip39.generateMnemonic())
let seed = await bip39.mnemonicToSeed(bip39.generateMnemonic())
seed = crypto.blake2b(seed)
t.true(null != load({ seed }))
})
6 changes: 3 additions & 3 deletions util.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ async function writeIdentity(identity) {

const output = createIdentityKeyPath(identity)

await pify(mkdirp)(output)
await mkdirp(output)

for (let i = 0; i < identity.files.length; ++i) {
if (
Expand All @@ -87,7 +87,7 @@ async function writeIdentity(identity) {
&& identity.files[i].buffer
) {
const dir = dirname(resolve(output, identity.files[i].path))
await pify(mkdirp)(dir)
await mkdirp(dir)
await pify(fs.writeFile)(
resolve(output, identity.files[i].path),
identity.files[i].buffer
Expand All @@ -110,7 +110,7 @@ async function resolveDNS(uri) {
async function writeCache(identifier, filename, buffer) {
try {
const cachePath = join(os.tmpdir(), 'aid', identifier, filename)
await pify(mkdirp)(dirname(cachePath))
await mkdirp(dirname(cachePath))
await pify(fs.writeFile)(cachePath, buffer)
} catch (err) {
debug(err)
Expand Down

0 comments on commit 2b6f642

Please sign in to comment.