Skip to content

Commit abd87a9

Browse files
committed
refactor: includeKeychain is type BooleanFromString
TICKET: WP-5415
1 parent 70d48ad commit abd87a9

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

modules/express/src/clientRoutes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ export async function handleV2GenerateWallet(req: ExpressApiRouteRequest<'expres
641641
const bitgo = req.bitgo;
642642
const coin = bitgo.coin(req.decoded.coin);
643643
const result = await coin.wallets().generateWallet(req.body);
644-
if (req.query.includeKeychains === 'false') {
644+
if ((req.decoded.includeKeychains as any) === false) {
645645
return result.wallet.toJSON();
646646
}
647647
return { ...result, wallet: result.wallet.toJSON() };

modules/express/src/typedRoutes/api/v2/generateWallet.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as t from 'io-ts';
2+
import { BooleanFromString } from 'io-ts-types';
23
import { httpRoute, httpRequest, optional } from '@api-ts/io-ts-http';
34
import { BitgoExpressError } from '../../schemas/error';
45
import { UserKeychainCodec, BackupKeychainCodec, BitgoKeychainCodec } from '../../schemas/keychain';
@@ -80,7 +81,7 @@ export const GenerateWalletV2Params = {
8081
*/
8182
export const GenerateWalletV2Query = {
8283
/** Include user, backup and bitgo keychains along with generated wallet */
83-
includeKeychains: optional(t.string),
84+
includeKeychains: optional(BooleanFromString),
8485
};
8586

8687
/**

modules/express/test/unit/clientRoutes/generateWallet.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,13 @@ describe('Generate Wallet', () => {
101101
coin,
102102
},
103103
query: {
104-
includeKeychains: 'true',
104+
includeKeychains: true,
105105
},
106106
body: walletGenerateBody,
107107
decoded: {
108108
...walletGenerateBody,
109109
coin,
110+
includeKeychains: true,
110111
},
111112
} as unknown as ExpressApiRouteRequest<'express.wallet.generate', 'post'>;
112113

@@ -186,12 +187,13 @@ describe('Generate Wallet', () => {
186187
coin,
187188
},
188189
query: {
189-
includeKeychains: 'false',
190+
includeKeychains: false,
190191
},
191192
body: walletGenerateBody,
192193
decoded: {
193194
...walletGenerateBody,
194195
coin,
196+
includeKeychains: false,
195197
},
196198
} as unknown as ExpressApiRouteRequest<'express.wallet.generate', 'post'>;
197199

0 commit comments

Comments
 (0)