From 83003de987b49b5c462d08623d6687501958e4b5 Mon Sep 17 00:00:00 2001 From: Alejandro Busse Date: Fri, 8 Dec 2023 14:53:42 -0300 Subject: [PATCH] feat(root): whitelist apiVersion for buildAccountConsolidations In order to start migrating TSS EdDSA to full txRequest, we need to allow this param to be passed to use txRequest full, similar on how we do for sendMany WP-1123 TICKET: WP-1123 --- modules/express/src/clientRoutes.ts | 2 +- .../unit/clientRoutes/consolidateAccount.ts | 19 +++++++++++++++++++ modules/sdk-core/src/bitgo/wallet/wallet.ts | 1 + 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/modules/express/src/clientRoutes.ts b/modules/express/src/clientRoutes.ts index 8b520f5384..62e96d9ef9 100755 --- a/modules/express/src/clientRoutes.ts +++ b/modules/express/src/clientRoutes.ts @@ -826,7 +826,7 @@ function createSendParams(req: express.Request) { } function createTSSSendParams(req: express.Request) { - if (req.config.externalSignerUrl !== undefined) { + if (req.config?.externalSignerUrl !== undefined) { const coin = req.bitgo.coin(req.params.coin); if (coin.getMPCAlgorithm() === MPCType.EDDSA) { return { diff --git a/modules/express/test/unit/clientRoutes/consolidateAccount.ts b/modules/express/test/unit/clientRoutes/consolidateAccount.ts index 7cb7cc6e50..2ef7553f75 100644 --- a/modules/express/test/unit/clientRoutes/consolidateAccount.ts +++ b/modules/express/test/unit/clientRoutes/consolidateAccount.ts @@ -104,6 +104,25 @@ describe('Consolidate account', () => { consolidationStub.should.be.calledOnceWith(body); }); + it('should pass the apiVersion param to bitgo api consolidate/build', async () => { + const result = { success: [], failure: [] }; + const body = { apiVersion: 'full' }; + const { bitgoStub, consolidationStub } = createConsolidateMocks(result, true, true); + const mockRequest = { + bitgo: bitgoStub, + params: { + coin: 'tsol', + id: '23423423423423', + }, + body, + }; + + await handleV2ConsolidateAccount(mockRequest as express.Request & typeof mockRequest).should.be.resolvedWith( + result + ); + consolidationStub.should.be.calledOnceWith(body); + }); + it('should return 202 when some transactions fail', async () => { const result = { success: [0], failure: [0] }; const body = 'testbody'; diff --git a/modules/sdk-core/src/bitgo/wallet/wallet.ts b/modules/sdk-core/src/bitgo/wallet/wallet.ts index eb3cb42d1c..3e5c7528f0 100644 --- a/modules/sdk-core/src/bitgo/wallet/wallet.ts +++ b/modules/sdk-core/src/bitgo/wallet/wallet.ts @@ -196,6 +196,7 @@ export class Wallet implements IWallet { 'validToBlock', 'preview', 'keepAlive', + 'apiVersion', ]; }