From 17ce6904a4ddee9c0d741b95b5859b015ddbabe7 Mon Sep 17 00:00:00 2001 From: Darius Parvin Date: Wed, 9 Feb 2022 21:06:29 -0800 Subject: [PATCH] refactor: address nits remove external signing routes for v1 wallet remove outdated comments remove unecessary prototpe set in ExternalSignerConfigError add more descriptive debug msg Ticket: BG-42470 --- modules/express/src/clientRoutes.ts | 12 +----------- modules/express/src/errors.ts | 1 - modules/express/src/expressApp.ts | 6 +----- 3 files changed, 2 insertions(+), 17 deletions(-) diff --git a/modules/express/src/clientRoutes.ts b/modules/express/src/clientRoutes.ts index 36cfec4d51..12eeed8f9a 100755 --- a/modules/express/src/clientRoutes.ts +++ b/modules/express/src/clientRoutes.ts @@ -115,7 +115,6 @@ function handleSendCoins(req: express.Request) { .wallets() .get({ id: req.params.id }) .then(function (wallet) { - // signs a tx, needs custom signing function passed in return wallet.sendCoins(req.body); }) .catch(function (err) { @@ -139,7 +138,6 @@ function handleSendMany(req: express.Request) { .wallets() .get({ id: req.params.id }) .then(function (wallet) { - // signs a tx, needs custom signing function passed in return wallet.sendMany(req.body); }) .catch(function (err) { @@ -180,7 +178,6 @@ function handleSignTransaction(req: express.Request) { .wallets() .get({ id: req.params.id }) .then(function (wallet) { - // signs a tx, needs custom signing function passed in return wallet.signTransaction(req.body); }); } @@ -248,7 +245,6 @@ function handleConsolidateUnspents(req: express.Request) { .wallets() .get({ id: req.params.id }) .then(function (wallet) { - // signs a tx, needs custom signing function passed in return wallet.consolidateUnspents(req.body); }); } @@ -262,7 +258,6 @@ function handleFanOutUnspents(req: express.Request) { .wallets() .get({ id: req.params.id }) .then(function (wallet) { - // signs a tx, needs custom signing function passed in return wallet.fanOutUnspents(req.body); }); } @@ -371,10 +366,6 @@ function handleCanonicalAddress(req: express.Request) { return (coin as Coin.Bch | Coin.Bsv | Coin.Ltc).canonicalAddress(address, version || fallbackVersion); } -function handleV1Sign(req: express.Request) { - throw new Error('not yet implemented'); -} - export async function handleV2Sign(req: express.Request) { const walletId = req.body.txPrebuild.walletId; const path = req.config.signerFileSystemPath; @@ -1016,7 +1007,6 @@ export function setupAPIRoutes(app: express.Application, config: Config): void { } export function setupSigningRoutes(app: express.Application, config: Config): void { - app.post('/api/v1/sign', parseBody, prepareBitGo(config), promiseWrapper(handleV1Sign)); app.post('/api/v2/:coin/sign', parseBody, prepareBitGo(config), promiseWrapper(handleV2Sign)); } @@ -1033,7 +1023,7 @@ export function createCustomSigningFunction(externalSignerUrl: string): CustomSi .type('json') .send({ txPrebuild: params.txPrebuild, pubs: params.pubs }), (err, tryCount) => { - console.error(`attempt number ${tryCount}`); + debug(`failed to connect to external signer (attempt ${tryCount}, error: ${err.message})`); } ); return signedTx; diff --git a/modules/express/src/errors.ts b/modules/express/src/errors.ts index ab45c8687d..dc24377d41 100644 --- a/modules/express/src/errors.ts +++ b/modules/express/src/errors.ts @@ -44,6 +44,5 @@ export class IpcError extends Errors.BitGoJsError { export class ExternalSignerConfigError extends Errors.BitGoJsError { public constructor(message?: string) { super(message || 'External signer configuration is invalid'); - Object.setPrototypeOf(this, ExternalSignerConfigError.prototype); } } diff --git a/modules/express/src/expressApp.ts b/modules/express/src/expressApp.ts index 0ecc89a9fc..1367ab2f93 100644 --- a/modules/express/src/expressApp.ts +++ b/modules/express/src/expressApp.ts @@ -234,11 +234,7 @@ function checkPreconditions(config: Config) { } if (signerFileSystemPath !== undefined) { - try { - checkSignerPrvPath(signerFileSystemPath); - } catch (e) { - throw e; - } + checkSignerPrvPath(signerFileSystemPath); } }