From b72ef27b2a8f9941fb9d79122ec449fed9d2464d Mon Sep 17 00:00:00 2001 From: Richard Moore Date: Wed, 20 Nov 2019 18:29:42 +0900 Subject: [PATCH] Fixed scrypt import in ESM build. --- packages/cli/src.ts/cli.ts | 4 ++-- packages/json-wallets/src.ts/keystore.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/cli/src.ts/cli.ts b/packages/cli/src.ts/cli.ts index d92248e497..a6d5bba25f 100644 --- a/packages/cli/src.ts/cli.ts +++ b/packages/cli/src.ts/cli.ts @@ -4,7 +4,7 @@ import fs from "fs"; import { basename } from "path"; import { ethers } from "ethers"; -import { scrypt } from "scrypt-js"; +import * as scrypt from "scrypt-js"; import { getChoice, getPassword, getProgressBar } from "./prompt"; @@ -421,7 +421,7 @@ async function loadAccount(arg: string, plugin: Plugin, preventFile?: boolean): let saltBytes = ethers.utils.arrayify(ethers.utils.HDNode.fromMnemonic(mnemonic).privateKey); let progressBar = getProgressBar("Decrypting"); - return scrypt(passwordBytes, saltBytes, (1 << 20), 8, 1, 32, progressBar).then((key) => { + return scrypt.scrypt(passwordBytes, saltBytes, (1 << 20), 8, 1, 32, progressBar).then((key) => { const derivedPassword = ethers.utils.hexlify(key).substring(2); const node = ethers.utils.HDNode.fromMnemonic(mnemonic, derivedPassword).derivePath(ethers.utils.defaultPath); return new ethers.Wallet(node.privateKey, plugin.provider); diff --git a/packages/json-wallets/src.ts/keystore.ts b/packages/json-wallets/src.ts/keystore.ts index ce67c33542..df1ff4636f 100644 --- a/packages/json-wallets/src.ts/keystore.ts +++ b/packages/json-wallets/src.ts/keystore.ts @@ -1,7 +1,7 @@ "use strict"; import aes from "aes-js"; -import { scrypt } from "scrypt-js"; +import * as scrypt from "scrypt-js"; import uuid from "uuid"; import { ExternallyOwnedAccount } from "@ethersproject/abstract-signer"; @@ -148,7 +148,7 @@ export async function decrypt(json: string, password: Bytes | string, progressCa throw new Error("unsupported key-derivation derived-key length"); } - const key = await scrypt(passwordBytes, salt, N, r, p, 64, progressCallback); + const key = await scrypt.scrypt(passwordBytes, salt, N, r, p, 64, progressCallback); //key = arrayify(key); return getAccount(key); @@ -260,7 +260,7 @@ export function encrypt(account: ExternallyOwnedAccount, password: Bytes | strin // We take 64 bytes: // - 32 bytes As normal for the Web3 secret storage (derivedKey, macPrefix) // - 32 bytes AES key to encrypt mnemonic with (required here to be Ethers Wallet) - return scrypt(passwordBytes, salt, N, r, p, 64, progressCallback).then((key) => { + return scrypt.scrypt(passwordBytes, salt, N, r, p, 64, progressCallback).then((key) => { key = arrayify(key); // This will be used to encrypt the wallet (as per Web3 secret storage)