From 36deabb22dab6b18f4de255b1673ab20f9a31424 Mon Sep 17 00:00:00 2001 From: Hugh Cunningham <57735705+hughy@users.noreply.github.com> Date: Wed, 18 Sep 2024 17:53:20 -0700 Subject: [PATCH] fixes errors in wallet/multisig/importParticipant (#5385) throws RPC errors with recognizable error codes allows CLI to hadnle RPC errors more easily --- .../wallet/multisig/importParticipant.test.ts | 4 +--- .../wallet/multisig/importParticipant.ts | 23 ++++++++++++------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/ironfish/src/rpc/routes/wallet/multisig/importParticipant.test.ts b/ironfish/src/rpc/routes/wallet/multisig/importParticipant.test.ts index e004606d9e..6d7e782aec 100644 --- a/ironfish/src/rpc/routes/wallet/multisig/importParticipant.test.ts +++ b/ironfish/src/rpc/routes/wallet/multisig/importParticipant.test.ts @@ -28,9 +28,7 @@ describe('Route wallet/multisig/importParticipant', () => { ).rejects.toThrow( expect.objectContaining({ message: expect.stringContaining( - `Multisig participant already exists for the identity ${identity - .serialize() - .toString('hex')}`, + `Multisig identity ${identity.serialize().toString('hex')} already exists`, ), status: 400, }), diff --git a/ironfish/src/rpc/routes/wallet/multisig/importParticipant.ts b/ironfish/src/rpc/routes/wallet/multisig/importParticipant.ts index db07f7dd5e..0e1de10590 100644 --- a/ironfish/src/rpc/routes/wallet/multisig/importParticipant.ts +++ b/ironfish/src/rpc/routes/wallet/multisig/importParticipant.ts @@ -2,11 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ import * as yup from 'yup' -import { - DuplicateAccountNameError, - DuplicateIdentityError, - DuplicateIdentityNameError, -} from '../../../../wallet/errors' +import { RPC_ERROR_CODES, RpcValidationError } from '../../../adapters' import { ApiNamespace } from '../../namespaces' import { routes } from '../../router' import { AssertHasRpcContext } from '../../rpcContext' @@ -42,7 +38,11 @@ routes.register