Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions modules/express/src/clientRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -995,11 +995,11 @@ export async function handleV2PrebuildAndSignTransaction(
* Enables tokens on a wallet
* @param req
*/
export async function handleV2EnableTokens(req: express.Request) {
export async function handleV2EnableTokens(req: ExpressApiRouteRequest<'express.v2.wallet.enableTokens', 'post'>) {
const bitgo = req.bitgo;
const coin = bitgo.coin(req.params.coin);
const coin = bitgo.coin(req.decoded.coin);
const reqId = new RequestTracer();
const wallet = await coin.wallets().get({ id: req.params.id, reqId });
const wallet = await coin.wallets().get({ id: req.decoded.id, reqId });
req.body.reqId = reqId;
try {
return wallet.sendTokenEnablements(createSendParams(req));
Expand Down Expand Up @@ -1653,12 +1653,7 @@ export function setupAPIRoutes(app: express.Application, config: Config): void {
]);

// token enablement
app.post(
'/api/v2/:coin/wallet/:id/enableTokens',
parseBody,
prepareBitGo(config),
promiseWrapper(handleV2EnableTokens)
);
router.post('express.v2.wallet.enableTokens', [prepareBitGo(config), typedPromiseWrapper(handleV2EnableTokens)]);

// unspent changes
router.post('express.v2.wallet.consolidateunspents', [
Expand Down
9 changes: 9 additions & 0 deletions modules/express/src/typedRoutes/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import { PostLightningWalletWithdraw } from './v2/lightningWithdraw';
import { PutV2PendingApproval } from './v2/pendingApproval';
import { PostConsolidateAccount } from './v2/consolidateAccount';
import { PostCanonicalAddress } from './v2/canonicalAddress';
import { PostWalletEnableTokens } from './v2/walletEnableTokens';
import { PostWalletSweep } from './v2/walletSweep';

// Too large types can cause the following error
Expand Down Expand Up @@ -246,6 +247,12 @@ export const ExpressWalletRecoverTokenApiSpec = apiSpec({
},
});

export const ExpressWalletEnableTokensApiSpec = apiSpec({
'express.v2.wallet.enableTokens': {
post: PostWalletEnableTokens,
},
});

export const ExpressCoinSigningApiSpec = apiSpec({
'express.v2.coin.signtx': {
post: PostCoinSignTx,
Expand Down Expand Up @@ -327,6 +334,7 @@ export type ExpressApi = typeof ExpressPingApiSpec &
typeof ExpressV2WalletSendCoinsApiSpec &
typeof ExpressOfcSignPayloadApiSpec &
typeof ExpressWalletRecoverTokenApiSpec &
typeof ExpressWalletEnableTokensApiSpec &
typeof ExpressCoinSigningApiSpec &
typeof ExpressExternalSigningApiSpec &
typeof ExpressWalletSigningApiSpec &
Expand Down Expand Up @@ -365,6 +373,7 @@ export const ExpressApi: ExpressApi = {
...ExpressV2WalletSendCoinsApiSpec,
...ExpressOfcSignPayloadApiSpec,
...ExpressWalletRecoverTokenApiSpec,
...ExpressWalletEnableTokensApiSpec,
...ExpressCoinSigningApiSpec,
...ExpressExternalSigningApiSpec,
...ExpressWalletSigningApiSpec,
Expand Down
Loading