Skip to content

Commit d0f6665

Browse files
committed
feat(express): migrated accelerateTx to type route
Ticket: WP-5433
1 parent d2b84fc commit d0f6665

File tree

4 files changed

+1590
-8
lines changed

4 files changed

+1590
-8
lines changed

modules/express/src/clientRoutes.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -841,10 +841,10 @@ async function handleV2Sweep(req: ExpressApiRouteRequest<'express.v2.wallet.swee
841841
* handle CPFP accelerate transaction creation
842842
* @param req
843843
*/
844-
async function handleV2AccelerateTransaction(req: express.Request) {
844+
async function handleV2AccelerateTransaction(req: ExpressApiRouteRequest<'express.v2.wallet.accelerateTx', 'post'>) {
845845
const bitgo = req.bitgo;
846-
const coin = bitgo.coin(req.params.coin);
847-
const wallet = await coin.wallets().get({ id: req.params.id });
846+
const coin = bitgo.coin(req.decoded.coin);
847+
const wallet = await coin.wallets().get({ id: req.decoded.id });
848848
return wallet.accelerateTransaction(createSendParams(req));
849849
}
850850

@@ -1670,12 +1670,10 @@ export function setupAPIRoutes(app: express.Application, config: Config): void {
16701670
router.post('express.v2.wallet.sweep', [prepareBitGo(config), typedPromiseWrapper(handleV2Sweep)]);
16711671

16721672
// CPFP
1673-
app.post(
1674-
'/api/v2/:coin/wallet/:id/acceleratetx',
1675-
parseBody,
1673+
router.post('express.v2.wallet.accelerateTx', [
16761674
prepareBitGo(config),
1677-
promiseWrapper(handleV2AccelerateTransaction)
1678-
);
1675+
typedPromiseWrapper(handleV2AccelerateTransaction),
1676+
]);
16791677

16801678
// account-based
16811679
router.post('express.v2.wallet.consolidateaccount', [

modules/express/src/typedRoutes/api/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import { PutV2PendingApproval } from './v2/pendingApproval';
4747
import { PostConsolidateAccount } from './v2/consolidateAccount';
4848
import { PostCanonicalAddress } from './v2/canonicalAddress';
4949
import { PostWalletSweep } from './v2/walletSweep';
50+
import { PostWalletAccelerateTx } from './v2/walletAccelerateTx';
5051

5152
// Too large types can cause the following error
5253
//
@@ -297,6 +298,12 @@ export const ExpressV2WalletSweepApiSpec = apiSpec({
297298
},
298299
});
299300

301+
export const ExpressV2WalletAccelerateTxApiSpec = apiSpec({
302+
'express.v2.wallet.accelerateTx': {
303+
post: PostWalletAccelerateTx,
304+
},
305+
});
306+
300307
export type ExpressApi = typeof ExpressPingApiSpec &
301308
typeof ExpressPingExpressApiSpec &
302309
typeof ExpressLoginApiSpec &
@@ -332,6 +339,7 @@ export type ExpressApi = typeof ExpressPingApiSpec &
332339
typeof ExpressWalletSigningApiSpec &
333340
typeof ExpressV2CanonicalAddressApiSpec &
334341
typeof ExpressV2WalletSweepApiSpec &
342+
typeof ExpressV2WalletAccelerateTxApiSpec &
335343
typeof ExpressWalletManagementApiSpec;
336344

337345
export const ExpressApi: ExpressApi = {
@@ -370,6 +378,7 @@ export const ExpressApi: ExpressApi = {
370378
...ExpressWalletSigningApiSpec,
371379
...ExpressV2CanonicalAddressApiSpec,
372380
...ExpressV2WalletSweepApiSpec,
381+
...ExpressV2WalletAccelerateTxApiSpec,
373382
...ExpressWalletManagementApiSpec,
374383
};
375384

0 commit comments

Comments
 (0)