Skip to content

Commit 1222063

Browse files
authored
feat(express): migrated accelerateTx to type route
2 parents 02282df + 343dc5e commit 1222063

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
@@ -854,10 +854,10 @@ async function handleV2Sweep(req: ExpressApiRouteRequest<'express.v2.wallet.swee
854854
* handle CPFP accelerate transaction creation
855855
* @param req
856856
*/
857-
async function handleV2AccelerateTransaction(req: express.Request) {
857+
async function handleV2AccelerateTransaction(req: ExpressApiRouteRequest<'express.v2.wallet.accelerateTx', 'post'>) {
858858
const bitgo = req.bitgo;
859-
const coin = bitgo.coin(req.params.coin);
860-
const wallet = await coin.wallets().get({ id: req.params.id });
859+
const coin = bitgo.coin(req.decoded.coin);
860+
const wallet = await coin.wallets().get({ id: req.decoded.id });
861861
return wallet.accelerateTransaction(createSendParams(req));
862862
}
863863

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

16841684
// CPFP
1685-
app.post(
1686-
'/api/v2/:coin/wallet/:id/acceleratetx',
1687-
parseBody,
1685+
router.post('express.v2.wallet.accelerateTx', [
16881686
prepareBitGo(config),
1689-
promiseWrapper(handleV2AccelerateTransaction)
1690-
);
1687+
typedPromiseWrapper(handleV2AccelerateTransaction),
1688+
]);
16911689

16921690
// account-based
16931691
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
@@ -48,6 +48,7 @@ import { PostConsolidateAccount } from './v2/consolidateAccount';
4848
import { PostCanonicalAddress } from './v2/canonicalAddress';
4949
import { PostWalletEnableTokens } from './v2/walletEnableTokens';
5050
import { PostWalletSweep } from './v2/walletSweep';
51+
import { PostWalletAccelerateTx } from './v2/walletAccelerateTx';
5152
import { PostIsWalletAddress } from './v2/isWalletAddress';
5253

5354
// Too large types can cause the following error
@@ -311,6 +312,12 @@ export const ExpressV2WalletSweepApiSpec = apiSpec({
311312
},
312313
});
313314

315+
export const ExpressV2WalletAccelerateTxApiSpec = apiSpec({
316+
'express.v2.wallet.accelerateTx': {
317+
post: PostWalletAccelerateTx,
318+
},
319+
});
320+
314321
export type ExpressApi = typeof ExpressPingApiSpec &
315322
typeof ExpressPingExpressApiSpec &
316323
typeof ExpressLoginApiSpec &
@@ -348,6 +355,7 @@ export type ExpressApi = typeof ExpressPingApiSpec &
348355
typeof ExpressWalletSigningApiSpec &
349356
typeof ExpressV2CanonicalAddressApiSpec &
350357
typeof ExpressV2WalletSweepApiSpec &
358+
typeof ExpressV2WalletAccelerateTxApiSpec &
351359
typeof ExpressWalletManagementApiSpec;
352360

353361
export const ExpressApi: ExpressApi = {
@@ -388,6 +396,7 @@ export const ExpressApi: ExpressApi = {
388396
...ExpressWalletSigningApiSpec,
389397
...ExpressV2CanonicalAddressApiSpec,
390398
...ExpressV2WalletSweepApiSpec,
399+
...ExpressV2WalletAccelerateTxApiSpec,
391400
...ExpressWalletManagementApiSpec,
392401
};
393402

0 commit comments

Comments
 (0)