Skip to content

Commit

Permalink
refactor: remove throwError util
Browse files Browse the repository at this point in the history
  • Loading branch information
mikesposito committed Jan 29, 2024
1 parent 6aa6706 commit 9985f69
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 19 deletions.
2 changes: 1 addition & 1 deletion packages/keyring-controller/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = merge(baseConfig, {
// An object that configures minimum threshold enforcement for coverage results
coverageThreshold: {
global: {
branches: 95.17,
branches: 95.71,
functions: 100,
lines: 99.21,
statements: 99.22,
Expand Down
25 changes: 15 additions & 10 deletions packages/keyring-controller/src/KeyringController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ import Wallet, { thirdparty as importers } from 'ethereumjs-wallet';
import type { Patch } from 'immer';

import { KeyringControllerError } from './constants';
import { throwError } from './utils';

const name = 'KeyringController';

Expand Down Expand Up @@ -1277,9 +1276,11 @@ export class KeyringController extends BaseController<
address,
)) as EthKeyring<Json>;

return keyring.prepareUserOperation
? await keyring.prepareUserOperation(address, transactions)
: throwError(KeyringControllerError.UnsupportedPrepareUserOperation);
if (!keyring.prepareUserOperation) {
throw new Error(KeyringControllerError.UnsupportedPrepareUserOperation);
}

return await keyring.prepareUserOperation(address, transactions);
}

/**
Expand All @@ -1299,9 +1300,11 @@ export class KeyringController extends BaseController<
address,
)) as EthKeyring<Json>;

return keyring.patchUserOperation
? await keyring.patchUserOperation(address, userOp)
: throwError(KeyringControllerError.UnsupportedPatchUserOperation);
if (!keyring.patchUserOperation) {
throw new Error(KeyringControllerError.UnsupportedPatchUserOperation);
}

return await keyring.patchUserOperation(address, userOp);
}

/**
Expand All @@ -1320,9 +1323,11 @@ export class KeyringController extends BaseController<
address,
)) as EthKeyring<Json>;

return keyring.signUserOperation
? await keyring.signUserOperation(address, userOp)
: throwError(KeyringControllerError.UnsupportedSignUserOperation);
if (!keyring.signUserOperation) {
throw new Error(KeyringControllerError.UnsupportedSignUserOperation);
}

return await keyring.signUserOperation(address, userOp);
}

/**
Expand Down
8 changes: 0 additions & 8 deletions packages/keyring-controller/src/utils.ts

This file was deleted.

0 comments on commit 9985f69

Please sign in to comment.