Skip to content

Commit 4f0014c

Browse files
committed
feat(express): migrated sendmany as type route
Ticket: WP-5427
1 parent 48664f3 commit 4f0014c

File tree

4 files changed

+1327
-4
lines changed

4 files changed

+1327
-4
lines changed

modules/express/src/clientRoutes.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -935,11 +935,11 @@ async function handleV2SendOne(req: express.Request) {
935935
* handle send many
936936
* @param req
937937
*/
938-
async function handleV2SendMany(req: express.Request) {
938+
async function handleV2SendMany(req: ExpressApiRouteRequest<'express.v2.wallet.sendmany', 'post'>) {
939939
const bitgo = req.bitgo;
940-
const coin = bitgo.coin(req.params.coin);
940+
const coin = bitgo.coin(req.decoded.coin);
941941
const reqId = new RequestTracer();
942-
const wallet = await coin.wallets().get({ id: req.params.id, reqId });
942+
const wallet = await coin.wallets().get({ id: req.decoded.id, reqId });
943943
req.body.reqId = reqId;
944944
let result;
945945
try {
@@ -1639,7 +1639,7 @@ export function setupAPIRoutes(app: express.Application, config: Config): void {
16391639

16401640
// send transaction
16411641
app.post('/api/v2/:coin/wallet/:id/sendcoins', parseBody, prepareBitGo(config), promiseWrapper(handleV2SendOne));
1642-
app.post('/api/v2/:coin/wallet/:id/sendmany', parseBody, prepareBitGo(config), promiseWrapper(handleV2SendMany));
1642+
router.post('express.v2.wallet.sendmany', [prepareBitGo(config), typedPromiseWrapper(handleV2SendMany)]);
16431643
app.post(
16441644
'/api/v2/:coin/wallet/:id/prebuildAndSignTransaction',
16451645
parseBody,

modules/express/src/typedRoutes/api/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import { PostWalletTxSignTSS } from './v2/walletTxSignTSS';
3434
import { PostShareWallet } from './v2/shareWallet';
3535
import { PutExpressWalletUpdate } from './v2/expressWalletUpdate';
3636
import { PostFanoutUnspents } from './v2/fanoutUnspents';
37+
import { PostSendMany } from './v2/sendmany';
3738
import { PostConsolidateUnspents } from './v2/consolidateunspents';
3839

3940
// Too large types can cause the following error
@@ -156,6 +157,12 @@ export const ExpressV2WalletCreateAddressApiSpec = apiSpec({
156157
},
157158
});
158159

160+
export const ExpressV2WalletSendManyApiSpec = apiSpec({
161+
'express.v2.wallet.sendmany': {
162+
post: PostSendMany,
163+
},
164+
});
165+
159166
export const ExpressKeychainLocalApiSpec = apiSpec({
160167
'express.keychain.local': {
161168
post: PostKeychainLocal,
@@ -236,6 +243,7 @@ export type ExpressApi = typeof ExpressPingApiSpec &
236243
typeof ExpressLightningGetStateApiSpec &
237244
typeof ExpressLightningInitWalletApiSpec &
238245
typeof ExpressLightningUnlockWalletApiSpec &
246+
typeof ExpressV2WalletSendManyApiSpec &
239247
typeof ExpressOfcSignPayloadApiSpec;
240248

241249
export const ExpressApi: ExpressApi = {
@@ -262,6 +270,7 @@ export const ExpressApi: ExpressApi = {
262270
...ExpressLightningGetStateApiSpec,
263271
...ExpressLightningInitWalletApiSpec,
264272
...ExpressLightningUnlockWalletApiSpec,
273+
...ExpressV2WalletSendManyApiSpec,
265274
...ExpressOfcSignPayloadApiSpec,
266275
};
267276

0 commit comments

Comments
 (0)