Skip to content

Commit f8f186c

Browse files
committed
feat(express): migrated wallet enableTokens to type route
Ticket: WP-5429
1 parent 001c662 commit f8f186c

File tree

5 files changed

+1573
-13
lines changed

5 files changed

+1573
-13
lines changed

modules/express/src/clientRoutes.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -995,11 +995,11 @@ export async function handleV2PrebuildAndSignTransaction(
995995
* Enables tokens on a wallet
996996
* @param req
997997
*/
998-
export async function handleV2EnableTokens(req: express.Request) {
998+
export async function handleV2EnableTokens(req: ExpressApiRouteRequest<'express.v2.wallet.enableTokens', 'post'>) {
999999
const bitgo = req.bitgo;
1000-
const coin = bitgo.coin(req.params.coin);
1000+
const coin = bitgo.coin(req.decoded.coin);
10011001
const reqId = new RequestTracer();
1002-
const wallet = await coin.wallets().get({ id: req.params.id, reqId });
1002+
const wallet = await coin.wallets().get({ id: req.decoded.id, reqId });
10031003
req.body.reqId = reqId;
10041004
try {
10051005
return wallet.sendTokenEnablements(createSendParams(req));
@@ -1653,12 +1653,7 @@ export function setupAPIRoutes(app: express.Application, config: Config): void {
16531653
]);
16541654

16551655
// token enablement
1656-
app.post(
1657-
'/api/v2/:coin/wallet/:id/enableTokens',
1658-
parseBody,
1659-
prepareBitGo(config),
1660-
promiseWrapper(handleV2EnableTokens)
1661-
);
1656+
router.post('express.v2.wallet.enableTokens', [prepareBitGo(config), typedPromiseWrapper(handleV2EnableTokens)]);
16621657

16631658
// unspent changes
16641659
router.post('express.v2.wallet.consolidateunspents', [

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import { PostLightningWalletWithdraw } from './v2/lightningWithdraw';
4646
import { PutV2PendingApproval } from './v2/pendingApproval';
4747
import { PostConsolidateAccount } from './v2/consolidateAccount';
4848
import { PostCanonicalAddress } from './v2/canonicalAddress';
49+
import { PostWalletEnableTokens } from './v2/walletEnableTokens';
4950

5051
// Too large types can cause the following error
5152
//
@@ -245,6 +246,12 @@ export const ExpressWalletRecoverTokenApiSpec = apiSpec({
245246
},
246247
});
247248

249+
export const ExpressWalletEnableTokensApiSpec = apiSpec({
250+
'express.v2.wallet.enableTokens': {
251+
post: PostWalletEnableTokens,
252+
},
253+
});
254+
248255
export const ExpressCoinSigningApiSpec = apiSpec({
249256
'express.v2.coin.signtx': {
250257
post: PostCoinSignTx,
@@ -320,6 +327,7 @@ export type ExpressApi = typeof ExpressPingApiSpec &
320327
typeof ExpressV2WalletSendCoinsApiSpec &
321328
typeof ExpressOfcSignPayloadApiSpec &
322329
typeof ExpressWalletRecoverTokenApiSpec &
330+
typeof ExpressWalletEnableTokensApiSpec &
323331
typeof ExpressCoinSigningApiSpec &
324332
typeof ExpressExternalSigningApiSpec &
325333
typeof ExpressWalletSigningApiSpec &
@@ -357,6 +365,7 @@ export const ExpressApi: ExpressApi = {
357365
...ExpressV2WalletSendCoinsApiSpec,
358366
...ExpressOfcSignPayloadApiSpec,
359367
...ExpressWalletRecoverTokenApiSpec,
368+
...ExpressWalletEnableTokensApiSpec,
360369
...ExpressCoinSigningApiSpec,
361370
...ExpressExternalSigningApiSpec,
362371
...ExpressWalletSigningApiSpec,

0 commit comments

Comments
 (0)