Skip to content

Commit d198116

Browse files
committed
refactor: removed any type cast and added reponse const variable
TICKET: WP-5445
1 parent 15e19aa commit d198116

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
@@ -129,7 +129,7 @@ describe('Lightning signer routes', () => {
129129
config: {
130130
lightningSignerFileSystemPath: 'lightningSignerFileSystemPath',
131131
},
132-
} as any;
132+
} as unknown as ExpressApiRouteRequest<'express.lightning.signerMacaroon', 'post'>;
133133

134134
try {
135135
await handleCreateSignerMacaroon(req);

0 commit comments

Comments
 (0)