Skip to content

Commit

Permalink
@metamask/eslint [email protected] (#10358)
Browse files Browse the repository at this point in the history
* @metamask/[email protected]
* Update eslintrc and prettierrc
* yarn lint:fix
  • Loading branch information
rekmarks authored Feb 4, 2021
1 parent e82ab94 commit 76a2a9b
Show file tree
Hide file tree
Showing 1,169 changed files with 32,914 additions and 32,568 deletions.
14 changes: 5 additions & 9 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,6 @@ module.exports = {

'prettier/prettier': 'error',

// Our usage of spaces before *named* function parens is unusual, and
// doesn't match the prettier spec. prettier does not offer an option
// to configure this
'space-before-function-paren': [
'error',
{ anonymous: 'always', named: 'never' },
],
// Our eslint config has the default setting for this as error. This
// include beforeBlockComment: true, but in order to match the prettier
// spec you have to enable before and after blocks, objects and arrays
Expand Down Expand Up @@ -147,7 +140,10 @@ module.exports = {
'no-invalid-this': 'off',
'@babel/no-invalid-this': 'error',

'@babel/semi': ['error', 'never'],
// prettier handles these
semi: 'off',
'@babel/semi': 'off',

'mocha/no-setup-in-describe': 'off',
'node/no-process-env': 'off',

Expand Down Expand Up @@ -213,4 +209,4 @@ module.exports = {
version: 'detect',
},
},
}
};
1 change: 0 additions & 1 deletion .prettierrc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
singleQuote: true
semi: false
trailingComma: all
48 changes: 24 additions & 24 deletions app/scripts/account-import-strategies/index.js
Original file line number Diff line number Diff line change
@@ -1,53 +1,53 @@
import log from 'loglevel'
import Wallet from 'ethereumjs-wallet'
import importers from 'ethereumjs-wallet/thirdparty'
import ethUtil from 'ethereumjs-util'
import { addHexPrefix } from '../lib/util'
import log from 'loglevel';
import Wallet from 'ethereumjs-wallet';
import importers from 'ethereumjs-wallet/thirdparty';
import ethUtil from 'ethereumjs-util';
import { addHexPrefix } from '../lib/util';

const accountImporter = {
importAccount(strategy, args) {
try {
const importer = this.strategies[strategy]
const privateKeyHex = importer(...args)
return Promise.resolve(privateKeyHex)
const importer = this.strategies[strategy];
const privateKeyHex = importer(...args);
return Promise.resolve(privateKeyHex);
} catch (e) {
return Promise.reject(e)
return Promise.reject(e);
}
},

strategies: {
'Private Key': (privateKey) => {
if (!privateKey) {
throw new Error('Cannot import an empty key.')
throw new Error('Cannot import an empty key.');
}

const prefixed = addHexPrefix(privateKey)
const buffer = ethUtil.toBuffer(prefixed)
const prefixed = addHexPrefix(privateKey);
const buffer = ethUtil.toBuffer(prefixed);

if (!ethUtil.isValidPrivate(buffer)) {
throw new Error('Cannot import invalid private key.')
throw new Error('Cannot import invalid private key.');
}

const stripped = ethUtil.stripHexPrefix(prefixed)
return stripped
const stripped = ethUtil.stripHexPrefix(prefixed);
return stripped;
},
'JSON File': (input, password) => {
let wallet
let wallet;
try {
wallet = importers.fromEtherWallet(input, password)
wallet = importers.fromEtherWallet(input, password);
} catch (e) {
log.debug('Attempt to import as EtherWallet format failed, trying V3')
wallet = Wallet.fromV3(input, password, true)
log.debug('Attempt to import as EtherWallet format failed, trying V3');
wallet = Wallet.fromV3(input, password, true);
}

return walletToPrivateKey(wallet)
return walletToPrivateKey(wallet);
},
},
}
};

function walletToPrivateKey(wallet) {
const privateKeyBuffer = wallet.getPrivateKey()
return ethUtil.bufferToHex(privateKeyBuffer)
const privateKeyBuffer = wallet.getPrivateKey();
return ethUtil.bufferToHex(privateKeyBuffer);
}

export default accountImporter
export default accountImporter;
Loading

0 comments on commit 76a2a9b

Please sign in to comment.