Skip to content

Commit 5a7e6f5

Browse files
committed
refactor: removed any type cast and added reponse const variable
TICKET: WP-5445
1 parent 7e45d7c commit 5a7e6f5

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

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

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { BitgoExpressError } from '../../schemas/error';
1010
export const SignerMacaroonParams = {
1111
coin: t.string,
1212
walletId: t.string,
13-
};
13+
} as const;
1414

1515
/**
1616
* Request body for creating a signer macaroon
@@ -20,7 +20,19 @@ export const SignerMacaroonParams = {
2020
export const SignerMacaroonBody = {
2121
passphrase: t.string,
2222
addIpCaveatToMacaroon: optional(t.boolean),
23-
};
23+
} as const;
24+
25+
/**
26+
* Response
27+
* - 200: Returns the updated wallet. On success, the wallet's `coinSpecific` includes the generated signer macaroon (derived from the signer node admin macaroon), optionally with an IP caveat.
28+
* - 400: BitGo Express error payload when macaroon creation cannot proceed (e.g., invalid coin, wallet not self‑custody lightning, missing encrypted signer admin macaroon, or external IP not set when an IP caveat is requested).
29+
*
30+
* See platform spec: POST /api/v2/{coin}/wallet/{walletId}/signermacaroon
31+
*/
32+
export const SignerMacaroonResponse = {
33+
200: t.UnknownRecord,
34+
400: BitgoExpressError,
35+
} as const;
2436

2537
/**
2638
* Lightning - Create signer macaroon
@@ -36,8 +48,5 @@ export const PostSignerMacaroon = httpRoute({
3648
params: SignerMacaroonParams,
3749
body: SignerMacaroonBody,
3850
}),
39-
response: {
40-
200: t.UnknownRecord,
41-
400: BitgoExpressError,
42-
},
51+
response: SignerMacaroonResponse,
4352
});

modules/express/test/unit/clientRoutes/lightning/lightningSignerRoutes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ describe('Lightning signer routes', () => {
142142
config: {
143143
lightningSignerFileSystemPath: 'lightningSignerFileSystemPath',
144144
},
145-
} as any;
145+
} as unknown as ExpressApiRouteRequest<'express.lightning.signerMacaroon', 'post'>;
146146

147147
try {
148148
await handleCreateSignerMacaroon(req);

0 commit comments

Comments
 (0)