Skip to content

Commit 66505b9

Browse files
authored
feat(express): migrated wallet enableTokens to type route
2 parents 4794167 + 1708658 commit 66505b9

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
@@ -1008,11 +1008,11 @@ export async function handleV2PrebuildAndSignTransaction(
10081008
* Enables tokens on a wallet
10091009
* @param req
10101010
*/
1011-
export async function handleV2EnableTokens(req: express.Request) {
1011+
export async function handleV2EnableTokens(req: ExpressApiRouteRequest<'express.v2.wallet.enableTokens', 'post'>) {
10121012
const bitgo = req.bitgo;
1013-
const coin = bitgo.coin(req.params.coin);
1013+
const coin = bitgo.coin(req.decoded.coin);
10141014
const reqId = new RequestTracer();
1015-
const wallet = await coin.wallets().get({ id: req.params.id, reqId });
1015+
const wallet = await coin.wallets().get({ id: req.decoded.id, reqId });
10161016
req.body.reqId = reqId;
10171017
try {
10181018
return wallet.sendTokenEnablements(createSendParams(req));
@@ -1670,12 +1670,7 @@ export function setupAPIRoutes(app: express.Application, config: Config): void {
16701670
]);
16711671

16721672
// token enablement
1673-
app.post(
1674-
'/api/v2/:coin/wallet/:id/enableTokens',
1675-
parseBody,
1676-
prepareBitGo(config),
1677-
promiseWrapper(handleV2EnableTokens)
1678-
);
1673+
router.post('express.v2.wallet.enableTokens', [prepareBitGo(config), typedPromiseWrapper(handleV2EnableTokens)]);
16791674

16801675
// unspent changes
16811676
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
import { PostWalletSweep } from './v2/walletSweep';
5051
import { PostIsWalletAddress } from './v2/isWalletAddress';
5152

@@ -253,6 +254,12 @@ export const ExpressWalletRecoverTokenApiSpec = apiSpec({
253254
},
254255
});
255256

257+
export const ExpressWalletEnableTokensApiSpec = apiSpec({
258+
'express.v2.wallet.enableTokens': {
259+
post: PostWalletEnableTokens,
260+
},
261+
});
262+
256263
export const ExpressCoinSigningApiSpec = apiSpec({
257264
'express.v2.coin.signtx': {
258265
post: PostCoinSignTx,
@@ -335,6 +342,7 @@ export type ExpressApi = typeof ExpressPingApiSpec &
335342
typeof ExpressV2WalletSendCoinsApiSpec &
336343
typeof ExpressOfcSignPayloadApiSpec &
337344
typeof ExpressWalletRecoverTokenApiSpec &
345+
typeof ExpressWalletEnableTokensApiSpec &
338346
typeof ExpressCoinSigningApiSpec &
339347
typeof ExpressExternalSigningApiSpec &
340348
typeof ExpressWalletSigningApiSpec &
@@ -374,6 +382,7 @@ export const ExpressApi: ExpressApi = {
374382
...ExpressV2WalletSendCoinsApiSpec,
375383
...ExpressOfcSignPayloadApiSpec,
376384
...ExpressWalletRecoverTokenApiSpec,
385+
...ExpressWalletEnableTokensApiSpec,
377386
...ExpressCoinSigningApiSpec,
378387
...ExpressExternalSigningApiSpec,
379388
...ExpressWalletSigningApiSpec,

0 commit comments

Comments
 (0)